Membuat Antrian PTSP part 6 menuju antrian PTSP dan Sidang

Bismillahirrahmanirrahim

sebelum update code harus disiapkan dulu sound atau suara yang saya buat menggunakan google voice. untuk suara sendiri bisa di update sesuai keinginan. berikut file suara yang bisa di download disini

download file sound.zip kemudian ekstrak didalam folder aplikasi, sehingga hasilnya seperti ini

sebelumnya yang dibahas adalah views, selanjutnya kita akan melakukan update pada models dan controllers

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 $db_sipp = 'sipp.v_jadwal_sidang';
    public $db_ptsp = 'ptsp.tbl_antrian_depan';

    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);
    }

    function jadwal_sidang($tgl_sidang){
        $this->db->select("$this->db_sipp.*,$this->db_ptsp.*");
        $this->db->from($this->db_sipp);
        $this->db->join($this->db_ptsp,"$this->db_sipp.nomor_perkara = $this->db_ptsp.ad_nomor_perkara","LEFT");
        $this->db->where("$this->db_sipp.tanggal_sidang", $tgl_sidang);
        $this->db->group_by("$this->db_sipp.nomor_perkara");
        $this->db->ORDER_BY("$this->db_ptsp.ad_nomor_panggil","ASC");
        $this->db->ORDER_BY("$this->db_sipp.nomor_perkara","ASC");
            return $this->db->get()->result();
    }

    function notif_count(){
        $this->db->from('tbl_display_ptsp');
        $this->db->where('dp_status','1');
        $this->db->where('dp_jenis','1'); //menyatakan antrian PTSP
        $query = $this->db->get();
            return $query->num_rows();
    }

    function load_antrian(){
        $query = $this->db->query("SELECT * FROM tbl_display_ptsp WHERE dp_jenis = '1' ORDER BY dp_id DESC LIMIT 0,1 ");
        if($query->num_rows() > 0){
            return $query->row();
        }
    }    

    function load_nomor_antrian($jenis_id){
        $query = $this->db->query("SELECT * FROM tbl_display_ptsp where dp_jenis_id = $jenis_id AND dp_jenis = '1' ORDER BY dp_id DESC LIMIT 0,1 ");
        if($query->num_rows() > 0){
            return $query->row()->dp_nomor_panggil;
        }
    }


    function notif_count_sidang(){
        $this->db->from('tbl_display_ptsp');
        $this->db->where('dp_status','1');
        $this->db->where('dp_jenis','2'); //menyatakan antrian sidang
        $query = $this->db->get();
            return $query->num_rows();
    }

    function load_antrian_sidang(){
        $query = $this->db->query("SELECT * FROM tbl_display_ptsp WHERE dp_jenis = '2' ORDER BY dp_id DESC LIMIT 0,1 ");
        if($query->num_rows() > 0){
            return $query->row();
        }
    }    

    function load_nomor_antrian_sidang($jenis_id,$ruangan){
        $query = $this->db->query("SELECT * FROM tbl_display_ptsp where dp_jenis_id = $jenis_id AND dp_jenis = '2' AND dp_ruangan = '$ruangan' ORDER BY dp_id DESC LIMIT 0,1 ");
        if($query->num_rows() > 0){
            return $query->row()->dp_nomor_panggil;
        }
    }


}

kemudian Controllers

Antrian_depan.php

<?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()
    {
        $tgl_sidang = date('Y-m-d');
        $data = array(
           'link_informasi' => site_url('antrian_depan/informasi'),
           'link_pengaduan' => site_url('antrian_depan/pengaduan'),
           'link_pendaftaran' => site_url('antrian_depan/pendaftaran'),
           'link_kasir' => site_url('antrian_depan/kasir'),
           'link_produk' => site_url('antrian_depan/produk'),
           'link_sidang' => site_url('antrian_depan/jadwal_sidang'),
           'jadwal_sidang' =>  $this->Antrian_depan_model->jadwal_sidang($tgl_sidang),
        );
    $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,
        );
        if(empty($row->ad_nomor_perkara)){
            $this->load->view('antrian_depan/v_cetak_antrian',$data);
        }else{
            $this->load->view('antrian_depan/v_cetak_antrian_sidang',$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 kasir() 
    {
        $ad_jenis_id = $this->input->post('ad_jenis_id',TRUE);
        $ad_jenis_nama = 'PEMBAYARAN';
        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 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(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'));
        }
    }

    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(5),
        'ad_nomor_panggil' => 'E'.$this->get_nomor(5),
        '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(5),
        );
            $this->Antrian_depan_model->insert($data);
            redirect(site_url('antrian_depan/cetak_antrian'));
        }
    }

    public function jadwal_sidang() 
    {
        $ad_jenis_id = $this->input->post('ad_jenis_id',TRUE);
        $ad_jenis_nama = 'ANTRIAN SIDANG';
        $ruangan = $this->input->post('ad_ruangan',TRUE);
        if(empty($ruangan) OR $ruangan == '' ){
            $ad_ruangan = '1';
        }else{
            $ad_ruangan = $this->input->post('ad_ruangan',TRUE);
        }
        if (empty($ad_jenis_id) OR $ad_jenis_id == '') {
            $this->index();
        } else {
            $data = array(
        'ad_nomor' => $this->get_nomor(6),
        'ad_nomor_panggil' => 'S'.$this->get_nomor(6),
        '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_nomor_perkara' => $this->input->post('ad_nomor_perkara',TRUE),
        'ad_ruangan' => $ad_ruangan,
        'ad_sisa_antrian' => $this->get_sisa_antrian(6),
        'ad_para_pihak' => $this->input->post('ad_para_pihak',TRUE),
        );
            $this->Antrian_depan_model->insert($data);
            redirect(site_url('antrian_depan/cetak_antrian'));
        }
    }

    function display(){
        $tgl = date('Y-m-d');
        $panggil = $this->Antrian_depan_model->load_antrian();
        if($panggil){
            $nomor_panggil =  substr($panggil->dp_nomor_panggil,1,3);
        }else{
            $nomor_panggil = '-';
        }
        $data = array(
            'jlhnotif' => $this->Antrian_depan_model->notif_count(),
        );
        $this->load->view('v_tampil_antrian',$data);
    }

    function display_ptsp(){
        $tgl = date('Y-m-d');
        $panggil = $this->Antrian_depan_model->load_antrian();
        if($panggil){
            $nomor_panggil =  substr($panggil->dp_nomor_panggil,1,3);
        }else{
            $nomor_panggil = '-';
        }
        $data = array(
            'jlhnotif' => $this->Antrian_depan_model->notif_count(),
            'video' => $this->db->query("SELECT * FROM tbl_latar WHERE aktif_slide = '1' ORDER BY slide_id DESC LIMIT 0,1 ")->row(),
        );
        $this->load->view('v_tampil_antrian_ptsp',$data);
    }

    function cari_data_panggil()
    {
        $date = date('Y-m-d');
            $q = $this->db->query("SELECT dp_nomor_panggil from tbl_display_ptsp WHERE dp_jenis = '1' ORDER BY dp_id DESC LIMIT 0,1");
            $row = $q->num_rows();
            if($row>0){
                foreach($q->result() as $dt){
                    $d['no_panggila'] = substr($dt->dp_nomor_panggil,1,1);
                    $d['no_panggilb'] = substr($dt->dp_nomor_panggil,2,1);
                    $d['no_panggilc'] = substr($dt->dp_nomor_panggil,3,1);
                    $d['layanan'] = substr($dt->dp_nomor_panggil,0,1);
                }
                echo json_encode($d);
            }else{
                $d['no_panggila'] = '';
                $d['no_panggilb'] = '';
                $d['no_panggilc'] = '';
                $d['layanan'] = '';
                echo json_encode($d);
            }
    }

    //fungsi untuk memanggil nomor berdasarkan mymodal popup
    function load_antrian_modal(){
        $panggil = $this->Antrian_depan_model->load_antrian();
        if($panggil){
            echo $panggil->dp_nomor_panggil;
        }else{
            echo '-';
        }
    }

    function load_antrian_modal_jenis(){
        $panggil = $this->Antrian_depan_model->load_antrian();
        if($panggil){
            echo $panggil->dp_jenis_nama;
        }else{
            echo '-';
        }
    }

    function cari_data_akhir()
    {
        $date = date('Y-m-d');
            $q = $this->db->query("SELECT count(*) as total from tbl_display_ptsp where dp_status='1' AND dp_jenis = '1' ");
            $row = $q->num_rows();
            if($row>0){
                foreach($q->result() as $dt){
                    $d['no_akhir'] = $dt->total;
                }
                echo json_encode($d);
            }else{
                $d['no_akhir'] = '';
                echo json_encode($d);
            }
    }

    //fungsi untuk memanggil nomor berdasarkan mymodal popup
    function load_antrian_informasi(){ //informasi kode A
        $jenis_id = '1';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian($jenis_id);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }    

    function load_antrian_pendaftaran(){ //pendaftaran kode B
        $jenis_id = '2';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian($jenis_id);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }

    function load_antrian_kasir(){ //kasir kode C
        $jenis_id = '3';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian($jenis_id);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }

    function load_antrian_produk(){ //produk pengadilan kode D
        $jenis_id = '4';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian($jenis_id);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }

    function load_antrian_pengaduan(){ //pengaduan kode E
        $jenis_id = '5';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian($jenis_id);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }


    //fungsi untuk memanggil nomor berdasarkan mymodal popup antrian sidang
    function load_antrian_modal_sidang(){
        $panggil = $this->Antrian_depan_model->load_antrian_sidang();
        if($panggil){
            echo $panggil->dp_nomor_panggil;
        }else{
            echo '-';
        }
    }

    function load_antrian_modal_jenis_sidang(){
        $panggil = $this->Antrian_depan_model->load_antrian_sidang();
        if($panggil){
            echo $panggil->dp_jenis_nama;
        }else{
            echo '-';
        }
    }

    function load_antrian_modal_no_perkara_sidang(){
        $panggil = $this->Antrian_depan_model->load_antrian_sidang();
        if($panggil){
            echo $panggil->dp_nomor_perkara;
        }else{
            echo '-';
        }
    }

    function load_antrian_modal_para_pihak_sidang(){
        $panggil = $this->Antrian_depan_model->load_antrian_sidang();
        if($panggil){
            echo $panggil->dp_para_pihak;
        }else{
            echo '-';
        }
    }

    function load_antrian_modal_nama_ruang_sidang(){
        $panggil = $this->Antrian_depan_model->load_antrian_sidang();
        if($panggil){
            echo $panggil->dp_nama_ruangan;
        }else{
            echo '-';
        }
    }

    function cari_data_akhir_sidang()
    {
        $date = date('Y-m-d');
            $q = $this->db->query("SELECT count(*) as total from tbl_display_ptsp where dp_status='1' AND dp_jenis = '2'  ");
            $row = $q->num_rows();
            if($row>0){
                foreach($q->result() as $dt){
                    $d['no_akhir'] = $dt->total;
                }
                echo json_encode($d);
            }else{
                $d['no_akhir'] = '';
                echo json_encode($d);
            }
    }

    //display antrian sidang
    function display_sidang(){
        $tgl = date('Y-m-d');
        $panggil = $this->Antrian_depan_model->load_antrian();
        if($panggil){
            $nomor_panggil =  substr($panggil->dp_nomor_panggil,1,3);
        }else{
            $nomor_panggil = '-';
        }
        $data = array(
            'jlhnotif' => $this->Antrian_depan_model->notif_count_sidang(),
            'video' => $this->db->query("SELECT * FROM tbl_latar WHERE aktif_slide = '1' ORDER BY slide_id DESC LIMIT 0,1 ")->row(),
        );
        $this->load->view('v_tampil_antrian_sidang',$data);
    }

    //fungsi untuk memanggil nomor berdasarkan mymodal popup
    function load_antrian_sidang1(){ //informasi kode A
        $jenis_id = '6';
        $ruangan = '1';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian_sidang($jenis_id,$ruangan);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }     


    //fungsi untuk memanggil nomor berdasarkan mymodal popup
    function load_antrian_sidang2(){ //informasi kode A
        $jenis_id = '6';
        $ruangan = '2';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian_sidang($jenis_id,$ruangan);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    }     

    function load_antrian_sidang3(){ //informasi kode A
        $jenis_id = '6';
        $ruangan = '3';
        $panggil = $this->Antrian_depan_model->load_nomor_antrian_sidang($jenis_id,$ruangan);
        if($panggil){
            echo $panggil;
        }else{
            echo '-';
        }
    } 

    function cari_data_panggil_sidang()
    {
        $date = date('Y-m-d');
            $q = $this->db->query("SELECT dp_nomor_panggil, dp_nomor_perkara, dp_ruangan from tbl_display_ptsp WHERE dp_jenis = '2' ORDER BY dp_id DESC LIMIT 0,1");
            $row = $q->num_rows();
            if($row>0){
                foreach($q->result() as $dt){
                    $d['no_panggila'] = substr($dt->dp_nomor_panggil,1,1);
                    $d['no_panggilb'] = substr($dt->dp_nomor_panggil,2,1);
                    $d['no_panggilc'] = substr($dt->dp_nomor_panggil,3,1);
                    $d['layanan'] = substr($dt->dp_nomor_panggil,0,1);
                    $d['nomor_perkara'] = $dt->dp_nomor_perkara;
                    $d['pkr0'] = substr($dt->dp_nomor_perkara,0,1);
                    $d['pkr1'] = substr($dt->dp_nomor_perkara,1,1);
                    $d['pkr2'] = substr($dt->dp_nomor_perkara,2,1);
                    $d['pkr3'] = substr($dt->dp_nomor_perkara,3,1);
                    $d['ruang'] = $dt->dp_ruangan;
                }
                echo json_encode($d);
            }else{
                $d['no_panggila'] = '';
                $d['no_panggilb'] = '';
                $d['no_panggilc'] = '';
                $d['layanan'] = '';
                $d['nomor_perkara'] = '';
                $d['pkr0'] = '';
                $d['pkr1'] = '';
                $d['pkr2'] = '';
                $d['pkr3'] = '';
                $d['ruang'] = '';
                echo json_encode($d);
            }
    }    

}

Recommended For You

About the Author: adyrhs

Leave a Reply

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