main_new_version.php 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  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'] = common::excuteOneSql("select ra_password from ra_online_user where user_login = 'ra.admin'");
  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. //拼接的date_start数据
  347. //todo 根据权限信息获取一共air查询的总表的整合,因为air信息是分别存在public 和sfs 两个模式中的
  348. // $air_view = "";
  349. // $air_sql = common::getAirSql($air_view,$type,$sql_where);
  350. // $Airlist = common::excuteListSql("select count as c, distext as d from ($air_sql) aa ");
  351. $Airlist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere_air'::text) "
  352. . "r (c bigint, d text)");
  353. //拼接数据
  354. if(empty($list)){
  355. $list = $Airlist;
  356. }else{
  357. foreach($list as $lk =>$lv){
  358. $list[$lk]['c'] = $list[$lk]['c'] + $Airlist[$lk]['c'];
  359. }
  360. }
  361. }
  362. if($mode == 'Road'){
  363. $sqlWhere_road = $sqlWhere ." and 1<>1 ";
  364. //拼接的date_start数据 road 没有数据 可以置为1<>1
  365. //todo 根据权限信息获取一共air查询的总表的整合,因为air信息是分别存在sspublic 和sfs 两个模式中的
  366. // $air_view = "";
  367. // $air_sql = common::getAirSql($air_view,$type,$sql_where);
  368. // $Airlist = common::excuteListSql("select count as c, distext as d from ($air_sql) aa ");
  369. $roadlist = common::excuteListSql("select * from public.online_order_status_date_kpi_new('$type'::text,'$sqlWhere_road'::text) "
  370. . "r (c bigint, d text)");
  371. //拼接数据
  372. if(empty($list)){
  373. $list = $roadlist;
  374. }else{
  375. foreach($list as $lk =>$lv){
  376. $list[$lk]['c'] = $list[$lk]['c'] + $roadlist[$lk]['c'];
  377. }
  378. }
  379. }
  380. }
  381. $key = "[";
  382. $value = "[";
  383. $totalValue = 0;
  384. foreach ($list as $vv) {
  385. if ($key != "[") {
  386. $key .= ",";
  387. $value .= ",";
  388. }
  389. if ($type == "ata_r3" || $type == "atd_r4" ) {
  390. $key .= '"' . $vv["d"] .'"';
  391. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] .'"}';
  392. $totalValue = $totalValue + $vv["c"];
  393. }
  394. }
  395. $key .= "]";
  396. $value .= "]";
  397. //处理返回原表数据格式
  398. $ETDList = array();
  399. $value_arr = json_decode($value,true);
  400. foreach($value_arr as $arr){
  401. $color = common::getItemStyle($type,$arr['name']);
  402. if($arr['name'] == "0 Day"){
  403. $arr['name'] = "≤1 Day";
  404. }
  405. if($arr['name'] == "7 Days"){
  406. $arr['name'] = "≥7 Days";
  407. }
  408. $ETDList[] = array("value" =>intval($arr['value']),"name" =>$arr['name'],"itemStyle" =>array("color" =>$color));
  409. }
  410. if($type == 'atd_r4'){
  411. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Departure","title2" =>"(ATD-ETD)","download_name" => "KPI Departure");
  412. }
  413. if($type == 'ata_r3'){
  414. $data = array("ETDList" =>$ETDList,"ETD_Radius"=>array('30%','50%'),"title1" =>"Arrival","title2" =>"(ATA-ETA)","download_name" => "KPI Arrival");
  415. }
  416. common::echo_json_encode(200, $data);
  417. exit();
  418. break;
  419. case 'main_report_container_bar':
  420. //新UI 要ALL 20 40 45 四份数据同时查询,且是柱状图,所以与r3 r4查询分开
  421. $container_type_arr = array("20","40","45");
  422. $container_type_param = "all";
  423. $ContainerCounSeries = array();
  424. foreach($container_type_arr as $_container_type){
  425. $container_type = $_container_type;
  426. $date_type = strtolower($_REQUEST["date_type"]);
  427. $type = $_REQUEST["r_type"];
  428. if (empty($_REQUEST["date_start"])) {
  429. $bdate = "null";
  430. } else {
  431. $bdate = $_REQUEST["date_start"];
  432. $bdate = "'$bdate'";
  433. }
  434. if (empty($_REQUEST["date_end"])) {
  435. $edate = "null";
  436. } else {
  437. $edate = $_REQUEST["date_end"];
  438. $edate = "'$edate'";
  439. }
  440. $list= array();
  441. //all 查询所有
  442. $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  443. $sqlWhere = common::check_input($sqlWhere);
  444. $sqlWhere = " " . $sqlWhere;
  445. //如果页面查询的是ALL 这个20 40 45都查询出来。否则值查询都对应的size,其他的不查询
  446. if(strtolower($container_type_param) == "all"){
  447. $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) "
  448. . "r (c bigint, e integer, b integer, d text)");
  449. }else{
  450. if($container_type_param == $_container_type){
  451. $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) "
  452. . "r (c bigint, e integer, b integer, d text)");
  453. }
  454. }
  455. $key = "[";
  456. $value = "[";
  457. $totalValue = 0;
  458. foreach ($list as $vv) {
  459. if ($key != "[") {
  460. $key .= ",";
  461. $value .= ",";
  462. }
  463. if ($type == "r2" || $type == "r3" || $type == "r3_1" || $type == "r4" || $type == "r4_1") {
  464. $key .= '"' . $vv["d"] . '"';
  465. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["d"] . '" }';
  466. $totalValue = $totalValue + $vv["c"];
  467. } else {
  468. if ($vv["e"] == -1) {
  469. $key .= '"Over 80 Days"';
  470. $value .= '{"value":"' . $vv["c"] . '","name":"Over 80 Days"}';
  471. } else {
  472. $key .= '"' . $vv["b"] . '-' . $vv["e"] . ' Days"';
  473. $value .= '{"value":"' . $vv["c"] . '","name":"' . $vv["b"] . '-' . $vv["e"] . ' Days"}';
  474. }
  475. $totalValue = $totalValue + $vv["c"];
  476. }
  477. }
  478. $key .= "]";
  479. $value .= "]";
  480. $key_arr = json_decode($key,true);
  481. $value_arr = json_decode($value,true);
  482. $data = array();
  483. //每一个size 的所有月份总计
  484. $total = 0;
  485. //每一个size 对应的最大值
  486. $max = 0;
  487. foreach($value_arr as $arr){
  488. $data[] = intval($arr['value']);
  489. $total = $total + intval($arr['value']);
  490. $max = $max < intval($arr['value']) ? intval($arr['value']) : $max;
  491. }
  492. $ContainerCounSeries[$container_type] = array("data"=>$data,"total"=>$total,"max"=>$max);
  493. }
  494. //处理返回时数据格式
  495. $ContainerCounSeries_return = array();
  496. //横坐标栏位
  497. $ContainerCount_Title = $key_arr;
  498. //所查的所有模式计算总和
  499. $total = 0;
  500. //所有size下的最大值,方便标注计算最长的Y坐标
  501. $max_all = 0;
  502. foreach($ContainerCounSeries as $k =>$v){
  503. //这个type 是页面传过来的。这个固定r2
  504. $color = common::getItemStyle($type,$k);
  505. $total = $total + $v['total'];
  506. $ContainerCounSeries_return[] = array("name"=>strval($k),"type"=>"bar","emphasis" => array("focus" =>"none"),
  507. "stack" =>"总计","data" =>$v['data'],"itemStyle" =>array("color" =>$color));
  508. $max_all = $max_all + $v['max'];
  509. }
  510. //计算Y坐标的间隔
  511. $interval = utils::calculateTicks(0,$max_all,5);
  512. if($interval == 0){
  513. //处理返回默认值
  514. $interval = 2;
  515. }
  516. $returnData = array("ContainerCount_Title"=>"Total: $total","ContainerCountList" =>$ContainerCount_Title,"ContainerCounSeries" =>$ContainerCounSeries_return,
  517. "min" => 0,"Max" =>$interval*5,"interval" =>$interval,"download_name" => "Container Count");
  518. //demo
  519. // $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}}';
  520. // $returnData = json_decode($json,true);
  521. // echo json_encode($returnData);
  522. // exit();
  523. common::echo_json_encode(200, $returnData);
  524. exit();
  525. break;
  526. case 'main_report_co2e_bar':
  527. $returnData = common::getCo2eBar();
  528. common::echo_json_encode(200, $returnData);
  529. exit();
  530. break;
  531. case 'main_report_top10_bar':
  532. $returnData = common::getTopBar();
  533. common::echo_json_encode(200, $returnData);
  534. exit();
  535. break;
  536. case 'main_report_revenue':
  537. $returnData = common::getRevenue();
  538. common::echo_json_encode(200, $returnData);
  539. exit();
  540. break;
  541. case 'main_map':
  542. $uncode = $_POST["uncode"];
  543. $serial_no = $_POST["serial_no"];
  544. $unall = explode("|", $uncode);
  545. $sql = "";
  546. if (!empty($unall[0]) && $unall[0] != "''") {
  547. $sql .= "select lon as lng, lat as lat, uncode, 'Place of receipt: '||name1 as location_namewo, 'por' as type from vessel.vt_unlocode where "
  548. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  549. . "($unall[0])";
  550. }
  551. if (!empty($unall[1]) && $unall[1] != "''") {
  552. if (!empty($sql)) {
  553. $sql .= " union ";
  554. }
  555. $sql .= "select lon as lng, lat as lat, uncode, 'POL: '||name1 as location_namewo, 'pol' as type from vessel.vt_unlocode where "
  556. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  557. . "($unall[1])";
  558. }
  559. if (!empty($unall[2]) && $unall[2] != "''") {
  560. if (!empty($sql)) {
  561. $sql .= " union ";
  562. }
  563. $sql .= "select lon as lng, lat as lat, uncode, 'POD: '||name1 as location_namewo, 'pod' as type from vessel.vt_unlocode where "
  564. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  565. . "($unall[2])";
  566. }
  567. if (!empty($unall[3]) && $unall[3] != "''") {
  568. if (!empty($sql)) {
  569. $sql .= " union ";
  570. }
  571. $sql .= "select lon as lng, lat as lat, uncode, 'Place of delivery: '||name1 as location_namewo, 'poe' as type from vessel.vt_unlocode where "
  572. . "lon<>0 and lat<>0 and lon is not null and lat is not null and uncode in "
  573. . "($unall[3])";
  574. }
  575. $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,
  576. to_char(tl.upload_time, 'MM/DD/YYYY HH24:MI:SS') as utime
  577. from public.tk_general g, public.tk_commodity c left join public.tk_location tl on c.serial_no=tl.serial_no
  578. 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");
  579. foreach ($tkStatus as $vv) {
  580. $ll = explode(",", $vv["location"]);
  581. if ($vv["by_pickup"] == "t") {
  582. $pf = explode("\r\n", $vv["pickup_from_exp"]);
  583. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  584. $dt = explode("\r\n", $vv["consignee_exp"]);
  585. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  586. } else {
  587. $pf = explode("\r\n", $vv["consignee_exp"]);
  588. $pf = common::check_input($pf[0]) . "(" . $vv["ctnr"] . ")";
  589. $dt = explode("\r\n", $vv["deliveryto_exp"]);
  590. $dt = common::check_input($dt[0]) . "(" . $vv["ctnr"] . ")";
  591. }
  592. if ($vv["type"] == "26" && !empty($ll[1])) {
  593. if (!empty($sql)) {
  594. $sql .= " union ";
  595. }
  596. $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";
  597. } elseif ($vv["type"] == "25" && !empty($ll[1])) {
  598. if (!empty($sql)) {
  599. $sql .= " union ";
  600. }
  601. $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";
  602. }
  603. }
  604. if (!empty($sql)) {
  605. $gps = common::excuteListSql($sql . "");
  606. }
  607. if (!empty($serial_no)) {
  608. $all = explode(",", $serial_no);
  609. foreach ($all as $a) {
  610. $rs = common::excuteOneSql("select public.get_vessel_position('$a'::text)");
  611. if (!empty($rs)) {
  612. $rss = explode("|", $rs);
  613. $lng_lat = explode(",", $rss[1]);
  614. $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" => "");
  615. }
  616. }
  617. }
  618. $data = array("gps" => $gps);
  619. common::echo_json_encode("200", $data);
  620. exit();
  621. break;
  622. case 'main_map_new':
  623. //include ONLINE_ROOT . 'libs' . DS . 'map_config.ini.php';
  624. //修改添加port_of_transshipment 和port_of_transshipment_name的坐标获取(有为空的可能)
  625. $serial_no = $_REQUEST["serial_no"];
  626. //$serial_no = "F41E6016-1A97-4C93-8198-53D8B3B26220";
  627. $sql = "with ss as (select '$serial_no' as sn)
  628. , aa as (
  629. 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.*
  630. from public.online_ocean oo
  631. left join LATERAL (
  632. select (select uncode from ports where code = o.port_of_transshipment) as port_of_transshipment_un,
  633. port_of_transshipment_name
  634. from ocean o where o.serial_no=oo.serial_no order by id desc limit 1
  635. ) dd on true
  636. where serial_no=(select sn from ss) limit 1
  637. )
  638. , rr as (
  639. 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
  640. 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
  641. union all
  642. 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
  643. 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
  644. union all
  645. 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
  646. 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
  647. )
  648. select * from rr order by sort, stime";
  649. $rss = common::excuteListSql($sql);
  650. //$rss = $mapdb->GetAll($sql);
  651. //先固定死
  652. // $json = '[{"lng":"100.78594000","lat":"13.68521000","label":"Origin","infor":"LAT KRABANG, THAILAND","sort":"0","stime":null,"ptype":"por"},
  653. // {"lng":"100.88333333","lat":"13.08333333","label":"Destination","infor":"LAEM CHABANG PORT,THAILAND","sort":"1","stime":null,"ptype":"pol"},
  654. // {"lng":"-122.28640000","lat":"37.79784000","label":"Transfer","infor":"OAKLAND, CA, USA","sort":"2","stime":null,"ptype":"pod"}]';
  655. //$rss = json_decode($json,true);
  656. // global $mapdb;
  657. // //查询线(包含所有的线)
  658. // error_log("select * from get_track_data('$serial_no',true)");
  659. // $map_sql = "select * from get_track_data('$serial_no',true)";
  660. // $Line = $mapdb->GetAll($map_sql) or ( (!$mapdb->ErrorMsg()) or error_log(common::dbLog($mapdb, $map_sql), 0));
  661. // error_log("total:".count($Line));
  662. // $solidLine = array();
  663. // $dottedLine = array();
  664. // $rangePoint = array();
  665. // foreach($Line as $line){
  666. // if($line['tp'] == "1"){
  667. // $solidLine[] = $line;
  668. // }elseif($line['tp'] == "0"){
  669. // $dottedLine[] = $line;
  670. // }else{
  671. // $rangePoint[] = $line;
  672. // }
  673. // }
  674. // error_log("total_1:".count($solidLine));
  675. // error_log("total_2:".count($dottedLine));
  676. // error_log("total_3:".count($rangePoint));
  677. // //如果没有虚线,这这个范围点也是异常的,不需要显示
  678. // if(empty($dottedLine)){
  679. // $rangePoint = array();
  680. // }
  681. // $data = array("point"=>$rss,"solidLine"=>$solidLine,"dottedLine"=>$dottedLine,"rangePoint"=>$rangePoint);
  682. // common::echo_json_encode(200, $data);
  683. common::echo_json_encode(200, $rss);
  684. exit();
  685. break;
  686. case 'main_welcome':
  687. $cp = common::check_input($_POST ['cp']); //current_page
  688. $ps = common::check_input($_POST ['ps']); //ps
  689. if (empty($ps))
  690. $ps = 10;
  691. $sqlWhere = ' where ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]);
  692. $transportation = $_REQUEST["transportation"];
  693. if(!is_array($transportation)){
  694. $transportation = array($transportation);
  695. }
  696. $list = array();
  697. if(count($transportation) == 1 && strtolower($transportation[0]) == 'all' ){
  698. $transportation = array("Sea","Air","Road");
  699. }else{
  700. if(!in_array("Sea",$transportation)){
  701. $sqlWhere .= " and 1<>1 ";
  702. }
  703. }
  704. // test dome
  705. // $_POST['is_default'] = "no";
  706. // $_POST['date_start'] =null;
  707. // $_POST['date_end'] = null;
  708. //默认初始条件:ALL& ETD& Current Month 当前月的1号到最后一天 这个默认条件已经废除,前端不会这样传参数
  709. if (isset($_POST['is_default']) && strtolower($_POST['is_default']) == "yes" && false){
  710. $sqlWhere .= "and etd>='" . date("Y-m") . "-01' and etd<='" . date("Y-m") . "-01'::date + interval '1 month'";
  711. } else {
  712. $date_type = strtolower(common::check_input($_POST ['date_type']));
  713. if (isset($_POST['date_start']) && !empty($_POST['date_start']))
  714. $sqlWhere .= " and $date_type >= '" . common::usDate2sqlDate($_POST['date_start']) . " 00:00:00'";
  715. if (isset($_POST['date_end']) && !empty($_POST['date_end']))
  716. $sqlWhere .= " and $date_type <= '" . common::usDate2sqlDate($_POST['date_end']) . " 23:59:59'";
  717. }
  718. if (isset($_POST['customer']) && !empty($_POST['customer'])){
  719. $sqlWhere .= " and (shipper ilike '%".common::check_input($_POST['customer'])."%' or shipper_id ilike '%".common::check_input($_POST['customer'])."%'
  720. or consignee ilike '%".common::check_input($_POST['customer'])."%' or consignee_id ilike '%".common::check_input($_POST['customer'])."%')";
  721. }
  722. $rc = $_POST ['rc'];
  723. if ($rc == - 1) {
  724. $sql = "SELECT count(1) from public.online_ocean" . $sqlWhere ." and last_status_315_update_time is not null";
  725. $rc = common::excuteOneSql($sql);
  726. //error_log($sql);
  727. }
  728. $tp = ceil($rc / $ps);
  729. if ($rc > 0) {
  730. $sql = "SELECT order_from as _schemas,serial_no,last_status_city, consignee, shipper, h_bol,final_desination_uncode,
  731. to_char(etd, 'MM/DD/YYYY'::text) as etd, to_char(eta, 'MM/DD/YYYY'::text) AS eta,
  732. fport_of_loading_un, mport_of_discharge_un, place_of_receipt_un, place_of_delivery_un, ctnrs, count_cntr, last_status_ctnr,booking_no,
  733. 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,
  734. f_vessel,f_voyage,
  735. CASE
  736. WHEN dd.status is null THEN 'Created'::text
  737. ELSE dd.status::text
  738. END AS new_status,
  739. dd.act_date,dd.act_time,dd.description,
  740. dd.timezone,dd.code as dd_code
  741. FROM public.online_ocean
  742. left join LATERAL (select case when a.code='IFFBCF' then 'Created'
  743. when a.code='IFFCPU' then 'Cargo Received'
  744. when a.code='IFFREC' then 'Cargo Received'
  745. when a.code='IFFDEP' then 'Departure'
  746. when a.code='IFFARR' then 'Arrived'
  747. when a.code='IFFDEL' then 'Completed'
  748. else 'Created' END as status,
  749. act_date,act_time,
  750. _dd.description as description,
  751. timezone,code
  752. from public.ocean_milestone a
  753. left join LATERAL (select sno,description from milestone where code=a.code and project_no = '*' order by sno limit 1) _dd on true
  754. where a.serial_no=online_ocean.serial_no
  755. and a.code in (select regexp_split_to_table('IFFBCF,IFFCPU,IFFREC,IFFDEP,IFFARR,IFFDEL', ','))
  756. and a.act_date is not null
  757. order by id desc limit 1) dd on true
  758. $sqlWhere and last_status_315_update_time is not null";
  759. if (_isDemo()) {
  760. $sql .= " ORDER BY eta DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  761. } else {
  762. $sql .= " ORDER BY last_status_315_update_time DESC limit " . $ps . " offset " . ($cp - 1) * $ps;
  763. }
  764. $rss = common::excuteListSql($sql);
  765. //RecentStatusList
  766. $RecentStatusList = array();
  767. foreach ($rss as $key => $value) {
  768. $_schemas = $value['_schemas'];
  769. if($_schemas == "public"){
  770. $_schemas = "ocean";
  771. }
  772. $timezone = "";
  773. //按照最新execl Timezone From 来自于origin
  774. if($value['dd_code'] == "IFFBCF" || $value['dd_code'] == "IFFCPU"){
  775. $sql = "SELECT (select time_zone from public.city_timezone where uncode = LEFT(country, 2) || COALESCE(city_code,'')) as timezone
  776. FROM $_schemas.contacts c WHERE c.contact_id = '".$value['origin']."'";
  777. $timezone = common::excuteOneSql($sql);
  778. }
  779. //按照最新execl Timezone From 来自于final_destination
  780. if($value['dd_code'] == "IFFDEL"){
  781. $sql = "select time_zone from public.city_timezone where uncode = '".$value['final_desination_uncode']."'";
  782. $timezone = common::excuteOneSql($sql);
  783. }
  784. if($value['dd_code'] == "IFFREC" || $value['dd_code'] == "IFFDEP" || $value['dd_code'] == "IFFARR"){
  785. //Timezone From 来自于EDI315
  786. $serial_no = $value["serial_no"];
  787. $EDI315Time = common::getEDI315Time($serial_no,$value['_schemas']);
  788. if($value['dd_code'] == "IFFREC" || $value['dd_code'] == "IFFDEP"){
  789. //先以EDI315 时区为准,如果没有这代表数据是手动输入,或者没有同步情况
  790. $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  791. if(empty($timezone)){
  792. if($value['dd_code'] == "IFFREC"){
  793. $sql = "select time_zone from public.city_timezone where uncode = '".$value['place_of_receipt_un']."'";
  794. }else{
  795. $sql = "select time_zone from public.city_timezone where uncode = '".$value['fport_of_loading_un']."'";
  796. }
  797. $timezone = common::excuteOneSql($sql);
  798. }
  799. }
  800. if($value['dd_code'] == "IFFARR"){
  801. $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  802. if(empty($timezone)){
  803. $sql = "select time_zone from public.city_timezone where uncode = '".$value['mport_of_discharge_un']."'";
  804. $timezone = common::excuteOneSql($sql);
  805. }
  806. }
  807. // 根据IFFDEL这个milestone来判断是否转变为completed
  808. // if($value['dd_code'] == "IFFAFD"){
  809. // $timezone = $EDI315Time[$value['dd_code']]['timezone'];
  810. // if(empty($timezone)){
  811. // $sql = "select time_zone from public.city_timezone where uncode = '".$value['place_of_delivery_un']."'";
  812. // $timezone = common::excuteOneSql($sql);
  813. // }
  814. // }
  815. }
  816. $Arrived = $value['description'];
  817. $RecentStatusList[] = array("Title"=>$value['h_bol'],
  818. "name"=>utils::outDisplayForMerge($value['f_vessel'],$value['f_voyage']),
  819. "bookingNumber" =>$value['booking_no'],
  820. "IsSubscribe" =>false,
  821. "shipperName"=>$value['shipper'],
  822. "consigneeName" =>$value['consignee'],
  823. "startStation"=>$value['fport_of_loading_un'],
  824. "endStation"=>$value['mport_of_discharge_un'],
  825. "ETD"=>$value['etd'],
  826. "ETA"=>$value['eta'],
  827. "type"=>$value['new_status'],
  828. "Arrived"=>$Arrived,
  829. "Time"=>$value["act_date"],
  830. "act_time" =>$value["act_time"],
  831. "timezone"=>$timezone,
  832. "_schemas"=>$value["_schemas"],
  833. "a" =>common::deCode($value['serial_no'], 'E'));
  834. }
  835. $data = common::getManagement();
  836. $arrTmp = array('searchData' => $RecentStatusList,
  837. 'Management' => $data['Management'],
  838. 'dashboard_filter' => $data['dashboard_filter'],
  839. 'is_customer' =>_isCustomerLogin(),
  840. 'rc' => $rc,
  841. 'ps' => $ps,
  842. 'cp' => $cp,
  843. 'tp' => $tp);
  844. } else {
  845. $data = common::getManagement();
  846. $arrTmp = array('searchData' => array(),
  847. 'Management' => $data['Management'],
  848. 'dashboard_filter' => $data['dashboard_filter']);
  849. }
  850. common::echo_json_encode(200,$arrTmp);
  851. exit();
  852. break;
  853. case 'save_layout':
  854. $management = json_encode($_POST["management"]);
  855. $dashboard_filter = json_encode($_POST["dashboardObj"]);
  856. $_param = "";
  857. if(!empty($_POST["management"])){
  858. $_param .= " management = '$management' ";
  859. }
  860. if(!empty($dashboard_filter)){
  861. $_param .= ",dashboard_filter = '$dashboard_filter' ";
  862. }
  863. if(!empty($_param)){
  864. common::excuteUpdateSql("update public.ra_online_user set $_param where lower(user_login) = '" . strtolower(_getLoginName()) . "'");
  865. }
  866. $returnData = array("msg" => "success");
  867. common::echo_json_encode(200, $returnData);
  868. exit();
  869. break;
  870. case 'password':
  871. tools::getInstance()->updatePassword();
  872. break;
  873. case 'tools':
  874. tools::getInstance()->markSystem();
  875. break;
  876. case 'user_guide':
  877. $rootPath = realpath(dirname(__FILE__)) . DS;
  878. //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");
  879. // PDF文件在服务器上的位置
  880. $filename = $rootPath."userFile". DS."KLN_Online_User_Guide_24.11.26.pdf";
  881. $display_name = "KLN_Online_User_Guide_24_11_26.pdf";
  882. // Header content type
  883. header("Content-type: application/pdf");
  884. header("Content-Length: " . filesize($filename));
  885. header("Content-Disposition:attachment;filename=\"" . $display_name . "\"");
  886. // 将文件发送到浏览器。
  887. readfile($filename);
  888. break;
  889. default:
  890. $data = array(
  891. 'msg' => 'Page not found',
  892. );
  893. common::echo_json_encode(500, $data);
  894. }
  895. $db->Close();
  896. $db = null;
  897. if ($max_ec > 0)
  898. ini_set('max_execution_time', $max_ec); //recover old value
  899. if (!empty($memory_limit))
  900. ini_set('memory_limit', $memory_limit);
  901. ?>