main_new_version.php 47 KB

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