tools.class.php 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of operation_log
  7. *
  8. * @author Administrator
  9. */
  10. class tools {
  11. private static $_tools;
  12. public static function getInstance() {
  13. if (!self::$_tools) {
  14. $c = __CLASS__;
  15. self::$_tools = new $c;
  16. }
  17. return self::$_tools;
  18. }
  19. /*
  20. * update password when login success
  21. */
  22. public function updatePassword() {
  23. if ($_SESSION['ONLINE_USER']['is_demo'] == "t") {
  24. $str = "DEMO cannot update password.";
  25. } else {
  26. $opsw = common::check_input($_POST ['opsw']);
  27. $npsw = common::check_input($_POST ['npsw']);
  28. $username = _getLoginName();
  29. $msg = common::checkPasswordRule($username, $npsw);
  30. //为空代表验证通过
  31. if (empty($msg)) {
  32. $sql = "select ra_password as password from ra_online_user where lower(user_login) = '" . strtolower($username) . "'";
  33. $rs = common::excuteObjectSql($sql);
  34. $str = '';
  35. if (!empty($rs)) {
  36. if ($rs['password'] == $opsw) {
  37. $sql = "UPDATE ra_online_user SET ra_password = '" . $npsw . "', last_pwd_change = now() WHERE lower(user_login) = '" . strtolower($username) . "'";
  38. $rls = common::excuteUpdateSql($sql);
  39. if (!$rls) {
  40. $str = "Password modification failed!";
  41. } else {
  42. $str = " Your password has been modified!";
  43. }
  44. } else {
  45. $str = "Old password is incorrect!";
  46. }
  47. } else {
  48. $str = "Old password is incorrect!";
  49. }
  50. } else {
  51. $str = $msg;
  52. }
  53. }
  54. $returnData = array("msg" => $str);
  55. common::echo_json_encode(200, $returnData);
  56. exit();
  57. }
  58. public function markSystem(){
  59. $operate = utils::_get('operate');
  60. $operate = strtolower($operate);
  61. if ($operate == "mark_save") {
  62. $suggestion = utils::implode(",",$_POST['suggestion']);
  63. $proposal = common::check_input($_POST['proposal']);
  64. $expression = common::check_input($_POST['expression']);
  65. $complete_funtionality = common::check_input($_POST['Complete_funtionality']);
  66. $accurate_data = common::check_input($_POST['Accurate_data']);
  67. $clear_information = common::check_input($_POST['Clear_information']);
  68. $easy_to_use = common::check_input($_POST['Easy_to_use']);
  69. $system_Performance = common::check_input($_POST['System_Performance']);
  70. $username = common::check_input($_POST['username']);
  71. $user_type = _isApexLogin() ? "employee" : "customer";
  72. if(!isset($_SESSION['ONLINE_USER'])){
  73. $user_type = "other";
  74. }
  75. $loginName = _getLoginName();
  76. $loginEamil = _getLoginEamil();
  77. //如果在没有登录前,没有登录信息,指定用户-- 这里逻辑取消,没有登录相当于匿名用户的评价,无法获取用户名
  78. // if(!isset($_SESSION['ONLINE_USER'])){
  79. // $user_type = "Customer";
  80. // if(!empty($username)){
  81. // $loginName = $username;
  82. // $loginEamil = common::excuteOneSql("select email from public.ra_online_user u where lower(user_login) = '" . strtolower($username) . "'");
  83. // }
  84. // }
  85. $sql = "INSERT INTO public.customer_service_user_mark(user_type, user_name, suggestion, proposal, expression, complete_funtionality,
  86. accurate_data, clear_information, easy_to_use, system_performance,
  87. created_time,email)
  88. VALUES ('$user_type', '$loginName', '$suggestion', '$proposal', '$expression', '$complete_funtionality',
  89. '$accurate_data', '$clear_information', '$easy_to_use', '$system_Performance', now(),'$loginEamil')";
  90. common::excuteUpdateSql($sql);
  91. $data = array("msg" =>"success");
  92. common::echo_json_encode(200,$data);
  93. exit();
  94. }
  95. }
  96. public function user_system_setting(){
  97. $operate = utils::_get('operate');
  98. $operate = strtolower($operate);
  99. if ($operate == "personal_profile_init") {
  100. // get system config
  101. $sql = "SELECT lower(ra_name) as ra_name, ra_value from ra_online_config where lower(ra_name) in ('employee_password_change_cycle', 'customer_password_change_cycle')";
  102. $rs1s = common::excuteListSql($sql);
  103. foreach ($rs1s as $rs1) {
  104. if ($rs1['ra_name'] == 'employee_password_change_cycle')
  105. $EMPLOYEE_PASSWORD_CHANGE_CYCLE = $rs1['ra_value'];
  106. if ($rs1['ra_name'] == 'customer_password_change_cycle')
  107. $CUSTOMER_PASSWORD_CHANGE_CYCLE = $rs1['ra_value'];
  108. }
  109. $sql="select item_value from config where item='passwordChangePeriod'";
  110. $pcp = common::excuteObjectSql($sql);
  111. $passwordChangePeriod = json_decode($pcp["item_value"],true);
  112. if (_isApexLogin()) {
  113. $PASSWORD_CHANGE_CYCLE = $EMPLOYEE_PASSWORD_CHANGE_CYCLE;
  114. //如果有新配置,则采用新配置
  115. if (!empty($pcp)) {
  116. $PASSWORD_CHANGE_CYCLE = $passwordChangePeriod["Employee"]["days"];
  117. }
  118. } else {
  119. $PASSWORD_CHANGE_CYCLE = $CUSTOMER_PASSWORD_CHANGE_CYCLE;
  120. //如果有新配置,则采用新配置
  121. if (!empty($pcp)) {
  122. $PASSWORD_CHANGE_CYCLE = $passwordChangePeriod["Customer"]["days"];
  123. }
  124. }
  125. $sql = "select u.first_name,u.last_name,u.user_login,u.email,EXTRACT(DAY from (now() - u.last_pwd_change)) as last_pwd_change_date,
  126. ue.date_format,ue.numbers_format
  127. from public.ra_online_user u
  128. left join public.kln_user_extend ue on u.user_login = ue.user_login
  129. where lower(u.user_login) = '".strtolower(_getLoginName())."' ";
  130. $data = common::excuteObjectSql($sql);
  131. $data["expire_day"] = $PASSWORD_CHANGE_CYCLE - $data['last_pwd_change_date'];
  132. common::echo_json_encode(200,$data);
  133. exit();
  134. }
  135. if ($operate == "personal_profile_save") {
  136. $save_model = common::check_input($_POST['save_model']);
  137. if ($save_model == "profile"){
  138. $first_name = common::check_input($_POST['first_name']);
  139. $last_name = common::check_input($_POST['last_name']);
  140. $sql = "update public.ra_online_user set first_name = '$first_name',last_name = '$last_name' where lower(user_login) = '".strtolower(_getLoginName())."'";
  141. }else{
  142. $date_format = common::check_input($_REQUEST['date_format']);
  143. $numbers_format = common::check_input($_REQUEST['numbers_format']);
  144. $exist_kln_user = common::excuteObjectSql("select user_login from public.kln_user_extend where lower(user_login) = '".strtolower(_getLoginName())."'");
  145. if (!empty($exist_kln_user['user_login'])){
  146. $sql = "update public.kln_user_extend set date_format = '$date_format',numbers_format = '$numbers_format' where lower(user_login) = '".strtolower(_getLoginName())."'";
  147. } else {
  148. $sql = "INSERT INTO public.kln_user_extend(user_login, date_format, numbers_format, subscribe_hbol)
  149. VALUES ('"._getLoginName()."', '$date_format', '$numbers_format', null);";
  150. }
  151. }
  152. common::excuteUpdateSql($sql);
  153. $data = array("msg" => "save Successful");
  154. common::echo_json_encode(200,$data);
  155. exit();
  156. }
  157. if ($operate == "subscribe_notification_init") {
  158. $subscribur_data =array();
  159. //查询用户对应的Rule
  160. $subscribe_rule_sql = "select *,TO_CHAR(daily_time, 'HH24:MI') as _daily_time,
  161. TO_CHAR(weekly_time, 'HH24:MI') as _weekly_time
  162. from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."' order by id";
  163. $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
  164. $all_rules = array("Milestone_Update","Container_Status_Update","Departure/Arrival_Delay","ETD/ETA_Change");
  165. foreach($all_rules as $rule_name){
  166. $rules = $this->getSubscribeRules($rule_name,$subscribe_rules);
  167. $subscribur_data[$rule_name] = $rules;
  168. }
  169. //整合拼接addedRules
  170. $addedRules = array();
  171. foreach($subscribe_rules as $addedRule){
  172. $addedRules[] = array(
  173. "visible" => false,
  174. "id" =>$addedRule['id'],
  175. "Event" =>$addedRule['rules_type'],
  176. "Event Details" =>$addedRule['event_details'],
  177. "Frequency" =>$addedRule['frequency_display'],
  178. "Methods" =>$addedRule['method_display']);
  179. }
  180. $subscribur_data['addedRules'] = array("tableData"=>$addedRules);
  181. //获取subscribe shipment 当前页数cp,每页ps
  182. $subscribeShipmentWithPage = $this->getSubscribeShipment(1,15);
  183. $subscribur_data['subscribeShipmentWithPage'] = $subscribeShipmentWithPage;
  184. common::echo_json_encode(200,$subscribur_data);
  185. exit();
  186. }
  187. if ($operate == "subscribe_notification_event_update"){
  188. $rules_type = common::check_input($_POST["rules_type"]);
  189. //判断该规则是否存在
  190. $exist = common::excuteObjectSql("select user_login,id from public.notifications_rules where notifications_type = 'Subscribe' and rules_type = '".$rules_type."'
  191. and lower(user_login) = '".strtolower(_getLoginName())."'");
  192. $updateOrInsert = empty($exist) ? "insert" : "update";
  193. $sql = $this->getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,"Subscribe",$exist['id']);
  194. $rs = common::excuteUpdateSql($sql);
  195. if ($rs === FALSE){
  196. $data = array("msg" => "Update Error");
  197. } else{
  198. $data = array("msg" => "Update Successful");
  199. //返回addedRules 全部列表
  200. $subscribe_rule_sql = "select * from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."' order by id";
  201. $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
  202. //整合拼接addedRules
  203. $addedRules = array();
  204. foreach($subscribe_rules as $addedRule){
  205. $addedRules[] = array(
  206. "id" =>$addedRule['id'],
  207. "Event" =>$addedRule['rules_type'],
  208. "Event Details" =>$addedRule['event_details'],
  209. "Frequency" =>$addedRule['frequency_display'],
  210. "Methods" =>$addedRule['method_display']);
  211. }
  212. $data['addedRules'] = array("tableData"=>$addedRules);
  213. }
  214. common::echo_json_encode(200,$data);
  215. exit();
  216. }
  217. if ($operate == "subscribe_notification_rules_delete"){
  218. $rules_type = common::check_input($_POST['rules_type']);
  219. $sql = "delete from notifications_rules where notifications_type = 'Subscribe'
  220. and rules_type = '$rules_type' and lower(user_login) = '".strtolower(_getLoginName())."'";
  221. common::excuteUpdateSql($sql);
  222. $data = array("msg" => "Delete Successful");
  223. common::echo_json_encode(200,$data);
  224. exit();
  225. }
  226. if ($operate == "subscribe_shipment"){
  227. $serial_no = common::deCode($_POST['serial_no'], 'D');
  228. $is_subscribe = common::check_input($_POST['is_subscribe']);
  229. if($is_subscribe == "true"){
  230. $exist = common::excuteOneSql("select user_login from public.kln_user_subscribed where lower(user_login) = '".strtolower(_getLoginName())."' and subscribed_serial_no = '$serial_no'");
  231. if(!empty($exist)){
  232. $data = array("msg" => "Subscribe exist,Please check");
  233. common::echo_json_encode(200,$data);
  234. exit();
  235. }
  236. $sql = "INSERT INTO public.kln_user_subscribed(user_login, subscribed_serial_no, create_user, create_time)
  237. VALUES ('"._getLoginName()."', '$serial_no', '"._getLoginName()."', now());";
  238. common::excuteUpdateSql($sql);
  239. $data = array("msg" => "Subscribe Successful");
  240. common::echo_json_encode(200,$data);
  241. exit();
  242. }else{
  243. //取消订阅
  244. $sql = "delete from public.kln_user_subscribed where lower(user_login) = '".strtolower(_getLoginName())."' and subscribed_serial_no = '$serial_no';";
  245. common::excuteUpdateSql($sql);
  246. $data = array("msg" => "Cancel Subscribe successfully");
  247. common::echo_json_encode(200,$data);
  248. exit();
  249. }
  250. }
  251. if ($operate == "subscribe_shipment_search"){
  252. $cp = common::check_input($_POST ['cp']); //current_page
  253. $ps = common::check_input($_POST ['ps']); //ps
  254. $arrTmp = $this->getSubscribeShipment($cp,$ps);
  255. common::echo_json_encode(200,$arrTmp);
  256. exit();
  257. }
  258. }
  259. public function user_monitoring_setting(){
  260. $operate = utils::_get('operate');
  261. $operate = strtolower($operate);
  262. if ($operate == "monitoring_rules_init"){
  263. $ret = array();
  264. //Milestone Update的页面配置数据
  265. $milestones = common::excuteListSql("select * from public.customer_service_milestone_sno order by type, sno");
  266. $oceanMilestone = array();
  267. $airMilestone = array();
  268. foreach($milestones as $milestone){
  269. if($milestone['type'] == "air"){
  270. $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  271. }
  272. if($milestone['type'] == "sea"){
  273. $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  274. }
  275. }
  276. $ret["OceanCheckBoxList"] = $oceanMilestone;
  277. $ret["AirCheckBoxList"] = $airMilestone;
  278. //Milestone Update的结构处理
  279. //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  280. //$event =common::getEDICtnrEvent();
  281. $event = common::excuteListSql("select ra_name as event_name,ra_order,description
  282. from public.ra_online_edi_event e
  283. where e.ra_name in('I','VD','VA','UV','AL','AR','OA','RD') order by e.ra_order desc");
  284. $ctnrStatus = array();
  285. foreach($event as $e){
  286. $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
  287. }
  288. $ret["CtnrCheckBoxList"] = $ctnrStatus;
  289. common::echo_json_encode(200,$ret);
  290. exit();
  291. }
  292. if ($operate == "monitoring_rules_search") {
  293. $cp = common::check_input($_POST ['cp']); //current_page
  294. $ps = common::check_input($_POST ['ps']); //ps
  295. if (empty($ps))
  296. $ps = 15;
  297. $sql = "select count(1) from public.notifications_rules where lower(user_login) = '".strtolower(_getLoginName())."' and notifications_type = 'Monitoring'";
  298. $rc = common::excuteOneSql($sql);
  299. $tp = ceil($rc / $ps);
  300. if ($rc > 0) {
  301. $sql = "select *,replace(rules_type, '_', ' ') AS _rules_type_display,
  302. case when rules_type = 'Milestone_Update' then 'Milestone'
  303. when rules_type = 'Container_Status_Update' then 'Container'
  304. when rules_type = 'Departure/Arrival_Delay' then 'Departure'
  305. when rules_type = 'ETD/ETA_Change' then 'ETDChange'
  306. else '' end as notifications_option
  307. from public.notifications_rules
  308. where lower(user_login) = '".strtolower(_getLoginName())."'
  309. and notifications_type = 'Monitoring' order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  310. $monitoringRules = common::excuteListSql($sql);
  311. $arrTmp = array('monitoringRules' => $monitoringRules,
  312. 'rc' => intval($rc),
  313. 'ps' => intval($ps),
  314. 'cp' => intval($cp),
  315. 'tp' => intval($tp)
  316. );
  317. } else {
  318. $arrTmp = array('searchData' => array(),
  319. 'rc' => intval($rc),
  320. 'ps' => intval($ps),
  321. 'cp' => intval($cp),
  322. 'tp' => intval($tp)
  323. );
  324. }
  325. common::echo_json_encode(200,$arrTmp);
  326. exit();
  327. }
  328. if ($operate == "monitoring_rules_edit"){
  329. $id = $_POST['id'];
  330. $rules_type = common::check_input($_POST['rules_type']);
  331. $subscribe_rule_sql = "select *,
  332. TO_CHAR(daily_time, 'HH24:MI') as _daily_time,
  333. TO_CHAR(weekly_time, 'HH24:MI') as _weekly_time,
  334. case when rules_type = 'Milestone_Update' then 'Milestone'
  335. when rules_type = 'Container_Status_Update' then 'Container'
  336. when rules_type = 'Departure/Arrival_Delay' then 'Departure'
  337. when rules_type = 'ETD/ETA_Change' then 'ETDChange'
  338. else '' end as notifications_option
  339. from public.notifications_rules where notifications_type = 'Monitoring' and lower(user_login) = '".strtolower(_getLoginName())."'
  340. and id = '$id' order by id";
  341. $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
  342. $rules = $this->getSubscribeRules($rules_type,$subscribe_rules);
  343. //数据转换前端需要的显示的格式
  344. $rules["shipment_transport_mode"] = utils::converModeToDisplay($rules["shipment_transport_mode"]);
  345. $monitoring_data[$rules_type] = $rules;
  346. common::echo_json_encode(200,$monitoring_data);
  347. exit();
  348. }
  349. if ($operate == "monitoring_rules_do") {
  350. $rules_type = common::check_input($_POST["rules_type"]);
  351. //检查编辑提交的Monitoring规则,是否允许保存
  352. $msg = $this->checkedMonitoringRulesSave($rules_type);
  353. if(!empty($msg)){
  354. $data = array("msg" =>$msg);
  355. common::echo_json_encode(200,$data);
  356. exit();
  357. }
  358. $updateOrInsert = "insert";
  359. if(isset($_POST['id']) && !empty($_POST['id'])){
  360. $updateOrInsert = "update";
  361. }
  362. $sql = $this->getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,"Monitoring",$_POST['id']);
  363. $rs = common::excuteUpdateSql($sql);
  364. if ($rs === FALSE){
  365. $data = array("msg" => "Update Error");
  366. } else{
  367. $data = array("msg" => "Update Successful");
  368. }
  369. common::echo_json_encode(200,$data);
  370. exit();
  371. }
  372. if ($operate == "monitoring_rules_delete"){
  373. $id = common::check_input($_POST['id']);
  374. $sql = "delete from notifications_rules where notifications_type = 'Monitoring'
  375. and lower(user_login) = '".strtolower(_getLoginName())."' and id = '$id'";
  376. common::excuteUpdateSql($sql);
  377. $data = array("msg" => "Delete Successful");
  378. common::echo_json_encode(200,$data);
  379. exit();
  380. }
  381. }
  382. public function notifications_rules(){
  383. $operate = utils::_get('operate');
  384. $operate = strtolower($operate);
  385. if ($operate == "notifications_init"){
  386. $rules_type = common::check_input($_REQUEST['rules_type']);
  387. $milestoneData = array();
  388. $containerData = array();
  389. $delayData = array();
  390. $changeData = array();
  391. if ($rules_type == "all"){
  392. $rules_type = "Milestone_Update;Container_Status_Update;Departure/Arrival_Delay;ETD/ETA_Change";
  393. $allData = $this->getNotifications($rules_type,"all");
  394. $milestoneData = $allData['Milestone_Update'];
  395. $containerData = $allData['Container_Status_Update'];
  396. $delayData = $allData['Departure/Arrival_Delay'];
  397. $changeData = $allData['ETD/ETA_Change'];
  398. } else {
  399. $data = $this->getNotifications($rules_type,"all");
  400. if($rules_type == "Milestone_Update"){
  401. $milestoneData = $data['Milestone_Update'];
  402. }elseif($rules_type == "Container_Status_Update"){
  403. $containerData = $data['Container_Status_Update'];
  404. }elseif($rules_type == "Departure/Arrival_Delay"){
  405. $delayData = $data['Departure/Arrival_Delay'];
  406. }elseif($rules_type == "ETD/ETA_Change"){
  407. $changeData = $data['ETD/ETA_Change'];
  408. }
  409. }
  410. $data = array("milestoneData"=>$milestoneData,"containerData"=>$containerData,"delayData"=>$delayData,"changeData"=>$changeData);
  411. $instant_sum = array();
  412. foreach($data as $v){
  413. if(!empty($v['instant'])){
  414. foreach($v['instant'] as $instant){
  415. $instant_sum[] = $instant;
  416. }
  417. }
  418. if(!empty($v['daily'])){
  419. $dailys = common::handleDailyWeekedData($v['daily']);
  420. foreach($dailys as $dailyArr){
  421. //取第一组的第一个显示
  422. $dailyFristAndFrist = utils::getDailyAndweeklyFrist($dailyArr);
  423. $instant_sum[]= $dailyFristAndFrist;
  424. }
  425. }
  426. if(!empty($v['weekly'])){
  427. $weeklys = common::handleDailyWeekedData($v['weekly']);
  428. foreach($weeklys as $weeklyArr){
  429. $weeklyFristAndFrist = utils::getDailyAndweeklyFrist($weeklyArr);
  430. $instant_sum[]= $weeklyFristAndFrist;
  431. }
  432. }
  433. }
  434. //根据时间顺序排序
  435. $insert_dates = array_column($instant_sum, 'insert_date');
  436. array_multisort($insert_dates, SORT_ASC, $instant_sum);
  437. $info = array();
  438. foreach($instant_sum as $mInfo){
  439. $eventCard = $this->getEventCard($mInfo);
  440. $info[] = array("notificationType"=>"event","info" =>$eventCard);
  441. }
  442. $returnData = $info;
  443. common::echo_json_encode(200,$returnData);
  444. exit();
  445. }
  446. if($operate == "notifications_see_all"){
  447. $rules_type = common::check_input($_REQUEST['rules_type']);
  448. $frequency_type = common::check_input($_REQUEST['frequency_type']); //这个只会传daily 和weekly
  449. $insert_date_format = common::check_input($_REQUEST['insert_date_format']);
  450. $notificationsData = $this->getNotifications($rules_type,$frequency_type,$insert_date_format);
  451. $moreData = $notificationsData[$rules_type][strtolower($frequency_type)];
  452. //这个函数里面带有分开计数的信息
  453. $dataInfo =utils::getDailyAndweeklyFrist($moreData);
  454. $returnData = array();
  455. $notificationList = array();
  456. $ids = array();
  457. foreach($moreData as $key => $data){
  458. $eventCard = $this->getEventCard($data);
  459. //sea all的数据格式和查询全部的格式有区别
  460. if($key == 0){
  461. $returnData["title"] = $eventCard["title"];
  462. if($eventCard["type"] == "change" || $eventCard["type"] == "delay"){
  463. $returnData["numericRecords_one"] = $dataInfo["numericRecords_one"];
  464. $returnData["numericRecords_two"] =$dataInfo["numericRecords_two"];
  465. }else{
  466. $returnData["numericRecords"] = $dataInfo["numericRecords"];
  467. }
  468. }
  469. //移除不需要的字段
  470. unset($eventCard["title"]);
  471. $notificationList[] = $eventCard;
  472. $ids[] = $data['id'];
  473. }
  474. if(!empty($notificationList)){
  475. $returnData["notificationList"] = $notificationList;
  476. }
  477. //点击seall会默认全部标记为已读
  478. if(!empty($ids)){
  479. $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$ids)));
  480. $markReadSql = "update public.kln_notifiation_info set is_send_message = true where id in ($more_param)";
  481. //common::excuteUpdateSql($markReadSql);
  482. }
  483. common::echo_json_encode(200,$returnData);
  484. exit();
  485. }
  486. if($operate == "notifications_read"){
  487. $read_type = common::check_input($_POST["read_type"]);
  488. $id = $_POST["id"];
  489. //代表改用户下的所有信息全部标记为已读
  490. if ($read_type == "true"){
  491. $rs = common::excuteUpdateSql("update public.kln_notifiation_info set is_send_message = true where lower(user_login) = '".strtolower(_getLoginName())."'");
  492. }else{
  493. $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$id)));
  494. $markReadSql = "update public.kln_notifiation_info set is_send_message = true where id in ($more_param)";
  495. $rs = common::excuteUpdateSql($markReadSql);
  496. }
  497. if ($rs === FALSE){
  498. $returnData = array("msg" =>"Error");
  499. common::echo_json_encode(500,$returnData);
  500. }else{
  501. $returnData = array("msg" =>"Success");
  502. common::echo_json_encode(200,$returnData);
  503. }
  504. exit();
  505. }
  506. if ($operate == "notifications_message_init"){
  507. $rules_type = common::check_input($_REQUEST['rules_type']);
  508. //查询所有情况得未读情况 查询最近一年的情况
  509. "with dt as(select from public.kln_notifiation_info
  510. where insert_date > NOW() - INTERVAL '1 year'
  511. and notifications_method = 'true' and is_send_message = 'false'
  512. and lower(ni.user_login) = '".strtolower(_getLoginName())."'
  513. and frequency_type = 'Daily' group by to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY'))";
  514. "select
  515. sum(case when (1<>1 or (notifiation_type='Milestone_Update') then 1 else 0 end) as m_rc,
  516. sum(case when (1<>1 or (notifiation_type='Container_Status_Update')) then 1 else 0 end) as cs_rc,
  517. sum(case when (1<>1 or (notifiation_type='Departure/Arrival_Delay')) then 1 else 0 end) as da_rc,
  518. sum(case when (1<>1 or (notifiation_type='ETD/ETA_Change')) then 1 else 0 end) as ec_rc,
  519. sum(case when (1<>1 or (notifiation_type='Feature_Update')) then 1 else 0 end) as f_rc,
  520. from public.kln_notifiation_info
  521. where insert_date > NOW() - INTERVAL '1 year'
  522. and frequency_type = 'Instant'
  523. and notifications_method = 'true' and is_send_message = 'false'
  524. and lower(ni.user_login) = '".strtolower(_getLoginName())."'";
  525. }
  526. }
  527. /**
  528. * 遍历查找对应的rule。
  529. */
  530. public function getSubscribeRules($rule_name,$subscribe_rules){
  531. //初始是不显示,没有值的情况
  532. $ret = array("is_display" => false);
  533. foreach($subscribe_rules as $rules){
  534. if($rules['rules_type'] == $rule_name){
  535. $rules["is_display"] = true;
  536. $rules["daily_time"] = $rules["_daily_time"];
  537. $rules["weekly_time"] = $rules["_weekly_time"];
  538. $rules["weekly_week"] = common::getWeek($rules["weekly_week"]);
  539. $ret = $rules;
  540. }
  541. }
  542. //Milestone Update的结构处理,处理init page load
  543. if($rule_name == "Milestone_Update"){
  544. //Milestone Update的页面配置数据
  545. $milestones = common::excuteListSql("select * from public.customer_service_milestone_sno order by type, sno");
  546. $oceanMilestone = array();
  547. $airMilestone = array();
  548. foreach($milestones as $milestone){
  549. if($milestone['type'] == "air"){
  550. $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  551. }
  552. if($milestone['type'] == "sea"){
  553. $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  554. }
  555. }
  556. $ret["OceanCheckBoxList"] = $oceanMilestone;
  557. $ret["AirCheckBoxList"] = $airMilestone;
  558. $oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
  559. $airMilestoneSetting = !empty($ret['air_milestone']) ? explode(";",$ret['air_milestone']): array();
  560. $ret["OceanCheckedList"] = $oceanMilestoneSetting;
  561. $ret["AirCheckedList"] = $airMilestoneSetting;
  562. }
  563. //Milestone Update的结构处理
  564. if($rule_name == "Container_Status_Update"){
  565. //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  566. //$event =common::getEDICtnrEvent();
  567. $event = common::excuteListSql("select ra_name as event_name,ra_order,description
  568. from public.ra_online_edi_event e
  569. where e.ra_name in('I','VD','VA','UV','AL','AR','OA','RD') order by e.ra_order desc");
  570. $ctnrStatus = array();
  571. foreach($event as $e){
  572. $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
  573. }
  574. $ret["CtnrCheckBoxList"] = $ctnrStatus;
  575. $ctnrStatusSetting = !empty($ret['ocean_ctnr_status']) ? explode(";",$ret['ocean_ctnr_status']) : array();
  576. $ret["CtnrCheckedList"] = $ctnrStatusSetting;
  577. }
  578. return $ret;
  579. }
  580. /**
  581. * 查询对应用户订阅的shipment信息.可能存在分页查询,如果有需要就改正
  582. * cp current_page
  583. */
  584. public function getSubscribeShipment($cp,$ps){
  585. if (empty($cp)){
  586. $cp = 1;
  587. }
  588. if (empty($ps)){
  589. $ps = 15;
  590. }
  591. $sql = "select count(1) from public.kln_user_subscribed u
  592. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  593. where lower(user_login) = '".strtolower(_getLoginName())."'";
  594. $rc = common::excuteOneSql($sql);
  595. $tp = ceil($rc / $ps);
  596. if ($rc > 0) {
  597. $sql = "select o.h_bol,
  598. o.shipper,o.consignee,o.etd,o.eta,
  599. case when transport_mode = 'sea'
  600. then (select sn.description
  601. from public.ocean_milestone a
  602. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'sea'
  603. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  604. when transport_mode = 'air' and order_from = 'public'
  605. then (select sn.description
  606. from public.air_milestone a
  607. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  608. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  609. when transport_mode = 'air' and order_from = 'sfs'
  610. then (select sn.description
  611. from sfs.air_milestone a
  612. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  613. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  614. else '' end as recent_milestone
  615. from public.kln_user_subscribed u
  616. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  617. where lower(user_login) = '".strtolower(_getLoginName())."' order by u.id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  618. $subscribeShipment = common::excuteListSql($sql);
  619. $arrTmp = array('tableData' => $subscribeShipment,
  620. 'rc' => intval($rc),
  621. 'ps' => $ps,
  622. 'cp' => $cp,
  623. 'tp' => $tp
  624. );
  625. } else {
  626. $arrTmp = array('tableData' => array(),
  627. 'rc' => $rc,
  628. 'ps' => $ps,
  629. 'cp' => $cp,
  630. 'tp' => $tp,
  631. );
  632. }
  633. return $arrTmp;
  634. }
  635. public function getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,$notifications_type,$id){
  636. $sql = "";
  637. //先删后加
  638. if($updateOrInsert == "update"){
  639. $sql.="delete from public.notifications_rules where rules_type = '$rules_type'
  640. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  641. and id = '$id';";
  642. }
  643. //这个几个参数是所有规则都有的参数
  644. $frequency_type = common::check_input($_POST['frequency_type']);
  645. $daily_time = "null";
  646. $daily_time_zone = "";
  647. $weekly_week = "";
  648. $weekly_time = "null";
  649. $weekly_time_zone = "";
  650. if(strtolower($frequency_type) == "daily"){
  651. $daily_time = "'".common::check_input($_POST['daily_time'])."'";
  652. $daily_time_zone = common::check_input($_POST['daily_time_zone']);
  653. } elseif (strtolower($frequency_type) == "weekly"){
  654. $weekly_week = common::check_input($_POST['weekly_week']);
  655. $weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
  656. $weekly_time_zone = common::check_input($_POST['weekly_time_zone']);
  657. }
  658. $method_by_email = !empty($_POST['method_by_email']) ? common::check_input($_POST['method_by_email']) : 'false';
  659. $method_by_message = !empty($_POST['method_by_message']) ? common::check_input($_POST['method_by_message']) : 'false';
  660. $event_details = common::check_input($_POST['event_details']);
  661. $frequency_display = common::check_input($_POST['frequency_display']);
  662. $method_display = common::check_input($_POST['method_display']);
  663. $shipment_detail = common::check_input($_POST['shipment_details']);
  664. //当规则是 Monitoring类型是,需要配置的range
  665. $shipment_transport_mode = "";
  666. $shipment_etd_limit = "";
  667. $shipment_eta_limit = "";
  668. if($notifications_type == "Monitoring"){
  669. $shipment_transport_mode = utils::converModeToDB($_POST['shipment_transport_mode']);
  670. $shipment_etd_limit = common::check_input($_POST['shipment_etd_limit']);
  671. $shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
  672. }
  673. if ($rules_type == "Milestone_Update"){
  674. $ocean_milestone = utils::implode(";",$_POST['ocean_milestone']);
  675. $air_milestone = utils::implode(";",$_POST['air_milestone']);
  676. $sql.="INSERT INTO public.notifications_rules(
  677. user_login, notifications_type, rules_type, ocean_milestone,
  678. air_milestone, frequency_type, daily_time, daily_time_zone,
  679. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  680. event_details, frequency_display, method_display,shipment_details,
  681. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  682. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_milestone',
  683. '$air_milestone', '$frequency_type', $daily_time, '$daily_time_zone',
  684. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  685. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  686. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  687. }
  688. if ($rules_type == "Container_Status_Update"){
  689. $ocean_ctnr_status = utils::implode(";",$_POST['ocean_ctnr_status']);
  690. $sql.="INSERT INTO public.notifications_rules(
  691. user_login, notifications_type, rules_type, ocean_ctnr_status,
  692. frequency_type, daily_time, daily_time_zone,
  693. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  694. event_details, frequency_display, method_display,shipment_details,
  695. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  696. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_ctnr_status',
  697. '$frequency_type', $daily_time, '$daily_time_zone',
  698. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  699. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  700. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  701. }
  702. if ($rules_type == "Departure/Arrival_Delay"){
  703. $ocean_atd_sub_etd = common::check_input($_POST['ocean_atd_sub_etd']);
  704. $ocean_atd_sub_etd_unit = common::check_input($_POST['ocean_atd_sub_etd_unit']);
  705. if(!empty($ocean_atd_sub_etd_unit)){
  706. $ocean_atd_sub_etd_unit = $ocean_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  707. }
  708. $ocean_ata_sub_eta = common::check_input($_POST['ocean_ata_sub_eta']);
  709. $ocean_ata_sub_eta_unit = common::check_input($_POST['ocean_ata_sub_eta_unit']);
  710. if(!empty($ocean_ata_sub_eta_unit)){
  711. $ocean_ata_sub_eta_unit = $ocean_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  712. }
  713. $air_atd_sub_etd = common::check_input($_POST['air_atd_sub_etd']);
  714. $air_atd_sub_etd_unit = common::check_input($_POST['air_atd_sub_etd_unit']);
  715. if(!empty($air_atd_sub_etd_unit)){
  716. $air_atd_sub_etd_unit = $air_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  717. }
  718. $air_ata_sub_eta = common::check_input($_POST['air_ata_sub_eta']);
  719. $air_ata_sub_eta_unit = common::check_input($_POST['air_ata_sub_eta_unit']);
  720. if(!empty($air_ata_sub_eta_unit)){
  721. $air_ata_sub_eta_unit = $air_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  722. }
  723. $sql.="INSERT INTO public.notifications_rules(
  724. user_login, notifications_type, rules_type,
  725. ocean_atd_sub_etd, ocean_atd_sub_etd_unit,ocean_ata_sub_eta,ocean_ata_sub_eta_unit,
  726. air_atd_sub_etd, air_atd_sub_etd_unit,air_ata_sub_eta,air_ata_sub_eta_unit,
  727. frequency_type, daily_time, daily_time_zone,
  728. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  729. event_details, frequency_display, method_display,shipment_details,
  730. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  731. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type',
  732. '$ocean_atd_sub_etd','$ocean_atd_sub_etd_unit','$ocean_ata_sub_eta','$ocean_ata_sub_eta_unit',
  733. '$air_atd_sub_etd','$air_atd_sub_etd_unit','$air_ata_sub_eta','$air_ata_sub_eta_unit',
  734. '$frequency_type', $daily_time, '$daily_time_zone',
  735. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  736. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  737. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  738. }
  739. if ($rules_type == "ETD/ETA_Change"){
  740. $ocean_etd_change = !empty($_POST['ocean_etd_change']) ? common::check_input($_POST['ocean_etd_change']) : 'false';
  741. $ocean_etd_old_sub_new = common::check_input($_POST['ocean_etd_old_sub_new']);
  742. $ocean_etd_old_sub_new_unit = common::check_input($_POST['ocean_etd_old_sub_new_unit']);
  743. if(!empty($ocean_etd_old_sub_new_unit)){
  744. $ocean_etd_old_sub_new_unit = $ocean_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  745. }
  746. $ocean_eta_change = !empty($_POST['ocean_eta_change']) ? common::check_input($_POST['ocean_eta_change']) : 'false';
  747. $ocean_eta_old_sub_new = common::check_input($_POST['ocean_eta_old_sub_new']);
  748. $ocean_eta_old_sub_new_unit = common::check_input($_POST['ocean_eta_old_sub_new_unit']);
  749. if(!empty($ocean_eta_old_sub_new_unit)){
  750. $ocean_eta_old_sub_new_unit = $ocean_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  751. }
  752. $air_etd_change = !empty($_POST['air_etd_change']) ? common::check_input($_POST['air_etd_change']) : 'false';
  753. $air_etd_old_sub_new = common::check_input($_POST['air_etd_old_sub_new']);
  754. $air_etd_old_sub_new_unit = common::check_input($_POST['air_etd_old_sub_new_unit']);
  755. if(!empty($air_etd_old_sub_new_unit)){
  756. $air_etd_old_sub_new_unit = $air_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  757. }
  758. $air_eta_change = !empty($_POST['air_eta_change']) ? common::check_input($_POST['air_eta_change']): 'false';
  759. $air_eta_old_sub_new = common::check_input($_POST['air_eta_old_sub_new']);
  760. $air_eta_old_sub_new_unit = common::check_input($_POST['air_eta_old_sub_new_unit']);
  761. if(!empty($air_eta_old_sub_new_unit)){
  762. $air_eta_old_sub_new_unit = $air_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  763. }
  764. $sql.="INSERT INTO public.notifications_rules(
  765. user_login, notifications_type, rules_type,
  766. 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,
  767. 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,
  768. frequency_type, daily_time, daily_time_zone,
  769. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  770. event_details, frequency_display, method_display,shipment_details,
  771. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  772. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type',
  773. '$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',
  774. '$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',
  775. '$frequency_type', $daily_time, '$daily_time_zone',
  776. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  777. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  778. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  779. }
  780. return $sql;
  781. }
  782. /**
  783. * 检查编辑提交的Monitoring规则,是否允许保存
  784. */
  785. public function checkedMonitoringRulesSave($rules_type){
  786. $sql_where = "";
  787. if(isset($_POST['id']) && !empty($_POST['id'])){
  788. $sql_where = " and id <> '".common::check_input($_POST['id'])."'";
  789. }
  790. $rules = common::excuteListSql("select * from public.notifications_rules where notifications_type = 'Monitoring' and rules_type = '".$rules_type."'
  791. and lower(user_login) = '".strtolower(_getLoginName())."' $sql_where");
  792. foreach($rules as $rule){
  793. //判断range 是否一样
  794. $checkRangeFiled = array("shipment_transport_mode","shipment_etd_limit","shipment_eta_limit");
  795. $range_flag = true;
  796. foreach($checkRangeFiled as $filed){
  797. if($filed == "shipment_transport_mode"){
  798. $postValue = utils::converModeToDB($_POST[$filed]);
  799. $rule_mode_arr = explode(";", $rule[$filed]);
  800. $post_mode_arr = explode(";", $postValue);
  801. if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
  802. $range_flag = false;
  803. }
  804. }else{
  805. //正常字段直接比较就行
  806. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  807. if($postValue != $rule[$filed]){
  808. $range_flag = false;
  809. }
  810. }
  811. }
  812. //判断details 是否一样
  813. $checkDetailsFiled = array("ocean_milestone","air_milestone","ocean_ctnr_status",
  814. "ocean_atd_sub_etd","ocean_atd_sub_etd_unit","ocean_ata_sub_eta","ocean_ata_sub_eta_unit",
  815. "air_atd_sub_etd","air_atd_sub_etd_unit","air_ata_sub_eta","air_ata_sub_eta_unit",
  816. "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",
  817. "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");
  818. $details_flag = true;
  819. foreach($checkDetailsFiled as $filed){
  820. if($filed == "ocean_milestone" || $filed == "air_milestone" || $filed == "ocean_ctnr_status"){
  821. $rule_mode_arr = explode(";", $rule[$filed]);
  822. $post_mode_arr = explode(";", $_POST[$filed]);
  823. if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
  824. $details_flag = false;
  825. }
  826. $postValue = utils::implode(";",$_POST[$filed]);
  827. } elseif ($filed == "ocean_etd_change" || $filed == "ocean_eta_change" || $filed == "air_etd_change" || $filed == "air_eta_change"){
  828. $post_boolean = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f":"t";
  829. if($post_boolean != $rule[$filed]){
  830. $details_flag = false;
  831. }
  832. } else {
  833. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  834. if($postValue != $rule[$filed]){
  835. $details_flag = false;
  836. }
  837. }
  838. }
  839. //判断frequency 是否一样
  840. $checkFrequencyFiled = array("frequency_type","daily_time","daily_time_zone",
  841. "weekly_week","weekly_time","weekly_time_zone","daily_time_zone");
  842. $frequency_flag = true;
  843. foreach($checkFrequencyFiled as $filed){
  844. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  845. if($postValue != $rule[$filed]){
  846. $frequency_flag = false;
  847. }
  848. }
  849. //判断通知方式是否一样
  850. $checkMethodFiled = array("method_by_email","method_by_message");
  851. $method_flag = true;
  852. foreach($checkMethodFiled as $filed){
  853. $postValue = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f" : "t";
  854. if($postValue != $rule[$filed]){
  855. $method_flag = false;
  856. }
  857. }
  858. //五个条件一样,不允许保存
  859. if($range_flag && $details_flag && $frequency_flag && $method_flag){
  860. $msg = "Unable to Save";
  861. continue;
  862. }
  863. //前三个重回,后面不重合,提示但允许保存
  864. if($range_flag && $details_flag && $_POST['is_similar_rule'] <> 'true'){
  865. $msg = "Similar Rule Detected";
  866. continue;
  867. }
  868. }
  869. return $msg;
  870. }
  871. public function getNotifications($notifiation_type,$frequency_type,$insert_date_format = null){
  872. if ($frequency_type == "all"){
  873. $sql_where = " and (ni.frequency_type = 'Instant'
  874. or (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)
  875. or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  876. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'))";
  877. } elseif($frequency_type == "Daily"){
  878. $sql_where = " and (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)";
  879. } elseif($frequency_type == "Weekly"){
  880. $sql_where = " and (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  881. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
  882. }
  883. //这里的查询会把不同日期的但hbol相同的信息,过滤掉只剩下最新的那一条。所以移除
  884. $aa_where = "";
  885. if (!empty($insert_date_format)){
  886. $aa_where = " where insert_date_format = '$insert_date_format'";
  887. }
  888. $more_param = common::getInNotInSqlForSearch($notifiation_type);
  889. $sql = "select *
  890. from (select ni.*,
  891. case when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'days'
  892. then (EXTRACT(DAY FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
  893. when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'hours'
  894. then (EXTRACT(HOUR FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
  895. else 0
  896. end as delay_diff,
  897. case when COALESCE(ni.frequency_type,'') = 'Daily'
  898. then to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY')
  899. when COALESCE(ni.frequency_type,'') = 'Weekly'
  900. 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')
  901. else ''
  902. end as insert_date_format,
  903. case when ni.notifiation_type ='Milestone_Update'
  904. then public.getPreviousMilestone(ni.serial_no,ni.milestone_code,ccc.transport_mode,ccc.order_from)
  905. else ''
  906. end as milestone_previous_json,
  907. case when ni.notifiation_type ='Container_Status_Update'
  908. then public.getPreviousCtnrStatus(ni.serial_no,ni.ctnr,ni.ctnr_status_code)
  909. else ''
  910. end as ctnr_previous_json,
  911. ccc.order_from,ccc.h_bol,ccc.transport_mode
  912. from public.kln_notifiation_info ni
  913. left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from
  914. from public.kln_ocean oo
  915. where oo.serial_no = ni.serial_no limit 1) ccc on true
  916. where lower(ni.user_login) = '".strtolower(_getLoginName())."'
  917. and lower(ni.notifiation_type) in ($more_param)
  918. ".$sql_where." and ni.notifications_method = true order by ni.insert_date desc) aa $aa_where";
  919. error_log($sql);
  920. $data_all_type = common::excuteListSql($sql);
  921. $data_group = array();
  922. $data_group_uniqe = array();
  923. foreach($data_all_type as $dat){
  924. $uniqe_group_str = $dat['notifiation_type'];
  925. if(utils::in_array($uniqe_group_str,$data_group_uniqe)){
  926. $tempArr = $data_group[$uniqe_group_str];
  927. $tempArr[] = $dat;
  928. $data_group[$uniqe_group_str] = $tempArr;
  929. } else {
  930. $data_group[$uniqe_group_str] = array($dat);
  931. $data_group_uniqe[] = $uniqe_group_str;
  932. }
  933. }
  934. $retData = array();
  935. foreach($data_group as $key => $data){
  936. $notifiation_type_db = $key;
  937. //统一处理数据Instant Daily weekly_week 先分开在处理
  938. $instant = array();
  939. $daily = array();
  940. $daily_uniqe = array();
  941. $weekly = array();
  942. $weekly_uniqe = array();
  943. foreach($data as $d){
  944. if ($d['frequency_type'] == "Instant"){
  945. $instant[] = $d;
  946. }
  947. //Daily 或者 Weekly类型为这个时才用这个去重,否则要加上描述(转船的情况,会让相同的HBOL显示)
  948. $uniqe_str = $d['serial_no'];
  949. if ($notifiation_type_db == "Milestone_Update"){
  950. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['milestone_code'];
  951. }else if ($notifiation_type_db == "Container_Status_Update"){
  952. $uniqe_str = $d['ctnr']."_".$d['insert_date_format']."_".$d['ctnr_status_code'];
  953. }else if($notifiation_type_db == "Departure/Arrival_Delay"){
  954. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['delay_name'];
  955. }else if($notifiation_type_db == "ETD/ETA_Change"){
  956. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['date_change_name'];
  957. }
  958. if ($d['frequency_type'] == "Daily"){
  959. if(!utils::in_array($uniqe_str,$daily_uniqe)){
  960. $daily[$uniqe_str] = $d;
  961. $daily_uniqe[] = $uniqe_str;
  962. }
  963. }
  964. if ($d['frequency_type'] == "Weekly"){
  965. if(!utils::in_array($uniqe_str,$weekly_uniqe)){
  966. $weekly[$uniqe_str] = $d;
  967. $weekly_uniqe[] = $uniqe_str;
  968. }
  969. }
  970. }
  971. $retData[$key]= array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly));
  972. }
  973. return $retData;
  974. }
  975. public function getEventCard($mInfo){
  976. $eventCard = array();
  977. $notifiation_type = $mInfo['notifiation_type'];
  978. if($notifiation_type == "Milestone_Update"){
  979. $eventCard = array("type" =>'milestone',
  980. "numericRecords"=>0,
  981. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  982. "title"=>"Milestone Update",
  983. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  984. "no"=>$mInfo["h_bol"],
  985. "tag"=>$mInfo["milestone_description"],
  986. "location"=>$mInfo["milestone_locations"],
  987. "timezone"=>$mInfo["milestone_timezone"],
  988. "time"=>$mInfo["milestone_date"]." ".$mInfo["milestone_time"],
  989. "timeLabel"=>"",
  990. "previous"=>"",
  991. "frequency_type"=>$mInfo["frequency_type"],
  992. "serial_no"=>$mInfo["serial_no"],
  993. "order_from"=>$mInfo["order_from"],
  994. "id"=>$mInfo["id"],
  995. "insert_date_format"=>'',
  996. "info"=>new stdClass());
  997. if ($mInfo["frequency_type"] == "Daily"){
  998. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  999. $eventCard["title"] = "Milestone Update Daily Summary(".$mInfo["insert_date_format"].")";
  1000. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1001. $eventCard["previous"] = '';
  1002. $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
  1003. if(!empty($milestone_previous['milestone']['milestone_date'])){
  1004. $eventCard["previous"] = array("tag" =>"Previous:".$milestone_previous['milestone']['milestone_description']." from ".$milestone_previous['milestone']['locations'],
  1005. "date" => $milestone_previous['milestone']['milestone_date'],
  1006. "time" => $milestone_previous['milestone']['milestone_time'],
  1007. "timezone" =>$milestone_previous['milestone']['timezone']);
  1008. }
  1009. } else if($mInfo["frequency_type"] == "Weekly"){
  1010. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1011. $eventCard["title"] = "Milestone Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1012. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1013. $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
  1014. if(!empty($milestone_previous['milestone']['milestone_date'])){
  1015. $eventCard["previous"] = array("tag" =>"Previous:".$milestone_previous['milestone']['milestone_description']." from ".$milestone_previous['milestone']['locations'],
  1016. "date" => $milestone_previous['milestone']['milestone_date'],
  1017. "time" => $milestone_previous['milestone']['milestone_time'],
  1018. "timezone" =>$milestone_previous['milestone']['timezone']);
  1019. }
  1020. }
  1021. }
  1022. if($notifiation_type == "Container_Status_Update"){
  1023. //当前状态的描述
  1024. $ctnrStatusdesc = $this->getContainerStatusDesc($mInfo["ctnr_status_code"]);
  1025. $eventCard = array("type" =>'container',
  1026. "numericRecords"=>0,
  1027. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  1028. "title"=>"Container_Status_Update",
  1029. "mode"=>"Ocean Freight",
  1030. "no"=>$mInfo["ctnr"],
  1031. "tag"=>$ctnrStatusdesc,
  1032. "location"=>$mInfo["ctnr_status_locations"],
  1033. "timezone"=>$mInfo["ctnr_status_timezone"],
  1034. "time"=>$mInfo["ctnr_status_date"]." ".$mInfo["ctnr_status_time"],
  1035. "timeLabel"=>"",
  1036. "previous"=>"",
  1037. "frequency_type"=>$mInfo["frequency_type"],
  1038. "serial_no"=>$mInfo["serial_no"],
  1039. "order_from"=>$mInfo["order_from"],
  1040. "id"=>$mInfo["id"],
  1041. "insert_date_format"=>'',
  1042. "info"=>new stdClass());
  1043. if ($mInfo["frequency_type"] == "Daily"){
  1044. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1045. $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
  1046. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1047. $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
  1048. if(!empty($ctnr_previous["ctnrStatus"]["date"])){
  1049. //当前状态 前一个的描述
  1050. $eventCard["previous"] = array("tag" =>"Previous:" .$ctnr_previous["ctnrStatus"]["description"]. " from " .$ctnr_previous["ctnrStatus"]["locations"],
  1051. "date" => $ctnr_previous["ctnrStatus"]["date"],
  1052. "time" => $ctnr_previous["ctnrStatus"]["time"],
  1053. "timezone" =>$ctnr_previous["ctnrStatus"]["timezone"]);
  1054. }
  1055. } else if($mInfo["frequency_type"] == "Weekly"){
  1056. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1057. $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1058. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1059. $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
  1060. if(!empty($ctnr_previous["ctnrStatus"]["date"])){
  1061. //当前状态 前一个的描述
  1062. $eventCard["previous"] = array("tag" =>"Previous:" .$ctnr_previous["ctnrStatus"]["description"]. " from " .$ctnr_previous["ctnrStatus"]["locations"],
  1063. "date" => $ctnr_previous["ctnrStatus"]["date"],
  1064. "time" => $ctnr_previous["ctnrStatus"]["time"],
  1065. "timezone" =>$ctnr_previous["ctnrStatus"]["timezone"]);
  1066. }
  1067. }
  1068. }
  1069. if($notifiation_type == "Departure/Arrival_Delay"){
  1070. //代表信息为转船信息,title要处理一下: leg 2/3 Departure_Delay => Departure_Delay
  1071. $title = $mInfo["delay_name"];
  1072. $outsideLocation = "";
  1073. $outsideTimezone = "";
  1074. $outsideTimeLabel= "";
  1075. $insideTimeLabel= "";
  1076. if(utils::checkExist($mInfo["delay_name"],"Departure_Delay")){
  1077. $outsideTimeLabel = "ETD";
  1078. $insideTimeLabel = "ATD";
  1079. }
  1080. if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay")){
  1081. $outsideTimeLabel = "ETA";
  1082. $insideTimeLabel = "ATA";
  1083. }
  1084. //直航的的
  1085. if(utils::checkExist($mInfo["delay_name"],"Departure_Delay") and $mInfo["delay_is_direct"] == 't'){
  1086. $outsideLocation = $mInfo["delay_locations_from"];
  1087. }
  1088. if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay") and $mInfo["delay_is_direct"] == 't'){
  1089. $outsideLocation = $mInfo["delay_locations_to"];
  1090. }
  1091. $route = array();
  1092. $leg = array();
  1093. if($mInfo["delay_is_direct"] <>'t'){
  1094. $title = substr($mInfo["delay_name"],8);
  1095. $route = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
  1096. //当前current Leg
  1097. $leg = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"]);
  1098. if($mInfo["delay_current"] == "2"){
  1099. $leg = array($mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
  1100. }
  1101. }
  1102. $act_date = $mInfo["delay_act_date"]." ".$mInfo["delay_act_time"];
  1103. $est_date = $mInfo["delay_est_date"]." ".$mInfo["delay_est_time"];
  1104. $delay_diff = $mInfo["delay_diff"];
  1105. $delay_unit = $mInfo["delay_unit"];
  1106. $eventCard = array("type" =>'delay',
  1107. "numericRecords"=>0,
  1108. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  1109. "title"=>$title,
  1110. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1111. "no"=>$mInfo["h_bol"],
  1112. "tag"=>$mInfo["delay_name"],
  1113. "location"=>$outsideLocation,
  1114. "timezone"=>$mInfo["delay_timezone"],
  1115. "time"=>$est_date,
  1116. "timeLabel"=>$outsideTimeLabel,
  1117. "previous"=>"",
  1118. "frequency_type"=>$mInfo["frequency_type"],
  1119. "serial_no"=>$mInfo["serial_no"],
  1120. "order_from"=>$mInfo["order_from"],
  1121. "id"=>$mInfo["id"],
  1122. "insert_date_format"=>'',
  1123. "info"=>array("route"=>$route,
  1124. "leg"=>$leg,
  1125. "etdOrdeparturNum"=>0,
  1126. "etaOrarrivalNum"=>0,
  1127. "time"=>$act_date,
  1128. "timeLabel"=>$insideTimeLabel,
  1129. "delayTimeTip"=>"+".$delay_diff." ".$delay_unit." delay",
  1130. "timezone"=>$mInfo["delay_timezone"]
  1131. ));
  1132. if ($mInfo["frequency_type"] == "Daily"){
  1133. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1134. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1135. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1136. $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
  1137. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1138. } else if($mInfo["frequency_type"] == "Weekly"){
  1139. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1140. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1141. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1142. $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1143. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1144. }
  1145. }
  1146. if($notifiation_type == "ETD/ETA_Change"){
  1147. $title = $mInfo["date_change_name"];
  1148. if(utils::checkExist($mInfo["date_change_name"],"ETD Change")){
  1149. $outsideTimeLabel = "Original ETD";
  1150. $insideTimeLabel = "Upoated ETD";
  1151. }
  1152. if(utils::checkExist($mInfo["date_change_name"],"ETA Change")){
  1153. $outsideTimeLabel = "Original ETA";
  1154. $insideTimeLabel = "Upoated ETA";
  1155. }
  1156. if($mInfo["date_change_is_direct"] <>'t'){
  1157. //代表信息为转船信息,title要处理一下: leg 1/3 ETD Change
  1158. $title = substr($mInfo["date_change_name"],8);
  1159. $route = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
  1160. $leg = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"]);
  1161. if($mInfo["delay_current"] == "2"){
  1162. $leg = array($mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
  1163. }
  1164. }
  1165. $updated_date = $mInfo["date_change_updated_date"]." ".$mInfo["date_change_updated_time"];
  1166. $original_date = $mInfo["date_change_original_date"]." ".$mInfo["date_change_original_time"];
  1167. $eventCard = array("type" =>'change',
  1168. "numericRecords"=>0,
  1169. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  1170. "title"=>$title,
  1171. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1172. "no"=>$mInfo["h_bol"],
  1173. "tag"=>$mInfo["date_change_name"],
  1174. "location"=>"",
  1175. "timezone"=>$mInfo["date_change_timezone"],
  1176. "time"=>$original_date,
  1177. "timeLabel"=>$outsideTimeLabel,
  1178. "previous"=>"",
  1179. "frequency_type"=>$mInfo["frequency_type"],
  1180. "serial_no"=>$mInfo["serial_no"],
  1181. "order_from"=>$mInfo["order_from"],
  1182. "id"=>$mInfo["id"],
  1183. "insert_date_format"=>'',
  1184. "info"=>array("route"=>$route,
  1185. "leg"=>$leg,
  1186. "etdOrdeparturNum"=>0,
  1187. "etaOrarrivalNum"=>0,
  1188. "time"=>$updated_date,
  1189. "timeLabel"=>$insideTimeLabel,
  1190. "delayTimeTip"=>"",
  1191. "timezone"=>$mInfo["date_change_timezone"]
  1192. ));
  1193. if ($mInfo["frequency_type"] == "Daily"){
  1194. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1195. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1196. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1197. $eventCard["title"] = "ETD/ETA Change Daily Summary(".$mInfo["insert_date_format"].")";
  1198. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1199. } else if($mInfo["frequency_type"] == "Weekly"){
  1200. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1201. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1202. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1203. $eventCard["title"] = "ETD/ETA Change Weekly Summary(".$mInfo["insert_date_format"].")";
  1204. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1205. }
  1206. }
  1207. return $eventCard;
  1208. }
  1209. /**
  1210. * 返回当前柜子的status信息描述,目前作废
  1211. */
  1212. public static function getContainerStatusDesc($ctnr_status_code){
  1213. $event =common::getEDICtnrEvent();
  1214. $ctnrStatusdesc = "";
  1215. foreach($event as $e){
  1216. if($e['event_name'] == $ctnr_status_code){
  1217. $ctnrStatusdesc = $e['description'];
  1218. }
  1219. }
  1220. return $ctnrStatusdesc;
  1221. }
  1222. }
  1223. ?>