load->library('session'); $this->load->library('rhlib'); } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_jadwalkrs(){ $q = "SELECT jadwalkrs.* , jkrs.nmjnskrs , v_prodi.nmprodi , v_tahunakademik.`nmthnakademik` FROM jadwalkrs INNER JOIN jkrs ON jadwalkrs.idjnskrs = jkrs.idjnskrs INNER JOIN v_prodi ON jadwalkrs.kdprodi = v_prodi.kdprodi INNER JOIN v_tahunakademik ON jadwalkrs.kdstsemester = v_tahunakademik.kdstsemester WHERE jadwalkrs.kdprodi IN (SELECT kdprodi FROM penggunaprodi WHERE userid = '".$this->my_usession->userdata('user_idunlaprivate')."')"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_jadwalkrs(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('jadwalkrs',$dataArray); return $ret; } function update_jadwalkrs(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE //$this->db->where('kdprodi', $_POST['kdprodi']); //$this->db->where('kdstsemester', $_POST['kdstsemester']); $this->db->where('idjadwalkrs', $_POST['idjadwalkrs']); $this->db->update('jadwalkrs', $fieldsAndValues); 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_jadwalkrs(){ //$where['kdprodi'] = $_POST['kdprodi']; //$where['kdstsemester'] = $_POST['kdstsemester']; $where['idjadwalkrs'] = $_POST['idjadwalkrs']; $ret = $this->rhlib->deleteRecord('jadwalkrs',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'idjnskrs'=> $_POST['idjnskrs'], 'kdprodi'=> $_POST['kdprodi'], 'kdstsemester'=> $_POST['kdstsemester'], 'tglawal'=> $_POST['tglawal'], 'tglakhir'=> $_POST['tglakhir'], 'mindppkrs'=> ($_POST['mindppkrs']) ? $_POST['mindppkrs']:0, 'mindpputs'=> ($_POST['mindpputs']) ? $_POST['mindpputs']:0, 'mindppuas'=> ($_POST['mindppuas']) ? $_POST['mindppuas']:0, ); return $dataArray; } } ?>