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 grid(){ $KEDUA= $this->load->database('second', TRUE); $idmhs = $_POST['idmhs']; $nim = $_POST['nim']; $q = "SELECT mahasiswa.nim, mahasiswa.nmmhs, mahasiswa.kdjnskelamin, mahasiswa.thnmasuk, mahasiswa.thnkeluar, mahasiswa.idpekerjaanalumni, mahasiswa.nmtptbekerjaalumni, mahasiswa.alamatkerjaalumni, mahasiswa.jabatanalumni, mahasiswa.tglbekerja_alumni, mahasiswa.jenjang_alumni, mahasiswa.pt_alumni, mahasiswa.bidangilmu_alumni, prodi.nmprodi, fakultas.nmfakultas FROM mahasiswa left join prodi on mahasiswa.kdprodi = prodi.kdprodi left join fakultas on fakultas.kdfakultas = prodi.kdfakultas WHERE idmhs='".$idmhs."' AND nim='".$nim."'"; $query = $KEDUA->query($q); $data = array(); $build_array = array ("success"=>false,"results"=>0,"data"=>array(),"msg"=>"no data"); if ($query->num_rows() > 0) { $data = $query->result(); $ttl = count($data); if($ttl == 1){ $build_array["success"]=true; $build_array["msg"]= ""; } $build_array["results"]=$ttl; $build_array["data"]=$data; $build_array["msg"]= "data lebih dari satu!"; } echo json_encode($build_array); } function get_mhs(){ //ISTRA //====================================================================== $KEDUA= $this->load->database('second', TRUE); $kdprodi = $_POST['kdprodi']; $thnmasuk = $_POST['thnmasuk']; $fields = $this->input->post("fields"); $query = $this->input->post("query"); $start = $this->input->post("start"); $limit = $this->input->post("limit"); $KEDUA->select("*"); $KEDUA->from("vv_mahasiswa_profile2"); //$this->db->where("pesanmsk <> ''"); $KEDUA->order_by("nim ASC"); $KEDUA->where("kdstaktivitasmhs = 'L' AND kdprodi = '".$kdprodi."' AND thnmasuk = '".$thnmasuk."'"); if($fields!="" || $query !=""){ $k=array('[',']','"'); $r=str_replace($k, '', $fields); // $a[explode(',', $r)]; $b=explode(',', $r); $c=count($b); for($i=0;$i<$c;$i++){ $d[$b[$i]]=$query; } // $this->db->bracket('open','like'); $KEDUA->or_like($d, $query); // $this->db->bracket('close','like'); } //$this->db->order_by("JDASHBOARD"); if ($start!=null){ $KEDUA->limit($limit,$start); }else{ $KEDUA->limit(1000,0); } $q = $KEDUA->get(); // $q = $this->db->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = count($data); $ttl = $datax; //====================================================================== $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'idmhs'=>$row->idmhs, 'nim'=>$row->nim, 'nmmhs'=>$row->nmmhs, 'nmstaktifmhs'=>$row->nmstaktifmhs, 'thnkeluar'=>$row->thnkeluar, 'nohpmhs'=>$row->nohpmhs, 'email'=>$row->email, )); } echo json_encode($build_array); } function get_mhs2(){ $KEDUA= $this->load->database('second', TRUE); $kdprodi = $_POST['kdprodi']; $thnmasuk = $_POST['thnmasuk']; $fields = $this->input->post("fields"); $query = $this->input->post("query"); $start = $this->input->post("start"); $limit = $this->input->post("limit"); //$q= $KEDUA->query("select * from mahasiswa where kdprodi = '".$kdprodi."' AND thnmasuk = '".$thnmasuk."'"); $KEDUA->select("*"); $KEDUA->from("mahasiswa"); //$this->db->where("pesanmsk <> ''"); $KEDUA->order_by("nim ASC"); $KEDUA->where("kdprodi = '".$kdprodi."' AND thnmasuk = '".$thnmasuk."'"); if($fields!="" || $query !=""){ $k=array('[',']','"'); $r=str_replace($k, '', $fields); // $a[explode(',', $r)]; $b=explode(',', $r); $c=count($b); for($i=0;$i<$c;$i++){ $d[$b[$i]]=$query; } // $this->db->bracket('open','like'); $KEDUA->or_like($d, $query); // $this->db->bracket('close','like'); } if ($start!=null){ $KEDUA->limit($limit,$start); }else{ $KEDUA->limit(50,0); } $q = $KEDUA->get(); $data = array(); if ($q->num_rows() > 0) { $data = $q->result(); } $datax = $KEDUA->count_all('mahasiswa'); $ttl = $datax; //====================================================================== $build_array = array ("success"=>true,"results"=>$ttl,"data"=>array()); foreach($data as $row) { array_push($build_array["data"],array( 'nim'=>$row->nim, 'nmmhs'=>$row->nmmhs, 'nohpmhs'=>$row->nohpmhs, 'email'=>$row->email, )); } echo json_encode($build_array); } function send_mail(){ $to = $_POST['email'];//$this->input->post("email"); //$cc = $this->input->post("cc"); $subject = $_POST['subjek'];//$this->input->post("subjek"); $message = $_POST['url'];//$this->input->post("url"); $message2 = $_POST['pesanklr'];//$this->input->post("pesanklr"); $email; $pass; $query = $this->db->query('SELECT emailadmin,passadmin FROM hubkamiinfo'); foreach ($query->result() as $row){ $email = $row->emailadmin; $pass = base64_decode($row->passadmin); } $this->load->library('email'); $config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_timeout'] = '7'; $config['smtp_user'] = $email; $config['smtp_pass'] = $pass; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n"; $config['mailtype'] = 'text'; // or html $config['validation'] = TRUE; // bool whether to validate email or not $this->email->initialize($config); $this->email->from('unlanet_kr@yahoo.co.id', 'Universitas Langlangbuana'); $this->email->to($to); // $this->email->cc($cc); $this->email->subject($subject); $this->email->message($message); $this->email->send(); } function update(){ // ISTRA $KEDUA= $this->load->database('second', TRUE); $data = array( 'idpekerjaanalumni'=> $_POST['idpekerjaanalumni'], 'nmtptbekerjaalumni'=> $_POST['nmtptbekerjaalumni'], 'alamatkerjaalumni'=> $_POST['alamatkerjaalumni'], 'jabatanalumni'=> $_POST['jabatanalumni'], 'tglbekerja_alumni'=> $_POST['tglbekerja_alumni'], 'jenjang_alumni'=> $_POST['jenjang_alumni'], 'pt_alumni'=> $_POST['pt_alumni'], 'bidangilmu_alumni'=> $_POST['bidangilmu_alumni'], ); $where['nim']=$this->input->post('nim'); $KEDUA->where($where); $KEDUA->update("mahasiswa", $data); if($KEDUA->affected_rows()){ $ret["success"]=true; $ret["msg"]='Update Data Berhasil'; }else{ $ret["success"]=false; $ret["msg"]= 'Update Data Gagal'; } return $ret; } } ?>