Membuat Antrian PTSP part 2

Bismillahirrahmanirrahim.

UPDATE update source code PTSP pada folder (application/tray_app/pengaturan), download file ini kemudian replace folder pengaturan dan update sekalian (application/tray_app/login) replace folder login

Sebelumnya telah dijelaskan tentang penambahan folder dan file-file di dalam aplikasi PTSP dengan menggunakan framework CodeIgniter dengan menambahkan konfigurasi lainnya sehingga yang awalnya MVC menjadi HMVC.

Sebelum kita lanjut, pada posting sebelumnya di http://it.dewady.com/membuat-antrian-ptsp-part-1/ ada sedikit perubahan di tbl_antrian_depan yang sudah dibuat, tambahkan 2 field (ad_nomor_panggil dan ad_sisa_antrian)pada tabel tersebut sehingga menjadi seperti pada gambar dibawah ini.

sebelum kita lanjut dengan mengupdate code yang sudah dibuat sebelumnya, disini kita menambahkan file baru (models) sebagai query untuk mengeksekusi database di dalam folder (application/tray_app/antrian_depan/models/) buat lah file baru dengan nama Antrian_depan_model.php (huruf depan harus kapital).

isi dari file Antrian_depan_model.php

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

class Antrian_depan_model extends CI_Model
{
    public $table = 'tbl_antrian_depan';
    public $id = 'ad_id';
    public $order = 'DESC';

    function __construct()
    {
        parent::__construct();
    }

    function get_data_cetak(){
    	return $this->db->query("SELECT * FROM tbl_antrian_depan ORDER BY ad_id DESC LIMIT 0,1")->row();
    }

    function insert($data)
    {
        $this->db->insert($this->table, $data);
    }

}

selanjutnya buat lagi file baru didalam folder views (application/tray_app/antria_depan/views/) buat file dengan nama v_cetak_antrian.php

<?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();
  $link_web = $this->db->query("SELECT * FROM tbl_pengaturan WHERE id = 12")->row();

  $hari=date('D');
  if($hari=='Sun'){$hari='Minggu';}
  else if($hari=='Mon'){$hari='Senin';}
  else if($hari=='Tue'){$hari='Selasa';}
  else if($hari=='Wed'){$hari='Rabu';}
  else if($hari=='Thu'){$hari='Kamis';}
  else if($hari=='Fri'){$hari='Jum\'at';}
  else if($hari=='Sat'){$hari='Sabtu';
  }
  
  $bulan=date('m');
  if($bulan=='01'){$bulan='Januari';}
  else if($bulan=='02'){$bulan='Februari';}
  else if($bulan=='03'){$bulan='Maret';}
  else if($bulan=='04'){$bulan='April';}
  else if($bulan=='05'){$bulan='Mei';}
  else if($bulan=='06'){$bulan='Juni';}
  else if($bulan=='07'){$bulan='Juli';}
  else if($bulan=='08'){$bulan='Agustus';}
  else if($bulan=='09'){$bulan='September';}
  else if($bulan=='10'){$bulan='Oktober';}
  else if($bulan=='11'){$bulan='November';}
  else if($bulan=='12'){$bulan='Desember';}
  
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="3; url=<?php echo base_url('antrian_depan');?>">
<textarea id="printing-css" style="display:none;">.no-print{display:none}</textarea>
<iframe id="printing-frame" name="print_frame" src="about:blank" style="display:none;"></iframe>
<script type="text/javascript">
 window.focus();
 window.print();
//}
</script>
</head>
<body>
<div id="print_antrian">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<center>
<table style="width:300px;">
<tr>
<td class="text-center">
<div class="container text-center">
  <div class="row">
    <div class="col-md bg-success" style="padding:10px;text-align:center">
      <div style="font-weight:bold;font-size:20px;padding-bottom:5px;"><?php echo strtoupper($instansi->keterangan);?></div>
      <div style="border-top:1px solid gray;width: 230px;margin-left: auto;margin-right: auto;"></div>
      <div style="padding:5px;font-weight:bold;font-size:15px;"><?php echo $row->ad_jenis_nama;?></div>			
      <div style="font-size:50px;font-weight:bold;padding:5px;">
        <?php echo $row->ad_nomor_panggil;?>
      </div>
      <div style="padding-top:5px;font-size:13px;">
      <?php echo date('d-m-Y H:i:s' ,strtotime($row->ad_tgl)); ?>
      </div>
      <div style="padding:5px;font-size:15px;font-weight:bold">
        Sisa Antrian : <?php echo $row->ad_sisa_antrian;?>
      </div>
      <div style="padding:5px;font-size:13px;"><?php echo $link_web->link;?></div>
      </div>
  </div>
</div>	
</td>
</tr>
</table>
</center>
</div>

</body>
</html>

– selanjutnya update code pada contollers Antrian_depan.php (application/tray_app/antria_depan/controllers/) menjadi

<?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'),
        );
    $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'));
        } 
    }

    public function delay(){
        $row = $this->Antrian_depan_model->get_data_cetak();
        if ($row) {
        $data = array(
            'row' => $row,
        );
        $this->load->view('antrian_depan/v_delay',$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'));
        }
    }
}

selanjutnya kita akan membuat form input data untuk pengambilan nomor antian, silahkan update file v_antrian_depan.php pada folder (application/tray_app/antria_depan/views/) menjadi seperti ini:

<?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-danger">
  <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>
  <form class="col-md alert btn-lg btn-success">
  <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">
  <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>
</div>
<hr/>
</div> <!-- end container -->
</body>
</html>

sampai disini pengambilan antrian untuk Pelayanan Meja Informasi sudah bisa diproses, untuk Layanan antrian lainnya akan segera diupdate 🙂

untuk Hasilnya kurang lebih demikian 🙂

Recommended For You

About the Author: adyrhs

Leave a Reply

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