ajax.class.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of auto
  7. *
  8. * @author Administrator
  9. */
  10. class ajax {
  11. private static $_ajax;
  12. public static function getInstance() {
  13. if (!self::$_ajax) {
  14. $c = __CLASS__;
  15. self::$_ajax = new $c;
  16. }
  17. return self::$_ajax;
  18. }
  19. public function run() {
  20. $time = time() - $_SESSION["LAST_OPERATE_TIME"];
  21. if ($time > $_SESSION['SESSION_TIMEOUT']) {
  22. exit(json_encode("session_time_out"));
  23. } else {
  24. $_SESSION["LAST_OPERATE_TIME"] = time();
  25. }
  26. $operate = utils::_get('operate');
  27. $operate = strtolower($operate);
  28. switch ($operate) {
  29. case 'save_setting_display':
  30. $this->save_setting_display();
  31. break;
  32. case 'autody':
  33. return json_encode($this->autody());
  34. break;
  35. case 'autoport':
  36. return json_encode($this->autoPort());
  37. break;
  38. default :
  39. break;
  40. }
  41. }
  42. public function save_setting_display() {
  43. $ids = $_POST['ids'];
  44. if(!empty($ids)){
  45. $ss = utils::implode(",", $_POST['ids']);
  46. column::getInstance()->saveSettingDisplay(utils::implode(",", $_POST['ids']),"", $_POST['model_name']);
  47. $data = array(
  48. 'msg' => 'success'
  49. );
  50. common::echo_json_encode(200,$data);
  51. }else{
  52. $data = array(
  53. 'msg' => 'data error'
  54. );
  55. common::echo_json_encode(500,$data);
  56. }
  57. }
  58. //不查询全局的信息,查询该用户,最近3个月内输入过的信息自动补全
  59. public function autody(){
  60. $term = $_POST['term'];
  61. $type = $_POST['type'];
  62. $search_field = $_POST['search_field'];
  63. $search_mode = $_POST['search_mode'];
  64. $term = trim($term);
  65. if (strtolower($type) == "apex" || strtolower($type) == "contanct" || strtolower($type) == "sales"
  66. || strtolower($type) == "vessel") {
  67. if($search_mode == "tracking"){
  68. $sqlWhere = $this->getTrackingSearchWhere();
  69. }elseif($search_mode == "booking"){
  70. $sqlWhere = $this->getBookingSearchWhere();
  71. }
  72. $search_field_mapping = array("Origin Agent"=>"origin as code",
  73. "Destination Agent"=>"agent as code",
  74. "Shipper Name"=>"shipper as code",
  75. "Consignee Name"=>"consignee as code",
  76. "Sales"=>"sales_rep as code",
  77. "Voyage/Flight_booking"=>"f_voyage as code,m_voyage as code_2",
  78. "Vessel_booking"=>"f_vessel as code,m_vessel as code_2",
  79. "Voyage/Flight_tracking"=>"voyage as code,f_voyage as code_2",
  80. "Vessel_tracking"=>"vessel as code,f_vessel as code_2");
  81. $sql_where_mapping = array("Origin Agent"=>" and (origin ilike '" . common::check_input($term) . "%')",
  82. "Destination Agent"=>" and (agent ilike '" . common::check_input($term) . "%')",
  83. "Shipper Name"=>" and (shipper ilike '" . common::check_input($term) . "%')",
  84. "Consignee Name"=>" and (consignee ilike '" . common::check_input($term) . "%')",
  85. "Sales"=>" and (sales_rep ilike '" . common::check_input($term) . "%')",
  86. "Voyage/Flight_booking"=>" and (f_voyage ilike '" . common::check_input($term) . "%' or m_voyage ilike '" . common::check_input($term) . "%')",
  87. "Vessel_booking"=>" and (f_vessel ilike '" . common::check_input($term) . "%' or m_vessel ilike '" . common::check_input($term) . "%')",
  88. "Voyage/Flight_tracking"=>" and (voyage ilike '" . common::check_input($term) . "%' or f_voyage ilike '" . common::check_input($term) . "%')",
  89. "Vessel_tracking"=>" and (vessel ilike '" . common::check_input($term) . "%' or f_vessel ilike '" . common::check_input($term) . "%')");
  90. //特殊处理一下合并Voyage和Vessel
  91. if ($search_field == "Voyage/Flight" || $search_field == "Vessel"){
  92. $_str = $search_mode == "tracking" ? "tracking" : "booking";
  93. $search_field = $search_field ."_".$_str;
  94. }
  95. $str = $search_field_mapping[$search_field];
  96. $sql_where = $sql_where_mapping[$search_field];
  97. $table = $search_mode == "tracking" ? "public.online_ocean " : "public.online_booking ";
  98. $sql = "select $str from $table $sqlWhere $sql_where ";
  99. $sql .= " order by id limit 20";
  100. $rs = common::excuteListSql($sql);
  101. }
  102. $rs = common::excuteListSql($sql);
  103. $array = array();
  104. foreach($rs as $v){
  105. if(!empty($v['code'])){
  106. $array[] = $v['code'];
  107. }
  108. if ($search_field == "Voyage/Flight" || $search_field == "Vessel"){
  109. $array[] = $v['code_2'];
  110. }
  111. }
  112. $array = utils::removeDuplicateArray($array);
  113. common::echo_json_encode(200,$array);
  114. exit();
  115. }
  116. public function autoPort() {
  117. $cp = common::check_input($_POST ['cp']); //current_page
  118. $ps = common::check_input($_POST ['ps']); //ps
  119. if (empty($ps))
  120. $ps = 20;
  121. $term = $_POST['term'];
  122. $term = trim($term);
  123. $search_field = $_POST['search_field'];
  124. $search_mode = $_POST['search_mode'];
  125. $in_sql = $this->getPortsUncity($search_field,$search_mode);
  126. $rc = $_POST ['rc'];
  127. if ($rc == - 1) {
  128. $sql = "SELECT count(1) from public.ports where (isoname ilike '" . common::check_input($term) . "%'
  129. or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')
  130. and $in_sql";
  131. $rc = common::excuteOneSql($sql);
  132. }
  133. $tp = ceil($rc / $ps);
  134. if ($rc > 0) {
  135. $sql = "SELECT isoname as country, uncity as city,uncode from public.ports where (isoname ilike '" . common::check_input($term) . "%'
  136. or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')
  137. and $in_sql";
  138. $sql .= " order by code limit " . $ps . " offset " . ($cp - 1) * $ps;
  139. $rs = common::excuteListSql($sql);
  140. //前端要加上id 从1开始
  141. $retData = array();
  142. foreach($rs as $key => $val){
  143. if(!empty($val['country'])){
  144. $val["id"] = $key +1;
  145. $retData[] = $val;
  146. }
  147. }
  148. $arrTmp = array('searchData' => $retData,
  149. 'rc' => $rc,
  150. 'ps' => $ps,
  151. 'cp' => $cp,
  152. 'tp' => $tp);
  153. common::echo_json_encode(200,$arrTmp);
  154. exit();
  155. }else{
  156. $arrTmp = array('searchData' => array(), 'rc' => 0);
  157. common::echo_json_encode(200, $arrTmp);
  158. exit();
  159. }
  160. }
  161. public function autoPort_old() {
  162. $cp = common::check_input($_POST ['cp']); //current_page
  163. $ps = common::check_input($_POST ['ps']); //ps
  164. if (empty($ps))
  165. $ps = 20;
  166. $term = $_POST['term'];
  167. $term = trim($term);
  168. $_curr_schemas = $_POST['model'];
  169. if (empty($_curr_schemas)) {
  170. $_curr_schemas = $_SESSION['ONLINE_USER']['main_schemas'];
  171. if (empty($_curr_schemas)) {
  172. $_curr_schemas = "public";
  173. }
  174. }
  175. $rc = $_POST ['rc'];
  176. if ($rc == - 1) {
  177. $sql = "SELECT count(1) from $_curr_schemas.ports where (isoname ilike '" . common::check_input($term) . "%'
  178. or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')";
  179. $rc = common::excuteOneSql($sql);
  180. }
  181. $tp = ceil($rc / $ps);
  182. if ($rc > 0) {
  183. $sql = "SELECT isoname as country, uncity as city,uncode from $_curr_schemas.ports where (isoname ilike '" . common::check_input($term) . "%'
  184. or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')";
  185. $sql .= " order by code limit " . $ps . " offset " . ($cp - 1) * $ps;
  186. $rs = common::excuteListSql($sql);
  187. //前端要加上id 从1开始
  188. $retData = array();
  189. foreach($rs as $key => $val){
  190. if(!empty($val['country'])){
  191. $val["id"] = $key +1;
  192. $retData[] = $val;
  193. }
  194. }
  195. $arrTmp = array('searchData' => $retData,
  196. 'rc' => $rc,
  197. 'ps' => $ps,
  198. 'cp' => $cp,
  199. 'tp' => $tp);
  200. common::echo_json_encode(200,$arrTmp);
  201. exit();
  202. }else{
  203. $arrTmp = array('searchData' => array());
  204. common::echo_json_encode(200, $arrTmp);
  205. exit();
  206. }
  207. }
  208. public function autody_old() {
  209. $term = $_POST['term'];
  210. $type = $_POST['type'];
  211. $term = trim($term);
  212. if (strtolower($type) == "apex") {
  213. $_curr_schemas = $_POST['model'];
  214. if (empty($_curr_schemas)) {
  215. $_curr_schemas = $_SESSION['ONLINE_USER']['main_schemas'];
  216. if (empty($_curr_schemas)) {
  217. $_curr_schemas = "public";
  218. }
  219. }
  220. if ($_curr_schemas == "public") {
  221. $sql = "select contact_id as code from ocean.contacts where ('Apex-DST'=any(regexp_split_to_array(contact_type::text, ';'::text))"
  222. . " or 'Apex-AGT'=any(regexp_split_to_array(contact_type::text, ';'::text))) "
  223. . "and active=true and coalesce(hblcode, '')<>'' and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')";
  224. } else {
  225. $sql = "select contact_id as code from $_curr_schemas.contacts where ('Apex-DST'=any(regexp_split_to_array(contact_type::text, ';'::text))"
  226. . " or 'Apex-AGT'=any(regexp_split_to_array(contact_type::text, ';'::text))) "
  227. . "and active=true and coalesce(hblcode, '')<>'' and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')";
  228. }
  229. $sql .= " order by contact_id limit 20";
  230. $rs = common::excuteListSql($sql);
  231. }
  232. //Shipper 和Consignee 的查询,但是表contact_v ,从ocean和air. 如果不做区分的话,可以上面的apex的Origin Agent/Destination Agent,合并
  233. if (strtolower($type) == "contanct") {
  234. $sql = "SELECT company as code from contact_v where active = true and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')";
  235. $sql .= " order by contact_id limit 20";
  236. $rs = common::excuteListSql($sql);
  237. }
  238. if (strtolower($type) == "sales") {
  239. $_curr_schemas = $_POST['model'];
  240. if (empty($_curr_schemas)) {
  241. $_curr_schemas = $_SESSION['ONLINE_USER']['main_schemas'];
  242. if (empty($_curr_schemas)) {
  243. $_curr_schemas = "public";
  244. }
  245. }
  246. $sql = "SELECT salesopcode as code from $_curr_schemas.employee where salesopcode is not null and salesopcode !='' and (salesopcode ilike '" . common::check_input($term) . "%' or employee_id ilike '" . common::check_input($term) . "%')";
  247. $sql .= " order by salesopcode limit 20";
  248. }
  249. if (strtolower($type) == "vessel") {
  250. $vessel = $_POST['vessel'];
  251. $sql = "SELECT carrier, vessel as code, flag from vessel_infor where vessel ilike '" . common::check_input($vessel) . "%'";
  252. $sql .= " order by vessel limit 20";
  253. }
  254. $rs = common::excuteListSql($sql);
  255. $array = array();
  256. foreach($rs as $v){
  257. if(!empty($v['code'])){
  258. $array[] = $v['code'];
  259. }
  260. }
  261. common::echo_json_encode(200,$array);
  262. exit();
  263. }
  264. public function getTrackingSearchWhere(){
  265. $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  266. $sqlWhere .= search::getInstance()->getSearchSQL("Ocean_Search");
  267. if (!empty($_REQUEST["_reportRef"])) {
  268. $_reportType = $_REQUEST["_reportType"];
  269. $_reportRef = $_REQUEST["_reportRef"];
  270. if ($_reportType == "r3") {
  271. if ($_reportRef == "Previous 7 Days") {
  272. $sqlWhere .= " and eta>(current_date-interval '7 days') and eta<current_date";
  273. } else if ($_reportRef == "0 Day") {
  274. $sqlWhere .= " and eta=current_date";
  275. } else if ($_reportRef == "1-2 Days") {
  276. $sqlWhere .= " and eta>current_date and eta<=(current_date+interval '2 days')";
  277. } else if ($_reportRef == "3-6 Days") {
  278. $sqlWhere .= " and eta>(current_date+interval '2 days') and eta<=(current_date+interval '6 days')";
  279. } else if ($_reportRef == "7 Days") {
  280. $sqlWhere .= " and eta>(current_date+interval '6 days')";
  281. } else {
  282. $sqlWhere .= " and 1<>1";
  283. }
  284. } else if ($_reportType == "r4") {
  285. if ($_reportRef == "Previous 7 Days") {
  286. $sqlWhere .= " and etd>(current_date-interval '7 days') and etd<current_date";
  287. } else if ($_reportRef == "0 Day") {
  288. $sqlWhere .= " and etd=current_date";
  289. } else if ($_reportRef == "1-2 Days") {
  290. $sqlWhere .= " and etd>current_date and etd<=(current_date+interval '2 days')";
  291. } else if ($_reportRef == "3-6 Days") {
  292. $sqlWhere .= " and etd>(current_date+interval '2 days') and etd<=(current_date+interval '6 days')";
  293. } else if ($_reportRef == "7 Days") {
  294. $sqlWhere .= " and etd>(current_date+interval '6 days')";
  295. } else {
  296. $sqlWhere .= " and 1<>1";
  297. }
  298. } else if ($_reportType == "ata_r3") {
  299. if ($_reportRef == "0 Day") {
  300. $sqlWhere .= " and ata >= etd and (ata-etd) >= 0 and (ata-etd) < 1";
  301. } else if ($_reportRef == "1-2 Days") {
  302. $sqlWhere .= " and ata >= etd and (ata-etd) >= 1 and (ata-etd) < 2";
  303. } else if ($_reportRef == "3-6 Days") {
  304. $sqlWhere .= " and ata >= etd and (ata-etd) >= 2 and (ata-etd) < 6";
  305. } else if ($_reportRef == "7 Days") {
  306. $sqlWhere .= " and ata >= etd and (ata-etd) >= 6";
  307. } else {
  308. $sqlWhere .= " and 1<>1";
  309. }
  310. } else if ($_reportType == "atd_r4") {
  311. if ($_reportRef == "0 Day") {
  312. $sqlWhere .= " and atd >= etd and (atd-etd) >= 0 and (atd-etd) < 1";
  313. } else if ($_reportRef == "1-2 Days") {
  314. $sqlWhere .= " and atd >= etd and (atd-etd) >= 1 and (atd-etd) < 2";
  315. } else if ($_reportRef == "3-6 Days") {
  316. $sqlWhere .= " and atd >= etd and (atd-etd) >= 2 and (atd-etd) < 6";
  317. } else if ($_reportRef == "7 Days") {
  318. $sqlWhere .= " and atd >= etd and (atd-etd) >= 6 ";
  319. } else {
  320. $sqlWhere .= " and 1<>1";
  321. }
  322. } else if ($_reportType == "top") {
  323. if (!empty($_reportRef)) {
  324. $_reportStationType = $_REQUEST["_reportStationType"];
  325. if($_reportStationType == 'shippr_uncode'){
  326. $sqlWhere = " and shippr_uncode = '$_reportRef'";
  327. }
  328. if($_reportStationType == 'fport_of_loading_un'){
  329. $sqlWhere = " and fport_of_loading_un = '$_reportRef'";
  330. }
  331. if($_reportStationType == 'consignee_uncode'){
  332. $sqlWhere .= " and consignee_uncode = '$_reportRef'";
  333. }
  334. if($_reportStationType == 'mport_of_discharge_un'){
  335. $sqlWhere .= " and mport_of_discharge_un = '$_reportRef'";
  336. }
  337. } else {
  338. $sqlWhere .= " and 1<>1";
  339. }
  340. } else if ($_reportType == "co2e") {
  341. $_reportDataType = $_REQUEST["_reportDataType"];
  342. //查询sea 其他的为空
  343. if (!empty($_reportRef) && $_reportDataType == "sea") {
  344. $_reportStationType = $_REQUEST["_reportStationType"];
  345. if($_reportStationType == 'origin'){
  346. $sqlWhere .= " and shippr_uncode = '$_reportRef'";
  347. }else{
  348. $sqlWhere .= " and consignee_uncode = '$_reportRef'";
  349. }
  350. } else {
  351. $sqlWhere .= " and 1<>1";
  352. }
  353. } else {
  354. $_reportRef = explode("-", $_REQUEST["_reportRef"]);
  355. $_reportRefb_date = $_REQUEST["_reportRefb_date"];
  356. $bdate = common::excuteOneSql("select to_date('$_reportRefb_date','mm/YYYY')");
  357. $_reportRefe_date = $_REQUEST["_reportRefe_date"];
  358. $edate = common::excuteOneSql("select to_date('$_reportRefe_date','mm/YYYY') + interval '1 month' - interval '1 day'");
  359. //$sqlWhere .= " and eta>='$bdate' and eta<='$edate'";
  360. if ($_REQUEST["_reportRef"] == "Over 80 Days") {
  361. $sqlWhere .= " and (eta-etd)>80";
  362. } else {
  363. $sqlWhere .= " and (eta-etd)>" . $_reportRef[0] . " and (eta-etd)<=" . substr($_reportRef[1], 0, 2);
  364. }
  365. }
  366. }
  367. //处理reference类型的组合查询 Search booking No./HBL No./PO No./Carrier Booking No.
  368. if (!empty($_POST["_textSearch"])) {
  369. $textSearch_arr = $_POST['_textSearch'];
  370. if(!is_array($textSearch_arr)){
  371. $textSearch_arr = array($textSearch_arr);
  372. }
  373. $more_sql = "1<>1";
  374. foreach($textSearch_arr as $tsv){
  375. $more_sql .= " or booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
  376. $more_sql .= " or h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
  377. $more_sql .= " or po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
  378. $more_sql .= " or carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
  379. }
  380. if ($more_sql <> "1<>1"){
  381. $sqlWhere .= " and ($more_sql)";
  382. }
  383. }
  384. return $sqlWhere;
  385. }
  386. public function getBookingSearchWhere(){
  387. $sqlWhere = ' where ' . common::searchExtendHandNew("booking", $_SESSION["ONLINE_USER"]);
  388. $sqlWhere .= search::getInstance()->getSearchSQL("Booking_Search");
  389. //新版要排除type2情况,总数才会对的上
  390. $sqlWhere .= " and (not(bol_type != 'BOOKING' and booking_no is not null and booking_no <> ''))";
  391. //处理reference类型的组合查询 Search booking No./HBL No./PO No./Carrier Booking No.
  392. if (!empty($_POST["_textSearch"])) {
  393. $textSearch_arr = $_POST['_textSearch'];
  394. if(!is_array($textSearch_arr)){
  395. $textSearch_arr = array($textSearch_arr);
  396. }
  397. $more_sql = "1<>1";
  398. foreach($textSearch_arr as $tsv){
  399. $more_sql .= " or booking_no ilike '%" . common::check_input(trim($tsv)) . "%'";
  400. $more_sql .= " or h_bol ilike '%" . common::check_input(trim($tsv)) . "%'";
  401. $more_sql .= " or po_no ilike '%" . common::check_input(trim($tsv)) . "%'";
  402. $more_sql .= " or carrier_booking ilike '%" . common::check_input(trim($tsv)) . "%'";
  403. }
  404. if ($more_sql <> "1<>1"){
  405. $sqlWhere .= " and ($more_sql)";
  406. }
  407. }
  408. return $sqlWhere;
  409. }
  410. PUBLIC function getPortsUncity($search_field,$search_mode){
  411. $uncity = array();
  412. if($search_field == "Origin" && $search_mode == "booking"){
  413. $sqlWhere = $this->getBookingSearchWhere();
  414. $sql = "select shipper_city from public.online_booking $sqlWhere";
  415. $city_temp = common::excuteListSql($sql);
  416. foreach($city_temp as $city){
  417. if(!empty($city['shipper_city'])){
  418. $uncity[] = $city['shipper_city'];
  419. }
  420. }
  421. }
  422. if($search_field == "Destination" && $search_mode == "booking"){
  423. $sqlWhere = $this->getBookingSearchWhere();
  424. $sql = "select consignee_city from public.online_booking $sqlWhere";
  425. $city_temp = common::excuteListSql($sql);
  426. foreach($city_temp as $city){
  427. if(!empty($city['consignee_city'])){
  428. $uncity[] = $city['consignee_city'];
  429. }
  430. }
  431. }
  432. if($search_field == "Place of Receipt" && $search_mode == "booking"){
  433. $sqlWhere = $this->getBookingSearchWhere();
  434. $sql = "select place_of_receipt_exp from public.online_booking $sqlWhere";
  435. $city_temp = common::excuteListSql($sql);
  436. foreach($city_temp as $city){
  437. if(!empty($city['place_of_receipt_exp'])){
  438. $uncity[] = $city['place_of_receipt_exp'];
  439. }
  440. }
  441. }
  442. if($search_field == "Port of Loading" && $search_mode == "booking"){
  443. $sqlWhere = $this->getBookingSearchWhere();
  444. $sql = "select fport_of_loading_exp from public.online_booking $sqlWhere";
  445. $city_temp = common::excuteListSql($sql);
  446. foreach($city_temp as $city){
  447. if(!empty($city['fport_of_loading_exp'])){
  448. $uncity[] = $city['fport_of_loading_exp'];
  449. }
  450. }
  451. }
  452. if($search_field == "Place of delivery" && $search_mode == "booking"){
  453. $sqlWhere = $this->getBookingSearchWhere();
  454. $sql = "select place_of_delivery_exp from public.online_booking $sqlWhere";
  455. $city_temp = common::excuteListSql($sql);
  456. foreach($city_temp as $city){
  457. if(!empty($city['place_of_delivery_exp'])){
  458. $uncity[] = $city['place_of_delivery_exp'];
  459. }
  460. }
  461. }
  462. //tracking
  463. if($search_field == "Origin" && $search_mode == "tracking"){
  464. $sqlWhere = $this->getTrackingSearchWhere();
  465. $sql = "select shipper_city,consignee_city from public.online_ocean $sqlWhere";
  466. $city_temp = common::excuteListSql($sql);
  467. foreach($city_temp as $city){
  468. if(!empty($city['shipper_city'])){
  469. $uncity[] = $city['shipper_city'];
  470. }
  471. if(!empty($city['consignee_city'])){
  472. $uncity[] = $city['consignee_city'];
  473. }
  474. }
  475. }
  476. if($search_field == "Destination" && $search_mode == "tracking"){
  477. $sqlWhere = $this->getTrackingSearchWhere();
  478. $sql = "select final_desination_exp from public.online_ocean $sqlWhere";
  479. $city_temp = common::excuteListSql($sql);
  480. foreach($city_temp as $city){
  481. if(!empty($city['final_desination_exp'])){
  482. $uncity[] = $city['final_desination_exp'];
  483. }
  484. }
  485. }
  486. if($search_field == "Place of Receipt" && $search_mode == "tracking"){
  487. $sqlWhere = $this->getTrackingSearchWhere();
  488. $sql = "select place_of_receipt_exp from public.online_ocean $sqlWhere";
  489. $city_temp = common::excuteListSql($sql);
  490. foreach($city_temp as $city){
  491. if(!empty($city['place_of_receipt_exp'])){
  492. $uncity[] = $city['place_of_receipt_exp'];
  493. }
  494. }
  495. }
  496. if($search_field == "Port of Loading" && $search_mode == "tracking"){
  497. $sqlWhere = $this->getTrackingSearchWhere();
  498. $sql = "select port_of_loading from public.online_ocean $sqlWhere";
  499. $city_temp = common::excuteListSql($sql);
  500. foreach($city_temp as $city){
  501. if(!empty($city['port_of_loading'])){
  502. $uncity[] = $city['port_of_loading'];
  503. }
  504. }
  505. }
  506. if($search_field == "Place of Discharge" && $search_mode == "tracking"){
  507. $sqlWhere = $this->getTrackingSearchWhere();
  508. $sql = "select port_of_discharge from public.online_ocean $sqlWhere";
  509. $city_temp = common::excuteListSql($sql);
  510. foreach($city_temp as $city){
  511. if(!empty($city['port_of_discharge'])){
  512. $uncity[] = $city['port_of_discharge'];
  513. }
  514. }
  515. }
  516. if($search_field == "Place of delivery" && $search_mode == "tracking"){
  517. $sqlWhere = $this->getTrackingSearchWhere();
  518. $sql = "select place_of_delivery_exp from public.online_ocean $sqlWhere";
  519. $city_temp = common::excuteListSql($sql);
  520. foreach($city_temp as $city){
  521. if(!empty($city['place_of_delivery_exp'])){
  522. $uncity[] = $city['place_of_delivery_exp'];
  523. }
  524. }
  525. }
  526. $uncity = utils::removeDuplicateArray($uncity);
  527. $in_sql = utils::getInSql(utils::implode(';', $uncity));
  528. if(!empty($uncity)){
  529. $in_sql = " lower(uncity) ".$in_sql;
  530. }
  531. return $in_sql;
  532. }
  533. }
  534. ?>