gundambison

etget3tq3

Dec 23rd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.01 KB | None | 0 0
  1. Controllernya :
  2. <?php
  3.     public function showFormIndustri()
  4.     {
  5.         $get = $this->input->get();
  6.         $output = array(
  7.             'data' => array(),
  8.             'sql' => array(),
  9.             'time' => array(),
  10.             'params' => $params,
  11.             'head' => array()
  12.         );
  13.         $output['draw'] = isset($get['draw']) ? $get['draw'] : rand(10000, 99999);
  14.         $output['recordsTotal'] = $result['recordsFiltered'] = 0; //default
  15.         $output['time']['start'] = microtime(); //wajib ada.. buat debug proses mana yg lambat
  16.         $output['recordsTotal'] = $result['recordsFiltered'] = 999;//default
  17.        
  18.         $result = $this->auth_model->model_formindustri();
  19.         $data = array();
  20.         foreach ($result as $value) {
  21.            $row = array();
  22.            $row[] = $value->nama_industri;
  23.            $row[] = $value->alamat_industri;
  24.            $row[] = $value->telepon_industri;
  25.            $row[] = $value->direktur_industri;
  26.            $row[] = $value->periode;
  27.            $row[] = $value->nomor_surat;
  28.            $data[] = $row;  
  29.         }
  30.  
  31.         $output['data']=$data;
  32.         $output['raw']=$result;
  33.         echo json_encode($output);
  34.     }
  35.     ?>
  36. Viewnya :
  37. <label>Cek Data Industri</label>                  
  38.                     <table class="table table-bordered table-hover" id="tableFormPersetujuan">
  39.                       <thead>
  40.                       <tr>
  41.                         <th>Nama Industri</th>
  42.                         <th>Alamat Industri</th>
  43.                         <th>Telephon</th>
  44.                         <th>Direktur</th>
  45.                         <th>Nomor Surat</th>
  46.                         <th>Periode</th>                      
  47.                       </tr>
  48.                       </thead>
  49.                     </table>
  50.             </div>    
  51.  
  52.                
  53.                  
  54.  
  55.     </div>
  56.  
  57.       <!-- /.row -->
  58.     </section>
  59.     <!-- /.content -->
  60.   </div>
  61.  <script>
  62.   $(function () {
  63.  
  64.    
  65.     $('#tableFormPersetujuan').DataTable({
  66.         "processing": true, //Feature control the processing indicator.
  67.         "serverSide": true, //Feature control DataTables' server-side processing mode.
  68.         "order": [], //Initial no order.
  69.  
  70.         'ajax': {
  71.           'url' : '<?php echo site_url()?>index.php/admin/showFormIndustri'
  72.         },
  73.  
  74.         "columnDefs": [
  75.         {
  76.             "targets": [ 0 ], //first column / numbering column
  77.             "orderable": false, //set not orderable
  78.         },
  79.         ],
  80.        
  81.     });
  82.    
  83.    
  84. Modelnya :
  85. <?php  
  86.  public function model_formindustri()
  87.     {
  88.         $this->db->select(
  89.         'm_industri.nama_industri,
  90.         m_industri.alamat_industri,
  91.         m_industri.telepon_industri,
  92.         m_industri.direktur,
  93.         formulir_persetujuan.nomor_surat,
  94.         formulir_persetujuan.periode');
  95.         $this->db->from('formulir_persetujuan');
  96.         $this->db->join('m_industri', 'm_industri.kode_industri = formulir_persetujuan.kode_industri');
  97.         $query = $this->db->get();      
  98.         $result = $query->result_array();
  99.         return $result;
  100.     }
  101. ?>
Add Comment
Please, Sign In to add comment