You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

130 lines
5.1 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. require_once '../Common/Mysql.php';
  7. if (ALLOW_ORIGIN)
  8. header("Access-Control-Allow-Origin:*");
  9. $method = isset($_GET['method']) ? $_GET['method'] : '';
  10. $pdo = conn();
  11. $USER_ID = getUserId();
  12. switch ($method) {
  13. case 'searchline' :
  14. $search = isset($_GET['word']) ? (empty($_GET['word']) ? '' : $_GET['word']) : '';
  15. $opera_org_id_sql = "select opera_org_id,main_corp_id from base_user where id = " . $USER_ID . " and cancel_flag = 0";
  16. $opera_org_id_result = $pdo->query($opera_org_id_sql);
  17. $rowset = $opera_org_id_result->fetchAll(PDO::FETCH_ASSOC);
  18. $opera_org_id = $rowset[0]['opera_org_id'];
  19. $main_corp_id = $rowset[0]['main_corp_id'];
  20. $and_sql = '';
  21. if ($opera_org_id != '') {
  22. $and_sql .= " and org_id in (" . $opera_org_id . ") ";
  23. }
  24. if ($main_corp_id != 0) {
  25. $and_sql .= " and main_corp_id in (" . $main_corp_id . ") ";
  26. }
  27. if ($search != '') {
  28. $and_sql .= " and (line_name like CONCAT('%','" . $search . "','%') or line_code like CONCAT('%','" . $search . "','%')) ";
  29. }
  30. $sql = "select concat(line_code,line_name) as name,line_id as lineid
  31. from opera_line
  32. where cancel_flag = 0
  33. and if_disabled = 0
  34. " . $and_sql;
  35. writeLog(" AddCarTime " . __LINE__ . ":" . $sql);
  36. //$sql="CALL XM_PRO_GET_LINE_LIST({$USER_ID},'".strtoupper($search)."')";
  37. if (is_object($pdo)) {
  38. $result = $pdo->query($sql);
  39. if ($result == false) {
  40. break;
  41. }
  42. $json = $result->fetchAll(PDO::FETCH_ASSOC);
  43. $result->closeCursor();
  44. }
  45. break;
  46. case 'throughstation':
  47. if (is_object($pdo)) {
  48. $lineid = isset($_GET['lineid']) ? $_GET['lineid'] : '';
  49. $sql = "CALL XM_PRO_GET_LINE_STATION(1," . $lineid . ")";
  50. writeLog('addCarTime.php throughstation sql:' . $sql);
  51. $result = $pdo->query($sql);
  52. $json1 = $result->fetchAll(PDO::FETCH_ASSOC);
  53. $result->closeCursor();
  54. $sql1 = "CALL XM_PRO_GET_LINE_TICKETS_TYPE(1," . $lineid . ")";
  55. $result1 = $pdo->query($sql1);
  56. $json2 = $result1->fetchAll(PDO::FETCH_ASSOC);
  57. $result1->closeCursor();
  58. $sql2 = "CALL XM_PRO_GET_LINE_CAR_TYPE(1,1)";
  59. $result2 = $pdo->query($sql2);
  60. $json3 = $result2->fetchAll(PDO::FETCH_ASSOC);
  61. $result2->closeCursor();
  62. //print_r($json3);
  63. foreach ($json1 as $k => $v) {
  64. if ($v['TICKET_GATE']) {
  65. $str = explode(',', $v['TICKET_GATE']);
  66. $json1[$k]['TICKET_GATE'] = '';
  67. foreach ($str as $val) {
  68. $str1 = explode("^-^", $val);
  69. $json1[$k]['TICKET_GATE'][$str1[0]] = $str1[1];
  70. }
  71. }
  72. }
  73. //$cost_type = array(array('type_id' => 518, 'type_name' => '按车辆结算'), array('type_id' => 519, 'type_name' => '按车座结算'));
  74. $cost_type = array(array('type_id' => 477, 'type_name' => '包车计价'), array('type_id' => 478, 'type_name' => '车座计价'));
  75. $sql3 = "select
  76. s.id as supplier_id,s.supplier_name as bus_team
  77. from
  78. base_supplier as s,base_supplier_purchase as p
  79. where
  80. s.id = p.supplier_id
  81. and s.cancel_flag = 0
  82. and s.supplier_type = 187
  83. and p.cancel_flag = 0
  84. and p.product_type = 259
  85. group by s.id";
  86. $result3 = $pdo->query($sql3);
  87. $json4 = $result3->fetchAll(PDO::FETCH_ASSOC);
  88. $sql5 = "select supplier_id,bus_res_id, base_cost from base_bus_cost where id > 0 ";
  89. $result5 = $pdo->query($sql5);
  90. $json5 = $result5->fetchAll(PDO::FETCH_ASSOC);
  91. $base_cost = array();
  92. foreach( $json5 as $base_cost_info ) {
  93. $supplier_id = $base_cost_info["supplier_id"];
  94. $bus_res_id = $base_cost_info["bus_res_id"];
  95. if( !isset($base_cost[$supplier_id]) ) {
  96. $base_cost[$supplier_id] = array();
  97. }
  98. $base_cost[$supplier_id][$bus_res_id] = $base_cost_info["base_cost"];
  99. }
  100. $json['station'] = $json1;
  101. $json['addcartype'] = $json3;
  102. $json['ticket'] = $json2;
  103. $json['cost_type'] = $cost_type;
  104. $json['supplier_list'] = $json4;
  105. $json['base_cost'] = $base_cost;
  106. }
  107. break;
  108. case 'addcartype':
  109. if (is_object($pdo)) {
  110. $sql = 'CALL XM_PRO_GET_LINE_CAR_TYPE(1,1)';
  111. $result = $pdo->query($sql);
  112. $json = $result->fetchAll(PDO::FETCH_ASSOC);
  113. //print_r($json);
  114. }
  115. break;
  116. }
  117. if (is_array($json)) {
  118. echo json_encode($json);
  119. }
  120. exit;
  121. //require_once '../Common/Config.php';