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 retValOrZero($val){ $val = ($val=='')? 0 : $val; return $val; } function get_kurdet(){ $idkurikulum = $_POST['idkurikulum']; $kdprodi = $_POST['kdprodi']; $thnmasuk = $_POST['thnmasuk']; $q = "SELECT * FROM v_syaratmk WHERE idkurikulum='".$idkurikulum."' AND kdprodi='".$kdprodi."' AND thnmasuk='".$thnmasuk."'"; $this->rhlib->jsonFromQueryWLimit($q); } function get_add_kurikulum(){ $kdprodi = $_POST['kdprodi']; $thnmasuk = $_POST['thnmasuk']; /* $q = "SELECT a.*, b.nmmkind, ifnull(c.nmsemester,c.kdsemester) as kdsemester, d.nmjkurikulum, e.nmjmk, f.nmstmk FROM kurikulum a LEFT JOIN matakuliah b ON b.kdmk=a.kdmk LEFT JOIN semester c ON c.idsemester=a.idsemester LEFT JOIN ( select kdkodtbkod as kdjkurikulum, nmkodtbkod as nmjkurikulum from tbkod where kdapltbkod='11')d ON d.kdjkurikulum=a.jnskurikulum LEFT JOIN ( select kdkodtbkod as kdjmk, nmkodtbkod as nmjmk from tbkod where kdapltbkod='28')e ON e.kdjmk=a.jnsmk LEFT JOIN ( select kdkodtbkod as kdstmk, nmkodtbkod as nmstmk from tbkod where kdapltbkod='14')f ON f.kdstmk=a.stmk WHERE a.kdprodi='".$kdprodi."' and a.thnmasuk='".$thnmasuk."'"; */ $q = "SELECT a.*, b.nmmkind FROM kurikulum a LEFT JOIN matakuliah b ON b.kdmk=a.kdmk and b.kdprodi=a.kdprodi WHERE a.kdprodi='".$kdprodi."' AND a.thnmasuk='".$thnmasuk."' AND a.kdmk NOT IN(SELECT c.kdmk FROM syaratmk c WHERE c.idkurikulum IN (SELECT a.idkurikulum FROM kurikulum a WHERE a.kdprodi = '".$kdprodi."' AND a.thnmasuk = '".$thnmasuk."')) ORDER BY a.idsemester, a.idkurikulum"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_kurdet(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('syaratmk',$dataArray); return $ret; } function update_kurdet(){ $fieldsAndValues = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsyaratmk', $_POST['idsyaratmk']); $this->db->update('syaratmk', $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 update1field_kurdet(){ $field1 = $_POST['field1']; $value1 = $_POST['value1']; $field2 = $_POST['field2']; $value2 = $_POST['value2']; $dataArray = array( $field1 => $value1, $field2 => $value2, ); //UPDATE $this->db->where('idsyaratmk', $_POST['idsyaratmk']); $this->db->update('syaratmk', $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 delete_kurdet(){ $where['idsyaratmk'] = $_POST['idsyaratmk']; $ret = $this->rhlib->deleteRecord('syaratmk',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'idkurikulum'=> $_POST['idkurikulum'], 'kdmk'=> $_POST['kdmk'], ); return $dataArray; } } ?>