main_new_version.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <?php
  2. $max_ec = ini_get('max_execution_time'); //set max_excution_time
  3. ini_set('max_execution_time', '600');
  4. $memory_limit = "";
  5. $action = "";
  6. if (isset($_GET['action']))
  7. $action = strtolower($_GET['action']);
  8. if (isset($_POST['action']))
  9. $action = strtolower($_POST['action']);
  10. include "include.ini.php";
  11. include 'service/ocean_booking.class.php';
  12. include 'service/ocean_order.class.php';
  13. include 'service/operation_log.class.php';
  14. include 'service/search.class.php';
  15. include 'service/column.class.php';
  16. include 'service/ajax.class.php';
  17. include 'service/login.class.php';
  18. include 'service/tools.class.php';
  19. //为了调用,临时做一个登录动作
  20. $_POST['uname'] = "ra.admin";
  21. $_POST['psw'] = "abc123456789";
  22. //login::getInstance()->do_login_auto();
  23. //验证路由权限
  24. common::securityCheckHandNew($action);
  25. if (_is_only_vgm()) {
  26. Header("Location:main.php?action=main");
  27. }
  28. error_log("--------------前端请求post参数---------------");
  29. error_log(utils::jsonFiltration("null", "\"\"", json_encode($_POST)));
  30. error_log("--------------前端请求get参数---------------");
  31. error_log(utils::jsonFiltration("null", "\"\"", json_encode($_GET)));
  32. //Operation log 日志记录
  33. utils::operation_log_records();
  34. switch ($action) {
  35. case 'ocean_booking':
  36. ocean_booking::getInstance()->ocean_booking();
  37. break;
  38. case 'ocean_order':
  39. include ONLINE_ROOT . 'libs' . DS . 'ams_config.ini.php';
  40. ocean_order::getInstance()->ocean_order();
  41. break;
  42. case 'ajax':
  43. echo ajax::getInstance()->run();
  44. break;
  45. case 'opreation_log':
  46. echo operation_log::getInstance()->operation_log();
  47. break;
  48. /* display index page */
  49. case 'main':
  50. if (_isAdmin())
  51. $sql = "select f_column, min(menu_id) as menu_id, max(menu_icon_font) as menu_icon_font from public.ra_online_permission where has_new_version=true group by f_column order by min(order_by)";
  52. elseif (_isNewUser())
  53. $sql = "select f_column, min(menu_id) as menu_id, max(menu_icon_font) as menu_icon_font from public.ra_online_permission where has_new_version=true and customer_check = true group by f_column ORDER BY min(order_by)";
  54. else
  55. $sql = "select p.f_column, min(menu_id) as menu_id, max(menu_icon_font) as menu_icon_font from public.ra_online_user_permission up left join public.ra_online_permission p on up.p_id = p.id where has_new_version=true and lower(user_name) = '" . common::check_input(strtolower(_getLoginName())) . "' group by p.f_column ORDER BY min(p.order_by)";
  56. $rs = common::excuteListSql($sql);
  57. if (empty($rs) && _isApexLogin()) {
  58. $sql = "select f_column, min(menu_id) as menu_id, max(menu_icon_font) as menu_icon_font from public.ra_online_permission where has_new_version=true and default_check = true group by f_column ORDER BY min(order_by)";
  59. $rs = common::excuteListSql($sql);
  60. }
  61. $msg = "";
  62. foreach ($rs as $value) {
  63. $msg .= '<div class="menu_first with_second" id="' . $value['menu_id'] . '" class="' . $value['menu_id'] . '_section"><div class="menu_icon_left"><span class="icon iconfont ' . $value['menu_icon_font'] . '"></span></div><div class="menu_title"><span>&nbsp;' . $value['f_column'] . '</span></div><div class="menu_icon_right icon_right"><span class="icon iconfont icon-you"></span>
  64. </div></div><ul class="menu_second" >';
  65. if (_isAdmin())
  66. $ll = common::excuteListSql("select s_column, url_action, sub_menu_id from public.ra_online_permission where has_new_version=true and f_column = '" . common::check_input($value['f_column']) . "' ORDER BY order_by");
  67. elseif (_isNewUser())
  68. $ll = common::excuteListSql("select s_column, url_action, sub_menu_id from public.ra_online_permission where has_new_version=true and customer_check = true and f_column = '" . common::check_input($value['f_column']) . "' ORDER BY order_by");
  69. else
  70. $ll = common::excuteListSql("select s_column, url_action, sub_menu_id from public.ra_online_permission p left join public.ra_online_user_permission gp on gp.p_id = p.id where has_new_version=true and f_column = '" . common::check_input($value['f_column']) . "' and lower(gp.user_name) = '" . common::check_input(strtolower(_getLoginName())) . "' ORDER BY p.order_by");
  71. if (empty($ll) && _isApexLogin()) {
  72. $ll = common::excuteListSql("select s_column, url_action, sub_menu_id from public.ra_online_permission where has_new_version=true and f_column = '" . common::check_input($value['f_column']) . "' and default_check = true ORDER BY order_by");
  73. }
  74. foreach ($ll as $v) {
  75. //非maria 帐号的全部移除Ocean Gross Profit Repor 权限
  76. if((strtolower(_getLoginName()) != "maria" && strtolower(_getLoginName()) != "doc.yuki") && $v["url_action"] == "ocean_gross_profit"){
  77. continue;
  78. }
  79. $msg .= '<li class="' . $v['sub_menu_id'] . '" onclick="commonRedirect(this, \'main_new_version.php?action=' . $v['url_action'] . '\', \'' . $v['sub_menu_id'] . '_section\')"><span class="menu_second_span">' . $v['s_column'] . '</span></li>';
  80. }
  81. $msg .= '</ul>';
  82. }
  83. //处理返回的格式
  84. $data = array();
  85. if (_isCustomerLogin()) {
  86. $data["isCustomerLogin"] = "yes";
  87. }
  88. $data["msg"] = $msg;
  89. $data["redirectTarget"] = $_SESSION['redirectTarget'];
  90. common::echo_json_encode("200",$data);
  91. break;
  92. case 'main_report':
  93. $type = $_REQUEST["r_type"];
  94. $container_type = $_REQUEST["container_type"];
  95. if (empty($_REQUEST["b_date"])) {
  96. $bdate = "null";
  97. } else {
  98. $bdate = $_REQUEST["b_date"];
  99. $bdate = "'$bdate'";
  100. }
  101. if (empty($_REQUEST["e_date"])) {
  102. $edate = "null";
  103. } else {
  104. $edate = $_REQUEST["e_date"];
  105. $edate = "'$edate'";
  106. }
  107. //Demo测试数据 日期全为空
  108. $edate = "null";
  109. $bdate = "null";
  110. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  111. $sqlWhere = common::check_input($sqlWhere);
  112. $sqlWhere = " " . $sqlWhere;
  113. $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  114. . "r (c bigint, e integer, b integer, d text)");
  115. $key = "[";
  116. $value = "[";
  117. $totalValue = 0;
  118. foreach ($list as $vv) {
  119. if ($key != "[") {
  120. $key .= ",";
  121. $value .= ",";
  122. }
  123. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  124. $key .= '"' . $vv["d"] . '"';
  125. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  126. $totalValue = $totalValue + $vv["c"];
  127. } else {
  128. if ($vv["e"] == -1) {
  129. $key .= '"Over 80 Days"';
  130. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  131. } else {
  132. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  133. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  134. }
  135. $totalValue = $totalValue + $vv["c"];
  136. }
  137. }
  138. $key .= "]";
  139. $value .= "]";
  140. //$data = array($key, $value, $totalValue);
  141. //处理返回原表数据格式
  142. $data = common::mian_repot_do($value,$type,$totalValue);
  143. common::echo_json_encode(200, $data);
  144. exit();
  145. break;
  146. case 'main_report_kpi':
  147. $type = $_REQUEST["r_type"];
  148. $container_type = $_REQUEST["container_type"];
  149. if (empty($_REQUEST["b_date"])) {
  150. $bdate = "null";
  151. } else {
  152. $bdate = $_REQUEST["b_date"];
  153. $bdate = "'$bdate'";
  154. }
  155. if (empty($_REQUEST["e_date"])) {
  156. $edate = "null";
  157. } else {
  158. $edate = $_REQUEST["e_date"];
  159. $edate = "'$edate'";
  160. }
  161. //Demo测试数据 日期全为空
  162. $edate = "null";
  163. $bdate = "null";
  164. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  165. $sqlWhere = common::check_input($sqlWhere);
  166. $sqlWhere = " " . $sqlWhere;
  167. $list = common::excuteListSql("select * from public.online_order_status_date_kpi('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  168. . "r (c bigint, d text)");
  169. error_log("select * from public.online_order_status_date_kpi('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  170. . "r (c bigint, d text)");
  171. $key = "[";
  172. $value = "[";
  173. $totalValue = 0;
  174. foreach ($list as $vv) {
  175. if ($key != "[") {
  176. $key .= ",";
  177. $value .= ",";
  178. }
  179. if ($type == "ata_r3" || $type == "atd_r4" ) {
  180. $key .= '"' . $vv["d"] .'"';
  181. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] .'"}';
  182. $totalValue = $totalValue + $vv["c"];
  183. }
  184. }
  185. $key .= "]";
  186. $value .= "]";
  187. //处理返回原表数据格式
  188. $ETDList = array();
  189. $value_arr = json_decode($value,true);
  190. foreach($value_arr as $arr){
  191. $color = common::getItemStyle($type,$arr['name']);
  192. $ETDList[] = array("value" =>intval($arr['value']),"name" =>$arr['name'],"itemStyle" =>array("color" =>$color));
  193. }
  194. if($type == 'atd_r4'){
  195. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Departure","title2" =>"(ATD-ETD)");
  196. }
  197. if($type == 'ata_r3'){
  198. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Arrival","title2" =>"(ATD-ETD)");
  199. }
  200. common::echo_json_encode(200, $data);
  201. exit();
  202. break;
  203. case 'main_report_container_bar':
  204. //新UI 要ALL 20 40 45 四份数据同时查询,且是柱状图,所以与r3 r4查询分开
  205. $container_type_arr = array("20","40","45");
  206. $container_type_param = $_REQUEST["container_type"];
  207. $ContainerCounSeries = array();
  208. foreach($container_type_arr as $_container_type){
  209. $container_type = $_container_type;
  210. $type = $_REQUEST["r_type"];
  211. if (empty($_REQUEST["b_date"])) {
  212. $bdate = "null";
  213. } else {
  214. $bdate = $_REQUEST["b_date"];
  215. $bdate = "'$bdate'";
  216. }
  217. if (empty($_REQUEST["e_date"])) {
  218. $edate = "null";
  219. } else {
  220. $edate = $_REQUEST["e_date"];
  221. $edate = "'$edate'";
  222. }
  223. //Demo测试数据 日期全为空
  224. $edate = "null";
  225. $bdate = "null";
  226. $list= array();
  227. //all 查询所有
  228. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  229. $sqlWhere = common::check_input($sqlWhere);
  230. $sqlWhere = " " . $sqlWhere;
  231. if(strtolower($container_type_param) == "all"){
  232. $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  233. . "r (c bigint, e integer, b integer, d text)");
  234. }else{
  235. if($container_type_param == $_container_type){
  236. $list = common::excuteListSql("select * from public.online_order_status_date('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text) "
  237. . "r (c bigint, e integer, b integer, d text)");
  238. }
  239. }
  240. $key = "[";
  241. $value = "[";
  242. $totalValue = 0;
  243. foreach ($list as $vv) {
  244. if ($key != "[") {
  245. $key .= ",";
  246. $value .= ",";
  247. }
  248. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  249. $key .= '"' . $vv["d"] . '"';
  250. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  251. $totalValue = $totalValue + $vv["c"];
  252. } else {
  253. if ($vv["e"] == -1) {
  254. $key .= '"Over 80 Days"';
  255. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  256. } else {
  257. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  258. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  259. }
  260. $totalValue = $totalValue + $vv["c"];
  261. }
  262. }
  263. $key .= "]";
  264. $value .= "]";
  265. $key_arr = json_decode($key,true);
  266. $value_arr = json_decode($value,true);
  267. $data = array();
  268. $total = 0;
  269. $max = 0;
  270. foreach($value_arr as $arr){
  271. $data[] = intval($arr['value']);
  272. $total = $total + intval($arr['value']);
  273. $max = $max < intval($arr['value']) ? intval($arr['value']) : $max;
  274. }
  275. $ContainerCounSeries[$container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
  276. }
  277. //处理返回时数据格式
  278. $ContainerCounSeries_return = array();
  279. $ContainerCount_Title = $key_arr;
  280. $total = 0;
  281. $max_all = 0;
  282. foreach($ContainerCounSeries as $k =>$v){
  283. //这个type 是页面传过来的
  284. $color = common::getItemStyle($type,$k);
  285. $total = $total + $v['total'];
  286. $ContainerCounSeries_return[] = array("name"=>$k,"type"=>"bar","emphasis" => array("focus" =>"none"),
  287. "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
  288. $max_all = $max_all + $v['max'];
  289. }
  290. //处理返回原表数据格式
  291. $interval = utils::calculateTicks(0,$max_all,5);
  292. if($interval == 0){
  293. //处理返回默认值
  294. $interval = 2;
  295. }
  296. $returnData = array("ContainerCount_Title"=>"Total: $total","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
  297. "min" => 0,"Max" =>$interval*5,"interval" =>$interval);
  298. common::echo_json_encode(200, $returnData);
  299. exit();
  300. break;
  301. case 'main_report_co2e_bar':
  302. $returnData = common::getCo2eBar();
  303. common::echo_json_encode(200, $returnData);
  304. exit();
  305. break;
  306. case 'main_report_top10_bar':
  307. $returnData = common::getTopBar();
  308. common::echo_json_encode(200, $returnData);
  309. exit();
  310. break;
  311. case 'main_map':
  312. $uncode = $_POST["uncode"];
  313. $serial_no = $_POST["serial_no"];
  314. $unall = explode("|", $uncode);
  315. $sql = "";
  316. if (!empty($unall[0]) && $unall[0] != "''") {
  317. $sql .= "select lon as lng, lat as lat, uncode, 'Place of receipt: '||name1 as location_namewo, 'por' as type from vessel.vt_unlocode where "
  318. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  319. . "($unall[0])";
  320. }
  321. if (!empty($unall[1]) && $unall[1] != "''") {
  322. if (!empty($sql)) {
  323. $sql .= " union ";
  324. }
  325. $sql .= "select lon as lng, lat as lat, uncode, 'POL: '||name1 as location_namewo, 'pol' as type from vessel.vt_unlocode where "
  326. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  327. . "($unall[1])";
  328. }
  329. if (!empty($unall[2]) && $unall[2] != "''") {
  330. if (!empty($sql)) {
  331. $sql .= " union ";
  332. }
  333. $sql .= "select lon as lng, lat as lat, uncode, 'POD: '||name1 as location_namewo, 'pod' as type from vessel.vt_unlocode where "
  334. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  335. . "($unall[2])";
  336. }
  337. if (!empty($unall[3]) && $unall[3] != "''") {
  338. if (!empty($sql)) {
  339. $sql .= " union ";
  340. }
  341. $sql .= "select lon as lng, lat as lat, uncode, 'Place of delivery: '||name1 as location_namewo, 'poe' as type from vessel.vt_unlocode where "
  342. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  343. . "($unall[3])";
  344. }
  345. $tkStatus = common::excuteListSql("select tl.by_pickup, g.consignee_exp, g.pickup_from_exp, c.ctnr, g.deliveryto_exp, g.serial_no, tl.location, tl.type, tl.id,
  346. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  347. from public.tk_general g, public.tk_commodity c left join public.tk_location tl on c.serial_no=tl.serial_no
  348. where g.serial_no=c.serial_no and g.bol=(select m_bol from public.ocean where serial_no='$serial_no') order by tl.order_id");
  349. foreach ($tkStatus as $vv) {
  350. $ll = explode(",", $vv["location"]);
  351. if ($vv["by_pickup"] == "t") {
  352. $pf = explode("\r\n", $vv["pickup_from_exp"]);
  353. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  354. $dt = explode("\r\n", $vv["consignee_exp"]);
  355. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  356. } else {
  357. $pf = explode("\r\n", $vv["consignee_exp"]);
  358. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  359. $dt = explode("\r\n", $vv["deliveryto_exp"]);
  360. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  361. }
  362. if ($vv["type"] == "26" && !empty($ll[1])) {
  363. if (!empty($sql)) {
  364. $sql .= " union ";
  365. }
  366. $sql .= "select '" . $ll[1] . "' as lng, '" . $ll[0] . "' as lat, '" . $vv["ctnr"] . "' as uncode, 'Pick up: " . $vv["utime"] . "<br>'||'" . $pf . "' as location_namewo, 'pickup' as type";
  367. } elseif ($vv["type"] == "25" && !empty($ll[1])) {
  368. if (!empty($sql)) {
  369. $sql .= " union ";
  370. }
  371. $sql .= "select '" . $ll[1] . "' as lng, '" . $ll[0] . "' as lat, '" . $vv["ctnr"] . "' as uncode, 'Delivery: " . $vv["utime"] . "<br>'||'" . $dt . "' as location_namewo, 'delivery' as type";
  372. }
  373. }
  374. if (!empty($sql)) {
  375. $gps = common::excuteListSql($sql . "");
  376. }
  377. if (!empty($serial_no)) {
  378. $all = explode(",", $serial_no);
  379. foreach ($all as $a) {
  380. $rs = common::excuteOneSql("select public.get_vessel_position('$a'::text)");
  381. if (!empty($rs)) {
  382. $rss = explode("|", $rs);
  383. $lng_lat = explode(",", $rss[1]);
  384. $gps[] = array("lng" => $lng_lat[0], "lat" => $lng_lat[1], "uncode" => "", "location_namewo" => "", "type" => "vessel", "vessel_name" => $rss[2], "m_shipname" => "", "mmsi" => "", "imo" => "", "m_shipstate" => "", "m_shiptype" => "", "m_dest" => "", "m_newshiparrive" => "", "m_newlasttime" => "", "lasttime" => "", "sub" => "");
  385. }
  386. }
  387. }
  388. $data = array("gps" => $gps);
  389. common::echo_json_encode("200", $data);
  390. exit();
  391. break;
  392. case 'main_map_new':
  393. $serial_no = $_POST["serial_no"];
  394. $sql = "with ss as (select '$serial_no' as sn)
  395. , aa as (
  396. select place_of_receipt_un, place_of_delivery_un, fport_of_loading_un, mport_of_discharge_un, port_of_loading, port_of_discharge, place_of_delivery_exp, place_of_receipt_exp from public.online_ocean oo where serial_no=(select sn from ss) limit 1
  397. )
  398. , v1 as (select public.get_vessel_position(sn::text) bbb from ss)
  399. , t1 as (select tl.upload_time, tl.by_pickup, split_part(g.consignee_exp,'\n',1) as consignee_exp, split_part(g.pickup_from_exp,'\n',1) as pickup_from_exp, c.ctnr, split_part(g.deliveryto_exp,'\n',1) as deliveryto_exp, g.serial_no, tl.location, tl.type, tl.id,
  400. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  401. from public.tk_general g, public.tk_commodity c left join public.tk_location tl on c.serial_no=tl.serial_no
  402. where g.serial_no=c.serial_no and g.bol=(select m_bol from public.ocean where serial_no=(select sn from ss)) order by tl.order_id)
  403. , vv as (select split_part(split_part(bbb, '|', 2), ',', 1)::numeric as lng, split_part(split_part(bbb, '|', 2), ',', 2)::numeric as lat, 'Vessel: '||split_part(bbb, '|', 3) as infor, 5 as sort, null::timestamp without time zone as stime, 'vessel'::text as ptype from v1 where bbb is not null and bbb<>'')
  404. , tt as (select split_part(location, ',', 2)::numeric as lng, split_part(location, ',', 1)::numeric as lat, (
  405. case when type='26' then ctnr||': Pick up: '||utime||', '||(case when by_pickup=true then pickup_from_exp else consignee_exp end)
  406. else ctnr||': Delivery: '||utime||', '||(case when by_pickup=true then consignee_exp else deliveryto_exp end)
  407. end
  408. ) as infor, 6 as sort, upload_time as stime, case when type='26' then 'pickup'::text else 'delivery'::text end as ptype from t1 where location is not null and location<>'')
  409. , rr as (
  410. select lon as lng, lat as lat, 'Place of receipt: '||place_of_receipt_exp as infor, 0 as sort, null::timestamp without time zone as stime, 'por'::text as ptype from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=place_of_receipt_un
  411. union all
  412. select lon as lng, lat as lat, 'POL: '||port_of_loading as infor, 1 as sort, null::timestamp without time zone as stime, 'pol'::text as ptype from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=fport_of_loading_un
  413. union all
  414. select lon as lng, lat as lat, 'POD: '||port_of_discharge as infor, 2 as sort, null::timestamp without time zone as stime, 'pod'::text as ptype from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=mport_of_discharge_un
  415. union all
  416. select lon as lng, lat as lat, 'Place of delivery: '||place_of_delivery_exp as infor, 3 as sort, null::timestamp without time zone as stime, 'poe'::text as ptype from vessel.vt_unlocode, aa where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=place_of_delivery_un
  417. union all
  418. select * from vv
  419. union all
  420. select * from tt
  421. )
  422. select * from rr order by sort, stime";
  423. $rss = common::excuteListSql($sql);
  424. common::echo_json_encode("200", $rss);
  425. exit();
  426. break;
  427. case 'main_welcome':
  428. $cp = common::check_input($_POST ['cp']); //current_page
  429. $ps = common::check_input($_POST ['ps']); //ps
  430. if (empty($ps))
  431. $ps = 10;
  432. $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  433. //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天
  434. if(isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes"){
  435. $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
  436. }else{
  437. $date_type = common::check_input($_POST ['date_type']);
  438. if (isset($_POST['date_start']) && !empty($_POST['date_start']))
  439. $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_POST['date_start']) . " 00:00:00'";
  440. if (isset($_POST['date_end']) && !empty($_POST['date_end']))
  441. $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_POST['date_end']) . " 23:59:59'";
  442. }
  443. $rc = $_POST ['rc'];
  444. if ($rc == - 1) {
  445. $sql = "SELECT count(1) from public.online_ocean" . $sqlWhere ." and last_status_315_update_time is not null";
  446. $rc = common::excuteOneSql($sql);
  447. error_log($sql);
  448. }
  449. $tp = ceil($rc / $ps);
  450. if ($rc > 0) {
  451. $sql = "SELECT serial_no,last_status_city, consignee, shipper, h_bol,
  452. to_char(etd, 'MM/DD/YYYY'::text) as etd, to_char(eta, 'MM/DD/YYYY'::text) AS eta,
  453. fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un, ctnrs, count_cntr, last_status_ctnr,booking_no,
  454. to_char(last_status_315_date, 'MM/DD/YYYY'::text) as last_status_315_date,last_status_315_code, last_status_loc, last_status_city, order_from
  455. FROM public.online_ocean
  456. $sqlWhere and last_status_315_update_time is not null";
  457. if (_isDemo()) {
  458. $sql .= " ORDER BY eta DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  459. } else {
  460. $sql .= " ORDER BY last_status_315_update_time DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  461. }
  462. $rss = common::excuteListSql($sql);
  463. //RecentStatusList
  464. $RecentStatusList = array();
  465. foreach ($rss as $key => $value) {
  466. $Arrived = utils::outDisplayForMerge(common::getStatusDesc($value["last_status_315_code"]),common::_toString($value["last_status_loc"]),";");
  467. $RecentStatusList[] = array("Title"=>$value['h_bol'],
  468. "name"=>"MSC SHANVI III / HD433A",
  469. "bookingNumber" =>$value['booking_no'],
  470. "IsSubscribe" =>false,
  471. "shipperName"=>$value['shipper'],
  472. "consigneeName" =>$value['consignee'],
  473. "startStation"=>$value['fport_of_loading_un'],
  474. "endStation"=>$value['mport_of_discharge_un'],
  475. "ETD"=>$value['etd'],
  476. "ETA"=>$value['eta'],
  477. "type"=>"Completed",
  478. "Arrived"=>$Arrived,
  479. "Time"=>$value["last_status_315_date"],
  480. "a" =>common::deCode($value['serial_no'], 'E'));
  481. }
  482. $arrTmp = array('searchData' => $RecentStatusList,
  483. 'Management' => common::getManagement(),
  484. 'is_customer' =>_isCustomerLogin(),
  485. 'rc' => $rc,
  486. 'ps' => $ps,
  487. 'cp' => $cp,
  488. 'tp' => $tp);
  489. } else {
  490. $arrTmp = array('searchData' => array(),
  491. 'Management' => common::getManagement());
  492. }
  493. common::echo_json_encode(200,$arrTmp);
  494. exit();
  495. break;
  496. case 'save_layout':
  497. $management = json_encode($_POST["management"]);
  498. common::excuteUpdateSql("update public.ra_online_user set management = '$management' where lower(user_login) = '" . strtolower(_getLoginName()) . "'");
  499. $returnData = array("msg" => "success");
  500. common::echo_json_encode(200, $returnData);
  501. exit();
  502. break;
  503. case 'password':
  504. tools::getInstance()->updatePassword();
  505. break;
  506. default:
  507. $data = array(
  508. 'msg' => 'Page not found',
  509. );
  510. common::echo_json_encode(500, $data);
  511. }
  512. $db->Close();
  513. $db = null;
  514. if ($max_ec > 0)
  515. ini_set('max_execution_time', $max_ec); //recover old value
  516. if (!empty($memory_limit))
  517. ini_set('memory_limit', $memory_limit);
  518. ?>