ShuanghongS 9 mesi fa
parent
commit
314af7473a

+ 10 - 6
main_new_version.php

@@ -88,20 +88,24 @@ switch ($action) {
                     foreach ($ll as $v) {
                         if($v['s_column'] =="Ocean Booking" || $v['s_column'] =="Ocean B/L Info."){
                             $urlData = $menuSetting[$v['s_column']];
-                            $menuList[] = array("index"=>$index,"label"=>$urlData['label'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
+                            $menuList[] = array("index"=>"$index","label"=>$urlData['label'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
                             $index = $index + 1;
                         }
                     }
                 }
             }
+
+            // $menuList[] = array("index"=>$index,"label"=>"System Management","icon"=>"icon_system__management_fill_b","type"=>"list",
+            //     "children"=>array(array("index" =>$index.'-1',"label" =>"Operation Log","path"=>"/Operationlog")));
+            $systemManagement = array("index"=>"$index","label"=>"System Management","icon"=>"icon_system__management_fill_b","type"=>"list"); 
+            $children  = array();   
             //只有chud的账户可以看日志记录
             if(_getLoginName() == "chud" || _getLoginName() == "IT.Andywu" || _getLoginName() == "ra.admin"){
-                $menuList[] = array("index"=>$index,"label"=>"System Management","icon"=>"icon_system__management_fill_b","type"=>"list",
-                    "children"=>array(array("index" =>$index.'-1',"label" =>"Operation Log","path"=>"/Operationlog")));
-                // $menuList[] = array("index"=>$index,"label"=>"System Management","icon"=>"icon_system__management_fill_b","type"=>"list",
-                //     "children"=>array(array("index" =>$index.'-1',"label" =>"Operation Log","path"=>"/Operationlog"),
-                //     array("index" =>$index.'-2',"label" =>"System Settings","path"=>"/SystemSettings")));    
+                $children[] = array("index" =>$index.'-1',"label" =>"Operation Log","path"=>"/Operationlog");  
             }
+            $children[] = array("index" =>$index.'-2',"label" =>"System Settings","path"=>"/SystemSettings");
+            $systemManagement["children"] = $children;
+            $menuList[] = $systemManagement;
         }
         common::echo_json_encode(200, $menuList);
         exit();

+ 11 - 3
service/column.class.php

@@ -239,7 +239,9 @@ class column {
             //formatter
             if (!empty($spconfig[$rs['database_column_name']]['formatter'])){
                 $temp['formatter'] = $spconfig[$rs['database_column_name']]['formatter'];
-
+                if($temp['formatter'] == "number"){
+                    $temp['digits'] = $spconfig[$rs['database_column_name']]['digits'];
+                }
             }else{
                 $temp['formatter'] = "";
             }
@@ -272,7 +274,10 @@ class column {
             "created_time" =>array("formatter" =>"dateTime"),
             "confirmation_time" =>array("formatter" =>"dateTime"),
             "f_etd" =>array("formatter" =>"date"),
-            "m_eta" =>array("formatter" =>"date"));
+            "m_eta" =>array("formatter" =>"date"),
+            "qty" =>array("formatter" =>"number","digits"=>0),
+            "piece_count" =>array("formatter" =>"number","digits"=>3),
+            "weight" =>array("formatter" =>"number","digits"=>3));
         }
         if ($type == "Ocean_Search"){
             return array("booking_no" =>array("type" =>"link"),
@@ -282,7 +287,10 @@ class column {
             "status" =>array("type" =>"status"),
             "created_time" =>array("formatter" =>"dateTime"),
             "etd" =>array("formatter" =>"date"),
-            "eta" =>array("formatter" =>"date"));
+            "eta" =>array("formatter" =>"date"),
+            "qty" =>array("formatter" =>"number","digits"=>0),
+            "piece_count" =>array("formatter" =>"number","digits"=>3),
+            "weight" =>array("formatter" =>"number","digits"=>3));
         }
         if ($type == "Operation_Search"){
             return array("operation_time" =>array("formatter" =>"dateTime"));

+ 1 - 1
service/login.class.php

@@ -1349,7 +1349,7 @@ class login {
                         e.description,s.event_type as eventtype, 
                         s.event_code as eventcode, s.event_city as eventcity,
                         (select time_zone from public.city_timezone where uncode = s.event_code) as timezone,
-                        (select uncity from public.ports where uncode = s.event_code) as uncity,
+                        s.event_city as uncity,
                         case when s.event_base ='I'  then 'IFFREC'::text
                             when s.event_base ='AE'  then 'IFFONB'::text
                             when s.event_base ='VD'  then 'IFFDEP'::text

+ 15 - 1
service/ocean_booking.class.php

@@ -413,8 +413,22 @@ class ocean_booking {
         //处理返回booking的 Container 信息数据
         $booking_container_column = array();
         $container_column = column::getInstance()->getDisplayColumnAll('Booking_Container');
+        $booking_Container_config = array("QTY" => array("formatter"=>"number","digits"=>0),
+                "KGS" => array("formatter"=>"number","digits"=>3),
+                "CBM" => array("formatter"=>"number","digits"=>3));
         foreach($container_column as $cc){
-            $booking_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],"formatter" =>"","type" =>"normal");
+            if(!empty($booking_Container_config[$cc['name']])){
+                $booking_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],
+                "formatter" =>$booking_Container_config[$cc['name']]["formatter"],
+                "digits" =>$booking_Container_config[$cc['name']]["digits"],
+                "type" =>"normal");
+            }else{
+                $booking_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],
+                "formatter" =>"",
+                "digits" =>"",
+                "type" =>"normal");
+            }
+            
         }
         if (!empty($ocean['_booking_no'])) {
             $sql = "SELECT " . column::getInstance()->getSearchSql('Booking_Container') . " from ocean_booking_container where lower(serial_no) = '" . strtolower($serial_no) . "'";

+ 14 - 1
service/ocean_order.class.php

@@ -1116,8 +1116,21 @@ class ocean_order {
         //处理Container :配置Ocean_Container字段 UI 需要的字段有:Container.no Packing,quantity,Gross weight(kg),Gross weight(LB),CBM,seal#,size.service
         $ocean_container_column = array();
         $container_column = column::getInstance()->getDisplayColumnAll('Ocean_Container');
+        $container_column_config = array("Quantity" => array("formatter"=>"number","digits"=>0),
+                "Gross Weight" => array("formatter"=>"number","digits"=>3),
+                "Gross Weight" => array("formatter"=>"number","digits"=>3),
+                "CBM" => array("formatter"=>"number","digits"=>3),
+                "CFT" => array("formatter"=>"number","digits"=>3));
         foreach($container_column as $cc){
-            $ocean_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],"formatter" =>"","type" =>"normal");
+            if(!empty($container_column_config[$cc['name']])){
+                $ocean_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],
+                "formatter" =>$container_column_config[$cc['name']]["formatter"],
+                "digits" =>$container_column_config[$cc['name']]["digits"],
+                "type" =>"normal");
+            }else{
+                $ocean_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],"formatter" =>"","type" =>"normal");
+            }
+
         }
         $sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container') . ",net_lbs from oc_container where lower(serial_no) = '" . strtolower($serial_no) . "'";
         $rss = common::excuteListSql($sql);

+ 178 - 168
service/tools.class.php

@@ -155,14 +155,14 @@ class tools {
                 $last_name = common::check_input($_POST['last_name']);
                 $sql = "update public.ra_online_user set first_name = '$first_name',last_name = '$last_name'  where lower(user_login) = '".strtolower(_getLoginName())."'";
             }else{
-                $date_fromat = common::check_input($_POST['date_fromat']);
-                $numbers_format = common::check_input($_POST['numbers_format']);
+                $date_format = common::check_input($_REQUEST['date_format']);
+                $numbers_format = common::check_input($_REQUEST['numbers_format']);
                 $exist_kln_user = common::excuteObjectSql("select user_login from  public.kln_user_extend where  lower(user_login) = '".strtolower(_getLoginName())."'");
                 if (!empty($exist_kln_user['user_login'])){
-                    $sql = "update public.kln_user_extend set date_fromat = '$date_fromat',numbers_format = '$numbers_format'  where lower(user_login) = '".strtolower(_getLoginName())."'";
+                    $sql = "update public.kln_user_extend set date_format = '$date_format',numbers_format = '$numbers_format'  where lower(user_login) = '".strtolower(_getLoginName())."'";
                 } else {
                     $sql = "INSERT INTO public.kln_user_extend(user_login, date_format, numbers_format, subscribe_hbol)
-                        VALUES ('"._getLoginName()."', '$date_fromat', '$numbers_format', null);";
+                        VALUES ('"._getLoginName()."', '$date_format', '$numbers_format', null);";
                 }
             }
             common::excuteUpdateSql($sql);
@@ -294,12 +294,10 @@ class tools {
             $airMilestone = array();
             foreach($milestones as $milestone){
                 if($milestone['type'] == "air"){
-                    $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
-                    "code"=>$milestone['code'],"description"=>$milestone['description']);
+                    $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
                 } 
                 if($milestone['type'] == "sea"){
-                    $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
-                    "code"=>$milestone['code'],"description"=>$milestone['description']);
+                    $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
                 }
             }
             $ret["OceanCheckBoxList"] = $oceanMilestone;
@@ -310,7 +308,7 @@ class tools {
             $event =common::getEDICtnrEvent();
             $ctnrStatus = array();
             foreach($event as $e){
-                $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
+                $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
             }
             $ret["CtnrCheckBoxList"] = $ctnrStatus; 
             common::echo_json_encode(200,$ret);
@@ -340,16 +338,16 @@ class tools {
                 $monitoringRules = common::excuteListSql($sql);
                 $arrTmp = array('monitoringRules' => $monitoringRules, 
                     'rc' => intval($rc),
-                    'ps' => $ps,
-                    'cp' => $cp,
-                    'tp' => $tp
+                    'ps' => intval($ps),
+                    'cp' => intval($cp),
+                    'tp' => intval($tp)
                 );
             } else {
                 $arrTmp = array('searchData' => array(), 
-                    'rc' => $rc,
-                    'ps' => $ps,
-                    'cp' => $cp,
-                    'tp' => $tp,
+                    'rc' => intval($rc),
+                    'ps' => intval($ps),
+                    'cp' => intval($cp),
+                    'tp' => intval($tp)
                 );
             }
             common::echo_json_encode(200,$arrTmp);
@@ -373,17 +371,8 @@ class tools {
 
             $rules = $this->getSubscribeRules($rules_type,$subscribe_rules);
             
-            //数据转换前端需要的
-            $converMode = array();
-            $shipment_transport_mode_arr = explode(";", $rules["shipment_transport_mode"]);
-            foreach($shipment_transport_mode_arr as $model){
-                if (strtolower($model) == "sea"){
-                    $converMode[] = 'Ocean';
-                }else{
-                    $converMode[] = ucfirst($model);
-                }
-            }
-            $rules["shipment_transport_mode"] = utils::implode(";",$converMode);
+            //数据转换前端需要的显示的格式
+            $rules["shipment_transport_mode"] = utils::converModeToDisplay($rules["shipment_transport_mode"]);
 
             $monitoring_data[$rules_type] = $rules;
             common::echo_json_encode(200,$monitoring_data);
@@ -435,20 +424,23 @@ class tools {
             $delayData = array();
             $changeData = array(); 
             if ($rules_type == "all"){
-                $milestoneData = $this->getNotifications("Milestone_Update","all");
-                $containerData = $this->getNotifications("Container_Status_Update","all");
-                $delayData = $this->getNotifications("Departure/Arrival_Delay","all");
-                $changeData = $this->getNotifications("ETD/ETA_Change","all");
+                $rules_type = "Milestone_Update;Container_Status_Update;Departure/Arrival_Delay;ETD/ETA_Change";
+                $allData = $this->getNotifications($rules_type,"all");
+
+                $milestoneData = $allData['Milestone_Update'];
+                $containerData = $allData['Container_Status_Update'];
+                $delayData = $allData['Departure/Arrival_Delay'];
+                $changeData = $allData['ETD/ETA_Change'];
             } else {
                 $data = $this->getNotifications($rules_type,"all");
                 if($rules_type == "Milestone_Update"){
-                    $milestoneData = $data;
+                    $milestoneData = $data['Milestone_Update'];
                 }elseif($rules_type == "Container_Status_Update"){
-                    $containerData = $data;
+                    $containerData = $data['Container_Status_Update'];
                 }elseif($rules_type == "Departure/Arrival_Delay"){
-                    $delayData = $data;
+                    $delayData = $data['Departure/Arrival_Delay'];
                 }elseif($rules_type == "ETD/ETA_Change"){
-                    $changeData = $data;
+                    $changeData = $data['ETD/ETA_Change'];
                 }
             }
 
@@ -490,8 +482,8 @@ class tools {
             $rules_type = common::check_input($_REQUEST['rules_type']);
             $frequency_type = common::check_input($_REQUEST['frequency_type']);  //这个只会传daily 和weekly
 
-            $data = $this->getNotifications($rules_type,$frequency_type);
-            $moreData = $data[strtolower($frequency_type)];
+            $notificationsData = $this->getNotifications($rules_type,$frequency_type);
+            $moreData = $notificationsData[$rules_type][strtolower($frequency_type)];
 
             //这个函数里面带有分开计数的信息
             $dataInfo =utils::getDailyAndweeklyFrist($moreData);
@@ -518,16 +510,44 @@ class tools {
                 $returnData["notificationList"] = $notificationList;
             }
             //点击seall会默认全部标记为已读
+            $all_id = $notificationsData[$rules_type][strtolower($frequency_type."_all_id")];
+            $returnData["all_id"] = $all_id;
+            if(!empty($all_id)){
+                $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$all_id)));
+                $markReadSql = "update public.kln_notifiation_info set is_send_message = true where id in ($more_param)";
+                //common::excuteUpdateSql($markReadSql);
+            }
             
             common::echo_json_encode(200,$returnData);
             exit();
         }
 
         if($operate == "notifications_read"){
-            
-          
+            $read_type = common::check_input($_POST["read_type"]);
+            $id = $_POST["id"];
+            //代表改用户下的所有信息全部标记为已读
+            if ($read_type == "true"){
+                $rs = common::excuteUpdateSql("update public.kln_notifiation_info set is_send_message = true where lower(user_login) = '".strtolower(_getLoginName())."'");
+            }else{
+                $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$id)));
+                $markReadSql = "update public.kln_notifiation_info set is_send_message = true where id in ($more_param)";
+                $rs = common::excuteUpdateSql($markReadSql);
+            }
+            if ($rs === FALSE){
+                $returnData = array("msg" =>"Error");
+                common::echo_json_encode(500,$returnData);
+            }else{
+                $returnData = array("msg" =>"Success");
+                common::echo_json_encode(200,$returnData);
+            }
             exit();
         }
+
+        if ($operate == "notifications_message_init"){
+            $rules_type = common::check_input($_REQUEST['rules_type']);
+            //查询所有情况得未读情况 查询最近一年的情况
+            //"select * from  public.kln_notifiation_info where ";
+        }
     }
 
     /**
@@ -553,12 +573,10 @@ class tools {
             $airMilestone = array();
             foreach($milestones as $milestone){
                 if($milestone['type'] == "air"){
-                    $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
-                    "code"=>$milestone['code'],"description"=>$milestone['description']);
+                    $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
                 } 
                 if($milestone['type'] == "sea"){
-                    $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
-                    "code"=>$milestone['code'],"description"=>$milestone['description']);
+                    $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
                 }
             }
             $ret["OceanCheckBoxList"] = $oceanMilestone;
@@ -566,12 +584,8 @@ class tools {
 
             $oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
             $airMilestoneSetting = !empty($ret['air_milestone']) ? explode(";",$ret['air_milestone']): array();
-            //转换描述,因为前端支持description,没有code的对应
-            $oceanMilestoneDescription = $this->convertDescriptionForMilestoneAndCtnr("Milestone_Update",$oceanMilestoneSetting,$oceanMilestone);
-            //转换描述,因为前端支持description,没有code的对应
-            $airMilestoneDescription = $this->convertDescriptionForMilestoneAndCtnr("Milestone_Update",$airMilestoneSetting,$airMilestone);
-            $ret["OceanCheckedList"] = $oceanMilestoneDescription;
-            $ret["AirCheckedList"] = $airMilestoneDescription;
+            $ret["OceanCheckedList"] = $oceanMilestoneSetting;
+            $ret["AirCheckedList"] = $airMilestoneSetting;
         }
         //Milestone Update的结构处理
         if($rule_name == "Container_Status_Update"){
@@ -579,14 +593,12 @@ class tools {
             $event =common::getEDICtnrEvent();
             $ctnrStatus = array();
             foreach($event as $e){
-                $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
+                $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
             }
             $ret["CtnrCheckBoxList"] = $ctnrStatus;
            
             $ctnrStatusSetting = !empty($ret['ocean_ctnr_status']) ? explode(";",$ret['ocean_ctnr_status']) : array();
-            //转换描述,因为前端支持description,没有code的对应
-            $ctnrStatusDescription = $this->convertDescriptionForMilestoneAndCtnr("Container_Status_Update",$ctnrStatusSetting,$event);
-            $ret["CtnrCheckedList"] = $ctnrStatusDescription;
+            $ret["CtnrCheckedList"] = $ctnrStatusSetting;
             
         }
         return $ret;
@@ -648,38 +660,6 @@ class tools {
         return $arrTmp;
     }
 
-    /**
-     * 转换描述,因为前端支持description,没有code的对应
-     */
-    public function convertDescriptionForMilestoneAndCtnr($type,$codeArr,$mappingData){
-        $descriptions = array();
-        $key = $type == "Milestone_Update" ? "code" : "event_name";
-        foreach($codeArr as $code){
-            foreach($mappingData as $md){
-                if($md[$key] == $code){
-                    $descriptions[] = common::check_input($md['description']);
-                }
-            }
-        }
-        return $descriptions;
-    }
-
-    /**
-     * 转换code,因为前端提交的是description,没有code的
-     */
-    public function convertCodeForMilestoneAndCtnr($type,$descriptionArr,$mappingData){
-        $codes = array();
-        $key = $type == "Milestone_Update" ? "code" : "event_name";
-        foreach($descriptionArr as $description){
-            foreach($mappingData as $md){
-                if($md['description'] == $description){
-                    $codes[] = common::check_input($md[$key]);
-                }
-            }
-        }
-        return $codes;
-    }
-
     public function getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,$notifications_type,$id){
         $sql = "";
         //先删后加
@@ -703,8 +683,10 @@ class tools {
             $weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
             $weekly_time_zone = common::check_input($_POST['weekly_time_zone']);
         }
-        $method_by_email = common::check_input($_POST['method_by_email']);
-        $method_by_message = common::check_input($_POST['method_by_message']);
+
+        
+        $method_by_email = !empty($_POST['method_by_email']) ? common::check_input($_POST['method_by_email']) : 'false';
+        $method_by_message = !empty($_POST['method_by_message']) ? common::check_input($_POST['method_by_message']) : 'false';
         $event_details = common::check_input($_POST['event_details']);
         $frequency_display = common::check_input($_POST['frequency_display']);
         $method_display = common::check_input($_POST['method_display']);
@@ -715,15 +697,7 @@ class tools {
         $shipment_etd_limit = "";
         $shipment_eta_limit = "";
         if($notifications_type == "Monitoring"){
-            $converMode = array();
-            foreach($_POST['shipment_transport_mode'] as $model){
-                if (strtolower($model) == "ocean"){
-                    $converMode[] = 'sea';
-                }else{
-                    $converMode[] = strtolower($model);
-                }
-            }
-            $shipment_transport_mode = utils::implode(";",$converMode);
+            $shipment_transport_mode = utils::converModeToDB($_POST['shipment_transport_mode']);
             $shipment_etd_limit = common::check_input($_POST['shipment_etd_limit']);
             $shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
         }
@@ -737,14 +711,12 @@ class tools {
                 if($milestone['type'] == "air"){
                     $airMilestone[] = $milestone;
                 } 
-                if($milestone['type'] == "ocean"){
+                if($milestone['type'] == "sea"){
                     $oceanMilestone[] = $milestone;
                 }
             }
-            $ocean_milestone = $this->convertCodeForMilestoneAndCtnr("Milestone_Update",$_POST['ocean_milestone'],$oceanMilestone);
-            $air_milestone = $this->convertCodeForMilestoneAndCtnr("Milestone_Update",$_POST['air_milestone'],$airMilestone);
-            $ocean_milestone = utils::implode(";",$ocean_milestone);
-            $air_milestone =  utils::implode(";",$air_milestone);
+            $ocean_milestone = utils::implode(";",$_POST['ocean_milestone']);
+            $air_milestone =  utils::implode(";",$_POST['air_milestone']);
 
             $sql.="INSERT INTO public.notifications_rules(
                     user_login, notifications_type, rules_type, ocean_milestone, 
@@ -761,8 +733,7 @@ class tools {
 
         if ($rules_type == "Container_Status_Update"){
             $event = common::getEDICtnrEvent();
-            $ocean_ctnr_status = $this->convertCodeForMilestoneAndCtnr("Container_Status_Update",$_POST['ocean_ctnr_status'],$event);
-            $ocean_ctnr_status = utils::implode(";",$ocean_ctnr_status);
+            $ocean_ctnr_status = utils::implode(";",$_POST['ocean_ctnr_status']);
 
             $sql.="INSERT INTO public.notifications_rules(
                     user_login, notifications_type, rules_type, ocean_ctnr_status, 
@@ -818,26 +789,26 @@ class tools {
         }
 
         if ($rules_type == "ETD/ETA_Change"){
-            $ocean_etd_change = common::check_input($_POST['ocean_etd_change']);
+            $ocean_etd_change = !empty($_POST['ocean_etd_change']) ? common::check_input($_POST['ocean_etd_change']) : 'false';
             $ocean_etd_old_sub_new = common::check_input($_POST['ocean_etd_old_sub_new']);
             $ocean_etd_old_sub_new_unit = common::check_input($_POST['ocean_etd_old_sub_new_unit']);
             if(!empty($ocean_etd_old_sub_new_unit)){
                 $ocean_etd_old_sub_new_unit = $ocean_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
             }
-            $ocean_eta_change = common::check_input($_POST['ocean_eta_change']);
+            $ocean_eta_change = !empty($_POST['ocean_eta_change']) ? common::check_input($_POST['ocean_eta_change']) : 'false';
             $ocean_eta_old_sub_new = common::check_input($_POST['ocean_eta_old_sub_new']);
             $ocean_eta_old_sub_new_unit = common::check_input($_POST['ocean_eta_old_sub_new_unit']);
             if(!empty($ocean_eta_old_sub_new_unit)){
                 $ocean_eta_old_sub_new_unit = $ocean_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
             }
 
-            $air_etd_change = common::check_input($_POST['air_etd_change']);
+            $air_etd_change = !empty($_POST['air_etd_change']) ? common::check_input($_POST['air_etd_change']) : 'false';
             $air_etd_old_sub_new = common::check_input($_POST['air_etd_old_sub_new']);
             $air_etd_old_sub_new_unit = common::check_input($_POST['air_etd_old_sub_new_unit']);
             if(!empty($air_etd_old_sub_new_unit)){
                 $air_etd_old_sub_new_unit = $air_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
             }
-            $air_eta_change = common::check_input($_POST['air_eta_change']);
+            $air_eta_change = !empty($_POST['air_eta_change']) ? common::check_input($_POST['air_eta_change']): 'false';
             $air_eta_old_sub_new = common::check_input($_POST['air_eta_old_sub_new']);
             $air_eta_old_sub_new_unit = common::check_input($_POST['air_eta_old_sub_new_unit']);
             if(!empty($air_eta_old_sub_new_unit)){
@@ -871,7 +842,7 @@ class tools {
         if(isset($_POST['id']) && !empty($_POST['id'])){
             $sql_where = " and id <> '".common::check_input($_POST['id'])."'";
         } 
-        $rules = common::excuteOneSql("select * from public.notifications_rules where notifications_type = 'Monitoring' and rules_type = '".$rules_type."'
+        $rules = common::excuteListSql("select * from public.notifications_rules where notifications_type = 'Monitoring' and rules_type = '".$rules_type."'
                     and  lower(user_login) = '".strtolower(_getLoginName())."' $sql_where");
         foreach($rules as $rule){
             //判断range 是否一样
@@ -879,12 +850,18 @@ class tools {
             $range_flag = true;   
             foreach($checkRangeFiled as $filed){
                 if($filed == "shipment_transport_mode"){
-                    $postValue = utils::implode(";",$_POST[$filed]);
+                    $postValue = utils::converModeToDB($_POST[$filed]);
+                    $rule_mode_arr = explode(";", $rule[$filed]);
+                    $post_mode_arr = explode(";", $postValue);
+                    if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
+                        $range_flag = false;
+                    }
                 }else{
+                    //正常字段直接比较就行
                     $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
-                }
-                if($postValue != $rule[$filed]){
-                    $range_flag = false;
+                    if($postValue != $rule[$filed]){
+                        $range_flag = false;
+                    }
                 }
             }
 
@@ -897,14 +874,23 @@ class tools {
             $details_flag = true;     
             foreach($checkDetailsFiled as $filed){
                 if($filed == "ocean_milestone" || $filed == "air_milestone" || $filed == "ocean_ctnr_status"){
+                    $rule_mode_arr = explode(";", $rule[$filed]);
+                    $post_mode_arr = explode(";", $_POST[$filed]);
+                    if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
+                        $details_flag = false;
+                    }
                     $postValue = utils::implode(";",$_POST[$filed]);
-                }else{
+                } elseif ($filed == "ocean_etd_change" || $filed == "ocean_eta_change" || $filed == "air_etd_change" || $filed == "air_eta_change"){
+                    $post_boolean = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f":"t";
+                    if($post_boolean != $rule[$filed]){
+                        $details_flag = false;
+                    }
+                } else {
                     $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
+                    if($postValue != $rule[$filed]){
+                        $details_flag = false;
+                    }
                 }
-                if($postValue != $rule[$filed]){
-                    $details_flag = false;
-                }
-
             }    
            
             //判断frequency 是否一样
@@ -922,7 +908,7 @@ class tools {
             $checkMethodFiled = array("method_by_email","method_by_message");
             $method_flag = true; 
             foreach($checkMethodFiled as $filed){
-                $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
+                $postValue = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f" : "t";
                 if($postValue != $rule[$filed]){
                     $method_flag = false;
                 }
@@ -934,7 +920,7 @@ class tools {
                 continue;
             }
             //前三个重回,后面不重合,提示但允许保存
-            if($range_flag && $details_flag){
+            if($range_flag && $details_flag && $_POST['is_similar_rule'] <> 'true'){
                 $msg = "Similar Rule Detected";
                 continue;
             }
@@ -956,6 +942,8 @@ class tools {
                                     and  ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
         }
         
+        $more_param = common::getInNotInSqlForSearch($notifiation_type);
+
         $sql = "select ni.*,
                     case when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'days'
                             then (EXTRACT(DAY FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
@@ -974,64 +962,86 @@ class tools {
                         left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from 
                             from public.kln_ocean oo 
                             where oo.serial_no = ni.serial_no limit 1) ccc on true
-                where lower(ni.user_login) = '"._getLoginName()."' 
-                        and ni.notifiation_type = '".$notifiation_type."'
+                where lower(ni.user_login) = '".strtolower(_getLoginName())."' 
+                        and lower(ni.notifiation_type) in ($more_param)
                     ".$sql_where." and ni.notifications_method = true order by ni.insert_date desc";
         error_log($sql);
-        $data = common::excuteListSql($sql);
-        //统一处理数据Instant Daily weekly_week 先分开在处理
-        $instant = array();
-        $daily = array();
-        $daily_uniqe = array();
-        $daily_all_id = array();
-
-        $weekly  = array();
-        $weekly_uniqe = array();
-        $weekly_all_id  = array();
-
-        foreach($data as $d){
-            if ($d['frequency_type'] == "Instant"){
-                $instant[] = $d;
-            }
-            //类型为这个时才用这个去重,否则要加上描述(转船的情况,会让相同的HBOL显示)
-            $uniqe_str = $d['serial_no'];
-            if ($notifiation_type == "Departure/Arrival_Delay"){
-                $uniqe_str = $d['serial_no']."_".$d['delay_name'];
-            } else if($notifiation_type == "ETD/ETA_Change"){
-                $uniqe_str = $d['serial_no']."_".$d['date_change_name'];
+
+        $data_all_type = common::excuteListSql($sql);
+        $data_group = array();
+        $data_group_uniqe = array();
+        foreach($data_all_type as $dat){
+            $uniqe_group_str = $dat['notifiation_type'];
+            if(utils::in_array($uniqe_group_str,$data_group_uniqe)){
+                $tempArr = $data_group[$uniqe_group_str];
+                $tempArr[] = $dat;
+                $data_group[$uniqe_group_str] = $tempArr;
+            } else {
+                $data_group[$uniqe_group_str] = array($dat);
+                $data_group_uniqe[] = $uniqe_group_str;
             }
-            if ($d['frequency_type'] == "Daily"){
-                $daily_all_id[] = $d["id"];
-                if(utils::in_array($uniqe_str,$daily_uniqe)){
-                    $temp = $daily[$uniqe_str];
-                    //previous只更新最近的一次,并且是需要查询详细的时候,才放开previous的查询
-                    if(empty($temp['previous']) && $frequency_type <> "all"){
-                        $temp['previous'] = $d;
+        }
+
+        $retData = array();
+        foreach($data_group as $key => $data){
+            $notifiation_type_db = $key;
+            //统一处理数据Instant Daily weekly_week 先分开在处理
+            $instant = array();
+            $daily = array();
+            $daily_uniqe = array();
+            $daily_all_id = array();
+
+            $weekly  = array();
+            $weekly_uniqe = array();
+            $weekly_all_id  = array();
+            foreach($data as $d){
+                if ($d['frequency_type'] == "Instant"){
+                    $instant[] = $d;
+                }
+                //类型为这个时才用这个去重,否则要加上描述(转船的情况,会让相同的HBOL显示)
+                $uniqe_str = $d['serial_no'];
+                if ($notifiation_type_db == "Departure/Arrival_Delay"){
+                    $uniqe_str = $d['serial_no']."_".$d['delay_name'];
+                } else if($notifiation_type_db == "ETD/ETA_Change"){
+                    $uniqe_str = $d['serial_no']."_".$d['date_change_name'];
+                }
+                if ($d['frequency_type'] == "Daily"){
+                    if($d["is_send_message"] <> 't'){
+                        $daily_all_id[] = $d["id"];
+                    }
+                    if(utils::in_array($uniqe_str,$daily_uniqe)){
+                        $temp = $daily[$uniqe_str];
+                        //previous只更新最近的一次,并且是需要查询详细的时候,才放开previous的查询
+                        if(empty($temp['previous']) && $frequency_type <> "all"){
+                            $temp['previous'] = $d;
+                        }
+                        $daily[$uniqe_str] = $temp;
+                    } else {
+                        $daily[$uniqe_str] = $d;
+                        $daily_uniqe[] = $uniqe_str;
                     }
-                    $daily[$uniqe_str] = $temp;
-                } else {
-                    $daily[$uniqe_str] = $d;
-                    $daily_uniqe[] = $uniqe_str;
                 }
-            }
-            if ($d['frequency_type'] == "Weekly"){
-                $weekly_all_id[] = $d["id"];
-                if(utils::in_array($uniqe_str,$weekly_uniqe)){
-                    $temp = $weekly[$uniqe_str];
-                    //previous只更新最近的一次,并且是需要查询详细的时候,才放开previous的查询
-                    if(empty($temp['previous']) && $frequency_type <> "all"){
-                        $temp['previous'] = $d;
+                if ($d['frequency_type'] == "Weekly"){
+                    if($d["is_send_message"] <> 't'){
+                        $weekly_all_id[] = $d["id"];
+                    }
+                    if(utils::in_array($uniqe_str,$weekly_uniqe)){
+                        $temp = $weekly[$uniqe_str];
+                        //previous只更新最近的一次,并且是需要查询详细的时候,才放开previous的查询
+                        if(empty($temp['previous']) && $frequency_type <> "all"){
+                            $temp['previous'] = $d;
+                        }
+                        $weekly[$uniqe_str] = $temp;
+                    } else {
+                        $weekly[$uniqe_str] = $d;
+                        $weekly_uniqe[] = $uniqe_str;
                     }
-                    $weekly[$uniqe_str] = $temp;
-                } else {
-                    $weekly[$uniqe_str] = $d;
-                    $weekly_uniqe[] = $uniqe_str;
                 }
             }
+            $retData[$key]=  array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly),
+                "daily_all_id" =>$daily_all_id,"weekly_all_id"=>$weekly_all_id);
         }
-
-        return array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly),
-            "daily_all_id" =>$daily_all_id,"weekly_all_id"=>$weekly_all_id);
+        return $retData;
     }
 
     public function getEventCard($mInfo){

+ 1 - 1
utils/common.class.php

@@ -1835,7 +1835,7 @@ class common {
                     e.description,s.event_type as eventtype, 
                     s.event_code as eventcode, s.event_city as eventcity,
                     (select time_zone from public.city_timezone where uncode = s.event_code) as timezone,
-                    '' as uncity,
+                    s.event_city as uncity,
                     case when s.event_base ='I' or s.event_base ='TR'  then 'IFFREC'::text
                         when s.event_base ='AE'  then 'IFFONB'::text
                         when s.event_base ='VD'  then 'IFFDEP'::text

+ 45 - 0
utils/utils.class.php

@@ -791,5 +791,50 @@ class utils {
         $ret["numericRecords_two"]= $numericRecords_two;
         return $ret;
     }
+
+    /**
+     * ocean ->sea
+     */
+    public static function converModeToDB($shipment_transport_mode_arr){
+        $converMode = array();
+        foreach($shipment_transport_mode_arr as $model){
+            if (strtolower($model) == "ocean"){
+                $converMode[] = 'sea';
+            }else{
+                $converMode[] = strtolower($model);
+            }
+        }
+        return utils::implode(";",$converMode);
+    }
+
+    /**
+     * sea ->ocean
+    */
+    public static function converModeToDisplay($shipment_transport_mode){
+        //数据转换前端需要的
+        $converMode = array();
+        $shipment_transport_mode_arr = explode(";", $shipment_transport_mode);
+        foreach($shipment_transport_mode_arr as $model){
+            if (strtolower($model) == "sea"){
+                $converMode[] = 'Ocean';
+            }else{
+                $converMode[] = ucfirst($model);
+            }
+        }
+        return  utils::implode(";",$converMode);
+    }
+
+    public static function compareArrayEq($array1,$array2){   
+        // 使用array_diff比较并重置键名
+        $diff1 = array_diff($array1, $array2);
+        $diff2 = array_diff($array2, $array1);
+         
+        // 如果结果为空,说明两个数组一样
+        if (empty($diff1) && empty($diff2)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
 }
 ?>