ShuanghongS 8 месяцев назад
Родитель
Сommit
445c05dadf
6 измененных файлов с 271 добавлено и 45 удалено
  1. 2 0
      .gitignore
  2. 12 1
      include.ini.php
  3. 26 8
      main_new_version.php
  4. 19 0
      service/login.class.php
  5. 207 35
      service/tools.class.php
  6. 5 1
      utils/common.class.php

+ 2 - 0
.gitignore

@@ -8,3 +8,5 @@ cache/
 .svn/
 demo.txt
 userFile/
+upload/
+

+ 12 - 1
include.ini.php

@@ -19,7 +19,7 @@ define('WEB_ROOT', str_replace(DS, '/', str_replace(str_replace("/", DS, $_SERVE
 define('ONLINE_ROOT', realpath(dirname(__FILE__)) . DS);
 define('ADODB_PATH', ONLINE_ROOT . 'libs' . DS . 'ADOdb-5.20.17' . DS);
 define('C_PATH', ONLINE_ROOT . 'service' . DS);
-define('SERVER_PAHT', 'http://192.168.0.161/Customer_Service_Online/');
+define('FILE_UPLOAD_PAHT', "upload" . DS);
 
 // define('DOCUMENT_AIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
 // define('DOCUMENT_OCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
@@ -46,6 +46,17 @@ include_once ONLINE_ROOT . 'libs' . DS . 'config.ini.php';
 include_once ONLINE_ROOT . 'utils' . DS . 'utils.class.php';
 include_once ONLINE_ROOT . 'utils' . DS . 'common.class.php';
 
+
+//测试服务器
+if(utils::startWith($_SERVER["HTTP_HOST"],"online-beta.kln.com")){
+    define('SERVER_PAHT', 'https://online-beta.kln.com/online_backend/');
+}elseif(utils::startWith($_SERVER["HTTP_HOST"],"online.kln.com")){
+    define('SERVER_PAHT', 'https://online.kln.com/online_backend/');
+}else{
+    //本地测试demo
+    define('SERVER_PAHT', 'http://192.168.0.161/Customer_Service_Online/');
+}
+
 $tar = common::excuteObjectSql("select item_value from config where item='Current_Used_Company'");
 if (!empty($tar["item_value"])&&$tar["item_value"]=="TOPOCEAN") {
     define("Soure", 'TopOcean');

+ 26 - 8
main_new_version.php

@@ -19,9 +19,12 @@ include 'service/ajax.class.php';
 include 'service/login.class.php';
 include 'service/tools.class.php';
 
-//为了调用,临时做一个登录动作
-//  $_POST['uname'] = "ra.admin";
-//  $_POST['psw'] = common::excuteOneSql("select ra_password from public.ra_online_user where user_login = 'ra.admin'");
+//为了调用,临时做一个登录动作  如果是正式版 要注释掉菜单System Settings
+ //$_POST['uname'] = "ra.admin";
+ //$_POST['psw'] = common::excuteOneSql("select ra_password from public.ra_online_user where user_login = 'ra.admin'");
+//  $name =strpos(common::ip(), "192.168.0.158") !== false || strpos(common::ip(), "192.168.0.161s") !== false ? "dddde" : 'ra.admin';
+//  $_POST['uname'] = $name;
+//  $_POST['psw'] = common::excuteOneSql("select ra_password from public.ra_online_user where user_login = '".$name."'");
 //  login::getInstance()->do_login_auto();
 //验证路由权限
 common::securityCheckHandNew($action);
@@ -98,12 +101,13 @@ switch ($action) {
             // $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();   
+            $children  = array(); 
+            $children[] = array("index" =>$index.'-1',"label" =>"System Message","path"=>"/system-message");
+            $children[] = array("index" =>$index.'-2',"label" =>"System Settings","path"=>"/SystemSettings");  
             //只有chud的账户可以看日志记录
             if(_getLoginName() == "chud" || _getLoginName() == "IT.Andywu" || _getLoginName() == "ra.admin"){
-                $children[] = array("index" =>$index.'-1',"label" =>"Operation Log","path"=>"/Operationlog");  
+                $children[] = array("index" =>$index.'-3',"label" =>"Operation Log","path"=>"/Operationlog");  
             }
-            $children[] = array("index" =>$index.'-2',"label" =>"System Settings","path"=>"/SystemSettings");
             $systemManagement["children"] = $children;
             if (!empty($children)){
                 $menuList[] = $systemManagement;
@@ -757,7 +761,7 @@ switch ($action) {
         if(!empty($_POST["management"])){
             $_param .= " management = '$management' ";
         }
-        if(!empty($dashboard_filter)){
+        if(isset($_POST["dashboardObj"]) && !empty($dashboard_filter)){
             $_param .= ",dashboard_filter = '$dashboard_filter' ";
         }
         if(!empty($_param)){
@@ -794,7 +798,21 @@ switch ($action) {
         header("Content-Disposition:attachment;filename=\"" . $display_name . "\"");
         // 将文件发送到浏览器。
         readfile($filename);
-        break;           
+        break;
+    case 'feature_update':
+        $id = $_REQUEST["id"];
+        $rootPath = realpath(dirname(__FILE__)) . DS;
+        //common::download_file($rootPath."images\ACE-M1_ISF_ACI_User_Guide\ACE-M1_ISF_ACI_User_Guide.pdf", "ACE-M1_ISF_ACI_User_Guide_V2.0.pdf");
+        // PDF文件在服务器上的位置
+        $filename = $rootPath."upload". DS."feature_update_".$id.".pdf";
+        $display_name = "feature_update.pdf";
+        // Header content type
+        header("Content-type: application/pdf");
+        header("Content-Length: " . filesize($filename));
+        header("Content-Disposition:inline;filename=\"" . $display_name . "\"");
+        // 将文件发送到浏览器。
+        readfile($filename);
+        break;               
     default:
         $data = array(
             'msg' => 'Page not found',

+ 19 - 0
service/login.class.php

@@ -197,6 +197,7 @@ class login {
                         'login_version' => $rs["login_version"],
                         'data' => '',
                         'uname' =>$uname,
+                        'user_info' => array("uname"=>$uname),
                         'msg' => 'First login, please change your password'
                     );
                     common::echo_json_encode(400, $data);
@@ -288,6 +289,22 @@ class login {
                                     "last_pwd_change"=>$rs['last_pwd_change'],
                                     "date_format"=>$kln_user['date_format'],
                                     "numbers_format"=>$kln_user['numbers_format']);
+                //添加密码是否快过期的消息通知 7 天内,3天内的通知
+                $expire_day = ($PASSWORD_CHANGE_CYCLE - $rs['last_pwd_change_date']);
+                if($expire_day <= 7){ 
+                    $exist = common::excuteListSql("select notifiation_type from public.kln_notifiation_info where notifiation_type = 'Passwond_Notifcations' 
+                        and lower(user_login) = '".strtolower($uname)."' and other_pnum = '".$expire_day."'");
+                    if (empty($exist)){
+                        $other_name = "Password Expiration in $expire_day Days";
+                        $other_desc = "Your password will expire in $expire_day days. To ensure the security of your
+    account, please change your password as soon as possible.";
+                        $message_sql ="INSERT INTO public.kln_notifiation_info(notifiation_type,  other_name, other_desc, other_img, notifications_method, email_method, 
+                            user_login, insert_date, readed_date, is_send_message, is_send_email, 
+                            frequency_type, other_type, other_pnum)
+                        VALUES ('Passwond_Notifcations','".$other_name."','".$other_desc."','',true,false,'".$uname."',now(),null,false,false,'Instant','password','".$expire_day."');";
+                        common::excuteUpdateSql($message_sql);
+                    }    
+                }
                 if ($diffdate == $PASSWORD_CHANGE_CYCLE) {// Due today
                     $login_tmp = array(
                         'msg' => 'today',
@@ -1031,9 +1048,11 @@ class login {
 
     //重置密码
     public function passwordExpires($loginName,$email,$uname){
+        $kln_user_info = array("uname"=>$uname);
         $result = array(
             'msg' => "passwordExpires",
             'uname' => $uname,
+            'user_info' => $kln_user_info
         );
         common::echo_json_encode(400, $result);
         exit();

+ 207 - 35
service/tools.class.php

@@ -346,7 +346,7 @@ class tools {
                     'tp' => intval($tp)
                 );
             } else {
-                $arrTmp = array('searchData' => array(), 
+                $arrTmp = array('monitoringRules' => array(), 
                     'rc' => intval($rc),
                     'ps' => intval($ps),
                     'cp' => intval($cp),
@@ -427,13 +427,15 @@ class tools {
             $delayData = array();
             $changeData = array(); 
             if ($rules_type == "all"){
-                $rules_type = "Milestone_Update;Container_Status_Update;Departure/Arrival_Delay;ETD/ETA_Change";
+                $rules_type = "Milestone_Update;Container_Status_Update;Departure/Arrival_Delay;ETD/ETA_Change;Feature_Update;Passwond_Notifcations";
                 $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'];
+                $featureUpdate = $allData['Feature_Update'];
+                $passwond_Notifcations = $allData['Passwond_Notifcations'];
             } else {
                 $data = $this->getNotifications($rules_type,"all");
                 if($rules_type == "Milestone_Update"){
@@ -444,10 +446,15 @@ class tools {
                     $delayData = $data['Departure/Arrival_Delay'];
                 }elseif($rules_type == "ETD/ETA_Change"){
                     $changeData = $data['ETD/ETA_Change'];
+                }elseif($rules_type == "Feature_Update"){
+                    $featureUpdate = $data['Feature_Update'];
+                }elseif($rules_type == "Passwond_Notifcations"){
+                    $passwond_Notifcations = $data['Passwond_Notifcations'];
                 }
             }
 
-            $data = array("milestoneData"=>$milestoneData,"containerData"=>$containerData,"delayData"=>$delayData,"changeData"=>$changeData);
+            $data = array("milestoneData"=>$milestoneData,"containerData"=>$containerData,"delayData"=>$delayData,
+                "changeData"=>$changeData,"featureUpdate"=>$featureUpdate,"passwond_Notifcations"=>$passwond_Notifcations);
             $instant_sum = array();
             foreach($data as $v){
                 if(!empty($v['instant'])){
@@ -473,12 +480,18 @@ class tools {
             }
             //根据时间顺序排序
             $insert_dates = array_column($instant_sum, 'insert_date');
-            array_multisort($insert_dates, SORT_ASC, $instant_sum);
+            array_multisort($insert_dates, SORT_DESC, $instant_sum);
 
             $info = array();
             foreach($instant_sum as $mInfo){
                 $eventCard = $this->getEventCard($mInfo);
-                $info[] = array("notificationType"=>"event","info" =>$eventCard);
+                if(!empty($mInfo['other_type']) && $mInfo['other_type'] == "password"){
+                    $info[] = array("notificationType"=>"password","info" =>$eventCard);
+                }elseif(!empty($mInfo['other_type']) && $mInfo['other_type'] == "feature"){
+                    $info[] = array("notificationType"=>"feature","info" =>$eventCard);
+                }else{
+                    $info[] = array("notificationType"=>"event","info" =>$eventCard);
+                }
             }
 
             $returnData = $info;
@@ -507,8 +520,9 @@ class tools {
                 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"];
+                        $returnData["etdOrdeparturNum"] = $dataInfo["numericRecords_one"];
+                        $returnData["etaOrarrivalNum"] =$dataInfo["numericRecords_two"];
+                        $returnData["type"] =$eventCard["type"];
                     }else{
                         $returnData["numericRecords"] = $dataInfo["numericRecords"];
                     }
@@ -525,8 +539,8 @@ class tools {
             //点击seall会默认全部标记为已读
             if(!empty($ids)){
                 $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$ids)));
-                $markReadSql = "update public.kln_notifiation_info set is_send_message = true where id in ($more_param)";
-                //common::excuteUpdateSql($markReadSql);
+                $markReadSql = "update public.kln_notifiation_info set is_send_message = true,readed_date = now() where id in ($more_param)";
+                common::excuteUpdateSql($markReadSql);
             }
             common::echo_json_encode(200,$returnData);
             exit();
@@ -537,10 +551,10 @@ class tools {
             $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())."'");
+                $rs = common::excuteUpdateSql("update public.kln_notifiation_info set is_send_message = true,readed_date = now() 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)";
+                $markReadSql = "update public.kln_notifiation_info set is_send_message = true,readed_date = now() where id in ($more_param)";
                 $rs = common::excuteUpdateSql($markReadSql);
             }
             if ($rs === FALSE){
@@ -554,24 +568,126 @@ class tools {
         }
 
         if ($operate == "notifications_message_init"){
-            $rules_type = common::check_input($_REQUEST['rules_type']);
             //查询所有情况得未读情况 查询最近一年的情况
-            "with dt as(select from  public.kln_notifiation_info 
-                where insert_date > NOW() - INTERVAL '1 year' 
-                    and notifications_method = 'true' and is_send_message = 'false'
+            $unreadSql = "with countTbale as (
+                select ni.notifiation_type,
+                    case when COALESCE(ni.frequency_type,'') = 'Daily'
+                            then to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY')
+                    when COALESCE(ni.frequency_type,'') = 'Weekly' 
+                            then to_char(date_trunc('week', ni.insert_date),'Mon DD, YYYY')|| ' - ' ||to_char((date_trunc('week', ni.insert_date) + INTERVAL '6 days'),'Mon DD, YYYY')
+                    else '' 
+                    end  as insert_date_format  
+                from  public.kln_notifiation_info ni
+                where ni.insert_date > NOW() - INTERVAL '1 year' 
+                    and ni.notifications_method = 'true' and ni.is_send_message = 'false'
                     and lower(ni.user_login) = '".strtolower(_getLoginName())."'
-                    and frequency_type = 'Daily' group by to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY'))";
-            "select 
-                    sum(case when (1<>1 or (notifiation_type='Milestone_Update') then 1 else 0 end) as m_rc,
+                    and ni.frequency_type in ('Daily','Weekly')  group by ni.notifiation_type,insert_date_format 
+            union all
+                select ni.notifiation_type, '' as insert_date_format  
+                    from  public.kln_notifiation_info ni
+                    where ni.insert_date > NOW() - INTERVAL '1 year' 
+                        and lower(ni.user_login) in ('".strtolower(_getLoginName())."','all_user')
+                        and ni.notifications_method = 'true' and ni.is_send_message = 'false'
+                        and frequency_type = 'Instant'  
+            )
+            select 
+                    sum(case when (1<>1 or (notifiation_type='Milestone_Update')) then 1 else 0 end) as m_rc,
                     sum(case when (1<>1 or (notifiation_type='Container_Status_Update')) then 1 else 0 end) as cs_rc,
                     sum(case when (1<>1 or (notifiation_type='Departure/Arrival_Delay')) then 1 else 0 end) as da_rc,
                     sum(case when (1<>1 or (notifiation_type='ETD/ETA_Change')) then 1 else 0 end) as ec_rc,
-                    sum(case when (1<>1 or (notifiation_type='Feature_Update')) then 1 else 0 end) as f_rc,
-                from  public.kln_notifiation_info 
-            where insert_date > NOW() - INTERVAL '1 year' 
-                and frequency_type = 'Instant'
-                and notifications_method = 'true' and is_send_message = 'false'
-                and lower(ni.user_login) = '".strtolower(_getLoginName())."'";
+                    sum(case when (1<>1 or (notifiation_type='Feature_Update')) then 1 else 0 end) as f_rc
+                from  countTbale ";
+
+            $count = common::excuteObjectSql($unreadSql);
+
+            //单独的选中的数据
+            $rules_type = common::check_input($_REQUEST['rules_type']);
+            $data = $this->getNotifications($rules_type,"all");
+
+            $unreadCount = 0;
+            $readCount = 0;
+            $instant_sum = array();
+            if(!empty($data[$rules_type]['instant'])){
+                foreach($data[$rules_type]['instant'] as $instant){
+                    $instant_sum[] = $instant;
+                    if($instant["is_send_message"] == 't'){
+                        $readCount +=1;
+                    }else{
+                        $unreadCount +=1;
+                    }
+                }
+            }
+            if(!empty($data[$rules_type]['daily'])){
+                $dailys = common::handleDailyWeekedData($data[$rules_type]['daily']);
+                foreach($dailys as $dailyArr){
+                    //取第一组的第一个显示
+                    $dailyFristAndFrist = utils::getDailyAndweeklyFrist($dailyArr);
+                    $instant_sum[]= $dailyFristAndFrist;
+                    if($dailyFristAndFrist["is_send_message"] == 't'){
+                        $readCount +=1;
+                    }else{
+                        $unreadCount +=1;
+                    }
+                }
+            }
+            if(!empty($data[$rules_type]['weekly'])){
+                $weeklys = common::handleDailyWeekedData($data[$rules_type]['weekly']);
+                foreach($weeklys as $weeklyArr){
+                    $weeklyFristAndFrist = utils::getDailyAndweeklyFrist($weeklyArr);
+                    $instant_sum[]= $weeklyFristAndFrist;
+                    if($weeklyFristAndFrist["is_send_message"] == 't'){
+                        $readCount +=1;
+                    }else{
+                        $unreadCount +=1;
+                    }
+                }
+            }
+
+            //根据时间顺序排序
+            $insert_dates = array_column($instant_sum, 'insert_date');
+            array_multisort($insert_dates, SORT_DESC, $instant_sum);
+
+            $info = array();
+            foreach($instant_sum as $mInfo){
+                $eventCard = $this->getEventCard($mInfo);
+                if(!empty($mInfo['other_type']) && $mInfo['other_type'] == "password"){
+                    $info[] = array("notificationType"=>"password","info" =>$eventCard);
+                }elseif(!empty($mInfo['other_type']) && $mInfo['other_type'] == "feature"){
+                    $info[] = array("notificationType"=>"feature","info" =>$eventCard);
+                }else{
+                    $info[] = array("notificationType"=>"event","info" =>$eventCard);
+                }
+            }
+
+            //返回数据结构
+            $returnData = array();
+            $m_rc = empty($count['m_rc']) ? 0 : intval($count['m_rc']);
+            $cs_rc = empty($count['cs_rc']) ? 0 : intval($count['cs_rc']);
+            $da_rc = empty($count['da_rc']) ? 0 : intval($count['da_rc']);
+            $ec_rc = empty($count['ec_rc']) ? 0 : intval($count['ec_rc']);
+            $f_rc = empty($count['f_rc']) ? 0 : intval($count['f_rc']);
+            $returnData['countList'] = array($m_rc,$cs_rc,$da_rc,$ec_rc,$f_rc);
+            $returnData['allCount'] =count($instant_sum);
+            $returnData['unreadCount'] =$unreadCount;
+            $returnData['readCount'] =$readCount;
+            $returnData['cardList'] =$info;
+
+            common::echo_json_encode(200,$returnData);
+            exit();
+        }
+
+        if ($operate == "check_notifications_message"){
+            $checkUnread = "select id
+                from public.kln_notifiation_info ni  
+                    where lower(ni.user_login) in ('".strtolower(_getLoginName())."','all_user')
+                        and (ni.frequency_type = 'Instant' 
+                            or (ni.frequency_type = 'Daily'  and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)
+                            or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time 
+                                    and  ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')) 
+                        and ni.notifications_method = true and is_send_message = false limit 1";
+            $unread = common::excuteObjectSql($checkUnread); 
+            $returnData = array("has_message" =>!empty($unread));
+            common::echo_json_encode(200,$returnData);      
         }
     }
 
@@ -874,7 +990,8 @@ class tools {
                 }else{
                     //正常字段直接比较就行
                     $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
-                    if($postValue != $rule[$filed]){
+                    $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
+                    if($postValue != $dbValue){
                         $range_flag = false;
                     }
                 }
@@ -902,7 +1019,8 @@ class tools {
                     }
                 } else {
                     $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
-                    if($postValue != $rule[$filed]){
+                    $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
+                    if($postValue != $dbValue){
                         $details_flag = false;
                     }
                 }
@@ -914,7 +1032,8 @@ class tools {
             $frequency_flag = true; 
             foreach($checkFrequencyFiled as $filed){
                 $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
-                if($postValue != $rule[$filed]){
+                $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
+                if($postValue != $dbValue){
                     $frequency_flag = false;
                 }
             }
@@ -956,6 +1075,17 @@ class tools {
             $sql_where = " and (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time 
                                     and  ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
         }
+        if (!empty($_REQUEST['current_time'])){
+            // $sql_where .= " and ni.insert_date >= TO_TIMESTAMP('".$_REQUEST['current_time']."', 'MM/DD/YYYY HH24:MI:SS') - interval '5 minutes'
+            //     and ni.is_send_message = false";
+            //这里都以服务器时间,检查标准
+            $sql_where .= " and ni.insert_date >= now() - interval '5 minutes'
+                 and ni.is_send_message = false";
+        }
+        if (!empty($_REQUEST['info_type']) && $_REQUEST['info_type'] == 'true'){
+            $sql_where .= " and ni.is_send_message = false";
+        }
+
         //这里的查询会把不同日期的但hbol相同的信息,过滤掉只剩下最新的那一条。所以移除
         $aa_where = "";
         if (!empty($insert_date_format)){
@@ -968,9 +1098,9 @@ class tools {
                     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)))
+                            then (FLOOR(EXTRACT(epoch FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp))/3600))
                         else 0 
-                    end  as delay_diff,
+                    end  as _delay_diff,
 
                     case when COALESCE(ni.frequency_type,'') = 'Daily'
                             then to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY')
@@ -989,12 +1119,18 @@ class tools {
                         else ''
                     end as ctnr_previous_json,
 
+                    case when ni.notifiation_type ='Container_Status_Update' 
+                        then (select description 
+                                    from public.ra_online_edi_event e where e.ra_name = ni.ctnr_status_code limit 1)
+                        else ''
+                    end as ctnr_desc,
+
                     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) = '".strtolower(_getLoginName())."' 
+                where lower(ni.user_login) in ('".strtolower(_getLoginName())."','all_user')
                         and lower(ni.notifiation_type) in ($more_param)
                     ".$sql_where." and ni.notifications_method = true order by ni.insert_date desc) aa $aa_where";
         error_log($sql);
@@ -1079,13 +1215,15 @@ class tools {
                     "order_from"=>$mInfo["order_from"], 
                     "id"=>$mInfo["id"],
                     "insert_date_format"=>'',
+                    "rules_type"=>$mInfo["notifiation_type"],
                     "info"=>new stdClass());
 
             if ($mInfo["frequency_type"] == "Daily"){
                 $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
                 $eventCard["title"] = "Milestone Update Daily Summary(".$mInfo["insert_date_format"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
-                $eventCard["previous"] = '';
+                //seeall 的时候,前端不需要id
+                $eventCard["id"] = '';
 
                 $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
                 if(!empty($milestone_previous['milestone']['milestone_date'])){
@@ -1098,6 +1236,8 @@ class tools {
                 $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
                 $eventCard["title"] = "Milestone Update Weekly Summary(".$mInfo["insert_date_format"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                //seeall 的时候,前端不需要id
+                $eventCard["id"] = '';
 
                 $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
                 if(!empty($milestone_previous['milestone']['milestone_date'])){
@@ -1106,18 +1246,19 @@ class tools {
                         "time" => $milestone_previous['milestone']['milestone_time'],
                         "timezone" =>$milestone_previous['milestone']['timezone']);    
                 }
+                
             }
         }
         if($notifiation_type == "Container_Status_Update"){
-            //当前状态的描述
-            $ctnrStatusdesc = $this->getContainerStatusDesc($mInfo["ctnr_status_code"]);
+            //当前状态的描述ctnr_desc
+            //$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,
+                    "tag"=>$mInfo["ctnr_desc"],
                     "location"=>$mInfo["ctnr_status_locations"],
                     "timezone"=>$mInfo["ctnr_status_timezone"],
                     "time"=>$mInfo["ctnr_status_date"]." ".$mInfo["ctnr_status_time"],
@@ -1128,12 +1269,15 @@ class tools {
                     "order_from"=>$mInfo["order_from"],
                     "id"=>$mInfo["id"],
                     "insert_date_format"=>'',
+                    "rules_type"=>$mInfo["notifiation_type"],
                     "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"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                //seeall 的时候,前端不需要id
+                $eventCard["id"] = '';
 
                 $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
                 if(!empty($ctnr_previous["ctnrStatus"]["date"])){
@@ -1147,6 +1291,8 @@ class tools {
                 $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
                 $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                //seeall 的时候,前端不需要id
+                $eventCard["id"] = '';
 
                 $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
                 if(!empty($ctnr_previous["ctnrStatus"]["date"])){
@@ -1195,7 +1341,7 @@ class tools {
             }
             $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_diff = $mInfo["_delay_diff"];
             $delay_unit = $mInfo["delay_unit"];
             $eventCard = array("type" =>'delay',
                     "numericRecords"=>0,
@@ -1214,6 +1360,7 @@ class tools {
                     "order_from"=>$mInfo["order_from"],
                     "id"=>$mInfo["id"],
                     "insert_date_format"=>'',
+                    "rules_type"=>$mInfo["notifiation_type"],
                     "info"=>array("route"=>$route,
                         "leg"=>$leg,
                         "etdOrdeparturNum"=>0,
@@ -1230,12 +1377,16 @@ class tools {
                 $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
                 $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                //seeall 的时候,前端不需要id
+                $eventCard["id"] = '';
             } 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"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                //seeall 的时候,前端不需要id
+                $eventCard["id"] = '';
             }
         }
         if($notifiation_type == "ETD/ETA_Change"){
@@ -1277,6 +1428,7 @@ class tools {
                     "order_from"=>$mInfo["order_from"],
                     "id"=>$mInfo["id"],
                     "insert_date_format"=>'',
+                    "rules_type"=>$mInfo["notifiation_type"],
                     "info"=>array("route"=>$route,
                         "leg"=>$leg,
                         "etdOrdeparturNum"=>0,
@@ -1293,14 +1445,34 @@ class tools {
                 $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
                 $eventCard["title"] = "ETD/ETA Change Daily Summary(".$mInfo["insert_date_format"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                $eventCard["id"] = "";
             } 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"].")";
                 $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
+                $eventCard["id"] = "";
             }
         }
+        if($notifiation_type == "Feature_Update" || $notifiation_type == "Passwond_Notifcations"){
+            $title = $mInfo["other_type"] == "password" ? "Password Notifications" : "Feature Update";
+            $isExpiration = false;
+            if($title == "Password Notifications" and $mInfo["other_pnum"] <= 3){
+                $isExpiration = true;
+            }
+            $eventCard = array(
+                "title" => $title,
+                "id"=> $mInfo["id"],
+                "header"=> $mInfo["other_name"],
+                "content"=>$mInfo["other_desc"],
+                "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
+                "isExpiration"=> $isExpiration,
+                "rules_type"=>$mInfo["notifiation_type"],
+                "imgSrc"=>SERVER_PAHT.FILE_UPLOAD_PAHT."feature_update_".$mInfo["id"].".jpg",
+                "view_more_link" =>"main_new_version.php?action=feature_update&id=".$mInfo["id"]
+            );
+        }
         return $eventCard;
     }
 

+ 5 - 1
utils/common.class.php

@@ -142,8 +142,12 @@ class common {
                         if (!utils::checkExist($_SESSION['ONLINE_USER']['permission'], $action) 
                             && !(stripos($action, "main") === 0) 
                             && !(stripos($action, "user_guide") === 0)
+                            && !(stripos($action, "feature_update") === 0)
                             && !(stripos($action, "ajax") === 0)
-                            && !(stripos($action, "opreation_log") === 0)) {
+                            && !(stripos($action, "opreation_log") === 0)
+                            && !(stripos($action, "system_setting") === 0)
+                            && !(stripos($action, "monitoring_setting") === 0)
+                            && !(stripos($action, "notifications_rules") === 0)) {
                                 
                             $data = array("msg"=>"Permission Denied");
                             common::echo_json_encode(500, $data);