common.class.php 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of common
  7. *
  8. * @author Administrator
  9. */
  10. class common {
  11. /*
  12. * mysql check input
  13. */
  14. public static function check_input($value, $boolean = FALSE, $toupper = FALSE) {
  15. if ($boolean !== FALSE) {
  16. if ($value == "t")
  17. return "'t'";
  18. else
  19. return "'f'";
  20. }
  21. $value = trim($value);
  22. if ($toupper !== FALSE)
  23. $value = mb_strtoupper($value);
  24. if (!is_numeric($value)) {
  25. $value = pg_escape_string($value);
  26. }
  27. return $value;
  28. }
  29. public static function excuteOneSql($sql, $exception = FALSE) {
  30. if ($exception) {
  31. global $db;
  32. $result = $db->GetOne($sql);
  33. return $result === FALSE ? null : $result;
  34. } else {
  35. if (empty($sql))
  36. exit(json_encode("Program encountered an error."));
  37. global $db;
  38. $result = $db->GetOne($sql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $sql), 0));
  39. return $result === FALSE ? null : $result;
  40. }
  41. }
  42. public static function excuteObjectSql($sql) {
  43. if (empty($sql))
  44. exit(json_encode("Program encountered an error."));
  45. global $db;
  46. $result = $db->GetRow($sql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $sql), 0));
  47. return $result === FALSE ? null : $result;
  48. }
  49. public static function excuteUpdateSql($sql, $req_id = FALSE) {
  50. if (empty($sql))
  51. exit(json_encode("Program encountered an error."));
  52. global $db;
  53. $rs = $db->Execute($sql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $sql), 0));
  54. if ($rs && $req_id !== FALSE)
  55. return $db->PO_Insert_ID();
  56. else
  57. return $rs;
  58. }
  59. public static function excuteListSql($sql, $exception = FALSE) {
  60. if ($exception) {
  61. global $db;
  62. $result = $db->GetAll($sql);
  63. return $result === FALSE ? null : $result;
  64. } else {
  65. if (empty($sql))
  66. exit(json_encode("Program encountered an error."));
  67. global $db;
  68. $result = $db->GetAll($sql) or ( (!$db->ErrorMsg()) or error_log(common::dbLog($db, $sql), 0));
  69. return $result === FALSE ? null : $result;
  70. }
  71. }
  72. /*
  73. * Database log output
  74. */
  75. public static function dbLog($db, $sql) {
  76. $backMsg = $db->errorMsg() . ' sql=' . $sql;
  77. return $backMsg;
  78. }
  79. /*
  80. * get IP
  81. */
  82. public static function ip() {
  83. if (getenv("HTTP_X_FORWARDED_FOR"))
  84. return getenv("HTTP_X_FORWARDED_FOR");
  85. if (getenv("HTTP_CLIENT_IP"))
  86. return getenv("HTTP_CLIENT_IP");
  87. if (getenv("REMOTE_ADDR"))
  88. return getenv("REMOTE_ADDR");
  89. if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"])
  90. return $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
  91. if ($HTTP_SERVER_VARS["HTTP_CLIENT_IP"])
  92. return $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];
  93. if ($HTTP_SERVER_VARS["REMOTE_ADDR"])
  94. return $HTTP_SERVER_VARS["REMOTE_ADDR"];
  95. return "Unknown";
  96. }
  97. public static function getDBUuid() {
  98. global $db;
  99. $sql = "select uuid_generate_v1()";
  100. $uuid = $db->GetOne($sql);
  101. return $uuid;
  102. }
  103. public static function securityCheckHandNew($action) {
  104. if (strpos($action, "handset") === 0) {
  105. } elseif (strpos($action, "hand") === 0) {
  106. } else {
  107. common::sessionVerify();
  108. $httpAccept = $_SERVER['HTTP_ACCEPT']; // ajax request,is json or html
  109. $ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER
  110. ['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; // is ajax request?
  111. //暂时这么写,放开action = main的查询是为了在没有登录时获取信息。
  112. //tools是为了避免查询的用户,没有配置tools权限,但是新版mark_save需要进入
  113. if($action == "main" || $action == "tools" || $action == "save_layout"){
  114. return;
  115. }
  116. if (!isset($_SESSION['ONLINE_USER'])) {
  117. self::timeoutPrintInfor($httpAccept, $ajax, 'no');
  118. } else {
  119. $time = time() - $_SESSION["LAST_OPERATE_TIME"];
  120. $set_session_timeout = $_SESSION['SESSION_TIMEOUT'];
  121. if (_getLoginName() == "ra.admin") {
  122. $set_session_timeout = 4 * 3600;
  123. }
  124. if ($time > $set_session_timeout) {
  125. self::timeoutPrintInfor($httpAccept, $ajax, 'yes');
  126. } else {
  127. $_SESSION["LAST_OPERATE_TIME"] = time();
  128. if (!_isAdmin() && $_GET["action"] != "linkcrm") {
  129. if (!utils::checkExist($_SESSION['ONLINE_USER']['permission'], $action)
  130. && !(stripos($action, "main") === 0)
  131. && !(stripos($action, "ajax") === 0)
  132. && !(stripos($action, "opreation_log") === 0)) {
  133. $data = array("msg"=>"Permission Denied");
  134. common::echo_json_encode(500, $data);
  135. exit();
  136. }
  137. }
  138. }
  139. }
  140. session_write_close();
  141. }
  142. }
  143. public static function getCompanySearch() {
  144. $sc_list = _get_schemas();
  145. if (count($sc_list) == 1) {
  146. return "";
  147. }
  148. if (_isCustomerLogin()) {
  149. $msg = '<input type="hidden" name="_apex_or_sfs" value=""/>';
  150. } else {
  151. $msg = '<div class="modules">Apex/SFS/Kerry :&nbsp;<select name="_apex_or_sfs" class="sl"><option value="">All</option>';
  152. if ($_SESSION['ONLINE_USER']['main_schemas'] == "public") {
  153. $msg .= '<option value="public">Apex</option>';
  154. } else {
  155. $msg .= '<option value="public">Apex</option>';
  156. }
  157. if ($_SESSION['ONLINE_USER']['main_schemas'] == "sfs") {
  158. $msg .= '<option value="sfs">SFS</option>';
  159. } else {
  160. $msg .= '<option value="sfs">SFS</option>';
  161. }
  162. if ($_SESSION['ONLINE_USER']['main_schemas'] == "kyiff") {
  163. $msg .= '<option value="kyiff">Kerry</option>';
  164. } else {
  165. $msg .= '<option value="kyiff">Kerry</option>';
  166. }
  167. $msg .= '</select></div>';
  168. }
  169. return $msg;
  170. }
  171. public static function sessionVerify() {
  172. if (!isset($_SESSION['user_agent'])) {
  173. $_SESSION['user_agent'] = MD5($_SERVER['REMOTE_ADDR']
  174. . $_SERVER['HTTP_USER_AGENT']);
  175. } elseif ($_SESSION['user_agent'] != MD5($_SERVER['REMOTE_ADDR']
  176. . $_SERVER['HTTP_USER_AGENT'])) {
  177. session_regenerate_id();
  178. }
  179. }
  180. public static function searchExtendHandNew($type, $user, $company_name = "station_name") {
  181. if (_isAdminHandNew($user)) {
  182. if(strtolower($type) == "air_booking" ) //|| strtolower($type) == "air"
  183. {
  184. return "1=1";
  185. }
  186. return " (schem_not_display is null or schem_not_display=false)";
  187. }
  188. if (_isDocAdmin($user["user_login"])) {
  189. if(strtolower($type) == "air_booking" ) //|| strtolower($type) == "air"
  190. {
  191. return "1=1";
  192. }
  193. return ' (schem_not_display is null or schem_not_display=false)';
  194. }
  195. if (strtolower($type) != "ocean" && strtolower($type) != "booking" && strtolower($type) != "air_booking"&& strtolower($type) != "air") {
  196. return " 1<>1";
  197. }
  198. if (empty($user["schemas_list"])) {
  199. $user["schemas_list"] = $_SESSION["schemas_list"];
  200. }
  201. $schemas_list = $user["schemas_list"];
  202. if ($user["is_kerry_shipment"] == "t") {
  203. $sqlWhere = " is_kerry_shipment is not null and is_kerry_shipment=true";
  204. } else if ($user["is_kerry_shipment"] == "f") {
  205. $sqlWhere = " (is_kerry_shipment is null or is_kerry_shipment=false)";
  206. } else {
  207. $sqlWhere = " 1=1";
  208. }
  209. if (!empty($_POST["_apex_or_sfs"])) {
  210. $sqlWhere .= " and order_from='" . $_POST["_apex_or_sfs"] . "'";
  211. }
  212. if (count($schemas_list) == 1) {
  213. $schames = $schemas_list[0]["schemas_name"];
  214. if(strtolower($type) == "air_booking" ||strtolower($type) == "air")
  215. {
  216. }
  217. else
  218. $sqlWhere .= " and order_from='$schames'";
  219. if ($schames == "sfs" && empty($user["sfs_ONLINE_USER"])) {
  220. $user = $_SESSION["sfs_ONLINE_USER"];
  221. }
  222. if (strtolower($type) == "ocean") {
  223. $sqlWhere .= self::_oceanHandNew($user, $schames);
  224. if ($company_name == "doc") {
  225. if (empty($user["view_file_format"])) {
  226. if (strtolower($user["user_type"]) == "customer") {
  227. $sqlWhere .= " and serial_no in (SELECT serial_no from $schames.ra_online_file_format where active = true and client_display = true)";
  228. } else {
  229. $sqlWhere .= " and serial_no in (SELECT serial_no from $schames.ra_online_file_format where active = true)";
  230. }
  231. } else {
  232. $sqlWhere .= " and serial_no in (SELECT regexp_split_to_table('" . $user["view_file_format"] . "',';'))";
  233. }
  234. }
  235. }
  236. if (strtolower($type) == "booking") {
  237. $sqlWhere .= self::_bookingHandNew($user, $schames);
  238. }
  239. if (strtolower($type) == "air_booking") {
  240. $sqlWhere .= self::_airHandNew($user, $schames);
  241. }
  242. if (strtolower($type) == "air") {
  243. $sqlWhere .= self::_airHandNew($user, $schames);
  244. if ($company_name == "doc") {
  245. if (empty($user["view_file_format"])) {
  246. if (strtolower($user["user_type"]) == "customer") {
  247. $sqlWhere .= " and serial_no in (SELECT serial_no from $schames.ra_online_file_format where active = true and client_display = true)";
  248. } else {
  249. $sqlWhere .= " and serial_no in (SELECT serial_no from $schames.ra_online_file_format where active = true)";
  250. }
  251. } else {
  252. $sqlWhere .= " and serial_no in (SELECT regexp_split_to_table('" . $user["view_file_format"] . "',';'))";
  253. }
  254. }
  255. }
  256. } elseif (count($schemas_list) == 2) {
  257. if(strtolower($type) == "air_booking" )//|| strtolower($type) == "air"
  258. {
  259. // $sqlWhere .= " and 1=1";
  260. }
  261. else
  262. $sqlWhere .= " and (schem_not_display is null or schem_not_display=false)";
  263. if (strtolower($type) == "ocean") {
  264. $sqlWhere .= " and ((order_from='public' ";
  265. $sqlWhere .= self::_oceanHandNew($user, "public");
  266. if ($company_name == "doc") {
  267. if (empty($user["view_file_format"])) {
  268. if (strtolower($user["user_type"]) == "customer") {
  269. $sqlWhere .= " and serial_no in (SELECT serial_no from public.ra_online_file_format where active = true and client_display = true)";
  270. } else {
  271. $sqlWhere .= " and serial_no in (SELECT serial_no from public.ra_online_file_format where active = true)";
  272. }
  273. } else {
  274. $sqlWhere .= " and serial_no in (SELECT regexp_split_to_table('" . $user["view_file_format"] . "',';'))";
  275. }
  276. }
  277. $sqlWhere .= ") or (order_from='sfs' ";
  278. if (empty($user["sfs_ONLINE_USER"])) {
  279. $user = $_SESSION["sfs_ONLINE_USER"];
  280. }
  281. $sqlWhere .= self::_oceanHandNew($user, "sfs");
  282. if ($company_name == "doc") {
  283. if (empty($user["view_file_format"])) {
  284. if (strtolower($user["user_type"]) == "customer") {
  285. $sqlWhere .= " and serial_no in (SELECT serial_no from sfs.ra_online_file_format where active = true and client_display = true)";
  286. } else {
  287. $sqlWhere .= " and serial_no in (SELECT serial_no from sfs.ra_online_file_format where active = true)";
  288. }
  289. } else {
  290. $sqlWhere .= " and serial_no in (SELECT regexp_split_to_table('" . $user["view_file_format"] . "',';'))";
  291. }
  292. }
  293. $sqlWhere .= ") )";
  294. }
  295. if (strtolower($type) == "booking") {
  296. $sqlWhere .= " and ((order_from='public' ";
  297. $sqlWhere .= self::_bookingHandNew($user, "public");
  298. $sqlWhere .= ") or (order_from='sfs' ";
  299. if (empty($user["sfs_ONLINE_USER"])) {
  300. $user = $_SESSION["sfs_ONLINE_USER"];
  301. }
  302. $sqlWhere .= self::_bookingHandNew($user, "sfs");
  303. $sqlWhere .= "))";
  304. }
  305. if (strtolower($type) == "air_booking") {
  306. $sqlWhere .= " and ((order_from='public' ";
  307. $sqlWhere .= self::_airHandNew($user, "public");
  308. $sqlWhere .= ") or (order_from='sfs' ";
  309. if (empty($user["sfs_ONLINE_USER"])) {
  310. $user = $_SESSION["sfs_ONLINE_USER"];
  311. }
  312. $sqlWhere .= self::_airHandNew($user, "sfs");
  313. $sqlWhere .= "))";
  314. // $sqlWhere .= self::_airHandNew($user, $schames);
  315. }
  316. if (strtolower($type) == "air") {
  317. $sqlWhere .= " and ((order_from='public' ";
  318. $sqlWhere .= self::_airHandNew($user, "public");
  319. if ($company_name == "doc") {
  320. if (empty($user["view_file_format"])) {
  321. if (strtolower($user["user_type"]) == "customer") {
  322. $sqlWhere .= " and serial_no in (SELECT serial_no from public.ra_online_file_format where active = true and client_display = true)";
  323. } else {
  324. $sqlWhere .= " and serial_no in (SELECT serial_no from public.ra_online_file_format where active = true)";
  325. }
  326. } else {
  327. $sqlWhere .= " and serial_no in (SELECT regexp_split_to_table('" . $user["view_file_format"] . "',';'))";
  328. }
  329. }
  330. $sqlWhere .= ") or (order_from='sfs' ";
  331. if (empty($user["sfs_ONLINE_USER"])) {
  332. $user = $_SESSION["sfs_ONLINE_USER"];
  333. }
  334. $sqlWhere .= self::_airHandNew($user, "sfs");
  335. if ($company_name == "doc") {
  336. if (empty($user["view_file_format"])) {
  337. if (strtolower($user["user_type"]) == "customer") {
  338. $sqlWhere .= " and serial_no in (SELECT serial_no from sfs.ra_online_file_format where active = true and client_display = true)";
  339. } else {
  340. $sqlWhere .= " and serial_no in (SELECT serial_no from sfs.ra_online_file_format where active = true)";
  341. }
  342. } else {
  343. $sqlWhere .= " and serial_no in (SELECT regexp_split_to_table('" . $user["view_file_format"] . "',';'))";
  344. }
  345. }
  346. $sqlWhere .= ") )";
  347. }
  348. } else {
  349. $sqlWhere = " 1<>1";
  350. }
  351. return $sqlWhere;
  352. }
  353. public static function getStatusStage($status) {
  354. if ($status == "EE" || $status == "I") {
  355. return 0;
  356. }
  357. if ($status == "AE" || $status == "VD" || $status == "VA_RELAY" || $status == "UV_RELAY" || $status == "AE_RELAY" || $status == "VD_RELAY") {
  358. return 1;
  359. }
  360. if ($status == "VA" || $status == "UV" || $status == "AL" || $status == "AR" || $status == "CU" || $status == "CT" || $status == "CR" || $status == "OA") {
  361. return 2;
  362. }
  363. if ($status == "AV" || $status == "D" || $status == "RD") {
  364. return 3;
  365. }
  366. return -1;
  367. }
  368. public static function getInNotInSql($contact_id, $type = 'in') {
  369. if (empty($contact_id))
  370. return " =''";
  371. $contact_id = trim($contact_id);
  372. $contact_id = trim($contact_id, ";");
  373. $contact_id = trim($contact_id);
  374. $contact_id = strtolower($contact_id);
  375. if ($type == 'in') {
  376. if (utils::checkExist($contact_id, ";")) {
  377. $ss = "";
  378. $aa = explode(";", $contact_id);
  379. foreach ($aa as $k => $v) {
  380. $v = trim($v);
  381. if (empty($ss))
  382. $ss = "'" . common::check_input($v) . "'";
  383. else
  384. $ss .= ",'" . common::check_input($v) . "'";
  385. }
  386. return " in (" . $ss . ")";
  387. } else {
  388. return " = '" . common::check_input($contact_id) . "'";
  389. }
  390. } else {
  391. if (utils::checkExist($contact_id, ";")) {
  392. $ss = "";
  393. $aa = explode(";", $contact_id);
  394. foreach ($aa as $k => $v) {
  395. $v = trim($v);
  396. if (empty($ss))
  397. $ss = "'" . common::check_input($v) . "'";
  398. else
  399. $ss .= ",'" . common::check_input($v) . "'";
  400. }
  401. return " in (" . $ss . ")";
  402. } else {
  403. return " != '" . common::check_input($contact_id) . "'";
  404. }
  405. }
  406. }
  407. /*
  408. * Encrypt a SQL query statement used to be passed as a parameter to get excel output
  409. encode :DeCode('str','E');
  410. decode :DeCode('enstr','D');
  411. */
  412. public static function deCode($string, $operation = "E") {
  413. $key = md5("uls_webwms");
  414. $key_length = strlen($key);
  415. if ($operation == "D")
  416. $string = rawurldecode($string);
  417. $string = $operation == 'D' ? base64_decode($string) : substr(md5($string . $key), 0, 8) . $string;
  418. $string_length = strlen($string);
  419. $rndkey = $box = array();
  420. $result = '';
  421. for ($i = 0; $i <= 255; $i++) {
  422. $rndkey [$i] = ord($key [$i % $key_length]);
  423. $box [$i] = $i;
  424. }
  425. for ($j = $i = 0; $i < 256; $i++) {
  426. $j = ($j + $box [$i] + $rndkey [$i]) % 256;
  427. $tmp = $box [$i];
  428. $box [$i] = $box [$j];
  429. $box [$j] = $tmp;
  430. }
  431. for ($a = $j = $i = 0; $i < $string_length; $i++) {
  432. $a = ($a + 1) % 256;
  433. $j = ($j + $box [$a]) % 256;
  434. $tmp = $box [$a];
  435. $box [$a] = $box [$j];
  436. $box [$j] = $tmp;
  437. $result .= chr(ord($string [$i]) ^ ($box [($box [$a] + $box [$j]) % 256]));
  438. }
  439. if ($operation == 'D') {
  440. if (substr($result, 0, 8) == substr(md5(substr($result, 8) . $key), 0, 8)) {
  441. return substr($result, 8);
  442. } else {
  443. return '';
  444. }
  445. } else {
  446. return rawurlencode(str_replace('=', '', base64_encode($result)));
  447. }
  448. }
  449. public static function getStatusDesc($code) {
  450. if (strtoupper($code) == "EE") {
  451. return "Empty Equipment Dispatched";
  452. }
  453. if (strtoupper($code) == "I") {
  454. return "Gate in full for a booking";
  455. }
  456. if (strtoupper($code) == "AE") {
  457. return "Container loaded on vessel";
  458. }
  459. if (strtoupper($code) == "VD") {
  460. return "Vessel Departure";
  461. }
  462. if (strtoupper($code) == "VA_RELAY") {
  463. return "Arrive Relay Port";
  464. }
  465. if (strtoupper($code) == "VD_RELAY") {
  466. return "Depart Relay Port";
  467. }
  468. if (strtoupper($code) == "AE_RELAY") {
  469. return "Loaded at Relay Port";
  470. }
  471. if (strtoupper($code) == "UV_RELAY") {
  472. return "Unloaded at Relay Port";
  473. }
  474. if (strtoupper($code) == "VA") {
  475. return "Vessel Arrival";
  476. }
  477. if (strtoupper($code) == "UV") {
  478. return "Unloaded From Vessel";
  479. }
  480. if (strtoupper($code) == "AL") {
  481. return "Container loaded on Rail";
  482. }
  483. if (strtoupper($code) == "AR") {
  484. return "Container unloaded from Rail";
  485. }
  486. if (strtoupper($code) == "CU") {
  487. return "Carrier and Customs Release";
  488. }
  489. if (strtoupper($code) == "CT") {
  490. return "Customs release";
  491. }
  492. if (strtoupper($code) == "CR") {
  493. return "Carrier release";
  494. }
  495. if (strtoupper($code) == "OA") {
  496. return "Gate out full from final discharge port";
  497. }
  498. if (strtoupper($code) == "AV") {
  499. return "Shipment available for pickup or delivery";
  500. }
  501. if (strtoupper($code) == "RD") {
  502. return "Container returned empty";
  503. }
  504. if (strtoupper($code) == "D") {
  505. return "Gate out for delivery to customer";
  506. }
  507. }
  508. public static function _toString($msg) {
  509. if ($msg == "" || $msg == NULL) {
  510. return "";
  511. }
  512. return $msg . "";
  513. }
  514. /*
  515. * timeout output
  516. */
  517. public static function timeoutPrintInfor($httpAccept, $ajax, $login) {
  518. //记录系统因session过期 退出登录
  519. utils::single_operation_log_save("logout","logout","System logout");
  520. $data = array("msg"=>"session_time_out");
  521. self::echo_json_encode(403,$data);
  522. exit();
  523. }
  524. private static function _oceanHandNew($user, $schemas = "public") {
  525. $o = $user['ocean_station'];
  526. $o_or = $user['ocean_station_or'];
  527. $d = $user['ocean_agent'];
  528. $d_or = $user['ocean_agent_or'];
  529. $sales = $user['ocean_sales'];
  530. $sales_or = $user['ocean_sales_or'];
  531. $op = $user['ocean_dest_op'];
  532. $op_or = $user['ocean_dest_op_or'];
  533. $follow = $user['ocean_following_sales'];
  534. $follow_or = $user['ocean_following_sales_or'];
  535. if (strtolower($o_or) == "all" || strtolower($d_or) == "all" || strtolower($sales_or) == "all" || strtolower($op_or) == "all") {
  536. return " and 1=1";
  537. }
  538. $sqlWhere = "";
  539. if (_isCustomerLoginHandNew($user)) {
  540. //error_log("_oceanHandNew".$schemas);
  541. $sqlWhere .= " and " . _customerFilerSearchHandNew($user, $schemas);
  542. } else {
  543. if (empty($o) && empty($d) && empty($sales) && empty($op) && empty($follow)) {
  544. return " and 1<>1";
  545. }
  546. if ((strtolower($o) == 'all' || empty($o)) && (strtolower($d) == "all" || empty($d))) {
  547. } else {
  548. $sql = "1=1";
  549. if (!empty($o) && strtolower($o) != 'all') {
  550. $sql .= " and lower(origin)";
  551. $sql .= utils::getInSql($o);
  552. }
  553. if (!empty($d) && strtolower($d) != 'all') {
  554. $sql .= " and lower(agent)";
  555. $sql .= utils::getInSql($d);
  556. }
  557. $sqlWhere .= " and (" . $sql . ")";
  558. }
  559. if (strtolower($sales) == 'all' || empty($sales)) {
  560. } else {
  561. if (utils::checkExist($sales, ";")) {
  562. $sql = "1!=1";
  563. $tt = explode(";", $sales);
  564. foreach ($tt as $t) {
  565. $t = trim($t);
  566. if (!empty($t))
  567. $sql .= " or lower(sales_rep)='" . strtolower($t) . "'";
  568. }
  569. $sqlWhere .= " and ($sql)";
  570. } else
  571. $sqlWhere .= " and lower(sales_rep)='" . strtolower($sales) . "'";
  572. }
  573. if (strtolower($op) == 'all' || empty($op)) {
  574. } else {
  575. $sqlWhere .= " and lower(dest_op) " . utils::getInSql($op);
  576. }
  577. if (strtolower($follow) == 'all' || empty($follow)) {
  578. } else {
  579. if (utils::checkExist($follow, ";")) {
  580. $sql = "1!=1";
  581. $tt = explode(";", $follow);
  582. foreach ($tt as $t) {
  583. $t = trim($t);
  584. if (!empty($t))
  585. $sql .= " or following_sales ilike '" . $t . "'";
  586. }
  587. $sqlWhere .= " and ($sql)";
  588. } else
  589. $sqlWhere .= " and following_sales ilike '" . $follow . "'";
  590. }
  591. $sqlWhere = " (1=1 $sqlWhere)";
  592. if (!empty($o_or)) {
  593. $sqlWhere .= " or lower(origin)";
  594. $sqlWhere .= utils::getInSql($o_or);
  595. }
  596. if (!empty($d_or)) {
  597. $sqlWhere .= " or lower(agent)";
  598. $sqlWhere .= utils::getInSql($d_or);
  599. }
  600. if (!empty($sales_or)) {
  601. if (utils::checkExist($sales_or, ";")) {
  602. $sql = "1!=1";
  603. $tt = explode(";", $sales_or);
  604. foreach ($tt as $t) {
  605. $t = trim($t);
  606. if (!empty($t))
  607. $sql .= " or lower(sales_rep)='" . strtolower($t) . "'";
  608. }
  609. $sqlWhere .= " or ($sql)";
  610. } else
  611. $sqlWhere .= " or lower(sales_rep)='" . strtolower($sales_or) . "'";
  612. }
  613. if (!empty($op_or)) {
  614. $sqlWhere .= " or lower(dest_op) " . utils::getInSql($op_or);
  615. }
  616. if (!empty($follow_or)) {
  617. if (utils::checkExist($follow_or, ";")) {
  618. $sql = "1!=1";
  619. $tt = explode(";", $follow_or);
  620. foreach ($tt as $t) {
  621. $t = trim($t);
  622. if (!empty($t))
  623. $sql .= " or following_sales ilike '" . $t . "'";
  624. }
  625. $sqlWhere .= " or ($sql)";
  626. }else {
  627. $sqlWhere .= " or following_sales ilike '" . $follow_or . "'";
  628. }
  629. }
  630. $sqlWhere = " and ($sqlWhere)";
  631. }
  632. return $sqlWhere;
  633. }
  634. private static function _bookingHandNew($user, $schames) {
  635. // if (_isDemo())
  636. // return " serial_no = 'D4DD1D79-83F4-4E65-9773-CF5277D72738'";
  637. $o = $user['ocean_station'];
  638. $o_or = $user['ocean_station_or'];
  639. $d = $user['ocean_agent'];
  640. $d_or = $user['ocean_agent_or'];
  641. $sales = $user['ocean_sales'];
  642. $sales_or = $user['ocean_sales_or'];
  643. $op = $user['ocean_dest_op'];
  644. $op_or = $user['ocean_dest_op_or'];
  645. $follow = $user['ocean_following_sales'];
  646. $follow_or = $user['ocean_following_sales_or'];
  647. if (strtolower($o_or) == "all" || strtolower($d_or) == "all" || strtolower($sales_or) == "all") {
  648. return " and 1=1";
  649. }
  650. // $sc_list = $user['schemas_list'];
  651. // if (empty($sc_list)) {
  652. // $sc_list = $_SESSION["schemas_list"];
  653. // }
  654. // if (empty($sc_list)) {
  655. // return " and 1<>1";
  656. // }
  657. // $sqlWhere = " and 1=1";
  658. // if ($user["is_kerry_shipment"] == "t") {
  659. // $sqlWhere = " and and is_kerry_shipment is not null and is_kerry_shipment=true";
  660. // } else if ($user["is_kerry_shipment"] == "f") {
  661. // $sqlWhere = " and (is_kerry_shipment is null or is_kerry_shipment=false)";
  662. // }
  663. // if (count($sc_list) == 1) {
  664. // $sch = $sc_list[0]['schemas_name'];
  665. // $sqlWhere .= " and order_from='$sch'";
  666. // } else {
  667. // $sqlWhere .= " and (schem_not_display is null or schem_not_display=false)";
  668. // }
  669. $sqlWhere = "";
  670. if (_isCustomerLoginHandNew($user)) {
  671. $sqlWhere .= " and " . _customerFilerSearchHandNew($user, $schames);
  672. } else {
  673. if (empty($o) && empty($d) && empty($sales) && empty($op) && empty($follow)) {
  674. return " and 1<>1";
  675. }
  676. if ((strtolower($o) == 'all' || empty($o)) && (strtolower($d) == "all" || empty($d))) {
  677. } else {
  678. $sql = "1=1";
  679. if (!empty($o) && strtolower($o) != 'all') {
  680. $sql .= " and lower(origin)";
  681. $sql .= utils::getInSql($o);
  682. }
  683. if (!empty($d) && strtolower($d) != 'all') {
  684. $sql .= " and lower(agent)";
  685. $sql .= utils::getInSql($d);
  686. }
  687. $sqlWhere .= " and (" . $sql . ")";
  688. }
  689. if (strtolower($sales) == 'all' || empty($sales)) {
  690. } else {
  691. if (utils::checkExist($sales, ";")) {
  692. $sql = "1!=1";
  693. $tt = explode(";", $sales);
  694. foreach ($tt as $t) {
  695. $t = trim($t);
  696. if (!empty($t))
  697. $sql .= " or lower(sales_rep)='" . strtolower($t) . "'";
  698. }
  699. $sqlWhere .= " and ($sql)";
  700. } else
  701. $sqlWhere .= " and lower(sales_rep)='" . strtolower($sales) . "'";
  702. }
  703. if (strtolower($follow) == 'all' || empty($follow)) {
  704. } else {
  705. if (utils::checkExist($follow, ";")) {
  706. $sql = "1!=1";
  707. $tt = explode(";", $follow);
  708. foreach ($tt as $t) {
  709. $t = trim($t);
  710. if (!empty($t))
  711. $sql .= " or following_sales ilike '" . $t . "%'";
  712. }
  713. $sqlWhere .= " and ($sql)";
  714. } else
  715. $sqlWhere .= " and following_sales ilike '" . $follow . "%'";
  716. }
  717. $sqlWhere = " (1=1 $sqlWhere)";
  718. if (!empty($o_or)) {
  719. $sqlWhere .= " or lower(origin)";
  720. $sqlWhere .= utils::getInSql($o_or);
  721. }
  722. if (!empty($d_or)) {
  723. $sqlWhere .= " or lower(agent)";
  724. $sqlWhere .= utils::getInSql($d_or);
  725. }
  726. if (!empty($sales_or)) {
  727. if (utils::checkExist($sales_or, ";")) {
  728. $sql = "1!=1";
  729. $tt = explode(";", $sales_or);
  730. foreach ($tt as $t) {
  731. $t = trim($t);
  732. if (!empty($t))
  733. $sql .= " or lower(sales_rep)='" . strtolower($t) . "'";
  734. }
  735. $sqlWhere .= " or ($sql)";
  736. } else
  737. $sqlWhere .= " or lower(sales_rep)='" . strtolower($sales_or) . "%'";
  738. }
  739. if (!empty($follow_or)) {
  740. if (utils::checkExist($follow_or, ";")) {
  741. $sql = "1!=1";
  742. $tt = explode(";", $follow_or);
  743. foreach ($tt as $t) {
  744. $t = trim($t);
  745. if (!empty($t))
  746. $sql .= " or following_sales ilike '" . $t . "%'";
  747. }
  748. $sqlWhere .= " or ($sql)";
  749. } else
  750. $sqlWhere .= " or following_sales ilike '" . $follow_or . "%'";
  751. }
  752. $sqlWhere = " and ($sqlWhere)";
  753. }
  754. return $sqlWhere;
  755. }
  756. private static function _airHandNew($user, $schemas = "public")
  757. {
  758. if($schemas=="public")
  759. {
  760. $station = $user['air_station'];
  761. $station_or = $user['air_station_or'];
  762. $sales = $user['air_sales'];
  763. $sales_or = $user['air_sales_or'];
  764. }
  765. else
  766. {
  767. $station = $user[$schemas."_ONLINE_USER"]['air_station'];
  768. $station_or = $user[$schemas."_ONLINE_USER"]['air_station_or'];
  769. $sales = $user[$schemas."_ONLINE_USER"]['air_sales'];
  770. $sales_or = $user[$schemas."_ONLINE_USER"]['air_sales_or'];
  771. }
  772. if (strtolower($station_or) == "all" || strtolower($sales_or) == "all" ) //|| strtolower($d_or) == "all"|| strtolower($op_or) == "all"|| strtolower($follow_or) == "all"
  773. {
  774. return " and 1=1";
  775. }
  776. $sqlWhere = "";
  777. if (_isCustomerLoginHandNew($user)) {
  778. //error_log("_oceanHandNew".$schemas);
  779. $sqlWhere .= " and " . _customerFilerSearchHandNew_Air($user, $schemas);
  780. }
  781. else
  782. {
  783. if (empty($station) && empty($sales) ) //&& empty($d)&& empty($op) && empty($follow)
  784. {
  785. return " and 1<>1";
  786. }
  787. if ((strtolower($station) == 'all' || empty($station)) ) //&& (strtolower($d) == "all" || empty($d))
  788. {
  789. }
  790. else
  791. {
  792. $sql = "1=1";
  793. if (!empty($station) && strtolower($station) != 'all') {
  794. $sql .= " and (lower(origin)";
  795. $sql .= utils::getInSql($station);
  796. $sql .= " or lower(destination_station)";
  797. $sql .= utils::getInSql($station);
  798. $sql .= ")";
  799. }
  800. $sqlWhere .= " and (" . $sql . ")";
  801. }
  802. if (strtolower($sales) == 'all' || empty($sales)) {
  803. } else
  804. {
  805. if (utils::checkExist($sales, ";")) {
  806. $sql = "1!=1";
  807. $tt = explode(";", $sales);
  808. foreach ($tt as $t) {
  809. $t = trim($t);
  810. if (!empty($t))
  811. {
  812. $sql .= " or lower(sales_rep)='" . strtolower($t) . "'";
  813. $sql .= " or lower(following_sales)='" . strtolower($t) . "'";
  814. }
  815. }
  816. $sqlWhere .= " and ($sql)";
  817. } else
  818. {
  819. $sqlWhere .= " or lower(sales_rep)='" . strtolower($sales) . "'";
  820. $sqlWhere .= " or lower(following_sales)='" . strtolower($sales) . "'";
  821. }
  822. }
  823. $sqlWhere = " (1=1 $sqlWhere)";
  824. if (!empty($station_or)) {
  825. $sqlWhere .= " or lower(origin)";
  826. $sqlWhere .= utils::getInSql($station_or);
  827. $sqlWhere .= " or lower(destination_station)";
  828. $sqlWhere .= utils::getInSql($station_or);
  829. }
  830. if (!empty($sales_or)) {
  831. if (utils::checkExist($sales_or, ";")) {
  832. $sql = "1!=1";
  833. $tt = explode(";", $sales_or);
  834. foreach ($tt as $t) {
  835. $t = trim($t);
  836. if (!empty($t))
  837. {
  838. $sql .= " or lower(sales_rep)='" . strtolower($t) . "'";
  839. $sql .= " or lower(following_sales)='" . strtolower($t) . "'";
  840. }
  841. }
  842. $sqlWhere .= " or ($sql)";
  843. } else
  844. {
  845. $sqlWhere .= " or lower(sales_rep)='" . strtolower($sales_or) . "'";
  846. $sqlWhere .= " or lower(following_sales)='" . strtolower($sales_or) . "'";
  847. }
  848. }
  849. $sqlWhere = " and ($sqlWhere)";
  850. }
  851. return $sqlWhere;
  852. }
  853. public static function isNewVersion() {
  854. if (utils::checkExist($_SERVER['PHP_SELF'], "main_new_version.php")) {
  855. return "_new";
  856. }
  857. return "";
  858. }
  859. public static function removeTopOceanOldVersionSpecialField($rss){
  860. $rss_bk = $rss;
  861. $new_arr = array();
  862. foreach ($rss_bk as $k => $v) {
  863. if (utils::startWith($v['database_column_name'], "__") || utils::startWith($v['database_column_name'], "___")){
  864. //unset($rss[$k]);
  865. }else{
  866. $new_arr[] = $v;
  867. }
  868. }
  869. return $new_arr;
  870. }
  871. public static function echo_json_encode($code,$data){
  872. $resData = array();
  873. $resData["code"] = $code;
  874. $resData["data"] =$data;
  875. //echo utils::jsonFiltration("null", "\"\"", json_encode($resData));
  876. echo json_encode($resData);
  877. }
  878. /*
  879. * MM/DD/YYYY To YYYY-MM-DD
  880. */
  881. public static function usDate2sqlDate($timestr) {
  882. if (empty($timestr))
  883. return '';
  884. $datearray = explode("/", $timestr);
  885. $m = $datearray [0];
  886. $d = $datearray [1];
  887. $y = $datearray [2];
  888. return $y . "-" . $m . "-" . $d;
  889. }
  890. public static function uuid() {
  891. return md5(uniqid("", TRUE) . mt_rand());
  892. }
  893. /*
  894. * YYYYMMDD To MM/DD/YYYY
  895. */
  896. public static function date2usdate($datestr) {
  897. if (empty($datestr))
  898. return '';
  899. $y = substr($datestr, 0, 4);
  900. $m = substr($datestr, 4, 2);
  901. $d = substr($datestr, 6, 2);
  902. return $m . "/" . $d . "/" . $y;
  903. }
  904. /*
  905. * date add some days
  906. */
  907. public static function addDays($date, $days) {
  908. $time = strtotime($date) + $days * 24 * 3600;
  909. return date('m/d/Y', $time);
  910. }
  911. /*
  912. * download file from file system
  913. */
  914. public static function download_file($filename, $display_name = null, $delete = FALSE, $files = NULL) {
  915. $filename = str_replace("/", DIRECTORY_SEPARATOR, $filename);
  916. $filename = str_replace("\\", DIRECTORY_SEPARATOR, $filename);
  917. if (!file_exists($filename))
  918. exit('File Not Exist');
  919. if (empty($display_name))
  920. $display_name = basename($filename);
  921. //$file = fopen($filename, "r");
  922. header_remove("Content-type");
  923. header("Content-type:" . self::getContentType($filename));
  924. header("Expires: 0");
  925. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  926. header("Pragma: can-cache");
  927. header("Accept-ranges:bytes");
  928. header("Accept-length:" . filesize($filename));
  929. header("Content-Disposition:attachment;filename=\"" . $display_name . "\"");
  930. //echo fread($file, filesize($filename));
  931. //fclose($file);
  932. //针对大文件,规定每次读取文件的字节数为4096字节,直接输出数据
  933. $read_buffer = 4096;
  934. $handle = fopen($filename, 'rb');
  935. //总的缓冲的字节数
  936. $sum_buffer = 0;
  937. $filesize = filesize($filename);
  938. //只要没到文件尾,就一直读取
  939. while (!feof($handle) && $sum_buffer < $filesize) {
  940. echo fread($handle, $read_buffer);
  941. $sum_buffer += $read_buffer;
  942. }
  943. //关闭句柄
  944. fclose($handle);
  945. if ($delete !== FALSE) {
  946. unlink($filename);
  947. }
  948. if (!empty($files)) {
  949. foreach ($files as $f) {
  950. unlink($f);
  951. }
  952. }
  953. }
  954. public static function getContentType($filename) {
  955. $extend = self::getExtendFilename($filename);
  956. $filetype = array(
  957. 'xls' => 'application/vnd.ms-excel',
  958. 'doc' => 'application/msword',
  959. 'gif' => 'image/gif',
  960. 'jpg' => 'image/jpeg',
  961. 'jpeg' => 'image/jpeg',
  962. 'jpe' => 'image/jpeg',
  963. 'bmp' => 'image/bmp',
  964. 'png' => 'image/png',
  965. 'tif' => 'image/tiff',
  966. 'pdf' => 'application/pdf',
  967. 'zip' => 'application/zip'
  968. );
  969. return $filetype[$extend];
  970. }
  971. /*
  972. * Get the file extension
  973. */
  974. public static function getExtendFilename($file_name) {
  975. $extend = pathinfo($file_name);
  976. $extend = strtolower($extend["extension"]);
  977. return $extend;
  978. }
  979. public static function getManagement(){
  980. //Management 自己配置需要创建表保存
  981. $user_management_data = common::excuteObjectSql("select management,dashboard_filter from ra_online_user where user_login = '"._getLoginName()."'");
  982. //为空,配置使用默认值
  983. $user_management = $user_management_data['management'];
  984. if(empty($user_management)){
  985. $Management = common::getdefaultManagement();
  986. }else{
  987. $Management = json_decode($user_management,true);
  988. foreach($Management as $key =>$val){
  989. $Management[$key]['id'] = intval($val['id']);
  990. $Management[$key]['switchValue'] = $val['switchValue'] == "true" ? true : false;
  991. }
  992. }
  993. return array("Management" => $Management,"dashboard_filter" =>$user_management_data['dashboard_filter']);
  994. }
  995. public static function getItemStyle($type,$code){
  996. if($type == 'r1'){
  997. $data = array("0-20 Days" =>"#ffc594",
  998. "20-40 Days" =>"#ff9e4c",
  999. "40-60 Days" =>"#ff7500",
  1000. "60-80 Days" =>"#ff3d00",
  1001. "Over 80 Days" =>"#d50000");
  1002. return $data[$code];
  1003. }
  1004. if($type == 'r4' || $type == 'r3' || $type == 'atd_r4' || $type == 'ata_r3'){
  1005. $data = array("0 Day" =>"#ffc594",
  1006. "Today" =>"#ffc594",
  1007. "1-2 Days" =>"#ff9e4c",
  1008. "3-6 Days" =>"#ff7500",
  1009. "7 Days" =>"#ff3d00");
  1010. return $data[$code];
  1011. }
  1012. if($type == 'r2' || utils::startWith($type,"co2e")){
  1013. $data = array("45" =>"#FFE3CC",
  1014. "40" =>"#FFAC66",
  1015. "20" =>"#FF7500",
  1016. "air" =>"#FFE3CC",
  1017. "sea" =>"#FFAC66",
  1018. "road" =>"#FF7500");
  1019. return $data[$code];
  1020. }
  1021. if($type == "top"){
  1022. $data = array("1" =>"#FF7500",
  1023. "2" =>"#ff9033",
  1024. "3" =>"#ff9e4d",
  1025. "4" =>"#ffac66",
  1026. "5" =>"#ffba80",
  1027. "6" =>"#ffc899",
  1028. "7" =>"#ffd6b3",
  1029. "8" =>"#ffe3cc",
  1030. "9" =>"#fff1e6",
  1031. "10" =>"#fff1e6");
  1032. return $data[$code];
  1033. }
  1034. }
  1035. //处理返回原表数据格式
  1036. public static function mian_repot_do($value,$type,$totalValue){
  1037. $data = array();
  1038. $value_arr = json_decode($value,true);
  1039. //r1 是 ETD to ETA (Days)圆形图表数据结构返回
  1040. if($type == 'r1'){
  1041. $ETDList = array();
  1042. foreach($value_arr as $arr){
  1043. $color = common::getItemStyle($type,$arr['name']);
  1044. $ETDList[] = array("value" =>intval($arr['value']),"name" =>$arr['name'],"itemStyle" =>array("color" =>$color));
  1045. }
  1046. $ETDList = array_reverse($ETDList);
  1047. $ETD_Title = "Total: $totalValue";
  1048. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('50%','80%'),"ETD_Title" =>$ETD_Title,"download_name" => "ETD to ETA (Days)");
  1049. }
  1050. if($type == 'r4' || $type == 'r3'){
  1051. //重新整理一下数据,给UI一致
  1052. $data_kd = array();
  1053. foreach($value_arr as $arr){
  1054. if(stripos("Today", $arr['name']) !== false){
  1055. $color = common::getItemStyle($type,"Today");
  1056. if(empty($data_kd["0"])){
  1057. $data_kd["0"] = array("value" =>intval($arr['value']),"name" =>"≤1 Day","itemStyle" =>array("color" =>$color));
  1058. }else{
  1059. $data_kd["0"]["value"] = $data_kd["0"]["value"] + intval($arr['value']);
  1060. }
  1061. }
  1062. if(stripos("+1 Days/+2 Days", $arr['name']) !== false){
  1063. $color = common::getItemStyle($type,"1-2 Days");
  1064. if(empty($data_kd["1"])){
  1065. $data_kd["1"] = array("value" =>intval($arr['value']),"name" =>"1-2 Days","itemStyle" =>array("color" =>$color));
  1066. }else{
  1067. $data_kd["1"]["value"] = $data_kd["1"]["value"] + intval($arr['value']);
  1068. }
  1069. }
  1070. if(stripos("+3 Days/+4 Days/+5 Days/+6 Days", $arr['name']) !== false){
  1071. $color = common::getItemStyle($type,"3-6 Days");
  1072. if(empty($data_kd["2"])){
  1073. $data_kd["2"] = array("value" =>intval($arr['value']),"name" =>"3-6 Days","itemStyle" =>array("color" =>$color));
  1074. }else{
  1075. $data_kd["2"]["value"] = $data_kd["2"]["value"] + intval($arr['value']);
  1076. }
  1077. }
  1078. if(stripos("+7 Days/Over 7 Days", $arr['name']) !== false){
  1079. $color = common::getItemStyle($type,"7 Days");
  1080. if(empty($data_kd["3"])){
  1081. $data_kd["3"] = array("value" =>intval($arr['value']),"name" =>"≥7 Days","itemStyle" =>array("color" =>$color));
  1082. }else{
  1083. $data_kd["3"]["value"] = $data_kd["3"]["value"] + intval($arr['value']);
  1084. }
  1085. }
  1086. }
  1087. if($type == 'r4'){
  1088. $data = array("ETDList" =>$data_kd,"ETD_Radius"=>array('30%','50%'),"title1" =>"Departure","title2" =>"","download_name" => "Pending Departure");
  1089. }
  1090. if($type == 'r3'){
  1091. $data = array("ETDList" =>$data_kd,"ETD_Radius"=>array('30%','50%'),"title1" =>"Arrival","title2" =>"","download_name" => "Pending Arrival");
  1092. }
  1093. }
  1094. return $data;
  1095. }
  1096. //单独处理co2e bar
  1097. public static function getCo2eBar(){
  1098. //新UI air sea road 目前只有sea
  1099. $type = $_REQUEST["r_type"];
  1100. $shipment_mode_arr = array("air","sea","road");
  1101. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  1102. $sqlWhere = " " . $sqlWhere;
  1103. $ContainerCount_Title = array();
  1104. //先查询总的排放量sea air road,确定排名后,在分别查询对应的sea air road
  1105. if ($type == "co2e_orgin"){
  1106. $co2e_shippr_sql = "select SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum ,
  1107. shippr_uncode as station from online_ocean where 1=1 and COALESCE(shippr_uncode)<>'' $sqlWhere group by shippr_uncode order by catnum desc limit 10";
  1108. $co2e_aLL = common::excuteListSql($co2e_shippr_sql);
  1109. }
  1110. if ($type == "co2e_destination"){
  1111. $co2e_consignee_sql = "select SUM(COALESCE(carbon_emission,0)::numeric(12,10)) as catnum,
  1112. consignee_uncode as station from online_ocean where 1=1 and COALESCE(consignee_uncode)<>'' $sqlWhere group by consignee_uncode order by catnum desc limit 10";
  1113. $co2e_aLL = common::excuteListSql($co2e_consignee_sql);
  1114. }
  1115. //最大Y值
  1116. $maxY = 0;
  1117. $stations = array();
  1118. foreach($co2e_aLL as $val){
  1119. $ContainerCount_Title[] = $val['station'];
  1120. $maxY = $maxY > $val['catnum'] ? $maxY : $val['catnum'];
  1121. $stations[] = $val['station'];
  1122. }
  1123. $station_str = utils::implode(',',$stations);
  1124. $ContainerCounSeries = array();
  1125. foreach($shipment_mode_arr as $_shipment_mode){
  1126. //类型有 sea air road,目前之类只查询sea的,其他为空
  1127. $shipment_mode = $_shipment_mode;
  1128. $co2e = array();
  1129. if ($type == "co2e_orgin"){
  1130. $co2e_shippr_sql_union = utils::_getSql($station_str,$type,$shipment_mode);
  1131. if(!empty($co2e_shippr_sql_union)){
  1132. $co2e = common::excuteListSql($co2e_shippr_sql_union);
  1133. }
  1134. $download_name = "CO2e Emission by Origin (Top 10)";
  1135. }
  1136. if ($type == "co2e_destination"){
  1137. $co2e_consignee_union = utils::_getSql($station_str,$type,$shipment_mode);
  1138. if(!empty($co2e_consignee_union)){
  1139. $co2e = common::excuteListSql($co2e_consignee_union);
  1140. }
  1141. $download_name = "CO2e Emission by Destination (Top 10)";
  1142. }
  1143. $total = 0;
  1144. $max = 0;
  1145. $data = array();
  1146. foreach($co2e as $val){
  1147. $data[] = $val['catnum'];
  1148. $total = $total + $val['catnum'];
  1149. $max = $max < $val['catnum'] ? $val['catnum'] : $max;
  1150. }
  1151. $ContainerCounSeries[$shipment_mode] = array("data"=>$data,"total"=>$total,"max"=>$max);
  1152. }
  1153. //处理返回时数据格式 其实不太需要计算最大值,在最开始总量查询的时候以及查询出来
  1154. $ContainerCounSeries_return = array();
  1155. foreach($ContainerCounSeries as $k =>$v){
  1156. $color = common::getItemStyle($type,$k);
  1157. $ContainerCounSeries_return[] = array("name"=>$k,"type"=>"bar","emphasis" => array("focus" =>"none"),
  1158. "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
  1159. }
  1160. //处理返回原表数据格式
  1161. //计算刻度值 最小值是0,最大值是3000,刻度是500 interval
  1162. $interval = utils::calculateTicks(0,$maxY,10);
  1163. if($interval == 0){
  1164. //处理返回默认值
  1165. $interval = 1;
  1166. }
  1167. $returnData = array("ContainerCount_Title"=>"","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
  1168. "min" => 0,"Max" =>$interval*10,"interval" =>$interval,"download_name" => $download_name);
  1169. return $returnData;
  1170. }
  1171. public static function getTopBar(){
  1172. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  1173. $sqlWhere = " " . $sqlWhere;
  1174. $toporiginType = "shippr_uncode";
  1175. // $shippr_uncode_10_sql = "select count(shippr_uncode) as num,shippr_uncode,
  1176. // (array_agg(shipper_city))[1] AS shipper_city from online_ocean
  1177. // where 1=1 and COALESCE(shippr_uncode)<>'' $sqlWhere group by shippr_uncode order by num desc limit 10";
  1178. $shippr_uncode_10_sql ="with aa as (select count(shippr_uncode) as num,shippr_uncode,
  1179. (array_agg(shipper_city))[1] AS shipper_city from online_ocean
  1180. where 1=1 and COALESCE(shippr_uncode)<>'' $sqlWhere group by shippr_uncode order by num desc limit 10)
  1181. select aa.*,dd.* from aa
  1182. left join LATERAL ( select lon as lng, lat as lat,
  1183. '' as label, '' as infor, 3 as sort,
  1184. null::timestamp without time zone as stime,''::text as ptype
  1185. from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=aa.shippr_uncode ) dd on true";
  1186. $shippr_uncode_10 = common::excuteListSql($shippr_uncode_10_sql);
  1187. //如果值没有:客户地址-->站点地址-->Port地址(POL/POD)
  1188. if(count($shippr_uncode_10) == 1 && empty($shippr_uncode_10[0]["shippr_uncode"])){
  1189. $toporiginType = "fport_of_loading_un";
  1190. $shippr_uncode_10_sql = "with aa as (select count(fport_of_loading_un) as num,fport_of_loading_un as shippr_uncode
  1191. from online_ocean where 1=1 and COALESCE(fport_of_loading_un)<>'' $sqlWhere group by fport_of_loading_un order by num desc limit 10)
  1192. select aa.*,dd.* from aa
  1193. left join LATERAL ( select lon as lng, lat as lat,
  1194. '' as label, '' as infor, 3 as sort,
  1195. null::timestamp without time zone as stime,''::text as ptype
  1196. from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=aa.fport_of_loading_un ) dd on true";
  1197. $shippr_uncode_10 = common::excuteListSql($shippr_uncode_10_sql);
  1198. }
  1199. //$toporiginType = "fport_of_loading_un";
  1200. $topdestinationinType = "consignee_uncode";
  1201. // $consignee_uncode_10_sql = "select count(consignee_uncode) as num,consignee_uncode,
  1202. // (array_agg(consignee_city))[1] AS consignee_city
  1203. // from online_ocean where 1=1 and COALESCE(consignee_uncode)<>'' $sqlWhere group by consignee_uncode order by num desc limit 10";
  1204. $consignee_uncode_10_sql = "with aa as (select count(consignee_uncode) as num,consignee_uncode,
  1205. (array_agg(consignee_city))[1] AS consignee_city
  1206. from online_ocean where 1=1 and COALESCE(consignee_uncode)<>'' $sqlWhere group by consignee_uncode order by num desc limit 10)
  1207. select aa.*,dd.* from aa
  1208. left join LATERAL ( select lon as lng, lat as lat,
  1209. '' as label, '' as infor, 3 as sort,
  1210. null::timestamp without time zone as stime,''::text as ptype
  1211. from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=aa.consignee_uncode ) dd on true";
  1212. $consignee_uncode_10 = common::excuteListSql($consignee_uncode_10_sql);
  1213. //如果值没有:客户地址-->站点地址-->Port地址(POL/POD)
  1214. if(count($consignee_uncode_10) == 1 && empty($consignee_uncode_10[0]["consignee_uncode"])){
  1215. $topdestinationinType = "mport_of_discharge_un";
  1216. $consignee_uncode_10_sql = "with aa as (select count(mport_of_discharge_un) as num,mport_of_discharge_un as consignee_uncode from online_ocean where 1=1 and COALESCE(mport_of_discharge_un)<>'' $sqlWhere group by mport_of_discharge_un order by num desc limit 10)
  1217. select aa.*,dd.* from aa
  1218. left join LATERAL ( select lon as lng, lat as lat,
  1219. '' as label, '' as infor, 3 as sort,
  1220. null::timestamp without time zone as stime,''::text as ptype
  1221. from vessel.vt_unlocode where lon<>0 and lat<>0 and lon is not null and lat is not null and uncode=aa.mport_of_discharge_un ) dd on true";
  1222. $consignee_uncode_10 = common::excuteListSql($consignee_uncode_10_sql);
  1223. }
  1224. $toporigin = array();
  1225. $toporiginMap = array();
  1226. $i = 0;
  1227. $origiNunMax = 0;
  1228. foreach($shippr_uncode_10 as $orgin){
  1229. $i = $i + 1;
  1230. $map = array();
  1231. if(!empty($orgin['lat'])&&!empty($orgin['lng'])){
  1232. $map = array("lat" =>$orgin['lat'],"lng" =>$orgin['lng']);
  1233. }
  1234. //$json = '{"lng":121.8525,"lat":29.926545,"label":"'.$orgin['origin'].'","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"}';
  1235. //$map = json_decode($json,true);
  1236. if(!empty($map)){
  1237. $toporiginMap[] = array("qandl"=>array(floatval($map['lat']),floatval($map['lng'])),
  1238. "divIcon" => array("iconSize"=>0),
  1239. "name" =>$orgin['shippr_uncode'],
  1240. "color" =>common::getItemStyle("top",$i),
  1241. "value" =>$orgin['num'],
  1242. "textcolor" =>"#FFF");
  1243. }
  1244. //查询uncode,对应的city
  1245. $city = "";
  1246. if($toporiginType == "shippr_uncode"){
  1247. $city = $orgin['shipper_city'];
  1248. }
  1249. //$city 做假数据
  1250. $toporigin[] = array("name"=>$orgin['shippr_uncode'],"city_name"=>$city,"value"=>$orgin['num'],"color"=>common::getItemStyle("top",$i));
  1251. $origiNunMax = $origiNunMax < $orgin['num'] ? $orgin['num'] : $origiNunMax;
  1252. }
  1253. $topdestination = array();
  1254. $topdestinationinMap = array();
  1255. $i = 0;
  1256. $agentiNunMax = 0;
  1257. foreach($consignee_uncode_10 as $agent){
  1258. $i = $i + 1;
  1259. $map = array();
  1260. if(!empty($agent['lat'])&&!empty($agent['lng'])){
  1261. $map = array("lat" =>$agent['lat'],"lng" =>$agent['lng']);
  1262. }
  1263. // $json = '{"lng":"100.78594000","lat":"13.68521000","label":"'.$agent['agent'].'","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"}';
  1264. // $map = json_decode($json,true);
  1265. if(!empty($map)){
  1266. $topdestinationinMap[] = array("qandl"=>array(floatval($map['lat']),floatval($map['lng'])),
  1267. "divIcon" => array("iconSize"=>0),
  1268. "name" =>$agent['consignee_uncode'],
  1269. "color" =>common::getItemStyle("top",$i),
  1270. "value" =>$agent['num'],
  1271. "textcolor" =>"#FFF");
  1272. }
  1273. //查询uncode,对应的city
  1274. $city = "";
  1275. if($topdestinationinType == "consignee_uncode"){
  1276. $city = $agent['consignee_city'];
  1277. }
  1278. //$city 做假数据
  1279. $topdestination[] = array("name"=>$agent['consignee_uncode'],"city_name"=>$city,"value"=>$agent['num'],"color"=>common::getItemStyle("top",$i));
  1280. $agentiNunMax = $agentiNunMax < $agent['num'] ? $agent['num'] : $agentiNunMax;
  1281. }
  1282. //处理返回原表数据格式
  1283. $interval = utils::calculateTicks(0,$origiNunMax,10);
  1284. if($interval == 0){
  1285. //处理返回默认值
  1286. $interval = 1;
  1287. }
  1288. $dest_interval = utils::calculateTicks(0,$agentiNunMax,10);
  1289. if($dest_interval == 0){
  1290. //处理返回默认值
  1291. $dest_interval = 1;
  1292. }
  1293. $returnData = array("seller_data_list_origin"=>$toporigin,"toporiginMap"=>array_reverse($toporiginMap),"toporiginType"=>$toporiginType,
  1294. "seller_data_list_destination"=>$topdestination,"topdestinationinMap"=>array_reverse($topdestinationinMap),"topdestinationinType"=>$topdestinationinType,
  1295. "min" => 0,"Max" =>$interval*10,"interval" =>$interval,
  1296. "dest_min" => 0,"dest_Max" =>$dest_interval*10,"dest_interval" =>$dest_interval);
  1297. return $returnData;
  1298. }
  1299. public static function getdefaultManagement(){
  1300. $Management = array();
  1301. $Management[] = array("id"=>1 ,
  1302. "title"=>"KPI",
  1303. "switchValue"=>true,
  1304. "text"=>"Pie chart showing figures of shipments KPI of Departure and Arrival.");
  1305. $Management[] = array("id"=>2 ,
  1306. "title"=>"Pending",
  1307. "switchValue"=>true,
  1308. "text"=>"Pie chart showing figures of shipments which are soon to depart/arrive (Calculated from ETD/ETA).");
  1309. $Management[] = array("id"=>3 ,
  1310. "title"=>"Recent Status",
  1311. "switchValue"=>true,
  1312. "text"=>"A shipment list with latest status update on top.");
  1313. $Management[] = array("id"=>4 ,
  1314. "title"=>"ETD to ETA (Days)",
  1315. "switchValue"=>true,
  1316. "text"=>"Pie chart showing figures of shipments which are soon to depart/arrive (Calculated from ETD/ETA).");
  1317. $Management[] = array("id"=>5 ,
  1318. "title"=>"Container Count",
  1319. "switchValue"=>true,
  1320. "text"=>"Pie chart showing figures of shipments which are soon to depart/arrive (Calculated from ETD/ETA).");
  1321. $Management[] = array("id"=>6 ,
  1322. "title"=>"Top 10 Origin/Destination",
  1323. "switchValue"=>true,
  1324. "text"=>"Figure of the top 10 origin/destination.",
  1325. "title1"=>"Top 10 Origin",
  1326. "title2"=>"Top 10 Destination");
  1327. $Management[] = array("id"=>7 ,
  1328. "title"=>"CO2e Emission by Origin (Top 10)",
  1329. "switchValue"=>true,
  1330. "text"=>"Figure of the CO2e Emission by origin.");
  1331. $Management[] = array("id"=>8 ,
  1332. "title"=>"CO2e Emission by Destination (Top 10)",
  1333. "switchValue"=>true,
  1334. "text"=>"Figure of the CO2e Emission by destination.");
  1335. return $Management;
  1336. }
  1337. /**
  1338. * Destroy Session
  1339. */
  1340. public static function sessionDestroy() {
  1341. session_destroy();
  1342. setcookie(session_name(), '', time() - 3600);
  1343. $_SESSION = array();
  1344. }
  1345. public static function retStationInfo($address_1,$address_2,$address_3,$address_4,$city,$state,$country,$zipcode){
  1346. $stationInfo = "";
  1347. if(!empty($address_1)){
  1348. $stationInfo .= $address_1;
  1349. }
  1350. if(!empty($address_2)){
  1351. $stationInfo .= " ".$address_2;
  1352. }
  1353. if(!empty($address_3)){
  1354. $stationInfo .= " ".$address_3;
  1355. }
  1356. if(!empty($address_4)){
  1357. $stationInfo .= " ".$address_4;
  1358. }
  1359. $temp_str = "";
  1360. if(!empty($city)){
  1361. $temp_str .= $city." ";
  1362. }
  1363. if(!empty($state)){
  1364. $temp_str .= $state." ";
  1365. }
  1366. if(!empty($zipcode)){
  1367. $temp_str .= $zipcode." ";
  1368. }
  1369. if(!empty($country)){
  1370. $temp_str .= $country." ";
  1371. }
  1372. if(!empty($temp_str)){
  1373. return $stationInfo." ".trim($temp_str);
  1374. }
  1375. return $stationInfo;
  1376. }
  1377. public static function getInsertSqlNull($table_name, $values) {
  1378. $field = "";
  1379. $value = "";
  1380. foreach ($values as $k => $v) {
  1381. if ($k == 'tmp' || $k == 'action' || $k == 'operate' || $k == 'x' || $k == 'y') {
  1382. continue;
  1383. }
  1384. if (is_array($v)) {
  1385. $v = utils::implode(",", $v);
  1386. }
  1387. if (empty($field)) {
  1388. $field = $k;
  1389. if (utils::checkExist($v, 'now()')) {
  1390. $value = $v;
  1391. } elseif ($v == null) {
  1392. $value .= 'null';
  1393. } elseif ($v == 'TRUE' || $v == 'FALSE') {
  1394. $value .= $v;
  1395. } else {
  1396. $value = '\'' . common::check_input($v) . '\'';
  1397. }
  1398. } else {
  1399. $field .= ',' . $k;
  1400. if (utils::checkExist($v, 'now()'))
  1401. $value .= ', now()';
  1402. elseif ($v == null) {
  1403. $value .= ',null';
  1404. } else if ($v == 'TRUE' || $v == 'FALSE') {
  1405. $value .= ',' . $v;
  1406. } else {
  1407. $value .= ', \'' . common::check_input($v) . '\'';
  1408. }
  1409. }
  1410. }
  1411. return 'insert into ' . $table_name . '(' . $field . ') values (' . $value . ')';
  1412. }
  1413. //密码规则验证
  1414. public static function checkPasswordRule($login, $new_password){
  1415. $sql="select item_value from config where item='passwordCheckRules'";
  1416. $rs = common::excuteObjectSql($sql);
  1417. $str = "";
  1418. if (!empty($rs)) {
  1419. $passwordCheckRules = json_decode($rs["item_value"],true);
  1420. //校验使用次数
  1421. if (!empty($passwordCheckRules["pastPasswordCheckNum"])) {
  1422. $sql = "select password from public.ra_online_user_password_history where lower(user_login)='".common::check_input(strtolower($login))."' order by id desc limit ".$passwordCheckRules["pastPasswordCheckNum"];
  1423. $passwords = common::excuteListSql($sql);
  1424. foreach ($passwords as $pwd) {
  1425. if ($pwd['password'] == $new_password) {
  1426. $str = "This password has been recently used";
  1427. }
  1428. }
  1429. }
  1430. if(empty($str)){
  1431. $str = utils::checkPassword($new_password,$passwordCheckRules,$login);
  1432. }
  1433. }else{
  1434. $str = utils::checkPassword($new_password);
  1435. }
  1436. return $str;
  1437. }
  1438. public static function getMilestonesInfo($ocean){
  1439. //Milestones info 列名固定
  1440. $Milestones_column = array();
  1441. $Milestones_column[] = array("title" =>"Milestones","field" =>"milestones","formatter" =>"normal","type" =>"normal");
  1442. $Milestones_column[] = array("title" =>"Date Time","field" =>"date_time","formatter" =>"dateTime","type" =>"normal");
  1443. $Milestones_column[] = array("title" =>"Locations","field" =>"locations","formatter" =>"normal","type" =>"normal");
  1444. $Milestones_column[] = array("title" =>"Remarks","field" =>"remarks","formatter" =>"normal","type" =>"normal");
  1445. //IFF Event and EDI 315 Mapping
  1446. $Mapping = array("IFFREC","IFFONB","IFFDEP","IFFARR","IFFUND","IFFAFD","IFFCTA","IFFICC","IFFPPD","IFFECP");
  1447. $Mapping_location = array();
  1448. foreach($Mapping as $code){
  1449. if($code == "IFFREC" || $code == "IFFONB" || $code == "IFFDEP" || $code == "IFFECP"){
  1450. //Place of Receipt,Port of Loading
  1451. $Mapping_location[$code] = empty($ocean['place_of_receipt_exp']) ? $ocean['fport_of_loading_exp'] : $ocean['place_of_receipt_exp'];
  1452. }
  1453. if($code == "IFFARR" || $code == "IFFICC" || $code == "IFFPPD"){
  1454. //Port of discharge
  1455. $Mapping_location[$code] = $ocean['mport_of_discharge_exp'];
  1456. }
  1457. if($code == "IFFUND"){
  1458. //Port of discharge,place of delivery / Final Destination
  1459. $Mapping_location[$code] = empty($ocean['mport_of_discharge_exp']) ? $ocean['place_of_delivery_exp']." ".$ocean['final_desination_exp'] : $ocean['mport_of_discharge_exp'];
  1460. }
  1461. if($code == "IFFAFD"){
  1462. //Place of Delivery
  1463. $Mapping_location[$code] = $ocean['place_of_delivery_exp'];
  1464. }
  1465. if($code == "IFFCTA"){
  1466. //Place of Delivery,port of discharge
  1467. $Mapping_location[$code] = empty($ocean['place_of_delivery_exp']) ? $ocean['mport_of_discharge_exp'] : $ocean['place_of_delivery_exp'];
  1468. }
  1469. }
  1470. //Milestones 数据信息待定
  1471. $Milestones_data = array();
  1472. $Milestones_data_arr = common::excuteListSql("select sn.description,
  1473. act_date||' '||COALESCE(act_time,'') as date_time,
  1474. remark,timezone,a.code,create_by, '' as act_update_by
  1475. from ocean_milestone a
  1476. inner join customer_service_milestone_sno sn on sn.code=a.code
  1477. where a.serial_no='".$ocean["serial_no"]."' and act_date is not null order by sn.sno asc");
  1478. foreach($Milestones_data_arr as $mda){
  1479. $locations = "";
  1480. if(!empty($Mapping_location[$mda['code']])){
  1481. $locations = $Mapping_location[$mda['code']];
  1482. }else{
  1483. //第二优先级:用Milestone更新的对应的站点的location
  1484. $user_login = empty($mda['act_update_by']) ? $mda['create_by'] : $mda['act_update_by'];
  1485. $city_by_user = common::excuteObjectSql("select e.city from ra_online_user r,employee e where r.employee_id=e.employee_id and lower(r.user_login)=lower('$user_login') limit 1");
  1486. $locations = $city_by_user['city'];
  1487. }
  1488. $Milestones_data[] = array("milestones"=>$mda['description'],"date_time"=>$mda['date_time'],"timezone" =>$mda['timezone'],
  1489. "locations" => $locations, "remarks" =>$mda['remark']);
  1490. }
  1491. $Milestones = array("Milestones_column"=>$Milestones_column,"Milestones_data" =>$Milestones_data);
  1492. return $Milestones;
  1493. }
  1494. /**
  1495. * 查询uncode 对应的时区
  1496. */
  1497. public static function getCityPortsInfo($uncodes){
  1498. $data =array();
  1499. $sql = "select timezonecode,ctrycitycode from public.city_ports where lower(ctrycitycode) ". common::getInNotInSql($uncodes);
  1500. $uncode_rs = common::excuteListSql($sql);
  1501. foreach($uncode_rs as $value){
  1502. $data[$value['ctrycitycode']] = $value['timezonecode'];
  1503. }
  1504. return $data;
  1505. }
  1506. }
  1507. ?>