ShuanghongS 1 месяц назад
Родитель
Сommit
15608fd646
1 измененных файлов с 19 добавлено и 12 удалено
  1. 19 12
      service/destination_delivery.class.php

+ 19 - 12
service/destination_delivery.class.php

@@ -763,7 +763,7 @@ class destination_delivery {
             }
         }
 
-         if ($operate == "search_calendar"){ 
+        if ($operate == "search_calendar"){ 
 
             $month = common::check_input($_POST ['month']); //current_page
             $sqlWhere = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
@@ -782,6 +782,7 @@ class destination_delivery {
             $search_calendar_sql = str_replace('<{month_end}>', $month['month_end'], $search_calendar_sql);
             $search_calendar_sql = str_replace('<{sqlWhere}>', $sqlWhere, $search_calendar_sql);
             
+            //error_log($search_calendar_sql);
             $result = common::excuteOneSql($search_calendar_sql);
             $result = json_decode($result,true);
             common::echo_json_encode(200,$result);
@@ -847,7 +848,7 @@ class destination_delivery {
             $booking_no = $_POST['booking_no'];  
             $manifest_type = $_POST['manifest_type'];  
             $h_bol = $_POST['h_bol']; 
-            $h_serial_no  = $_POST['serial_no'];
+            $h_serial_no  = $_POST['h_serial_no'];
             $order_from  = $_POST['order_from']; 
             $m_bol = $_POST['m_bol'];  
             $ctnr = $_POST['ctnr'];
@@ -855,6 +856,7 @@ class destination_delivery {
             $consignee = $_POST['consignee'];
             $consignee_id = $_POST['consignee_id'];
             $dc_country = $_POST['dc_country'];
+            $pakages = $_POST['pakages'];
 
             $recommended_delivery_window_date_from = $_POST['recommended_delivery_from_date'];
             $recommended_delivery_window_date_to = $_POST['recommended_delivery_to_date'];
@@ -948,7 +950,7 @@ class destination_delivery {
                 //array("msg"=>"","result"=>$result);
                 $saveDataArr = $this->groupShipments($booking_no,$manifest_type,$h_bol,$h_serial_no,$order_from,$m_bol,$ctnr,$kln_pic,$consignee,$consignee_id,
                     $recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
-                    $recommended_delivery_from,$recommended_delivery_to,$dc_country);
+                    $recommended_delivery_from,$recommended_delivery_to,$dc_country,$pakages);
                 
                 if(!empty($saveDataArr['msg'])){
                     $data = array("msg" =>$saveDataArr['msg']);
@@ -992,14 +994,14 @@ class destination_delivery {
                             consignee, delivery_date, delivery_mode, status, delivery_address,delivery_address_detail, special_requirements,delivery_reference, 
                             recommended_delivery_window_date_from, recommended_delivery_window_date_to, d_address_change_log,
                             recommended_delivery_from, recommended_delivery_to,kln_pic,
-                            create_by, created_time, modify_by, update_time)
+                            create_by, created_time, modify_by, update_time,total_qty)
                     VALUES ('$serial_no', ".$tags_sql.",".$country_sql.",
                             '".$booking_no_new."', '".utils::implode(',',$sData['h_bol'])."','".common::check_input(json_encode($sData['h_bol_multiple_link']))."',
                             '".utils::implode(',',$sData['m_bol'])."', '".utils::implode(',',$sData['ctnr'])."',
                             '".$sData['consignee']."', $delivery_date,'$delivery_mode','$status', '$delivery_address','$delivery_address_detail', '$special_requirements','$delivery_reference',
                             $recommended_delivery_window_date_from, $recommended_delivery_window_date_to,'',
                             '".$sData['recommended_delivery_from']."', '".$sData['recommended_delivery_to']."','".$sData['kln_pic']."',
-                            '"._getLoginName()."', now(), '"._getLoginName()."', now());";
+                            '"._getLoginName()."', now(), '"._getLoginName()."', now(),'".$sData['pakages']."');";
                     //记录log
                     $sql .="INSERT INTO public.kln_destination_delivery_operation_log(
                                     serial_no, action,notes, create_by, created_time, created_zone)
@@ -1395,7 +1397,7 @@ class destination_delivery {
             ),
             matched_data as (
                 select
-                    ooc.serial_no,
+                    ooc.serial_no as h_serial_no,
                     ooc.h_bol,
                     ooc.m_bol,
                     oc.ctnr,
@@ -1429,7 +1431,7 @@ class destination_delivery {
                 where  ooc.order_from = 'public' and transport_mode = 'sea'
                 union all
                 select 
-                    ooc.serial_no,
+                    ooc.serial_no as h_serial_no,
                     ooc.h_bol,
                     ooc.m_bol,
                     oc.ctnr,
@@ -1463,7 +1465,7 @@ class destination_delivery {
                 where  ooc.order_from = 'sfs' and transport_mode = 'sea'
                 union all
                 select 
-                    ooc.serial_no,
+                    ooc.serial_no as h_serial_no,
                     ooc.h_bol,
                     ooc.m_bol,
                     '' as ctnr,
@@ -1582,7 +1584,7 @@ class destination_delivery {
             ),
             matched_data as (
                 select
-                    ooc.serial_no,
+                    ooc.serial_no as h_serial_no,
                     ooc.h_bol,
                     ooc.m_bol,
                     oc.ctnr,
@@ -1615,7 +1617,7 @@ class destination_delivery {
                 where  ooc.order_from = 'public' and transport_mode = 'sea' ".$sqlCtnr."
                 union all
                 select 
-                    ooc.serial_no,
+                    ooc.serial_no as h_serial_no,
                     ooc.h_bol,
                     ooc.m_bol,
                     oc.ctnr,
@@ -1648,7 +1650,7 @@ class destination_delivery {
                 where  ooc.order_from = 'sfs' and transport_mode = 'sea' ".$sqlCtnr."
                 union all
                 select 
-                    ooc.serial_no,
+                    ooc.serial_no as h_serial_no,
                     ooc.h_bol,
                     ooc.m_bol,
                     '' as ctnr,
@@ -1708,7 +1710,7 @@ class destination_delivery {
 
     function groupShipments($booking_no, $manifest_type, $h_bol,$h_serial_no, $order_from,$m_bol, $ctnr,$kln_pic,$consignee,$consignee_id,
         $recommended_delivery_window_date_from, $recommended_delivery_window_date_to,
-        $recommended_delivery_from,$recommended_delivery_to,$dc_country){
+        $recommended_delivery_from,$recommended_delivery_to,$dc_country,$pakages){
         // Combine the data into an array of shipments
         $shipments = [];
         foreach ($h_bol as $index => $_h_bol) {
@@ -1724,6 +1726,7 @@ class destination_delivery {
                 'consignee' => $consignee[$index],
                 'consignee_id' => $consignee_id[$index],
                 'dc_country' => $dc_country[$index],
+                'pakages' => $pakages[$index],
                 'recommended_delivery_window_date_from' => $recommended_delivery_window_date_from[$index],
                 'recommended_delivery_window_date_to' => $recommended_delivery_window_date_to[$index],
                 'recommended_delivery_from' => $recommended_delivery_from[$index],
@@ -1744,6 +1747,7 @@ class destination_delivery {
             $ctnr = $item['ctnr'];
             $dc_country = $item['dc_country'];
             $consignee_id = $item['consignee_id'];
+            $pakages = $item['pakages'];
 
             if(strtoupper($item['manifest_type']) == 'BCN'){
                 if (!isset($groupedByMbol[$m_bol])) {
@@ -1753,6 +1757,7 @@ class destination_delivery {
                     $item['ctnr'] = array();
                     $item['dc_country'] = array();
                     $item['consignee_id'] = array();
+                    $item['pakages'] = 0;
                     $item['m_bol'] = array($item['m_bol']);
                     $groupedByMbol[$m_bol] = $item;
                 }
@@ -1766,6 +1771,7 @@ class destination_delivery {
                 }
                 if (!in_array($ctnr, $groupedByMbol[$m_bol]['ctnr'])) {
                     $groupedByMbol[$m_bol]['ctnr'][] = $ctnr;
+                    $groupedByMbol[$m_bol]['pakages'] += intval($pakages);
                 }
             } else {
                 if (!isset($groupedByShipmentId[$h_serial_no])) {
@@ -1785,6 +1791,7 @@ class destination_delivery {
 
                 if (!in_array($ctnr, $groupedByShipmentId[$h_serial_no]['ctnr'])) {
                     $groupedByShipmentId[$h_serial_no]['ctnr'][] = $ctnr;
+                    $groupedByShipmentId[$h_serial_no]['pakages'] += intval($pakages);
                 }
             }
         }