|
@@ -155,14 +155,14 @@ class tools {
|
|
|
$last_name = common::check_input($_POST['last_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())."'";
|
|
$sql = "update public.ra_online_user set first_name = '$first_name',last_name = '$last_name' where lower(user_login) = '".strtolower(_getLoginName())."'";
|
|
|
}else{
|
|
}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())."'");
|
|
$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'])){
|
|
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 {
|
|
} else {
|
|
|
$sql = "INSERT INTO public.kln_user_extend(user_login, date_format, numbers_format, subscribe_hbol)
|
|
$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);
|
|
common::excuteUpdateSql($sql);
|
|
@@ -294,12 +294,10 @@ class tools {
|
|
|
$airMilestone = array();
|
|
$airMilestone = array();
|
|
|
foreach($milestones as $milestone){
|
|
foreach($milestones as $milestone){
|
|
|
if($milestone['type'] == "air"){
|
|
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"){
|
|
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;
|
|
$ret["OceanCheckBoxList"] = $oceanMilestone;
|
|
@@ -310,7 +308,7 @@ class tools {
|
|
|
$event =common::getEDICtnrEvent();
|
|
$event =common::getEDICtnrEvent();
|
|
|
$ctnrStatus = array();
|
|
$ctnrStatus = array();
|
|
|
foreach($event as $e){
|
|
foreach($event as $e){
|
|
|
- $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
|
|
|
|
|
|
|
+ $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
|
|
|
}
|
|
}
|
|
|
$ret["CtnrCheckBoxList"] = $ctnrStatus;
|
|
$ret["CtnrCheckBoxList"] = $ctnrStatus;
|
|
|
common::echo_json_encode(200,$ret);
|
|
common::echo_json_encode(200,$ret);
|
|
@@ -340,16 +338,16 @@ class tools {
|
|
|
$monitoringRules = common::excuteListSql($sql);
|
|
$monitoringRules = common::excuteListSql($sql);
|
|
|
$arrTmp = array('monitoringRules' => $monitoringRules,
|
|
$arrTmp = array('monitoringRules' => $monitoringRules,
|
|
|
'rc' => intval($rc),
|
|
'rc' => intval($rc),
|
|
|
- 'ps' => $ps,
|
|
|
|
|
- 'cp' => $cp,
|
|
|
|
|
- 'tp' => $tp
|
|
|
|
|
|
|
+ 'ps' => intval($ps),
|
|
|
|
|
+ 'cp' => intval($cp),
|
|
|
|
|
+ 'tp' => intval($tp)
|
|
|
);
|
|
);
|
|
|
} else {
|
|
} else {
|
|
|
$arrTmp = array('searchData' => array(),
|
|
$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);
|
|
common::echo_json_encode(200,$arrTmp);
|
|
@@ -373,17 +371,8 @@ class tools {
|
|
|
|
|
|
|
|
$rules = $this->getSubscribeRules($rules_type,$subscribe_rules);
|
|
$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;
|
|
$monitoring_data[$rules_type] = $rules;
|
|
|
common::echo_json_encode(200,$monitoring_data);
|
|
common::echo_json_encode(200,$monitoring_data);
|
|
@@ -435,20 +424,23 @@ class tools {
|
|
|
$delayData = array();
|
|
$delayData = array();
|
|
|
$changeData = array();
|
|
$changeData = array();
|
|
|
if ($rules_type == "all"){
|
|
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 {
|
|
} else {
|
|
|
$data = $this->getNotifications($rules_type,"all");
|
|
$data = $this->getNotifications($rules_type,"all");
|
|
|
if($rules_type == "Milestone_Update"){
|
|
if($rules_type == "Milestone_Update"){
|
|
|
- $milestoneData = $data;
|
|
|
|
|
|
|
+ $milestoneData = $data['Milestone_Update'];
|
|
|
}elseif($rules_type == "Container_Status_Update"){
|
|
}elseif($rules_type == "Container_Status_Update"){
|
|
|
- $containerData = $data;
|
|
|
|
|
|
|
+ $containerData = $data['Container_Status_Update'];
|
|
|
}elseif($rules_type == "Departure/Arrival_Delay"){
|
|
}elseif($rules_type == "Departure/Arrival_Delay"){
|
|
|
- $delayData = $data;
|
|
|
|
|
|
|
+ $delayData = $data['Departure/Arrival_Delay'];
|
|
|
}elseif($rules_type == "ETD/ETA_Change"){
|
|
}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']);
|
|
$rules_type = common::check_input($_REQUEST['rules_type']);
|
|
|
$frequency_type = common::check_input($_REQUEST['frequency_type']); //这个只会传daily 和weekly
|
|
$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);
|
|
$dataInfo =utils::getDailyAndweeklyFrist($moreData);
|
|
@@ -518,16 +510,44 @@ class tools {
|
|
|
$returnData["notificationList"] = $notificationList;
|
|
$returnData["notificationList"] = $notificationList;
|
|
|
}
|
|
}
|
|
|
//点击seall会默认全部标记为已读
|
|
//点击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);
|
|
common::echo_json_encode(200,$returnData);
|
|
|
exit();
|
|
exit();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if($operate == "notifications_read"){
|
|
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();
|
|
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();
|
|
$airMilestone = array();
|
|
|
foreach($milestones as $milestone){
|
|
foreach($milestones as $milestone){
|
|
|
if($milestone['type'] == "air"){
|
|
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"){
|
|
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;
|
|
$ret["OceanCheckBoxList"] = $oceanMilestone;
|
|
@@ -566,12 +584,8 @@ class tools {
|
|
|
|
|
|
|
|
$oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
|
|
$oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
|
|
|
$airMilestoneSetting = !empty($ret['air_milestone']) ? explode(";",$ret['air_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的结构处理
|
|
//Milestone Update的结构处理
|
|
|
if($rule_name == "Container_Status_Update"){
|
|
if($rule_name == "Container_Status_Update"){
|
|
@@ -579,14 +593,12 @@ class tools {
|
|
|
$event =common::getEDICtnrEvent();
|
|
$event =common::getEDICtnrEvent();
|
|
|
$ctnrStatus = array();
|
|
$ctnrStatus = array();
|
|
|
foreach($event as $e){
|
|
foreach($event as $e){
|
|
|
- $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
|
|
|
|
|
|
|
+ $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
|
|
|
}
|
|
}
|
|
|
$ret["CtnrCheckBoxList"] = $ctnrStatus;
|
|
$ret["CtnrCheckBoxList"] = $ctnrStatus;
|
|
|
|
|
|
|
|
$ctnrStatusSetting = !empty($ret['ocean_ctnr_status']) ? explode(";",$ret['ocean_ctnr_status']) : array();
|
|
$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;
|
|
return $ret;
|
|
@@ -648,38 +660,6 @@ class tools {
|
|
|
return $arrTmp;
|
|
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){
|
|
public function getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,$notifications_type,$id){
|
|
|
$sql = "";
|
|
$sql = "";
|
|
|
//先删后加
|
|
//先删后加
|
|
@@ -703,8 +683,10 @@ class tools {
|
|
|
$weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
|
|
$weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
|
|
|
$weekly_time_zone = common::check_input($_POST['weekly_time_zone']);
|
|
$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']);
|
|
$event_details = common::check_input($_POST['event_details']);
|
|
|
$frequency_display = common::check_input($_POST['frequency_display']);
|
|
$frequency_display = common::check_input($_POST['frequency_display']);
|
|
|
$method_display = common::check_input($_POST['method_display']);
|
|
$method_display = common::check_input($_POST['method_display']);
|
|
@@ -715,15 +697,7 @@ class tools {
|
|
|
$shipment_etd_limit = "";
|
|
$shipment_etd_limit = "";
|
|
|
$shipment_eta_limit = "";
|
|
$shipment_eta_limit = "";
|
|
|
if($notifications_type == "Monitoring"){
|
|
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_etd_limit = common::check_input($_POST['shipment_etd_limit']);
|
|
|
$shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
|
|
$shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
|
|
|
}
|
|
}
|
|
@@ -737,14 +711,12 @@ class tools {
|
|
|
if($milestone['type'] == "air"){
|
|
if($milestone['type'] == "air"){
|
|
|
$airMilestone[] = $milestone;
|
|
$airMilestone[] = $milestone;
|
|
|
}
|
|
}
|
|
|
- if($milestone['type'] == "ocean"){
|
|
|
|
|
|
|
+ if($milestone['type'] == "sea"){
|
|
|
$oceanMilestone[] = $milestone;
|
|
$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(
|
|
$sql.="INSERT INTO public.notifications_rules(
|
|
|
user_login, notifications_type, rules_type, ocean_milestone,
|
|
user_login, notifications_type, rules_type, ocean_milestone,
|
|
@@ -761,8 +733,7 @@ class tools {
|
|
|
|
|
|
|
|
if ($rules_type == "Container_Status_Update"){
|
|
if ($rules_type == "Container_Status_Update"){
|
|
|
$event = common::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);
|
|
|
|
|
|
|
+ $ocean_ctnr_status = utils::implode(";",$_POST['ocean_ctnr_status']);
|
|
|
|
|
|
|
|
$sql.="INSERT INTO public.notifications_rules(
|
|
$sql.="INSERT INTO public.notifications_rules(
|
|
|
user_login, notifications_type, rules_type, ocean_ctnr_status,
|
|
user_login, notifications_type, rules_type, ocean_ctnr_status,
|
|
@@ -818,26 +789,26 @@ class tools {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($rules_type == "ETD/ETA_Change"){
|
|
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 = 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']);
|
|
$ocean_etd_old_sub_new_unit = common::check_input($_POST['ocean_etd_old_sub_new_unit']);
|
|
|
if(!empty($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_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 = 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']);
|
|
$ocean_eta_old_sub_new_unit = common::check_input($_POST['ocean_eta_old_sub_new_unit']);
|
|
|
if(!empty($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";
|
|
$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 = 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']);
|
|
$air_etd_old_sub_new_unit = common::check_input($_POST['air_etd_old_sub_new_unit']);
|
|
|
if(!empty($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_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 = 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']);
|
|
$air_eta_old_sub_new_unit = common::check_input($_POST['air_eta_old_sub_new_unit']);
|
|
|
if(!empty($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'])){
|
|
if(isset($_POST['id']) && !empty($_POST['id'])){
|
|
|
$sql_where = " and id <> '".common::check_input($_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");
|
|
and lower(user_login) = '".strtolower(_getLoginName())."' $sql_where");
|
|
|
foreach($rules as $rule){
|
|
foreach($rules as $rule){
|
|
|
//判断range 是否一样
|
|
//判断range 是否一样
|
|
@@ -879,12 +850,18 @@ class tools {
|
|
|
$range_flag = true;
|
|
$range_flag = true;
|
|
|
foreach($checkRangeFiled as $filed){
|
|
foreach($checkRangeFiled as $filed){
|
|
|
if($filed == "shipment_transport_mode"){
|
|
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{
|
|
}else{
|
|
|
|
|
+ //正常字段直接比较就行
|
|
|
$postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
|
|
$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;
|
|
$details_flag = true;
|
|
|
foreach($checkDetailsFiled as $filed){
|
|
foreach($checkDetailsFiled as $filed){
|
|
|
if($filed == "ocean_milestone" || $filed == "air_milestone" || $filed == "ocean_ctnr_status"){
|
|
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]);
|
|
$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] : "";
|
|
$postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
|
|
|
|
|
+ if($postValue != $rule[$filed]){
|
|
|
|
|
+ $details_flag = false;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- if($postValue != $rule[$filed]){
|
|
|
|
|
- $details_flag = false;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//判断frequency 是否一样
|
|
//判断frequency 是否一样
|
|
@@ -922,7 +908,7 @@ class tools {
|
|
|
$checkMethodFiled = array("method_by_email","method_by_message");
|
|
$checkMethodFiled = array("method_by_email","method_by_message");
|
|
|
$method_flag = true;
|
|
$method_flag = true;
|
|
|
foreach($checkMethodFiled as $filed){
|
|
foreach($checkMethodFiled as $filed){
|
|
|
- $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
|
|
|
|
|
|
|
+ $postValue = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f" : "t";
|
|
|
if($postValue != $rule[$filed]){
|
|
if($postValue != $rule[$filed]){
|
|
|
$method_flag = false;
|
|
$method_flag = false;
|
|
|
}
|
|
}
|
|
@@ -934,7 +920,7 @@ class tools {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
//前三个重回,后面不重合,提示但允许保存
|
|
//前三个重回,后面不重合,提示但允许保存
|
|
|
- if($range_flag && $details_flag){
|
|
|
|
|
|
|
+ if($range_flag && $details_flag && $_POST['is_similar_rule'] <> 'true'){
|
|
|
$msg = "Similar Rule Detected";
|
|
$msg = "Similar Rule Detected";
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -956,6 +942,8 @@ class tools {
|
|
|
and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
|
|
and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $more_param = common::getInNotInSqlForSearch($notifiation_type);
|
|
|
|
|
+
|
|
|
$sql = "select ni.*,
|
|
$sql = "select ni.*,
|
|
|
case when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'days'
|
|
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)))
|
|
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
|
|
left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from
|
|
|
from public.kln_ocean oo
|
|
from public.kln_ocean oo
|
|
|
where oo.serial_no = ni.serial_no limit 1) ccc on true
|
|
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";
|
|
".$sql_where." and ni.notifications_method = true order by ni.insert_date desc";
|
|
|
error_log($sql);
|
|
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){
|
|
public function getEventCard($mInfo){
|