Exemplo n.º 1
0
             }
             $loop++;
         }
     }
 }
 $now = date('Y-m-d H:i:s');
 if (!empty($dataArray)) {
     foreach ($dataArray as $value) {
         if (preg_match('/^RT/', $value[1])) {
             $fields = array('outbound_id' => '', 'order_type' => $value[0], 'order_number' => $value[1], 'shipto_id' => $value[2], 'shipto_name' => $value[3], 'date_enter' => conv2mysqldatetime($value[4]), 'order_line' => $value[5], 'cate_name' => null, 'product_id' => $value[6], 'product_name' => $value[7], 'order_qty' => str_replace(',', '', $value[8]), 'product_unit' => $value[9], 'remark' => $value[10] ? $value[10] : '', 'date_create' => $now, 'date_update' => $now, 'date_cancel' => '0');
             // 				$db->insert("sync_outbound_rt", $fields);
             // 				_print($db->last_query());
             $db->select('id')->from('outbound_rt');
             $db->where(array('rt_refid' => $value[1], 'rt_date' => conv2mysqldatetime($value[4]), 'barcode' => $value[6], 'order_line' => $value[5], 'status' => 0, 'status_cancel' => 0));
             $query = $db->get();
             $outbound = array('user_id' => $user_id, 'rt_refid' => $value[1], 'order_type' => $value[0], 'shipto_id' => $value[2], 'shipto_name' => $value[3], 'rt_date' => conv2mysqldatetime($value[4]), 'order_line' => $value[5], 'rt_qty' => str_replace(',', '', $value[8]), 'barcode' => $value[6], 'goods_name' => $value[7], 'unit' => $value[9], 'qty_amount' => 0, 'remark' => $value[10] ? $value[10] : '', 'date_create' => $now, 'date_update' => $now, 'date_cancel' => NULL);
             if ($query->num_rows() == 0) {
                 $db->insert("outbound_rt", $outbound);
             } else {
                 foreach ($query->result() as $row) {
                     $key_id = $row->id;
                 }
                 $where = array('id' => $key_id);
                 unset($outbound['date_create']);
                 $db->update('outbound_rt', $outbound, $where);
             }
             /* Save LOG table */
             unset($outbound['date_update']);
             unset($outbound['date_update']);
             // 				$db->insert("outbound_rt_log", $outbound);
             // 			_print($db->last_query());exit;
Exemplo n.º 2
0
     $result = $sql->row();
     $product_qty = $result->product_qty;
     $stock_product_update_fields = array('product_qty' => str_replace(',', '', $value['Ordered Quantity']) + $product_qty, 'product_update' => $now, 'user_id' => $user_id);
     $db->update("stock_product", $stock_product_update_fields, $where);
 } else {
     $db->insert('stock_product', $stock_product_fields);
 }
 ///////////import inbound make data
 $fields = array('outbound_id' => '', 'order_type' => $value['Order TYPE'], 'order_number' => $value['Order Number'], 'shipto_id' => $value['Ship-To store'], 'shipto_name' => $value['Ship to Name'], 'date_enter' => conv2mysqldatetime($value['Date Entered']), 'order_line' => $value['Order Line'], 'category' => $value['CAT'], 'product_id' => $value['Barcode'], 'product_name' => $value['Name'], 'order_qty' => str_replace(',', '', $value['Ordered Quantity']), 'product_unit' => $value['UOM'], 'remark' => $value['Remark'] ? $value['Remark'] : '', 'date_create' => $now, 'date_update' => $now, 'date_cancel' => '0');
 // 				$db->insert("sync_outbound_rt", $fields);
 // 				_print($db->last_query());
 $db->select('id')->from('outbound_rt');
 $db->where(array('rt_refid' => $value['Order Number'], 'rt_date' => conv2mysqldatetime($value['Date Entered']), 'barcode' => $value['Barcode'], 'order_line' => $value['Order Line'], 'status' => 0, 'status_cancel' => 0));
 $query = $db->get();
 // 				_print($db->last_query());exit;
 $outbound = array('user_id' => $user_id, 'rt_refid' => $value['Order Number'], 'order_type' => $value['Order TYPE'], 'shipto_id' => $value['Ship-To store'], 'shipto_name' => $value['Ship to Name'], 'rt_date' => conv2mysqldatetime($value['Date Entered']), 'order_line' => $value['Order Line'], 'category' => $value['CAT'], 'rt_qty' => str_replace(',', '', $value['Ordered Quantity']), 'barcode' => $value['Barcode'], 'goods_name' => $value['Name'], 'unit' => $value['UOM'], 'qty_amount' => 0, 'remark' => $value['Remark'] ? $value['Remark'] : '', 'date_create' => $now, 'date_update' => $now, 'date_cancel' => NULL);
 if ($query->num_rows() == 0) {
     // 					$db->insert("outbound_rt", $outbound);
 } else {
     foreach ($query->result() as $row) {
         $key_id = $row->id;
     }
     $where = array('id' => $key_id);
     unset($outbound['date_create']);
     // 					$db->update('outbound_rt', $outbound, $where);
 }
 /* Save LOG table */
 unset($outbound['date_update']);
 unset($outbound['date_update']);
 // 				$db->insert("outbound_rt_log", $outbound);
 // 			_print($db->last_query());exit;
Exemplo n.º 3
0
     $dataRow = $objWorksheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, null, true, true, true);
     $col = 0;
     if (isset($dataRow[$row]['A']) && $dataRow[$row]['A'] > '') {
         ++$r;
         foreach ($headingsArray as $columnKey => $columnHeading) {
             // 			mb_detect_encoding($tmp)=="UTF-8" // ตรวจสอบการเข้ารหัส
             $dataRow[$row][$columnKey] = utf8_decode($dataRow[$row][$columnKey]);
             $dataArray[$r][$col] = iconv('TIS-620', 'UTF-8', $dataRow[$row][$columnKey]);
             ++$col;
         }
     }
 }
 $now = date('Y-m-d H:i:s');
 if (!empty($dataArray)) {
     foreach ($dataArray as $value) {
         $inbound_po_fields = array('po_id' => $value[3], 'ibp_id' => '', 'receipt_type' => $value[4], 'po_create' => $now, 'po_delivery_date' => conv2mysqldatetime($value[0]), 'po_supplier' => $value[2], 'product_no' => $value[6], 'product_name' => $value[7], 'cat' => $value[11], 'order_qty' => str_replace(',', '', $value[8]), 'product_qty' => 0, 'free_qty' => 0, 'product_unit' => $value[9], 'product_date_in' => 0, 'product_create_date' => 0, 'product_fefo' => 0, 'product_fefo_date' => 0, 'user_create' => $user_id, 'user_update' => $user_id, 'note' => $value[13], 'po_status' => 0, 'datecreate' => $now, 'dateupdate' => $now, 'status' => strtolower($value[12]) == 'active' ? 0 : 1);
         $where = array('po_id' => $value[3], 'product_no' => $value[6]);
         $db->select('po_id')->from('inbound_po');
         $db->where($where);
         $sql = $db->get();
         $count = $sql->num_rows();
         if (empty($count)) {
             //INSERT
             $db->insert('inbound_po', $inbound_po_fields);
         } else {
             // UPDATE
             unset($inbound_po_fields['user_create']);
             unset($inbound_po_fields['datecreate']);
             unset($inbound_po_fields['po_create']);
             $db->update('inbound_po', $inbound_po_fields, $where);
         }