yudaduy

data_kendaraan_model.php

Apr 19th, 2020
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.31 KB | None | 0 0
  1.     function json_data(){
  2.         try{
  3.             $where = '{column: "jenis" comparator: "=" value:"0" conjunction: "and"}';
  4.  
  5.             $plat_nomor = $this->input->post('form[search_plat_Nomor]', true);
  6.             $tahun = $this->input->post('form[search_tahun]', true);
  7.             $kondisi = $this->input->post('form[search_kondisi]', true);
  8.  
  9.             if($plat_nomor != ''){
  10.                 $where .= '{column: "plat_nomor" comparator: "=" value:"'.$plat_nomor.'" conjunction: "and"}';
  11.             }
  12.  
  13.             if($tahun != ''){
  14.                 $where .= '{column: "tahun" comparator: "=" value:"'.$tahun.'" conjunction: "and"}';
  15.             }
  16.  
  17.             if($kondisi != ''){
  18.                 $where .= '{column: "kondisi" comparator: "=" value:"'.$kondisi.'" conjunction: "and"}';
  19.             }
  20.  
  21.  
  22.             $response = $this->client->Request(
  23.                 'POST',
  24.                 $this->vars['_API_URL'].'/api',
  25.                 [
  26.                     "json" => [
  27.                         "query" => '{
  28.                             kendaraans(
  29.                                 where:['.$where.']
  30.                                 isDT:true limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
  31.                             ){
  32.                                 plat_nomor,
  33.                                 status,
  34.                                 merk,
  35.                                 tipe,
  36.                                 tahun,
  37.                                 jenis,
  38.                                 pengguna,
  39.                                 bagian,
  40.                                 km_service_terakhir,
  41.                                 kondisi  
  42.                             }
  43.                             recordsFiltered(
  44.                                 gquery: "kendaraan" limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
  45.                                 where:['.$where.']
  46.                             )
  47.                             recordsTotal(gquery: "kendaraan")
  48.                         }',
  49.                     ],
  50.                     'http_errors' => false,
  51.                 ]
  52.             );
  53.             $body = (array)json_decode($response->getBody(), true);
  54.             return $body;
  55.         }
  56.         catch(Exception $e){
  57.             return false;
  58.         }
  59.     }
  60.  
  61.     function json_data_mobil(){
  62.         try{
  63.             $where = '{column: "jenis" comparator: "=" value:"1" conjunction: "and"}';
  64.  
  65.             $plat_nomor = $this->input->post('form[search_plat_Nomor]', true);
  66.             $tahun = $this->input->post('form[search_tahun]', true);
  67.             $kondisi = $this->input->post('form[search_kondisi]', true);
  68.  
  69.             if($plat_nomor != ''){
  70.                 $where .= '{column: "plat_nomor" comparator: "=" value:"'.$plat_nomor.'" conjunction: "and"}';
  71.             }
  72.  
  73.             if($tahun != ''){
  74.                 $where .= '{column: "tahun" comparator: "=" value:"'.$tahun.'" conjunction: "and"}';
  75.             }
  76.  
  77.             if($kondisi != ''){
  78.                 $where .= '{column: "kondisi" comparator: "=" value:"'.$kondisi.'" conjunction: "and"}';
  79.             }
  80.  
  81.  
  82.             $response = $this->client->Request(
  83.                 'POST',
  84.                 $this->vars['_API_URL'].'/api',
  85.                 [
  86.                     "json" => [
  87.                         "query" => '{
  88.                             kendaraans(
  89.                                 where:['.$where.']
  90.                                 isDT:true limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
  91.                             ){
  92.                                 plat_nomor,
  93.                                 status,
  94.                                 merk,
  95.                                 tipe,
  96.                                 tahun,
  97.                                 jenis,
  98.                                 km_service_terakhir,
  99.                                 kondisi  
  100.                             }
  101.                             recordsFiltered(
  102.                                 gquery: "kendaraan" limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
  103.                                 where:['.$where.']
  104.                             )
  105.                             recordsTotal(gquery: "kendaraan")
  106.                         }',
  107.                     ],
  108.                     'http_errors' => false,
  109.                 ]
  110.             );
  111.             $body = (array)json_decode($response->getBody(), true);
  112.             return $body;
  113.         }
  114.         catch(Exception $e){
  115.             return false;
  116.         }
  117.     }
Advertisement
Add Comment
Please, Sign In to add comment