main_new_version.php 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901
  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. include 'service/robot.class.php';
  20. include 'service/AIClientFactory.php';
  21. include 'service/destination_delivery.class.php';
  22. include 'service/report.class.php';
  23. include 'service/multilingual.class.php';
  24. //为了调用,临时做一个登录动作 如果是正式版 要注释掉菜单System Settings
  25. //$_POST['uname'] = "ra.admin";
  26. //$_POST['psw'] = common::excuteOneSql("select ra_password from public.ra_online_user where user_login = 'ra.admin'");
  27. // $name = "dddde";
  28. // $name = "ra.admin";
  29. // $_POST['uname'] = $name;
  30. // $_POST['psw'] = common::excuteOneSql("select ra_password from public.ra_online_user where user_login = '".$name."'");
  31. // login::getInstance()->do_login_auto("test");
  32. //验证路由权限
  33. common::securityCheckHandNew($action);
  34. if (_is_only_vgm()) {
  35. Header("Location:main.php?action=main");
  36. }
  37. error_log("--------------前端请求post参数---------------");
  38. error_log(utils::jsonFiltration("null", "\"\"", json_encode($_POST)));
  39. error_log("--------------前端请求get参数---------------");
  40. error_log(utils::jsonFiltration("null", "\"\"", json_encode($_GET)));
  41. //Operation log 日志记录
  42. utils::operation_log_records();
  43. switch ($action) {
  44. case 'ocean_booking':
  45. ocean_booking::getInstance()->ocean_booking();
  46. break;
  47. case 'ocean_order':
  48. ocean_order::getInstance()->ocean_order();
  49. break;
  50. case 'ajax':
  51. echo ajax::getInstance()->run();
  52. break;
  53. case 'opreation_log':
  54. echo operation_log::getInstance()->operation_log();
  55. break;
  56. case 'main':
  57. //如果在没有登录前,没有登录信息,指定用户
  58. if(!isset($_SESSION['ONLINE_USER'])){
  59. $menuList = array();
  60. $menuList[] = array("index"=>'1',"label"=>"Dashboard","cleaned_field_name"=>"menu.dashboard","icon"=>"icon_data_fill_b","path"=>"/dashboard");
  61. $menuList[] = array("index"=>'2',"label"=>"Booking","cleaned_field_name"=>"menu.booking","icon"=>"icon_booking__fill_b","path"=>"/booking");
  62. $menuList[] = array("index"=>'3',"label"=>"Tracking","cleaned_field_name"=>"menu.tracking","icon"=>"icon_tracking__fill_b","path"=>"/tracking");
  63. } else {
  64. //d登录后,根据配置的权限,是否显示
  65. if (_isAdmin())
  66. $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)";
  67. elseif (_isNewUser())
  68. $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)";
  69. else
  70. $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)";
  71. $rs = common::excuteListSql($sql);
  72. if (empty($rs) && _isApexLogin()) {
  73. $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)";
  74. $rs = common::excuteListSql($sql);
  75. }
  76. $menuSetting = array("Ocean Booking" => array("label"=>"Booking","cleaned_field_name"=>"menu.booking","path"=>"/booking","icon"=>"icon_booking__fill_b"),
  77. "Ocean B/L Info." => array("label"=>"Tracking","cleaned_field_name"=>"menu.tracking","path"=>"/tracking","icon"=>"icon_tracking__fill_b"));
  78. $menuList = array();
  79. $menuList[] = array("index"=>'1',"label"=>"Dashboard","cleaned_field_name"=>"menu.dashboard","icon"=>"icon_data_fill_b","path"=>"/dashboard");
  80. $index = 2;
  81. foreach ($rs as $value) {
  82. if ($value['f_column'] == "Shipment Info."){
  83. if (_isAdmin())
  84. $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");
  85. elseif (_isNewUser())
  86. $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");
  87. else
  88. $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");
  89. if (empty($ll) && _isApexLogin()) {
  90. $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");
  91. }
  92. //单独拼接URL
  93. foreach ($ll as $v) {
  94. if($v['s_column'] =="Ocean B/L Info."){
  95. $urlData = $menuSetting[$v['s_column']];
  96. $menuList[] = array("index"=>"$index","label"=>$urlData['label'],"cleaned_field_name"=>$urlData['cleaned_field_name'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
  97. $index = $index + 1;
  98. }
  99. //特殊处理book,需要加二级菜
  100. if($v['s_column'] =="Ocean Booking"){
  101. // $urlData = $menuSetting[$v['s_column']];
  102. // $menuList[] = array("index"=>"$index","label"=>$urlData['label'],"icon"=>$urlData['icon'],"path"=>$urlData['path']);
  103. $bookingManagement = array("index"=>"$index","label"=>"Booking","cleaned_field_name"=>"menu.booking","icon"=>"icon_booking__fill_b","type"=>"list");
  104. $children = array();
  105. $urlData = $menuSetting[$v['s_column']];
  106. $children[] = array("index"=>$index.'-1',"label"=>"Booking Management","cleaned_field_name"=>"menu.booking_management","path"=>$urlData['path']);
  107. $children[] = array("index"=>$index.'-2',"label"=>"Destination Delivery","cleaned_field_name"=>"menu.destination_delivery","path"=>"/destination-delivery");
  108. $bookingManagement["children"] = $children;
  109. $menuList[] = $bookingManagement;
  110. $index = $index + 1;
  111. }
  112. }
  113. }
  114. }
  115. //Report 暂时先这么写,后面这个kln 单独维护独有的菜单栏,和online 隔离开
  116. $urlData = $menuSetting[$v['s_column']];
  117. $menuList[] = array("index"=>"4","label"=>"Report","cleaned_field_name"=>"menu.report","icon"=>'icon_report__fill_b',"path"=>'/report');
  118. $index = $index + 1;
  119. $systemManagement = array("index"=>"$index","label"=>"System Management","cleaned_field_name"=>"menu.system_management","icon"=>"icon_system__management_fill_b","type"=>"list");
  120. $children = array();
  121. if(_isVipReportAdmin(_getLoginName())){
  122. $children[] = array("index" =>$index.'-7',"label" =>"Template Management","cleaned_field_name"=>"menu.template_management","path"=>"/template-management");
  123. }
  124. $children[] = array("index" =>$index.'-1',"label" =>"System Message","cleaned_field_name"=>"menu.system_message","path"=>"/system-message");
  125. $children[] = array("index" =>$index.'-2',"label" =>"System Settings","cleaned_field_name"=>"menu.system_settings","path"=>"/system-settings");
  126. if(_isTranslationReviewerAdmin(_getLoginName())){
  127. $children[] = array("index" =>$index.'-3',"label" =>"multilingual_config","cleaned_field_name"=>"menu.multilingual_config","path"=>"/multilingual-config");
  128. }
  129. //只有chud的账户可以看日志记录
  130. if(strtolower(_getLoginName()) == "chud"
  131. || strtolower(_getLoginName()) == strtolower("IT.Andywu")
  132. || strtolower(_getLoginName()) == "ra.admin"){
  133. $children[] = array("index" =>$index.'-4',"label" =>"Chat Log","cleaned_field_name"=>"menu.chat_log","path"=>"/chat-log");
  134. $children[] = array("index" =>$index.'-5',"label" =>"AI API Log","cleaned_field_name"=>"menu.ai_api_log","path"=>"/ai-api-log");
  135. $children[] = array("index" =>$index.'-6',"label" =>"Operation Log","cleaned_field_name"=>"menu.operation_log","path"=>"/operation-log");
  136. $children[] = array("index" =>$index.'-7',"label" =>"Prompt Configuration","cleaned_field_name"=>"menu.prompt_configuration","path"=>"/prompt-configuration");
  137. }
  138. $systemManagement["children"] = $children;
  139. if (!empty($children)){
  140. $menuList[] = $systemManagement;
  141. }
  142. }
  143. common::echo_json_encode(200, $menuList);
  144. exit();
  145. break;
  146. case 'main_filter':
  147. $data = common::getManagement();
  148. common::echo_json_encode(200, $data['dashboard_filter']);
  149. exit();
  150. break;
  151. case 'main_report':
  152. //分担查询
  153. include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  154. //这里只剩下r3,r4的查询
  155. $type = $_REQUEST["r_type"];
  156. $sqlWhere = ' and ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
  157. $sqlWhere = " " . $sqlWhere;
  158. $sqlWhere .= common::getDashboardTransportationSqlWhere();
  159. $sqlWhere .= common::getDashboardContactIDSqlWhere();
  160. $sqlWhere = common::check_input($sqlWhere);
  161. // $list = common::excuteListSql("select * from public.online_order_status_date_kln_pending('$type'::text, '$sqlWhere'::text) "
  162. // . "r (c bigint, e integer, b integer, d text)");
  163. $sql = "select * from public.online_order_status_date_kln_pending('$type'::text, '$sqlWhere'::text) "
  164. . "r (c bigint, e integer, b integer, d text)";
  165. $list = $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
  166. $key = "[";
  167. $value = "[";
  168. $totalValue = 0;
  169. foreach ($list as $vv) {
  170. if ($key != "[") {
  171. $key .= ",";
  172. $value .= ",";
  173. }
  174. if ($type == "r2" || $type == "r3" || $type == "r4") {
  175. $key .= '"' . $vv["d"] . '"';
  176. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  177. $totalValue = $totalValue + $vv["c"];
  178. } else {
  179. if ($vv["e"] == -1) {
  180. $key .= '"Over 80 Days"';
  181. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  182. } else {
  183. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  184. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  185. }
  186. $totalValue = $totalValue + $vv["c"];
  187. }
  188. }
  189. $key .= "]";
  190. $value .= "]";
  191. //处理返回原表数据格式 r1 r3 r4的数据返回
  192. $data = common::mian_repot_do($value,$type,$totalValue);
  193. common::echo_json_encode(200, $data);
  194. exit();
  195. break;
  196. case 'main_report_etd':
  197. //分担查询
  198. include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  199. //这里只有r1查询
  200. $type = "r1";
  201. $container_type = "";
  202. $date_type = strtolower($_REQUEST["date_type"]);
  203. if (empty($_REQUEST["date_start"])) {
  204. $bdate = "null";
  205. } else {
  206. $bdate = $_REQUEST["date_start"];
  207. $bdate = "'$bdate'";
  208. }
  209. if (empty($_REQUEST["date_end"])) {
  210. $edate = "null";
  211. } else {
  212. $edate = $_REQUEST["date_end"];
  213. $edate = "'$edate'";
  214. }
  215. $sqlWhere = ' and ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
  216. $sqlWhere = " " . $sqlWhere;
  217. $sqlWhere = $sqlWhere . common::getDashboardTransportationSqlWhere();
  218. $sqlWhere .= common::getDashboardContactIDSqlWhere();
  219. $sqlWhere = common::check_input($sqlWhere);
  220. // $list = common::excuteListSql("select * from public.online_order_status_date_kln_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
  221. // . "r (c bigint, e integer, b integer, d text)");
  222. $sql = "select * from public.online_order_status_date_kln_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text,'$date_type'::text) "
  223. . "r (c bigint, e integer, b integer, d text)";
  224. $list = $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
  225. $key = "[";
  226. $value = "[";
  227. $totalValue = 0;
  228. foreach ($list as $vv) {
  229. if ($key != "[") {
  230. $key .= ",";
  231. $value .= ",";
  232. }
  233. if ($type == "r2" || $type == "r3" || $type == "r4") {
  234. $key .= '"' . $vv["d"] . '"';
  235. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  236. $totalValue = $totalValue + $vv["c"];
  237. } else {
  238. if ($vv["e"] == -1) {
  239. $key .= '"Over 80 Days"';
  240. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  241. } else {
  242. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  243. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  244. }
  245. $totalValue = $totalValue + $vv["c"];
  246. }
  247. }
  248. $key .= "]";
  249. $value .= "]";
  250. //处理返回原表数据格式 r1 r3 r4的数据返回
  251. $data = common::mian_repot_do($value,$type,$totalValue);
  252. common::echo_json_encode(200, $data);
  253. exit();
  254. break;
  255. case 'main_report_kpi':
  256. //分担查询
  257. include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  258. $type = $_REQUEST["r_type"];
  259. $sqlWhere = ' and ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
  260. $sqlWhere = " " . $sqlWhere;
  261. $sqlWhere = $sqlWhere . common::getDashboardTransportationSqlWhere();
  262. $sqlWhere .= common::getDashboardContactIDSqlWhere();
  263. $sqlWhere = common::check_input($sqlWhere);
  264. $date_type = strtolower($_REQUEST["date_type"]);
  265. if (isset($_REQUEST['date_start']) && !empty($_REQUEST['date_start']))
  266. $sqlWhere .= " and $date_type >= ''" . common::usDate2sqlDate($_REQUEST['date_start']) . " 00:00:00''";
  267. if (isset($_REQUEST['date_end']) && !empty($_REQUEST['date_end']))
  268. $sqlWhere .= " and $date_type <= ''" . common::usDate2sqlDate($_REQUEST['date_end']) . " 23:59:59''";
  269. // $list = common::excuteListSql("select * from public.online_order_status_date_kln_kpi('$type'::text,'$sqlWhere'::text) "
  270. // . "r (c bigint, d text)");
  271. $sql = "select * from public.online_order_status_date_kln_kpi('$type'::text,'$sqlWhere'::text) "
  272. . "r (c bigint, d text)";
  273. $list = $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
  274. $key = "[";
  275. $value = "[";
  276. $totalValue = 0;
  277. foreach ($list as $vv) {
  278. if ($key != "[") {
  279. $key .= ",";
  280. $value .= ",";
  281. }
  282. if ($type == "ata_r3" || $type == "atd_r4" ) {
  283. $key .= '"' . $vv["d"] .'"';
  284. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] .'"}';
  285. $totalValue = $totalValue + $vv["c"];
  286. }
  287. }
  288. $key .= "]";
  289. $value .= "]";
  290. //处理返回原表数据格式
  291. $ETDList = array();
  292. $value_arr = json_decode($value,true);
  293. foreach($value_arr as $arr){
  294. $color = common::getItemStyle($type,$arr['name']);
  295. if($arr['name'] == "0 Day"){
  296. $arr['name'] = "≤1 Day";
  297. }
  298. if($arr['name'] == "7 Days"){
  299. $arr['name'] = "≥7 Days";
  300. }
  301. $ETDList[] = array("value" =>intval($arr['value']),"name" =>$arr['name'],"itemStyle" =>array("color" =>$color));
  302. }
  303. // 排序依据的键数组(这里我们用一个数字数组来表示)
  304. $order = ["≤1 Day", "1-2 Days", "3-6 Days","≥7 Days"];
  305. $ETDList = utils::arrayOrderBykeys($order,$ETDList,"name");
  306. if($type == 'atd_r4'){
  307. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Departure","title2" =>"(ATD-ETD)","download_name" => "KPI Departure");
  308. }
  309. if($type == 'ata_r3'){
  310. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Arrival","title2" =>"(ATA-ETA)","download_name" => "KPI Arrival");
  311. }
  312. common::echo_json_encode(200, $data);
  313. exit();
  314. break;
  315. case 'main_report_container_bar':
  316. //新UI 20 40 45 3份数据同时查询,且是柱状图,所以与r3 r4查询分开
  317. $container_type ='';
  318. $ContainerCounSeries = array();
  319. $date_type = strtolower($_REQUEST["date_type"]);
  320. $type = $_REQUEST["r_type"];
  321. if (empty($_REQUEST["date_start"])) {
  322. $bdate = "null";
  323. } else {
  324. $bdate = $_REQUEST["date_start"];
  325. $bdate = "'$bdate'";
  326. }
  327. if (empty($_REQUEST["date_end"])) {
  328. $edate = "null";
  329. } else {
  330. $edate = $_REQUEST["date_end"];
  331. $edate = "'$edate'";
  332. }
  333. $list= array();
  334. common::set("tableName", "online_container");
  335. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  336. $sqlWhere = common::check_input($sqlWhere);
  337. $sqlWhere .= common::getDashboardContactIDSqlWhere("container_bar");
  338. $sqlWhere = " " . $sqlWhere;
  339. common::set("tableName", "");
  340. //这个20 40 45都查询出来。否则值查询都对应的size,其他的不查询
  341. $value_arr = common::excuteListSql("select * from public.online_order_status_date_kln_r1_r2('$type'::text, 'eta'::text, 'etd'::text, $bdate, $edate, '$sqlWhere'::text, '$container_type'::text, '$date_type'::text) "
  342. . "r (month_group text, _20_rc numeric, _40_rc numeric, _45_rc numeric)");
  343. $key_arr = array();
  344. $container_type_arr = array("20","40","45");
  345. foreach($container_type_arr as $_container_type){
  346. $data = array();
  347. //每一个size 的所有月份总计
  348. $total = 0;
  349. //每一个size 对应的最大值
  350. $max = 0;
  351. foreach($value_arr as $arr){
  352. $data[] = intval($arr['_'.$_container_type.'_rc']);
  353. $total = $total + intval($arr['_'.$_container_type.'_rc']);
  354. $max = $max < intval($arr['_'.$_container_type.'_rc']) ? intval($arr['_'.$_container_type.'_rc']) : $max;
  355. if ($_container_type == '20'){
  356. $key_arr[] = $arr['month_group'];
  357. }
  358. }
  359. $ContainerCounSeries[$_container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
  360. }
  361. //处理返回时数据格式
  362. $ContainerCounSeries_return = array();
  363. //横坐标栏位
  364. $ContainerCount_Title = $key_arr;
  365. //所查的所有模式计算总和
  366. $total = 0;
  367. //所有size下的最大值,方便标注计算最长的Y坐标
  368. $max_all = 0;
  369. foreach($ContainerCounSeries as $k =>$v){
  370. //这个type 是页面传过来的。这个固定r2
  371. $color = common::getItemStyle($type,$k);
  372. $total = $total + $v['total'];
  373. $ContainerCounSeries_return[] = array("name"=>strval($k),"type"=>"bar","emphasis" => array("focus" =>"none"),
  374. "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
  375. $max_all = $max_all + $v['max'];
  376. }
  377. //计算Y坐标的间隔
  378. $interval = utils::calculateTicks(0,$max_all,5);
  379. if($interval == 0){
  380. //处理返回默认值
  381. $interval = 2;
  382. }
  383. $returnData = array("ContainerCount_Title"=>"Total: $total","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
  384. "min" => 0,"Max" =>$interval*5,"interval" =>$interval,"download_name" => "Container Count");
  385. //demo
  386. // $json = '{"code":200,"data":{"ContainerCount_Title":"Total: 463518","ContainerCountList":["OCT,23","NOV,23","DEC,23","JAN,24","FEB,24","MAR,24","APR,24","MAY,24","JUN,24","JUL,24","AUG,24","SEP,24","OCT,24"],"ContainerCounSeries":[{"name":"20","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[4400,8600,8804,9271,8961,8793,8534,9476,9530,10277,10081,8997,5784],"itemStyle":{"color":"#FF7500"}},{"name":"40","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[13652,28021,30422,30136,26320,27035,23979,26494,28406,33318,32318,30962,16369],"itemStyle":{"color":"#FFAC66"}},{"name":"45","type":"bar","emphasis":{"focus":"none"},"stack":"\u603b\u8ba1","data":[189,337,415,437,439,321,250,320,324,603,328,415,200],"itemStyle":{"color":"#FFE3CC"}}],"min":0,"Max":45000,"interval":9000}}';
  387. // $returnData = json_decode($json,true);
  388. // echo json_encode($returnData);
  389. // exit();
  390. common::echo_json_encode(200, $returnData);
  391. exit();
  392. break;
  393. case 'main_report_co2e_bar':
  394. $returnData = common::getCo2eBar();
  395. common::echo_json_encode(200, $returnData);
  396. exit();
  397. break;
  398. case 'main_report_top10_bar':
  399. $returnData = common::getTopBarNew();
  400. common::echo_json_encode(200, $returnData);
  401. exit();
  402. break;
  403. case 'main_report_revenue':
  404. $returnData = common::getRevenue();
  405. common::echo_json_encode(200, $returnData);
  406. exit();
  407. break;
  408. case 'main_map':
  409. $uncode = $_POST["uncode"];
  410. $serial_no = $_POST["serial_no"];
  411. $unall = explode("|", $uncode);
  412. $sql = "";
  413. if (!empty($unall[0]) && $unall[0] != "''") {
  414. $sql .= "select lon as lng, lat as lat, uncode, 'Place of receipt: '||name1 as location_namewo, 'por' as type from vessel.vt_unlocode where "
  415. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  416. . "($unall[0])";
  417. }
  418. if (!empty($unall[1]) && $unall[1] != "''") {
  419. if (!empty($sql)) {
  420. $sql .= " union ";
  421. }
  422. $sql .= "select lon as lng, lat as lat, uncode, 'POL: '||name1 as location_namewo, 'pol' as type from vessel.vt_unlocode where "
  423. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  424. . "($unall[1])";
  425. }
  426. if (!empty($unall[2]) && $unall[2] != "''") {
  427. if (!empty($sql)) {
  428. $sql .= " union ";
  429. }
  430. $sql .= "select lon as lng, lat as lat, uncode, 'POD: '||name1 as location_namewo, 'pod' as type from vessel.vt_unlocode where "
  431. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  432. . "($unall[2])";
  433. }
  434. if (!empty($unall[3]) && $unall[3] != "''") {
  435. if (!empty($sql)) {
  436. $sql .= " union ";
  437. }
  438. $sql .= "select lon as lng, lat as lat, uncode, 'Place of delivery: '||name1 as location_namewo, 'poe' as type from vessel.vt_unlocode where "
  439. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  440. . "($unall[3])";
  441. }
  442. $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,
  443. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  444. from public.tk_general g, public.tk_commodity c left join public.tk_location tl on c.serial_no=tl.serial_no
  445. 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");
  446. foreach ($tkStatus as $vv) {
  447. $ll = explode(",", $vv["location"]);
  448. if ($vv["by_pickup"] == "t") {
  449. $pf = explode("\r\n", $vv["pickup_from_exp"]);
  450. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  451. $dt = explode("\r\n", $vv["consignee_exp"]);
  452. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  453. } else {
  454. $pf = explode("\r\n", $vv["consignee_exp"]);
  455. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  456. $dt = explode("\r\n", $vv["deliveryto_exp"]);
  457. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  458. }
  459. if ($vv["type"] == "26" && !empty($ll[1])) {
  460. if (!empty($sql)) {
  461. $sql .= " union ";
  462. }
  463. $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";
  464. } elseif ($vv["type"] == "25" && !empty($ll[1])) {
  465. if (!empty($sql)) {
  466. $sql .= " union ";
  467. }
  468. $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";
  469. }
  470. }
  471. if (!empty($sql)) {
  472. $gps = common::excuteListSql($sql . "");
  473. }
  474. if (!empty($serial_no)) {
  475. $all = explode(",", $serial_no);
  476. foreach ($all as $a) {
  477. $rs = common::excuteOneSql("select public.get_vessel_position('$a'::text)");
  478. if (!empty($rs)) {
  479. $rss = explode("|", $rs);
  480. $lng_lat = explode(",", $rss[1]);
  481. $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" => "");
  482. }
  483. }
  484. }
  485. $data = array("gps" => $gps);
  486. common::echo_json_encode("200", $data);
  487. exit();
  488. break;
  489. case 'main_map_new':
  490. include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  491. //修改添加port_of_transshipment 和port_of_transshipment_name的坐标获取(有为空的可能)
  492. $serial_no = $_REQUEST["serial_no"];
  493. $_schemas = $_REQUEST['_schemas'];
  494. if(empty($_schemas)){
  495. $_schemas ="public";
  496. }
  497. //$serial_no = "F41E6016-1A97-4C93-8198-53D8B3B26220";
  498. $transport_mode = common::excuteOneSql("SELECT transport_mode FROM public.kln_ocean ko
  499. WHERE ko.serial_no = '$serial_no' and order_from = '$_schemas'");
  500. if($transport_mode == "sea"){
  501. $sql = "with ss as (select '$serial_no' as sn)
  502. , aa as (
  503. 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,dd.*
  504. from public.kln_ocean oo
  505. left join LATERAL (
  506. select (select uncode from ports where code = o.port_of_transshipment) as port_of_transshipment_un,
  507. port_of_transshipment_name
  508. from $_schemas.ocean o where o.serial_no=oo.serial_no order by id desc limit 1
  509. ) dd on true
  510. where serial_no=(select sn from ss) limit 1
  511. )
  512. , rr as (
  513. select lon as lng, lat as lat, 'Origin' as label, port_of_loading as infor, 1 as sort, null::timestamp without time zone as stime, 'pol'::text as ptype
  514. from vessel.vt_unlocode, aa where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode=fport_of_loading_un
  515. union all
  516. select lon as lng, lat as lat, 'Destination' as label, port_of_discharge as infor, 2 as sort, null::timestamp without time zone as stime, 'pod'::text as ptype
  517. from vessel.vt_unlocode, aa where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode=mport_of_discharge_un
  518. union all
  519. select lon as lng, lat as lat, 'Transfer' as label, port_of_transshipment_name as infor, 3 as sort, null::timestamp without time zone as stime, 'poe'::text as ptype
  520. from vessel.vt_unlocode, aa where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode=port_of_transshipment_un
  521. )
  522. select * from rr order by sort, stime";
  523. } elseif ($transport_mode == "air"){
  524. $sql = "with ss as (select '$serial_no' as sn)
  525. , aa as (
  526. 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
  527. from public.kln_ocean oo
  528. where serial_no=(select sn from ss) limit 1
  529. )
  530. , rr as (
  531. select lon as lng, lat as lat, 'Origin' as label, port_of_loading as infor, 1 as sort, null::timestamp without time zone as stime, 'pol'::text as ptype
  532. from vessel.vt_unlocode, aa where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode=fport_of_loading_un
  533. union all
  534. select lon as lng, lat as lat, 'Destination' as label, port_of_discharge as infor, 2 as sort, null::timestamp without time zone as stime, 'pod'::text as ptype
  535. from vessel.vt_unlocode, aa where (lat<=90 and lat>=-90) and (lon<=180 and lon>=-180) and lon is not null and lat is not null and uncode=mport_of_discharge_un
  536. )
  537. select * from rr order by sort, stime";
  538. }
  539. $rss = common::excuteListSql($sql);
  540. //$rss = $mapdb->GetAll($sql);
  541. //先固定死
  542. // $json = '[{"lng":"100.78594000","lat":"13.68521000","label":"Origin","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"},
  543. // {"lng":"100.88333333","lat":"13.08333333","label":"Destination","infor":"LAEM CHABANG PORT,THAILAND","sort":"1","stime":null,"ptype":"pol"},
  544. // {"lng":"-122.28640000","lat":"37.79784000","label":"Transfer","infor":"OAKLAND, CA, USA","sort":"2","stime":null,"ptype":"pod"}]';
  545. //$rss = json_decode($json,true);
  546. ///global $mapdb;
  547. //查询线(包含所有的线) 空运不查询航线
  548. if ($transport_mode == "air"){
  549. $Line =array();
  550. }else{
  551. error_log("select * from get_track_data('$serial_no',true)");
  552. $map_sql = "select * from get_track_data('$serial_no',true)";
  553. $Line = $mapdb->GetAll($map_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $map_sql), 0));
  554. }
  555. $solidLine = array();
  556. $dottedLine = array();
  557. $rangePoint = array();
  558. foreach($Line as $line){
  559. if($line['tp'] == "1"){
  560. $solidLine[] = $line;
  561. }elseif($line['tp'] == "0"){
  562. $dottedLine[] = $line;
  563. }else{
  564. $rangePoint[] = $line;
  565. }
  566. }
  567. //如果没有虚线,这这个范围点也是异常的,不需要显示
  568. if(empty($dottedLine)){
  569. $rangePoint = array();
  570. }
  571. $data = array("point"=>$rss,"solidLine"=>$solidLine,"dottedLine"=>$dottedLine,"rangePoint"=>$rangePoint);
  572. common::echo_json_encode(200, $data);
  573. //common::echo_json_encode(200, $rss);
  574. exit();
  575. break;
  576. case 'main_welcome':
  577. //分担查询
  578. include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  579. $cp = common::check_input($_POST ['cp']); //current_page
  580. $ps = common::check_input($_POST ['ps']); //ps
  581. if (empty($ps))
  582. $ps = 10;
  583. $sqlWhere = ' where ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
  584. $sqlWhere .= common::getDashboardTransportationSqlWhere();
  585. $sqlWhere .= common::getDashboardContactIDSqlWhere();
  586. // test dome
  587. // $_POST['is_default'] = "no";
  588. // $_POST['date_start'] =null;
  589. // $_POST['date_end'] = null;
  590. //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天 这个默认条件已经废除,前端不会这样传参数
  591. if (isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes" && false){
  592. $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
  593. } else {
  594. $date_type = strtolower(common::check_input($_POST ['date_type']));
  595. if (isset($_POST['date_start']) && !empty($_POST['date_start']))
  596. $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_POST['date_start']) . " 00:00:00'";
  597. if (isset($_POST['date_end']) && !empty($_POST['date_end']))
  598. $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_POST['date_end']) . " 23:59:59'";
  599. }
  600. if (isset($_POST['customer']) && !empty($_POST['customer'])){
  601. $sqlWhere .= " and (shipper ilike '%".common::check_input($_POST['customer'])."%' or shipper_id ilike '%".common::check_input($_POST['customer'])."%'
  602. or consignee ilike '%".common::check_input($_POST['customer'])."%' or consignee_id ilike '%".common::check_input($_POST['customer'])."%')";
  603. }
  604. $rc = $_POST ['rc'];
  605. if ($rc == - 1) {
  606. $sql = "SELECT count(1) from public.kln_ocean" . $sqlWhere;
  607. //$rc = common::excuteOneSql($sql);
  608. $rc = $mapdb->GetOne($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
  609. }
  610. $tp = ceil($rc / $ps);
  611. if ($rc > 0) {
  612. $sql = "SELECT order_from as _schemas,serial_no, consignee, shipper, h_bol,final_desination_uncode, transport_mode,transport_mode_extend,
  613. to_char(etd, 'MM/DD/YYYY'::text) as etd,
  614. to_char(eta, 'MM/DD/YYYY'::text) AS eta,
  615. fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un, booking_no,
  616. f_vessel,f_voyage,origin,
  617. CASE
  618. WHEN ((m_iffbcf is not null or m_iffbcf is null) and m_iffcpu is null and m_iffrec is null and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Created'::text
  619. WHEN ((m_iffcpu is not null or m_iffrec is not null) and m_iffdep is null and m_iffarr is null and m_iffdel is null) THEN 'Cargo Received'::text
  620. WHEN (m_iffdep is not null and m_iffarr is null and m_iffdel is null) THEN 'Departed'::text
  621. WHEN (m_iffarr is not null and m_iffdel is null) THEN 'Arrived'::text
  622. WHEN (m_iffdel is not null) THEN 'Completed'::text
  623. ELSE 'Created'::text
  624. END AS new_status
  625. FROM public.kln_ocean $sqlWhere";
  626. //$sqlWhere and last_status_315_update_time is not null";
  627. $sql .= " ORDER BY eta desc,id DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  628. //$sql .= " ORDER BY last_status_315_update_time DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  629. //$rss = common::excuteListSql($sql);
  630. $rss = $mapdb->GetAll($sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $sql), 0));
  631. //RecentStatusList
  632. $RecentStatusList = array();
  633. foreach ($rss as $key => $value) {
  634. $serial_no = $value["serial_no"];
  635. $_schemas_bk = $value['_schemas'];
  636. $_schemas = $value['_schemas'];
  637. if($_schemas == "public"){
  638. $_schemas = "ocean";
  639. }
  640. //单独取查询milestone信息
  641. if ($value['transport_mode'] == "sea"){
  642. $milestone_sql = "select a.act_date,a.act_time,sn.description,a.timezone,
  643. a.code as dd_code
  644. from public.ocean_milestone a
  645. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'sea'
  646. where a.serial_no='$serial_no'
  647. and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFDEL', ','))
  648. and a.act_date is not null
  649. order by sn.sno desc limit 1";
  650. } elseif ($value['transport_mode'] == "air"){
  651. //air milestone 的Departed实际描述要替换: IFFDEP =》 IFFONB
  652. $milestone_sql = "select a.act_date,a.act_time,sn.description,a.timezone,
  653. a.code as dd_code
  654. from $_schemas_bk.air_milestone a
  655. inner join public.customer_service_milestone_sno sn on sn.code=a.code and sn.type = 'air'
  656. where a.serial_no='$serial_no'
  657. and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFONB,IFFARR,IFFDEL', ','))
  658. and a.act_date is not null
  659. order by sn.sno desc limit 1";
  660. }
  661. $milestone = common::excuteObjectSql($milestone_sql);
  662. $value["act_date"] = $milestone["act_date"];
  663. $value["act_time"] = $milestone["act_time"];
  664. $value["description"] = $milestone["description"];
  665. $value["timezone"] = $milestone["timezone"];
  666. $value["dd_code"] = $milestone["dd_code"];
  667. $timezone = "";
  668. //按照最新execl Timezone From 来自于origin
  669. if($value['dd_code'] == "IFFBCF" || $value['dd_code'] == "IFFCPU"){
  670. $sql = "SELECT (select time_zone from public.city_timezone where uncode = LEFT(c.country, 2) || COALESCE(c.city_code,'')) as timezone
  671. FROM $_schemas.contacts c WHERE c.contact_id = '".$value['origin']."'";
  672. $timezone = common::excuteOneSql($sql);
  673. }
  674. //按照最新execl Timezone From 来自于final_destination
  675. if($value['dd_code'] == "IFFDEL"){
  676. $sql = "select time_zone from public.city_timezone where uncode = '".$value['final_desination_uncode']."'";
  677. $timezone = common::excuteOneSql($sql);
  678. }
  679. if($value['dd_code'] == "IFFREC" || $value['dd_code'] == "IFFDEP" || $value['dd_code'] == "IFFARR"){
  680. $EDI315Time = array();
  681. if ($value['transport_mode'] == "sea"){
  682. //Timezone From 来自于EDI315
  683. $EDI315Time = common::getEDI315Time($serial_no,$value['_schemas']);
  684. }
  685. if($value['dd_code'] == "IFFREC" || $value['dd_code'] == "IFFDEP"){
  686. //先以EDI315 时区为准,如果没有这代表数据是手动输入,或者没有同步情况
  687. $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  688. if(empty($timezone)){
  689. if($value['dd_code'] == "IFFREC"){
  690. $sql = "select time_zone from public.city_timezone where uncode = '".$value['place_of_receipt_un']."'";
  691. }else{
  692. $sql = "select time_zone from public.city_timezone where uncode = '".$value['fport_of_loading_un']."'";
  693. }
  694. $timezone = common::excuteOneSql($sql);
  695. }
  696. }
  697. if($value['dd_code'] == "IFFARR"){
  698. $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  699. if(empty($timezone)){
  700. $sql = "select time_zone from public.city_timezone where uncode = '".$value['mport_of_discharge_un']."'";
  701. $timezone = common::excuteOneSql($sql);
  702. }
  703. }
  704. }
  705. $Arrived = $value['description'];
  706. $startStation=$value['fport_of_loading_un'];
  707. $endStation=$value['mport_of_discharge_un'];
  708. if ($value['transport_mode'] == "sea"){
  709. $startStation=$value['place_of_receipt_un'];
  710. $endStation=$value['place_of_delivery_un'];
  711. }
  712. if ($value['transport_mode'] == "air"){
  713. $startStation=!empty($ocean['place_of_receipt_un'])? $ocean['place_of_receipt_un'] : $ocean['fport_of_loading_un'];
  714. $endStation=!empty($ocean['place_of_delivery_un']) ? $ocean['place_of_delivery_un'] : $ocean['mport_of_discharge_un'];
  715. }
  716. $RecentStatusList[] = array("Title"=>$value['h_bol'],
  717. "name"=>utils::outDisplayForMerge($value['f_vessel'],$value['f_voyage']),
  718. "bookingNumber" =>$value['booking_no'],
  719. "IsSubscribe" =>false,
  720. "shipperName"=>$value['shipper'],
  721. "consigneeName" =>$value['consignee'],
  722. "startStation"=>$startStation,
  723. "endStation"=>$endStation,
  724. "ETD"=>$value['etd'],
  725. "ETA"=>$value['eta'],
  726. "type"=>$value['new_status'],
  727. "Arrived"=>$Arrived,
  728. "Time"=>$value["act_date"],
  729. "act_time" =>$value["act_time"],
  730. "timezone"=>$timezone,
  731. "_schemas"=>$value["_schemas"],
  732. "transport_mode"=>$value["transport_mode_extend"],
  733. 'is_subscribe' =>common::checkedSubscribe($value['serial_no']),
  734. "a" =>common::deCode($value['serial_no'], 'E'));
  735. }
  736. $data = common::getManagement();
  737. $arrTmp = array('searchData' => $RecentStatusList,
  738. 'Management' => $data['Management'],
  739. 'dashboard_filter' => $data['dashboard_filter'],
  740. 'is_customer' =>_isCustomerLogin(),
  741. 'rc' => $rc,
  742. 'ps' => $ps,
  743. 'cp' => $cp,
  744. 'tp' => $tp);
  745. } else {
  746. $data = common::getManagement();
  747. $arrTmp = array('searchData' => array(),
  748. 'Management' => $data['Management'],
  749. 'dashboard_filter' => $data['dashboard_filter']);
  750. }
  751. common::echo_json_encode(200,$arrTmp);
  752. exit();
  753. break;
  754. case 'save_layout':
  755. $management = json_encode($_POST["management"]);
  756. $dashboard_filter = json_encode($_POST["dashboardObj"]);
  757. $_param = "";
  758. if(!empty($_POST["management"])){
  759. $_param .= " management = '$management' ";
  760. }
  761. if(isset($_POST["dashboardObj"]) && !empty($dashboard_filter)){
  762. $_param .= ",dashboard_filter = '$dashboard_filter' ";
  763. }
  764. if(!empty($_param)){
  765. common::excuteUpdateSql("update public.ra_online_user set $_param where lower(user_login) = '" . strtolower(_getLoginName()) . "'");
  766. }
  767. $returnData = array("msg" => "success");
  768. common::echo_json_encode(200, $returnData);
  769. exit();
  770. break;
  771. case 'password':
  772. tools::getInstance()->updatePassword();
  773. break;
  774. case 'tools':
  775. tools::getInstance()->markSystem();
  776. break;
  777. case 'robot':
  778. robot::getInstance()->robot_prompt_configuration();
  779. break;
  780. case 'robot_chat':
  781. robot::getInstance()->ai_chat();
  782. break;
  783. case 'robot_chat_log':
  784. robot::getInstance()->robot_chat_log();
  785. break;
  786. case 'robot_api_log':
  787. robot::getInstance()->robot_api_log();
  788. break;
  789. case 'system_setting':
  790. tools::getInstance()->user_system_setting();
  791. break;
  792. case 'monitoring_setting':
  793. tools::getInstance()->user_monitoring_setting();
  794. break;
  795. case 'notifications_rules':
  796. tools::getInstance()->notifications_rules();
  797. break;
  798. case 'destination_delivery_load':
  799. destination_delivery::getInstance()->destination_delivery_load();
  800. break;
  801. case 'destination_delivery_config':
  802. destination_delivery::getInstance()->destination_delivery_config();
  803. break;
  804. case 'destination_delivery_booking':
  805. destination_delivery::getInstance()->destination_delivery_booking();
  806. break;
  807. case 'report_config':
  808. report::getInstance()->report_config();
  809. break;
  810. case 'shipment_status_report':
  811. report::getInstance()->shipment_status_report();
  812. break;
  813. case 'user_guide':
  814. $rootPath = realpath(dirname(__FILE__)) . DS;
  815. //common::download_file($rootPath."images\ACE-M1_ISF_ACI_User_Guide\ACE-M1_ISF_ACI_User_Guide.pdf", "ACE-M1_ISF_ACI_User_Guide_V2.0.pdf");
  816. // PDF文件在服务器上的位置
  817. $filename = $rootPath."userFile". DS."KLN_Online_User_Guide_24.11.26.pdf";
  818. $display_name = "KLN_Online_User_Guide_24_11_26.pdf";
  819. // Header content type
  820. header("Content-type: application/pdf");
  821. header("Content-Length: " . filesize($filename));
  822. header("Content-Disposition:attachment;filename=\"" . $display_name . "\"");
  823. // 将文件发送到浏览器。
  824. readfile($filename);
  825. break;
  826. case 'feature_update':
  827. $id = $_REQUEST["id"];
  828. $rootPath = realpath(dirname(__FILE__)) . DS;
  829. //common::download_file($rootPath."images\ACE-M1_ISF_ACI_User_Guide\ACE-M1_ISF_ACI_User_Guide.pdf", "ACE-M1_ISF_ACI_User_Guide_V2.0.pdf");
  830. // PDF文件在服务器上的位置
  831. $filename = $rootPath."upload". DS."feature_update_".$id.".pdf";
  832. $display_name = "feature_update.pdf";
  833. // Header content type
  834. header("Content-type: application/pdf");
  835. header("Content-Length: " . filesize($filename));
  836. header("Content-Disposition:inline;filename=\"" . $display_name . "\"");
  837. // 将文件发送到浏览器。
  838. readfile($filename);
  839. break;
  840. case 'kam_customer_auto_login':
  841. $name = common::check_input($_POST['uname']);
  842. $_POST['psw'] = common::excuteOneSql("select ra_password from public.ra_online_user where user_login = '".$name."'");
  843. login::getInstance()->do_login_auto();
  844. break;
  845. case 'multilingual':
  846. multilingual::getInstance()->multilingual_config();
  847. break;
  848. default:
  849. $data = array(
  850. 'msg' => 'Page not found',
  851. );
  852. common::echo_json_encode(500, $data);
  853. }
  854. $db->Close();
  855. $db = null;
  856. if ($max_ec > 0)
  857. ini_set('max_execution_time', $max_ec); //recover old value
  858. if (!empty($memory_limit))
  859. ini_set('memory_limit', $memory_limit);
  860. ?>