main_new_version.php 47 KB

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