tools.class.php 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704
  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 desc";
  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. //检查参数是否正常
  193. $err = $this->checkedNotificationParam();
  194. if(!empty($err)){
  195. $data = array("msg" =>"Parameter error: ".$err);
  196. common::echo_json_encode(500,$data);
  197. exit();
  198. }
  199. $updateOrInsert = empty($exist) ? "insert" : "update";
  200. $sql = $this->getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,"Subscribe",$exist['id']);
  201. $rs = common::excuteUpdateSql($sql);
  202. if ($rs === FALSE){
  203. $data = array("msg" => "Update Error");
  204. } else{
  205. $data = array("msg" => "Update Successful");
  206. //返回addedRules 全部列表
  207. $subscribe_rule_sql = "select * from public.notifications_rules where notifications_type = 'Subscribe' and lower(user_login) = '".strtolower(_getLoginName())."' order by id";
  208. $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
  209. //整合拼接addedRules
  210. $addedRules = array();
  211. foreach($subscribe_rules as $addedRule){
  212. $addedRules[] = array(
  213. "id" =>$addedRule['id'],
  214. "Event" =>$addedRule['rules_type'],
  215. "Event Details" =>$addedRule['event_details'],
  216. "Frequency" =>$addedRule['frequency_display'],
  217. "Methods" =>$addedRule['method_display']);
  218. }
  219. $data['addedRules'] = array("tableData"=>$addedRules);
  220. }
  221. common::echo_json_encode(200,$data);
  222. exit();
  223. }
  224. if ($operate == "subscribe_notification_rules_delete"){
  225. $rules_type = common::check_input($_POST['rules_type']);
  226. $sql = "delete from notifications_rules where notifications_type = 'Subscribe'
  227. and rules_type = '$rules_type' and lower(user_login) = '".strtolower(_getLoginName())."'";
  228. common::excuteUpdateSql($sql);
  229. $data = array("msg" => "Delete Successful");
  230. common::echo_json_encode(200,$data);
  231. exit();
  232. }
  233. if ($operate == "subscribe_shipment"){
  234. $serial_no = common::deCode($_POST['serial_no'], 'D');
  235. $is_subscribe = common::check_input($_POST['is_subscribe']);
  236. if($is_subscribe == "true"){
  237. $exist = common::excuteOneSql("select user_login from public.kln_user_subscribed where lower(user_login) = '".strtolower(_getLoginName())."' and subscribed_serial_no = '$serial_no'");
  238. if(!empty($exist)){
  239. $data = array("msg" => "Subscribe exist,Please check");
  240. common::echo_json_encode(200,$data);
  241. exit();
  242. }
  243. $sql = "INSERT INTO public.kln_user_subscribed(user_login, subscribed_serial_no, create_user, create_time)
  244. VALUES ('"._getLoginName()."', '$serial_no', '"._getLoginName()."', now());";
  245. common::excuteUpdateSql($sql);
  246. $data = array("msg" => "Subscribe Successful");
  247. common::echo_json_encode(200,$data);
  248. exit();
  249. }else{
  250. //取消订阅
  251. $sql = "delete from public.kln_user_subscribed where lower(user_login) = '".strtolower(_getLoginName())."' and subscribed_serial_no = '$serial_no';";
  252. common::excuteUpdateSql($sql);
  253. $data = array("msg" => "Cancel Subscribe successfully");
  254. common::echo_json_encode(200,$data);
  255. exit();
  256. }
  257. }
  258. if ($operate == "subscribe_shipment_search"){
  259. $cp = common::check_input($_POST ['cp']); //current_page
  260. $ps = common::check_input($_POST ['ps']); //ps
  261. $arrTmp = $this->getSubscribeShipment($cp,$ps);
  262. common::echo_json_encode(200,$arrTmp);
  263. exit();
  264. }
  265. }
  266. public function user_monitoring_setting(){
  267. $operate = utils::_get('operate');
  268. $operate = strtolower($operate);
  269. if ($operate == "monitoring_rules_init"){
  270. $ret = array();
  271. //Milestone Update的页面配置数据
  272. $milestones = common::excuteListSql("select * from public.customer_service_milestone_sno order by type, sno");
  273. $oceanMilestone = array();
  274. $airMilestone = array();
  275. foreach($milestones as $milestone){
  276. if($milestone['type'] == "air"){
  277. $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  278. }
  279. if($milestone['type'] == "sea"){
  280. $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  281. }
  282. }
  283. $ret["OceanCheckBoxList"] = $oceanMilestone;
  284. $ret["AirCheckBoxList"] = $airMilestone;
  285. //Milestone Update的结构处理
  286. //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  287. //$event =common::getEDICtnrEvent();
  288. $event = common::excuteListSql("select ra_name as event_name,ra_order,description
  289. from public.ra_online_edi_event e
  290. where e.ra_name in('I','VD','VA','UV','AL','AR','OA','RD') order by e.ra_order desc");
  291. $ctnrStatus = array();
  292. foreach($event as $e){
  293. $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
  294. }
  295. $ret["CtnrCheckBoxList"] = $ctnrStatus;
  296. common::echo_json_encode(200,$ret);
  297. exit();
  298. }
  299. if ($operate == "monitoring_rules_search") {
  300. $cp = common::check_input($_POST ['cp']); //current_page
  301. $ps = common::check_input($_POST ['ps']); //ps
  302. if (empty($ps))
  303. $ps = 15;
  304. $sql = "select count(1) from public.notifications_rules where lower(user_login) = '".strtolower(_getLoginName())."' and notifications_type = 'Monitoring'";
  305. $rc = common::excuteOneSql($sql);
  306. $tp = ceil($rc / $ps);
  307. if ($rc > 0) {
  308. $sql = "select *,replace(rules_type, '_', ' ') AS _rules_type_display,
  309. case when rules_type = 'Milestone_Update' then 'Milestone'
  310. when rules_type = 'Container_Status_Update' then 'Container'
  311. when rules_type = 'Departure/Arrival_Delay' then 'Departure'
  312. when rules_type = 'ETD/ETA_Change' then 'ETDChange'
  313. else '' end as notifications_option
  314. from public.notifications_rules
  315. where lower(user_login) = '".strtolower(_getLoginName())."'
  316. and notifications_type = 'Monitoring' order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  317. $monitoringRules = common::excuteListSql($sql);
  318. $arrTmp = array('monitoringRules' => $monitoringRules,
  319. 'rc' => intval($rc),
  320. 'ps' => intval($ps),
  321. 'cp' => intval($cp),
  322. 'tp' => intval($tp)
  323. );
  324. } else {
  325. $arrTmp = array('monitoringRules' => array(),
  326. 'rc' => intval($rc),
  327. 'ps' => intval($ps),
  328. 'cp' => intval($cp),
  329. 'tp' => intval($tp)
  330. );
  331. }
  332. common::echo_json_encode(200,$arrTmp);
  333. exit();
  334. }
  335. if ($operate == "monitoring_rules_edit"){
  336. $id = $_POST['id'];
  337. $rules_type = common::check_input($_POST['rules_type']);
  338. $subscribe_rule_sql = "select *,
  339. TO_CHAR(daily_time, 'HH24:MI') as _daily_time,
  340. TO_CHAR(weekly_time, 'HH24:MI') as _weekly_time,
  341. case when rules_type = 'Milestone_Update' then 'Milestone'
  342. when rules_type = 'Container_Status_Update' then 'Container'
  343. when rules_type = 'Departure/Arrival_Delay' then 'Departure'
  344. when rules_type = 'ETD/ETA_Change' then 'ETDChange'
  345. else '' end as notifications_option
  346. from public.notifications_rules where notifications_type = 'Monitoring' and lower(user_login) = '".strtolower(_getLoginName())."'
  347. and id = '$id' order by id";
  348. $subscribe_rules = common::excuteListSql($subscribe_rule_sql);
  349. $rules = $this->getSubscribeRules($rules_type,$subscribe_rules);
  350. //数据转换前端需要的显示的格式
  351. $rules["shipment_transport_mode"] = utils::converModeToDisplay($rules["shipment_transport_mode"]);
  352. $monitoring_data[$rules_type] = $rules;
  353. common::echo_json_encode(200,$monitoring_data);
  354. exit();
  355. }
  356. if ($operate == "monitoring_rules_do") {
  357. $rules_type = common::check_input($_POST["rules_type"]);
  358. //检查参数是否正常
  359. $err = $this->checkedNotificationParam();
  360. if(!empty($err)){
  361. $data = array("msg" =>"Parameter error: ".$err);
  362. common::echo_json_encode(500,$data);
  363. exit();
  364. }
  365. //检查编辑提交的Monitoring规则,是否允许保存
  366. $msg = $this->checkedMonitoringRulesSave($rules_type);
  367. if(!empty($msg)){
  368. $data = array("msg" =>$msg);
  369. common::echo_json_encode(200,$data);
  370. exit();
  371. }
  372. $updateOrInsert = "insert";
  373. if(isset($_POST['id']) && !empty($_POST['id'])){
  374. $updateOrInsert = "update";
  375. }
  376. $sql = $this->getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,"Monitoring",$_POST['id']);
  377. $rs = common::excuteUpdateSql($sql);
  378. if ($rs === FALSE){
  379. $data = array("msg" => "Update Error");
  380. } else{
  381. $data = array("msg" => "Update Successful");
  382. }
  383. common::echo_json_encode(200,$data);
  384. exit();
  385. }
  386. if ($operate == "monitoring_rules_delete"){
  387. $id = common::check_input($_POST['id']);
  388. $sql = "delete from notifications_rules where notifications_type = 'Monitoring'
  389. and lower(user_login) = '".strtolower(_getLoginName())."' and id = '$id'";
  390. common::excuteUpdateSql($sql);
  391. $data = array("msg" => "Delete Successful");
  392. common::echo_json_encode(200,$data);
  393. exit();
  394. }
  395. }
  396. public function notifications_rules(){
  397. $operate = utils::_get('operate');
  398. $operate = strtolower($operate);
  399. if ($operate == "notifications_init"){
  400. $rules_type = common::check_input($_REQUEST['rules_type']);
  401. $milestoneData = array();
  402. $containerData = array();
  403. $delayData = array();
  404. $changeData = array();
  405. if ($rules_type == "all"){
  406. $rules_type = "Milestone_Update;Container_Status_Update;Departure/Arrival_Delay;ETD/ETA_Change;Feature_Update;Passwond_Notifcations";
  407. $allData = $this->getNotifications($rules_type,"all");
  408. $milestoneData = $allData['Milestone_Update'];
  409. $containerData = $allData['Container_Status_Update'];
  410. $delayData = $allData['Departure/Arrival_Delay'];
  411. $changeData = $allData['ETD/ETA_Change'];
  412. $featureUpdate = $allData['Feature_Update'];
  413. $passwond_Notifcations = $allData['Passwond_Notifcations'];
  414. } else {
  415. $data = $this->getNotifications($rules_type,"all");
  416. if($rules_type == "Milestone_Update"){
  417. $milestoneData = $data['Milestone_Update'];
  418. }elseif($rules_type == "Container_Status_Update"){
  419. $containerData = $data['Container_Status_Update'];
  420. }elseif($rules_type == "Departure/Arrival_Delay"){
  421. $delayData = $data['Departure/Arrival_Delay'];
  422. }elseif($rules_type == "ETD/ETA_Change"){
  423. $changeData = $data['ETD/ETA_Change'];
  424. }elseif($rules_type == "Feature_Update"){
  425. $featureUpdate = $data['Feature_Update'];
  426. }elseif($rules_type == "Passwond_Notifcations"){
  427. $passwond_Notifcations = $data['Passwond_Notifcations'];
  428. }
  429. }
  430. $data = array("milestoneData"=>$milestoneData,"containerData"=>$containerData,"delayData"=>$delayData,
  431. "changeData"=>$changeData,"featureUpdate"=>$featureUpdate,"passwond_Notifcations"=>$passwond_Notifcations);
  432. $instant_sum = array();
  433. foreach($data as $v){
  434. if(!empty($v['instant'])){
  435. foreach($v['instant'] as $instant){
  436. $instant_sum[] = $instant;
  437. }
  438. }
  439. if(!empty($v['daily'])){
  440. $dailys = common::handleDailyWeekedData($v['daily']);
  441. foreach($dailys as $dailyArr){
  442. //取第一组的第一个显示
  443. $dailyFristAndFrist = utils::getDailyAndweeklyFrist($dailyArr);
  444. $instant_sum[]= $dailyFristAndFrist;
  445. }
  446. }
  447. if(!empty($v['weekly'])){
  448. $weeklys = common::handleDailyWeekedData($v['weekly']);
  449. foreach($weeklys as $weeklyArr){
  450. $weeklyFristAndFrist = utils::getDailyAndweeklyFrist($weeklyArr);
  451. $instant_sum[]= $weeklyFristAndFrist;
  452. }
  453. }
  454. }
  455. //根据时间顺序排序
  456. $insert_dates = array_column($instant_sum, 'insert_date');
  457. array_multisort($insert_dates, SORT_DESC, $instant_sum);
  458. $info = array();
  459. foreach($instant_sum as $mInfo){
  460. $eventCard = $this->getEventCard($mInfo);
  461. if(!empty($mInfo['other_type']) && $mInfo['other_type'] == "password"){
  462. $info[] = array("notificationType"=>"password","info" =>$eventCard);
  463. }elseif(!empty($mInfo['other_type']) && $mInfo['other_type'] == "feature"){
  464. $info[] = array("notificationType"=>"feature","info" =>$eventCard);
  465. }else{
  466. $info[] = array("notificationType"=>"event","info" =>$eventCard);
  467. }
  468. }
  469. $returnData = $info;
  470. common::echo_json_encode(200,$returnData);
  471. exit();
  472. }
  473. if($operate == "notifications_see_all"){
  474. $rules_type = common::check_input($_REQUEST['rules_type']);
  475. $frequency_type = common::check_input($_REQUEST['frequency_type']); //这个只会传daily 和weekly
  476. $insert_date_format = common::check_input($_REQUEST['insert_date_format']);
  477. $notificationsData = $this->getNotifications($rules_type,$frequency_type,$insert_date_format);
  478. $moreData = $notificationsData[$rules_type][strtolower($frequency_type)];
  479. //这个函数里面带有分开计数的信息
  480. $dataInfo =utils::getDailyAndweeklyFrist($moreData);
  481. $returnData = array();
  482. $notificationList = array();
  483. $ids = array();
  484. foreach($moreData as $key => $data){
  485. $eventCard = $this->getEventCard($data);
  486. //sea all的数据格式和查询全部的格式有区别
  487. if($key == 0){
  488. $returnData["title"] = $eventCard["title"];
  489. if($eventCard["type"] == "change" || $eventCard["type"] == "delay"){
  490. $returnData["etdOrdeparturNum"] = $dataInfo["numericRecords_one"];
  491. $returnData["etaOrarrivalNum"] =$dataInfo["numericRecords_two"];
  492. $returnData["type"] =$eventCard["type"];
  493. }else{
  494. $returnData["numericRecords"] = $dataInfo["numericRecords"];
  495. }
  496. }
  497. //移除不需要的字段
  498. unset($eventCard["title"]);
  499. $notificationList[] = $eventCard;
  500. $ids[] = $data['id'];
  501. }
  502. if(!empty($notificationList)){
  503. $returnData["notificationList"] = $notificationList;
  504. }
  505. //点击seall会默认全部标记为已读
  506. if(!empty($ids)){
  507. $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$ids)));
  508. $markReadSql = "update public.kln_notifiation_info set is_send_message = now(),readed_date = now() where id in ($more_param)";
  509. common::excuteUpdateSql($markReadSql);
  510. }
  511. common::echo_json_encode(200,$returnData);
  512. exit();
  513. }
  514. if($operate == "notifications_read"){
  515. $read_type = common::check_input($_POST["read_type"]);
  516. $id = $_POST["id"];
  517. //代表改用户下的所有信息全部标记为已读
  518. if ($read_type == "true"){
  519. $rs = common::excuteUpdateSql("update public.kln_notifiation_info set is_send_message = now(),readed_date = now() where lower(user_login) = '".strtolower(_getLoginName())."'");
  520. }else{
  521. $more_param = common::getInNotInSqlForSearch(strtolower(utils::implode(';',$id)));
  522. $markReadSql = "update public.kln_notifiation_info set is_send_message = now(),readed_date = now() where id in ($more_param)";
  523. $rs = common::excuteUpdateSql($markReadSql);
  524. }
  525. if ($rs === FALSE){
  526. $returnData = array("msg" =>"Error");
  527. common::echo_json_encode(500,$returnData);
  528. }else{
  529. $returnData = array("msg" =>"Success");
  530. common::echo_json_encode(200,$returnData);
  531. }
  532. exit();
  533. }
  534. if ($operate == "notifications_message_init"){
  535. //查询所有情况得未读情况 查询最近一年的情况
  536. $unreadSql = "with countTbale as (
  537. select ni.notifiation_type,
  538. case when COALESCE(ni.frequency_type,'') = 'Daily'
  539. then to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY')
  540. when COALESCE(ni.frequency_type,'') = 'Weekly'
  541. then to_char(ni.insert_date::date - (((EXTRACT(dow FROM ni.insert_date)::integer - ni.weekly_week::integer + 7) % 7) ||' days')::INTERVAL,'Mon DD, YYYY')
  542. || ' - ' ||
  543. to_char(ni.insert_date::date + (((ni.weekly_week::integer - EXTRACT(dow FROM ni.insert_date)::integer + 7) % 7)-1 + CASE WHEN EXTRACT(DOW FROM ni.insert_date)::integer=ni.weekly_week::integer THEN 7 ELSE 0 END ||' days')::INTERVAL,'Mon DD, YYYY')
  544. else ''
  545. end as insert_date_format
  546. from public.kln_notifiation_info ni
  547. where ni.insert_date > NOW() - INTERVAL '1 year'
  548. and ni.notifications_method = 'true' and ni.is_send_message is null
  549. and lower(ni.user_login) = '".strtolower(_getLoginName())."'
  550. and ((ni.frequency_type = 'Daily'
  551. and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time
  552. and ni.insert_date::date <= CURRENT_DATE + ni.daily_time::time)
  553. or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  554. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
  555. and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time))
  556. group by ni.notifiation_type,insert_date_format
  557. union all
  558. select ni.notifiation_type, '' as insert_date_format
  559. from public.kln_notifiation_info ni
  560. where ni.insert_date > NOW() - INTERVAL '1 year'
  561. and lower(ni.user_login) in ('".strtolower(_getLoginName())."','all_user')
  562. and ni.notifications_method = 'true' and ni.is_send_message is null
  563. and frequency_type = 'Instant'
  564. )
  565. select
  566. sum(case when (1<>1 or (notifiation_type='Milestone_Update')) then 1 else 0 end) as m_rc,
  567. sum(case when (1<>1 or (notifiation_type='Container_Status_Update')) then 1 else 0 end) as cs_rc,
  568. sum(case when (1<>1 or (notifiation_type='Departure/Arrival_Delay')) then 1 else 0 end) as da_rc,
  569. sum(case when (1<>1 or (notifiation_type='ETD/ETA_Change')) then 1 else 0 end) as ec_rc,
  570. sum(case when (1<>1 or (notifiation_type='Feature_Update')) then 1 else 0 end) as f_rc
  571. from countTbale ";
  572. $count = common::excuteObjectSql($unreadSql);
  573. //单独的选中的数据
  574. $rules_type = common::check_input($_REQUEST['rules_type']);
  575. $data = $this->getNotifications($rules_type,"all");
  576. $unreadCount = 0;
  577. $readCount = 0;
  578. $instant_sum = array();
  579. if(!empty($data[$rules_type]['instant'])){
  580. foreach($data[$rules_type]['instant'] as $instant){
  581. $instant_sum[] = $instant;
  582. if(!empty($instant["is_send_message"])){
  583. $readCount +=1;
  584. }else{
  585. $unreadCount +=1;
  586. }
  587. }
  588. }
  589. if(!empty($data[$rules_type]['daily'])){
  590. $dailys = common::handleDailyWeekedData($data[$rules_type]['daily']);
  591. foreach($dailys as $dailyArr){
  592. //取第一组的第一个显示
  593. $dailyFristAndFrist = utils::getDailyAndweeklyFrist($dailyArr);
  594. $instant_sum[]= $dailyFristAndFrist;
  595. if(!empty($dailyFristAndFrist["is_send_message"])){
  596. $readCount +=1;
  597. }else{
  598. $unreadCount +=1;
  599. }
  600. }
  601. }
  602. if(!empty($data[$rules_type]['weekly'])){
  603. $weeklys = common::handleDailyWeekedData($data[$rules_type]['weekly']);
  604. foreach($weeklys as $weeklyArr){
  605. $weeklyFristAndFrist = utils::getDailyAndweeklyFrist($weeklyArr);
  606. $instant_sum[]= $weeklyFristAndFrist;
  607. if(!empty($weeklyFristAndFrist["is_send_message"])){
  608. $readCount +=1;
  609. }else{
  610. $unreadCount +=1;
  611. }
  612. }
  613. }
  614. //根据时间顺序排序
  615. $insert_dates = array_column($instant_sum, 'insert_date');
  616. array_multisort($insert_dates, SORT_DESC, $instant_sum);
  617. $info = array();
  618. foreach($instant_sum as $mInfo){
  619. $eventCard = $this->getEventCard($mInfo);
  620. if(!empty($mInfo['other_type']) && $mInfo['other_type'] == "password"){
  621. $info[] = array("notificationType"=>"password","info" =>$eventCard);
  622. }elseif(!empty($mInfo['other_type']) && $mInfo['other_type'] == "feature"){
  623. $info[] = array("notificationType"=>"feature","info" =>$eventCard);
  624. }else{
  625. $info[] = array("notificationType"=>"event","info" =>$eventCard);
  626. }
  627. }
  628. //返回数据结构
  629. $returnData = array();
  630. $m_rc = empty($count['m_rc']) ? 0 : intval($count['m_rc']);
  631. $cs_rc = empty($count['cs_rc']) ? 0 : intval($count['cs_rc']);
  632. $da_rc = empty($count['da_rc']) ? 0 : intval($count['da_rc']);
  633. $ec_rc = empty($count['ec_rc']) ? 0 : intval($count['ec_rc']);
  634. $f_rc = empty($count['f_rc']) ? 0 : intval($count['f_rc']);
  635. $returnData['countList'] = array($m_rc,$cs_rc,$da_rc,$ec_rc,$f_rc);
  636. $returnData['allCount'] =count($instant_sum);
  637. $returnData['unreadCount'] =$unreadCount;
  638. $returnData['readCount'] =$readCount;
  639. $returnData['cardList'] =$info;
  640. common::echo_json_encode(200,$returnData);
  641. exit();
  642. }
  643. if ($operate == "check_notifications_message"){
  644. $checkUnread = "select id
  645. from public.kln_notifiation_info ni
  646. where lower(ni.user_login) in ('".strtolower(_getLoginName())."','all_user')
  647. and (ni.frequency_type = 'Instant'
  648. or (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time
  649. and ni.insert_date::date <= CURRENT_DATE + ni.daily_time::time)
  650. or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  651. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
  652. and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time))
  653. and ni.notifications_method = true and is_send_message is null limit 1";
  654. $unread = common::excuteObjectSql($checkUnread);
  655. $returnData = array("has_message" =>!empty($unread));
  656. common::echo_json_encode(200,$returnData);
  657. }
  658. }
  659. /**
  660. * 遍历查找对应的rule。
  661. */
  662. public function getSubscribeRules($rule_name,$subscribe_rules){
  663. //初始是不显示,没有值的情况
  664. $ret = array("is_display" => false);
  665. foreach($subscribe_rules as $rules){
  666. if($rules['rules_type'] == $rule_name){
  667. $rules["is_display"] = true;
  668. $rules["daily_time"] = $rules["_daily_time"];
  669. $rules["weekly_time"] = $rules["_weekly_time"];
  670. $rules["weekly_week"] = common::getWeek($rules["weekly_week"]);
  671. //字符串转数字
  672. $rules["ocean_atd_sub_etd"] = common::convertoint($rules["ocean_atd_sub_etd"]);
  673. $rules["ocean_ata_sub_eta"] = common::convertoint($rules["ocean_ata_sub_eta"]);
  674. $rules["air_atd_sub_etd"] = common::convertoint($rules["air_atd_sub_etd"]);
  675. $rules["air_ata_sub_eta"] = common::convertoint($rules["air_ata_sub_eta"]);
  676. $rules["ocean_etd_old_sub_new"] = common::convertoint($rules["ocean_etd_old_sub_new"]);
  677. $rules["ocean_eta_old_sub_new"] = common::convertoint($rules["ocean_eta_old_sub_new"]);
  678. $rules["air_etd_old_sub_new"] = common::convertoint($rules["air_etd_old_sub_new"]);
  679. $rules["air_eta_old_sub_new"] = common::convertoint($rules["air_eta_old_sub_new"]);
  680. $rules["shipment_etd_limit"] = common::convertoint($rules["shipment_etd_limit"]);
  681. $rules["shipment_eta_limit"] = common::convertoint($rules["shipment_eta_limit"]);
  682. $rules["shipment_etd_limit_from"] = common::convertoint($rules["shipment_etd_limit_from"]);
  683. $rules["shipment_eta_limit_from"] = common::convertoint($rules["shipment_eta_limit_from"]);
  684. // $air_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  685. $rules["ocean_atd_sub_etd_unit"] = common::convertoVue($rules["ocean_atd_sub_etd_unit"]);
  686. $rules["ocean_ata_sub_eta_unit"] = common::convertoVue($rules["ocean_ata_sub_eta_unit"]);
  687. $rules["air_atd_sub_etd_unit"] = common::convertoVue($rules["air_atd_sub_etd_unit"]);
  688. $rules["air_ata_sub_eta_unit"] = common::convertoVue($rules["air_ata_sub_eta_unit"]);
  689. $rules["ocean_etd_old_sub_new_unit"] = common::convertoVue($rules["ocean_etd_old_sub_new_unit"]);
  690. $rules["ocean_eta_old_sub_new_unit"] = common::convertoVue($rules["ocean_eta_old_sub_new_unit"]);
  691. $rules["air_etd_old_sub_new_unit"] = common::convertoVue($rules["air_etd_old_sub_new_unit"]);
  692. $rules["air_eta_old_sub_new_unit"] = common::convertoVue($rules["air_eta_old_sub_new_unit"]);
  693. $ret = $rules;
  694. }
  695. }
  696. //Milestone Update的结构处理,处理init page load
  697. if($rule_name == "Milestone_Update"){
  698. //Milestone Update的页面配置数据
  699. $milestones = common::excuteListSql("select * from public.customer_service_milestone_sno order by type, sno");
  700. $oceanMilestone = array();
  701. $airMilestone = array();
  702. foreach($milestones as $milestone){
  703. if($milestone['type'] == "air"){
  704. $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  705. }
  706. if($milestone['type'] == "sea"){
  707. $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['code']);
  708. }
  709. }
  710. $ret["OceanCheckBoxList"] = $oceanMilestone;
  711. $ret["AirCheckBoxList"] = $airMilestone;
  712. $oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
  713. $airMilestoneSetting = !empty($ret['air_milestone']) ? explode(";",$ret['air_milestone']): array();
  714. $ret["OceanCheckedList"] = $oceanMilestoneSetting;
  715. $ret["AirCheckedList"] = $airMilestoneSetting;
  716. }
  717. //Milestone Update的结构处理
  718. if($rule_name == "Container_Status_Update"){
  719. //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  720. //$event =common::getEDICtnrEvent();
  721. $event = common::excuteListSql("select ra_name as event_name,ra_order,description
  722. from public.ra_online_edi_event e
  723. where e.ra_name in('I','VD','VA','UV','AL','AR','OA','RD') order by e.ra_order desc");
  724. $ctnrStatus = array();
  725. foreach($event as $e){
  726. $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['event_name']);
  727. }
  728. $ret["CtnrCheckBoxList"] = $ctnrStatus;
  729. $ctnrStatusSetting = !empty($ret['ocean_ctnr_status']) ? explode(";",$ret['ocean_ctnr_status']) : array();
  730. $ret["CtnrCheckedList"] = $ctnrStatusSetting;
  731. }
  732. return $ret;
  733. }
  734. /**
  735. * 查询对应用户订阅的shipment信息.可能存在分页查询,如果有需要就改正
  736. * cp current_page
  737. */
  738. public function getSubscribeShipment($cp,$ps){
  739. if (empty($cp)){
  740. $cp = 1;
  741. }
  742. if (empty($ps)){
  743. $ps = 15;
  744. }
  745. $sql = "select count(1) from public.kln_user_subscribed u
  746. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  747. where lower(user_login) = '".strtolower(_getLoginName())."'";
  748. $rc = common::excuteOneSql($sql);
  749. $tp = ceil($rc / $ps);
  750. if ($rc > 0) {
  751. $sql = "select o.serial_no,order_from as _schemas,o.h_bol,
  752. o.shipper,o.consignee,o.etd,o.eta,
  753. case when transport_mode = 'sea'
  754. then (select sn.description
  755. from public.ocean_milestone a
  756. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'sea'
  757. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  758. when transport_mode = 'air' and order_from = 'public'
  759. then (select sn.description
  760. from public.air_milestone a
  761. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  762. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  763. when transport_mode = 'air' and order_from = 'sfs'
  764. then (select sn.description
  765. from sfs.air_milestone a
  766. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  767. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  768. else '' end as recent_milestone
  769. from public.kln_user_subscribed u
  770. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  771. where lower(user_login) = '".strtolower(_getLoginName())."' order by u.id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  772. $subscribeShipment = common::excuteListSql($sql);
  773. foreach($subscribeShipment as $key => $val){
  774. $subscribeShipment[$key]["__serial_no"] = common::deCode($val['serial_no'], 'E');
  775. }
  776. $arrTmp = array('tableData' => $subscribeShipment,
  777. 'rc' => intval($rc),
  778. 'ps' => intval($ps),
  779. 'cp' => intval($cp),
  780. 'tp' => intval($tp)
  781. );
  782. } else {
  783. $arrTmp = array('tableData' => array(),
  784. 'rc' => intval($rc),
  785. 'ps' => intval($ps),
  786. 'cp' => intval($cp),
  787. 'tp' => intval($tp),
  788. );
  789. }
  790. return $arrTmp;
  791. }
  792. public function checkedNotificationParam(){
  793. $rules_type = common::check_input($_POST["rules_type"]);
  794. //先判断异常数据
  795. $msg = "";
  796. if ($rules_type == "Departure/Arrival_Delay"){
  797. $ocean_atd_sub_etd = common::check_input($_POST['ocean_atd_sub_etd']);
  798. if (!empty($ocean_atd_sub_etd) && ctype_digit($ocean_atd_sub_etd)) {
  799. $msg = "Ocean Delayed(ATD-ETD) is not Number";
  800. }
  801. $ocean_ata_sub_eta = common::check_input($_POST['ocean_ata_sub_eta']);
  802. if (!empty($ocean_ata_sub_eta) && ctype_digit($ocean_ata_sub_eta)) {
  803. $msg = "Ocean Delayed(ATA-ETA) is not Number";
  804. }
  805. $air_atd_sub_etd = common::check_input($_POST['air_atd_sub_etd']);
  806. if (!empty($air_atd_sub_etd) && ctype_digit($air_atd_sub_etd)) {
  807. $msg = "Air Delayed(ATD-ETD) is not Number";
  808. }
  809. $air_ata_sub_eta = common::check_input($_POST['air_ata_sub_eta']);
  810. if (!empty($air_ata_sub_eta) && ctype_digit($air_ata_sub_eta)) {
  811. $msg = "Air Delayed(ATA-ETA) is not Number";
  812. }
  813. }
  814. if ($rules_type == "ETD/ETA_Change"){
  815. $ocean_etd_old_sub_new = common::check_input($_POST['ocean_etd_old_sub_new']);
  816. if (!empty($ocean_etd_old_sub_new) && ctype_digit($ocean_etd_old_sub_new)) {
  817. $msg = "Ocean Notify(ETD) is not Number";
  818. }
  819. $ocean_eta_old_sub_new = common::check_input($_POST['ocean_eta_old_sub_new']);
  820. if (!empty($ocean_eta_old_sub_new) && ctype_digit($ocean_eta_old_sub_new)) {
  821. $msg = "Ocean Notify(ETA) is not Number";
  822. }
  823. $air_etd_old_sub_new = common::check_input($_POST['air_etd_old_sub_new']);
  824. if (!empty($air_etd_old_sub_new) && ctype_digit($air_etd_old_sub_new)) {
  825. $msg = "Air Notify(ETD) is not Number";
  826. }
  827. $air_eta_old_sub_new = common::check_input($_POST['air_eta_old_sub_new']);
  828. if (!empty($air_eta_old_sub_new) && ctype_digit($air_eta_old_sub_new)) {
  829. $msg = "Air Notify(ETA) is not Number";
  830. }
  831. }
  832. return $msg;
  833. }
  834. public function getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,$notifications_type,$id){
  835. $sql = "";
  836. //先删后加 这个逻辑有移除
  837. // if($updateOrInsert == "update"){
  838. // $sql.="delete from public.notifications_rules where rules_type = '$rules_type'
  839. // and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  840. // and id = '$id';";
  841. // }
  842. //这个几个参数是所有规则都有的参数
  843. $frequency_type = common::check_input($_POST['frequency_type']);
  844. $daily_time = "null";
  845. $daily_time_zone = "";
  846. $weekly_week = "";
  847. $weekly_time = "null";
  848. $weekly_time_zone = "";
  849. if(strtolower($frequency_type) == "daily"){
  850. $daily_time = "'".common::check_input($_POST['daily_time'])."'";
  851. $daily_time_zone = common::check_input($_POST['daily_time_zone']);
  852. } elseif (strtolower($frequency_type) == "weekly"){
  853. $weekly_week = common::check_input($_POST['weekly_week']);
  854. $weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
  855. $weekly_time_zone = common::check_input($_POST['weekly_time_zone']);
  856. }
  857. $method_by_email = !empty($_POST['method_by_email']) ? common::check_input($_POST['method_by_email']) : 'false';
  858. $method_by_message = !empty($_POST['method_by_message']) ? common::check_input($_POST['method_by_message']) : 'false';
  859. $event_details = common::check_input($_POST['event_details']);
  860. $frequency_display = common::check_input($_POST['frequency_display']);
  861. $method_display = common::check_input($_POST['method_display']);
  862. $shipment_detail = common::check_input($_POST['shipment_details']);
  863. //当规则是 Monitoring类型是,需要配置的range
  864. $shipment_transport_mode = "";
  865. $shipment_etd_limit = "";
  866. $shipment_eta_limit = "";
  867. $shipment_etd_limit_from = "";
  868. $shipment_eta_limit_from = "";
  869. if($notifications_type == "Monitoring"){
  870. $shipment_transport_mode = utils::converModeToDB($_POST['shipment_transport_mode']);
  871. $shipment_etd_limit = common::check_input($_POST['shipment_etd_limit']);
  872. $shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
  873. $shipment_etd_limit_from = common::check_input($_POST['shipment_etd_limit_from']);
  874. $shipment_eta_limit_from = common::check_input($_POST['shipment_eta_limit_from']);
  875. }
  876. if ($rules_type == "Milestone_Update"){
  877. $ocean_milestone = utils::implode(";",$_POST['ocean_milestone']);
  878. $air_milestone = utils::implode(";",$_POST['air_milestone']);
  879. //改为update 不在是删除后添加,为了保留原始顺序
  880. if ($updateOrInsert == "update"){
  881. $sql.="update public.notifications_rules set ocean_milestone = '$ocean_milestone',air_milestone = '$air_milestone',
  882. frequency_type = '$frequency_type',daily_time = $daily_time, daily_time_zone = '$daily_time_zone',
  883. weekly_week = '$weekly_week', weekly_time = $weekly_time, weekly_time_zone = '$weekly_time_zone', method_by_email = '$method_by_email',method_by_message = '$method_by_message',
  884. event_details = '$event_details', frequency_display = '$frequency_display', method_display = '$method_display', shipment_details = '$shipment_detail',
  885. shipment_transport_mode = '$shipment_transport_mode', shipment_etd_limit = '$shipment_etd_limit', shipment_eta_limit = '$shipment_eta_limit',
  886. shipment_etd_limit_from = '$shipment_etd_limit_from', shipment_eta_limit_from = '$shipment_eta_limit_from'
  887. where rules_type = '$rules_type'
  888. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  889. and id = '$id';";
  890. } else {
  891. $sql.="INSERT INTO public.notifications_rules(
  892. user_login, notifications_type, rules_type, ocean_milestone,
  893. air_milestone, frequency_type, daily_time, daily_time_zone,
  894. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  895. event_details, frequency_display, method_display,shipment_details,
  896. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit,shipment_etd_limit_from,shipment_eta_limit_from)
  897. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_milestone',
  898. '$air_milestone', '$frequency_type', $daily_time, '$daily_time_zone',
  899. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  900. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  901. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit','$shipment_etd_limit_from','$shipment_eta_limit_from');";
  902. }
  903. }
  904. if ($rules_type == "Container_Status_Update"){
  905. $ocean_ctnr_status = utils::implode(";",$_POST['ocean_ctnr_status']);
  906. //改为update 不在是删除后添加,为了保留原始顺序
  907. if ($updateOrInsert == "update"){
  908. $sql.="update public.notifications_rules set ocean_ctnr_status = '$ocean_ctnr_status',
  909. frequency_type = '$frequency_type',daily_time = $daily_time, daily_time_zone = '$daily_time_zone',
  910. weekly_week = '$weekly_week', weekly_time = $weekly_time, weekly_time_zone = '$weekly_time_zone', method_by_email = '$method_by_email',method_by_message = '$method_by_message',
  911. event_details = '$event_details', frequency_display = '$frequency_display', method_display = '$method_display', shipment_details = '$shipment_detail',
  912. shipment_transport_mode = '$shipment_transport_mode', shipment_etd_limit = '$shipment_etd_limit', shipment_eta_limit = '$shipment_eta_limit',
  913. shipment_etd_limit_from = '$shipment_etd_limit_from', shipment_eta_limit_from = '$shipment_eta_limit_from'
  914. where rules_type = '$rules_type'
  915. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  916. and id = '$id';";
  917. }else{
  918. $sql.="INSERT INTO public.notifications_rules(
  919. user_login, notifications_type, rules_type, ocean_ctnr_status,
  920. frequency_type, daily_time, daily_time_zone,
  921. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  922. event_details, frequency_display, method_display,shipment_details,
  923. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit,shipment_etd_limit_from,shipment_eta_limit_from)
  924. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_ctnr_status',
  925. '$frequency_type', $daily_time, '$daily_time_zone',
  926. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  927. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  928. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit','$shipment_etd_limit_from','$shipment_eta_limit_from');";
  929. }
  930. }
  931. if ($rules_type == "Departure/Arrival_Delay"){
  932. $ocean_atd_sub_etd = common::check_input($_POST['ocean_atd_sub_etd']);
  933. $ocean_atd_sub_etd_unit = common::check_input($_POST['ocean_atd_sub_etd_unit']);
  934. if(!empty($ocean_atd_sub_etd_unit)){
  935. $ocean_atd_sub_etd_unit = $ocean_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  936. }
  937. $ocean_ata_sub_eta = common::check_input($_POST['ocean_ata_sub_eta']);
  938. $ocean_ata_sub_eta_unit = common::check_input($_POST['ocean_ata_sub_eta_unit']);
  939. if(!empty($ocean_ata_sub_eta_unit)){
  940. $ocean_ata_sub_eta_unit = $ocean_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  941. }
  942. $air_atd_sub_etd = common::check_input($_POST['air_atd_sub_etd']);
  943. $air_atd_sub_etd_unit = common::check_input($_POST['air_atd_sub_etd_unit']);
  944. if(!empty($air_atd_sub_etd_unit)){
  945. $air_atd_sub_etd_unit = $air_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  946. }
  947. $air_ata_sub_eta = common::check_input($_POST['air_ata_sub_eta']);
  948. $air_ata_sub_eta_unit = common::check_input($_POST['air_ata_sub_eta_unit']);
  949. if(!empty($air_ata_sub_eta_unit)){
  950. $air_ata_sub_eta_unit = $air_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  951. }
  952. //改为update 不在是删除后添加,为了保留原始顺序
  953. if ($updateOrInsert == "update"){
  954. $sql.="update public.notifications_rules set
  955. ocean_atd_sub_etd = '$ocean_atd_sub_etd',ocean_atd_sub_etd_unit = '$ocean_atd_sub_etd_unit',
  956. ocean_ata_sub_eta = '$ocean_ata_sub_eta',ocean_ata_sub_eta_unit = '$ocean_ata_sub_eta_unit',
  957. air_atd_sub_etd = '$air_atd_sub_etd',air_atd_sub_etd_unit = '$air_atd_sub_etd_unit',
  958. air_ata_sub_eta = '$air_ata_sub_eta',air_ata_sub_eta_unit = '$air_ata_sub_eta_unit',
  959. frequency_type = '$frequency_type',daily_time = $daily_time, daily_time_zone = '$daily_time_zone',
  960. weekly_week = '$weekly_week', weekly_time = $weekly_time, weekly_time_zone = '$weekly_time_zone', method_by_email = '$method_by_email',method_by_message = '$method_by_message',
  961. event_details = '$event_details', frequency_display = '$frequency_display', method_display = '$method_display', shipment_details = '$shipment_detail',
  962. shipment_transport_mode = '$shipment_transport_mode', shipment_etd_limit = '$shipment_etd_limit', shipment_eta_limit = '$shipment_eta_limit',
  963. shipment_etd_limit_from = '$shipment_etd_limit_from', shipment_eta_limit_from = '$shipment_eta_limit_from'
  964. where rules_type = '$rules_type'
  965. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  966. and id = '$id';";
  967. }else{
  968. $sql.="INSERT INTO public.notifications_rules(
  969. user_login, notifications_type, rules_type,
  970. ocean_atd_sub_etd, ocean_atd_sub_etd_unit,ocean_ata_sub_eta,ocean_ata_sub_eta_unit,
  971. air_atd_sub_etd, air_atd_sub_etd_unit,air_ata_sub_eta,air_ata_sub_eta_unit,
  972. frequency_type, daily_time, daily_time_zone,
  973. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  974. event_details, frequency_display, method_display,shipment_details,
  975. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit,shipment_etd_limit_from,shipment_eta_limit_from)
  976. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type',
  977. '$ocean_atd_sub_etd','$ocean_atd_sub_etd_unit','$ocean_ata_sub_eta','$ocean_ata_sub_eta_unit',
  978. '$air_atd_sub_etd','$air_atd_sub_etd_unit','$air_ata_sub_eta','$air_ata_sub_eta_unit',
  979. '$frequency_type', $daily_time, '$daily_time_zone',
  980. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  981. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  982. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit','$shipment_etd_limit_from','$shipment_eta_limit_from');";
  983. }
  984. }
  985. if ($rules_type == "ETD/ETA_Change"){
  986. $ocean_etd_change = !empty($_POST['ocean_etd_change']) ? common::check_input($_POST['ocean_etd_change']) : 'false';
  987. $ocean_etd_old_sub_new = common::check_input($_POST['ocean_etd_old_sub_new']);
  988. $ocean_etd_old_sub_new_unit = common::check_input($_POST['ocean_etd_old_sub_new_unit']);
  989. if(!empty($ocean_etd_old_sub_new_unit)){
  990. $ocean_etd_old_sub_new_unit = $ocean_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  991. }
  992. $ocean_eta_change = !empty($_POST['ocean_eta_change']) ? common::check_input($_POST['ocean_eta_change']) : 'false';
  993. $ocean_eta_old_sub_new = common::check_input($_POST['ocean_eta_old_sub_new']);
  994. $ocean_eta_old_sub_new_unit = common::check_input($_POST['ocean_eta_old_sub_new_unit']);
  995. if(!empty($ocean_eta_old_sub_new_unit)){
  996. $ocean_eta_old_sub_new_unit = $ocean_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  997. }
  998. $air_etd_change = !empty($_POST['air_etd_change']) ? common::check_input($_POST['air_etd_change']) : 'false';
  999. $air_etd_old_sub_new = common::check_input($_POST['air_etd_old_sub_new']);
  1000. $air_etd_old_sub_new_unit = common::check_input($_POST['air_etd_old_sub_new_unit']);
  1001. if(!empty($air_etd_old_sub_new_unit)){
  1002. $air_etd_old_sub_new_unit = $air_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  1003. }
  1004. $air_eta_change = !empty($_POST['air_eta_change']) ? common::check_input($_POST['air_eta_change']): 'false';
  1005. $air_eta_old_sub_new = common::check_input($_POST['air_eta_old_sub_new']);
  1006. $air_eta_old_sub_new_unit = common::check_input($_POST['air_eta_old_sub_new_unit']);
  1007. if(!empty($air_eta_old_sub_new_unit)){
  1008. $air_eta_old_sub_new_unit = $air_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  1009. }
  1010. //改为update 不在是删除后添加,为了保留原始顺序
  1011. if ($updateOrInsert == "update"){
  1012. $sql.="update public.notifications_rules set
  1013. ocean_etd_change = '$ocean_etd_change',ocean_etd_old_sub_new = '$ocean_etd_old_sub_new',ocean_etd_old_sub_new_unit = '$ocean_etd_old_sub_new_unit',
  1014. ocean_eta_change = '$ocean_eta_change',ocean_eta_old_sub_new = '$ocean_eta_old_sub_new',ocean_eta_old_sub_new_unit = '$ocean_eta_old_sub_new_unit',
  1015. air_etd_change = '$air_etd_change',air_etd_old_sub_new = '$air_etd_old_sub_new',air_etd_old_sub_new_unit = '$air_etd_old_sub_new_unit',
  1016. air_eta_change = '$air_eta_change',air_eta_old_sub_new = '$air_eta_old_sub_new',air_eta_old_sub_new_unit = '$air_eta_old_sub_new_unit',
  1017. frequency_type = '$frequency_type',daily_time = $daily_time, daily_time_zone = '$daily_time_zone',
  1018. weekly_week = '$weekly_week', weekly_time = $weekly_time, weekly_time_zone = '$weekly_time_zone', method_by_email = '$method_by_email',method_by_message = '$method_by_message',
  1019. event_details = '$event_details', frequency_display = '$frequency_display', method_display = '$method_display', shipment_details = '$shipment_detail',
  1020. shipment_transport_mode = '$shipment_transport_mode', shipment_etd_limit = '$shipment_etd_limit', shipment_eta_limit = '$shipment_eta_limit',
  1021. shipment_etd_limit_from = '$shipment_etd_limit_from', shipment_eta_limit_from = '$shipment_eta_limit_from'
  1022. where rules_type = '$rules_type'
  1023. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  1024. and id = '$id';";
  1025. }else{
  1026. $sql.="INSERT INTO public.notifications_rules(
  1027. user_login, notifications_type, rules_type,
  1028. 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,
  1029. 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,
  1030. frequency_type, daily_time, daily_time_zone,
  1031. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  1032. event_details, frequency_display, method_display,shipment_details,
  1033. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit,shipment_etd_limit_from,shipment_eta_limit_from)
  1034. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type',
  1035. '$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',
  1036. '$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',
  1037. '$frequency_type', $daily_time, '$daily_time_zone',
  1038. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  1039. '$event_details', '$frequency_display', '$method_display','$shipment_detail',
  1040. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit','$shipment_etd_limit_from','$shipment_eta_limit_from');";
  1041. }
  1042. }
  1043. return $sql;
  1044. }
  1045. /**
  1046. * 检查编辑提交的Monitoring规则,是否允许保存
  1047. */
  1048. public function checkedMonitoringRulesSave($rules_type){
  1049. $sql_where = "";
  1050. if(isset($_POST['id']) && !empty($_POST['id'])){
  1051. $sql_where = " and id <> '".common::check_input($_POST['id'])."'";
  1052. }
  1053. $rules = common::excuteListSql("select *,
  1054. TO_CHAR(daily_time, 'HH24:MI') as _daily_time,
  1055. TO_CHAR(weekly_time, 'HH24:MI') as _weekly_time
  1056. from public.notifications_rules where notifications_type = 'Monitoring' and rules_type = '".$rules_type."'
  1057. and lower(user_login) = '".strtolower(_getLoginName())."' $sql_where");
  1058. foreach($rules as $rule){
  1059. //判断range 是否一样
  1060. $checkRangeFiled = array("shipment_transport_mode","shipment_etd_limit","shipment_eta_limit","shipment_etd_limit_from","shipment_eta_limit_from");
  1061. $range_flag = true;
  1062. foreach($checkRangeFiled as $filed){
  1063. if($filed == "shipment_transport_mode"){
  1064. $postValue = utils::converModeToDB($_POST[$filed]);
  1065. $rule_mode_arr = explode(";", $rule[$filed]);
  1066. $post_mode_arr = explode(";", $postValue);
  1067. if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
  1068. $range_flag = false;
  1069. }
  1070. }else{
  1071. //正常字段直接比较就行
  1072. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  1073. $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
  1074. if($postValue != $dbValue){
  1075. $range_flag = false;
  1076. }
  1077. }
  1078. }
  1079. //判断details 是否一样
  1080. $checkDetailsFiled = array("ocean_milestone","air_milestone","ocean_ctnr_status",
  1081. "ocean_atd_sub_etd","ocean_atd_sub_etd_unit","ocean_ata_sub_eta","ocean_ata_sub_eta_unit",
  1082. "air_atd_sub_etd","air_atd_sub_etd_unit","air_ata_sub_eta","air_ata_sub_eta_unit",
  1083. "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",
  1084. "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");
  1085. $details_flag = true;
  1086. foreach($checkDetailsFiled as $filed){
  1087. if($filed == "ocean_milestone" || $filed == "air_milestone" || $filed == "ocean_ctnr_status"){
  1088. $rule_mode_arr = empty($rule[$filed])? array() :explode(";", $rule[$filed]);
  1089. $post_mode_arr = $_POST[$filed];
  1090. if(!utils::compareArrayEq($post_mode_arr,$rule_mode_arr)){
  1091. $details_flag = false;
  1092. }
  1093. } elseif ($filed == "ocean_etd_change" || $filed == "ocean_eta_change" || $filed == "air_etd_change" || $filed == "air_eta_change"){
  1094. $post_boolean = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f":"t";
  1095. if($post_boolean != $rule[$filed]){
  1096. $details_flag = false;
  1097. }
  1098. } elseif ($filed == "ocean_atd_sub_etd_unit" || $filed == "ocean_ata_sub_eta_unit"
  1099. || $filed == "air_atd_sub_etd_unit" || $filed == "air_ata_sub_eta_unit"
  1100. || $filed == "ocean_etd_old_sub_new_unit" || $filed == "ocean_eta_old_sub_new_unit"
  1101. || $filed == "air_etd_old_sub_new_unit" || $filed == "air_eta_old_sub_new_unit"){
  1102. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  1103. if(!empty($postValue)){
  1104. $postValue = $postValue=="Day(s)" ? "days":"hours";
  1105. }
  1106. $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
  1107. if($postValue != $dbValue){
  1108. $details_flag = false;
  1109. }
  1110. } else {
  1111. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  1112. $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
  1113. if($postValue != $dbValue){
  1114. $details_flag = false;
  1115. }
  1116. }
  1117. }
  1118. //判断frequency 是否一样
  1119. $checkFrequencyFiled = array("frequency_type","daily_time","daily_time_zone",
  1120. "weekly_week","weekly_time","weekly_time_zone","daily_time_zone");
  1121. $frequency_flag = true;
  1122. foreach($checkFrequencyFiled as $filed){
  1123. if($filed == "daily_time" || $filed == "weekly_time"){
  1124. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  1125. //_daily_time _weekly_time
  1126. $dbValue = !empty($rule["_".$filed]) ? $rule["_".$filed] : "";
  1127. if($postValue != $dbValue){
  1128. $frequency_flag = false;
  1129. }
  1130. } else {
  1131. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  1132. $dbValue = !empty($rule[$filed]) ? $rule[$filed] : "";
  1133. if($postValue != $dbValue){
  1134. $frequency_flag = false;
  1135. }
  1136. }
  1137. }
  1138. //判断通知方式是否一样
  1139. $checkMethodFiled = array("method_by_email","method_by_message");
  1140. $method_flag = true;
  1141. foreach($checkMethodFiled as $filed){
  1142. $postValue = (empty($_POST[$filed]) || $_POST[$filed] == "false") ? "f" : "t";
  1143. if($postValue != $rule[$filed]){
  1144. $method_flag = false;
  1145. }
  1146. }
  1147. //五个条件一样,不允许保存
  1148. if($range_flag && $details_flag && $frequency_flag && $method_flag){
  1149. $msg = "Unable to Save";
  1150. break;
  1151. }
  1152. //前三个重回,后面不重合,提示但允许保存
  1153. if($range_flag && $details_flag && $_POST['is_similar_rule'] <> 'true'){
  1154. $msg = "Similar Rule Detected";
  1155. break;
  1156. }
  1157. }
  1158. return $msg;
  1159. }
  1160. public function getNotifications($notifiation_type,$frequency_type,$insert_date_format = null){
  1161. if ($frequency_type == "all"){
  1162. $sql_where = " and (ni.frequency_type = 'Instant'
  1163. or (ni.frequency_type = 'Daily'
  1164. and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time
  1165. and ni.insert_date::date <= CURRENT_DATE + ni.daily_time::time)
  1166. or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  1167. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
  1168. and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time))";
  1169. } elseif($frequency_type == "Daily"){
  1170. $sql_where = " and (ni.frequency_type = 'Daily'
  1171. and timezone(ni.daily_time_zone, NOW()::time) >= ni.daily_time::time
  1172. and ni.insert_date::date <= CURRENT_DATE + ni.daily_time::time)";
  1173. } elseif($frequency_type == "Weekly"){
  1174. $sql_where = " and (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  1175. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'
  1176. and ni.insert_date::date <= CURRENT_DATE + ni.weekly_time::time)";
  1177. }
  1178. if (!empty($_REQUEST['current_time'])){
  1179. // $sql_where .= " and ni.insert_date >= TO_TIMESTAMP('".$_REQUEST['current_time']."', 'MM/DD/YYYY HH24:MI:SS') - interval '5 minutes'
  1180. // and ni.is_send_message is null";
  1181. //这里都以服务器时间,检查标准
  1182. $sql_where .= " and ni.insert_date >= now() - interval '5 minutes'
  1183. and ni.is_send_message is null";
  1184. }
  1185. if (!empty($_REQUEST['info_type']) && $_REQUEST['info_type'] == 'true'){
  1186. $sql_where .= " and ni.is_send_message is null";
  1187. }
  1188. //这里的查询会把不同日期的但hbol相同的信息,过滤掉只剩下最新的那一条。所以移除
  1189. $aa_where = "";
  1190. if (!empty($insert_date_format)){
  1191. $aa_where = " where insert_date_format = '$insert_date_format'";
  1192. }
  1193. $more_param = common::getInNotInSqlForSearch($notifiation_type);
  1194. $sql = "select *
  1195. from (select ni.*,
  1196. case when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'days'
  1197. then (EXTRACT(DAY FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp)))
  1198. when ni.notifiation_type = 'Departure/Arrival_Delay' and ni.delay_unit = 'hours'
  1199. then (FLOOR(EXTRACT(epoch FROM ((delay_act_date||' '||delay_act_time)::timestamp - (delay_est_date||' '||delay_est_time)::timestamp))/3600))
  1200. else 0
  1201. end as _delay_diff,
  1202. case when COALESCE(ni.frequency_type,'') = 'Daily'
  1203. then to_char(timezone(ni.daily_time_zone, ni.insert_date),'Mon DD, YYYY')
  1204. when COALESCE(ni.frequency_type,'') = 'Weekly'
  1205. then to_char(ni.insert_date::date - (((EXTRACT(dow FROM ni.insert_date)::integer - ni.weekly_week::integer + 7) % 7) ||' days')::INTERVAL,'Mon DD, YYYY')
  1206. || ' - ' ||
  1207. to_char(ni.insert_date::date + (((ni.weekly_week::integer - EXTRACT(dow FROM ni.insert_date)::integer + 7) % 7)-1 + CASE WHEN EXTRACT(DOW FROM ni.insert_date)::integer=ni.weekly_week::integer THEN 7 ELSE 0 END ||' days')::INTERVAL,'Mon DD, YYYY')
  1208. else ''
  1209. end as insert_date_format,
  1210. case when ni.notifiation_type ='Milestone_Update'
  1211. then public.getPreviousMilestone(ni.serial_no,ni.milestone_code,ccc.transport_mode,ccc.order_from)
  1212. else ''
  1213. end as milestone_previous_json,
  1214. case when ni.notifiation_type ='Container_Status_Update'
  1215. then public.getPreviousCtnrStatus(ni.serial_no,ni.ctnr,ni.ctnr_status_code)
  1216. else ''
  1217. end as ctnr_previous_json,
  1218. case when ni.notifiation_type ='Container_Status_Update'
  1219. then (select description
  1220. from public.ra_online_edi_event e where e.ra_name = ni.ctnr_status_code limit 1)
  1221. else ''
  1222. end as ctnr_desc,
  1223. ccc.order_from,ccc.h_bol,ccc.transport_mode
  1224. from public.kln_notifiation_info ni
  1225. left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from
  1226. from public.kln_ocean oo
  1227. where oo.serial_no = ni.serial_no limit 1) ccc on true
  1228. where lower(ni.user_login) in ('".strtolower(_getLoginName())."','all_user')
  1229. and lower(ni.notifiation_type) in ($more_param)
  1230. ".$sql_where." and ni.notifications_method = true order by ni.insert_date desc) aa $aa_where";
  1231. error_log($sql);
  1232. $data_all_type = common::excuteListSql($sql);
  1233. $data_group = array();
  1234. $data_group_uniqe = array();
  1235. foreach($data_all_type as $dat){
  1236. $uniqe_group_str = $dat['notifiation_type'];
  1237. if(utils::in_array($uniqe_group_str,$data_group_uniqe)){
  1238. $tempArr = $data_group[$uniqe_group_str];
  1239. $tempArr[] = $dat;
  1240. $data_group[$uniqe_group_str] = $tempArr;
  1241. } else {
  1242. $data_group[$uniqe_group_str] = array($dat);
  1243. $data_group_uniqe[] = $uniqe_group_str;
  1244. }
  1245. }
  1246. $retData = array();
  1247. foreach($data_group as $key => $data){
  1248. $notifiation_type_db = $key;
  1249. //统一处理数据Instant Daily weekly_week 先分开在处理
  1250. $instant = array();
  1251. $daily = array();
  1252. $daily_uniqe = array();
  1253. $weekly = array();
  1254. $weekly_uniqe = array();
  1255. foreach($data as $d){
  1256. if ($d['frequency_type'] == "Instant"){
  1257. $instant[] = $d;
  1258. }
  1259. //Daily 或者 Weekly类型为这个时才用这个去重,否则要加上描述(转船的情况,会让相同的HBOL显示)
  1260. $uniqe_str = $d['serial_no'];
  1261. if ($notifiation_type_db == "Milestone_Update"){
  1262. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['milestone_code'];
  1263. }else if ($notifiation_type_db == "Container_Status_Update"){
  1264. $uniqe_str = $d['ctnr']."_".$d['insert_date_format']."_".$d['ctnr_status_code'];
  1265. }else if($notifiation_type_db == "Departure/Arrival_Delay"){
  1266. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['delay_name'];
  1267. }else if($notifiation_type_db == "ETD/ETA_Change"){
  1268. $uniqe_str = $d['serial_no']."_".$d['insert_date_format']."_".$d['date_change_name'];
  1269. }
  1270. if ($d['frequency_type'] == "Daily"){
  1271. if(!utils::in_array($uniqe_str,$daily_uniqe)){
  1272. $daily[$uniqe_str] = $d;
  1273. $daily_uniqe[] = $uniqe_str;
  1274. }
  1275. }
  1276. if ($d['frequency_type'] == "Weekly"){
  1277. if(!utils::in_array($uniqe_str,$weekly_uniqe)){
  1278. $weekly[$uniqe_str] = $d;
  1279. $weekly_uniqe[] = $uniqe_str;
  1280. }
  1281. }
  1282. }
  1283. $retData[$key]= array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly));
  1284. }
  1285. return $retData;
  1286. }
  1287. public function getEventCard($mInfo){
  1288. $eventCard = array();
  1289. $notifiation_type = $mInfo['notifiation_type'];
  1290. if($notifiation_type == "Milestone_Update"){
  1291. $eventCard = array("type" =>'milestone',
  1292. "numericRecords"=>0,
  1293. "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
  1294. "title"=>"Milestone Update",
  1295. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1296. "no"=>$mInfo["h_bol"],
  1297. "tag"=>$mInfo["milestone_description"],
  1298. "location"=>$mInfo["milestone_locations"],
  1299. "timezone"=>$mInfo["milestone_timezone"],
  1300. "time"=>$mInfo["milestone_date"]." ".$mInfo["milestone_time"],
  1301. "timeLabel"=>"",
  1302. "previous"=>"",
  1303. "frequency_type"=>$mInfo["frequency_type"],
  1304. "serial_no"=>common::deCode($mInfo["serial_no"], 'E'),
  1305. "order_from"=>$mInfo["order_from"],
  1306. "id"=>$mInfo["id"],
  1307. "insert_date_format"=>'',
  1308. "rules_type"=>$mInfo["notifiation_type"],
  1309. "info"=>new stdClass());
  1310. if ($mInfo["frequency_type"] == "Daily"){
  1311. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1312. $eventCard["title"] = "Milestone Update Daily Summary(".$mInfo["insert_date_format"].")";
  1313. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1314. //seeall 的时候,前端不需要id
  1315. $eventCard["id"] = '';
  1316. $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
  1317. if(!empty($milestone_previous['milestone']['milestone_date'])){
  1318. $eventCard["previous"] = array("tag" =>"Previous:".$milestone_previous['milestone']['milestone_description']." from ".$milestone_previous['milestone']['locations'],
  1319. "date" => $milestone_previous['milestone']['milestone_date'],
  1320. "time" => $milestone_previous['milestone']['milestone_time'],
  1321. "timezone" =>$milestone_previous['milestone']['timezone']);
  1322. }
  1323. } else if($mInfo["frequency_type"] == "Weekly"){
  1324. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1325. $eventCard["title"] = "Milestone Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1326. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1327. //seeall 的时候,前端不需要id
  1328. $eventCard["id"] = '';
  1329. $milestone_previous = json_decode($mInfo["milestone_previous_json"],true);
  1330. if(!empty($milestone_previous['milestone']['milestone_date'])){
  1331. $eventCard["previous"] = array("tag" =>"Previous:".$milestone_previous['milestone']['milestone_description']." from ".$milestone_previous['milestone']['locations'],
  1332. "date" => $milestone_previous['milestone']['milestone_date'],
  1333. "time" => $milestone_previous['milestone']['milestone_time'],
  1334. "timezone" =>$milestone_previous['milestone']['timezone']);
  1335. }
  1336. }
  1337. }
  1338. if($notifiation_type == "Container_Status_Update"){
  1339. //当前状态的描述ctnr_desc
  1340. //$ctnrStatusdesc = $this->getContainerStatusDesc($mInfo["ctnr_status_code"]);
  1341. $eventCard = array("type" =>'container',
  1342. "numericRecords"=>0,
  1343. "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
  1344. "title"=>"Container_Status_Update",
  1345. "mode"=>"Ocean Freight",
  1346. "no"=>$mInfo["ctnr"],
  1347. "tag"=>$mInfo["ctnr_desc"],
  1348. "location"=>$mInfo["ctnr_status_locations"],
  1349. "timezone"=>$mInfo["ctnr_status_timezone"],
  1350. "time"=>$mInfo["ctnr_status_date"]." ".$mInfo["ctnr_status_time"],
  1351. "timeLabel"=>"",
  1352. "previous"=>"",
  1353. "frequency_type"=>$mInfo["frequency_type"],
  1354. "serial_no"=>common::deCode($mInfo["serial_no"], 'E'),
  1355. "order_from"=>$mInfo["order_from"],
  1356. "id"=>$mInfo["id"],
  1357. "insert_date_format"=>'',
  1358. "rules_type"=>$mInfo["notifiation_type"],
  1359. "info"=>new stdClass());
  1360. if ($mInfo["frequency_type"] == "Daily"){
  1361. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1362. $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
  1363. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1364. //seeall 的时候,前端不需要id
  1365. $eventCard["id"] = '';
  1366. $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
  1367. if(!empty($ctnr_previous["ctnrStatus"]["date"])){
  1368. //当前状态 前一个的描述
  1369. $eventCard["previous"] = array("tag" =>"Previous:" .$ctnr_previous["ctnrStatus"]["description"]. " from " .$ctnr_previous["ctnrStatus"]["locations"],
  1370. "date" => $ctnr_previous["ctnrStatus"]["date"],
  1371. "time" => $ctnr_previous["ctnrStatus"]["time"],
  1372. "timezone" =>$ctnr_previous["ctnrStatus"]["timezone"]);
  1373. }
  1374. } else if($mInfo["frequency_type"] == "Weekly"){
  1375. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1376. $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1377. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1378. //seeall 的时候,前端不需要id
  1379. $eventCard["id"] = '';
  1380. $ctnr_previous = json_decode($mInfo["ctnr_previous_json"],true);
  1381. if(!empty($ctnr_previous["ctnrStatus"]["date"])){
  1382. //当前状态 前一个的描述
  1383. $eventCard["previous"] = array("tag" =>"Previous:" .$ctnr_previous["ctnrStatus"]["description"]. " from " .$ctnr_previous["ctnrStatus"]["locations"],
  1384. "date" => $ctnr_previous["ctnrStatus"]["date"],
  1385. "time" => $ctnr_previous["ctnrStatus"]["time"],
  1386. "timezone" =>$ctnr_previous["ctnrStatus"]["timezone"]);
  1387. }
  1388. }
  1389. }
  1390. if($notifiation_type == "Departure/Arrival_Delay"){
  1391. //代表信息为转船信息,title要处理一下: leg 2/3 Departure_Delay => Departure_Delay
  1392. $title = $mInfo["delay_name"];
  1393. $outsideLocation = "";
  1394. $outsideTimezone = "";
  1395. $outsideTimeLabel= "";
  1396. $insideTimeLabel= "";
  1397. if(utils::checkExist($mInfo["delay_name"],"Departure_Delay")){
  1398. $outsideTimeLabel = "ETD";
  1399. $insideTimeLabel = "ATD";
  1400. }
  1401. if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay")){
  1402. $outsideTimeLabel = "ETA";
  1403. $insideTimeLabel = "ATA";
  1404. }
  1405. //直航的的
  1406. if(utils::checkExist($mInfo["delay_name"],"Departure_Delay") and $mInfo["delay_is_direct"] == 't'){
  1407. $outsideLocation = $mInfo["delay_locations_from"];
  1408. }
  1409. if(utils::checkExist($mInfo["delay_name"],"Arrival_Delay") and $mInfo["delay_is_direct"] == 't'){
  1410. $outsideLocation = $mInfo["delay_locations_to"];
  1411. }
  1412. $route = array();
  1413. $leg = array();
  1414. if($mInfo["delay_is_direct"] <>'t'){
  1415. $title = substr($mInfo["delay_name"],8);
  1416. $route = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
  1417. //当前current Leg
  1418. $leg = array($mInfo["delay_locations_from"],$mInfo["delay_locations_transshipment"]);
  1419. if($mInfo["delay_current"] == "2"){
  1420. $leg = array($mInfo["delay_locations_transshipment"],$mInfo["delay_locations_to"]);
  1421. }
  1422. }
  1423. $act_date = $mInfo["delay_act_date"]." ".$mInfo["delay_act_time"];
  1424. $est_date = $mInfo["delay_est_date"]." ".$mInfo["delay_est_time"];
  1425. $delay_diff = $mInfo["_delay_diff"];
  1426. $delay_unit = $mInfo["delay_unit"];
  1427. $eventCard = array("type" =>'delay',
  1428. "numericRecords"=>0,
  1429. "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
  1430. "title"=>$title,
  1431. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1432. "no"=>$mInfo["h_bol"],
  1433. "tag"=>$mInfo["delay_name"],
  1434. "location"=>$outsideLocation,
  1435. "timezone"=>$mInfo["delay_timezone"],
  1436. "time"=>$est_date,
  1437. "timeLabel"=>$outsideTimeLabel,
  1438. "previous"=>"",
  1439. "frequency_type"=>$mInfo["frequency_type"],
  1440. "serial_no"=>common::deCode($mInfo["serial_no"], 'E'),
  1441. "order_from"=>$mInfo["order_from"],
  1442. "id"=>$mInfo["id"],
  1443. "insert_date_format"=>'',
  1444. "rules_type"=>$mInfo["notifiation_type"],
  1445. "info"=>array("route"=>$route,
  1446. "leg"=>$leg,
  1447. "etdOrdeparturNum"=>0,
  1448. "etaOrarrivalNum"=>0,
  1449. "time"=>$act_date,
  1450. "timeLabel"=>$insideTimeLabel,
  1451. "delayTimeTip"=>"+".$delay_diff." ".$delay_unit." delay",
  1452. "timezone"=>$mInfo["delay_timezone"]
  1453. ));
  1454. if ($mInfo["frequency_type"] == "Daily"){
  1455. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1456. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1457. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1458. $eventCard["title"] = "Container Status Update Daily Summary(".$mInfo["insert_date_format"].")";
  1459. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1460. //seeall 的时候,前端不需要id
  1461. $eventCard["id"] = '';
  1462. } else if($mInfo["frequency_type"] == "Weekly"){
  1463. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1464. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1465. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1466. $eventCard["title"] = "Container Status Update Weekly Summary(".$mInfo["insert_date_format"].")";
  1467. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1468. //seeall 的时候,前端不需要id
  1469. $eventCard["id"] = '';
  1470. }
  1471. }
  1472. if($notifiation_type == "ETD/ETA_Change"){
  1473. $title = $mInfo["date_change_name"];
  1474. if(utils::checkExist($mInfo["date_change_name"],"ETD Change")){
  1475. $outsideTimeLabel = "Original ETD";
  1476. $insideTimeLabel = "Upoated ETD";
  1477. }
  1478. if(utils::checkExist($mInfo["date_change_name"],"ETA Change")){
  1479. $outsideTimeLabel = "Original ETA";
  1480. $insideTimeLabel = "Upoated ETA";
  1481. }
  1482. if($mInfo["date_change_is_direct"] <>'t'){
  1483. //代表信息为转船信息,title要处理一下: leg 1/3 ETD Change
  1484. $title = substr($mInfo["date_change_name"],8);
  1485. $route = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
  1486. $leg = array($mInfo["date_change_locations_from"],$mInfo["date_change_locations_transshipment"]);
  1487. if($mInfo["date_change_current"] == "2"){
  1488. $leg = array($mInfo["date_change_locations_transshipment"],$mInfo["date_change_locations_to"]);
  1489. }
  1490. }
  1491. $updated_date = $mInfo["date_change_updated_date"]." ".$mInfo["date_change_updated_time"];
  1492. $original_date = $mInfo["date_change_original_date"]." ".$mInfo["date_change_original_time"];
  1493. $eventCard = array("type" =>'change',
  1494. "numericRecords"=>0,
  1495. "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
  1496. "title"=>$title,
  1497. "mode"=>$mInfo["transport_mode"] == 'sea' ? "Ocean Freight": "Air Freight",
  1498. "no"=>$mInfo["h_bol"],
  1499. "tag"=>$mInfo["date_change_name"],
  1500. "location"=>"",
  1501. "timezone"=>$mInfo["date_change_timezone"],
  1502. "time"=>$original_date,
  1503. "timeLabel"=>$outsideTimeLabel,
  1504. "previous"=>"",
  1505. "frequency_type"=>$mInfo["frequency_type"],
  1506. "serial_no"=>common::deCode($mInfo["serial_no"], 'E'),
  1507. "order_from"=>$mInfo["order_from"],
  1508. "id"=>$mInfo["id"],
  1509. "insert_date_format"=>'',
  1510. "rules_type"=>$mInfo["notifiation_type"],
  1511. "info"=>array("route"=>$route,
  1512. "leg"=>$leg,
  1513. "etdOrdeparturNum"=>0,
  1514. "etaOrarrivalNum"=>0,
  1515. "time"=>$updated_date,
  1516. "timeLabel"=>$insideTimeLabel,
  1517. "delayTimeTip"=>"",
  1518. "timezone"=>$mInfo["date_change_timezone"]
  1519. ));
  1520. if ($mInfo["frequency_type"] == "Daily"){
  1521. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1522. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1523. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1524. $eventCard["title"] = "ETD/ETA Change Daily Summary(".$mInfo["insert_date_format"].")";
  1525. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1526. $eventCard["id"] = "";
  1527. } else if($mInfo["frequency_type"] == "Weekly"){
  1528. $eventCard["numericRecords"] = !empty($mInfo["numericRecords"]) ? $mInfo["numericRecords"] : 0;
  1529. $eventCard["info"]["etdOrdeparturNum"] = !empty($mInfo["numericRecords_one"]) ? $mInfo["numericRecords_one"] : 0;
  1530. $eventCard["info"]["etaOrarrivalNum"] = !empty($mInfo["numericRecords_two"]) ? $mInfo["numericRecords_two"] : 0;
  1531. $eventCard["title"] = "ETD/ETA Change Weekly Summary(".$mInfo["insert_date_format"].")";
  1532. $eventCard["insert_date_format"] = $mInfo["insert_date_format"];
  1533. $eventCard["id"] = "";
  1534. }
  1535. }
  1536. if($notifiation_type == "Feature_Update" || $notifiation_type == "Passwond_Notifcations"){
  1537. $title = $mInfo["other_type"] == "password" ? "Password Notifications" : "Feature Update";
  1538. $isExpiration = false;
  1539. if($title == "Password Notifications" and $mInfo["other_pnum"] <= 3){
  1540. $isExpiration = true;
  1541. }
  1542. $eventCard = array(
  1543. "title" => $title,
  1544. "id"=> $mInfo["id"],
  1545. "header"=> $mInfo["other_name"],
  1546. "content"=>$mInfo["other_desc"],
  1547. "isRead"=>!empty($mInfo["is_send_message"]) ? true : false,
  1548. "isExpiration"=> $isExpiration,
  1549. "rules_type"=>$mInfo["notifiation_type"],
  1550. "imgSrc"=>SERVER_PAHT.FILE_UPLOAD_PAHT."feature_update_".$mInfo["id"].".jpg",
  1551. "view_more_link" =>"main_new_version.php?action=feature_update&id=".$mInfo["id"]
  1552. );
  1553. }
  1554. return $eventCard;
  1555. }
  1556. /**
  1557. * 返回当前柜子的status信息描述,目前作废
  1558. */
  1559. public static function getContainerStatusDesc($ctnr_status_code){
  1560. $event =common::getEDICtnrEvent();
  1561. $ctnrStatusdesc = "";
  1562. foreach($event as $e){
  1563. if($e['event_name'] == $ctnr_status_code){
  1564. $ctnrStatusdesc = $e['description'];
  1565. }
  1566. }
  1567. return $ctnrStatusdesc;
  1568. }
  1569. }
  1570. ?>