AmuzkA

Laporan by tanggal

Feb 22nd, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.56 KB | None | 0 0
  1. MODEL
  2.  
  3. // Lihat Semua Tanggal
  4. function lihat_semua_tanggal() {
  5.     $this->db->select('*');
  6.     $this->db->from('tbl_sio');
  7.     $query = $this->db->get();
  8.     if ($query->num_rows() > 0) {
  9.         return $query->result();
  10.     } else {
  11.         return false;
  12.         }
  13.     }
  14.  
  15. function ambil_diantara_tanggal($data) {
  16. $condition = "tanggal  BETWEEN " . "'" . $data['date1'] . "'" . " AND " . "'" . $data['date2'] . "'";
  17.     $this->db->select('*');
  18.     $this->db->from('tbl_sio');            
  19.     $this->db->where($condition);
  20.     $this->db->order_by('tanggal','ASC');          
  21.     $query = $this->db->get();
  22.     if ($query->num_rows() > 0) {
  23.         return $query->result();
  24.     } else {
  25.         return false;
  26.         }
  27.     }
  28.  
  29.  
  30. VIEW
  31. <?php
  32.     if (isset($read_set_value)) {
  33.         echo $read_set_value;
  34.     }
  35.     if (isset($message_display)) {
  36.         echo $message_display;
  37.     }
  38. ?>
  39.  
  40.     <div id="show_form">
  41.         <form action="<?php echo base_url('index.php/sio/laporan');?>" method="post">
  42.     <div class="col-md-6">
  43.     <label>Dari Tanggal</label>
  44.     <div class="form-group input-group">
  45.         <span class="input-group-addon"><i class="fa fa-calendar"></i></span>            
  46.         <input type="date" name="date_from" class="form-control">
  47.     </div>
  48.     </div>
  49.     <div class="col-md-6">
  50.         <label>Sampai Tanggal</label>
  51.     <div class="form-group input-group">
  52.         <span class="input-group-addon"><i class="fa fa-calendar"></i></span>            
  53.         <input type="date" name="date_to" class="form-control">
  54.     </div>
  55.     </div>  
  56.     <div class="col-md-12">
  57.         <p align="right"><button class="btn btn-primary">Lihat</button></p>    
  58.     </div>
  59.     </form>    
  60.     <div class="message">
  61. <?php
  62.     if (isset($result_display)) {
  63.     $_SESSION['result'] = $result_display;
  64. ?>
  65.  
  66. <?php
  67.     if ($result_display == 'No record found !') {
  68.         echo $result_display;
  69.     } else {
  70.         echo "<table class='table table-striped table-bordered table-hover'>";
  71.     echo '<tr>
  72.         <th>#</th>
  73.         <th>Kd Pekerja</th>
  74.         <th>No Ktp</th>
  75.         <th>Nm Karyawan</th>
  76.         <th>No Sio</th>
  77.         <th>tgl_buat</th>
  78.         <th>Ms Berlaku</th>
  79.         <th>jatuh Tempo</th>
  80.         <th>Ket</th>
  81.         <th>Status</th>
  82.         <tr/>';
  83.     $i=1; foreach ($result_display as $value) {
  84.     echo '<tr>' .
  85.         '<td>' . $i . '</td>' .
  86.         '<td>' . $sio->kd_pekerja .' '. $value->nama_belakang . '</td>' .
  87.         '<td>' . $sio->no_ktp . '</td>' .
  88.         '<td>' . $sio->nm_karyawan . '</td>' .
  89.         '<td>' . $sio->no_sio . '</td>' .
  90.         '<td>' . $sio->tgl_buat . '</td>' .
  91.         '<td>' . $sio->ms_berlaku . '</td>' .
  92.         '<td>' . $sio->jth_tempo . '</td>' .
  93.         '<td>' . $sio->ket . '</td>' .
  94.         '<td>' . $sio->status . '</td>' .
  95.         '<tr/>';
  96.     $i++; }
  97.     echo '</table>';
  98.         }
  99.     }
  100. ?>
  101.  
  102. CONTROLLER
  103. // Lihat Diantara Tanggal
  104. public function lihat_tanggal(){
  105.     $result = $this->M_sio->lihat_semua_tanggal();
  106.     if ($result != false) {
  107.         return $result;
  108.     } else {
  109.         return 'Database is empty !';
  110.         }
  111.     }
  112.  
  113. // Mengurutkan Diantara Tanggal
  114. public function laporan() {
  115.     $date1 = $this->input->post('tgl_buat');
  116.     $date2 = $this->input->post('ms_berlaku');
  117.     $data = array(
  118.         'date1' => $date1,
  119.         'date2' => $date2
  120.     );
  121.     if ($date1 == "" || $date2 == "") {
  122.         $data['date_range_error_message'] = "Kedua Tanggal Harus Di Isi";
  123.     } else {
  124.         $result = $this->M_sio->ambil_diantara_tanggal($data);
  125.     if ($result != false) {
  126.         $data['result_display'] = $result;
  127.         } else {
  128.         $data['result_display'] = "Tidak Ada Data Ditampilkan !";
  129.         }
  130.     }
  131.         $data['show_table'] = $this->lihat_tanggal();
  132.         $data['title'] = 'Laporan pertanggal';
  133.         $data['isi']  = 'sio/laporan';
  134.         $this->template->load('template','sio/diantara_tanggal', $data);
  135.     }
Advertisement
Add Comment
Please, Sign In to add comment