load->library('session'); } function id_field($column,$tbl,$whereb, $wherea){ $q = "SELECT ".$column." as id FROM ".$tbl." where ".$whereb." = '".$wherea."' " ; $query = $this->db->query($q); $id = ''; if ($query->num_rows() != 0) { $row = $query->row(); $id=$row->id; } return $id; } function nm_field($column,$tbl,$whereb, $wherea){ $q = "SELECT ".$column." as nm FROM ".$tbl." where ".$whereb." = '".$wherea."' " ; $query = $this->db->query($q); $nm= ''; if ($query->num_rows() != 0) { $row = $query->row(); $nm=$row->nm; } return $nm; } function grid(){ //ISTRA $y=''; //====================================================================== $start = $this->input->post("start"); $limit = $this->input->post("limit"); $fields = $this->input->post("fields"); $query = $this->input->post("query"); $idjadwalpmb = $this->input->post("idjadwalpmb"); $kdprodi = $this->input->post("kdprodi"); // $prodiall = $this->input->post("prodiall"); // $this->db->select("*"); $this->db->from("v_pmbterverifikasi1"); if($idjadwalpmb !=''){ $where['idjadwalpmb'] =$idjadwalpmb; // $this->db->where($where); } if($kdprodi !=''){ $where['kdprodi1'] =$kdprodi; // $this->db->where($where); } //====================================================================== if($start!='' || $limit!='' || $fields!='' || $query !='' || $idjadwalpmb !='' ) { $this->db->where($where); } if($fields!="" || $query !=""){ $k=array('[',']','"'); $r=str_replace($k, '', $fields); // $a[explode(',', $r)]; $b=explode(',', $r); $c=count($b); for($i=0;$i<$c;$i++){ $d[$b[$i]]=$query; } // $this->db->bracket('open','like'); $this->db->or_like($d, $query); // $this->db->bracket('close','like'); } //$this->db->order_by("JDASHBOARD"); if ($start!=null){ $this->db->limit($limit,$start); }else{ $this->db->limit(50,0); } $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = $this->db->count_all('v_pmbterverifikasi'); $ttl = $datax; //====================================================================== $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'nopmb'=>$row->nopmb, 'nousm'=>$row->nousm, 'tglpmb'=>date('d-m-Y',strtotime(substr($row->tglpmb,0,9))), 'nama'=>$row->nama, 'kdjk'=>$row->kdjk, 'kdprodi1'=>$this->nm_field('nourutprodi','v_prodi','kdprodi',$row->kdprodi1).'.'.$this->nm_field('nmprodi','v_prodi','kdprodi',$row->kdprodi1).' '. $this->nm_field('nmjenjangstudi','v_prodi','kdprodi',$row->kdprodi1),// $row->kdprodi1, 'nmklsmhs'=>$row->nmklsmhs,//$this->nm_field('nmstusm','stusm','idstusm',$row->idstusm), 'nmstmskmhs'=>$row->nmstmskmhs,//$this->nm_field('nmstmskmhs','stmskmhs','idstmskmhs',$row->idstmskmhs), )); } echo json_encode($build_array); } }