Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //echo "Import data mahasiswa";
- $objPHPExcel->setActiveSheetIndex(0);
- $cell_collection = $objPHPExcel->getActiveSheet()->getCellCollection();
- $jml_row = $objPHPExcel->getActiveSheet()->getHighestRow()-1;
- foreach ($cell_collection as $cell) {
- $column = $objPHPExcel->getActiveSheet()->getCell($cell)->getColumn();
- $row = $objPHPExcel->getActiveSheet()->getCell($cell)->getRow();
- $data_value = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue();
- if ($row == 1) {
- $header[$row][$column] = $data_value;
- } else {
- $arr_data[$row][$column] = $data_value;
- }
- }
- if ($arr_data) {
- $temp_data = array();
- $sukses_count = 0;
- $sukses_msg = '';
- $error_count = 0;
- $error_msg = array();
- $sukses_msg = array();
- //$i=0;
- foreach ($arr_data as $key => $value) {
- //++$i;
- $nim = $value['B'];
- $nm_mhs = $value['C'];
- $tmp_lahir =$value['D'];
- $tgl_lahir = date('Y-m-d', strtotime($value['E']));
- $jk = trim($value['F']);
- $agama = trim($value['G']);
- $ds_kel = $value['H'];
- $wilayah = trim($value['I']);
- $nm_ibu = $value['J'];
- $kode_prodi = trim($value['K']);
- $tgl_masuk = date('Y-m-d', strtotime($value['L']));
- $smt_awal = trim($value['M']);
- $stat_mhs = trim($value['N']);
- $stat_awal = trim($value['O']);
- $sks_diakui = $value['P'];
- $pt_asal = $value['Q'];
- $prodi_asal = $value['R'];
- $filter_sms = "kode_prodi='".$kode_prodi."' AND id_sp='".$this->session->userdata('id_sp')."'";
- $temp_sms = $this->feeder->getrecord($this->session->userdata('token'),'sms',$filter_sms);
- $id_sms = $temp_sms['result']?$temp_sms['result']['id_sms']:'';
- $temp_data['nm_pd'] = $nm_mhs;
- $temp_data['jk'] = $jk;
- $temp_data['tmpt_lahir'] = $tmp_lahir;
- $temp_data['tgl_lahir'] = $tgl_lahir;
- $temp_data['id_agama'] = $agama;
- $temp_data['id_kk'] = 0;
- $temp_data['id_sp'] = $this->session->userdata('id_sp');
- $temp_data['ds_kel'] = $ds_kel;
- $temp_data['id_wil'] = $wilayah;
- $temp_data['a_terima_kps'] = 0;
- $temp_data['stat_pd'] = $stat_mhs;
- $temp_data['id_kebutuhan_khusus_ayah'] = 0;
- $temp_data['nm_ibu_kandung'] = $nm_ibu;
- $temp_data['id_kebutuhan_khusus_ibu'] = 0;
- $temp_data['kewarganegaraan'] = 'ID';
- $temps_data['id_sms'] = $id_sms;
- $temps_data['id_sp'] = $this->session->userdata('id_sp');
- $temps_data['id_jns_daftar'] = $stat_awal;
- $temps_data['nipd'] = $nim;
- $temps_data['tgl_masuk_sp'] = $tgl_masuk;
- $temps_data['a_pernah_paud'] = 0;
- $temps_data['a_pernah_tk'] = 0;
- $temps_data['mulai_smt'] = $smt_awal;
- if ($stat_awal=='2') {
- $temps_data['sks_diakui'] = $sks_diakui;
- $temps_data['nm_pt_asal'] = $pt_asal;
- $temps_data['nm_prodi_asal'] = $prodi_asal;
- }
- $temp_result = $this->feeder->insertrecord($this->session->userdata['token'], $this->table, $temp_data);
- if ($temp_result['result']) {
- //Error handle
- if ($temp_result['result']['error_desc']==NULL) {
- ++$sukses_count;
- $temps_data['id_pd'] = $temp_result['result']['id_pd'];
- $temps_result = $this->feeder->insertrecord($this->session->userdata['token'], $this->table1, $temps_data);
- if ($temps_result['result']) {
- if ($temps_result['result']['error_desc']=='') {
- $sukses_msg[] = "<h4>Sukses</h4>Biodata dan histori pendidikan mahasiswa <strong>".$nm_mhs."</strong> / <strong>NIM: ".$nim."</strong> berhasil ditambahkan.";
- } else {
- ++$error_count;
- $error_msg[] = "<h4>Error ".$temps_result['result']['error_code']." (".$nm_mhs." / NIM: ".$nim.")</h4><strong>Histori pendidikan:</strong> ".$temps_result['result']['error_desc'];
- }
- if (($temps_result['result']['error_desc']!='') && ($temp_result['result']['error_desc']=='')) {
- $sukses_msg[] = "<h4>Sukses</h4>Biodata mahasiswa <strong>".$nm_mhs."</strong> berhasil ditambahkan.";
- }
- }
- } else {
- if ($temp_result['result']['error_code']==200) {
- $filter_pd = "(nm_pd='".$nm_mhs."') AND (tmpt_lahir='".$tmp_lahir."') AND (tgl_lahir='".$tgl_lahir."') AND (nm_ibu_kandung='".$nm_ibu."') AND (p.id_sp='".$this->session->userdata('id_sp')."')";
- $temp_pd = $this->feeder->getrecord($this->session->userdata('token'),$this->table,$filter_pd);
- $temps_data['id_pd'] = $temp_pd['result']['id_pd'];
- $temps_result = $this->feeder->insertrecord($this->session->userdata['token'], $this->table1, $temps_data);
- if ($temps_result['result']) {
- if ($temps_result['result']['error_desc']==NULL) {
- ++$sukses_count;
- $sukses_msg[] = "<h4>Sukses</h4>Histori pendidikan mahasiswa <strong>".$nm_mhs."</strong> berhasil ditambahkan dengan <strong>NIM ".$nim."</strong>";
- } else {
- ++$error_count;
- $error_msg[] = "<h4>Error ".$temp_result['result']['error_code'].' / '.$temps_result['result']['error_code']." (".$nm_mhs." / NIM: ".$nim.")</h4><strong>Biodata:</strong> ".$temp_result['result']['error_desc']."<br /><strong>Histori pendidikan:</strong> ".$temps_result['result']['error_desc']."";
- }
- }
- }
- }
- } else {
- $error_msg[] = "<h4>Error ".$temp_result['result']['error_code']."</h4>".$temp_result['result']['error_desc'];
- }
- }
- $this->benchmark->mark('selesai');
- $time_eks = $this->benchmark->elapsed_time('mulai', 'selesai');
- if ((!$sukses_count==0) || (!$error_count==0)) {
- echo "Waktu eksekusi ".$time_eks." detik<br />
- Results (total ".$jml_row." baris data):<br />
- <font color=\"#3c763d\">".$sukses_count." data Mahasiswa baru berhasil ditambah</font>";
- if ($sukses_count!=0) {
- echo "<a data-toggle=\"collapse\" href=\"#cols_sukses\" aria-expanded=\"false\" aria-controls=\"cols_sukses\"> Detail</a><br />";
- } else { echo "<br />"; }
- echo "<div class=\"collapse\" id=\"cols_sukses\">";
- foreach ($sukses_msg as $pesan_sukses) {
- echo "<div class=\"bs-callout bs-callout-success\">".$pesan_sukses."</div><br />";
- }
- echo "</div>";
- echo "<font color=\"#ce4844\" >".$error_count." data tidak bisa ditambahkan </font>";
- if ($error_count!=0) {
- echo "<a data-toggle=\"collapse\" href=\"#cols_error\" aria-expanded=\"false\" aria-controls=\"cols_error\">Detail error</a>";
- }
- echo "<div class=\"collapse\" id=\"cols_error\">";
- foreach ($error_msg as $pesan) {
- echo "<div class=\"bs-callout bs-callout-danger\">".$pesan."</div><br />";
- }
- echo "</div>";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement