load->library('session'); $this->load->library('rhlib'); } function get_klpsetting(){ $start = $this->input->post("start"); $limit = $this->input->post("limit"); $fields = $this->input->post("fields"); $query = $this->input->post("query"); $this->db->select("*"); $this->db->from("klpsetting"); if($fields!="" || $query !=""){ $k=array('[',']','"'); $r=str_replace($k, '', $fields); $b=explode(',', $r); $c=count($b); for($i=0;$i<$c;$i++){ $d[$b[$i]]=$query; } $this->db->or_like($d, $query); } if ($start!=null){ $this->db->limit($limit,$start); }else{ $this->db->limit(22,0); } $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = $this->numrow($fields, $query); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); if($ttl>0){ $build_array["data"]=$data; } echo json_encode($build_array); } function numrow($fields, $query){ $this->db->select("*"); $this->db->from("klpsetting"); if($fields!="" || $query !=""){ $k=array('[',']','"'); $r=str_replace($k, '', $fields); $b=explode(',', $r); $c=count($b); for($i=0;$i<$c;$i++){ $d[$b[$i]]=$query; } $this->db->or_like($d, $query); } $q = $this->db->get(); return $q->num_rows(); } function delete_klpsetting(){ $where['idklpset'] = $_POST['idklpset']; $del = $this->rhlib->deleteRecord('klpsetting',$where); return $del; } function insert_klpsetting(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('klpsetting',$dataArray); return $ret; } function update_klpsetting(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idklpset', $_POST['idklpset']); $this->db->update('klpsetting', $dataArray); if($this->db->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } function getFieldsAndValues(){ $dataArray = array( 'idklpset'=> $_POST['idklpset'], 'kdklpset'=> $_POST['kdklpset'], 'nmklpset'=> $_POST['nmklpset'], 'deskripsi'=> $_POST['deskripsi'] ); return $dataArray; } }