load->library('session'); } function getAll($table,$order,$desasc) { $KETIGA = $this->load->database('third', TRUE); if($order != '' || $desasc != ''){ $KETIGA->order_by($order,$desasc); } $query = $KETIGA->get($table); if ($query->num_rows() > 0) { return $query->result(); } else { return array(); } } function getNumRows($table) { $KETIGA = $this->load->database('third', TRUE); $query = $KETIGA->get($table); return $query->num_rows(); } function get_all_table(){ $KETIGA = $this->load->database('third', TRUE); $q= $KETIGA->query("SELECT ucase(`tables`.`TABLE_NAME`) AS `table_name`, `tables`.`TABLE_COMMENT` AS `table_comment` FROM `information_schema`.`tables` WHERE ((`tables`.`TABLE_TYPE` = 'base table') AND (`tables`.`TABLE_SCHEMA` = 'unla_dikti'))"); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $ttl = count($data); $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); array_push($build_array["data"],array( 'table_name'=>'MAHASISWA', 'table_comment'=>'Biodata Lengkap Mahasiswa', )); foreach($data as $row) { array_push($build_array["data"],array( 'table_name'=>$row->table_name, 'table_comment'=>$row->table_comment, )); } echo json_encode($build_array); } function export_data(){ $KETIGA = $this->load->database('third', TRUE); $par=$this->input->post("parameter"); $procedure=$this->input->post("procedurename"); $KETIGA->trans_begin(); $KETIGA->query("CALL ".$procedure, array( $this->input->post("param1"), //thnakademik $this->input->post("param2"), //prodi ) ); if ($KETIGA->trans_status() === FALSE) { $KETIGA->trans_rollback(); $return["success"]=false; $return["message"]="Execute Failure"; } else { $KETIGA->trans_commit(); $return["success"]=true; $return["message"]="Execute Success"; } echo json_encode($return); } function exportexcel($tbl,$kdstsemester,$kdprodi) { $KETIGA = $this->load->database('third', TRUE); $tablename=strtolower($tbl); $opt = ($kdprodi == "-") ? "<>":"="; $querymhs = "SELECT * FROM ".$tablename." WHERE kdprodi ".$opt." '$kdprodi'"; // khusus master tabel siak $data['eksport'] = ($tbl=='MAHASISWA') ? $this->db->query($querymhs)->result():$this->getAll($tablename,'',''); $data['table'] = $tablename; $data['kdstsemester'] = $kdstsemester; $data['kdprodi'] = $kdprodi; $data['fieldname'] = ($tbl=='MAHASISWA') ? $this->db->list_fields($tablename):$KETIGA->list_fields($tablename); $this->load->view('exportexcel', $data); } function truncate_all(){ $KETIGA = $this->load->database('third', TRUE); $KETIGA->trans_begin(); $KETIGA->query("CALL truncate_all_table_dikti"); if ($KETIGA->trans_status() === FALSE) { $KETIGA->trans_rollback(); $return["success"]=false; $return["message"]="Clear All Data Failure"; } else { $KETIGA->trans_commit(); $return["success"]=true; $return["message"]="Clear All Data Success"; } echo json_encode($return); } }