ShuanghongS 2 months ago
parent
commit
48e7055a1f
4 changed files with 165 additions and 78 deletions
  1. 6 1
      service/destination_delivery.class.php
  2. 9 3
      service/ocean_order.class.php
  3. 93 72
      utils/common.class.php
  4. 57 2
      utils/utils.class.php

+ 6 - 1
service/destination_delivery.class.php

@@ -1003,8 +1003,13 @@ class destination_delivery {
             //审核通过时,才取下放当时应用修改的地址
             if ($status == "Approve") {
                 $delivery_booking = common::excuteObjectSql("select *,array_to_json(address_country) as address_country,
-                    array_to_json(h_serial_no) as h_serial_no_json from public.kln_destination_delivery where serial_no = '$serial_no'");
+                    array_to_json(h_serial_no) as h_serial_no_json,
+                    TO_CHAR( delivery_date, 'HH24:MI') AS _delivery_time,
+                    delivery_date::date AS _delivery_date
+                    from public.kln_destination_delivery where serial_no = '$serial_no'");
+
                 $onine_address = common::excuteListSql("select * from public.contacts_address_online where delivery_serial_no = '$serial_no'");
+
                 $sql .= "delete from public.contacts_address_online where delivery_serial_no = '$serial_no';";
                 $sql .=common::returnDAddressRecord($delivery_booking["address_country"],$onine_address);
 

+ 9 - 3
service/ocean_order.class.php

@@ -1923,7 +1923,8 @@ class ocean_order {
         )
         SELECT m_eta as _m_eta,  h_bol as _h_bol, m_bol as _m_bol,job_no as _job_bol,
                 o.* ,sh.*, cn.* ,aa.*,dd.*,fd.*,oo.*,
-                (select uncode from $order_from.ports where  code = o.port_of_transshipment) as port_of_transshipment_un
+                (select uncode from $order_from.ports where  code = o.port_of_transshipment) as port_of_transshipment_un,
+                (select loadterm from $order_from.ocean_extend  where  serial_no = o.serial_no) as loadterm
         from o 
         LEFT JOIN LATERAL ( SELECT tracking_no as _tracking_no,shippr_uncode,shipper_city,
                     consignee_uncode,consignee_city,incoterms,
@@ -1935,6 +1936,7 @@ class ocean_order {
                     eta as oo_eta,
                     atd as oo_atd,
                     ata as oo_ata,
+                    carbon_emission,
                     (select time_zone from public.city_timezone where uncode = oo.fport_of_loading_un limit 1) as pol_timezone,
                     (select uncity from $order_from.ports where uncode = oo.fport_of_loading_un limit 1) as pol_uncity,
                     (select time_zone from public.city_timezone where uncode = oo.mport_of_discharge_un limit 1) as mpod_timezone,
@@ -2205,7 +2207,9 @@ class ocean_order {
         $voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
         $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['booking_no'],
             "PO_NO" =>$ocean['_po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
-            "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service']);
+            "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service'],
+            "CO2 Emission" =>$ocean['carbon_emission'],"Load Terms" =>$ocean['loadterm'],
+            "Shipment Type" =>$ocean['manifest_type'] == "GPE" ? "LCL" : $ocean['manifest_type']);
         $data['basicInfo'] = $basicInfo;    
 
         //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
@@ -2366,7 +2370,9 @@ class ocean_order {
         $voyage = $ocean['voyage'];
         $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['booking_no'],
             "PO_NO" =>$ocean['po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
-            "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service']);
+            "Incoterm" =>$ocean['incoterms'],"Service_Type" =>$ocean['service'],
+            "CO2 Emission" =>$ocean['carbon_emission'],"Load Terms" =>"",
+            "Shipment Type" =>"");
         $data['basicInfo'] = $basicInfo;    
 
         //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询

+ 93 - 72
utils/common.class.php

@@ -4024,103 +4024,124 @@ class common {
         $h_serial_no_arr  =json_decode($h_serial_no_json,true);
 
         $ctnr  = $delivery_booking['ctnr'];
-         
+        
         //从UI 设计的case来讲,一个hbol就生成成一个wo ID 
-        //空運我們先不管,不做同步,就只做創建到審批,後面的讓他們自己錄入系統處理吧
         foreach($h_serial_no_arr as $serial_no){
-            $oceanInfo = common::excuteObjectSql("select (select manifest_type from public.ocean o where o.serial_no = ooc.serial_no  limit 1) as manifest_type
-                from public.kln_ocean oo where o.serial_no ='".$serial_no."'" );
+            $sql = "";
+
+            $oceanInfo = common::excuteObjectSql("select * from public.kln_ocean oo where oo.serial_no ='".$serial_no."'" );
+            //空運我們先不管,不做同步,就只做創建到審批,後面的讓他們自己錄入系統處理吧
+            if ($oceanInfo['transport_mode'] == "air"){
+                continue;
+            }
+            $biztype = $oceanInfo['ex_im'] == "Export" && $oceanInfo['transport_mode'] == "sea" ? "SE" :(
+                       $oceanInfo['ex_im'] == "Import" && $oceanInfo['transport_mode'] == "sea" ? "SI" :(
+                       $oceanInfo['ex_im'] == "Export" && $oceanInfo['transport_mode'] == "air" ? "AE" :(
+                       $oceanInfo['ex_im'] == "Import" && $oceanInfo['transport_mode'] == "air" ? "AI" : "" )));
+            $mode_type = $delivery_booking['delivery_mode'] == "Truck" ? "Road" : "";
+            
+            $consignee = $oceanInfo['consignee_id'];
+            $_schema = $oceanInfo['order_from'];
+            $_schema_contacts = $oceanInfo['order_from'];
+            if($oceanInfo['order_from'] == "public"){
+                $_schema_contacts = "ocean";
+            }
+        
+            $delivery_address  =json_decode($delivery_booking['delivery_address_detail'],true);
+            $consignee_name = common::excuteOneSql("select company from $_schema_contacts.contacts where contact_id = '$consignee' limit 1");
+            $consignee_exp = common::combineContactInfoString($delivery_address);
+            $consignee_sync_key = $delivery_address['sync_key'];
 
-            $ctnrs = common::excuteListSql("select ctnr,seal_no,size,qty,unit,grs_kgs,cbm,marks,description,is_lcl FROM oc_container oc where oc.serial_no::text = '".$serial_no."' 
+            $ctnrs = common::excuteListSql("select * FROM $_schema.oc_container oc where oc.serial_no::text = '".$serial_no."' 
                     and oc.ctnr in (select regexp_split_to_table('".$ctnr."', ','))" );
-       
             $total_pcs = "";
             $total_pcs_unit = "";
             $total_weight = "";
-            $total_weight_unit = "";
+            $total_weight_unit = "KGS";
             $total_volume = "";
-            $total_volume_unit = "";
+            $total_volume_unit = "CBM";
             foreach($ctnrs as $_ctnr_info){
-                
+                $total_pcs_unit = $_ctnr_info['unit'];
+                $total_pcs += $_ctnr_info['qty'];
+                $total_weight += $_ctnr_info['grs_kgs'];
+                $total_volume += $_ctnr_info['cbm'];
             }      
 
-            $biztype =  $oceanInfo['ex_im'] == "Export" && $oceanInfo['transport_mode'] == "sea" ? "SE" :(
-                        $oceanInfo['ex_im'] == "Import" && $oceanInfo['transport_mode'] == "sea" ? "SI" :(
-                        $oceanInfo['ex_im'] == "Export" && $oceanInfo['transport_mode'] == "air" ? "AE" :(
-                        $oceanInfo['ex_im'] == "Import" && $oceanInfo['transport_mode'] == "air" ? "AI" : "" )));
-
-            // 记录                
-            // "INSERT INTO public.do_header(
-            //     id,air_ocean, station_code, do_no, biztype, delivery_type,mode_type,
-            //     serial_no, lot_no, awbbl_no, job_no, do_date,
-            //     consignee, consignee_name, consignee_exp,consignee_pic, consignee_tel, consignee_fax, 
-            //     collect, collect_name,collect_exp, collect_pic, collect_tel, collect_fax,
-            //     notify, notify_name, shipper, shipper_name, 
-            //     transport_agent, transport_agent_name, transport_agent_exp,transport_agent_pic, transport_agent_tel, transport_agent_fax,
-            //     truck_no, driver_name,do_release_to, total_pcs, total_pcs_unit, total_weight,
-            //     est_delivery_date, est_delivery_time,
-            //     instructions,
-            //     total_weight_unit, total_volume, total_volume_unit, commodity1, commodity2, remark, create_user, create_time,
-            //     modify_user, modify_time, booking_no,total_chrgwt_unit,departure_airport,discharge_airport,chrgwt, consignee_addr_type, collect_addr_type, consignee2, consignee2_name,
-            //     broker, broker_name, broker_exp, broker_pic, broker_tel, broker_fax, broker_addr_type,
-            //     terminal_code, terminal_name, terminal_signed_by, terminal_reference,terminal_time,terminal_date,terminal_address,terminal_tel,terminal_fax,terminal_pic,
-            //     delivery_vehicle_type, delivery_fuel_type,
-            //     delivery_is_refrigerated_shipment,collect_addr_type_id,consignee_addr_type_id,broker_addr_type_id,loadterm,collect_addr_key,consignee_addr_key,
-            //     broker_addr_key,collect_city_code,collect_country_code,consignee_country_code,consignee_city_code)            
-            /**
-             * 这个id,和no, 我这边应该不生成,每个站点的应该不一样
-             * delivery_type 按逻辑来说是 Select code,description,category From kerry_system_code Where category in ('DELIVERYTYPE') and is_active =true order by sno取出来的。
-             * online上没有值,暂时取截图里面的值 "Awaiting Confirmation"
-             * 
-             * over_balance,total_chrgwt_unit,chrgwt
-             * 
-             * delivery_vehicle_type, delivery_fuel_type,  如果选择的是road ,会有默认的配置信息,每个站点应该不一样
-             */
-            $doNo = common::GeneralDoNo($oceanInfo['agent']);
-            $Id = common::excuteOneSql("select nextval('do_header_id_seq')");
-            "INSERT INTO public.do_header(
-                id,air_ocean, station_code, do_no, biztype, delivery_type,mode_type,
+            $doHeaderId = common::excuteOneSql("select nextval('do_header_id_seq')");
+            $sql .="INSERT INTO public.do_header(
+                id,air_ocean, station_code, biztype,delivery_type,mode_type,
                 serial_no, lot_no, awbbl_no, job_no, do_date,
                 total_pcs, total_pcs_unit,
                 total_weight,total_weight_unit,
                 total_volume, total_volume_unit,
-                est_delivery_date, est_delivery_time,
-                instructions,
-                create_user, create_time,modify_user, modify_time,
-                booking_no,delivery_vehicle_type, delivery_fuel_type,
-                consignee, consignee_name, consignee_exp,consignee_pic, consignee_tel, consignee_fax)
-            VALUES ('".$Id."', '".$oceanInfo['transport_mode']."', '".$oceanInfo['agent']."','".$doNo."','".$biztype."','Awaiting Confirmation','".$delivery_booking['delivery_mode']."',
+                est_delivery_date, est_delivery_time,instructions,
+                create_user, create_time,delivery_vehicle_type,delivery_fuel_type,
+                consignee, consignee_name, consignee_exp)
+            VALUES ('".$doHeaderId."','Ocean', '".$oceanInfo['agent']."','".$biztype."','Awaiting Confirmation','".$mode_type."',
                 '".$serial_no."','".$oceanInfo['m_bol']."','".$oceanInfo['h_bol']."','".$oceanInfo['job_no']."',now(),
                 '".$total_pcs."','".$total_pcs_unit."','".$total_weight."','".$total_weight_unit."','".$total_volume."','".$total_volume_unit."',
-                '".$delivery_booking['delivery_date']."','".$delivery_booking['delivery_date']."',
+                '".$delivery_booking['_delivery_date']."','".$delivery_booking['_delivery_time']."',
                 '".$delivery_booking['special_requirements']."',
-                '"._getLoginName()."',now(),'"._getLoginName()."',now(),
-                '".$oceanInfo['booking_no']."');"; 
+                'KLN_Online',now(),'Subcontractor','Diesel','".$consignee."','".$consignee_name."','".$consignee_exp."');"; 
             
-            /**
-            * sno
-            */
             foreach($ctnrs as $ctnr){
-                "INSERT INTO public.do_detail(
+                $qty = empty($ctnr['qty']) ? "null" : "'".$ctnr['qty']."'";
+                $grs_kgs = empty($ctnr['grs_kgs']) ? "null" : "'".$ctnr['grs_kgs']."'";
+                $cbm = empty($ctnr['cbm']) ? "null" : "'".$ctnr['cbm']."'";
+                $l4_length = empty($ctnr['l4_length']) ? "null" : "'".$ctnr['l4_length']."'";
+                $l4_width = empty($ctnr['l4_width']) ? "null" : "'".$ctnr['l4_width']."'";
+                $l4_height = empty($ctnr['l4_height']) ? "null" : "'".$ctnr['l4_height']."'";
+
+                $sql .="INSERT INTO public.do_detail(
                     do_header_id, pcs, pcs_unit, weight, weight_unit, volume, 
-                    marks, description, create_user, create_time, modify_user, modify_time, 
-                    ctnr, size, seal_no, is_lcl)
-                VALUES ('".$Id."','".$ctnr['qty']."', '".$ctnr['unit']."','".$ctnr['grs_kgs']."','KGS','".$ctnr['cbm']."',
-                    '".$ctnr['marks']."','".$ctnr['description']."','"._getLoginName()."',now(),'"._getLoginName()."',now(),
-                    '".$ctnr['ctnr']."','".$ctnr['size']."','".$ctnr['seal_no']."','".$ctnr['is_lcl']."');";
+                    marks, description, create_user, create_time, 
+                    ctnr, size, seal_no, is_lcl,
+                    length,width,height)
+                VALUES ('".$doHeaderId."',$qty, '".$ctnr['unit']."',$grs_kgs,'KGS',$cbm,
+                    '".$ctnr['marks']."','".$ctnr['description']."','KLN_Online',now(),
+                    '".$ctnr['ctnr']."','".$ctnr['size']."','".$ctnr['seal_no']."','".$ctnr['is_lcl']."',
+                    $l4_length,$l4_width,$l4_height);";
             }    
-
+            common::excuteUpdateSql($sql);
         }
     }
 
-    public static function GeneralDoNo($agent){
-        // 构建前缀:DO- + 站点 + 年(2位) + 月(2位)
-        $prefix = 'DO-' . $agent;
-        $prefix .= date('y'); // 两位年份
-        $prefix .= str_pad(date('m'), 2, '0', STR_PAD_LEFT); // 两位月份
-        // 数据库函数调用:gen_serial_no(key, prefix, length, padding)
-        $sql = "SELECT * FROM gen_serial_no('invoice_no', :prefix, 1, 4)";
-        return common::excuteOneSql($sql);
+    public static function combineContactInfoString($contact){
+        $backString = "";
+        if ($contact !== null) {
+            $address1 = trim($contact['address_1'] ?? '');
+            $address2 = trim($contact['address_2'] ?? '');
+            $address3 = trim($contact['address_3'] ?? '');
+            $address4 = trim($contact['address_4'] ?? '');
+            $city     = trim($contact['city'] ?? '');
+            $zipcode  = trim($contact['postal_code'] ?? '');
+            $country  = trim($contact['country'] ?? '');
+
+            // 拼接非空的地址行
+            if ($address1 !== '') {
+                $backString .= $address1;
+            }
+
+            if ($address2 !== '') {
+                $backString .= ($backString !== '' ? "\n" : '') . $address2;
+            }
+
+            if ($address3 !== '') {
+                $backString .= ($backString !== '' ? "\n" : '') . $address3;
+            }
+
+            if ($address4 !== '') {
+                $backString .= ($backString !== '' ? "\n" : '') . $address4;
+            }
+
+            // 添加城市、邮编和国家
+            $location = trim("$city $zipcode $country");
+            if ($location !== '') {
+                $backString .= ($backString !== '' ? "\n" : '') . $location;
+            }
+        }
+
+        return trim($backString);
     }
 }
 ?>

+ 57 - 2
utils/utils.class.php

@@ -453,7 +453,19 @@ class utils {
             || ($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "verifcation_code")
             || ($_REQUEST["action"] == "login" && $_REQUEST["operate"] == "check_uname")
             || ($_REQUEST["action"] == "ocean_order" && $_REQUEST["operate"] == "setting_ocean_order_display")
-            || ($_REQUEST["action"] == "ocean_booking" && $_REQUEST["operate"] == "setting_display")){
+            || ($_REQUEST["action"] == "ocean_booking" && $_REQUEST["operate"] == "setting_display")
+            //opreation_log  过滤非下载的所有请求
+            || ($_REQUEST["action"] == "opreation_log" && $_REQUEST["operate"] != "excel")
+            //monitoring_setting 过滤非查询和保存的所有请求
+            || ($_REQUEST["action"] == "monitoring_setting" 
+                && !($_REQUEST["operate"] == "monitoring_rules_init" || $_REQUEST["operate"] == "monitoring_rules_do"))
+            //notifications_rules 过滤以下和登录自动轮播和五分钟有消息提醒
+            || ($_REQUEST["action"] == "notifications_rules" 
+                && ($_REQUEST["operate"] == "check_notifications_message" 
+                    || $_REQUEST["operate"] == "notifications_see_all"
+                    || ($_REQUEST["operate"] == "notifications_init" && $_REQUEST['info_type'] == 'true')
+                    || ($_REQUEST["operate"] == "notifications_init" && !empty($_REQUEST['current_time']))))    
+            ){
             return;
         }
         //排除robot的相关的记录
@@ -531,6 +543,22 @@ class utils {
             "ocean_order=document_upload" => array("page" =>"Tracking","operate"=>"document_upload"),
             "ocean_order=document_upload_do" => array("page" =>"Tracking","operate"=>"document_upload_do"),
 
+            "opreation_log=excel" => array("page" =>"Opreation_Log","operate"=>"Download"),
+            "ocean_order=default_vgm" => array("page" =>"Tracking","operate"=>"Enter Default VGM Settings"),
+            "ocean_order=default_vgm_update" => array("page" =>"Tracking","operate"=>"Save Default VGM Settings"),
+
+            "notifications_rules=notifications_init" => array("page" =>"Top Section","operate"=>"Save Notifiation bell"),
+            "notifications_rules=notifications_read" => array("page" =>"Top Section","operate"=>"Read Message"),
+            "notifications_rules=notifications_message_init" => array("page" =>"System_Message","operate"=>"Enter Page"),
+
+            "system_setting=subscribe_shipment" => array("page" =>"Dashboard/Tracking","operate"=>"Subscribe Shipment"),
+            "system_setting=personal_profile_save" => array("page" =>"System_Setting","operate"=>"Personal Profile"),
+            "system_setting=subscribe_notification_init" => array("page" =>"System_Setting","operate"=>"Subscribe_Notification"),
+            "system_setting=subscribe_notification_event_update" => array("page" =>"System_Setting","operate"=>"Subscribe_Notification"),
+
+            "monitoring_setting=monitoring_rules_search" => array("page" =>"System_Setting","operate"=>"Monitoring_Setting"),
+            "monitoring_setting=monitoring_rules_do" => array("page" =>"System_Setting","operate"=>"Monitoring_Setting"),
+
             "tools=mark_save" => array("page" =>"Tools","operate"=>"Mark_Save"),
             "password=" => array("page" =>"Profile","operate"=>"Change password"));
         if($action == "ajax" && $operate == "save_setting_display"){
@@ -544,6 +572,9 @@ class utils {
         return $operationConvertName[$action."=".$operate];
     }
 
+    /**
+     *  这里是配置需要自定义的 operation Details
+     */
     public static function analyzeOperationDetail($action,$operate){
         $detail = "";
         if($action == "login" && $operate == "do_login"){
@@ -635,7 +666,7 @@ class utils {
         if(($action == "ocean_order") && $operate == "ams_isf_log"){
             $detail = "Enter AMS/ISF Page";  
         }
-        if(($action == "ocean_booking" || $action == "ocean_order") && $operate == "excel"){
+        if(($action == "ocean_booking" || $action == "ocean_order" || $action == "opreation_log") && $operate == "excel"){
             $detail = "Filter_condition:" . $_REQUEST['excel_filter_condition']." Selected Fields:". $_REQUEST['selected_fields'];
         }
         //Tracking詳情頁download的file(顯示file名稱)
@@ -655,6 +686,30 @@ class utils {
         if(($action == "ocean_order") && $operate == "document_upload"){
             $detail = "Enter Upload Files page";
         }
+
+        if(($action == "notifications_rules") && $operate == "notifications_init"){
+            $detail = "點擊頂部欄的消息鈴鐺進入";
+        }
+        if(($action == "system_setting") && $operate == "personal_profile_save"){
+            if($_REQUEST['save_model'] == "no_profile"){
+                $detail = "Save Personal Preference: ".common::check_input(utils::jsonFiltration("null", "\"\"", json_encode($_REQUEST)));
+            }else{
+                $detail = "Save Basic Information: ".common::check_input(utils::jsonFiltration("null", "\"\"", json_encode($_REQUEST)));
+            }
+        }
+
+        if(($action == "system_setting") && $operate == "subscribe_notification_init"){
+            $detail = "點擊進入這個tab頁";
+        }
+        if(($action == "system_setting") && $operate == "subscribe_notification_event_update"){
+            $detail = "保存頁面操作: ".common::check_input(utils::jsonFiltration("null", "\"\"", json_encode($_REQUEST)));
+        }
+        if(($action == "monitoring_setting") && $operate == "monitoring_rules_search"){
+            $detail = "點擊進入這個tab頁";
+        }
+        if(($action == "monitoring_setting") && $operate == "monitoring_rules_do"){
+            $detail = "保存頁面操作: ".common::check_input(utils::jsonFiltration("null", "\"\"", json_encode($_REQUEST)));
+        }
         
         return $detail;