| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- <?php
- if (!defined('IN_ONLINE')) {
- exit('Access Denied');
- }
- /**
- * Description of operation_log
- *
- * @author Administrator
- */
- class destination_delivery {
- private static $_destination_delivery;
- public static function getInstance() {
- if (!self::$_destination_delivery) {
- $c = __CLASS__;
- self::$_destination_delivery = new $c;
- }
- return self::$_destination_delivery;
- }
- /**
- * 关于destination_delivery 页面的所有的静态加载数据查询
- */
- public function destination_delivery_load(){
- $operate = utils::_get('operate');
- $operate = strtolower($operate);
- /**
- * select country
- */
- if ($operate == "country") {
- $$cp = common::check_input($_POST ['cp']); //current_page
- $ps = common::check_input($_POST ['ps']); //ps
- if (empty($ps))
- $ps = 20;
- $term = $_POST['term'];
- $term = trim($term);
- $rc = $_POST ['rc'];
- if ($rc == - 1) {
- $sql = "select COUNT(DISTINCT SUBSTRING(c.country FROM 1 FOR 2)) AS total_count
- from public.contract_region_mapping crm
- left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
- where coalesce(c.country,'')<> ''
- and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
- $rc = common::excuteOneSql($sql);
- }
- $tp = ceil($rc / $ps);
- if ($rc > 0) {
- $sql = "select DISTINCT SUBSTRING(c.country FROM 1 FOR 2) AS country_code
- from public.contract_region_mapping crm
- left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
- where coalesce(c.country,'')<> ''
- and SUBSTRING(c.country FROM 1 FOR 2) ilike '" . common::check_input($term) . "%'";
- $sql .= " order by country_code limit " . $ps . " offset " . ($cp - 1) * $ps;
- $rs = common::excuteListSql($sql);
- //前端要加上id 从1开始
- $retData = array();
- foreach($rs as $key => $val){
- if(!empty($val['country_code'])){
- $val["id"] = $key +1;
- $retData[] = $val;
- }
- }
- $arrTmp = array('searchData' => $retData,
- 'rc' => $rc,
- 'ps' => $ps,
- 'cp' => $cp,
- 'tp' => $tp);
- common::echo_json_encode(200,$arrTmp);
- exit();
- }else{
- $arrTmp = array('searchData' => array());
- common::echo_json_encode(200, $arrTmp);
- exit();
- }
- }
- /**
- * select station 选择国家后再展示 station list数据
- */
- if ($operate == "station") {
- $country = common::check_input($_REQUEST['country']);
- $sql = "select crm.overeas from public.contract_region_mapping crm
- left join ocean.contacts c on c.contact_id = crm.overeas and crm.ksmart_station_new ilike 'ksmart%'
- where SUBSTRING(c.country FROM 1 FOR 2) = '".$country."'";
- $data = common::excuteListSql($sql);
- common::echo_json_encode(200,$data);
- exit();
- }
- /**
- * select KLN PIC 下拉可供选择的employee帐号,且帐号权限站点包含选中的station
- */
- if ($operate == "employee_account") {
- $station = $_REQUEST['station'];
- $more_param = common::getInNotInSqlForSearch(utils::implode(';',$station));
- $sql = "select email from employee where contact_id in ($more_param) ";
- $data = common::excuteListSql($sql);
- common::echo_json_encode(200,$data);
- exit();
- }
- /**
- * 下拉可供选择的ports
- */
- if ($operate == "ports") {
- $mode = $_REQUEST['mode'];
- if ($mode == 'sea'){
- $sql = "select DISTINCT uncode from public.ports where coalesce(uncode,'')<> '' order by uncode";
- } else {
- $sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
- where coalesce(country_abb,'')<>'' order by uncode";
- }
- $data = common::excuteListSql($sql);
- common::echo_json_encode(200,$data);
- exit();
- $cp = common::check_input($_POST ['cp']); //current_page
- $ps = common::check_input($_POST ['ps']); //ps
- if (empty($ps))
- $ps = 20;
-
- $mode = $_POST['mode'];
- $term = $_POST['term'];
- $term = trim($term);
- $rc = $_POST ['rc'];
- if ($rc == - 1) {
- if ($mode == 'sea'){
- $sql = "select COUNT(DISTINCT uncode) from public.ports
- where coalesce(uncode,'')<>'' and uncode ilike '" . common::check_input($term) . "%'";
- } else {
- $sql = "select COUNT(DISTINCT coalesce(airport.country_abb,'')||airport.airport_code) from sfs.airport
- where coalesce(country_abb,'')<>''
- and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
- }
- $rc = common::excuteOneSql($sql);
- }
- $tp = ceil($rc / $ps);
- if ($rc > 0) {
- if ($mode == 'sea'){
- $sql = "select DISTINCT uncode from public.ports
- where coalesce(uncode,'')<> '' and uncode ilike '" . common::check_input($term) . "%'";
- } else {
- $sql = "select DISTINCT coalesce(airport.country_abb,'')||airport.airport_code as uncode from sfs.airport
- where coalesce(country_abb,'')<>''
- and coalesce(airport.country_abb,'')||airport.airport_code ilike '" . common::check_input($term) . "%'";
- }
- $sql .= " order by uncode limit " . $ps . " offset " . ($cp - 1) * $ps;
- $rs = common::excuteListSql($sql);
- //前端要加上id 从1开始
- $retData = array();
- foreach($rs as $key => $val){
- if(!empty($val['uncode'])){
- $val["id"] = $key +1;
- $retData[] = $val;
- }
- }
- $arrTmp = array('searchData' => $retData,
- 'rc' => $rc,
- 'ps' => $ps,
- 'cp' => $cp,
- 'tp' => $tp);
- common::echo_json_encode(200,$arrTmp);
- exit();
- }else{
- $arrTmp = array('searchData' => array());
- common::echo_json_encode(200, $arrTmp);
- exit();
- }
- }
- /**
- * 下拉可供选择的carrier
- */
- if ($operate == "carrier") {
- $cp = common::check_input($_POST ['cp']); //current_page
- $ps = common::check_input($_POST ['ps']); //ps
- if (empty($ps))
- $ps = 20;
- $term = $_POST['term'];
- $term = trim($term);
- $rc = $_POST ['rc'];
- if ($rc == - 1) {
- $sql = "select COUNT(DISTINCT scac) from public.vessel_company
- where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
- $rc = common::excuteOneSql($sql);
- }
- $tp = ceil($rc / $ps);
- if ($rc > 0) {
- $sql = "select DISTINCT scac from public.vessel_company
- where coalesce(scac,'')<> '' and scac ilike '" . common::check_input($term) . "%'";
- $sql .= " order by scac limit " . $ps . " offset " . ($cp - 1) * $ps;
- $rs = common::excuteListSql($sql);
- //前端要加上id 从1开始
- $retData = array();
- foreach($rs as $key => $val){
- if(!empty($val['scac'])){
- $val["id"] = $key +1;
- $retData[] = $val;
- }
- }
- $arrTmp = array('searchData' => $retData,
- 'rc' => $rc,
- 'ps' => $ps,
- 'cp' => $cp,
- 'tp' => $tp);
- common::echo_json_encode(200,$arrTmp);
- exit();
- }else{
- $arrTmp = array('searchData' => array());
- common::echo_json_encode(200, $arrTmp);
- exit();
- }
- }
- }
- /**
- * destination_delivery 配置
- */
- public function destination_delivery_config(){
- $operate = utils::_get('operate');
- $operate = strtolower($operate);
- /**
- * 这个是嵌套在destination_delivery的配置查询,
- */
- if ($operate == "search"){
- $sql = "select * from public.kln_destination_delivery_config";
- $data = common::excuteListSql($sql);
- common::echo_json_encode(200,$data);
- exit();
- }
- if ($operate == "add"){
- $id = common::deCode($_GET['a'], 'D');
- if (!empty($id)){
- } else {
- }
- global $_COPYRIGHT;
- $data = array('copyright' =>$_COPYRIGHT,
- 'website' =>"");
- common::echo_json_encode(200,$data);
- exit();
- }
- if ($operate == "save"){
- $id = common::deCode($_GET['a'], 'D');
- if (!empty($id)){
- } else {
- }
- $data = "";
- common::echo_json_encode(200,$data);
- exit();
- }
- }
- /**
- * booking
- */
- public function destination_delivery(){
- }
- }
- ?>
|