Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function json_data(){
- try{
- $where = '{column: "jenis" comparator: "=" value:"0" conjunction: "and"}';
- $plat_nomor = $this->input->post('form[search_plat_Nomor]', true);
- $tahun = $this->input->post('form[search_tahun]', true);
- $kondisi = $this->input->post('form[search_kondisi]', true);
- if($plat_nomor != ''){
- $where .= '{column: "plat_nomor" comparator: "=" value:"'.$plat_nomor.'" conjunction: "and"}';
- }
- if($tahun != ''){
- $where .= '{column: "tahun" comparator: "=" value:"'.$tahun.'" conjunction: "and"}';
- }
- if($kondisi != ''){
- $where .= '{column: "kondisi" comparator: "=" value:"'.$kondisi.'" conjunction: "and"}';
- }
- $response = $this->client->Request(
- 'POST',
- $this->vars['_API_URL'].'/api',
- [
- "json" => [
- "query" => '{
- kendaraans(
- where:['.$where.']
- isDT:true limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
- ){
- plat_nomor,
- status,
- merk,
- tipe,
- tahun,
- jenis,
- pengguna,
- bagian,
- km_service_terakhir,
- kondisi
- }
- recordsFiltered(
- gquery: "kendaraan" limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
- where:['.$where.']
- )
- recordsTotal(gquery: "kendaraan")
- }',
- ],
- 'http_errors' => false,
- ]
- );
- $body = (array)json_decode($response->getBody(), true);
- return $body;
- }
- catch(Exception $e){
- return false;
- }
- }
- function json_data_mobil(){
- try{
- $where = '{column: "jenis" comparator: "=" value:"1" conjunction: "and"}';
- $plat_nomor = $this->input->post('form[search_plat_Nomor]', true);
- $tahun = $this->input->post('form[search_tahun]', true);
- $kondisi = $this->input->post('form[search_kondisi]', true);
- if($plat_nomor != ''){
- $where .= '{column: "plat_nomor" comparator: "=" value:"'.$plat_nomor.'" conjunction: "and"}';
- }
- if($tahun != ''){
- $where .= '{column: "tahun" comparator: "=" value:"'.$tahun.'" conjunction: "and"}';
- }
- if($kondisi != ''){
- $where .= '{column: "kondisi" comparator: "=" value:"'.$kondisi.'" conjunction: "and"}';
- }
- $response = $this->client->Request(
- 'POST',
- $this->vars['_API_URL'].'/api',
- [
- "json" => [
- "query" => '{
- kendaraans(
- where:['.$where.']
- isDT:true limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
- ){
- plat_nomor,
- status,
- merk,
- tipe,
- tahun,
- jenis,
- km_service_terakhir,
- kondisi
- }
- recordsFiltered(
- gquery: "kendaraan" limit:'.$this->input->post('length', true).' offset:'.$this->input->post('start', true).' order:[{column: "id" dir: "asc"}]
- where:['.$where.']
- )
- recordsTotal(gquery: "kendaraan")
- }',
- ],
- 'http_errors' => false,
- ]
- );
- $body = (array)json_decode($response->getBody(), true);
- return $body;
- }
- catch(Exception $e){
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment