load->library('session'); $this->load->library('rhlib'); } var $_jsVars = array(); public function setJsVar($name, $value) { $this->_jsVars[$name] = $value; } function autoNumber($column, $tbl) { $q = "SELECT max(" . $column . ")+1 as max FROM " . $tbl . ""; $query = $this->db->query($q); $max = ''; if ($query->num_rows() != 0) { $row = $query->row(); $max = $row->max; } if ($max == null) { $max = 0; } return $max; } /* function get_data() { $sql = "SELECT * FROM v_diskonmhs"; $this->rhlib->jsonFromQueryWLimit($sql); } */ function get_data(){ //ISTRA $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("v_diskonmhs"); 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'); } if ($start!=null){ $this->db->limit($limit,$start); }else{ $this->db->limit(50,0); } $q = $this->db->get(); // $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = $this->db->count_all('v_diskonmhs'); $ttl = $datax; $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); if($ttl>0){ $build_array["data"]=$data; } echo json_encode($build_array); } function get_count_diskon(){ $nim = $_POST['nim']; $idsetbiaya = $_POST['idsetbiaya']; $kdstsemester = $_POST['kdstsemester']; //$idjnsdiskon = $_POST['idjnsdiskon']; $idjnsbiaya = $_POST['idjnsbiaya']; $kdjnsbiaya = $_POST['kdjnsbiaya']; $queryExt = ($kdjnsbiaya!='DPK' && $kdjnsbiaya!='KON')? " AND kdstsemester = '".$kdstsemester."'" : ""; /* $q = "SELECT count(nim) AS jml FROM diskonmhs WHERE nim = '".$nim."' AND idsetbiaya = '".$idsetbiaya."' ".$queryExt." AND idjnsdiskon = '".$idjnsdiskon."'"; */ $q = "SELECT count(nim) AS jml FROM diskonmhs WHERE nim = '".$nim."' AND idsetbiaya = '".$idsetbiaya."' ".$queryExt; $query = $this->db->query($q); $data= ''; if ($query->num_rows() > 0) { $row = $query->row(); $data['result']=$row->jml; } else { $data['result']=0; } echo json_encode($data); } function get_data_setbiaya() { $kdprodi = $_POST['kdprodix']; $idjnsbiaya = $_POST['idjnsbiayax']; $idjnskls = $_POST['idjnsklsx']; $tahunmsk = $_POST['tahunmskx']; $kdstsemester = $_POST['kdstsemesterx']; $queryadd=($idjnsbiaya!="2" && $idjnsbiaya!="5") ? "AND kdstsemester = $kdstsemester":""; $q = "SELECT idsetbiaya, biaya FROM setbiaya WHERE kdprodi = $kdprodi AND idjnsbiaya = $idjnsbiaya AND idjnskls = $idjnskls AND tahunmsk = $tahunmsk $queryadd AND idstatus = 1"; $query = $this->db->query($q); $data = array(); $build_array = array(); if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); $build_array = array ("success"=>true,"results"=>count($data),"data"=>$data,"msg"=>"1"); } else { $build_array = array ("success"=>false,"results"=>0,"data"=>array(),"msg"=>"0"); } echo json_encode($build_array); } function get_nominal_diskon() { $idjnsdiskon = $_POST['idjnsdiskonx']; $q = "SELECT nominal FROM jdiskon WHERE idjnsdiskon = $idjnsdiskon"; $query = $this->db->query($q); $data = array(); $build_array = array ("success"=>false,"results"=>0,"data"=>array(),"msg"=>"no data"); if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); if($ttl == 1){ $build_array["success"]=true; $build_array["msg"]= ""; } $build_array["results"]=$ttl; $build_array["data"]=$data; $build_array["msg"]= "data lebih dari satu!"; } //var_dump(json_encode($build_array)); echo json_encode($build_array); } function insert() { $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('diskonmhs',$dataArray); return $ret; } function update_setbiaya() { $filedAndVal = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsetbiaya', $_POST['id_module']); $this->db->update('setbiaya', $filedAndVal); 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 update() { $filedAndVal = $this->getFieldsAndValuesUpdate(); $where = array( 'kdstsemester' => $_POST['kdstsemesterx'], 'idsetbiaya' => $_POST['idsetbiayax'], 'nim' => $_POST['nimx'] ); //UPDATE $this->db->where($where); $this->db->update('diskonmhs', $filedAndVal); 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 delete() { //ISTRA $where = array( 'idjnsdiskon' => $_POST['idjnsdiskonx'], 'kdstsemester' => $_POST['kdstsemesterx'], 'idsetbiaya' => $_POST['idsetbiayax'], 'nim' => $_POST['nimx'] ); if ($_POST['idjnsbiayax']=='2') { unset($where['kdstsemester']); } if ($_POST['idjnsbiayax']=='5') { unset($where['kdstsemester']); } $ret = $this->rhlib->deleteRecord('diskonmhs',$where); return $ret; $this->db->trans_begin(); } function retValOrNull($val) { //especially for combo & looukup with no item selected $val = ($val == '') ? null : $val; return $val; } function getFieldsAndValues() { $data = array( 'kdstsemester' => (!$_POST['kdstsemesterx']) ? null:$_POST['kdstsemesterx'], 'idsetbiaya' => $_POST['idsetbiayax'], 'nim' => $_POST['nimx'], 'idjnsdiskon' => $_POST['idjnsdiskonx'], 'diskon' => $_POST['nominalx'] ); return $data; } function getFieldsAndValuesUpdate() { $data = array( 'idjnsdiskon' => $_POST['idjnsdiskonx'], 'diskon' => $_POST['nominalx'], //'idsetbiaya' => $_POST['idsetbiayax'] ); return $data; } function get_semester_active() { $data = $this->db->get_where('stsemester', array('idstatus' => 1))->row(); echo json_encode($data); } function copy_diskon() { $smtlama = $this->input->post('smtlama'); $smtbaru = $this->input->post('smtbaru'); if(empty($smtlama) || empty($smtbaru)){ echo json_encode(array("success"=>false)); die; } //get all diskon from smtlama $data_smtlama = $this->db->get_where('diskonmhs', array('kdstsemester' => $smtlama))->result_array(); if(!empty($data_smtlama)) { foreach($data_smtlama as $diskonlama) { $diskonbaru = $diskonlama; $diskonbaru['kdstsemester'] = $smtbaru; //insert $this->db->insert('diskonmhs', $diskonbaru); } } echo json_encode(array("success"=>true)); die; } } /* End of file c_setting_biaya.php */ /* Location: ./application/backend/controllers/keuangan/c_setting_biaya.php */