tools.class.php 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  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. "select
  510. sum(case when (1<>1 or (notifiation_type='Milestone_Update')) then 1 else 0 end) as sea_rc,
  511. sum(case when (1<>1 or (notifiation_type='sea')) then 1 else 0 end) as sea_rc,
  512. sum(case when (1<>1 or (notifiation_type='sea')) then 1 else 0 end) as sea_rc,
  513. sum(case when (1<>1 or (notifiation_type='sea')) then 1 else 0 end) as sea_rc,
  514. sum(case when (1<>1 or (notifiation_type='sea')) then 1 else 0 end) as sea_rc
  515. from public.kln_notifiation_info
  516. where insert_date > NOW() - INTERVAL '1 year'
  517. and notifications_method = 'true' and is_send_message = 'false'";
  518. }
  519. }
  520. /**
  521. * 遍历查找对应的rule。
  522. */
  523. public function getSubscribeRules($rule_name,$subscribe_rules){
  524. //初始是不显示,没有值的情况
  525. $ret = array("is_display" => false);
  526. foreach($subscribe_rules as $rules){
  527. if($rules['rules_type'] == $rule_name){
  528. $rules["is_display"] = true;
  529. $rules["daily_time"] = $rules["_daily_time"];
  530. $rules["weekly_time"] = $rules["_weekly_time"];
  531. $rules["weekly_week"] = common::getWeek($rules["weekly_week"]);
  532. $ret = $rules;
  533. }
  534. }
  535. //Milestone Update的结构处理,处理init page load
  536. if($rule_name == "Milestone_Update"){
  537. //Milestone Update的页面配置数据
  538. $milestones = common::excuteListSql("select * from public.customer_service_milestone_sno order by type, sno");
  539. $oceanMilestone = array();
  540. $airMilestone = array();
  541. foreach($milestones as $milestone){
  542. if($milestone['type'] == "air"){
  543. $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  544. }
  545. if($milestone['type'] == "sea"){
  546. $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  547. }
  548. }
  549. $ret["OceanCheckBoxList"] = $oceanMilestone;
  550. $ret["AirCheckBoxList"] = $airMilestone;
  551. $oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
  552. $airMilestoneSetting = !empty($ret['air_milestone']) ? explode(";",$ret['air_milestone']): array();
  553. $ret["OceanCheckedList"] = $oceanMilestoneSetting;
  554. $ret["AirCheckedList"] = $airMilestoneSetting;
  555. }
  556. //Milestone Update的结构处理
  557. if($rule_name == "Container_Status_Update"){
  558. //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  559. //$event =common::getEDICtnrEvent();
  560. $event = common::excuteListSql("select ra_name as event_name,ra_order,description
  561. from public.ra_online_edi_event e
  562. where e.ra_name in('I','VD','VA','UV','AL','AR','OA','RD') order by e.ra_order desc");
  563. $ctnrStatus = array();
  564. foreach($event as $e){
  565. $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
  566. }
  567. $ret["CtnrCheckBoxList"] = $ctnrStatus;
  568. $ctnrStatusSetting = !empty($ret['ocean_ctnr_status']) ? explode(";",$ret['ocean_ctnr_status']) : array();
  569. $ret["CtnrCheckedList"] = $ctnrStatusSetting;
  570. }
  571. return $ret;
  572. }
  573. /**
  574. * 查询对应用户订阅的shipment信息.可能存在分页查询,如果有需要就改正
  575. * cp current_page
  576. */
  577. public function getSubscribeShipment($cp,$ps){
  578. if (empty($cp)){
  579. $cp = 1;
  580. }
  581. if (empty($ps)){
  582. $ps = 15;
  583. }
  584. $sql = "select count(1) from public.kln_user_subscribed u
  585. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  586. where lower(user_login) = '".strtolower(_getLoginName())."'";
  587. $rc = common::excuteOneSql($sql);
  588. $tp = ceil($rc / $ps);
  589. if ($rc > 0) {
  590. $sql = "select o.h_bol,
  591. o.shipper,o.consignee,o.etd,o.eta,
  592. case when transport_mode = 'sea'
  593. then (select sn.description
  594. from public.ocean_milestone a
  595. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'sea'
  596. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  597. when transport_mode = 'air' and order_from = 'public'
  598. then (select sn.description
  599. from public.air_milestone a
  600. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  601. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  602. when transport_mode = 'air' and order_from = 'sfs'
  603. then (select sn.description
  604. from sfs.air_milestone a
  605. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  606. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  607. else '' end as recent_milestone
  608. from public.kln_user_subscribed u
  609. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  610. where lower(user_login) = '".strtolower(_getLoginName())."' order by u.id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  611. $subscribeShipment = common::excuteListSql($sql);
  612. $arrTmp = array('tableData' => $subscribeShipment,
  613. 'rc' => intval($rc),
  614. 'ps' => $ps,
  615. 'cp' => $cp,
  616. 'tp' => $tp
  617. );
  618. } else {
  619. $arrTmp = array('tableData' => array(),
  620. 'rc' => $rc,
  621. 'ps' => $ps,
  622. 'cp' => $cp,
  623. 'tp' => $tp,
  624. );
  625. }
  626. return $arrTmp;
  627. }
  628. public function getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,$notifications_type,$id){
  629. $sql = "";
  630. //先删后加
  631. if($updateOrInsert == "update"){
  632. $sql.="delete from public.notifications_rules where rules_type = '$rules_type'
  633. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  634. and id = '$id';";
  635. }
  636. //这个几个参数是所有规则都有的参数
  637. $frequency_type = common::check_input($_POST['frequency_type']);
  638. $daily_time = "null";
  639. $daily_time_zone = "";
  640. $weekly_week = "";
  641. $weekly_time = "null";
  642. $weekly_time_zone = "";
  643. if(strtolower($frequency_type) == "daily"){
  644. $daily_time = "'".common::check_input($_POST['daily_time'])."'";
  645. $daily_time_zone = common::check_input($_POST['daily_time_zone']);
  646. } elseif (strtolower($frequency_type) == "weekly"){
  647. $weekly_week = common::check_input($_POST['weekly_week']);
  648. $weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
  649. $weekly_time_zone = common::check_input($_POST['weekly_time_zone']);
  650. }
  651. $method_by_email = !empty($_POST['method_by_email']) ? common::check_input($_POST['method_by_email']) : 'false';
  652. $method_by_message = !empty($_POST['method_by_message']) ? common::check_input($_POST['method_by_message']) : 'false';
  653. $event_details = common::check_input($_POST['event_details']);
  654. $frequency_display = common::check_input($_POST['frequency_display']);
  655. $method_display = common::check_input($_POST['method_display']);
  656. $shipment_detail = common::check_input($_POST['shipment_details']);
  657. //当规则是 Monitoring类型是,需要配置的range
  658. $shipment_transport_mode = "";
  659. $shipment_etd_limit = "";
  660. $shipment_eta_limit = "";
  661. if($notifications_type == "Monitoring"){
  662. $shipment_transport_mode = utils::converModeToDB($_POST['shipment_transport_mode']);
  663. $shipment_etd_limit = common::check_input($_POST['shipment_etd_limit']);
  664. $shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
  665. }
  666. if ($rules_type == "Milestone_Update"){
  667. $ocean_milestone = utils::implode(";",$_POST['ocean_milestone']);
  668. $air_milestone = utils::implode(";",$_POST['air_milestone']);
  669. $sql.="INSERT INTO public.notifications_rules(
  670. user_login, notifications_type, rules_type, ocean_milestone,
  671. air_milestone, frequency_type, daily_time, daily_time_zone,
  672. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  673. event_details, frequency_display, method_display,shipment_details,
  674. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  675. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_milestone',
  676. '$air_milestone', '$frequency_type', $daily_time, '$daily_time_zone',
  677. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  678. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  679. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  680. }
  681. if ($rules_type == "Container_Status_Update"){
  682. $ocean_ctnr_status = utils::implode(";",$_POST['ocean_ctnr_status']);
  683. $sql.="INSERT INTO public.notifications_rules(
  684. user_login, notifications_type, rules_type, ocean_ctnr_status,
  685. frequency_type, daily_time, daily_time_zone,
  686. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  687. event_details, frequency_display, method_display,shipment_details,
  688. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  689. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_ctnr_status',
  690. '$frequency_type', $daily_time, '$daily_time_zone',
  691. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  692. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  693. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  694. }
  695. if ($rules_type == "Departure/Arrival_Delay"){
  696. $ocean_atd_sub_etd = common::check_input($_POST['ocean_atd_sub_etd']);
  697. $ocean_atd_sub_etd_unit = common::check_input($_POST['ocean_atd_sub_etd_unit']);
  698. if(!empty($ocean_atd_sub_etd_unit)){
  699. $ocean_atd_sub_etd_unit = $ocean_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  700. }
  701. $ocean_ata_sub_eta = common::check_input($_POST['ocean_ata_sub_eta']);
  702. $ocean_ata_sub_eta_unit = common::check_input($_POST['ocean_ata_sub_eta_unit']);
  703. if(!empty($ocean_ata_sub_eta_unit)){
  704. $ocean_ata_sub_eta_unit = $ocean_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  705. }
  706. $air_atd_sub_etd = common::check_input($_POST['air_atd_sub_etd']);
  707. $air_atd_sub_etd_unit = common::check_input($_POST['air_atd_sub_etd_unit']);
  708. if(!empty($air_atd_sub_etd_unit)){
  709. $air_atd_sub_etd_unit = $air_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  710. }
  711. $air_ata_sub_eta = common::check_input($_POST['air_ata_sub_eta']);
  712. $air_ata_sub_eta_unit = common::check_input($_POST['air_ata_sub_eta_unit']);
  713. if(!empty($air_ata_sub_eta_unit)){
  714. $air_ata_sub_eta_unit = $air_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  715. }
  716. $sql.="INSERT INTO public.notifications_rules(
  717. user_login, notifications_type, rules_type,
  718. ocean_atd_sub_etd, ocean_atd_sub_etd_unit,ocean_ata_sub_eta,ocean_ata_sub_eta_unit,
  719. air_atd_sub_etd, air_atd_sub_etd_unit,air_ata_sub_eta,air_ata_sub_eta_unit,
  720. frequency_type, daily_time, daily_time_zone,
  721. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  722. event_details, frequency_display, method_display,shipment_details,
  723. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  724. VALUES ('".strtolower(_getLoginName())."', '$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_detail',
  730. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  731. }
  732. if ($rules_type == "ETD/ETA_Change"){
  733. $ocean_etd_change = !empty($_POST['ocean_etd_change']) ? common::check_input($_POST['ocean_etd_change']) : 'false';
  734. $ocean_etd_old_sub_new = common::check_input($_POST['ocean_etd_old_sub_new']);
  735. $ocean_etd_old_sub_new_unit = common::check_input($_POST['ocean_etd_old_sub_new_unit']);
  736. if(!empty($ocean_etd_old_sub_new_unit)){
  737. $ocean_etd_old_sub_new_unit = $ocean_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  738. }
  739. $ocean_eta_change = !empty($_POST['ocean_eta_change']) ? common::check_input($_POST['ocean_eta_change']) : 'false';
  740. $ocean_eta_old_sub_new = common::check_input($_POST['ocean_eta_old_sub_new']);
  741. $ocean_eta_old_sub_new_unit = common::check_input($_POST['ocean_eta_old_sub_new_unit']);
  742. if(!empty($ocean_eta_old_sub_new_unit)){
  743. $ocean_eta_old_sub_new_unit = $ocean_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  744. }
  745. $air_etd_change = !empty($_POST['air_etd_change']) ? common::check_input($_POST['air_etd_change']) : 'false';
  746. $air_etd_old_sub_new = common::check_input($_POST['air_etd_old_sub_new']);
  747. $air_etd_old_sub_new_unit = common::check_input($_POST['air_etd_old_sub_new_unit']);
  748. if(!empty($air_etd_old_sub_new_unit)){
  749. $air_etd_old_sub_new_unit = $air_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  750. }
  751. $air_eta_change = !empty($_POST['air_eta_change']) ? common::check_input($_POST['air_eta_change']): 'false';
  752. $air_eta_old_sub_new = common::check_input($_POST['air_eta_old_sub_new']);
  753. $air_eta_old_sub_new_unit = common::check_input($_POST['air_eta_old_sub_new_unit']);
  754. if(!empty($air_eta_old_sub_new_unit)){
  755. $air_eta_old_sub_new_unit = $air_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  756. }
  757. $sql.="INSERT INTO public.notifications_rules(
  758. user_login, notifications_type, rules_type,
  759. 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,
  760. 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,
  761. frequency_type, daily_time, daily_time_zone,
  762. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  763. event_details, frequency_display, method_display,shipment_details,
  764. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  765. VALUES ('".strtolower(_getLoginName())."', '$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_detail',
  771. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  772. }
  773. return $sql;
  774. }
  775. /**
  776. * 检查编辑提交的Monitoring规则,是否允许保存
  777. */
  778. public function checkedMonitoringRulesSave($rules_type){
  779. $sql_where = "";
  780. if(isset($_POST['id']) && !empty($_POST['id'])){
  781. $sql_where = " and id <> '".common::check_input($_POST['id'])."'";
  782. }
  783. $rules = common::excuteListSql("select * from public.notifications_rules where notifications_type = 'Monitoring' and rules_type = '".$rules_type."'
  784. and lower(user_login) = '".strtolower(_getLoginName())."' $sql_where");
  785. foreach($rules as $rule){
  786. //判断range 是否一样
  787. $checkRangeFiled = array("shipment_transport_mode","shipment_etd_limit","shipment_eta_limit");
  788. $range_flag = true;
  789. foreach($checkRangeFiled as $filed){
  790. if($filed == "shipment_transport_mode"){
  791. $postValue = utils::converModeToDB($_POST[$filed]);
  792. $rule_mode_arr = explode(";", $rule[$filed]);
  793. $post_mode_arr = explode(";", $postValue);
  794. if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
  795. $range_flag = false;
  796. }
  797. }else{
  798. //正常字段直接比较就行
  799. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  800. if($postValue != $rule[$filed]){
  801. $range_flag = false;
  802. }
  803. }
  804. }
  805. //判断details 是否一样
  806. $checkDetailsFiled = array("ocean_milestone","air_milestone","ocean_ctnr_status",
  807. "ocean_atd_sub_etd","ocean_atd_sub_etd_unit","ocean_ata_sub_eta","ocean_ata_sub_eta_unit",
  808. "air_atd_sub_etd","air_atd_sub_etd_unit","air_ata_sub_eta","air_ata_sub_eta_unit",
  809. "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",
  810. "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");
  811. $details_flag = true;
  812. foreach($checkDetailsFiled as $filed){
  813. if($filed == "ocean_milestone" || $filed == "air_milestone" || $filed == "ocean_ctnr_status"){
  814. $rule_mode_arr = explode(";", $rule[$filed]);
  815. $post_mode_arr = explode(";", $_POST[$filed]);
  816. if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
  817. $details_flag = false;
  818. }
  819. $postValue = utils::implode(";",$_POST[$filed]);
  820. } elseif ($filed == "ocean_etd_change" || $filed == "ocean_eta_change" || $filed == "air_etd_change" || $filed == "air_eta_change"){
  821. $post_boolean = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f":"t";
  822. if($post_boolean != $rule[$filed]){
  823. $details_flag = false;
  824. }
  825. } else {
  826. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  827. if($postValue != $rule[$filed]){
  828. $details_flag = false;
  829. }
  830. }
  831. }
  832. //判断frequency 是否一样
  833. $checkFrequencyFiled = array("frequency_type","daily_time","daily_time_zone",
  834. "weekly_week","weekly_time","weekly_time_zone","daily_time_zone");
  835. $frequency_flag = true;
  836. foreach($checkFrequencyFiled as $filed){
  837. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  838. if($postValue != $rule[$filed]){
  839. $frequency_flag = false;
  840. }
  841. }
  842. //判断通知方式是否一样
  843. $checkMethodFiled = array("method_by_email","method_by_message");
  844. $method_flag = true;
  845. foreach($checkMethodFiled as $filed){
  846. $postValue = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f" : "t";
  847. if($postValue != $rule[$filed]){
  848. $method_flag = false;
  849. }
  850. }
  851. //五个条件一样,不允许保存
  852. if($range_flag && $details_flag && $frequency_flag && $method_flag){
  853. $msg = "Unable to Save";
  854. continue;
  855. }
  856. //前三个重回,后面不重合,提示但允许保存
  857. if($range_flag && $details_flag && $_POST['is_similar_rule'] <> 'true'){
  858. $msg = "Similar Rule Detected";
  859. continue;
  860. }
  861. }
  862. return $msg;
  863. }
  864. public function getNotifications($notifiation_type,$frequency_type,$insert_date_format = null){
  865. if ($frequency_type == "all"){
  866. $sql_where = " and (ni.frequency_type = 'Instant'
  867. or (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)
  868. or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  869. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'))";
  870. } elseif($frequency_type == "Daily"){
  871. $sql_where = " and (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)";
  872. } elseif($frequency_type == "Weekly"){
  873. $sql_where = " and (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  874. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
  875. }
  876. //这里的查询会把不同日期的但hbol相同的信息,过滤掉只剩下最新的那一条。所以移除
  877. $aa_where = "";
  878. if (!empty($insert_date_format)){
  879. $aa_where = " where insert_date_format = '$insert_date_format'";
  880. }
  881. $more_param = common::getInNotInSqlForSearch($notifiation_type);
  882. $sql = "select *
  883. from (select ni.*,
  884. case when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'days'
  885. then (EXTRACT(DAY FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
  886. when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'hours'
  887. then (EXTRACT(HOUR FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
  888. else 0
  889. end as delay_diff,
  890. case when COALESCE(ni.frequency_type,'') = 'Daily'
  891. then to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY')
  892. when COALESCE(ni.frequency_type,'') = 'Weekly'
  893. 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')
  894. else ''
  895. end as insert_date_format,
  896. case when ni.notifiation_type ='Milestone_Update'
  897. then public.getPreviousMilestone(ni.serial_no,ni.milestone_code,ccc.transport_mode,ccc.order_from)
  898. else ''
  899. end as milestone_previous_json,
  900. case when ni.notifiation_type ='Container_Status_Update'
  901. then public.getPreviousCtnrStatus(ni.serial_no,ni.ctnr,ni.ctnr_status_code)
  902. else ''
  903. end as ctnr_previous_json,
  904. ccc.order_from,ccc.h_bol,ccc.transport_mode
  905. from public.kln_notifiation_info ni
  906. left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from
  907. from public.kln_ocean oo
  908. where oo.serial_no = ni.serial_no limit 1) ccc on true
  909. where lower(ni.user_login) = '".strtolower(_getLoginName())."'
  910. and lower(ni.notifiation_type) in ($more_param)
  911. ".$sql_where." and ni.notifications_method = true order by ni.insert_date desc) aa $aa_where";
  912. error_log($sql);
  913. $data_all_type = common::excuteListSql($sql);
  914. $data_group = array();
  915. $data_group_uniqe = array();
  916. foreach($data_all_type as $dat){
  917. $uniqe_group_str = $dat['notifiation_type'];
  918. if(utils::in_array($uniqe_group_str,$data_group_uniqe)){
  919. $tempArr = $data_group[$uniqe_group_str];
  920. $tempArr[] = $dat;
  921. $data_group[$uniqe_group_str] = $tempArr;
  922. } else {
  923. $data_group[$uniqe_group_str] = array($dat);
  924. $data_group_uniqe[] = $uniqe_group_str;
  925. }
  926. }
  927. $retData = array();
  928. foreach($data_group as $key => $data){
  929. $notifiation_type_db = $key;
  930. //统一处理数据Instant Daily weekly_week 先分开在处理
  931. $instant = array();
  932. $daily = array();
  933. $daily_uniqe = array();
  934. $weekly = array();
  935. $weekly_uniqe = array();
  936. foreach($data as $d){
  937. if ($d['frequency_type'] == "Instant"){
  938. $instant[] = $d;
  939. }
  940. //Daily 或者 Weekly类型为这个时才用这个去重,否则要加上描述(转船的情况,会让相同的HBOL显示)
  941. $uniqe_str = $d['serial_no'];
  942. if ($notifiation_type_db == "Milestone_Update"){
  943. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['milestone_code'];
  944. }else if ($notifiation_type_db == "Container_Status_Update"){
  945. $uniqe_str = $d['ctnr']."_".$d['insert_date_format']."_".$d['ctnr_status_code'];
  946. }else if($notifiation_type_db == "Departure/Arrival_Delay"){
  947. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['delay_name'];
  948. }else if($notifiation_type_db == "ETD/ETA_Change"){
  949. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['date_change_name'];
  950. }
  951. if ($d['frequency_type'] == "Daily"){
  952. if(!utils::in_array($uniqe_str,$daily_uniqe)){
  953. $daily[$uniqe_str] = $d;
  954. $daily_uniqe[] = $uniqe_str;
  955. }
  956. }
  957. if ($d['frequency_type'] == "Weekly"){
  958. if(!utils::in_array($uniqe_str,$weekly_uniqe)){
  959. $weekly[$uniqe_str] = $d;
  960. $weekly_uniqe[] = $uniqe_str;
  961. }
  962. }
  963. }
  964. $retData[$key]= array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly));
  965. }
  966. return $retData;
  967. }
  968. public function getEventCard($mInfo){
  969. $eventCard = array();
  970. $notifiation_type = $mInfo['notifiation_type'];
  971. if($notifiation_type == "Milestone_Update"){
  972. $eventCard = array("type" =>'milestone',
  973. "numericRecords"=>0,
  974. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  975. "title"=>"Milestone Update",
  976. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  977. "no"=>$mInfo["h_bol"],
  978. "tag"=>$mInfo["milestone_description"],
  979. "location"=>$mInfo["milestone_locations"],
  980. "timezone"=>$mInfo["milestone_timezone"],
  981. "time"=>$mInfo["milestone_date"]." ".$mInfo["milestone_time"],
  982. "timeLabel"=>"",
  983. "previous"=>"",
  984. "frequency_type"=>$mInfo["frequency_type"],
  985. "serial_no"=>$mInfo["serial_no"],
  986. "order_from"=>$mInfo["order_from"],
  987. "id"=>$mInfo["id"],
  988. "insert_date_format"=>'',
  989. "info"=>new stdClass());
  990. if ($mInfo["frequency_type"] == "Daily"){
  991. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  992. $eventCard["title"] = "Milestone Update Daily Summary(".$mInfo["insert_date_format"].")";
  993. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  994. $eventCard["previous"] = '';
  995. $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
  996. if(!empty($milestone_previous['milestone']['milestone_date'])){
  997. $eventCard["previous"] = array("tag" =>"Previous:".$milestone_previous['milestone']['milestone_description']." from ".$milestone_previous['milestone']['locations'],
  998. "date" => $milestone_previous['milestone']['milestone_date'],
  999. "time" => $milestone_previous['milestone']['milestone_time'],
  1000. "timezone" =>$milestone_previous['milestone']['timezone']);
  1001. }
  1002. } else if($mInfo["frequency_type"] == "Weekly"){
  1003. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1004. $eventCard["title"] = "Milestone Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1005. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1006. $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
  1007. if(!empty($milestone_previous['milestone']['milestone_date'])){
  1008. $eventCard["previous"] = array("tag" =>"Previous:".$milestone_previous['milestone']['milestone_description']." from ".$milestone_previous['milestone']['locations'],
  1009. "date" => $milestone_previous['milestone']['milestone_date'],
  1010. "time" => $milestone_previous['milestone']['milestone_time'],
  1011. "timezone" =>$milestone_previous['milestone']['timezone']);
  1012. }
  1013. }
  1014. }
  1015. if($notifiation_type == "Container_Status_Update"){
  1016. //当前状态的描述
  1017. $ctnrStatusdesc = $this->getContainerStatusDesc($mInfo["ctnr_status_code"]);
  1018. $eventCard = array("type" =>'container',
  1019. "numericRecords"=>0,
  1020. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  1021. "title"=>"Container_Status_Update",
  1022. "mode"=>"Ocean Freight",
  1023. "no"=>$mInfo["ctnr"],
  1024. "tag"=>$ctnrStatusdesc,
  1025. "location"=>$mInfo["ctnr_status_locations"],
  1026. "timezone"=>$mInfo["ctnr_status_timezone"],
  1027. "time"=>$mInfo["ctnr_status_date"]." ".$mInfo["ctnr_status_time"],
  1028. "timeLabel"=>"",
  1029. "previous"=>"",
  1030. "frequency_type"=>$mInfo["frequency_type"],
  1031. "serial_no"=>$mInfo["serial_no"],
  1032. "order_from"=>$mInfo["order_from"],
  1033. "id"=>$mInfo["id"],
  1034. "insert_date_format"=>'',
  1035. "info"=>new stdClass());
  1036. if ($mInfo["frequency_type"] == "Daily"){
  1037. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1038. $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
  1039. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1040. $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
  1041. if(!empty($ctnr_previous["ctnrStatus"]["date"])){
  1042. //当前状态 前一个的描述
  1043. $eventCard["previous"] = array("tag" =>"Previous:" .$ctnr_previous["ctnrStatus"]["description"]. " from " .$ctnr_previous["ctnrStatus"]["locations"],
  1044. "date" => $ctnr_previous["ctnrStatus"]["date"],
  1045. "time" => $ctnr_previous["ctnrStatus"]["time"],
  1046. "timezone" =>$ctnr_previous["ctnrStatus"]["timezone"]);
  1047. }
  1048. } else if($mInfo["frequency_type"] == "Weekly"){
  1049. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1050. $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1051. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1052. $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
  1053. if(!empty($ctnr_previous["ctnrStatus"]["date"])){
  1054. //当前状态 前一个的描述
  1055. $eventCard["previous"] = array("tag" =>"Previous:" .$ctnr_previous["ctnrStatus"]["description"]. " from " .$ctnr_previous["ctnrStatus"]["locations"],
  1056. "date" => $ctnr_previous["ctnrStatus"]["date"],
  1057. "time" => $ctnr_previous["ctnrStatus"]["time"],
  1058. "timezone" =>$ctnr_previous["ctnrStatus"]["timezone"]);
  1059. }
  1060. }
  1061. }
  1062. if($notifiation_type == "Departure/Arrival_Delay"){
  1063. //代表信息为转船信息,title要处理一下: leg 2/3 Departure_Delay => Departure_Delay
  1064. $title = $mInfo["delay_name"];
  1065. $outsideLocation = "";
  1066. $outsideTimezone = "";
  1067. $outsideTimeLabel= "";
  1068. $insideTimeLabel= "";
  1069. if(utils::checkExist($mInfo["delay_name"],"Departure_Delay")){
  1070. $outsideTimeLabel = "ETD";
  1071. $insideTimeLabel = "ATD";
  1072. }
  1073. if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay")){
  1074. $outsideTimeLabel = "ETA";
  1075. $insideTimeLabel = "ATA";
  1076. }
  1077. //直航的的
  1078. if(utils::checkExist($mInfo["delay_name"],"Departure_Delay") and $mInfo["delay_is_direct"] == 't'){
  1079. $outsideLocation = $mInfo["delay_locations_from"];
  1080. }
  1081. if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay") and $mInfo["delay_is_direct"] == 't'){
  1082. $outsideLocation = $mInfo["delay_locations_to"];
  1083. }
  1084. $route = array();
  1085. $leg = array();
  1086. if($mInfo["delay_is_direct"] <>'t'){
  1087. $title = substr($mInfo["delay_name"],8);
  1088. $route = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
  1089. //当前current Leg
  1090. $leg = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"]);
  1091. if($mInfo["delay_current"] == "2"){
  1092. $leg = array($mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
  1093. }
  1094. }
  1095. $act_date = $mInfo["delay_act_date"]." ".$mInfo["delay_act_time"];
  1096. $est_date = $mInfo["delay_est_date"]." ".$mInfo["delay_est_time"];
  1097. $delay_diff = $mInfo["delay_diff"];
  1098. $delay_unit = $mInfo["delay_unit"];
  1099. $eventCard = array("type" =>'delay',
  1100. "numericRecords"=>0,
  1101. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  1102. "title"=>$title,
  1103. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1104. "no"=>$mInfo["h_bol"],
  1105. "tag"=>$mInfo["delay_name"],
  1106. "location"=>$outsideLocation,
  1107. "timezone"=>$mInfo["delay_timezone"],
  1108. "time"=>$est_date,
  1109. "timeLabel"=>$outsideTimeLabel,
  1110. "previous"=>"",
  1111. "frequency_type"=>$mInfo["frequency_type"],
  1112. "serial_no"=>$mInfo["serial_no"],
  1113. "order_from"=>$mInfo["order_from"],
  1114. "id"=>$mInfo["id"],
  1115. "insert_date_format"=>'',
  1116. "info"=>array("route"=>$route,
  1117. "leg"=>$leg,
  1118. "etdOrdeparturNum"=>0,
  1119. "etaOrarrivalNum"=>0,
  1120. "time"=>$act_date,
  1121. "timeLabel"=>$insideTimeLabel,
  1122. "delayTimeTip"=>"+".$delay_diff." ".$delay_unit." delay",
  1123. "timezone"=>$mInfo["delay_timezone"]
  1124. ));
  1125. if ($mInfo["frequency_type"] == "Daily"){
  1126. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1127. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1128. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1129. $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
  1130. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1131. } else if($mInfo["frequency_type"] == "Weekly"){
  1132. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1133. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1134. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1135. $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1136. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1137. }
  1138. }
  1139. if($notifiation_type == "ETD/ETA_Change"){
  1140. $title = $mInfo["date_change_name"];
  1141. if(utils::checkExist($mInfo["date_change_name"],"ETD Change")){
  1142. $outsideTimeLabel = "Original ETD";
  1143. $insideTimeLabel = "Upoated ETD";
  1144. }
  1145. if(utils::checkExist($mInfo["date_change_name"],"ETA Change")){
  1146. $outsideTimeLabel = "Original ETA";
  1147. $insideTimeLabel = "Upoated ETA";
  1148. }
  1149. if($mInfo["date_change_is_direct"] <>'t'){
  1150. //代表信息为转船信息,title要处理一下: leg 1/3 ETD Change
  1151. $title = substr($mInfo["date_change_name"],8);
  1152. $route = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
  1153. $leg = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"]);
  1154. if($mInfo["delay_current"] == "2"){
  1155. $leg = array($mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
  1156. }
  1157. }
  1158. $updated_date = $mInfo["date_change_updated_date"]." ".$mInfo["date_change_updated_time"];
  1159. $original_date = $mInfo["date_change_original_date"]." ".$mInfo["date_change_original_time"];
  1160. $eventCard = array("type" =>'change',
  1161. "numericRecords"=>0,
  1162. "isRead"=>$mInfo["is_send_message"] == 't' ? true : false,
  1163. "title"=>$title,
  1164. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1165. "no"=>$mInfo["h_bol"],
  1166. "tag"=>$mInfo["date_change_name"],
  1167. "location"=>"",
  1168. "timezone"=>$mInfo["date_change_timezone"],
  1169. "time"=>$original_date,
  1170. "timeLabel"=>$outsideTimeLabel,
  1171. "previous"=>"",
  1172. "frequency_type"=>$mInfo["frequency_type"],
  1173. "serial_no"=>$mInfo["serial_no"],
  1174. "order_from"=>$mInfo["order_from"],
  1175. "id"=>$mInfo["id"],
  1176. "insert_date_format"=>'',
  1177. "info"=>array("route"=>$route,
  1178. "leg"=>$leg,
  1179. "etdOrdeparturNum"=>0,
  1180. "etaOrarrivalNum"=>0,
  1181. "time"=>$updated_date,
  1182. "timeLabel"=>$insideTimeLabel,
  1183. "delayTimeTip"=>"",
  1184. "timezone"=>$mInfo["date_change_timezone"]
  1185. ));
  1186. if ($mInfo["frequency_type"] == "Daily"){
  1187. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1188. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1189. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1190. $eventCard["title"] = "ETD/ETA Change Daily Summary(".$mInfo["insert_date_format"].")";
  1191. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1192. } else if($mInfo["frequency_type"] == "Weekly"){
  1193. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1194. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1195. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1196. $eventCard["title"] = "ETD/ETA Change Weekly Summary(".$mInfo["insert_date_format"].")";
  1197. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1198. }
  1199. }
  1200. return $eventCard;
  1201. }
  1202. /**
  1203. * 返回当前柜子的status信息描述,目前作废
  1204. */
  1205. public static function getContainerStatusDesc($ctnr_status_code){
  1206. $event =common::getEDICtnrEvent();
  1207. $ctnrStatusdesc = "";
  1208. foreach($event as $e){
  1209. if($e['event_name'] == $ctnr_status_code){
  1210. $ctnrStatusdesc = $e['description'];
  1211. }
  1212. }
  1213. return $ctnrStatusdesc;
  1214. }
  1215. }
  1216. ?>