���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/luckymerchan/code/admin/dangsoloc/ |
<?php use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\IOFactory; if(isset($CORE->input['submitbt'])){ $txt_error = ''; if(isset($_FILES['excel_file']) and $_FILES['excel_file']['name']!=''){ if($_FILES['excel_file']['type']!='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'){ exit('Xin up file excel'); } function sap_xep($a,$b){ $a = trim($a); $b = trim($b); if(intval($a)==intval($b)){ return 0; } return (intval($a) < intval($b)) ? -1 : 1; } $file_excel = $_FILES['excel_file']['tmp_name']; $spreadsheet = IOFactory::load($file_excel); /*$sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true);*/ $sheetData_1day = $spreadsheet->getSheet(0)->toArray(null, true, true, true); foreach($sheetData_1day as $key=>$val){ $date = $val['A']; if(!check_date_input($date)){ $txt_error .= '<tr><td>Sai định dạng ngày dd-mm-yyyy</td><td>'.$date.'</td></tr>'; continue; } $kqloc_excel_date = date('Y-m-d',strtotime($date)); $kqloc_excel_data = trim($val['B']); $kqloc_excel_type = 1; $kqloc_excel_show_free = 0; $row_check = $DB->fetch_row($DB->query("SELECT * FROM tb_kqloc_excel WHERE kqloc_excel_date='$kqloc_excel_date' AND kqloc_excel_type='$kqloc_excel_type' ")); if(!$row_check) { $arr_insert = array('kqloc_excel_date' => $kqloc_excel_date, 'kqloc_excel_data' => $kqloc_excel_data,'kqloc_excel_type'=>$kqloc_excel_type,'kqloc_excel_show_free'=>$kqloc_excel_show_free); $kqloc_excel_id = $DB->do_insert('tb_kqloc_excel', $arr_insert); }else{ $kqloc_excel_id = $row_check['kqloc_excel_id']; $arr_update = array( 'kqloc_excel_data' => $kqloc_excel_data); $DB->do_update('tb_kqloc_excel', $arr_update, " WHERE kqloc_excel_id='$kqloc_excel_id' "); } //detail $DB->query("DELETE FROM tb_kqloc WHERE kqloc_excel_id='$kqloc_excel_id' "); $arr_kq= explode('-',$kqloc_excel_data); if(count($arr_kq)==1){ $arr_insert_kqloc = array('kqloc_excel_id'=>$kqloc_excel_id,'kqloc_date'=>$kqloc_excel_date,'kqloc_so'=>$arr_kq[0],'kqloc_type'=>$kqloc_excel_type,'kqloc_show_free'=>$kqloc_excel_show_free); $DB->do_insert('tb_kqloc', $arr_insert_kqloc); }else { usort($arr_kq, 'sap_xep'); $arr_kq = array_map('trim', $arr_kq); $arr_kq = array_unique($arr_kq); foreach ($arr_kq as $val) { $arr_insert_kqloc = array('kqloc_excel_id' => $kqloc_excel_id, 'kqloc_date' => $kqloc_excel_date, 'kqloc_so' => $val, 'kqloc_type' => $kqloc_excel_type, 'kqloc_show_free' => $kqloc_excel_show_free); $DB->do_insert('tb_kqloc', $arr_insert_kqloc); } } } $sheetData_6day = $spreadsheet->getSheet(1)->toArray(null, true, true, true); foreach($sheetData_6day as $key=>$val){ $date = $val['A']; if(!check_date_input($date)){ $txt_error .= '<tr><td>Sai định dạng ngày dd-mm-yyyy</td><td>'.$date.'</td></tr>'; continue; } $kqloc_excel_date = date('Y-m-d',strtotime($date)); $kqloc_excel_data = trim($val['B']); $kqloc_excel_type = 6; $kqloc_excel_show_free = intval($val['C']); $row_check = $DB->fetch_row($DB->query("SELECT * FROM tb_kqloc_excel WHERE kqloc_excel_date='$kqloc_excel_date' AND kqloc_excel_type='$kqloc_excel_type' ")); if(!$row_check) { $arr_insert = array('kqloc_excel_date' => $kqloc_excel_date, 'kqloc_excel_data' => $kqloc_excel_data,'kqloc_excel_type'=>$kqloc_excel_type,'kqloc_excel_show_free'=>$kqloc_excel_show_free); $kqloc_excel_id = $DB->do_insert('tb_kqloc_excel', $arr_insert); }else{ $kqloc_excel_id = $row_check['kqloc_excel_id']; $arr_update = array( 'kqloc_excel_data' => $kqloc_excel_data,'kqloc_excel_show_free'=>$kqloc_excel_show_free); $DB->do_update('tb_kqloc_excel', $arr_update, " WHERE kqloc_excel_id='$kqloc_excel_id' "); } //detail $DB->query("DELETE FROM tb_kqloc WHERE kqloc_excel_id='$kqloc_excel_id' "); $arr_kq= explode('-',$kqloc_excel_data); if(count($arr_kq)==1){ $arr_insert_kqloc = array('kqloc_excel_id'=>$kqloc_excel_id,'kqloc_date'=>$kqloc_excel_date,'kqloc_so'=>$arr_kq[0],'kqloc_type'=>$kqloc_excel_type,'kqloc_show_free'=>$kqloc_excel_show_free); $DB->do_insert('tb_kqloc', $arr_insert_kqloc); }else { usort($arr_kq, 'sap_xep'); $arr_kq = array_map('trim', $arr_kq); $arr_kq = array_dups($arr_kq); foreach ($arr_kq as $val) { $arr_insert_kqloc = array('kqloc_excel_id' => $kqloc_excel_id, 'kqloc_date' => $kqloc_excel_date, 'kqloc_so' => $val, 'kqloc_type' => $kqloc_excel_type, 'kqloc_show_free' => $kqloc_excel_show_free); $DB->do_insert('tb_kqloc', $arr_insert_kqloc); } } } } close_popup('Đã cập nhật'); } include ROOT_PATH . 'include/block/header_popup.php'; ?> <div class="card"> <div class="card-header">Import excel kết quả lọc <div class="card-tools"><a href="upload/Form up kqsoloc.xlsx" target="_blank">Tải file excel mẫu</a></div> </div> <div class="card-body" style="font-size: 12px;"> <form method="post" id="form_hoan_tra" action="" enctype="multipart/form-data"> <div class="row"> <div class="col-sm-12"> <div class="form-group"> <label>Excel</label> <input type="file" name="excel_file" class="form-control"> </div> </div> </div> <input type="submit" class="submit" style="display:none;" name="submitbt"> </form> </div> <div class="card-footer"> <a class="gui_yeu_cau btn btn-danger" href="javascript:void(0);">Submit</a> <a class="dong m-l-5 btn btn-dark" href="javascript:void(0);">Close</a> </div> </div> <script> $('.gui_yeu_cau').click(function (){ $('#form_hoan_tra .submit').click(); return false; }); $('.dong').click(function (){ window.close(); }); </script> <?php include ROOT_PATH . 'include/block/footer_popup.php'; exit(); ?>