Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function additional_scan()
- {
- if($this->request->isAJAX())
- {
- $part_code = $this->request->getVar('part_code');
- $qty_part = $this->request->getVar('qty_part');
- $pl_unix = $this->request->getVar('pl_unix');
- $var = "/^[0-9]*$/";
- $respon = "";
- if($part_code === NULL)
- {
- $respon = 0;
- $data = " ";
- $res = 'Part code tidak boleh kosong';
- }elseif(!preg_match($var,$part_code)){
- $respon = 0;
- $data = " ";
- $res = 'Input part code harus angka';
- }elseif(strlen($part_code) < 5){
- $respon = 0;
- $data = " ";
- $res = 'Part code kurang dari 5 digit';
- }elseif(strlen($part_code) > 5){
- $respon = 0;
- $data = " ";
- $res = 'Part code lebih dari 5 digit';
- }else{
- //TAMBAHKAN VALIDASI JIKA PART CODE TIDAK TERDAFTAR
- $row = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_part_code' => $part_code])->first();
- if(!$row)
- {
- $respon = 0;
- $data = " ";
- $res = 'Part code tidak terdaftar';
- }else{
- $id = $row['dt_id'];
- $tot_scan = $row['dt_tot_scan'];
- $has_scan = $row['dt_has_scan'];
- $result = $row['dt_result'];
- //jika part additional
- if($tot_scan != 0 AND $tot_scan != $has_scan AND $result == 'Open') //cek jika total scan tidak 0 dan hasil scan tidak sama dengan total scan
- {
- $tambah = $has_scan + $qty_part;
- $d_update_1 = [
- 'dt_has_scan' => $tambah,
- 'update_by' => $this->session->get('user_name'),
- 'update_date' => date('Y-m-d H:i:s')
- ];
- $log_scan = [
- 'pl_unix' => $pl_unix,
- 'ls_part_code' => $part_code,
- 'ls_num_scan' => $tambah,
- 'created_by' => $this->session->get('user_name'),
- 'created_date' => date('Y-m-d H:i:s')
- ];
- $this->m_detail_picking->update($id, $d_update_1); //input data
- $this->m_log_scan->insert($log_scan);
- $rd = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_part_code' => $part_code])->first();
- $t_scan = $rd['dt_tot_scan'];
- $h_scan = $rd['dt_has_scan'];
- $r_scan = $rd['dt_result'];
- // for reload data
- // $rw = $this->m_picking_data->where('pl_unix', $pl_unix)->first();
- $query = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' ");
- $rw = $query->getFirstRow();
- $query = $this->db->query("SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' AND dt_result = 'Open' ORDER BY dt_part_wh_code ASC");
- $rs = $query->getResult();
- //update status results
- $query_status = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' ");
- $row_status = $query_status->getResult();
- $temp_res = [];
- foreach($row_status as $hs)
- {
- $dt_result = $hs->dt_result;
- $temp_res[] = (object) [
- 'result' => $dt_result
- ];
- }
- $arraySearch = array_search('Open', array_column($temp_res,'result'));
- if($arraySearch === FALSE)
- {
- $has_result = 'Close';
- }else{
- $has_result = 'Open';
- }
- //update status results
- $total_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0])->get()->getNumRows();
- $before_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Open'])->get()->getNumRows();
- $after_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Close'])->get()->getNumRows();
- $data = [
- 'heading' => 'Picking',
- 'judul' => 'Double Check Picking',
- 'unix' => $rw->pl_unix,
- 'product_id' => $rw->dt_product_id,
- 'product_name' => $rw->dt_product_name,
- 'lot_control' => $rw->dt_lot_control,
- 'operation_number' => $rw->dt_operation_number,
- 'delivery' => $rw->dt_delivery,
- 'result' => $has_result,
- 'total_scan' => $total_scan,
- 'before_scan' => $before_scan,
- 'after_scan' => $after_scan,
- 'tampil_detail' => $rs
- ];
- $respon = 1;
- if($t_scan == $h_scan AND $r_scan == 'Open') //jika total scan sama dengan hasil scan dan result open
- {
- $i_res = 'Close';
- $d_update_2 = [
- 'dt_result' => $i_res,
- 'update_by' => $this->session->get('user_name'),
- 'update_date' => date('Y-m-d H:i:s')
- ];
- /*$log_scan = [
- 'pl_unix' => $pl_unix,
- 'ls_part_code' => $part_code,
- 'ls_num_scan' => $tambah,
- 'created_by' => $this->session->get('user_name'),
- 'created_date' => date('Y-m-d H:i:s')
- ];*/
- $this->m_detail_picking->update($id, $d_update_2);
- // $this->m_log_scan->insert($log_scan);
- // update data
- $query = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' ");
- $rw = $query->getFirstRow();
- $query = $this->db->query("SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' AND dt_result = 'Open' ORDER BY dt_part_wh_code ASC");
- $rs = $query->getResult();
- //update status results
- $query_status = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' ");
- $row_status = $query_status->getResult();
- $temp_res = [];
- foreach($row_status as $hs)
- {
- $dt_result = $hs->dt_result;
- $temp_res[] = (object) [
- 'result' => $dt_result
- ];
- }
- $arraySearch = array_search('Open', array_column($temp_res,'result'));
- if($arraySearch === FALSE)
- {
- $has_result = 'Close';
- }else{
- $has_result = 'Open';
- }
- //update status results
- $total_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0])->get()->getNumRows();
- $before_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Open'])->get()->getNumRows();
- $after_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Close'])->get()->getNumRows();
- $data = [
- 'heading' => 'Picking',
- 'judul' => 'Double Check Picking',
- 'unix' => $rw->pl_unix,
- 'product_id' => $rw->dt_product_id,
- 'product_name' => $rw->dt_product_name,
- 'lot_control' => $rw->dt_lot_control,
- 'operation_number' => $rw->dt_operation_number,
- 'delivery' => $rw->dt_delivery,
- 'result' => $has_result,
- 'total_scan' => $total_scan,
- 'before_scan' => $before_scan,
- 'after_scan' => $after_scan,
- 'tampil_detail' => $rs
- ];
- $res = 'Part '.$part_code.' Berhasil di verifikasi';
- $respon = 1;
- }else{
- // update data
- $query = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' ");
- $rw = $query->getFirstRow();
- $query = $this->db->query("SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' AND dt_result = 'Open' ORDER BY dt_part_wh_code ASC");
- $rs = $query->getResult();
- //update status results
- $query_status = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' ");
- $row_status = $query_status->getResult();
- $temp_res = [];
- foreach($row_status as $hs)
- {
- $dt_result = $hs->dt_result;
- $temp_res[] = (object) [
- 'result' => $dt_result
- ];
- }
- $arraySearch = array_search('Open', array_column($temp_res,'result'));
- if($arraySearch === FALSE)
- {
- $has_result = 'Close';
- }else{
- $has_result = 'Open';
- }
- //update status results
- $total_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0])->get()->getNumRows();
- $before_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Open'])->get()->getNumRows();
- $after_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Close'])->get()->getNumRows();
- $data = [
- 'heading' => 'Picking',
- 'judul' => 'Double Check Picking',
- 'unix' => $rw->pl_unix,
- 'product_id' => $rw->dt_product_id,
- 'product_name' => $rw->dt_product_name,
- 'lot_control' => $rw->dt_lot_control,
- 'operation_number' => $rw->dt_operation_number,
- 'delivery' => $rw->dt_delivery,
- 'result' => $has_result,
- 'total_scan' => $total_scan,
- 'before_scan' => $before_scan,
- 'after_scan' => $after_scan,
- 'tampil_detail' => $rs
- ];
- $res = 'Part '.$part_code.' Berhasil di verifikasi';
- $respon = 1;
- }
- }else{
- // update data
- $query = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' ");
- $rw = $query->getFirstRow();
- $query = $this->db->query("SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' AND dt_result = 'Open' ORDER BY dt_part_wh_code ASC");
- $rs = $query->getResult();
- //update status results
- $query_status = $this->db->query(" SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != '0' ");
- $row_status = $query_status->getResult();
- $temp_res = [];
- foreach($row_status as $hs)
- {
- $dt_result = $hs->dt_result;
- $temp_res[] = (object) [
- 'result' => $dt_result
- ];
- }
- $arraySearch = array_search('Open', array_column($temp_res,'result'));
- if($arraySearch === FALSE)
- {
- $has_result = 'Close';
- }else{
- $has_result = 'Open';
- }
- //update status results
- $total_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0])->get()->getNumRows();
- $before_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Open'])->get()->getNumRows();
- $after_scan = $this->m_detail_picking->where(['pl_unix' => $pl_unix, 'dt_tot_scan !=' => 0, 'dt_result' => 'Close'])->get()->getNumRows();
- $data = [
- 'heading' => 'Picking',
- 'judul' => 'Double Check Picking',
- 'unix' => $rw->pl_unix,
- 'product_id' => $rw->dt_product_id,
- 'product_name' => $rw->dt_product_name,
- 'lot_control' => $rw->dt_lot_control,
- 'operation_number' => $rw->dt_operation_number,
- 'delivery' => $rw->dt_delivery,
- 'result' => $has_result,
- 'total_scan' => $total_scan,
- 'before_scan' => $before_scan,
- 'after_scan' => $after_scan,
- 'tampil_detail' => $rs
- ];
- $res = 'Data sudah close';
- $respon = 0;
- }
- // ./ UPDATE STATUS DELIVERY
- // cek data apakah picking sudah close semuanya
- $sql = $this->db->query("SELECT * FROM pl_details WHERE pl_unix = '".$pl_unix."' AND dt_tot_scan != 0 ");
- $cek_status = $sql->getResult();
- $temp_status = [];
- foreach($cek_status as $datas)
- {
- $rslt = $datas->dt_result;
- $temp_status[] = (object) [
- 'rslt' => $rslt
- ];
- }
- $flag_status = "";
- $srcStatus = array_search('Open', array_column($temp_status,'rslt'));
- if($srcStatus === FALSE)
- {
- $flag_status = TRUE;
- }else{
- // $res = 'Data belum close';
- $flag_status = FALSE;
- }
- if($flag_status === TRUE)
- {
- $update_status = [
- 'dl_status' => 'ST-4',
- 'update_by' => $this->session->get('user_name'),
- 'update_date' => date('Y-m-d H:i:s')
- ];
- $update_result = [
- 'dt_result' => 'Close',
- 'update_by' => $this->session->get('user_name'),
- 'update_date' => date('Y-m-d H:i:s')
- ];
- }elseif($flag_status === FALSE){
- // $update_status = "LANJUT";
- $update_status = [
- 'dl_temp' => NULL
- ];
- $update_result = [
- 'dt_result' => 'Open'
- ];
- }
- //ambil data dari m_delivery
- $row_delivery = $this->m_delivery->where(['dl_unix' => $pl_unix])->first();
- $dl_id = $row_delivery['dl_id'];
- $dl_status = $row_delivery['dl_status'];
- //Update delivery
- $this->m_delivery->update($dl_id, $update_status);
- // ./ UPDATE STATUS DELIVERY
- $row_result = $this->m_picking_data->where(['pl_unix' => $pl_unix])->first();
- $pl_id = $row_result['pl_id'];
- $this->m_picking_data->update($pl_id, $update_result);
- // ./part additional
- }
- }
- $msg = [
- 'respon' => $respon,
- 'data' => $res,
- 'res' => $data
- // 'res' => view('Picking/pickingCheck', $data)
- ];
- echo json_encode($msg);
- }else{
- exit('Maaf request tidak dapat diproses!');
- }
- }
Add Comment
Please, Sign In to add comment