Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODEL
- // Lihat Semua Tanggal
- function lihat_semua_tanggal() {
- $this->db->select('*');
- $this->db->from('tbl_sio');
- $query = $this->db->get();
- if ($query->num_rows() > 0) {
- return $query->result();
- } else {
- return false;
- }
- }
- function ambil_diantara_tanggal($data) {
- $condition = "tanggal BETWEEN " . "'" . $data['date1'] . "'" . " AND " . "'" . $data['date2'] . "'";
- $this->db->select('*');
- $this->db->from('tbl_sio');
- $this->db->where($condition);
- $this->db->order_by('tanggal','ASC');
- $query = $this->db->get();
- if ($query->num_rows() > 0) {
- return $query->result();
- } else {
- return false;
- }
- }
- VIEW
- <?php
- if (isset($read_set_value)) {
- echo $read_set_value;
- }
- if (isset($message_display)) {
- echo $message_display;
- }
- ?>
- <div id="show_form">
- <form action="<?php echo base_url('index.php/sio/laporan');?>" method="post">
- <div class="col-md-6">
- <label>Dari Tanggal</label>
- <div class="form-group input-group">
- <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
- <input type="date" name="date_from" class="form-control">
- </div>
- </div>
- <div class="col-md-6">
- <label>Sampai Tanggal</label>
- <div class="form-group input-group">
- <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
- <input type="date" name="date_to" class="form-control">
- </div>
- </div>
- <div class="col-md-12">
- <p align="right"><button class="btn btn-primary">Lihat</button></p>
- </div>
- </form>
- <div class="message">
- <?php
- if (isset($result_display)) {
- $_SESSION['result'] = $result_display;
- ?>
- <?php
- if ($result_display == 'No record found !') {
- echo $result_display;
- } else {
- echo "<table class='table table-striped table-bordered table-hover'>";
- echo '<tr>
- <th>#</th>
- <th>Kd Pekerja</th>
- <th>No Ktp</th>
- <th>Nm Karyawan</th>
- <th>No Sio</th>
- <th>tgl_buat</th>
- <th>Ms Berlaku</th>
- <th>jatuh Tempo</th>
- <th>Ket</th>
- <th>Status</th>
- <tr/>';
- $i=1; foreach ($result_display as $value) {
- echo '<tr>' .
- '<td>' . $i . '</td>' .
- '<td>' . $sio->kd_pekerja .' '. $value->nama_belakang . '</td>' .
- '<td>' . $sio->no_ktp . '</td>' .
- '<td>' . $sio->nm_karyawan . '</td>' .
- '<td>' . $sio->no_sio . '</td>' .
- '<td>' . $sio->tgl_buat . '</td>' .
- '<td>' . $sio->ms_berlaku . '</td>' .
- '<td>' . $sio->jth_tempo . '</td>' .
- '<td>' . $sio->ket . '</td>' .
- '<td>' . $sio->status . '</td>' .
- '<tr/>';
- $i++; }
- echo '</table>';
- }
- }
- ?>
- CONTROLLER
- // Lihat Diantara Tanggal
- public function lihat_tanggal(){
- $result = $this->M_sio->lihat_semua_tanggal();
- if ($result != false) {
- return $result;
- } else {
- return 'Database is empty !';
- }
- }
- // Mengurutkan Diantara Tanggal
- public function laporan() {
- $date1 = $this->input->post('tgl_buat');
- $date2 = $this->input->post('ms_berlaku');
- $data = array(
- 'date1' => $date1,
- 'date2' => $date2
- );
- if ($date1 == "" || $date2 == "") {
- $data['date_range_error_message'] = "Kedua Tanggal Harus Di Isi";
- } else {
- $result = $this->M_sio->ambil_diantara_tanggal($data);
- if ($result != false) {
- $data['result_display'] = $result;
- } else {
- $data['result_display'] = "Tidak Ada Data Ditampilkan !";
- }
- }
- $data['show_table'] = $this->lihat_tanggal();
- $data['title'] = 'Laporan pertanggal';
- $data['isi'] = 'sio/laporan';
- $this->template->load('template','sio/diantara_tanggal', $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment