|
|
@@ -174,7 +174,9 @@ class tools {
|
|
|
if ($operate == "subscribe_notification_init") {
|
|
|
$subscribur_data =array();
|
|
|
//查询用户对应的Rule
|
|
|
- $subscribe_rule_sql = "select * from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."' order by id";
|
|
|
+ $subscribe_rule_sql = "select *,TO_CHAR(daily_time, 'HH24:MI') as _daily_time,
|
|
|
+ TO_CHAR(weekly_time, 'HH24:MI') as _weekly_time
|
|
|
+ from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."' order by id";
|
|
|
$subscribe_rules = common::excuteListSql($subscribe_rule_sql);
|
|
|
$all_rules = array("Milestone_Update","Container_Status_Update","Departure/Arrival_Delay","ETD/ETA_Change");
|
|
|
foreach($all_rules as $rule_name){
|
|
|
@@ -195,7 +197,7 @@ class tools {
|
|
|
$subscribur_data['addedRules'] = array("tableData"=>$addedRules);
|
|
|
|
|
|
//获取subscribe shipment 当前页数cp,每页ps
|
|
|
- $subscribeShipmentWithPage = $this->getSubscribeShipment(1,20);
|
|
|
+ $subscribeShipmentWithPage = $this->getSubscribeShipment(1,15);
|
|
|
$subscribur_data['subscribeShipmentWithPage'] = $subscribeShipmentWithPage;
|
|
|
|
|
|
common::echo_json_encode(200,$subscribur_data);
|
|
|
@@ -245,9 +247,9 @@ class tools {
|
|
|
}
|
|
|
|
|
|
if ($operate == "subscribe_shipment"){
|
|
|
- $serial_no = common::deCode($_GET['serial_no'], 'D');
|
|
|
+ $serial_no = common::deCode($_POST['serial_no'], 'D');
|
|
|
$is_subscribe = common::check_input($_POST['is_subscribe']);
|
|
|
- if($is_subscribe == "yes"){
|
|
|
+ if($is_subscribe == "true"){
|
|
|
$exist = common::excuteOneSql("select user_login from public.kln_user_subscribed where lower(user_login) = '".strtolower(_getLoginName())."' and subscribed_serial_no = '$serial_no'");
|
|
|
if(!empty($exist)){
|
|
|
$data = array("msg" => "Subscribe exist,Please check");
|
|
|
@@ -270,6 +272,14 @@ class tools {
|
|
|
exit();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ($operate == "subscribe_shipment_search"){
|
|
|
+ $cp = common::check_input($_POST ['cp']); //current_page
|
|
|
+ $ps = common::check_input($_POST ['ps']); //ps
|
|
|
+ $arrTmp = $this->getSubscribeShipment($cp,$ps);
|
|
|
+ common::echo_json_encode(200,$arrTmp);
|
|
|
+ exit();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public function user_monitoring_setting(){
|
|
|
@@ -343,6 +353,54 @@ class tools {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function notifications_rules(){
|
|
|
+ $operate = utils::_get('operate');
|
|
|
+ $operate = strtolower($operate);
|
|
|
+
|
|
|
+ if ($operate == "notifications"){
|
|
|
+ $rules_type = common::check_input($_POST ['rules_type']);
|
|
|
+ if ($rules_type == "all"){
|
|
|
+ $sql = "select *,
|
|
|
+ (select o.h_bol from public.kln_ocean o where o.serial_no = ni.serial_no limit 1)
|
|
|
+ from public.kln_notifiation_info ni
|
|
|
+ where lower(ni.user_login) = '"._getLoginName()."'
|
|
|
+ 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 ni.is_send_message = false order by ni.insert_date desc";
|
|
|
+ }else{
|
|
|
+ $sql = "select case when COALESCE(ni.milestone_code,'') <> '' and ni.milestone_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,
|
|
|
+ ni.milestone_code,*
|
|
|
+ (select o.h_bol from public.kln_ocean o where o.serial_no = ni.serial_no limit 1)
|
|
|
+ from public.kln_notifiation_info ni
|
|
|
+ where lower(ni.user_login) = '"._getLoginName()."'
|
|
|
+ and ni.rules_type = '".$rules_type."'
|
|
|
+ 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 ni.is_send_message = false order by ni.insert_date desc";
|
|
|
+ }
|
|
|
+ $notifications = common::excuteListSql($sql);
|
|
|
+
|
|
|
+ $all_rules = array("Milestone_Update","Container_Status_Update","Departure/Arrival_Delay","ETD/ETA_Change");
|
|
|
+
|
|
|
+ foreach($notifications as $notification){
|
|
|
+ if($notification["notifiation_type"] == "Milestone_Update"){
|
|
|
+ if ($notification["frequency_type"] == "Instant"){
|
|
|
+ $milestoneInstantMessage[] = array("mode"=>$notification["milestone_transport_mode"],"HBOL"=>$notification["milestone_transport_mode"],
|
|
|
+ "HBOL"=>$notification["milestone_transport_mode"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 遍历查找对应的rule。
|
|
|
*/
|
|
|
@@ -352,6 +410,9 @@ class tools {
|
|
|
foreach($subscribe_rules as $rules){
|
|
|
if($rules['rules_type'] == $rule_name){
|
|
|
$rules["is_display"] = true;
|
|
|
+ $rules["daily_time"] = $rules["_daily_time"];
|
|
|
+ $rules["weekly_time"] = $rules["_weekly_time"];
|
|
|
+ $rules["weekly_week"] = common::getWeek($rules["weekly_week"]);
|
|
|
$ret = $rules;
|
|
|
}
|
|
|
}
|
|
|
@@ -407,10 +468,15 @@ class tools {
|
|
|
* cp current_page
|
|
|
*/
|
|
|
public function getSubscribeShipment($cp,$ps){
|
|
|
+ if (empty($cp)){
|
|
|
+ $cp = 1;
|
|
|
+ }
|
|
|
if (empty($ps)){
|
|
|
- $ps = 20;
|
|
|
+ $ps = 15;
|
|
|
}
|
|
|
- $sql = "select count(1) from public.kln_user_subscribed where lower(user_login) = '".strtolower(_getLoginName())."'";
|
|
|
+ $sql = "select count(1) from public.kln_user_subscribed u
|
|
|
+ left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
|
|
|
+ where lower(user_login) = '".strtolower(_getLoginName())."'";
|
|
|
$rc = common::excuteOneSql($sql);
|
|
|
$tp = ceil($rc / $ps);
|
|
|
if ($rc > 0) {
|
|
|
@@ -433,7 +499,7 @@ class tools {
|
|
|
where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
|
|
|
else '' end as recent_milestone
|
|
|
from public.kln_user_subscribed u
|
|
|
- left join public.kln_ocean o on o.serial_no in (SELECT regexp_split_to_table(subscribed_serial_no,';'))
|
|
|
+ left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
|
|
|
where lower(user_login) = '".strtolower(_getLoginName())."' order by u.id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
|
|
|
$subscribeShipment = common::excuteListSql($sql);
|
|
|
$arrTmp = array('tableData' => $subscribeShipment,
|
|
|
@@ -754,6 +820,32 @@ class tools {
|
|
|
return $event;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function getNotifications($rules_type){
|
|
|
+
|
|
|
+ //$all_rules = array("Milestone_Update","Container_Status_Update","Departure/Arrival_Delay","ETD/ETA_Change");
|
|
|
+ if($rules_type == "Milestone_Update"){
|
|
|
+ $sql = "select case when COALESCE(ni.milestone_code,'') <> '' and ni.milestone_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,
|
|
|
+ case when ni.milestone_code in ('IFFBCF','IFFBCR','IFFSIL','IFFEDO','IFFECC')
|
|
|
+ then ''
|
|
|
+ when ni.milestone_code in ('IFFREC','IFFECP')
|
|
|
+ then ''
|
|
|
+ ni.milestone_date,ni.milestone_time,
|
|
|
+ (select o.h_bol from public.kln_ocean o where o.serial_no = ni.serial_no limit 1)
|
|
|
+ from public.kln_notifiation_info ni
|
|
|
+ where lower(ni.user_login) = '"._getLoginName()."'
|
|
|
+ and ni.rules_type = '".$rules_type."'
|
|
|
+ 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 ni.is_send_message = false order by ni.insert_date desc";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
?>
|