ceklog(); $this->load->library('session'); $this->load->library('rhlib'); } function ceklog() { $user = $this->session->userdata("usernameunlaprivate"); if($user==""){ redirect('auth/login'); } } function retValOrNull($val){ //especially for combo & looukup with no item selected $val = ($val=='')? null : $val; return $val; } function get_srtcuti(){ $kdprodi = $_POST['kdprodi']; $kdstsemester = $_POST['kdstsemester']; //$q = "SELECT * FROM v_srtberhentimhs WHERE kdprodi='".$kdprodi."' AND kdstsemester='".$kdstsemester."'"; $q = "SELECT a.*,b.nmprodi as prodi FROM v_srtcutimhs a LEFT JOIN v_mahasiswa_cari b ON a.nim = b.nim WHERE a.kdprodi='".$kdprodi."' AND a.kdstsemester='".$kdstsemester."'"; $this->rhlib->jsonFromQueryWLimit($q); } function insert_srtcuti(){ $dataArray = $this->getFieldsAndValues(); $ret = $this->rhlib->insertRecord('srtcutimhs',$dataArray); return $ret; } function update_srtcuti(){ $dataArray = $this->getFieldsAndValues(); //UPDATE $this->db->where('idsrtcutimhs', $_POST['idsrtcutimhs']); $this->db->update('srtcutimhs', $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_srtcuti(){ $where['idsrtcutimhs'] = $_POST['idsrtcutimhs']; $ret = $this->rhlib->deleteRecord('srtcutimhs',$where); return $ret; } function getFieldsAndValues(){ $dataArray = array( 'nomor'=> $_POST['nomor'], 'tglpermohonan'=> $_POST['tglpermohonan'], 'kdstsemester'=> $_POST['kdstsemester'], 'nim'=> $_POST['nim'], 'idsemester1'=> $_POST['idsemester1'], 'idsemester2'=> $_POST['idsemester2'], 'idsemester3'=> $_POST['idsemester3'], 'idsemester4'=> $_POST['idsemester4'], 'idthnakademik1'=> $_POST['idthnakademik1'], 'idthnakademik2'=> $_POST['idthnakademik2'], 'idthnakademik3'=> $_POST['idthnakademik3'], 'idthnakademik4'=> $_POST['idthnakademik4'], 'daritglmohon'=> $_POST['daritglmohon'], 'sampaitglmohon'=> $_POST['sampaitglmohon'], 'daritglijin'=> $_POST['daritglijin'], 'sampaitglijin'=> $_POST['sampaitglijin'], 'idpimpinan' =>$_POST['idpimpinan'], 'idstsetuju' => $_POST['idstsetuju'], 'tglpersetujuan' => ($_POST['tglpersetujuan']) ? $_POST['tglpersetujuan'] : null, ); return $dataArray; } }