ocean_order.class.php 69 KB

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