|
|
@@ -539,7 +539,7 @@ 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,readed_date = now() where id in ($more_param)";
|
|
|
+ $markReadSql = "update public.kln_notifiation_info set is_send_message = now(),readed_date = now() where id in ($more_param)";
|
|
|
common::excuteUpdateSql($markReadSql);
|
|
|
}
|
|
|
common::echo_json_encode(200,$returnData);
|
|
|
@@ -551,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,readed_date = now() where lower(user_login) = '".strtolower(_getLoginName())."'");
|
|
|
+ $rs = common::excuteUpdateSql("update public.kln_notifiation_info set is_send_message = now(),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,readed_date = now() where id in ($more_param)";
|
|
|
+ $markReadSql = "update public.kln_notifiation_info set is_send_message = now(),readed_date = now() where id in ($more_param)";
|
|
|
$rs = common::excuteUpdateSql($markReadSql);
|
|
|
}
|
|
|
if ($rs === FALSE){
|
|
|
@@ -574,12 +574,14 @@ class tools {
|
|
|
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')
|
|
|
+ then to_char(ni.insert_date::date - (((EXTRACT(dow FROM ni.insert_date)::integer - ni.weekly_week::integer + 7) % 7) ||' days')::INTERVAL,'Mon DD, YYYY')
|
|
|
+ || ' - ' ||
|
|
|
+ to_char(ni.insert_date::date + (((ni.weekly_week::integer - EXTRACT(dow FROM ni.insert_date)::integer + 7) % 7)-1 + CASE WHEN EXTRACT(DOW FROM ni.insert_date)::integer=ni.weekly_week::integer THEN 7 ELSE 0 END ||' days')::INTERVAL,'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 ni.notifications_method = 'true' and ni.is_send_message is null
|
|
|
and lower(ni.user_login) = '".strtolower(_getLoginName())."'
|
|
|
and ni.frequency_type in ('Daily','Weekly') group by ni.notifiation_type,insert_date_format
|
|
|
union all
|
|
|
@@ -587,7 +589,7 @@ class tools {
|
|
|
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 ni.notifications_method = 'true' and ni.is_send_message is null
|
|
|
and frequency_type = 'Instant'
|
|
|
)
|
|
|
select
|
|
|
@@ -610,7 +612,7 @@ class tools {
|
|
|
if(!empty($data[$rules_type]['instant'])){
|
|
|
foreach($data[$rules_type]['instant'] as $instant){
|
|
|
$instant_sum[] = $instant;
|
|
|
- if($instant["is_send_message"] == 't'){
|
|
|
+ if(!empty($instant["is_send_message"])){
|
|
|
$readCount +=1;
|
|
|
}else{
|
|
|
$unreadCount +=1;
|
|
|
@@ -623,7 +625,7 @@ class tools {
|
|
|
//取第一组的第一个显示
|
|
|
$dailyFristAndFrist = utils::getDailyAndweeklyFrist($dailyArr);
|
|
|
$instant_sum[]= $dailyFristAndFrist;
|
|
|
- if($dailyFristAndFrist["is_send_message"] == 't'){
|
|
|
+ if(!empty($dailyFristAndFrist["is_send_message"])){
|
|
|
$readCount +=1;
|
|
|
}else{
|
|
|
$unreadCount +=1;
|
|
|
@@ -635,7 +637,7 @@ class tools {
|
|
|
foreach($weeklys as $weeklyArr){
|
|
|
$weeklyFristAndFrist = utils::getDailyAndweeklyFrist($weeklyArr);
|
|
|
$instant_sum[]= $weeklyFristAndFrist;
|
|
|
- if($weeklyFristAndFrist["is_send_message"] == 't'){
|
|
|
+ if(!empty($weeklyFristAndFrist["is_send_message"])){
|
|
|
$readCount +=1;
|
|
|
}else{
|
|
|
$unreadCount +=1;
|
|
|
@@ -681,10 +683,12 @@ class tools {
|
|
|
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 = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time
|
|
|
+ and ni.insert_date::date <= CURRENT_DATE + 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";
|
|
|
+ and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
|
|
|
+ and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time))
|
|
|
+ and ni.notifications_method = true and is_send_message is null limit 1";
|
|
|
$unread = common::excuteObjectSql($checkUnread);
|
|
|
$returnData = array("has_message" =>!empty($unread));
|
|
|
common::echo_json_encode(200,$returnData);
|
|
|
@@ -1187,24 +1191,30 @@ class tools {
|
|
|
public function getNotifications($notifiation_type,$frequency_type,$insert_date_format = null){
|
|
|
if ($frequency_type == "all"){
|
|
|
$sql_where = " 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 = 'Daily'
|
|
|
+ and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time
|
|
|
+ and ni.insert_date::date <= CURRENT_DATE + 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.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
|
|
|
+ and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time))";
|
|
|
} elseif($frequency_type == "Daily"){
|
|
|
- $sql_where = " and (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)";
|
|
|
+ $sql_where = " and (ni.frequency_type = 'Daily'
|
|
|
+ and timezone(ni.daily_time_zone, NOW()::time) >= ni.daily_time::time
|
|
|
+ and ni.insert_date::date <= CURRENT_DATE + ni.daily_time::time)";
|
|
|
} elseif($frequency_type == "Weekly"){
|
|
|
$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())) ||'%')";
|
|
|
+ and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
|
|
|
+ and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time)";
|
|
|
}
|
|
|
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";
|
|
|
+ // and ni.is_send_message is null";
|
|
|
//这里都以服务器时间,检查标准
|
|
|
$sql_where .= " and ni.insert_date >= now() - interval '5 minutes'
|
|
|
- and ni.is_send_message = false";
|
|
|
+ and ni.is_send_message is null";
|
|
|
}
|
|
|
if (!empty($_REQUEST['info_type']) && $_REQUEST['info_type'] == 'true'){
|
|
|
- $sql_where .= " and ni.is_send_message = false";
|
|
|
+ $sql_where .= " and ni.is_send_message is null";
|
|
|
}
|
|
|
|
|
|
//这里的查询会把不同日期的但hbol相同的信息,过滤掉只剩下最新的那一条。所以移除
|
|
|
@@ -1226,7 +1236,9 @@ class tools {
|
|
|
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')
|
|
|
+ then to_char(ni.insert_date::date - (((EXTRACT(dow FROM ni.insert_date)::integer - ni.weekly_week::integer + 7) % 7) ||' days')::INTERVAL,'Mon DD, YYYY')
|
|
|
+ || ' - ' ||
|
|
|
+ to_char(ni.insert_date::date + (((ni.weekly_week::integer - EXTRACT(dow FROM ni.insert_date)::integer + 7) % 7)-1 + CASE WHEN EXTRACT(DOW FROM ni.insert_date)::integer=ni.weekly_week::integer THEN 7 ELSE 0 END ||' days')::INTERVAL,'Mon DD, YYYY')
|
|
|
else ''
|
|
|
end as insert_date_format,
|
|
|
|
|
|
@@ -1321,7 +1333,7 @@ class tools {
|
|
|
if($notifiation_type == "Milestone_Update"){
|
|
|
$eventCard = array("type" =>'milestone',
|
|
|
"numericRecords"=>0,
|
|
|
- "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
|
|
|
+ "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
|
|
|
"title"=>"Milestone Update",
|
|
|
"mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
|
|
|
"no"=>$mInfo["h_bol"],
|
|
|
@@ -1375,7 +1387,7 @@ class tools {
|
|
|
//$ctnrStatusdesc = $this->getContainerStatusDesc($mInfo["ctnr_status_code"]);
|
|
|
$eventCard = array("type" =>'container',
|
|
|
"numericRecords"=>0,
|
|
|
- "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
|
|
|
+ "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
|
|
|
"title"=>"Container_Status_Update",
|
|
|
"mode"=>"Ocean Freight",
|
|
|
"no"=>$mInfo["ctnr"],
|
|
|
@@ -1466,7 +1478,7 @@ class tools {
|
|
|
$delay_unit = $mInfo["delay_unit"];
|
|
|
$eventCard = array("type" =>'delay',
|
|
|
"numericRecords"=>0,
|
|
|
- "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
|
|
|
+ "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
|
|
|
"title"=>$title,
|
|
|
"mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
|
|
|
"no"=>$mInfo["h_bol"],
|
|
|
@@ -1534,7 +1546,7 @@ class tools {
|
|
|
$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,
|
|
|
+ "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
|
|
|
"title"=>$title,
|
|
|
"mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
|
|
|
"no"=>$mInfo["h_bol"],
|
|
|
@@ -1587,7 +1599,7 @@ class tools {
|
|
|
"id"=> $mInfo["id"],
|
|
|
"header"=> $mInfo["other_name"],
|
|
|
"content"=>$mInfo["other_desc"],
|
|
|
- "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
|
|
|
+ "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
|
|
|
"isExpiration"=> $isExpiration,
|
|
|
"rules_type"=>$mInfo["notifiation_type"],
|
|
|
"imgSrc"=>SERVER_PAHT.FILE_UPLOAD_PAHT."feature_update_".$mInfo["id"].".jpg",
|