ocean_order.class.php 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of ocean
  7. *
  8. * @author Administrator
  9. */
  10. class ocean_order {
  11. private static $_ocean;
  12. function __construct() {
  13. }
  14. public static function getInstance() {
  15. global $memory_limit;
  16. $memory_limit = ini_get("memory_limit");
  17. ini_set("memory_limit", '2048M');
  18. if (!self::$_ocean) {
  19. $c = __CLASS__;
  20. self::$_ocean = new $c;
  21. }
  22. return self::$_ocean;
  23. }
  24. public function ocean_order() {
  25. $operate = utils::_get('operate');
  26. $operate = strtolower($operate);
  27. /*
  28. * index page
  29. */
  30. if (empty($operate)) {
  31. //search
  32. //栏位信息
  33. $column = column::getInstance()->getDisplayColumn('Ocean_Search');
  34. $BookingTableColumns = column::getInstance()->tableColumns('Ocean_Search',$column);
  35. $data['TrackingTableColumns'] = $BookingTableColumns;
  36. common::echo_json_encode(200,$data);
  37. exit();
  38. }
  39. /*
  40. * ocean order search
  41. */
  42. if ($operate == "search") {
  43. $this->_ocean_search();
  44. }
  45. /*
  46. * ocean order detail
  47. */
  48. if ($operate == "detail") {
  49. $this->_ocean_detail();
  50. }
  51. if ($operate == "ams_isf_log"){
  52. $this->_ams_isf_log();
  53. }
  54. /*
  55. * export ocean order to excel
  56. */
  57. if ($operate == "excel") {
  58. $this->_ocean_excel();
  59. }
  60. if ($operate == 'setting_ocean_order_display') {
  61. column::getInstance()->settingDisplay('Ocean_Search', 'main_new_version.php?action=ocean_order');
  62. }
  63. /*
  64. * download document
  65. */
  66. if ($operate == "download") {
  67. $this->_download();
  68. }
  69. if ($operate == "save_communication") {
  70. try {
  71. $content = $_POST["content"];
  72. $content = common::check_input($content);
  73. $text = $_POST["text"];
  74. $content = urldecode($content);
  75. $web_content = urldecode($text);
  76. $communication_cc = $_POST["communication_cc"];
  77. $serial_no = common::uuid();
  78. $email_uuid = $_POST["serial_no"];
  79. $add_by = _getLoginName();
  80. $refer_id = 0;
  81. $email = $this->getEmail($email_uuid);
  82. $from_email = "US.KApex.Online@kerryapex.com";
  83. $to_email = $email["email"];
  84. $cc_email = $_SESSION['ONLINE_USER']['email'] . ";ApexOnlineCommunication@apexshipping.com";
  85. $communication_cc = trim($communication_cc);
  86. if (!empty($communication_cc)) {
  87. $communication_cc = common::check_input($communication_cc);
  88. $cc_email .= ";" . $communication_cc;
  89. }
  90. $user_from = _getLoginName();
  91. $user_to = $email["name"];
  92. $user_cc = $_SESSION['ONLINE_USER']['first_name'];
  93. if (empty($user_cc)) {
  94. $user_cc = _getLoginName();
  95. }
  96. $user_cc .= ";ApexOnlineCommunication";
  97. //邮件发送
  98. $poKey = "<br><br>Important note: when you reply this email, do not remove ApexOnlineCommunication@apexshipping.com<br>Below is system code, do not delete.<br>@@";
  99. $emailSql = "select encode(public.pgp_sym_encrypt('" . $serial_no . "','pom_key'), 'base64')::text;";
  100. $key = common::excuteOneSql($emailSql);
  101. $historyEmails = "";
  102. $title = "Communication from " . _getLoginName() . ", HBOL: " . $email["h_bol"] . ", Consignee: " . $email["consignee"];
  103. $emailContent = $content . $poKey . $key . ";" . "@@<br>For your convenience weblink: https://ra.kerryapex.com/<br><br>" . $historyEmails;
  104. common::excuteUpdateSql("insert into public.email_record (type,title,from_email,to_email,cc_email,content,insert_date)values('Communication','$title','$from_email','$to_email','$cc_email','$emailContent',now());");
  105. $rs = common::excuteUpdateSql("INSERT INTO public.online_ocean_communication(serial_no, email_uuid, content,web_content,user_from, user_to, user_cc, refer_id, add_by, add_time, cc_email)
  106. VALUES ('$serial_no', '$email_uuid', '$emailContent','$web_content', '$user_from', '$to_email', '$cc_email', $refer_id, '$add_by', now(), '$communication_cc');");
  107. $emailRecords = $this->getCommunicationNew($email_uuid);
  108. common::echo_json_encode(200,array("msg" => "Sent Successfully", "emailRecords" => $emailRecords));
  109. exit();
  110. } catch (Exception $e) {
  111. common::echo_json_encode(500,array("msg" => "Sent Error."));
  112. exit();
  113. }
  114. }
  115. if ($operate == "ocean_vgm") {
  116. if (!_canEdiVgm()) {
  117. $data = array("msg" =>"Vgm Permission Error");
  118. common::echo_json_encode(200, $data);
  119. exit();
  120. }
  121. $serial_no = common::deCode(($_GET["a"]), 'D');
  122. $sqlWhere = " and o.serial_no='" . $serial_no . "'";
  123. $column = "*";
  124. $schemas = $_GET["_schemas"];
  125. if (empty($schemas)) {
  126. $schemas = "public";
  127. }
  128. $ocean_info_sql = "select o.from_station as o_from_station, o.h_bol as o_h_bol, o.carrier_booking, o.m_vessel, o.m_voyage, to_char(o.f_etd, 'MM/DD/YYYY') as f_etd, to_char(o.m_eta, 'MM/DD/YYYY') as m_eta, v.*, o.master_base_number from "
  129. . "$schemas.ocean o left join $schemas.ocean_vgm v on o.serial_no=v.serial_no or o.master_base_number=v.master_base_number where 1=1 and o.status::text <> 'Cancelled'::text AND o.bol_type::text <> 'BOOKING'::text AND o.bol_type::text <> 'QUOTE'::text" . $sqlWhere;
  130. $ocean_info = common::excuteObjectSql($ocean_info_sql);
  131. $rs_sql = "select o.service, o.ctnr, v.carrier_booking_no, o.ctnr, o.size, v.vgm_weight, v.unit, v.vgm_time, v.vgm_method, o.grs_kgs, o.grs_lbs, ov.id as ocean_vgm_id, v.id as ocean_vgm_container_id from "
  132. . "$schemas.oc_container o left join $schemas.ocean oc on o.serial_no=oc.serial_no "
  133. . " left join $schemas.ocean_vgm ov on oc.serial_no=ov.serial_no or oc.master_base_number=ov.master_base_number "
  134. . " left join $schemas.ocean_vgm_container v on ov.serial_no=v.serial_no and o.ctnr=v.ctnr "
  135. . " where 1=1 and oc.status::text <> 'Cancelled'::text AND oc.bol_type::text <> 'BOOKING'::text AND oc.bol_type::text <> 'QUOTE'::text and oc.master_base_number='" . $ocean_info["master_base_number"] . "' and oc.from_station='" . $ocean_info["o_from_station"] . "'";
  136. $rs = common::excuteListSql($rs_sql);
  137. $ocean_info["is_send"] = (empty($ocean_info["is_send"]) ? "f" : $ocean_info["is_send"]);
  138. if (empty($ocean_info["id"])) {
  139. $ocean_info["is_send"] = "t";
  140. }
  141. $err_msg = "";
  142. if (empty($ocean_info["carrier_booking"])) {
  143. $err_msg = "Carrier Booking is empty.";
  144. }
  145. if ($schemas <> "public") {
  146. $err_msg .= "This hbol do not support.";
  147. }
  148. foreach ($rs as $cv) {
  149. if (empty($cv["ctnr"])) {
  150. $err_msg .= "Container# is empty.";
  151. }
  152. if (substr($cv["service"], 0, 3) == "CFS") {
  153. $err_msg .= "CFS cannot support update.";
  154. }
  155. }
  156. if (!empty($err_msg)) {
  157. $err_msg = "You cant't add this VGM, (" . $err_msg . ")";
  158. }
  159. $serial_no = common::deCode($serial_no, "E");
  160. //default
  161. if (empty($rs["id"])) {
  162. $default = common::excuteObjectSql("select * from ocean_vgm_setting where login_name ilike '" . _getLoginName() . "'");
  163. }
  164. $log = common::excuteListSql("select * from ocean_vermas where from_serial_no ilike '" . $ocean_info["master_base_number"] . "'");
  165. //detail information
  166. $detail_information_column = array();
  167. $detail_information_column[] = array("title" =>"SN","field" =>"sn","formatter" =>"","edit_type" =>"normal",);
  168. $detail_information_column[] = array("title" =>"Carrier Booking No.","field" =>"carrier_booking_no","formatter" =>"","edit_type" =>"normal");
  169. $detail_information_column[] = array("title" =>"Container No","field" =>"ctnr","formatter" =>"","edit_type" =>"normal");
  170. $detail_information_column[] = array("title" =>"VGM Weight","field" =>"vgm_weight","formatter" =>"","edit_type" =>"input");
  171. $detail_information_column[] = array("title" =>"VGM Unit","field" =>"unit","formatter" =>"","edit_type" =>"select");
  172. $detail_information_column[] = array("title" =>"VGM Time","field" =>"vgm_time","formatter" =>"","edit_type" =>"dateTime");
  173. $detail_information_column[] = array("title" =>"VGM Method","field" =>"vgm_method","formatter" =>"","edit_type" =>"input");
  174. foreach($rs as $rk => $rv){
  175. $log[$rk]['sn'] = $rk +1;
  176. }
  177. $detail_information =array("detail_information_column" =>$detail_information_column,
  178. "detail_information_data" =>$rs);
  179. $data = array("msg" =>$err_msg);
  180. $Submitter = $ocean_info["authorized_company"];
  181. if(empty($ocean_info["id"])){
  182. $Submitter = $default["submitter"];
  183. }
  184. $signature = $ocean_info["signature"];
  185. if(empty($ocean_info["id"])){
  186. $signature = $default["signature"];
  187. }
  188. $authorized_email = $ocean_info["authorized_email"];
  189. if(empty($ocean_info["id"])){
  190. $authorized_email = $default["authorized_email"];
  191. }
  192. $authorized_tel = $ocean_info["authorized_tel"];
  193. if(empty($ocean_info["id"])){
  194. $authorized_tel = $default["authorized_tel"];
  195. }
  196. $data["general_information"] = array("HBL No."=>$ocean_info["o_h_bol"],
  197. "Carrier Booking No."=>$ocean_info["carrier_booking"],
  198. "Vessel"=>$ocean_info["m_vessel"],"Voyage"=>$ocean_info["m_voyage"],
  199. "ETD"=>$ocean_info["f_etd"],"ETA"=>$ocean_info["m_eta"],
  200. "Last updated User"=>$ocean_info["modify_user"],"Last updated Time"=>$ocean_info["modify_time"],
  201. "Submitter" =>$Submitter,"signature" =>$signature,"authorized_email" =>$authorized_email,"authorized_tel" =>$authorized_tel,"is_send" =>$ocean_info['is_send']);
  202. $data["detail_information"] = $detail_information;
  203. $data["schemas"] = $schemas;
  204. $data["serial_no"] = $serial_no;
  205. common::echo_json_encode(200, $data);
  206. exit();
  207. }
  208. if ($operate == "save_ocean_vgm") {
  209. if (!_canEdiVgm()) {
  210. $data = array("msg" =>"Vgm Permission Error");
  211. common::echo_json_encode(200, $data);
  212. exit();
  213. }
  214. $msg = $this->save_vgm();
  215. $data = array("msg" =>$msg);
  216. common::echo_json_encode(200, $data);
  217. exit();
  218. }
  219. }
  220. /*
  221. * ocean order search
  222. */
  223. private function _ocean_search() {
  224. $cp = common::check_input($_POST ['cp']); //current_page
  225. $ps = common::check_input($_POST ['ps']); //ps
  226. if (empty($ps))
  227. $ps = 50;
  228. if (empty($cp))
  229. $cp = 1;
  230. $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  231. $sqlWhere .= search::getInstance()->getSearchSQL("Ocean_Search");
  232. if (!empty($_REQUEST["_reportRef"])) {
  233. $_reportType = $_REQUEST["_reportType"];
  234. $_reportRef = $_REQUEST["_reportRef"];
  235. if ($_reportType == "r3") {
  236. if ($_reportRef == "Previous 7 Days") {
  237. $sqlWhere .= " and eta>(current_date-interval '7 days') and eta<current_date";
  238. } else if ($_reportRef == "0 Day") {
  239. $sqlWhere .= " and eta=current_date";
  240. } else if ($_reportRef == "1-2 Days") {
  241. $sqlWhere .= " and eta>current_date and eta<=(current_date+interval '2 days')";
  242. } else if ($_reportRef == "3-6 Days") {
  243. $sqlWhere .= " and eta>(current_date+interval '2 days') and eta<=(current_date+interval '6 days')";
  244. } else if ($_reportRef == "7 Days") {
  245. $sqlWhere .= " and eta>(current_date+interval '6 days')";
  246. } else {
  247. $sqlWhere .= " and 1<>1";
  248. }
  249. } else if ($_reportType == "r4") {
  250. if ($_reportRef == "Previous 7 Days") {
  251. $sqlWhere .= " and etd>(current_date-interval '7 days') and etd<current_date";
  252. } else if ($_reportRef == "0 Day") {
  253. $sqlWhere .= " and etd=current_date";
  254. } else if ($_reportRef == "1-2 Days") {
  255. $sqlWhere .= " and etd>current_date and etd<=(current_date+interval '2 days')";
  256. } else if ($_reportRef == "3-6 Days") {
  257. $sqlWhere .= " and etd>(current_date+interval '2 days') and etd<=(current_date+interval '6 days')";
  258. } else if ($_reportRef == "7 Days") {
  259. $sqlWhere .= " and etd>(current_date+interval '6 days')";
  260. } else {
  261. $sqlWhere .= " and 1<>1";
  262. }
  263. } else if ($_reportType == "ata_r3") {
  264. if ($_reportRef == "0 Day") {
  265. $sqlWhere .= " and ata >= etd and (ata-etd) >= 0 and (ata-etd) < 1";
  266. } else if ($_reportRef == "1-2 Days") {
  267. $sqlWhere .= " and ata >= etd and (ata-etd) >= 1 and (ata-etd) < 2";
  268. } else if ($_reportRef == "3-6 Days") {
  269. $sqlWhere .= " and ata >= etd and (ata-etd) >= 2 and (ata-etd) < 6";
  270. } else if ($_reportRef == "7 Days") {
  271. $sqlWhere .= " and ata >= etd and (ata-etd) >= 6";
  272. } else {
  273. $sqlWhere .= " and 1<>1";
  274. }
  275. } else if ($_reportType == "atd_r4") {
  276. if ($_reportRef == "0 Day") {
  277. $sqlWhere .= " and atd >= etd and (atd-etd) >= 0 and (atd-etd) < 1";
  278. } else if ($_reportRef == "1-2 Days") {
  279. $sqlWhere .= " and atd >= etd and (atd-etd) >= 1 and (atd-etd) < 2";
  280. } else if ($_reportRef == "3-6 Days") {
  281. $sqlWhere .= " and atd >= etd and (atd-etd) >= 2 and (atd-etd) < 6";
  282. } else if ($_reportRef == "7 Days") {
  283. $sqlWhere .= " and atd >= etd and (atd-etd) >= 6 ";
  284. } else {
  285. $sqlWhere .= " and 1<>1";
  286. }
  287. } else if ($_reportType == "top") {
  288. if (!empty($_reportRef)) {
  289. $_reportStationType = $_REQUEST["_reportStationType"];
  290. if($_reportStationType == 'origin'){
  291. $sqlWhere .= " and origin = '$_reportRef'";
  292. }else{
  293. $sqlWhere .= " and agent = '$_reportRef'";
  294. }
  295. } else {
  296. $sqlWhere .= " and 1<>1";
  297. }
  298. } else if ($_reportType == "co2e") {
  299. $_reportDataType = $_REQUEST["_reportDataType"];
  300. //查询sea 其他的为空
  301. if (!empty($_reportRef) && $_reportDataType == "sea") {
  302. $_reportStationType = $_REQUEST["_reportStationType"];
  303. if($_reportStationType == 'origin'){
  304. $sqlWhere .= " and origin = '$_reportRef'";
  305. }else{
  306. $sqlWhere .= " and agent = '$_reportRef'";
  307. }
  308. } else {
  309. $sqlWhere .= " and 1<>1";
  310. }
  311. } else {
  312. $_reportRef = explode("-", $_REQUEST["_reportRef"]);
  313. $_reportRefb_date = $_REQUEST["_reportRefb_date"];
  314. $bdate = common::excuteOneSql("select to_date('$_reportRefb_date','mm/YYYY')");
  315. $_reportRefe_date = $_REQUEST["_reportRefe_date"];
  316. $edate = common::excuteOneSql("select to_date('$_reportRefe_date','mm/YYYY') + interval '1 month' - interval '1 day'");
  317. //$sqlWhere .= " and eta>='$bdate' and eta<='$edate'";
  318. if ($_REQUEST["_reportRef"] == "Over 80 Days") {
  319. $sqlWhere .= " and (eta-etd)>80";
  320. } else {
  321. $sqlWhere .= " and (eta-etd)>" . $_reportRef[0] . " and (eta-etd)<=" . substr($_reportRef[1], 0, 2);
  322. }
  323. }
  324. }
  325. //查询tag
  326. // IFFBCF;Booking Confirmation
  327. // IFFREC;Cargo Arrived at Origin
  328. // IFFDEP;Departure
  329. // IFFARR;Arrived at Final Destination Port
  330. // IFFAFD;Arrived at Final Destination
  331. if (!empty($_POST["filterTag"])) {
  332. if (count($_POST['filterTag']) == 1){
  333. $filterTag = $_POST['filterTag'][0];
  334. }else{
  335. $filterTag = implode(",", $_POST['filterTag']);
  336. }
  337. $_sqlwhere = "1<>1";
  338. if (stripos($filterTag, "Booked") !== FALSE) {
  339. $_sqlwhere .= " or (dd.status = 'Booked')";
  340. }
  341. if (stripos($filterTag, "Cargo Received") !== FALSE) {
  342. $_sqlwhere .= " or (dd.status = 'Cargo Received')";
  343. }
  344. if (stripos($filterTag, "Departed") !== FALSE) {
  345. $_sqlwhere .= " or (dd.status = 'Departed')";
  346. }
  347. if (stripos($filterTag, "Arrived") !== FALSE) {
  348. $_sqlwhere .= " or (dd.status = 'Arrived')";
  349. }
  350. if (stripos($filterTag, "Completed") !== FALSE) {
  351. $_sqlwhere .= " or (dd.status = 'Completed')";
  352. }
  353. if(strtolower($filterTag) <> "all" && !empty($filterTag)){
  354. $sqlWhere .= " and ($_sqlwhere)";
  355. }
  356. }
  357. //取消全文检索
  358. // if (!empty($_POST["_textSearch"])) {
  359. // $sqlWhere .= " and text_search @@ (str_to_tsquery('" . common::check_input($_POST["_textSearch"]) . "'))";
  360. // }
  361. //处理reference类型的组合查询 Search booking No./HBL No./PO No./Carrier Booking No.
  362. if (!empty($_POST["_textSearch"])) {
  363. $textSearch_arr = $_POST['_textSearch'];
  364. if(!is_array($textSearch_arr)){
  365. $textSearch_arr = array($textSearch_arr);
  366. }
  367. $more_sql = "1<>1";
  368. foreach($textSearch_arr as $tsv){
  369. $more_sql .= " or booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
  370. $more_sql .= " or h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
  371. $more_sql .= " or po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
  372. $more_sql .= " or carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
  373. }
  374. if ($more_sql <> "1<>1"){
  375. $sqlWhere .= " and ($more_sql)";
  376. }
  377. }
  378. $rc = $_POST ['rc'];
  379. //这里都要查询,除非多传几个参数回来
  380. if ($rc == - 1 || true) {
  381. $sql = "select count(1) from online_ocean
  382. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  383. when a.description='Cargo Pickup' then 'Cargo Received'
  384. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  385. when a.description='Departure' then 'Departed'
  386. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  387. when a.description='Arrived at Final Destination' then 'Completed'
  388. else 'Booked' END as status
  389. from ocean_milestone a
  390. where a.serial_no=online_ocean.serial_no
  391. and a.description in (
  392. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  393. order by id desc limit 1) dd on true" . $sqlWhere;
  394. $rc = common::excuteOneSql($sql);
  395. error_log("sss:".$sql);
  396. //Booked
  397. $sql = $this->getOcanOrderSearchSql("Booked",$sqlWhere);
  398. $Booked = common::excuteOneSql($sql);
  399. //Cargo Received
  400. $sql = $this->getOcanOrderSearchSql("Cargo Received",$sqlWhere);
  401. $Cargo_Received = common::excuteOneSql($sql);
  402. //Departed
  403. $sql = $this->getOcanOrderSearchSql("Departed",$sqlWhere);
  404. $Departed = common::excuteOneSql($sql);
  405. //Arrived
  406. $sql = $this->getOcanOrderSearchSql("Arrived",$sqlWhere);
  407. $Arrived = common::excuteOneSql($sql);
  408. //Completed
  409. $sql = $this->getOcanOrderSearchSql("Completed",$sqlWhere);
  410. $Completed = common::excuteOneSql($sql);
  411. if (!empty($_POST["filterTag"])) {
  412. $tagsList = array(array("name"=>"All","number"=>$rc,"type"=>"all","checked"=>in_array('All', $_POST["filterTag"])? true : false),
  413. array("name"=>"Booked","number"=>$Booked,"type"=>"booked","checked"=>in_array('Booked', $_POST["filterTag"])? true : false),
  414. array("name"=>"Cargo Received","number"=>$Cargo_Received,"type"=>"cargo_received","checked"=>in_array('Cargo Received', $_POST["filterTag"])? true : false),
  415. array("name"=>"Departure","number"=>$Departed,"type"=>"departure","checked"=>in_array('Departure', $_POST["filterTag"])? true : false),
  416. array("name"=>"Arrived","number"=>$Arrived,"type"=>"arrived","checked"=>in_array('Arrived', $_POST["filterTag"])? true : false),
  417. array("name"=>"Completed","number"=>$Completed,"type"=>"completed","checked"=>in_array('Completed', $_POST["filterTag"])? true : false));
  418. }else{
  419. //初始,前端有选择着带入选择
  420. $tagsList = array(array("name"=>"All","number"=>$rc,"type"=>"all","checked"=> true ),
  421. array("name"=>"Booked","number"=>$Booked,"type"=>"booked","checked"=> false),
  422. array("name"=>"Cargo Received","number"=>$Cargo_Received,"type"=>"cargo_received","checked"=> false),
  423. array("name"=>"Departure","number"=>$Departed,"type"=>"departure","checked"=> false),
  424. array("name"=>"Arrived","number"=>$Arrived,"type"=>"arrived","checked"=> false),
  425. array("name"=>"Completed","number"=>$Completed,"type"=>"completed","checked"=>false));
  426. }
  427. $TransportList = array(
  428. array("name"=>"Ocean Freight","number"=>$rc,"checked"=>false,"icon"=>"#icon-icon_ocean_b"));
  429. //现在下载交给前端,后台预先只返回全部字段的列,
  430. $allColumn = column::getInstance()->getDisplayColumnAllReomveDefault('Ocean_Search');
  431. $allBookingColumns = column::getInstance()->tableColumns('Ocean_Search',$allColumn);
  432. }
  433. $tp = ceil($rc / $ps);
  434. $order_by = " etd desc NULLS LAST, id";
  435. if (_isCustomerLogin()) {
  436. $order_by = " eta desc NULLS LAST, id";
  437. }
  438. if ($rc > 0) {
  439. $ocean_ref_sql = " LEFT JOIN LATERAL ( SELECT string_agg(ref_code ||ref_value, ', ') AS other_refenrence_no
  440. FROM public.ocean_reference temp WHERE temp.serial_no = online_ocean.serial_no) aa ON true ";
  441. $ocean_status_sql = " LEFT JOIN LATERAL ( select case when a.description='Booking Confirmation' then 'Booked'
  442. when a.description='Cargo Pickup' then 'Cargo Received'
  443. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  444. when a.description='Departure' then 'Departed'
  445. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  446. when a.description='Arrived at Final Destination' then 'Completed'
  447. else 'Booked' END as new_status
  448. from ocean_milestone a
  449. where a.serial_no=online_ocean.serial_no
  450. and a.description in (
  451. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  452. order by id desc limit 1) dd ON true ";
  453. $sql = "SELECT order_from as _schemas,serial_no as __serial_no, serial_no,
  454. h_bol as _hbol, isf_bol as _isfbol,
  455. CASE
  456. WHEN dd.new_status is null THEN 'Booked'::text
  457. ELSE dd.new_status::text
  458. END AS new_status, ".
  459. column::getInstance()->getSearchSqlForDisplay('Ocean_Search') . " from public.online_ocean $ocean_ref_sql $ocean_status_sql" . $sqlWhere .
  460. " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
  461. $sss = " order by $order_by limit " . $ps . " offset " . ($cp - 1) * $ps;
  462. $rs = common::excuteListSql($sql);
  463. //对查询的结果做特殊处理,比如要拼接某个值,合并值等
  464. foreach($rs as $index => $val) {
  465. //返回加密serial_no
  466. $rs[$index]["__serial_no"] = common::deCode($val['__serial_no'], 'E');
  467. $rs[$index]["mode"] = "Ocean Freight";
  468. $rs[$index]["Status"] = $rs[$index]["new_status"];
  469. }
  470. $arrTmp = array('searchData' => $rs,
  471. 'tagsList' => $tagsList,
  472. 'TransportList' => $TransportList,
  473. 'allColums' => $allBookingColumns,
  474. 'canEdiVgm' => _canEdiVgm(),
  475. 'rc' => $rc,
  476. 'ps' => $ps,
  477. 'cp' => $cp,
  478. 'tp' => $tp,
  479. 'tmp_search' => common::deCode($sql, 'E'),
  480. 'type' => common::check_input($_POST ['_ntype']));
  481. } else {
  482. $arrTmp = array('searchData' => array(),
  483. 'tagsList' => $tagsList,
  484. 'TransportList' => $TransportList,
  485. 'allColums' => $allBookingColumns,
  486. 'allColcanEdiVgmums' => _canEdiVgm(),
  487. 'rc' => $rc,
  488. 'ps' => $ps,
  489. 'cp' => $cp,
  490. 'tp' => $tp,
  491. 'tmp_search' => common::deCode($sql, 'E'),
  492. 'type' => common::check_input($_POST ['_ntype']));
  493. }
  494. common::echo_json_encode(200,$arrTmp);
  495. exit();
  496. }
  497. private function _ocean_detail() {
  498. $serial_no = common::deCode($_GET['a'], 'D');
  499. $sql = $this->getOceanDetail($serial_no);
  500. $ocean = common::excuteObjectSql($sql);
  501. if (!empty($ocean)) {
  502. $ocean['_isf_bol'] = $ocean['isf_bol'];
  503. if (empty($ocean['_isf_bol'])) {
  504. $ocean['_isf_bol'] = "AMAW" . $ocean['_h_bol'];
  505. }
  506. $isf_ss = md5(md5($ocean['_isf_bol']));
  507. $isf_ss = substr($isf_ss, 7) . substr($isf_ss, 0, 7);
  508. //ETA Dest的计算逻辑移除
  509. // most update status
  510. $_schemas = $_REQUEST["_schemas"];
  511. $mostStatusSql = "select last_status_loc, last_status_city, to_char(last_status_315_date, 'MM/DD/YYYY') as last_status_315_date,last_status_315_code "
  512. . ", fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un FROM public.online_ocean "
  513. . "where serial_no= '" . $ocean["serial_no"] . "'";
  514. if (!empty($_schemas)) {
  515. $mostStatusSql .= " and order_from='" . $_schemas . "'";
  516. }
  517. $mostStatus = common::excuteObjectSql($mostStatusSql);
  518. $state = -1;
  519. if (!empty($mostStatus["last_status_315_code"])) {
  520. //desc 逻辑处理取消
  521. $state = common::getStatusStage($mostStatus["last_status_315_code"]);
  522. }
  523. //请求地图是需要的参数
  524. $uncode = "'";
  525. if ($mostStatus["place_of_receipt_un"] != $mostStatus["fport_of_loading_un"]) {
  526. $uncode .= $mostStatus["place_of_receipt_un"];
  527. }
  528. $uncode .= "'|'" . $mostStatus["fport_of_loading_un"] . "'|'" . $mostStatus["mport_of_discharge_un"] . "'|'";
  529. if ($mostStatus["mport_of_discharge_un"] != $mostStatus["place_of_delivery_un"]) {
  530. $uncode .= $mostStatus["place_of_delivery_un"];
  531. }
  532. $uncode .= "'";
  533. }
  534. $vueData = $this->returnOceanDetailData($ocean,$state);
  535. //处理shipment data暂时写死
  536. $simplexData = $vueData['shipmentData'];
  537. //处理transportInfo信息数据
  538. $transportInfo = $vueData['transportInfo'];
  539. //处理basicInfo信息数据
  540. $basicInfo = $vueData['basicInfo'];
  541. //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
  542. $businessPartners = $vueData['businessPartners'];
  543. //处理routes 转船可能有多个情况
  544. $routes = $vueData['routes'];
  545. //处理marksAndDescription
  546. $marksAndDescription = $vueData['marksAndDescription'];
  547. //处理ocean_reference
  548. $ref_no = array();
  549. $ref_arr = common::excuteListSql("select * from ocean_reference where lower(serial_no) = '" . strtolower($serial_no) . "'");
  550. if(!empty($ref_arr)){
  551. foreach($ref_arr as $ref) {
  552. $ref_no[] = array("label"=>$ref["ref_code"],"value"=>$ref["ref_value"]);
  553. }
  554. }
  555. //处理Container :配置Ocean_Container字段 UI 需要的字段有:Container.no Packing,quantity,Gross weight(kg),Gross weight(LB),CBM,seal#,size.service
  556. $ocean_container_column = array();
  557. $container_column = column::getInstance()->getDisplayColumnAll('Ocean_Container');
  558. foreach($container_column as $cc){
  559. $ocean_container_column[] =array("field" =>$cc['database_column_name'],"title" =>$cc['name'],"formatter" =>"","type" =>"normal");
  560. }
  561. $sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container') . " from oc_container where lower(serial_no) = '" . strtolower($serial_no) . "'";
  562. $rss = common::excuteListSql($sql);
  563. $quantity_tolal = 0;
  564. $packages = "CTN";
  565. $g_weight_tolal = 0;
  566. $ch_weight_tolal = 0;
  567. $cbm_tolal = 0;
  568. foreach ($rss as $key => $rs) {
  569. $quantity_tolal += $rs['qty'];
  570. $g_weight_tolal += $rs['grs_kgs'];
  571. $ch_weight_tolal += $rs['grs_lbs'];
  572. $cbm_tolal += $rs['cbm'];
  573. $packages = " ".$rs['unit'];
  574. //特殊处理weight
  575. if(!empty($rss[$key]['grs_kgs'])){
  576. $rss[$key]['grs_kgs'] = $rs['grs_kgs']."KG";
  577. }
  578. if(!empty($rss[$key]['grs_lbs'])){
  579. $rss[$key]['grs_lbs'] = $rs['grs_lbs']."LB";
  580. }
  581. }
  582. $containers = array("container_column"=>$ocean_container_column,"container_data" =>$rss);
  583. //Packing信息
  584. $packing = array("Quantity/Unit"=>$quantity_tolal.$packages,"G. Weight" => $g_weight_tolal." KGS","Ch. Weight" => $ch_weight_tolal." LBS","Volume" => $cbm_tolal." CBM");
  585. /* Container Status */
  586. //数据库里配置好
  587. $sql = "SELECT " . column::getInstance()->getSearchSql('Ocean_Container_Status') . " from oc_container_v where lower(serial_no) = '" . strtolower($serial_no) . "'";
  588. $rss = common::excuteListSql($sql);
  589. $containerStatusData = array();
  590. if (!empty($rss)) {
  591. //Container_Status 新版只显示几个状态, CTNR# EE I AE VD VA
  592. $container_status_column = array("EE","I","AE","VD","VA");
  593. foreach ($rss as $rsk => $rs) {
  594. $containerStatusDataTemp = array();
  595. $content = array();
  596. //新UI 还有站点取值,但不清楚取的什么值,CN,SHK 暂时写死
  597. foreach($container_status_column as $status){
  598. $dec = common::excuteOneSql("select description from ra_online_edi_event where ra_name = '" . $status . "'");
  599. $status = strtolower($status);
  600. $content[] = array("title" =>$dec,"date"=>common::date2usdate($rs[$status]),"country"=>"CN,SHK");
  601. }
  602. $containerStatusDataTemp['label'] = $rs['ctnr']." / ".$rs['size'];
  603. $containerStatusDataTemp['content'] = $content;
  604. $containerStatusData[] = $containerStatusDataTemp;
  605. }
  606. }
  607. //Milestones info 列名固定
  608. $Milestones = $this->getMilestonesInfo($ocean);
  609. //页面固定写死的信息
  610. $document_column = array();
  611. $document_column[] = array("title" =>"File Type","field" =>"file_type","formatter" =>"","type" =>"normal");
  612. $document_column[] = array("title" =>"File","field" =>"file","formatter" =>"","type" =>"normal");
  613. $document_data = array();
  614. $document = _getViewDocType($_REQUEST["_schemas"]);
  615. $OutFileURL = common::excuteOneSql("select item_value from config where item='OutFileURL'");
  616. $ocean_can_view_file = common::excuteOneSql("select ocean_can_view_file from ra_online_user where lower(user_login)='".strtolower($_SESSION['ONLINE_USER']['user_login'])."'");
  617. if (!empty($document)) {
  618. foreach ($document as $v) {
  619. $file_type = $v['display_name'];
  620. $file_arr = $this->getFileByHbol($ocean['_m_bol'], $ocean['_h_bol'], $v['serial_no'], $v['m_h'], $v['display_name'], TRUE,$ocean['_job_bol']) ;
  621. $tar = json_decode($ocean_can_view_file,true);
  622. if(!empty($tar[$v['display_name']])){
  623. foreach ($tar[$v['display_name']] as $dkey => $dvalue) {
  624. switch ($v['display_name']) {
  625. case 'HBL':
  626. $sql = "SELECT from_system,serial_no,file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date
  627. from ra_online_doc_upload
  628. where lower(bol) = lower('".$ocean['_h_bol']."') and lower(format_serailno) in ('".strtolower(str_replace(";","','",$dvalue['value']))."') and upper((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2]) = '".$dvalue['type']."'
  629. order by id desc";
  630. break;
  631. case 'MBL':
  632. $sql = "SELECT from_system,serial_no,file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date
  633. from ra_online_doc_upload
  634. where ( lower(bol) = lower('".strtolower($ocean['_m_bol'])."') or lower(bol) = lower('".strtolower($ocean['_job_bol'])."')) and lower(format_serailno) in ('".strtolower(str_replace(";","','",$dvalue['value']))."') and upper((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2]) = '".$dvalue['type']."'
  635. order by id desc";
  636. break;
  637. case 'Others':
  638. $sql = "SELECT from_system,serial_no,file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date
  639. from ra_online_doc_upload
  640. where (lower(bol) = lower('".strtolower($ocean['_h_bol'])."') or lower(bol) = lower('".strtolower($ocean['_m_bol'])."') or lower(bol) = lower('".strtolower($ocean['_job_bol'])."')) and lower(format_serailno) in ('".strtolower(str_replace(";","','",$dvalue['value']))."') and upper((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2]) = '".$dvalue['type']."'
  641. order by id desc";
  642. break;
  643. default:
  644. $sql = "";
  645. break;
  646. }
  647. if (!empty($sql)) {
  648. $rss = common::excuteListSql($sql);
  649. foreach ($rss as $rs) {
  650. if ($rs['from_system']=="TOPOCEAN"||$rs['from_system']=="KSMART") {
  651. $file_arr[] = array("url"=>$OutFileURL."/download.php?_schemas=&a=".base64_encode(base64_encode($rs['serial_no'])),
  652. "file_name" => $rs['file_name'],
  653. "detail"=>$rs['upload_date'],
  654. "can_delete"=>_getLoginName() == $rs['upload_by']);
  655. }else{
  656. $file_arr[] = array("url"=>"main_new_version?action=ocean_order&operate=download&url=". (common::deCode($rs['file_path'] . DS . $rs['file_name'], 'E')),
  657. "file_name" => $rs['file_name'],
  658. "detail"=>$rs['upload_date'],
  659. "can_delete"=>_getLoginName() == $rs['upload_by']);
  660. }
  661. }
  662. }
  663. }
  664. }
  665. //$document_data[] = array("file_type"=>$file_type,"file"=>$file_arr);
  666. //按现在的逻辑,有值才会显示
  667. foreach($file_arr as $f){
  668. $document_data[] = array("file_type"=>$file_type,"file"=>$f);
  669. }
  670. }
  671. }
  672. $document_info = array("document_column"=>$document_column,"document_data" =>$document_data);
  673. $emailRecords = $this->getCommunicationNew($ocean["serial_no"]);
  674. $cc_email = common::excuteOneSql("select cc_email from public.online_ocean_communication where email_uuid='" . $ocean["serial_no"] . "' order by id desc limit 1");
  675. $email = $this->getEmail($ocean["serial_no"]);
  676. $email['cc_email'] = $cc_email;
  677. $email['emailRecords'] = $emailRecords;
  678. global $_COPYRIGHT;
  679. $data = array('transportInfo' => $transportInfo,
  680. 'basicInfo' => $basicInfo,
  681. 'businessPartners' => $businessPartners,
  682. 'ref_no' => $ref_no,
  683. 'packing' => $packing,
  684. 'marksAndDescription' => $marksAndDescription,
  685. 'containers' => $containers,
  686. 'simplexData' =>$simplexData,
  687. 'containerStatusData' => $containerStatusData,
  688. 'document_info' => $document_info,
  689. 'containers' => $containers,
  690. 'Milestones' => $Milestones,
  691. 'routes' => $routes,
  692. 'email' => $email,
  693. 'ams_ss' => md5(md5($ocean['serial_no'])),
  694. 'isf_ss' => $isf_ss,
  695. '_schemas' =>$_schemas,
  696. 'uncode' =>$uncode,
  697. 'serial_no' =>$serial_no,
  698. 'can_upload_doc' => strtolower($_SESSION['ONLINE_USER']['can_upload_doc']) == 't' || strtolower($_SESSION['ONLINE_USER']['can_view_doc']) == 't',
  699. 'canEdiVgm' => _canEdiVgm(),
  700. 'copyright' =>$_COPYRIGHT);
  701. common::echo_json_encode(200,$data);
  702. exit();
  703. }
  704. private function _ocean_excel() {
  705. //现在下载交给前端,后台最后只返回全部字段的列,
  706. $allColumn = column::getInstance()->getDisplayColumnAll('Ocean_Search');
  707. $allBookingColumns = column::getInstance()->tableColumns('Ocean_Search',$allColumn);
  708. common::echo_json_encode(200,array("msg"=>"success","allColums" => $allBookingColumns));
  709. exit;
  710. }
  711. private function _ams_isf_log(){
  712. global $cbpdb;
  713. $ams_ss = $_POST['ams_ss'];
  714. $isf_ss = $_POST['isf_ss'];
  715. $amsLog = array();
  716. //页面固定写死的信息
  717. $amsLog_column = array();
  718. $amsLog_column[] = array("title" =>"Date Time","field" =>"atime","formatter" =>"","type" =>"dateTime");
  719. $amsLog_column[] = array("title" =>"Code","field" =>"cbperrorcode","formatter" =>"","type" =>"normal");
  720. $amsLog_column[] = array("title" =>"Name","field" =>"isams_submit","formatter" =>"","type" =>"normal");
  721. $amsLog_column[] = array("title" =>"Description","field" =>"amslog","formatter" =>"","type" =>"normal");
  722. $amsLog["amsLog_column"] = $amsLog_column;
  723. $amsLog["msg"] = "Origin have not filed ACE-M1, no data found";
  724. $amsLog["data"] = array();
  725. if (_canViewAMSLog()) {
  726. $s = $ams_ss;
  727. //$s = "PDLA200127H";
  728. if (!empty($s)) {
  729. //$cc = $cbpdb->GetAll("select distinct h_bol from ams_information where md5(md5(from_serial_no)) = '" . pg_escape_string($s) . "'");
  730. $cc = $cbpdb->GetAll("select distinct h_bol from ams_information where h_bol = '" . pg_escape_string($s) . "'");
  731. foreach ($cc as $v){
  732. $amses[] = $cbpdb->GetAll("select * from ams_info where h_bol = '" . pg_escape_string($v['h_bol']) . "'");
  733. }
  734. //考虑一个情况
  735. if (count($amses) > 0) {
  736. $ams = $amses[0];
  737. $carrier_hbol = substr($ams[0]['m_bol'], 4);
  738. $carrier_scac = substr($ams[0]['m_bol'], 0, 4);
  739. if (empty($ams[0]['h_bol'])){
  740. $amsLog["msg"] = "Origin have not filed ACE-M1, no data found";
  741. $amsLog["data"] = array();
  742. }else{
  743. $log = $cbpdb->GetAll("select cbpreplytime as atime, amslog, cbperrorcode, isams_submit
  744. from v_e_amslog where hbol = '" . pg_escape_string($ams[0]['h_bol']) . "'
  745. and split_part(stationname, ',', 1) = split_part('" . pg_escape_string($ams[0]['station_name']) . "', ',', 1)
  746. order by cbpreplytime desc, substr(cbperrorcode, 2, 1) desc");
  747. $amsLog["msg"] = "";
  748. $amsLog["data"] = $log;
  749. }
  750. }
  751. }
  752. }
  753. $isfLog = array();
  754. //页面固定写死的信息
  755. $isfLog_column = array();
  756. $isfLog_column[] = array("title" =>"Date Time","field" =>"atime","formatter" =>"","type" =>"dateTime");
  757. $isfLog_column[] = array("title" =>"Code","field" =>"cbperrorcode","formatter" =>"","type" =>"normal");
  758. $isfLog_column[] = array("title" =>"Name","field" =>"isfsubmit","formatter" =>"","type" =>"normal");
  759. $isfLog_column[] = array("title" =>"Description","field" =>"isflog","formatter" =>"","type" =>"normal");
  760. $isfLog["isfLog_column"] = $isfLog_column;
  761. $isfLog["msg"] = "Origin have not filed ISF, no data found";
  762. $isfLog["data"] = array();
  763. if (_canViewISFLog()) {
  764. if (!empty($isf_ss)) {
  765. $ss = $isf_ss;
  766. $len = strlen($ss);
  767. $b = substr($ss, $len - 7) . substr($ss, 0, $len - 7);
  768. if (empty($b)){
  769. $isfLog["msg"] = "Origin have not filed ISF, no data found";
  770. $isfLog["data"] = array();
  771. }else{
  772. $isf = $cbpdb->GetRow("select * from ocean_isf where md5(md5(bol)) = '" . pg_escape_string($b) . "' or md5(md5(substr(bol, 5))) = '" . pg_escape_string($b) . "' order by id desc limit 1");
  773. }
  774. if (!empty($isf)) {
  775. if (!empty($isf['dob'])){
  776. $isf['dob'] = date("m/d/Y", strtotime($isf['dob']));
  777. }
  778. $msg = $cbpdb->GetAll("select cbpreplytime as atime, isflog, cbperrorcode, isfsubmit, hbol
  779. from v_e_isflog where (case when coalesce(isf_no, '')<>''
  780. then isf_no = '" . pg_escape_string($isf["isf_no"]) . "' else hbol = '" . pg_escape_string($isf["bol"]) . "'
  781. and stationname = '" . pg_escape_string($isf["station_name"]) . "' end)
  782. order by cbpreplytime desc, rowid desc");
  783. $isfLog["msg"] = "";
  784. $isfLog["data"] = $msg;
  785. }else{
  786. $isfLog["msg"] = "Origin have not filed ISF, no data found";
  787. $isfLog["data"] = array();
  788. }
  789. }
  790. }
  791. $data =array("msg"=>"success",
  792. "canViewAMSLog" => _canViewAMSLog(),
  793. "canViewISFLog" => _canViewISFLog(),
  794. "amsLog" =>$amsLog,
  795. "isfLog" =>$isfLog);
  796. common::echo_json_encode(200,$data);
  797. exit;
  798. }
  799. private function getEmail($serial_no) {
  800. return utils::getEmail($serial_no);
  801. }
  802. private function getCommunicationNew($serial_no) {
  803. $list = common::excuteListSql("select to_char(add_time, 'MM/dd/yyyy hh24:MI:ss') as add_times, * from public.online_ocean_communication where email_uuid='$serial_no' and refer_id = 0 order by id");
  804. $emialRecords =array();
  805. foreach ($list as $k => $v) {
  806. $msg =array();
  807. $msg["name"] = $v["add_by"];
  808. $msg["creatTime"] = $v["add_times"];
  809. $msg["content"] = urldecode($v["web_content"]);
  810. $emialRecords[] = $msg;
  811. }
  812. return $emialRecords;
  813. }
  814. /*
  815. * get file by hbol/destination
  816. * H:HBL
  817. * M: MBL
  818. * F: FL
  819. * I: C/I & Packing list
  820. */
  821. private function getFileByHbol($m_bol, $h_bol, $types, $m_bs, $display, $detail = FALSE,$job_no="") {
  822. $types = strtolower($types);
  823. $types = explode(";", $types);
  824. $m_bs = explode(";", $m_bs);
  825. $otheres = NULL;
  826. $filefilter = " ('TELEX') ";//过滤掉类型,单独配置 3537
  827. $OutFileURL = common::excuteOneSql("select item_value from config where item='OutFileURL'");
  828. $file = array();
  829. foreach ($types as $k => $type) {
  830. $m_b = $m_bs[$k];
  831. if (strtolower($m_b) == 'm')
  832. $sql = "SELECT from_system,serial_no,file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date from ra_online_doc_upload where (lower(bol) = '" . strtolower($m_bol) . "' or lower(bol) ='".strtolower($job_no)."' ) and lower(format_serailno) = '$type' and upper(coalesce((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2],'')) not in ".$filefilter." order by id desc";
  833. if (strtolower($m_b) == 'h')
  834. $sql = "SELECT from_system,serial_no,file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date from ra_online_doc_upload where lower(bol) = '" . strtolower($h_bol) . "' and lower(format_serailno) = '$type' and upper(coalesce((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2],'')) not in ".$filefilter." order by id desc";
  835. if (strtolower($m_b) == 'a')
  836. $sql = "SELECT from_system,serial_no,file_path, file_name, upload_by, to_char(upload_date, 'MM/DD/YYYY') as upload_date from ra_online_doc_upload where (lower(bol) = '" . strtolower($m_bol) . "' or lower(bol) = '" . strtolower($h_bol) . "' or lower(bol) ='".strtolower($job_no)."') and lower(format_serailno) = '$type' and upper(coalesce((string_to_array((string_to_array(file_name,'.'))[1], '_'))[2],'')) not in ".$filefilter." order by id desc";
  837. if (!empty($sql)) {
  838. $rss = common::excuteListSql($sql);
  839. foreach ($rss as $rs) {
  840. if ($rs['from_system']=="TOPOCEAN"||$rs['from_system']=="KSMART") {
  841. $file[] = array("url"=>$OutFileURL.'/download.php?_schemas=&a='.base64_encode(base64_encode($rs['serial_no'])),
  842. "file_name" => $rs['file_name'],
  843. "detail"=>$rs['upload_date'],
  844. "can_delete"=>_getLoginName() == $rs['upload_by']);
  845. }else {
  846. $file[] = array("url"=>"main_new_version?action=ocean_order&operate=download&url=". (common::deCode($rs['file_path'] . DS . $rs['file_name'], 'E')),
  847. "file_name" => $rs['file_name'],
  848. "detail"=>$rs['upload_date'],
  849. "can_delete"=>_getLoginName() == $rs['upload_by']);
  850. }
  851. }
  852. }
  853. }
  854. return $file;
  855. }
  856. /*
  857. * download file
  858. */
  859. private function _download() {
  860. $url = common::deCode($_GET['url'], 'D');
  861. common::download_file($url);
  862. }
  863. private function getOcanOrderSearchSql($type,$sqlWhere) {
  864. if($type == "Booked"){
  865. $Booked_sqlWhere = " and (1<>1 or dd.status ='Booked')";
  866. return "select count(1) from online_ocean
  867. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  868. when a.description='Cargo Pickup' then 'Cargo Received'
  869. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  870. when a.description='Departure' then 'Departed'
  871. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  872. when a.description='Arrived at Final Destination' then 'Completed'
  873. else 'Booked' END as status
  874. from ocean_milestone a
  875. where a.serial_no=online_ocean.serial_no
  876. and a.description in (
  877. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  878. order by id desc limit 1) dd on true" . $sqlWhere.$Booked_sqlWhere;
  879. }
  880. if($type == "Cargo Received"){
  881. $Cargo_Received_sqlWhere = " and (1<>1 or dd.status ='Cargo Received')";
  882. return "select count(1) from online_ocean
  883. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  884. when a.description='Cargo Pickup' then 'Cargo Received'
  885. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  886. when a.description='Departure' then 'Departed'
  887. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  888. when a.description='Arrived at Final Destination' then 'Completed'
  889. else 'Booked' END as status
  890. from ocean_milestone a
  891. where a.serial_no=online_ocean.serial_no
  892. and a.description in (
  893. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  894. order by id desc limit 1) dd on true" . $sqlWhere.$Cargo_Received_sqlWhere;
  895. }
  896. if($type == "Departed"){
  897. $Departed_sqlWhere = " and (1<>1 or dd.status ='Departed')";
  898. return "select count(1) from online_ocean
  899. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  900. when a.description='Cargo Pickup' then 'Cargo Received'
  901. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  902. when a.description='Departure' then 'Departed'
  903. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  904. when a.description='Arrived at Final Destination' then 'Completed'
  905. else 'Booked' END as status
  906. from ocean_milestone a
  907. where a.serial_no=online_ocean.serial_no
  908. and a.description in (
  909. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  910. order by id desc limit 1) dd on true" . $sqlWhere.$Departed_sqlWhere;
  911. }
  912. if($type == "Arrived"){
  913. $Arrived_sqlWhere = " and (1<>1 or dd.status ='Arrived')";
  914. return "select count(1) from online_ocean
  915. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  916. when a.description='Cargo Pickup' then 'Cargo Received'
  917. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  918. when a.description='Departure' then 'Departed'
  919. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  920. when a.description='Arrived at Final Destination' then 'Completed'
  921. else 'Booked' END as status
  922. from ocean_milestone a
  923. where a.serial_no=online_ocean.serial_no
  924. and a.description in (
  925. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  926. order by id desc limit 1) dd on true" . $sqlWhere.$Arrived_sqlWhere;
  927. }
  928. if($type == "Completed"){
  929. $Completed_sqlWhere = " and (1<>1 or dd.status ='Completed')";
  930. return "select count(1) from online_ocean
  931. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  932. when a.description='Cargo Pickup' then 'Cargo Received'
  933. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  934. when a.description='Departure' then 'Departed'
  935. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  936. when a.description='Arrived at Final Destination' then 'Completed'
  937. else 'Booked' END as status
  938. from ocean_milestone a
  939. where a.serial_no=online_ocean.serial_no
  940. and a.description in (
  941. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  942. order by id desc limit 1) dd on true" . $sqlWhere.$Completed_sqlWhere;
  943. }
  944. }
  945. private function save_vgm() {
  946. $schemas = $_POST["schemas"];
  947. $serial_no = common::deCode($_POST["serial_no"], 'D');
  948. $ocean = common::excuteObjectSql("select m_bol, master_base_number, from_station, h_bol from $schemas.ocean where serial_no='" . common::check_input($serial_no) . "'");
  949. $contact = common::excuteObjectSql("select company, city, state, zipcode, phone_1, fax, email_1, contactname_1, address_1, address_2, address_3, address_4 from ocean.contacts where contact_id='" . $ocean["from_station"] . "'");
  950. $address = $contact["address_1"];
  951. if (!empty($address)) {
  952. $address .= "\r\n";
  953. }
  954. $address .= $contact["address_2"];
  955. if (!empty($address)) {
  956. $address .= "\r\n";
  957. }
  958. $address .= $contact["address_3"];
  959. if (!empty($address)) {
  960. $address .= "\r\n";
  961. }
  962. $address .= $contact["address_4"];
  963. $exists = common::excuteOneSql("select serial_no from $schemas.ocean_vgm_masterbasenumber where master_base_number ilike '" . $ocean["master_base_number"] . "'");
  964. global $db;
  965. $db->StartTrans();
  966. if (empty($_POST["is_send"])) {
  967. $_POST["is_send"] = 'f';
  968. }
  969. if (empty($exists)) {
  970. $db->Execute("insert into ocean_vgm_masterbasenumber (master_base_number, serial_no) values ('" . $ocean["master_base_number"] . "', '$serial_no');");
  971. $value["serial_no"] = $serial_no;
  972. $value["carrier_booking_no"] = $_POST["all_carrier_booking"];
  973. $value["modify_user"] = _getLoginName();
  974. $value["modify_time"] = "now()";
  975. $value["authorized_email"] = !empty($_POST["authorized_email"]) ? $_POST["authorized_email"] : "";
  976. $value["authorized_tel"] = !empty($_POST["authorized_tel"]) ? $_POST["authorized_tel"] : "";
  977. $value["authorized_company"] = !empty($_POST["submitter"]) ? $_POST["submitter"] : "";
  978. $value["signature"] = !empty($_POST["signature"]) ? $_POST["signature"] : "";
  979. $value["is_send"] = $_POST["is_send"];
  980. $value["action"] = "New";
  981. $value["type"] = "Shipper";
  982. $value["m_bol"] = $ocean["m_bol"];
  983. $value["master_base_number"] = $ocean["master_base_number"];
  984. $value["shipper_id"] = $ocean["from_station"];
  985. $value["shipper"] = $contact["company"];
  986. $value["shipper_address"] = $address;
  987. $value["shipper_contactname"] = $contact["contactname_1"];
  988. $value["shipper_email"] = $contact["email_1"];
  989. $value["shipper_fax"] = $contact["fax"];
  990. $value["shipper_telephone"] = $contact["phone_1"];
  991. $value["update_uuid"] = utils::uuid();
  992. $value["h_bol"] = $ocean["h_bol"];
  993. $value["from_station"] = $ocean["from_station"];
  994. $sql = common::getInsertSqlNull("$schemas .ocean_vgm", $value);
  995. $db->Execute($sql);
  996. } else {
  997. $serial_no = $exists;
  998. $db->Execute("update ocean_vgm_masterbasenumber set id=id where master_base_number ilike '" . $ocean["master_base_number"] . "';");
  999. $db->Execute("update $schemas.ocean_vgm set is_send='" . $_POST["is_send"] . "', carrier_booking_no='" . $_POST["all_carrier_booking"] . "', modify_user='" . _getLoginName() . "', modify_time=now(),"
  1000. . "authorized_email='" . $_POST["authorized_email"] . "', authorized_tel='" . $_POST["authorized_tel"] . "', authorized_company='" . $_POST["submitter"] . "', signature='" . $_POST["signature"] . "', send_time=null "
  1001. . ", update_uuid='" . utils::uuid() . "' where master_base_number ilike '" . $ocean["master_base_number"] . "';");
  1002. }
  1003. $db->Execute("delete from ocean_vgm_container where serial_no ilike '" . $serial_no . "';");
  1004. foreach ($_POST["container_no"] as $i => $cv) {
  1005. $value1["serial_no"] = $serial_no;
  1006. $value1["carrier_booking_no"] = !empty($_POST["carrier_booking_no"][$i]) ? $_POST["carrier_booking_no"][$i] : "";
  1007. $value1["ctnr"] = !empty($_POST["container_no"][$i]) ? $_POST["container_no"][$i] : "";
  1008. $value1["size"] = !empty($_POST["size"][$i]) ? $_POST["size"][$i] : "";
  1009. $value1["vgm_weight"] = !empty($_POST["vgm_weight"][$i]) ? $_POST["vgm_weight"][$i] : "";
  1010. $value1["unit"] = !empty($_POST["vgm_kg_lg"][$i]) ? $_POST["vgm_kg_lg"][$i] : "";
  1011. $value1["vgm_time"] = !empty($_POST["vgm_date"][$i]) ? $_POST["vgm_date"][$i] : "";
  1012. $value1["cargo_weight_kgs"] = !empty($_POST["cargo_weight_kg"][$i]) ? $_POST["cargo_weight_kg"][$i] : "";
  1013. $value1["cargo_weight_lbs"] = !empty($_POST["cargo_weight_lb"][$i]) ? $_POST["cargo_weight_lb"][$i] : "";
  1014. $value1["vgm_method"] = !empty($_POST["vgm_method"][$i]) ? $_POST["vgm_method"][$i] : "";
  1015. $value1["master_base_number"] = $ocean["master_base_number"];
  1016. $sql = common::getInsertSqlNull("$schemas.ocean_vgm_container", $value1);
  1017. $db->Execute($sql);
  1018. }
  1019. if ($db->CompleteTrans() === FALSE) {
  1020. return "error";
  1021. } else {
  1022. return "success";
  1023. }
  1024. }
  1025. private function getOceanDetail($serial_no) {
  1026. $sql = "SELECT m_eta as _m_eta, h_bol as _h_bol, m_bol as _m_bol,job_no as _job_bol,
  1027. public.z_get_eta_dest(o.final_eta::date, o.eta_dest::text, o.service::text, o.m_eta::date, o.place_of_delivery::text, o.mport_of_discharge::text) as _eta_dest,
  1028. to_char(final_eta, 'MM/DD/YYYY') as _final_eta,
  1029. o.* ,sh.*, cn.* ,aa.*,dd.*,ee.status as new_status
  1030. from ocean o
  1031. left join LATERAL (select case when a.description='Booking Confirmation' then 'Booked'
  1032. when a.description='Cargo Pickup' then 'Cargo Received'
  1033. when a.description='Cargo Arrived at Origin' then 'Cargo Received'
  1034. when a.description='Departure' then 'Departed'
  1035. when a.description='Arrived at Final Destination Port Arrived' then 'Arrived'
  1036. when a.description='Arrived at Final Destination' then 'Completed'
  1037. else 'Booked' END as status
  1038. from ocean_milestone a
  1039. where a.serial_no=o.serial_no
  1040. and a.description in (
  1041. select regexp_split_to_table('Booking Confirmation,Cargo Pickup,Cargo Arrived at Origin,Departure,Arrived at Final Destination Port,Arrived at Final Destination', ','))
  1042. order by id desc limit 1) ee on true
  1043. LEFT JOIN LATERAL ( SELECT company as cn_company,
  1044. address_1 as cn_address_1,
  1045. address_2 as cn_address_2,
  1046. address_3 as cn_address_3,
  1047. address_4 as cn_address_4,
  1048. city as cn_city, state as cn_state, zipcode as cn_zipcode, country as cn_country,
  1049. phone_1 as cn_phone
  1050. FROM contacts c WHERE o.consignee::text = c.contact_id::text) cn ON true
  1051. LEFT JOIN LATERAL ( SELECT company as sh_company,
  1052. address_1 as sh_address_1,
  1053. address_2 as sh_address_2,
  1054. address_3 as sh_address_3,
  1055. address_4 as sh_address_4,
  1056. city as sh_city, state as sh_state, zipcode as sh_zipcode, country as sh_country,
  1057. phone_1 as sh_phone
  1058. FROM contacts c WHERE o.shipper::text = c.contact_id::text) sh ON true
  1059. LEFT JOIN LATERAL ( SELECT company as aa_company,
  1060. address_1 as aa_address_1,
  1061. address_2 as aa_address_2,
  1062. address_3 as aa_address_3,
  1063. address_4 as aa_address_4,
  1064. city as aa_city, state as aa_state, zipcode as aa_zipcode, country as aa_country,
  1065. phone_1 as aa_phone
  1066. FROM contacts c WHERE o.origin_station::text = c.contact_id::text) aa ON true
  1067. LEFT JOIN LATERAL ( SELECT company as dd_company,
  1068. address_1 as dd_address_1,
  1069. address_2 as dd_address_2,
  1070. address_3 as dd_address_3,
  1071. address_4 as dd_address_4,
  1072. city as dd_city, state as dd_state, zipcode as dd_zipcode, country as dd_country,
  1073. phone_1 as dd_phone
  1074. FROM contacts c WHERE o.destination_station::text = c.contact_id::text) dd ON true
  1075. where lower(serial_no) = '" . strtolower($serial_no) . "'";
  1076. return $sql;
  1077. }
  1078. private function returnOceanDetailData($ocean,$state){
  1079. $data = array();
  1080. //处理shipment data暂时写死
  1081. $simplexData = array();
  1082. $simplexData[] = array("index" =>1,"label" =>"Place of Receipt",
  1083. "path" =>$ocean['place_of_receipt_exp']."/".$ocean['place_of_receipt'],"isArrival" =>$state == 1 ? true : false);
  1084. $simplexData[] = array("index" =>2,"label" =>"Port of Loading",
  1085. "path" =>$ocean['fport_of_loading_exp_exp']."/".$ocean['fport_of_loading_exp'],"isArrival" =>$state == 2 ? true : false,
  1086. "children" =>array(array("label" =>"Cargo arrival at Origin","date" =>"2024-02-01"),
  1087. array("label" =>"'Departure","date" =>"2024-02-01")));
  1088. $simplexData[] = array("index" =>3,"label" =>"Port of Discharge",
  1089. "path" =>$ocean['mport_of_discharge_exp']."/".$ocean['mport_of_discharge'],"isArrival" =>$state == 3 ? true : false,
  1090. "children" =>array(array("label" =>"ETA","date" =>"2024-02-01")));
  1091. $simplexData[] = array("index" =>4,"label" =>"Place of Delivery",
  1092. "path" =>$ocean['place_of_delivery_exp']."/".$ocean['place_of_delivery'],"isArrival" =>$state == 4 ? true : false);
  1093. $data['shipmentData'] = $simplexData;
  1094. //处理transportInfo信息数据
  1095. $transportInfo = array("Tracking No." =>$ocean['tracking_no'],"status"=>$ocean['new_status'],"mode" => "Ocean Freight",
  1096. "origin" =>$ocean['origin_station'],"destination" =>$ocean['destination_station'],
  1097. "etd" =>$ocean['f_etd'],"atd" =>"","eta" =>$ocean['m_eta'],"ata" =>"");
  1098. $data['transportInfo'] = $transportInfo;
  1099. //处理basicInfo信息数据
  1100. $vessel = utils::outDisplayForMerge($ocean['f_vessel'],$ocean['m_vessel']);
  1101. $voyage = utils::outDisplayForMerge($ocean['f_voyage'],$ocean['m_voyage']);
  1102. $basicInfo = array("MAWB/MBL No." =>$ocean['m_bol'],"HAWB/HBOL" => $ocean['h_bol'],"Carrier_Booking_No" =>$ocean['carrier_booking'],
  1103. "PO_NO" =>$ocean['po_no'],"Vessel/Airline" =>$vessel,"Voyage/Filght" =>$voyage,
  1104. "Incoterm" =>$ocean['terms'],"Service_Type" =>$ocean['service']);
  1105. $data['basicInfo'] = $basicInfo;
  1106. //处理 拼接地址 ocean表单exp 字段无法精准分割电话和地址信息,只能从contacts表里查询
  1107. $shipper_address = common::retStationInfo($ocean['sh_address_1'], $ocean['sh_address_2'], $ocean['sh_address_3'], $ocean['sh_address_4'],
  1108. $ocean['sh_city'], $ocean['sh_state'], $ocean['sh_zipcode'], $ocean['sh_country']);
  1109. $consignee_address = common::retStationInfo($ocean['cn_address_1'], $ocean['cn_address_2'], $ocean['cn_address_3'], $ocean['cn_address_4'],
  1110. $ocean['cn_city'], $ocean['cn_state'], $ocean['cn_zipcode'], $ocean['cn_country']);
  1111. $origin_address = common::retStationInfo($ocean['aa_address_1'], $ocean['aa_address_2'], $ocean['aa_address_3'], $ocean['aa_address_4'],
  1112. $ocean['aa_city'], $ocean['aa_state'], $ocean['aa_zipcode'], $ocean['aa_country']);
  1113. $destination_address = common::retStationInfo($ocean['dd_address_1'], $ocean['dd_address_2'], $ocean['dd_address_3'], $ocean['dd_address_4'],
  1114. $ocean['dd_city'], $ocean['dd_state'], $ocean['dd_zipcode'], $ocean['dd_country']);
  1115. $shipperPartners = array("company" =>$ocean['sh_company'],"address"=>$shipper_address,"phone"=>$ocean['sh_phone']);
  1116. $consigneePartners = array("company" =>$ocean['cn_company'],"address"=>$consignee_address,"phone"=>$ocean['cn_phone']);
  1117. $originPartners = array("company" =>$ocean['aa_company'],"address"=>$origin_address,"phone"=>$ocean['aa_phone']);
  1118. $destinationPartners = array("company" =>$ocean['dd_company'],"address"=>$destination_address,"phone"=>$ocean['dd_phone']);
  1119. $businessPartners = array("shipper"=>$shipperPartners,"consignee" => $consigneePartners,"origin" => $originPartners,"destination" => $destinationPartners);
  1120. $data['businessPartners'] = $businessPartners;
  1121. //处理routes 转船可能有多个情况
  1122. $routes = array(array("mode" =>"Sea", "origin" =>$ocean['origin_station'],
  1123. "destination" => $ocean['destination_station'], "etd" => $ocean['f_etd'],"atd" => "",
  1124. "eta" =>$ocean['m_eta'],"ata" =>"","vessel" =>$vessel,"voyageNo" =>$voyage));
  1125. $data['routes'] = $routes;
  1126. //处理marksAndDescription
  1127. $marksAndDescription = array("marks"=>$ocean['marks'],"description"=>$ocean['description']);
  1128. $data['marksAndDescription'] = $marksAndDescription;
  1129. return $data;
  1130. }
  1131. private function getMilestonesInfo($ocean){
  1132. //Milestones info 列名固定
  1133. $Milestones_column = array();
  1134. $Milestones_column[] = array("title" =>"Milestones","field" =>"milestones","formatter" =>"","type" =>"normal");
  1135. $Milestones_column[] = array("title" =>"Date Time","field" =>"date_time","formatter" =>"","type" =>"dateTime");
  1136. $Milestones_column[] = array("title" =>"Locations","field" =>"locations","formatter" =>"","type" =>"normal");
  1137. $Milestones_column[] = array("title" =>"Remarks","field" =>"remarks","formatter" =>"","type" =>"normal");
  1138. //Milestones 数据信息待定
  1139. $Milestones_data = array();
  1140. $Milestones_data_arr = common::excuteListSql("select description,act_date||' '||act_time as date_time, remark,timezone from ocean_milestone a
  1141. where a.serial_no='".$ocean["serial_no"]."' order by id");
  1142. foreach($Milestones_data_arr as $mda){
  1143. $Milestones_data[] = array("milestones"=>$mda['description'],"date_time"=>$mda['date_time'],"timezone" =>$mda['timezone'],
  1144. "locations" => "", "remarks" =>$mda['remark']);
  1145. }
  1146. $Milestones = array("Milestones_column"=>$Milestones_column,"Milestones_data" =>$Milestones_data);
  1147. return $Milestones;
  1148. }
  1149. }
  1150. ?>