tools.class.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  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 ra_online_user u
  128. left join 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. $user_name = common::check_input($_POST['user_name']);
  139. $email = common::check_input($_POST['email']);
  140. $sql = "update public.ra_online_user set user_login = '$user_name',email = '$email' where lower(user_login) = '".strtolower(_getLoginName())."'";
  141. }else{
  142. $date_fromat = common::check_input($_POST['date_fromat']);
  143. $numbers_format = common::check_input($_POST['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_fromat = '$date_fromat',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_fromat', '$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_search") {
  263. $cp = common::check_input($_POST ['cp']); //current_page
  264. $ps = common::check_input($_POST ['ps']); //ps
  265. if (empty($ps))
  266. $ps = 50;
  267. $sql = "select count(1) from public.notifications_rules where lower(user_login) = '".strtolower(_getLoginName())."' and notifications_type = 'Monitoring'";
  268. $rc = common::excuteOneSql($sql);
  269. $tp = ceil($rc / $ps);
  270. if ($rc > 0) {
  271. $sql = "select count(1) from public.notifications_rules
  272. where lower(user_login) = '".strtolower(_getLoginName())."'
  273. and notifications_type = 'Monitoring' order by id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  274. $monitoringRules = common::excuteObjectSql($sql);
  275. $arrTmp = array('monitoringRules' => $monitoringRules,
  276. 'rc' => intval($rc),
  277. 'ps' => $ps,
  278. 'cp' => $cp,
  279. 'tp' => $tp
  280. );
  281. } else {
  282. $arrTmp = array('searchData' => array(),
  283. 'rc' => $rc,
  284. 'ps' => $ps,
  285. 'cp' => $cp,
  286. 'tp' => $tp,
  287. );
  288. }
  289. common::echo_json_encode(200,$arrTmp);
  290. exit();
  291. }
  292. if ($operate == "monitoring_rules_do") {
  293. $rules_type = common::check_input($_POST["rules_type"]);
  294. //检查编辑提交的Monitoring规则,是否允许保存
  295. $msg = $this->checkedMonitoringRulesSave($rules_type);
  296. if(!empty($msg)){
  297. $data = array("msg" =>$msg);
  298. common::echo_json_encode(200,$data);
  299. exit();
  300. }
  301. $updateOrInsert = "insert";
  302. if(isset($_POST['id']) && !empty($_POST['id'])){
  303. $updateOrInsert = "update";
  304. }
  305. $sql = $this->getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,"Monitoring",$_POST['id']);
  306. $rs = common::excuteUpdateSql($sql);
  307. if ($rs === FALSE){
  308. $data = array("msg" => "Update Error");
  309. } else{
  310. $data = array("msg" => "Update Successful");
  311. }
  312. common::echo_json_encode(200,$data);
  313. exit();
  314. }
  315. if ($operate == "monitoring_rules_delete"){
  316. $id = common::check_input($_POST['id']);
  317. $rules_type = common::check_input($_POST['rules_type']);
  318. $sql = "delete from notifications_rules where notifications_type = 'Monitoring'
  319. and rules_type = '$rules_type' and lower(user_login) = '".strtolower(_getLoginName())."' and id = '$id '";
  320. common::excuteUpdateSql($sql);
  321. $data = array("msg" => "Delete Successful");
  322. common::echo_json_encode(200,$data);
  323. exit();
  324. }
  325. }
  326. public function notifications_rules(){
  327. $operate = utils::_get('operate');
  328. $operate = strtolower($operate);
  329. if ($operate == "notifications_init"){
  330. $rules_type = common::check_input($_REQUEST['rules_type']);
  331. $milestoneData = array();
  332. $containerData = array();
  333. $delayData = array();
  334. $changeData = array();
  335. if ($rules_type == "all"){
  336. $milestoneData = $this->getNotifications("Milestone_Update","all");
  337. $containerData = $this->getNotifications("Container_Status_Update","all");
  338. $delayData = $this->getNotifications("Departure/Arrival_Delay","all");
  339. $changeData = $this->getNotifications("ETD/ETA_Change","all");
  340. } else {
  341. $data = $this->getNotifications($rules_type,"all");
  342. if($rules_type == "Milestone_Update"){
  343. $milestoneData = $data;
  344. }elseif($rules_type == "Container_Status_Update"){
  345. $containerData = $data;
  346. }elseif($rules_type == "Departure/Arrival_Delay"){
  347. $delayData = $data;
  348. }elseif($rules_type == "ETD/ETA_Change"){
  349. $changeData = $data;
  350. }
  351. }
  352. $data = array("milestoneData"=>$milestoneData,"containerData"=>$containerData,"delayData"=>$delayData,"changeData"=>$changeData);
  353. $instant_sum = array();
  354. foreach($data as $v){
  355. if(!empty($v['instant'])){
  356. foreach($v['instant'] as $instant){
  357. $instant_sum[] = $instant;
  358. }
  359. }
  360. if(!empty($v['daily'])){
  361. //取第一个显示
  362. $v['daily'][0]['numericRecords'] = count($v['daily']);
  363. $instant_sum[]= $v['daily'][0];
  364. }
  365. if(!empty($milestoneData['weekly'])){
  366. $v['weekly'][0]['numericRecords'] = count($v['weekly']);
  367. $instant_sum[]= $v['weekly'][0];
  368. }
  369. }
  370. //根据时间顺序排序
  371. $insert_dates = array_column($instant_sum, 'insert_date');
  372. array_multisort($insert_dates, SORT_ASC, $instant_sum);
  373. $info = array();
  374. foreach($instant_sum as $mInfo){
  375. $eventCard = $this->getEventCard($mInfo,"Milestone_Update");
  376. $Info[] = $eventCard;
  377. }
  378. $returnData = array("notificationType"=>"event","info" =>$info);
  379. common::echo_json_encode(200,$returnData);
  380. exit();
  381. }
  382. }
  383. /**
  384. * 遍历查找对应的rule。
  385. */
  386. public function getSubscribeRules($rule_name,$subscribe_rules){
  387. //初始是不显示,没有值的情况
  388. $ret = array("is_display" => false);
  389. foreach($subscribe_rules as $rules){
  390. if($rules['rules_type'] == $rule_name){
  391. $rules["is_display"] = true;
  392. $rules["daily_time"] = $rules["_daily_time"];
  393. $rules["weekly_time"] = $rules["_weekly_time"];
  394. $rules["weekly_week"] = common::getWeek($rules["weekly_week"]);
  395. $ret = $rules;
  396. }
  397. }
  398. //Milestone Update的结构处理,处理init page load
  399. if($rule_name == "Milestone_Update"){
  400. //Milestone Update的页面配置数据
  401. $milestones = common::excuteListSql("select * from customer_service_milestone_sno order by type, sno");
  402. $oceanMilestone = array();
  403. $airMilestone = array();
  404. foreach($milestones as $milestone){
  405. if($milestone['type'] == "air"){
  406. $airMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
  407. "code"=>$milestone['code'],"description"=>$milestone['description']);
  408. }
  409. if($milestone['type'] == "ocean"){
  410. $oceanMilestone[] = array("label"=>$milestone['description'],"value"=>$milestone['description'],
  411. "code"=>$milestone['code'],"description"=>$milestone['description']);
  412. }
  413. }
  414. $ret["OceanCheckBoxList"] = $oceanMilestone;
  415. $ret["AirCheckBoxList"] = $airMilestone;
  416. $oceanMilestoneSetting = !empty($ret['ocean_milestone']) ? explode(";",$ret['ocean_milestone']) : array();
  417. $airMilestoneSetting = !empty($ret['air_milestone']) ? explode(";",$ret['air_milestone']): array();
  418. //转换描述,因为前端支持description,没有code的对应
  419. $oceanMilestoneDescription = $this->convertDescriptionForMilestoneAndCtnr("Milestone_Update",$oceanMilestoneSetting,$oceanMilestone);
  420. //转换描述,因为前端支持description,没有code的对应
  421. $airMilestoneDescription = $this->convertDescriptionForMilestoneAndCtnr("Milestone_Update",$airMilestoneSetting,$airMilestone);
  422. $ret["OceanCheckedList"] = $oceanMilestoneDescription;
  423. $ret["AirCheckedList"] = $airMilestoneDescription;
  424. }
  425. //Milestone Update的结构处理
  426. if($rule_name == "Container_Status_Update"){
  427. //这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  428. $event =$this->getEDICtnrEvent();
  429. $ctnrStatus = array();
  430. foreach($event as $e){
  431. $ctnrStatus[] = array("label"=>$e['description'],"value"=>$e['description']);
  432. }
  433. $ret["CtnrCheckBoxList"] = $ctnrStatus;
  434. $ctnrStatusSetting = !empty($ret['ocean_ctnr_status']) ? explode(";",$ret['ocean_ctnr_status']) : array();
  435. //转换描述,因为前端支持description,没有code的对应
  436. $ctnrStatusDescription = $this->convertDescriptionForMilestoneAndCtnr("Container_Status_Update",$ctnrStatusSetting,$event);
  437. $ret["CtnrCheckedList"] = $ctnrStatusDescription;
  438. }
  439. return $ret;
  440. }
  441. /**
  442. * 查询对应用户订阅的shipment信息.可能存在分页查询,如果有需要就改正
  443. * cp current_page
  444. */
  445. public function getSubscribeShipment($cp,$ps){
  446. if (empty($cp)){
  447. $cp = 1;
  448. }
  449. if (empty($ps)){
  450. $ps = 15;
  451. }
  452. $sql = "select count(1) from public.kln_user_subscribed u
  453. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  454. where lower(user_login) = '".strtolower(_getLoginName())."'";
  455. $rc = common::excuteOneSql($sql);
  456. $tp = ceil($rc / $ps);
  457. if ($rc > 0) {
  458. $sql = "select o.h_bol,
  459. o.shipper,o.consignee,o.etd,o.eta,
  460. case when transport_mode = 'sea'
  461. then (select sn.description
  462. from public.ocean_milestone a
  463. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'sea'
  464. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  465. when transport_mode = 'air' and order_from = 'public'
  466. then (select sn.description
  467. from public.air_milestone a
  468. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  469. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  470. when transport_mode = 'air' and order_from = 'sfs'
  471. then (select sn.description
  472. from sfs.air_milestone a
  473. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  474. where a.serial_no=o.serial_no and act_date is not null order by sn.sno desc limit 1)
  475. else '' end as recent_milestone
  476. from public.kln_user_subscribed u
  477. left join public.kln_ocean o on o.serial_no = u.subscribed_serial_no
  478. where lower(user_login) = '".strtolower(_getLoginName())."' order by u.id desc limit " . $ps . " offset " . ($cp - 1) * $ps;
  479. $subscribeShipment = common::excuteListSql($sql);
  480. $arrTmp = array('tableData' => $subscribeShipment,
  481. 'rc' => intval($rc),
  482. 'ps' => $ps,
  483. 'cp' => $cp,
  484. 'tp' => $tp
  485. );
  486. } else {
  487. $arrTmp = array('tableData' => array(),
  488. 'rc' => $rc,
  489. 'ps' => $ps,
  490. 'cp' => $cp,
  491. 'tp' => $tp,
  492. );
  493. }
  494. return $arrTmp;
  495. }
  496. /**
  497. * 转换描述,因为前端支持description,没有code的对应
  498. */
  499. public function convertDescriptionForMilestoneAndCtnr($type,$codeArr,$mappingData){
  500. $descriptions = array();
  501. $key = $type == "Milestone_Update" ? "code" : "event_name";
  502. foreach($codeArr as $code){
  503. foreach($mappingData as $md){
  504. if($md[$key] == $code){
  505. $descriptions[] = common::check_input($md['description']);
  506. }
  507. }
  508. }
  509. return $descriptions;
  510. }
  511. /**
  512. * 转换code,因为前端提交的是description,没有code的
  513. */
  514. public function convertCodeForMilestoneAndCtnr($type,$descriptionArr,$mappingData){
  515. $codes = array();
  516. $key = $type == "Milestone_Update" ? "code" : "event_name";
  517. foreach($descriptionArr as $description){
  518. foreach($mappingData as $md){
  519. if($md['description'] == $description){
  520. $codes[] = common::check_input($md[$key]);
  521. }
  522. }
  523. }
  524. return $codes;
  525. }
  526. public function getNotificationsRulesUpdateSql($updateOrInsert,$rules_type,$notifications_type,$id){
  527. $sql = "";
  528. //先删后加
  529. if($updateOrInsert == "update"){
  530. $sql.="delete from public.notifications_rules where rules_type = '$rules_type'
  531. and notifications_type = '$notifications_type' and lower(user_login) = '".strtolower(_getLoginName())."'
  532. and id = '$id';";
  533. }
  534. //这个几个参数是所有规则都有的参数
  535. $frequency_type = common::check_input($_POST['frequency_type']);
  536. $daily_time = "null";
  537. $daily_time_zone = "";
  538. $weekly_week = "";
  539. $weekly_time = "null";
  540. $weekly_time_zone = "";
  541. if(strtolower($frequency_type) == "daily"){
  542. $daily_time = "'".common::check_input($_POST['daily_time'])."'";
  543. $daily_time_zone = common::check_input($_POST['daily_time_zone']);
  544. } elseif (strtolower($frequency_type) == "weekly"){
  545. $weekly_week = common::check_input($_POST['weekly_week']);
  546. $weekly_time = "'".common::check_input($_POST['weekly_time'])."'";
  547. $weekly_time_zone = common::check_input($_POST['weekly_time_zone']);
  548. }
  549. $method_by_email = common::check_input($_POST['method_by_email']);
  550. $method_by_message = common::check_input($_POST['method_by_message']);
  551. $event_details = common::check_input($_POST['event_details']);
  552. $frequency_display = common::check_input($_POST['frequency_display']);
  553. $method_display = common::check_input($_POST['method_display']);
  554. //当规则是 Monitoring类型是,需要配置的range
  555. $shipment_transport_mode = "";
  556. $shipment_etd_limit = "";
  557. $shipment_eta_limit = "";
  558. if($notifications_type == "Monitoring"){
  559. $shipment_transport_mode = utils::implode(";",$_POST['shipment_transport_mode']);
  560. $shipment_etd_limit = common::check_input($_POST['shipment_etd_limit']);
  561. $shipment_eta_limit = common::check_input($_POST['shipment_eta_limit']);
  562. }
  563. if ($rules_type == "Milestone_Update"){
  564. //提交的description 的转换code
  565. $milestones = common::excuteListSql("select * from customer_service_milestone_sno order by type, sno");
  566. $oceanMilestone = array();
  567. $airMilestone = array();
  568. foreach($milestones as $milestone){
  569. if($milestone['type'] == "air"){
  570. $airMilestone[] = $milestone;
  571. }
  572. if($milestone['type'] == "ocean"){
  573. $oceanMilestone[] = $milestone;
  574. }
  575. }
  576. $ocean_milestone = $this->convertCodeForMilestoneAndCtnr("Milestone_Update",$_POST['ocean_milestone'],$oceanMilestone);
  577. $air_milestone = $this->convertCodeForMilestoneAndCtnr("Milestone_Update",$_POST['air_milestone'],$airMilestone);
  578. $ocean_milestone = utils::implode(";",$ocean_milestone);
  579. $air_milestone = utils::implode(";",$air_milestone);
  580. $sql.="INSERT INTO public.notifications_rules(
  581. user_login, notifications_type, rules_type, ocean_milestone,
  582. air_milestone, frequency_type, daily_time, daily_time_zone,
  583. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  584. event_details, frequency_display, method_display,
  585. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  586. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_milestone',
  587. '$air_milestone', '$frequency_type', $daily_time, '$daily_time_zone',
  588. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  589. '$event_details', '$frequency_display', '$method_display',
  590. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  591. }
  592. if ($rules_type == "Container_Status_Update"){
  593. $event = $this->getEDICtnrEvent();
  594. $ocean_ctnr_status = $this->convertCodeForMilestoneAndCtnr("Container_Status_Update",$_POST['ocean_ctnr_status'],$event);
  595. $ocean_ctnr_status = utils::implode(";",$ocean_ctnr_status);
  596. $sql.="INSERT INTO public.notifications_rules(
  597. user_login, notifications_type, rules_type, ocean_ctnr_status,
  598. frequency_type, daily_time, daily_time_zone,
  599. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  600. event_details, frequency_display, method_display,
  601. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  602. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type', '$ocean_ctnr_status',
  603. '$frequency_type', $daily_time, '$daily_time_zone',
  604. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  605. '$event_details', '$frequency_display', '$method_display',
  606. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  607. }
  608. if ($rules_type == "Departure/Arrival_Delay"){
  609. $ocean_atd_sub_etd = $_POST['ocean_atd_sub_etd'];
  610. $ocean_atd_sub_etd_unit = $_POST['ocean_atd_sub_etd_unit'];
  611. if(!empty($ocean_atd_sub_etd_unit)){
  612. $ocean_atd_sub_etd_unit = $ocean_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  613. }
  614. $ocean_ata_sub_eta = $_POST['ocean_ata_sub_eta'];
  615. $ocean_ata_sub_eta_unit = $_POST['ocean_ata_sub_eta_unit'];
  616. if(!empty($ocean_ata_sub_eta_unit)){
  617. $ocean_ata_sub_eta_unit = $ocean_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  618. }
  619. $air_atd_sub_etd = $_POST['air_atd_sub_etd'];
  620. $air_atd_sub_etd_unit = $_POST['air_atd_sub_etd_unit'];
  621. if(!empty($air_atd_sub_etd_unit)){
  622. $air_atd_sub_etd_unit = $air_atd_sub_etd_unit=="Day(s)" ? "days":"hours";
  623. }
  624. $air_ata_sub_eta = $_POST['air_ata_sub_eta'];
  625. $air_ata_sub_eta_unit = $_POST['air_ata_sub_eta_unit'];
  626. if(!empty($air_ata_sub_eta_unit)){
  627. $air_ata_sub_eta_unit = $air_ata_sub_eta_unit=="Day(s)" ? "days":"hours";
  628. }
  629. $sql.="INSERT INTO public.notifications_rules(
  630. user_login, notifications_type, rules_type,
  631. ocean_atd_sub_etd, ocean_atd_sub_etd_unit,ocean_ata_sub_eta,ocean_ata_sub_eta_unit,
  632. air_atd_sub_etd, air_atd_sub_etd_unit,air_ata_sub_eta,air_ata_sub_eta_unit,
  633. frequency_type, daily_time, daily_time_zone,
  634. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  635. event_details, frequency_display, method_display,
  636. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  637. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type',
  638. '$ocean_atd_sub_etd','$ocean_atd_sub_etd_unit','$ocean_ata_sub_eta','$ocean_ata_sub_eta_unit',
  639. '$air_atd_sub_etd','$air_atd_sub_etd_unit','$air_ata_sub_eta','$air_ata_sub_eta_unit',
  640. '$frequency_type', $daily_time, '$daily_time_zone',
  641. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  642. '$event_details', '$frequency_display', '$method_display',
  643. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  644. }
  645. if ($rules_type == "ETD/ETA_Change"){
  646. $ocean_etd_change = $_POST['ocean_etd_change'];
  647. $ocean_etd_old_sub_new = $_POST['ocean_etd_old_sub_new'];
  648. $ocean_etd_old_sub_new_unit = $_POST['ocean_etd_old_sub_new_unit'];
  649. if(!empty($ocean_etd_old_sub_new_unit)){
  650. $ocean_etd_old_sub_new_unit = $ocean_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  651. }
  652. $ocean_eta_change = $_POST['ocean_eta_change'];
  653. $ocean_eta_old_sub_new = $_POST['ocean_eta_old_sub_new'];
  654. $ocean_eta_old_sub_new_unit = $_POST['ocean_eta_old_sub_new_unit'];
  655. if(!empty($ocean_eta_old_sub_new_unit)){
  656. $ocean_eta_old_sub_new_unit = $ocean_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  657. }
  658. $air_etd_change = $_POST['air_etd_change'];
  659. $air_etd_old_sub_new = $_POST['air_etd_old_sub_new'];
  660. $air_etd_old_sub_new_unit = $_POST['air_etd_old_sub_new_unit'];
  661. if(!empty($air_etd_old_sub_new_unit)){
  662. $air_etd_old_sub_new_unit = $air_etd_old_sub_new_unit=="Day(s)" ? "days":"hours";
  663. }
  664. $air_eta_change = $_POST['air_eta_change'];
  665. $air_eta_old_sub_new = $_POST['air_eta_old_sub_new'];
  666. $air_eta_old_sub_new_unit = $_POST['air_eta_old_sub_new_unit'];
  667. if(!empty($air_eta_old_sub_new_unit)){
  668. $air_eta_old_sub_new_unit = $air_eta_old_sub_new_unit=="Day(s)" ? "days":"hours";
  669. }
  670. $sql.="INSERT INTO public.notifications_rules(
  671. user_login, notifications_type, rules_type,
  672. 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,
  673. 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,
  674. frequency_type, daily_time, daily_time_zone,
  675. weekly_week, weekly_time, weekly_time_zone, method_by_email, method_by_message,
  676. event_details, frequency_display, method_display,
  677. shipment_transport_mode,shipment_etd_limit,shipment_eta_limit)
  678. VALUES ('".strtolower(_getLoginName())."', '$notifications_type', '$rules_type',
  679. '$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',
  680. '$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',
  681. '$frequency_type', $daily_time, '$daily_time_zone',
  682. '$weekly_week', $weekly_time, '$weekly_time_zone', '$method_by_email', '$method_by_message',
  683. '$event_details', '$frequency_display', '$method_display',
  684. '$shipment_transport_mode','$shipment_etd_limit','$shipment_eta_limit');";
  685. }
  686. return $sql;
  687. }
  688. /**
  689. * 检查编辑提交的Monitoring规则,是否允许保存
  690. */
  691. public function checkedMonitoringRulesSave($rules_type){
  692. $sql_where = "";
  693. if(isset($_POST['id']) && !empty($_POST['id'])){
  694. $sql_where = " and id <> '".common::check_input($_POST['id'])."'";
  695. }
  696. $rules = common::excuteOneSql("select * from public.notifications_rules where notifications_type = 'Monitoring' and rules_type = '".$rules_type."'
  697. and lower(user_login) = '".strtolower(_getLoginName())."' $sql_where");
  698. foreach($rules as $rule){
  699. //判断range 是否一样
  700. $checkRangeFiled = array("shipment_transport_mode","shipment_etd_limit","shipment_eta_limit");
  701. $range_flag = true;
  702. foreach($checkRangeFiled as $filed){
  703. if($filed == "shipment_transport_mode"){
  704. $postValue = utils::implode(";",$_POST[$filed]);
  705. }else{
  706. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  707. }
  708. if($postValue != $rule[$filed]){
  709. $range_flag = false;
  710. }
  711. }
  712. //判断details 是否一样
  713. $checkDetailsFiled = array("ocean_milestone","air_milestone","ocean_ctnr_status",
  714. "ocean_atd_sub_etd","ocean_atd_sub_etd_unit","ocean_ata_sub_eta","ocean_ata_sub_eta_unit",
  715. "air_atd_sub_etd","air_atd_sub_etd_unit","air_ata_sub_eta","air_ata_sub_eta_unit",
  716. "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",
  717. "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");
  718. $details_flag = true;
  719. foreach($checkDetailsFiled as $filed){
  720. if($filed == "ocean_milestone" || $filed == "air_milestone" || $filed == "ocean_ctnr_status"){
  721. $postValue = utils::implode(";",$_POST[$filed]);
  722. }else{
  723. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  724. }
  725. if($postValue != $rule[$filed]){
  726. $details_flag = false;
  727. }
  728. }
  729. //判断frequency 是否一样
  730. $checkFrequencyFiled = array("frequency_type","daily_time","daily_time_zone",
  731. "weekly_week","weekly_time","weekly_time_zone","daily_time_zone");
  732. $frequency_flag = true;
  733. foreach($checkFrequencyFiled as $filed){
  734. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  735. if($postValue != $rule[$filed]){
  736. $frequency_flag = false;
  737. }
  738. }
  739. //判断通知方式是否一样
  740. $checkMethodFiled = array("method_by_email","method_by_message");
  741. $method_flag = true;
  742. foreach($checkMethodFiled as $filed){
  743. $postValue = !empty($_POST[$filed]) ? $_POST[$filed] : "";
  744. if($postValue != $rule[$filed]){
  745. $method_flag = false;
  746. }
  747. }
  748. //五个条件一样,不允许保存
  749. if($range_flag && $details_flag && $frequency_flag && $method_flag){
  750. $msg = "Unable to Save";
  751. continue;
  752. }
  753. //前三个重回,后面不重合,提示但允许保存
  754. if($range_flag && $details_flag){
  755. $msg = "Similar Rule Detected";
  756. continue;
  757. }
  758. }
  759. return $msg;
  760. }
  761. /**
  762. * 这里基准event 写死, 根据online查询页面的通用的来, 这里需提问确定
  763. */
  764. public function getEDICtnrEvent(){
  765. $event =array(array("event_name"=>"EE","description"=>"Empty Equipment Dispatched"),array("event_name"=>"I","description"=>"Gate in full for a booking"),array("event_name"=>"AE","description"=>"Container loaded on vessel"),
  766. array("event_name"=>"VD","description"=>"Vessel Departure"),array("event_name"=>"VA_RELAY","description"=>"Arrive Relay Port"),array("event_name"=>"UV_RELAY","description"=>"Unloaded at Relay Port"),
  767. array("event_name"=>"AE_RELAY","description"=>"Loaded at Relay Port"),array("event_name"=>"VD_RELAY","description"=>"Depart Relay Port"),array("event_name"=>"CU","description"=>"Carrier and Customs Release"),
  768. array("event_name"=>"CT","description"=>"Customs release"),array("event_name"=>"CR","description"=>"Carrier release"),array("event_name"=>"VA","description"=>"Vessel Arrival"),
  769. array("event_name"=>"UV","description"=>"Unloaded From Vessel"),array("event_name"=>"AG","description"=>"Estimated Delivery"),array("event_name"=>"OA","description"=>"Gate out full from final discharge port"),
  770. array("event_name"=>"FT","description"=>"Free Time Expired"),array("event_name"=>"AL","description"=>"Container loaded on Rail"),array("event_name"=>"AR","description"=>"Container unloaded from Rail"),
  771. array("event_name"=>"AV","description"=>"Shipment available for pickup or delivery"),array("event_name"=>"D","description"=>"Gate out for delivery to customer"),array("event_name"=>"RD","description"=>"Container returned empty"),
  772. array("event_name"=>"C","description"=>"Vessel Estimated Time of Departure"),array("event_name"=>"C_RELAY","description"=>"Estimated Time of Departure from Tranship Port"),array("event_name"=>"AG_DES","description"=>"Estimated Delivery Destination"),
  773. array("event_name"=>"IFFADW","description"=>"Shipment in CFS warehouse"),array("event_name"=>"IFFDDW","description"=>"Shipment Out from CFS House"));
  774. return $event;
  775. }
  776. public function getNotifications($notifiation_type,$frequency_type){
  777. if ($frequency_type == "all"){
  778. $sql_where = " and (ni.frequency_type = 'Instant'
  779. or (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)
  780. or (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  781. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%'))";
  782. } elseif($frequency_type == "Daily"){
  783. $sql_where = " and (ni.frequency_type = 'Daily' and timezone(ni.daily_time_zone, NOW()::time) > ni.daily_time::time)";
  784. } elseif($frequency_type == "Weekly"){
  785. $sql_where = " and (ni.frequency_type = 'Weekly' and timezone(ni.weekly_time_zone, NOW()::time) > ni.weekly_time::time
  786. and ni.weekly_week ilike '%'|| EXTRACT(dow FROM timezone(ni.weekly_time_zone, NOW())) ||'%')";
  787. }
  788. if ($notifiation_type == "Milestone_Update"){
  789. $sql = "select ni.*,
  790. case when COALESCE(ni.frequency_type,'') = 'Daily'
  791. then to_char(timezone(ni.daily_time_zone, insert_date),'Mon DD, YYYY')
  792. when COALESCE(ni.frequency_type,'') = 'Weekly'
  793. then to_char(timezone(ni.weekly_time_zone, insert_date),'Mon DD, YYYY')
  794. else ''
  795. end as insert_date_format,
  796. ccc.order_from,ccc.h_bol,ccc.transport_mode,ccc.milestone_desc
  797. from public.kln_notifiation_info ni
  798. left join LATERAL (select oo.h_bol,oo.transport_mode,oo.order_from,
  799. case when COALESCE(ni.milestone_code,'') <> '' and oo.transport_mode = 'sea'
  800. then (select description from public.customer_service_milestone_sno where type = 'sea' and code = ni.milestone_code)
  801. else (select description from public.customer_service_milestone_sno where type = 'air' and code = ni.milestone_code)
  802. end as milestone_desc
  803. from public.kln_ocean oo
  804. where oo.serial_no = ni.serial_no limit 1) ccc on true
  805. where lower(ni.user_login) = '"._getLoginName()."'
  806. and ni.notifiation_type = '".$notifiation_type."'
  807. ".$sql_where." and ni.notifications_method = true and ni.is_send_message = false order by ni.insert_date desc";
  808. }
  809. if ($notifiation_type == "Milestone_Update"){
  810. }
  811. error_log($sql);
  812. $data = common::excuteListSql($sql);
  813. //统一处理数据Instant Daily weekly_week 先分开在处理
  814. $instant = array();
  815. $daily = array();
  816. $daily_uniqe = array();
  817. $weekly = array();
  818. $weekly_uniqe = array();
  819. foreach($data as $d){
  820. if ($d['frequency_type'] == "Instant"){
  821. $instant[] = $d;
  822. }
  823. if ($d['frequency_type'] == "Daily"){
  824. if(utils::in_array($d['serial_no'],$daily_uniqe)){
  825. $temp = $daily[$d['serial_no']];
  826. $temp[] = $d;
  827. $daily[$d['serial_no']] = $temp;
  828. } else {
  829. $daily[$d['serial_no']] = $d['serial_no'];
  830. $daily_uniqe[] = $d;
  831. }
  832. }
  833. if ($d['frequency_type'] == "Weekly"){
  834. if(utils::in_array($d['serial_no'],$weekly_uniqe)){
  835. $temp = $weekly[$d['serial_no']];
  836. $temp[] = $d;
  837. $weekly[$d['serial_no']] = $temp;
  838. } else {
  839. $weekly[$d['serial_no']] = $d;
  840. $weekly_uniqe[] = $d['serial_no'];
  841. }
  842. }
  843. }
  844. return array("instant" =>$instant,"daily" =>utils::arrayKeyToInt($daily),"weekly"=>utils::arrayKeyToInt($weekly));
  845. }
  846. public function getEventCard($mInfo,$notifiation_type){
  847. if($notifiation_type == "Milestone_Update"){
  848. $timeAndlocations = common::getMilestoneTimeAndlocations($mInfo["milestone_code"],$mInfo["transport_mode"],$mInfo["serial_no"],$mInfo["order_from"]);
  849. $eventCard = array("type" =>'milestone',
  850. "numericRecords"=>0,
  851. "isRead"=>false,
  852. "title"=>"Milestone Update",
  853. "mode"=>$mInfo["transport_mode"],
  854. "no"=>$mInfo["h_bol"],
  855. "tag"=>$mInfo["milestone_desc"],
  856. "location"=>$timeAndlocations["locations"],
  857. "timezone"=>$timeAndlocations["timezone"],
  858. "time"=>$mInfo["milestone_date"]." ".$mInfo["milestone_time"],
  859. "previous"=>"",
  860. "frequency_type"=>$mInfo["frequency_type"],
  861. "delayInfo"=>array(),"changeInfo"=>array());
  862. if ($mInfo["frequency_type"] == "Daily"){
  863. $eventCard["numericRecords"] = $mInfo["numericRecords"];
  864. $eventCard["title"] = "Milestone Update Daily Summary(".$mInfo["insert_date_format"].")";
  865. } else if($mInfo["frequency_type"] == "Weekly"){
  866. $eventCard["numericRecords"] = $mInfo["numericRecords"];
  867. $eventCard["title"] = "Milestone Update Weekly Summary(".$mInfo["insert_date_format"].")";
  868. }
  869. }
  870. return $eventCard;
  871. }
  872. }
  873. ?>