Membuat Antrian PTSP cetak antrian part 3

Bismillahirrahmanirrahim

Berikut adalah update dari source code sebelumnya, yang perlu di update hanya beberapa code saja, diantaranya

views v_antrian_depan.php (application/tray_app/antrian_depan/views)

<?php 
  $fav = $this->db->query("SELECT gambar FROM tbl_pengaturan WHERE id = 7")->row()->gambar;
  $sistem = $this->db->query("SELECT * FROM tbl_pengaturan WHERE id = 14")->row();
  $instansi = $this->db->query("SELECT * FROM tbl_pengaturan WHERE id = 11")->row();
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title><?php echo $sistem->judul.' | '.$sistem->deskripsi;?></title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<!--=================================================================-->
  <link rel="icon" type="image/png" href="<?php echo base_url('img/'.$fav);?>"/>
<!--=================================================================-->
  <link rel="stylesheet" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css');?>">
  <link rel="stylesheet" href="<?php echo base_url();?>bower_components/font-awesome/css/font-awesome.min.css">

</head>
<body>
<div class="container">
<h1 align="center">SELAMAT DATANG DI PTSP<br/>
<?php echo strtoupper($instansi->keterangan);?></h1>
<hr/>
<div class="row" style="text-align: center;">
  <form class="col-md alert btn-lg btn-info" action="<?php echo $link_informasi;?>" method="POST">
  <input type="hidden" name="ad_jenis_id" value="1">
  <button type="submit" class="col-md alert btn-lg btn-info" style="height: 300px;color:white;">
    <b style="font-size:30px;">MEJA<br/>INFORMASI</b><br/><br/>
    <i class="fa fa-info-circle" style="font-size:40px;"></i><br/><br/>
    <div class="btn btn-lg btn-block btn-danger">AMBIL ANTRIAN</div>
  </button>
  </form>
  <form class="col-md alert btn-lg btn-success" action="<?php echo $link_pendaftaran;?>" method="POST">
  <input type="hidden" name="ad_jenis_id" value="2">
  <button class="col-md alert btn-lg btn-success" style="height: 300px;color:white;">
    <b style="font-size:30px;">PENDAFTARAN<br/>PERKARA</b><br/><br/>
    <i class="fa fa-book" style="font-size:40px;"></i><br/><br/>
    <a href="#" class="btn btn-lg btn-block btn-warning" style="color:white;">AMBIL ANTRIAN</a>
  </button>
  </form>
  <form class="col-md alert btn-lg btn-warning" action="<?php echo $link_produk;?>" method="POST">
  <input type="hidden" name="ad_jenis_id" value="3">
  <button class="col-md alert btn-lg btn-warning" style="height: 300px;color:white;">
    <b style="font-size:30px;">PRODUK<br/>PENGADILAN</b><br/><br/>
    <i class="fa fa-file" style="font-size:40px;"></i><br/><br/>
    <a href="#" class="btn btn-lg btn-block btn-success">AMBIL ANTRIAN</a>
  </button>
  </form>
  <form class="col-md alert btn-lg btn-danger" action="<?php echo $link_pengaduan;?>" method="POST">
  <input type="hidden" name="ad_jenis_id" value="4">
  <button class="col-md alert btn-lg btn-danger" style="height: 300px;color:white;">
    <b style="font-size:30px;">LAYANAN<br/>PENGADUAN</b><br/><br/>
    <i class="fa fa-ticket" style="font-size:40px;"></i><br/><br/>
    <a href="#" class="btn btn-lg btn-block btn-info">AMBIL ANTRIAN</a>
  </button>
  </form>
</div>
<hr/>
</div> <!-- end container -->
</body>
</html>

dan controllers Antrian_depan.php (application/tray_app/antrian_depan/controllers)

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Antrian_depan extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
        $this->load->model('Antrian_depan_model');
    }

    public function index()
    {
        $data = array(
           'link_informasi' => site_url('antrian_depan/informasi'),
           'link_pengaduan' => site_url('antrian_depan/pengaduan'),
           'link_pendaftaran' => site_url('antrian_depan/pendaftaran'),
           'link_produk' => site_url('antrian_depan/produk'),
        );
    $this->load->view('antrian_depan/v_antrian_depan',$data);
  }

    public function get_nomor($jenis_id){
        $tahun = date("Y");
        $bulan = date("m");
        $hari  = date("d");
        $query = $this->db->query("SELECT MAX(ad_nomor) as max_id FROM tbl_antrian_depan where YEAR(ad_tgl)='$tahun' AND MONTH(ad_tgl) = '$bulan' AND DAY(ad_tgl) = $hari AND ad_jenis_id = $jenis_id ");
        $row = $query->row_array();
        $max_id = $row['max_id'];
        $max_id1 =(int) substr($max_id,0,3);
        $nomor = $max_id1 +1;
        $maxkode = sprintf("%03s",$nomor);
        return $maxkode;
    }

    public function get_sisa_antrian($jenis_id){
        $tahun = date("Y");
        $bulan = date("m");
        $hari  = date("d");
        $query = $this->db->query("SELECT count(ad_id) as sisa FROM tbl_antrian_depan where YEAR(ad_tgl)='$tahun' AND MONTH(ad_tgl) = '$bulan' AND DAY(ad_tgl) = $hari AND ad_jenis_id = $jenis_id ");
        $sisa = $query->row()->sisa;
        return $sisa;
    }

    public function cetak_antrian(){
        $row = $this->Antrian_depan_model->get_data_cetak();
        if ($row) {
        $data = array(
            'row' => $row,
        );
        $this->load->view('antrian_depan/v_cetak_antrian',$data);
        }else{
            redirect(site_url('antrian_depan'));
        } 
    }
    
    //06-01-2019//
    public function informasi() 
    {
        $ad_jenis_id = $this->input->post('ad_jenis_id',TRUE);
        $ad_jenis_nama = 'MEJA INFORMASI';
        if (empty($ad_jenis_id) OR $ad_jenis_id == '') {
            $this->index();
        } else {
            $data = array(
        'ad_nomor' => $this->get_nomor(1),
        'ad_nomor_panggil' => 'A'.$this->get_nomor(1),
        'ad_jenis_id' => $this->input->post('ad_jenis_id',TRUE),
        'ad_jenis_nama' => $ad_jenis_nama,
        'ad_tgl' => date('Y-m-d H:i:s'),
        'ad_status' => '1',
        'ad_ke' => '',
        'ad_sisa_antrian' => $this->get_sisa_antrian(1),
        );
            $this->Antrian_depan_model->insert($data);
            redirect(site_url('antrian_depan/cetak_antrian'));
        }
    }

    public function pendaftaran() 
    {
        $ad_jenis_id = $this->input->post('ad_jenis_id',TRUE);
        $ad_jenis_nama = 'PENDAFTARAN PERKARA';
        if (empty($ad_jenis_id) OR $ad_jenis_id == '') {
            $this->index();
        } else {
            $data = array(
        'ad_nomor' => $this->get_nomor(2),
        'ad_nomor_panggil' => 'B'.$this->get_nomor(2),
        'ad_jenis_id' => $this->input->post('ad_jenis_id',TRUE),
        'ad_jenis_nama' => $ad_jenis_nama,
        'ad_tgl' => date('Y-m-d H:i:s'),
        'ad_status' => '1',
        'ad_ke' => '',
        'ad_sisa_antrian' => $this->get_sisa_antrian(2),
        );
            $this->Antrian_depan_model->insert($data);
            redirect(site_url('antrian_depan/cetak_antrian'));
        }
    }

    public function produk() 
    {
        $ad_jenis_id = $this->input->post('ad_jenis_id',TRUE);
        $ad_jenis_nama = 'PRODUK PENGADILAN';
        if (empty($ad_jenis_id) OR $ad_jenis_id == '') {
            $this->index();
        } else {
            $data = array(
        'ad_nomor' => $this->get_nomor(3),
        'ad_nomor_panggil' => 'C'.$this->get_nomor(3),
        'ad_jenis_id' => $this->input->post('ad_jenis_id',TRUE),
        'ad_jenis_nama' => $ad_jenis_nama,
        'ad_tgl' => date('Y-m-d H:i:s'),
        'ad_status' => '1',
        'ad_ke' => '',
        'ad_sisa_antrian' => $this->get_sisa_antrian(3),
        );
            $this->Antrian_depan_model->insert($data);
            redirect(site_url('antrian_depan/cetak_antrian'));
        }
    }

    public function pengaduan() 
    {
        $ad_jenis_id = $this->input->post('ad_jenis_id',TRUE);
        $ad_jenis_nama = 'LAYANAN PENGADUAN';
        if (empty($ad_jenis_id) OR $ad_jenis_id == '') {
            $this->index();
        } else {
            $data = array(
        'ad_nomor' => $this->get_nomor(4),
        'ad_nomor_panggil' => 'D'.$this->get_nomor(4),
        'ad_jenis_id' => $this->input->post('ad_jenis_id',TRUE),
        'ad_jenis_nama' => $ad_jenis_nama,
        'ad_tgl' => date('Y-m-d H:i:s'),
        'ad_status' => '1',
        'ad_ke' => '',
        'ad_sisa_antrian' => $this->get_sisa_antrian(4),
        );
            $this->Antrian_depan_model->insert($data);
            redirect(site_url('antrian_depan/cetak_antrian'));
        }
    }

}

selamat mencoba

Recommended For You

About the Author: adyrhs

Leave a Reply

Your email address will not be published. Required fields are marked *