load->library('session'); } function get_kuisioner(){ $key = $_POST["key"]; $this->db->select("setting_kuisioner.kdstsemester,setting_kuisioner.id_question, setting_kuisioner.question,pengguna.nmlengkap"); $this->db->from("setting_kuisioner"); $this->db->join('pengguna', 'pengguna.userid = setting_kuisioner.userid', 'left'); $this->db->order_by('setting_kuisioner.id_question'); $where = array(); $where['setting_kuisioner.kdstsemester']= $_POST['kdstsemester']; $this->db->where($where); if ($key=='1'){ $id = $_POST["id"]; $name = $_POST["name"]; $this->db->or_like($id, $name); } $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = $this->db->count_all("setting_kuisioner"); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); if($ttl>0){ $build_array["data"]=$data; } echo json_encode($build_array); } function insert_question(){ $this->load->library('rhlib'); $dataArray = array( 'kdstsemester'=> $_POST['kdstsemester'], 'question'=> $_POST['question'], 'userid'=> $_POST['userid'] ); $ret = $this->rhlib->insertRecord('setting_kuisioner',$dataArray); return $ret; } function delete_data(){ $this->load->library('rhlib'); $where['id_question'] = $_POST['id_question']; $del = $this->rhlib->deleteRecord('setting_kuisioner',$where); return $del; } function copy_data(){ $this->load->library('rhlib'); $where['kdstsemester'] = $_POST['tahun_baru']; $this->rhlib->deleteRecord('setting_kuisioner',$where); $tahun_lama = $_POST['tahun_lama']; $tahun_baru = $_POST['tahun_baru']; $sql = "INSERT INTO setting_kuisioner (kdstsemester, question, userid) SELECT ".$tahun_baru." , question , userid FROM setting_kuisioner WHERE kdstsemester = '".$tahun_lama."'"; $ret = $this->db->query($sql); return $ret; } } ?>