ShuanghongS 9 月之前
父节点
当前提交
9a776527f6
共有 4 个文件被更改,包括 512 次插入113 次删除
  1. 19 4
      service/login.class.php
  2. 440 107
      service/tools.class.php
  3. 19 2
      utils/common.class.php
  4. 34 0
      utils/utils.class.php

+ 19 - 4
service/login.class.php

@@ -22,7 +22,7 @@ class login {
     }
 
     private function getLoginSql($uname) {
-        return "select user_login,(select active from public.employee ee where ee.employee_id=u.employee_id) as employee_id_active, can_visit_vgm,can_add_booking, can_add_tk_status,truck_driver,po_booking,o_final_delivery_u,ipad_view_po,can_view_doc,can_upload_doc,can_add_catalog,can_add_po,packing_list_company,is_only_vgm,contact_id_user,is_demo, ra_password as password,employee_id, contact_id, user_type, last_pwd_change, EXTRACT(DAY from (now() - last_pwd_change)) as last_pwd_change_date, email, user_webtype_id, active, is_online, station, allow_login_remote, can_see_amslog,can_view_eccn, can_see_isflog, can_see_isflog_withaddress, 
+        return "select first_name,last_name,user_login,(select active from public.employee ee where ee.employee_id=u.employee_id) as employee_id_active, can_visit_vgm,can_add_booking, can_add_tk_status,truck_driver,po_booking,o_final_delivery_u,ipad_view_po,can_view_doc,can_upload_doc,can_add_catalog,can_add_po,packing_list_company,is_only_vgm,contact_id_user,is_demo, ra_password as password,employee_id, contact_id, user_type, last_pwd_change, EXTRACT(DAY from (now() - last_pwd_change)) as last_pwd_change_date, email, user_webtype_id, active, is_online, station, allow_login_remote, can_see_amslog,can_view_eccn, can_see_isflog, can_see_isflog_withaddress, 
         customer_search_type, customer_destination, can_add_ams, can_add_isf, air_station, air_sales, ocean_station, ocean_sales,ocean_following_sales,ocean_following_sales_or,air_following_sales,air_following_sales_or, trucking_station, ocean_dest_op, can_see_password, can_add_opsales_code, ocean_station_or, ocean_agent_or, ocean_sales_or, ocean_dest_op_or, air_station_or, air_sales_or, trucking_station_or, 
         can_add_user, can_add_employee, can_add_contact, company_name, ams_email, isf_email, customer_discharge, online_active, is_super, ocean_agent,active, can_send_email, view_file_format as docdownload, container_status, consolidated_cbsa_code, can_add_aci, 
         air_customers, air_customer_search_type,trucking_customers,trucking_customer_search_type, upload_document, view_file_format, event_type, belong_schemas, main_schemas, error_login_count, EXTRACT(EPOCH FROM (now()-COALESCE(error_login_time, now()))) as second, po_status, view_air_file_format, 
@@ -276,17 +276,31 @@ class login {
                     }
                 }
 
+                //kln新版查询 date_format,numbers_format
+                $kln_user = common::excuteObjectSql("select * from kln_user_extend where lower(user_login) = '".strtolower($uname)."'");
+                $kln_user_info = array("uname"=>$uname,
+                                    "user_type"=>strtolower($rs['user_type']),
+                                    "first_name"=>$rs['first_name'],
+                                    "last_name"=>$rs['last_name'],
+                                    "email"=>$rs['email'],
+                                    "expire_day"=>$PASSWORD_CHANGE_CYCLE - $rs['last_pwd_change_date'],
+                                    "PASSWORD_CHANGE_CYCLE"=>intval($PASSWORD_CHANGE_CYCLE),
+                                    "last_pwd_change"=>$rs['last_pwd_change'],
+                                    "date_format"=>$kln_user['date_format'],
+                                    "numbers_format"=>$kln_user['numbers_format']);
                 if ($diffdate == $PASSWORD_CHANGE_CYCLE) {// Due today
                     $login_tmp = array(
                         'msg' => 'today',
-                        'uname' => $uname,
+                        "uname"=>$uname,
+                        'user_info' => $kln_user_info,
                         'login_version' => $rs["login_version"],
                         'data' => ''
                     );
                 } elseif ($diffdate >= ($PASSWORD_CHANGE_CYCLE - $PASSWORD_CHANGE_ALERT)) {// Password expires soon, JS Tips
                     $login_tmp = array(
                         'msg' => 'last',
-                        'uname' => $uname,
+                        "uname"=>$uname,
+                        'user_info' => $kln_user_info,
                         'login_version' => $rs["login_version"],
                         'data' => $PASSWORD_CHANGE_CYCLE - $diffdate,
                         'is_only_vgm' => $rs["is_only_vgm"]
@@ -303,7 +317,8 @@ class login {
                     } else {
                         $data = array(
                             'msg' => 'success',
-                            'uname' => $uname,
+                            "uname"=>$uname,
+                            'user_info' => $kln_user_info,
                             'login_version' => $rs["login_version"],
                             'data' => '',
                             'is_only_vgm' => $rs["is_only_vgm"]

+ 440 - 107
service/tools.class.php

@@ -151,9 +151,9 @@ class tools {
         if ($operate == "personal_profile_save") {
             $save_model = common::check_input($_POST['save_model']);
             if ($save_model == "profile"){
-                $user_name = common::check_input($_POST['user_name']);
-                $email = common::check_input($_POST['email']);
-                $sql = "update public.ra_online_user set user_login = '$user_name',email = '$email'  where lower(user_login) = '".strtolower(_getLoginName())."'";
+                $first_name = common::check_input($_POST['first_name']);
+                $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']);
@@ -286,21 +286,58 @@ class tools {
         $operate = utils::_get('operate');
         $operate = strtolower($operate);
 
+        if ($operate == "monitoring_rules_init"){
+            $ret = array();
+            //Milestone Update的页面配置数据
+            $milestones = common::excuteListSql("select * from customer_service_milestone_sno order by type, sno");
+            $oceanMilestone = array();
+            $airMilestone = array();
+            foreach($milestones as $milestone){
+                if($milestone['type'] == "air"){
+                    $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
+                    "code"=>$milestone['code'],"description"=>$milestone['description']);
+                } 
+                if($milestone['type'] == "sea"){
+                    $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
+                    "code"=>$milestone['code'],"description"=>$milestone['description']);
+                }
+            }
+            $ret["OceanCheckBoxList"] = $oceanMilestone;
+            $ret["AirCheckBoxList"] = $airMilestone;
+
+            //Milestone Update的结构处理
+            //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
+            $event =common::getEDICtnrEvent();
+            $ctnrStatus = array();
+            foreach($event as $e){
+                $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
+            }
+            $ret["CtnrCheckBoxList"] = $ctnrStatus; 
+            common::echo_json_encode(200,$ret);
+            exit();
+        }
+
         if ($operate == "monitoring_rules_search") {
             $cp = common::check_input($_POST ['cp']); //current_page
             $ps = common::check_input($_POST ['ps']); //ps
             if (empty($ps))
-                $ps = 50;
+                $ps = 15;
 
             $sql = "select count(1) from public.notifications_rules where lower(user_login) = '".strtolower(_getLoginName())."' and notifications_type = 'Monitoring'";
             $rc = common::excuteOneSql($sql);
 
             $tp = ceil($rc / $ps);
             if ($rc > 0) {
-                $sql = "select count(1) from public.notifications_rules 
+                $sql = "select *,replace(rules_type, '_', ' ') AS _rules_type_display,
+                        case when rules_type = 'Milestone_Update' then 'Milestone'
+                            when rules_type = 'Container_Status_Update' then 'Container'
+                            when rules_type = 'Departure/Arrival_Delay' then 'Departure'
+                            when rules_type = 'ETD/ETA_Change' then 'ETDChange'
+                        else '' end as notifications_option 
+                     from public.notifications_rules 
                         where lower(user_login) = '".strtolower(_getLoginName())."' 
                             and notifications_type = 'Monitoring' order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
-                $monitoringRules = common::excuteObjectSql($sql);
+                $monitoringRules = common::excuteListSql($sql);
                 $arrTmp = array('monitoringRules' => $monitoringRules, 
                     'rc' => intval($rc),
                     'ps' => $ps,
@@ -318,6 +355,41 @@ class tools {
             common::echo_json_encode(200,$arrTmp);
             exit();
         }
+
+        if ($operate == "monitoring_rules_edit"){
+            $id = $_POST['id'];
+            $rules_type = common::check_input($_POST['rules_type']);
+            $subscribe_rule_sql = "select *,
+                    TO_CHAR(daily_time, 'HH24:MI') as _daily_time,
+                    TO_CHAR(weekly_time, 'HH24:MI') as _weekly_time,
+                    case when rules_type = 'Milestone_Update' then 'Milestone'
+                         when rules_type = 'Container_Status_Update' then 'Container'
+                         when rules_type = 'Departure/Arrival_Delay' then 'Departure'
+                         when rules_type = 'ETD/ETA_Change' then 'ETDChange'
+                    else '' end as notifications_option
+                from public.notifications_rules where notifications_type = 'Monitoring' and lower(user_login) = '".strtolower(_getLoginName())."'
+                    and id = '$id' order by id";
+            $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
+
+            $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);
+
+            $monitoring_data[$rules_type] = $rules;
+            common::echo_json_encode(200,$monitoring_data);
+            exit();
+        }
+
         if ($operate == "monitoring_rules_do") {
             $rules_type = common::check_input($_POST["rules_type"]);
             //检查编辑提交的Monitoring规则,是否允许保存
@@ -343,9 +415,8 @@ class tools {
         }
         if ($operate == "monitoring_rules_delete"){
             $id = common::check_input($_POST['id']);
-            $rules_type = common::check_input($_POST['rules_type']);
             $sql = "delete from notifications_rules where notifications_type = 'Monitoring' 
-                and  rules_type = '$rules_type' and lower(user_login) = '".strtolower(_getLoginName())."' and  id = '$id '";
+                 and lower(user_login) = '".strtolower(_getLoginName())."' and  id = '$id'";
             common::excuteUpdateSql($sql);
             $data = array("msg" => "Delete Successful");
             common::echo_json_encode(200,$data);
@@ -390,13 +461,13 @@ class tools {
                     }
                 }
                 if(!empty($v['daily'])){
-                    //取第一个显示
-                    $v['daily'][0]['numericRecords'] = count($v['daily']);
-                    $instant_sum[]= $v['daily'][0];
+                    //取第一组的第一个显示
+                    $dailyFristAndFrist = utils::getDailyAndweeklyFrist($v['daily']);
+                    $instant_sum[]= $dailyFristAndFrist;
                 }
-                if(!empty($milestoneData['weekly'])){
-                    $v['weekly'][0]['numericRecords'] = count($v['weekly']);
-                    $instant_sum[]= $v['weekly'][0];
+                if(!empty($v['weekly'])){
+                    $weeklyFristAndFrist = utils::getDailyAndweeklyFrist($v['weekly']);
+                    $instant_sum[]= $weeklyFristAndFrist;
                 }
             }
             //根据时间顺序排序
@@ -405,14 +476,57 @@ class tools {
 
             $info = array();
             foreach($instant_sum as $mInfo){
-                $eventCard = $this->getEventCard($mInfo,"Milestone_Update");
-                $Info[] = $eventCard;
+                $eventCard = $this->getEventCard($mInfo);
+                $info[] = array("notificationType"=>"event","info" =>$eventCard);
             }
 
-            $returnData = array("notificationType"=>"event","info" =>$info);
+            $returnData = $info;
+            common::echo_json_encode(200,$returnData);
+            exit();
+
+        }
+
+        if($operate == "notifications_see_all"){
+            $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)];
+
+            //这个函数里面带有分开计数的信息
+            $dataInfo =utils::getDailyAndweeklyFrist($moreData);
+
+            $returnData = array();
+            $notificationList = array();
+            foreach($moreData as $key => $data){
+                $eventCard = $this->getEventCard($data);
+                //sea all的数据格式和查询全部的格式有区别
+                if($key == 0){
+                    $returnData["title"] = $eventCard["title"];
+                    if($eventCard["type"] == "change" || $eventCard["type"] == "delay"){
+                        $returnData["numericRecords_one"] = $dataInfo["numericRecords_one"];
+                        $returnData["numericRecords_two"] =$dataInfo["numericRecords_two"];
+                    }else{
+                        $returnData["numericRecords"] = $dataInfo["numericRecords"];
+                    }
+                }
+                //移除不需要的字段
+                unset($eventCard["title"]);
+                $notificationList[] = $eventCard;
+            }
+            if(!empty($notificationList)){
+                $returnData["notificationList"] = $notificationList;
+            }
+            //点击seall会默认全部标记为已读
+            
             common::echo_json_encode(200,$returnData);
             exit();
+        }
 
+        if($operate == "notifications_read"){
+            
+          
+            exit();
         }
     }
 
@@ -442,7 +556,7 @@ class tools {
                     $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
                     "code"=>$milestone['code'],"description"=>$milestone['description']);
                 } 
-                if($milestone['type'] == "ocean"){
+                if($milestone['type'] == "sea"){
                     $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
                     "code"=>$milestone['code'],"description"=>$milestone['description']);
                 }
@@ -462,7 +576,7 @@ class tools {
         //Milestone Update的结构处理
         if($rule_name == "Container_Status_Update"){
             //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
-            $event =$this->getEDICtnrEvent();
+            $event =common::getEDICtnrEvent();
             $ctnrStatus = array();
             foreach($event as $e){
                 $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
@@ -594,13 +708,22 @@ class tools {
         $event_details = common::check_input($_POST['event_details']);
         $frequency_display = common::check_input($_POST['frequency_display']);
         $method_display = common::check_input($_POST['method_display']);
+        $shipment_detail = common::check_input($_POST['shipment_details']);
 
         //当规则是 Monitoring类型是,需要配置的range
         $shipment_transport_mode = "";
         $shipment_etd_limit = "";
         $shipment_eta_limit = "";
         if($notifications_type == "Monitoring"){
-            $shipment_transport_mode = utils::implode(";",$_POST['shipment_transport_mode']);
+            $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_etd_limit = common::check_input($_POST['shipment_etd_limit']);
             $shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
         }
@@ -627,17 +750,17 @@ class tools {
                     user_login, notifications_type, rules_type, ocean_milestone, 
                     air_milestone, frequency_type, daily_time, daily_time_zone,
                     weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
-                    event_details, frequency_display, method_display,
+                    event_details, frequency_display, method_display,shipment_details,
                     shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
             VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_milestone',
                     '$air_milestone', '$frequency_type', $daily_time, '$daily_time_zone', 
                     '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
-                    '$event_details', '$frequency_display', '$method_display',
+                    '$event_details', '$frequency_display', '$method_display','$shipment_detail',
                     '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
         }
 
         if ($rules_type == "Container_Status_Update"){
-            $event = $this->getEDICtnrEvent();
+            $event = common::getEDICtnrEvent();
             $ocean_ctnr_status = $this->convertCodeForMilestoneAndCtnr("Container_Status_Update",$_POST['ocean_ctnr_status'],$event);
             $ocean_ctnr_status = utils::implode(";",$ocean_ctnr_status);
 
@@ -645,34 +768,34 @@ class tools {
                     user_login, notifications_type, rules_type, ocean_ctnr_status, 
                     frequency_type, daily_time, daily_time_zone,
                     weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
-                    event_details, frequency_display, method_display,
+                    event_details, frequency_display, method_display,shipment_details,
                     shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
             VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_ctnr_status',
                     '$frequency_type', $daily_time, '$daily_time_zone', 
                     '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
-                    '$event_details', '$frequency_display', '$method_display',
+                    '$event_details', '$frequency_display', '$method_display','$shipment_detail',
                     '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
         }
 
         if ($rules_type == "Departure/Arrival_Delay"){
-            $ocean_atd_sub_etd = $_POST['ocean_atd_sub_etd'];
-            $ocean_atd_sub_etd_unit = $_POST['ocean_atd_sub_etd_unit'];
+            $ocean_atd_sub_etd = common::check_input($_POST['ocean_atd_sub_etd']);
+            $ocean_atd_sub_etd_unit = common::check_input($_POST['ocean_atd_sub_etd_unit']);
             if(!empty($ocean_atd_sub_etd_unit)){
                 $ocean_atd_sub_etd_unit = $ocean_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
             }
-            $ocean_ata_sub_eta = $_POST['ocean_ata_sub_eta'];
-            $ocean_ata_sub_eta_unit = $_POST['ocean_ata_sub_eta_unit'];
+            $ocean_ata_sub_eta = common::check_input($_POST['ocean_ata_sub_eta']);
+            $ocean_ata_sub_eta_unit = common::check_input($_POST['ocean_ata_sub_eta_unit']);
             if(!empty($ocean_ata_sub_eta_unit)){
                 $ocean_ata_sub_eta_unit = $ocean_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
             }
 
-            $air_atd_sub_etd = $_POST['air_atd_sub_etd'];
-            $air_atd_sub_etd_unit = $_POST['air_atd_sub_etd_unit'];
+            $air_atd_sub_etd = common::check_input($_POST['air_atd_sub_etd']);
+            $air_atd_sub_etd_unit = common::check_input($_POST['air_atd_sub_etd_unit']);
             if(!empty($air_atd_sub_etd_unit)){
                 $air_atd_sub_etd_unit = $air_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
             }
-            $air_ata_sub_eta = $_POST['air_ata_sub_eta'];
-            $air_ata_sub_eta_unit = $_POST['air_ata_sub_eta_unit'];
+            $air_ata_sub_eta = common::check_input($_POST['air_ata_sub_eta']);
+            $air_ata_sub_eta_unit = common::check_input($_POST['air_ata_sub_eta_unit']);
             if(!empty($air_ata_sub_eta_unit)){
                 $air_ata_sub_eta_unit = $air_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
             }
@@ -683,40 +806,40 @@ class tools {
                     air_atd_sub_etd, air_atd_sub_etd_unit,air_ata_sub_eta,air_ata_sub_eta_unit,
                     frequency_type, daily_time, daily_time_zone,
                     weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
-                    event_details, frequency_display, method_display,
+                    event_details, frequency_display, method_display,shipment_details,
                     shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
             VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', 
                     '$ocean_atd_sub_etd','$ocean_atd_sub_etd_unit','$ocean_ata_sub_eta','$ocean_ata_sub_eta_unit',
                     '$air_atd_sub_etd','$air_atd_sub_etd_unit','$air_ata_sub_eta','$air_ata_sub_eta_unit',
                     '$frequency_type', $daily_time, '$daily_time_zone', 
                     '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
-                    '$event_details', '$frequency_display', '$method_display',
+                    '$event_details', '$frequency_display', '$method_display','$shipment_detail',
                     '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
         }
 
         if ($rules_type == "ETD/ETA_Change"){
-            $ocean_etd_change = $_POST['ocean_etd_change'];
-            $ocean_etd_old_sub_new = $_POST['ocean_etd_old_sub_new'];
-            $ocean_etd_old_sub_new_unit = $_POST['ocean_etd_old_sub_new_unit'];
+            $ocean_etd_change = common::check_input($_POST['ocean_etd_change']);
+            $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 = $_POST['ocean_eta_change'];
-            $ocean_eta_old_sub_new = $_POST['ocean_eta_old_sub_new'];
-            $ocean_eta_old_sub_new_unit = $_POST['ocean_eta_old_sub_new_unit'];
+            $ocean_eta_change = common::check_input($_POST['ocean_eta_change']);
+            $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 = $_POST['air_etd_change'];
-            $air_etd_old_sub_new = $_POST['air_etd_old_sub_new'];
-            $air_etd_old_sub_new_unit = $_POST['air_etd_old_sub_new_unit'];
+            $air_etd_change = common::check_input($_POST['air_etd_change']);
+            $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 = $_POST['air_eta_change'];
-            $air_eta_old_sub_new = $_POST['air_eta_old_sub_new'];
-            $air_eta_old_sub_new_unit = $_POST['air_eta_old_sub_new_unit'];
+            $air_eta_change = common::check_input($_POST['air_eta_change']);
+            $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)){
                 $air_eta_old_sub_new_unit = $air_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
             }
@@ -727,14 +850,14 @@ class tools {
                     air_etd_change, air_etd_old_sub_new,air_etd_old_sub_new_unit,air_eta_change,air_eta_old_sub_new,air_eta_old_sub_new_unit,
                     frequency_type, daily_time, daily_time_zone,
                     weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
-                    event_details, frequency_display, method_display,
+                    event_details, frequency_display, method_display,shipment_details,
                     shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
             VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', 
                     '$ocean_etd_change','$ocean_etd_old_sub_new','$ocean_etd_old_sub_new_unit','$ocean_eta_change','$ocean_eta_old_sub_new','$ocean_eta_old_sub_new_unit',
                     '$air_etd_change','$air_etd_old_sub_new','$air_etd_old_sub_new_unit','$air_eta_change','$air_eta_old_sub_new','$air_eta_old_sub_new_unit',
                     '$frequency_type', $daily_time, '$daily_time_zone', 
                     '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
-                    '$event_details', '$frequency_display', '$method_display',
+                    '$event_details', '$frequency_display', '$method_display','$shipment_detail',
                     '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
         }
         return $sql;
@@ -819,22 +942,6 @@ class tools {
         return $msg;
     }
 
-    /**
-     * 这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
-     */
-    public function getEDICtnrEvent(){
-        $event =array(array("event_name"=>"EE","description"=>"Empty Equipment Dispatched"),array("event_name"=>"I","description"=>"Gate in full for a booking"),array("event_name"=>"AE","description"=>"Container loaded on vessel"),
-                array("event_name"=>"VD","description"=>"Vessel Departure"),array("event_name"=>"VA_RELAY","description"=>"Arrive Relay Port"),array("event_name"=>"UV_RELAY","description"=>"Unloaded at Relay Port"),
-                array("event_name"=>"AE_RELAY","description"=>"Loaded at Relay Port"),array("event_name"=>"VD_RELAY","description"=>"Depart Relay Port"),array("event_name"=>"CU","description"=>"Carrier and Customs Release"),
-                array("event_name"=>"CT","description"=>"Customs release"),array("event_name"=>"CR","description"=>"Carrier release"),array("event_name"=>"VA","description"=>"Vessel Arrival"),
-                array("event_name"=>"UV","description"=>"Unloaded From Vessel"),array("event_name"=>"AG","description"=>"Estimated Delivery"),array("event_name"=>"OA","description"=>"Gate out full from final discharge port"),
-                array("event_name"=>"FT","description"=>"Free Time Expired"),array("event_name"=>"AL","description"=>"Container loaded on Rail"),array("event_name"=>"AR","description"=>"Container unloaded from Rail"),
-                array("event_name"=>"AV","description"=>"Shipment available for pickup or delivery"),array("event_name"=>"D","description"=>"Gate out for delivery to customer"),array("event_name"=>"RD","description"=>"Container returned empty"),
-                array("event_name"=>"C","description"=>"Vessel Estimated Time of Departure"),array("event_name"=>"C_RELAY","description"=>"Estimated Time of Departure from Tranship Port"),array("event_name"=>"AG_DES","description"=>"Estimated Delivery Destination"),
-                array("event_name"=>"IFFADW","description"=>"Shipment in CFS warehouse"),array("event_name"=>"IFFDDW","description"=>"Shipment Out from CFS House"));
-        return  $event;   
-    }
-
 
     public function getNotifications($notifiation_type,$frequency_type){
         if ($frequency_type == "all"){
@@ -849,96 +956,322 @@ class tools {
                                     and  ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
         }
         
-        if ($notifiation_type == "Milestone_Update"){
-            $sql = "select ni.*,
+        $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)))
+                        when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'hours'
+                            then (EXTRACT(HOUR FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
+                        else 0 
+                    end  as delay_diff,
                     case when COALESCE(ni.frequency_type,'') = 'Daily'
-                            then to_char(timezone(ni.daily_time_zone, insert_date),'Mon DD, YYYY')
+                            then to_char(timezone(ni.daily_time_zone, now()),'Mon DD, YYYY')
                         when COALESCE(ni.frequency_type,'') = 'Weekly'  
-                            then to_char(timezone(ni.weekly_time_zone, insert_date),'Mon DD, YYYY')
+                            then to_char(timezone(ni.weekly_time_zone, now()),'Mon DD, YYYY')
                         else '' 
                     end  as insert_date_format,
-                        ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.milestone_desc
-                    from public.kln_notifiation_info ni
-                        left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from,
-                                case when COALESCE(ni.milestone_code,'') <> '' and oo.transport_mode = 'sea'
-                                        then  (select description from  public.customer_service_milestone_sno where type = 'sea' and code = ni.milestone_code)
-                                    else (select description from  public.customer_service_milestone_sno where type = 'air' and code = ni.milestone_code)
-                                end as milestone_desc
-                              from public.kln_ocean oo 
+                    ccc.order_from,ccc.h_bol,ccc.transport_mode
+                from public.kln_notifiation_info ni
+                        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()."' 
+                where lower(ni.user_login) = '"._getLoginName()."' 
                         and ni.notifiation_type = '".$notifiation_type."'
-                        ".$sql_where." and ni.notifications_method = true and ni.is_send_message = false order by ni.insert_date desc";
-        }
-        if ($notifiation_type == "Milestone_Update"){
-
-        }
-
+                    ".$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'];
+            }
             if ($d['frequency_type'] == "Daily"){
-                if(utils::in_array($d['serial_no'],$daily_uniqe)){
-                    $temp = $daily[$d['serial_no']];
-                    $temp[] = $d;
-                    $daily[$d['serial_no']] = $temp;
+                $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[$d['serial_no']] = $d['serial_no'];
-                    $daily_uniqe[] = $d;
+                    $daily[$uniqe_str] = $d;
+                    $daily_uniqe[] = $uniqe_str;
                 }
             }
             if ($d['frequency_type'] == "Weekly"){
-                if(utils::in_array($d['serial_no'],$weekly_uniqe)){
-                    $temp = $weekly[$d['serial_no']];
-                    $temp[] = $d;
-                    $weekly[$d['serial_no']] = $temp;
+                $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[$d['serial_no']] = $d;
-                    $weekly_uniqe[] = $d['serial_no'];
+                    $weekly[$uniqe_str] = $d;
+                    $weekly_uniqe[] = $uniqe_str;
                 }
             }
         }
 
-        return array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly));
+        return array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly),
+            "daily_all_id" =>$daily_all_id,"weekly_all_id"=>$weekly_all_id);
     }
 
-    public function getEventCard($mInfo,$notifiation_type){
+    public function getEventCard($mInfo){
+        $eventCard = array();
+        $notifiation_type = $mInfo['notifiation_type'];
         if($notifiation_type == "Milestone_Update"){
-            $timeAndlocations = common::getMilestoneTimeAndlocations($mInfo["milestone_code"],$mInfo["transport_mode"],$mInfo["serial_no"],$mInfo["order_from"]);
             $eventCard = array("type" =>'milestone',
                     "numericRecords"=>0,
-                    "isRead"=>false,
+                    "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
                     "title"=>"Milestone Update",
-                    "mode"=>$mInfo["transport_mode"],
+                    "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
                     "no"=>$mInfo["h_bol"],
-                    "tag"=>$mInfo["milestone_desc"],
-                    "location"=>$timeAndlocations["locations"],
-                    "timezone"=>$timeAndlocations["timezone"],
+                    "tag"=>$mInfo["milestone_description"],
+                    "location"=>$mInfo["milestone_locations"],
+                    "timezone"=>$mInfo["milestone_timezone"],
                     "time"=>$mInfo["milestone_date"]." ".$mInfo["milestone_time"],
+                    "timeLabel"=>"",
                     "previous"=>"",
                     "frequency_type"=>$mInfo["frequency_type"],
-                    "delayInfo"=>array(),"changeInfo"=>array());
+                    "serial_no"=>$mInfo["serial_no"],
+                    "order_from"=>$mInfo["order_from"],
+                    "id"=>$mInfo["id"],
+                    "info"=>new stdClass());
 
             if ($mInfo["frequency_type"] == "Daily"){
-                $eventCard["numericRecords"] = $mInfo["numericRecords"];
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
                 $eventCard["title"] = "Milestone Update Daily Summary(".$mInfo["insert_date_format"].")";
+                if(!empty($mInfo["previous"])){
+                    $eventCard["previous"] = array("tag" =>"Previous:".$mInfo["previous"]["milestone_description"]." from ".$mInfo["previous"]["milestone_locations"],
+                        "time" => $mInfo["previous"]["milestone_time"],
+                        "timezone" =>$mInfo["previous"]["milestone_timezone"]);    
+                }
             } else if($mInfo["frequency_type"] == "Weekly"){
-                $eventCard["numericRecords"] = $mInfo["numericRecords"];
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
                 $eventCard["title"] = "Milestone Update Weekly Summary(".$mInfo["insert_date_format"].")";
+                if(!empty($mInfo["previous"])){
+                    $eventCard["previous"] = array("tag" =>"Previous:".$mInfo["previous"]["milestone_desc"]." from ".$mInfo["previous"]["milestone_description"],
+                        "time" => $mInfo["previous"]["milestone_time"],
+                        "timezone" =>$mInfo["previous"]["milestone_timezone"]);    
+                }
+            }
+        }
+        if($notifiation_type == "Container_Status_Update"){
+            //当前状态的描述
+            $ctnrStatusdesc = $this->getContainerStatusDesc($mInfo["ctnr_status_code"]);
+            $eventCard = array("type" =>'container',
+                    "numericRecords"=>0,
+                    "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
+                    "title"=>"Container_Status_Update",
+                    "mode"=>"Ocean Freight",
+                    "no"=>$mInfo["ctnr"],
+                    "tag"=>$ctnrStatusdesc,
+                    "location"=>$mInfo["ctnr_status_locations"],
+                    "timezone"=>$mInfo["ctnr_status_timezone"],
+                    "time"=>$mInfo["ctnr_status_date"]." ".$mInfo["ctnr_status_time"],
+                    "timeLabel"=>"",
+                    "previous"=>"",
+                    "frequency_type"=>$mInfo["frequency_type"],
+                    "serial_no"=>$mInfo["serial_no"],
+                    "order_from"=>$mInfo["order_from"],
+                    "id"=>$mInfo["id"],
+                    "info"=>new stdClass());
+
+            if ($mInfo["frequency_type"] == "Daily"){
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
+                $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
+                if(!empty($mInfo["previous"])){
+                    //当前状态 前一个的描述
+                    $previousCtnrStatusdesc = $this->getContainerStatusDesc($mInfo["previous"]["ctnr_status_code"]);
+                    $eventCard["previous"] = array("tag" =>"Previous:" .$previousCtnrStatusdesc. " from " .$mInfo["previous"]["ctnr_status_locations"],
+                        "time" => $mInfo["previous"]["ctnr_status_time"],
+                        "timezone" =>$mInfo["previous"]["ctnr_status_timezone"]);    
+                }
+            } else if($mInfo["frequency_type"] == "Weekly"){
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
+                $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
+                if(!empty($mInfo["previous"])){
+                    //当前状态 前一个的描述
+                    $previousCtnrStatusdesc = $this->getContainerStatusDesc($mInfo["previous"]["ctnr_status_code"]);
+                    $eventCard["previous"] = array("tag" =>"Previous:" .$previousCtnrStatusdesc. " from " .$mInfo["previous"]["ctnr_status_locations"],
+                        "time" => $mInfo["previous"]["ctnr_status_time"],
+                        "timezone" =>$mInfo["previous"]["ctnr_status_timezone"]);    
+                }
+            }
+        }
+
+        if($notifiation_type == "Departure/Arrival_Delay"){
+            //代表信息为转船信息,title要处理一下: leg 2/3 Departure_Delay => Departure_Delay
+            $title = $mInfo["delay_name"];
+            $outsideLocation = "";
+            $outsideTimezone = "";
+            $outsideTimeLabel= "";
+            $insideTimeLabel= "";
+            if(utils::checkExist($mInfo["delay_name"],"Departure_Delay")){
+                $outsideTimeLabel = "ETD";
+                $insideTimeLabel = "ATD";
+            }
+            if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay")){
+                $outsideTimeLabel = "ETA";
+                $insideTimeLabel = "ATA";
+            }
+            //直航的的
+            if(utils::checkExist($mInfo["delay_name"],"Departure_Delay") and $mInfo["delay_is_direct"] == 't'){
+                $outsideLocation = $mInfo["delay_locations_from"];
+            }
+            if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay") and $mInfo["delay_is_direct"] == 't'){
+                $outsideLocation = $mInfo["delay_locations_to"];
+            }
+
+            $route = array();
+            $leg = array();
+            if($mInfo["delay_is_direct"] <>'t'){
+                $title = substr($mInfo["delay_name"],8);
+                $route = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
+                //当前current Leg
+                $leg = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"]);
+                if($mInfo["delay_current"] == "2"){
+                    $leg = array($mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
+                }
+            }
+            $act_date = $mInfo["delay_act_date"]." ".$mInfo["delay_act_time"];
+            $est_date = $mInfo["delay_est_date"]." ".$mInfo["delay_est_time"];
+            $delay_diff = $mInfo["delay_diff"];
+            $delay_unit = $mInfo["delay_unit"];
+            $eventCard = array("type" =>'delay',
+                    "numericRecords"=>0,
+                    "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
+                    "title"=>$title,
+                    "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
+                    "no"=>$mInfo["h_bol"],
+                    "tag"=>$mInfo["delay_name"],
+                    "location"=>$outsideLocation,
+                    "timezone"=>$mInfo["delay_timezone"],
+                    "time"=>$est_date,
+                    "timeLabel"=>$outsideTimeLabel,
+                    "previous"=>"",
+                    "frequency_type"=>$mInfo["frequency_type"],
+                    "serial_no"=>$mInfo["serial_no"],
+                    "order_from"=>$mInfo["order_from"],
+                    "id"=>$mInfo["id"],
+                    "info"=>array("route"=>$route,
+                        "leg"=>$leg,
+                        "etdOrdeparturNum"=>0,
+                        "etaOrarrivalNum"=>0,
+                        "time"=>$act_date,
+                        "timeLabel"=>$insideTimeLabel,
+                        "delayTimeTip"=>"+".$delay_diff." ".$delay_unit." delay",
+                        "timezone"=>$mInfo["delay_timezone"]
+                    ));
+
+            if ($mInfo["frequency_type"] == "Daily"){
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
+                $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
+                $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
+                $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
+            } else if($mInfo["frequency_type"] == "Weekly"){
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
+                $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
+                $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
+                $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
             }
         }
+        if($notifiation_type == "ETD/ETA_Change"){
+            $title = $mInfo["date_change_name"];
+            if(utils::checkExist($mInfo["date_change_name"],"ETD Change")){
+                $outsideTimeLabel = "Original ETD";
+                $insideTimeLabel = "Upoated ETD";
+            }
+            if(utils::checkExist($mInfo["date_change_name"],"ETA Change")){
+                $outsideTimeLabel = "Original ETA";
+                $insideTimeLabel = "Upoated ETA";
+            }
+             
+            if($mInfo["date_change_is_direct"] <>'t'){
+                //代表信息为转船信息,title要处理一下: leg 1/3 ETD Change
+                $title = substr($mInfo["date_change_name"],8);
+                $route = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
+                $leg = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"]);
+                if($mInfo["delay_current"] == "2"){
+                    $leg = array($mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
+                }
+            }
+            $updated_date = $mInfo["date_change_updated_date"]." ".$mInfo["date_change_updated_time"];
+            $original_date = $mInfo["date_change_original_date"]." ".$mInfo["date_change_original_time"];
+            $eventCard = array("type" =>'change',
+                    "numericRecords"=>0,
+                    "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
+                    "title"=>$title,
+                    "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
+                    "no"=>$mInfo["h_bol"],
+                    "tag"=>$mInfo["date_change_name"],
+                    "location"=>"",
+                    "timezone"=>$mInfo["date_change_timezone"],
+                    "time"=>$original_date,
+                    "timeLabel"=>$outsideTimeLabel,
+                    "previous"=>"",
+                    "frequency_type"=>$mInfo["frequency_type"],
+                    "serial_no"=>$mInfo["serial_no"],
+                    "order_from"=>$mInfo["order_from"],
+                    "id"=>$mInfo["id"],
+                    "info"=>array("route"=>$route,
+                        "leg"=>$leg,
+                        "etdOrdeparturNum"=>0,
+                        "etaOrarrivalNum"=>0,
+                        "time"=>$updated_date,
+                        "timeLabel"=>$insideTimeLabel,
+                        "delayTimeTip"=>"",
+                        "timezone"=>$mInfo["date_change_timezone"]
+                    ));
 
+            if ($mInfo["frequency_type"] == "Daily"){
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
+                $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
+                $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
+                $eventCard["title"] = "ETD/ETA Change Daily Summary(".$mInfo["insert_date_format"].")";
+            } else if($mInfo["frequency_type"] == "Weekly"){
+                $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
+                $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
+                $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
+                $eventCard["title"] = "ETD/ETA Change Weekly Summary(".$mInfo["insert_date_format"].")";
+            }
+        }
         return $eventCard;
     }
+
+
+
+    /**
+     * 返回当前柜子的status信息描述
+     */
+    public static function getContainerStatusDesc($ctnr_status_code){
+        $event =common::getEDICtnrEvent();
+        $ctnrStatusdesc = "";
+        foreach($event as $e){
+            if($e['event_name'] == $ctnr_status_code){
+                $ctnrStatusdesc = $e['description'];
+            }
+        }
+        return $ctnrStatusdesc;
+    }
 }
 
 ?>

+ 19 - 2
utils/common.class.php

@@ -813,10 +813,10 @@ class common {
             $sqlWhere .= " and " . _customerAirFilerSearch($schemas);
         } else {
             if (empty($station) && empty($sales)) {
-                return " 1<>1";
+                return "and 1<>1";
             }
             if (strtolower($station_or) == "all" || strtolower($sales_or) == "all")
-                        return $sqlWhere;
+                        return " and ($sqlWhere)";
         
             if (strtolower($station) == 'all' || empty($station)) {
                         
@@ -2197,5 +2197,22 @@ class common {
         }
         return $week;
     }
+
+    /**
+     * 这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
+    */
+    public  static function getEDICtnrEvent(){
+        $event =array(array("event_name"=>"EE","description"=>"Empty Equipment Dispatched"),array("event_name"=>"I","description"=>"Gate in full for a booking"),array("event_name"=>"AE","description"=>"Container loaded on vessel"),
+                array("event_name"=>"VD","description"=>"Vessel Departure"),array("event_name"=>"VA_RELAY","description"=>"Arrive Relay Port"),array("event_name"=>"UV_RELAY","description"=>"Unloaded at Relay Port"),
+                array("event_name"=>"AE_RELAY","description"=>"Loaded at Relay Port"),array("event_name"=>"VD_RELAY","description"=>"Depart Relay Port"),array("event_name"=>"CU","description"=>"Carrier and Customs Release"),
+                array("event_name"=>"CT","description"=>"Customs release"),array("event_name"=>"CR","description"=>"Carrier release"),array("event_name"=>"VA","description"=>"Vessel Arrival"),
+                array("event_name"=>"UV","description"=>"Unloaded From Vessel"),array("event_name"=>"AG","description"=>"Estimated Delivery"),array("event_name"=>"OA","description"=>"Gate out full from final discharge port"),
+                array("event_name"=>"FT","description"=>"Free Time Expired"),array("event_name"=>"AL","description"=>"Container loaded on Rail"),array("event_name"=>"AR","description"=>"Container unloaded from Rail"),
+                array("event_name"=>"AV","description"=>"Shipment available for pickup or delivery"),array("event_name"=>"D","description"=>"Gate out for delivery to customer"),array("event_name"=>"RD","description"=>"Container returned empty"),
+                array("event_name"=>"C","description"=>"Vessel Estimated Time of Departure"),array("event_name"=>"C_RELAY","description"=>"Estimated Time of Departure from Tranship Port"),array("event_name"=>"AG_DES","description"=>"Estimated Delivery Destination"),
+                array("event_name"=>"IFFADW","description"=>"Shipment in CFS warehouse"),array("event_name"=>"IFFDDW","description"=>"Shipment Out from CFS House"));
+        return  $event;   
+    }
+
 }
 ?>

+ 34 - 0
utils/utils.class.php

@@ -757,5 +757,39 @@ class utils {
         }
         return $ret;
     }
+
+    public static function getDailyAndweeklyFrist($arr){
+        $numericRecords = count($arr);
+        $ret = array();
+
+        $numericRecords_one = 0;
+        $numericRecords_two = 0;
+        foreach($arr as $key => $val){
+            if($key == 0){
+                $val["numericRecords"] = $numericRecords;
+                $ret = $val;
+            }
+            if($val["notifiation_type"] == "Departure/Arrival_Delay"){
+                if(utils::checkExist($val["delay_name"],"Departure_Delay")){
+                    $numericRecords_one +=1;
+                }
+                if(utils::checkExist($val["delay_name"],"Arrival_Delay")){
+                    $numericRecords_two +=1;
+                }
+            }
+            if($val["notifiation_type"] == "ETD/ETA_Change"){
+                if(utils::checkExist($val["date_change_name"],"ETD Change")){
+                    $numericRecords_one +=1;
+                }
+                if(utils::checkExist($val["date_change_name"],"ETA Change")){
+                    $numericRecords_two +=1;
+                }
+            }
+        }
+        //对Delay and change 特殊处理
+        $ret["numericRecords_one"]= $numericRecords_one;
+        $ret["numericRecords_two"]= $numericRecords_two;
+        return $ret;
+    }
 }
 ?>