load->library('session'); $this->load->library('rhlib'); } 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 getJsonFromSPpublic($sql, $parameters){ $query = $this->db->query($sql, $parameters); $data = array(); $build_array = array ("success"=>false,"results"=>-1,"data"=>array(),"msg"=>"error"); if ($query->num_rows() == 0) { $build_array["success"]=true; $build_array["results"]=0; $build_array["msg"]="no data"; } if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); if($ttl > 0){ $build_array["success"]=true; $build_array["results"]=$ttl; $build_array["data"]=$data; $build_array["msg"]= ""; } } echo json_encode($build_array); } function grid(){ //ISTRA $y=''; //====================================================================== $start = $this->input->post("start"); $limit = $this->input->post("limit"); $fields = $this->input->post("fields"); $query = $this->input->post("query"); $tahunakademik = $this->input->post("thnakademik"); $tgl1 = $this->input->post("tglawal"); $tgl2 = $this->input->post("tglakhir"); $jmlbiaya = $this->input->post("jmlbiaya"); $this->db->select("*"); $this->db->from("v_kaspmb"); if($this->input->post('cbjmlbiaya')=='true'){ $this->db->where('nominal', $jmlbiaya); } if($this->input->post('cbakademik')=='true'){ $this->db->where('kdstsemester', $tahunakademik); } if($this->input->post('cbperiode')=='true'){ $this->db->where("date(tglkuitansipmb) between '". $tgl1 ."' and '". $tgl2."'" ); } //====================================================================== /* if ($start!=null){ $this->db->limit($limit,$start); }else{ $this->db->limit(1000,0); } */ $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = $this->db->count_all('v_kaspmb'); $ttl = $datax; //====================================================================== $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( //'nopmb'=>$row->nopmb, 'nokuitansipmb'=>$row->nokuitansipmb, 'tglkuitansipmb'=>$row->tglkuitansipmb, 'nama'=>$row->nama, 'kdjk'=>$row->kdjk, 'nmstmskmhs'=>$row->nmstmskmhs, 'nmfakultas'=>$row->nmfakultas, 'nmprodi'=>$row->nmprodi, 'nominal'=>$row->nominal, 'nmcarabyr'=>$row->nmcarabyr, 'namapembayar'=>$row->namapembayar, )); } echo json_encode($build_array); } //--------------------excel-----------------------// function export_excel($cbjmlbiaya,$cbakademik,$cbperiode,$jmlbiaya,$tahunakademik,$tgl1,$tgl2) { $tablename="v_kaspmb"; $this->db->select("*"); $this->db->from($tablename); if($cbjmlbiaya=='true'){ $this->db->where('nominal', $jmlbiaya); } if($cbakademik=='true'){ $this->db->where('kdstsemester', $tahunakademik); } if($cbperiode=='true'){ $this->db->where("date(tglkuitansipmb) between '". $tgl1 ."' and '". $tgl2."'" ); } $q = $this->db->get(); $result = array(); if ($q->num_rows() > 0) { $result = $q->result(); } $list_fields = array( 'nopmb', 'nokuitansipmb', 'tglkuitansipmb', 'nama', 'kdjk', 'nmstmskmhs', 'nmfakultas', 'nmprodi', 'nominal', 'nmcarabyr', 'namapembayar', ); $data['eksport'] = $result; $data['table'] = "excel_lap_kas_pmb"; $data['fieldname'] = $list_fields; $this->load->view('exportexcel', $data); } }