Advertisement
hilmawanyr

Untitled

Apr 2nd, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. $total_mhs = count($this->input->post('mhs'));
  2.         $ta        = $this->session->userdata('ta');
  3.         $npm       = $this->input->post('mhs',TRUE);
  4.  
  5.         $this->db->where_in('npm_mahasiswa', $npm);
  6.         $this->db->where('tahunajaran', $ta);
  7.         $this->db->delete('tbl_khs');
  8.  
  9.         for ($i=1; $i <= $total_mhs; $i++) {       
  10.             $nim     = $this->input->post('mhs['.$i.']');
  11.             $ips     = $this->input->post('ips['.$i.']');
  12.             $totsks  = $this->input->post('sks['.$i.']');
  13.             $ipk     = $this->input->post('ipk['.$i.']');
  14.             $sks_smt = $this->input->post('smt['.$i.']');
  15.  
  16.             $datax[] = [
  17.                     'npm_mahasiswa' => $nim,
  18.                     'tahunajaran'   => $ta,
  19.                     'ips'           => $ips,
  20.                     'total_sks'     => $totsks,
  21.                     'ipk'           => $ipk
  22.                 ];
  23.  
  24.             $param = ['THSMSTRAKM' => $ta, 'NIMHSTRAKM' => $nim];
  25.             $is_data_available = $this->db->get_where('tbl_aktifitas_kuliah_mahasiswa', $param)->num_rows();
  26.            
  27.             if ($is_data_available > 0) {
  28.                 $datas = [
  29.                     'SKSTTTRAKM' => $totsks,
  30.                     'NLIPKTRAKM' => $ipk
  31.                 ];
  32.                 $this->db->where('NIMHSTRAKM', $nim);
  33.                 $this->db->where('THSMSTRAKM', $ta);
  34.                 $this->db->update('tbl_aktifitas_kuliah_mahasiswa', $datas);
  35.                
  36.             } else {
  37.                 $data_akm = [
  38.                     'THSMSTRAKM' => $ta,
  39.                     'KDPTITRAKM' => '031036',
  40.                     'KDJENTRAKM' => 'C',
  41.                     'KDPSTTRAKM' => $this->userid,
  42.                     'NIMHSTRAKM' => $nim,
  43.                     'SKSEMTRAKM' => $sks_smt,
  44.                     'NLIPSTRAKM' => $ips,
  45.                     'SKSTTTRAKM' => $totsks,
  46.                     'NLIPKTRAKM' => $ipk
  47.                 ];
  48.                 $this->db->insert('tbl_aktifitas_kuliah_mahasiswa', $data_akm);
  49.             }
  50.         }
  51.  
  52.         $this->db->insert_batch('tbl_khs',$datax);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement