main_new_version.php 47 KB

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