destination_delivery.class.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <?php
  2. if (!defined('IN_ONLINE')) {
  3. exit('Access Denied');
  4. }
  5. /**
  6. * Description of operation_log
  7. *
  8. * @author Administrator
  9. */
  10. class destination_delivery {
  11. private static $_destination_delivery;
  12. public static function getInstance() {
  13. if (!self::$_destination_delivery) {
  14. $c = __CLASS__;
  15. self::$_destination_delivery = new $c;
  16. }
  17. return self::$_destination_delivery;
  18. }
  19. /**
  20. * 关于destination_delivery 页面的所有的静态加载数据查询
  21. */
  22. public function destination_delivery_load(){
  23. $operate = utils::_get('operate');
  24. $operate = strtolower($operate);
  25. /**
  26. * select country
  27. */
  28. if ($operate == "country") {
  29. $$cp = common::check_input($_POST ['cp']); //current_page
  30. $ps = common::check_input($_POST ['ps']); //ps
  31. if (empty($ps))
  32. $ps = 20;
  33. $term = $_POST['term'];
  34. $term = trim($term);
  35. $rc = $_POST ['rc'];
  36. if ($rc == - 1) {
  37. $sql = "select COUNT(DISTINCT SUBSTRING(c.country FROM 1 FOR 2)) AS total_count
  38. from public.contract_region_mapping crm
  39. left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
  40. where coalesce(c.country,'')<> ''
  41. and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
  42. $rc = common::excuteOneSql($sql);
  43. }
  44. $tp = ceil($rc / $ps);
  45. if ($rc > 0) {
  46. $sql = "select DISTINCT SUBSTRING(c.country FROM 1 FOR 2) AS country_code
  47. from public.contract_region_mapping crm
  48. left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
  49. where coalesce(c.country,'')<> ''
  50. and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
  51. $sql .= " order by country_code limit " . $ps . " offset " . ($cp - 1) * $ps;
  52. $rs = common::excuteListSql($sql);
  53. //前端要加上id 从1开始
  54. $retData = array();
  55. foreach($rs as $key => $val){
  56. if(!empty($val['country_code'])){
  57. $val["id"] = $key +1;
  58. $retData[] = $val;
  59. }
  60. }
  61. $arrTmp = array('searchData' => $retData,
  62. 'rc' => $rc,
  63. 'ps' => $ps,
  64. 'cp' => $cp,
  65. 'tp' => $tp);
  66. common::echo_json_encode(200,$arrTmp);
  67. exit();
  68. }else{
  69. $arrTmp = array('searchData' => array());
  70. common::echo_json_encode(200, $arrTmp);
  71. exit();
  72. }
  73. }
  74. /**
  75. * select station 选择国家后再展示 station list数据
  76. */
  77. if ($operate == "station") {
  78. $country = common::check_input($_REQUEST['country']);
  79. $sql = "select crm.overeas from public.contract_region_mapping crm
  80. left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
  81. where SUBSTRING(c.country FROM 1 FOR 2) = '".$country."'";
  82. $data = common::excuteListSql($sql);
  83. common::echo_json_encode(200,$data);
  84. exit();
  85. }
  86. /**
  87. * select KLN PIC 下拉可供选择的employee帐号,且帐号权限站点包含选中的station
  88. */
  89. if ($operate == "employee_account") {
  90. $station = $_REQUEST['station'];
  91. $more_param = common::getInNotInSqlForSearch(utils::implode(';',$station));
  92. $sql = "select email from employee where contact_id in ($more_param) ";
  93. $data = common::excuteListSql($sql);
  94. common::echo_json_encode(200,$data);
  95. exit();
  96. }
  97. /**
  98. * 下拉可供选择的ports
  99. */
  100. if ($operate == "ports") {
  101. $mode = $_REQUEST['mode'];
  102. if ($mode == 'sea'){
  103. $sql = "select DISTINCT uncode from public.ports where coalesce(uncode,'')<> '' order by uncode";
  104. } else {
  105. $sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
  106. where coalesce(country_abb,'')<>'' order by uncode";
  107. }
  108. $data = common::excuteListSql($sql);
  109. common::echo_json_encode(200,$data);
  110. exit();
  111. $cp = common::check_input($_POST ['cp']); //current_page
  112. $ps = common::check_input($_POST ['ps']); //ps
  113. if (empty($ps))
  114. $ps = 20;
  115. $mode = $_POST['mode'];
  116. $term = $_POST['term'];
  117. $term = trim($term);
  118. $rc = $_POST ['rc'];
  119. if ($rc == - 1) {
  120. if ($mode == 'sea'){
  121. $sql = "select COUNT(DISTINCT uncode) from public.ports
  122. where coalesce(uncode,'')<>'' and uncode ilike '" . common::check_input($term) . "%'";
  123. } else {
  124. $sql = "select COUNT(DISTINCT coalesce(airport.country_abb,'')||airport.airport_code) from sfs.airport
  125. where coalesce(country_abb,'')<>''
  126. and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
  127. }
  128. $rc = common::excuteOneSql($sql);
  129. }
  130. $tp = ceil($rc / $ps);
  131. if ($rc > 0) {
  132. if ($mode == 'sea'){
  133. $sql = "select DISTINCT uncode from public.ports
  134. where coalesce(uncode,'')<> '' and uncode ilike '" . common::check_input($term) . "%'";
  135. } else {
  136. $sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
  137. where coalesce(country_abb,'')<>''
  138. and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
  139. }
  140. $sql .= " order by uncode limit " . $ps . " offset " . ($cp - 1) * $ps;
  141. $rs = common::excuteListSql($sql);
  142. //前端要加上id 从1开始
  143. $retData = array();
  144. foreach($rs as $key => $val){
  145. if(!empty($val['uncode'])){
  146. $val["id"] = $key +1;
  147. $retData[] = $val;
  148. }
  149. }
  150. $arrTmp = array('searchData' => $retData,
  151. 'rc' => $rc,
  152. 'ps' => $ps,
  153. 'cp' => $cp,
  154. 'tp' => $tp);
  155. common::echo_json_encode(200,$arrTmp);
  156. exit();
  157. }else{
  158. $arrTmp = array('searchData' => array());
  159. common::echo_json_encode(200, $arrTmp);
  160. exit();
  161. }
  162. }
  163. /**
  164. * 下拉可供选择的carrier
  165. */
  166. if ($operate == "carrier") {
  167. $cp = common::check_input($_POST ['cp']); //current_page
  168. $ps = common::check_input($_POST ['ps']); //ps
  169. if (empty($ps))
  170. $ps = 20;
  171. $term = $_POST['term'];
  172. $term = trim($term);
  173. $rc = $_POST ['rc'];
  174. if ($rc == - 1) {
  175. $sql = "select COUNT(DISTINCT scac) from public.vessel_company
  176. where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
  177. $rc = common::excuteOneSql($sql);
  178. }
  179. $tp = ceil($rc / $ps);
  180. if ($rc > 0) {
  181. $sql = "select DISTINCT scac from public.vessel_company
  182. where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
  183. $sql .= " order by scac limit " . $ps . " offset " . ($cp - 1) * $ps;
  184. $rs = common::excuteListSql($sql);
  185. //前端要加上id 从1开始
  186. $retData = array();
  187. foreach($rs as $key => $val){
  188. if(!empty($val['scac'])){
  189. $val["id"] = $key +1;
  190. $retData[] = $val;
  191. }
  192. }
  193. $arrTmp = array('searchData' => $retData,
  194. 'rc' => $rc,
  195. 'ps' => $ps,
  196. 'cp' => $cp,
  197. 'tp' => $tp);
  198. common::echo_json_encode(200,$arrTmp);
  199. exit();
  200. }else{
  201. $arrTmp = array('searchData' => array());
  202. common::echo_json_encode(200, $arrTmp);
  203. exit();
  204. }
  205. }
  206. }
  207. /**
  208. * destination_delivery 配置
  209. */
  210. public function destination_delivery_config(){
  211. $operate = utils::_get('operate');
  212. $operate = strtolower($operate);
  213. /**
  214. * 这个是嵌套在destination_delivery的配置查询,
  215. */
  216. if ($operate == "search"){
  217. $sql = "select * from public.kln_destination_delivery_config";
  218. $data = common::excuteListSql($sql);
  219. common::echo_json_encode(200,$data);
  220. exit();
  221. }
  222. if ($operate == "add"){
  223. $id = common::deCode($_GET['a'], 'D');
  224. if (!empty($id)){
  225. } else {
  226. }
  227. global $_COPYRIGHT;
  228. $data = array('copyright' =>$_COPYRIGHT,
  229. 'website' =>"");
  230. common::echo_json_encode(200,$data);
  231. exit();
  232. }
  233. if ($operate == "save"){
  234. $id = common::deCode($_GET['a'], 'D');
  235. if (!empty($id)){
  236. } else {
  237. }
  238. $data = "";
  239. common::echo_json_encode(200,$data);
  240. exit();
  241. }
  242. }
  243. /**
  244. * booking
  245. */
  246. public function destination_delivery(){
  247. }
  248. }
  249. ?>