$_SESSION['SESSION_TIMEOUT']) { exit(json_encode("session_time_out")); } else { $_SESSION["LAST_OPERATE_TIME"] = time(); } $operate = utils::_get('operate'); $operate = strtolower($operate); switch ($operate) { case 'save_setting_display': $this->save_setting_display(); break; case 'autody': return json_encode($this->autody()); break; case 'autoport': return json_encode($this->autoPort()); break; default : break; } } public function save_setting_display() { $ids = $_POST['ids']; if(!empty($ids)){ $ss = utils::implode(",", $_POST['ids']); column::getInstance()->saveSettingDisplay(utils::implode(",", $_POST['ids']),"", $_POST['model_name']); $data = array( 'msg' => 'success' ); common::echo_json_encode(200,$data); }else{ $data = array( 'msg' => 'data error' ); common::echo_json_encode(500,$data); } } //不查询全局的信息,查询该用户,最近3个月内输入过的信息自动补全 public function autody_new(){ $term = $_POST['term']; $type = $_POST['type']; $search_field = $_POST['search_field']; $search_mode = $_POST['search_mode']; $term = trim($term); if (strtolower($type) == "apex") { $sqlWhere = ' and ' . common::searchExtendHandNew("ocean", $_SESSION["ONLINE_USER"]); $sqlWhere = " " . $sqlWhere; $search_field_mapping = array("Origin Agent"=>"origin", "Destination Agent"=>"agent", "Shipper Name"=>"shipper", "Consignee Name"=>"consignee", "Sales"=>"sales_rep", "Voyage"=>"voyage", "Vessel"=>"vessel"); $str = $search_field_mapping['$search_field ']; $table = $search_mode == "Tracking" ? "public.online_ocean" : "public.online_ocean"; $sql = "select $str from $table where 1=1 $sqlWhere and f_etd >= current_date - INTERVAL '3 months'"; $sql .= " order by contact_id limit 20"; $rs = common::excuteListSql($sql); } //Shipper 和Consignee 的查询,但是表contact_v ,从ocean和air. 如果不做区分的话,可以上面的apex的Origin Agent/Destination Agent,合并 if (strtolower($type) == "contanct") { $sql = "SELECT company as code from contact_v where active = true and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')"; $sql .= " order by contact_id limit 20"; $rs = common::excuteListSql($sql); } $rs = common::excuteListSql($sql); $array = array(); foreach($rs as $v){ if(!empty($v['code'])){ $array[] = $v['code']; } } common::echo_json_encode(200,$array); exit(); } public function autoPort() { $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); $_curr_schemas = $_POST['model']; if (empty($_curr_schemas)) { $_curr_schemas = $_SESSION['ONLINE_USER']['main_schemas']; if (empty($_curr_schemas)) { $_curr_schemas = "public"; } } $rc = $_POST ['rc']; if ($rc == - 1) { $sql = "SELECT count(1) from $_curr_schemas.ports where (isoname ilike '" . common::check_input($term) . "%' or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')"; $rc = common::excuteOneSql($sql); } $tp = ceil($rc / $ps); if ($rc > 0) { $sql = "SELECT isoname as country, uncity as city,uncode from $_curr_schemas.ports where (isoname ilike '" . common::check_input($term) . "%' or uncity ilike '" . common::check_input($term) . "%' or uncode ilike '" . common::check_input($term) . "%')"; $sql .= " order by code limit " . $ps . " offset " . ($cp - 1) * $ps; $rs = common::excuteListSql($sql); //前端要加上id 从1开始 $retData = array(); foreach($rs as $key => $val){ if(!empty($val['country'])){ $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(); } } public function autody() { $term = $_POST['term']; $type = $_POST['type']; $term = trim($term); if (strtolower($type) == "apex") { $_curr_schemas = $_POST['model']; if (empty($_curr_schemas)) { $_curr_schemas = $_SESSION['ONLINE_USER']['main_schemas']; if (empty($_curr_schemas)) { $_curr_schemas = "public"; } } if ($_curr_schemas == "public") { $sql = "select contact_id as code from ocean.contacts where ('Apex-DST'=any(regexp_split_to_array(contact_type::text, ';'::text))" . " or 'Apex-AGT'=any(regexp_split_to_array(contact_type::text, ';'::text))) " . "and active=true and coalesce(hblcode, '')<>'' and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')"; } else { $sql = "select contact_id as code from $_curr_schemas.contacts where ('Apex-DST'=any(regexp_split_to_array(contact_type::text, ';'::text))" . " or 'Apex-AGT'=any(regexp_split_to_array(contact_type::text, ';'::text))) " . "and active=true and coalesce(hblcode, '')<>'' and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')"; } $sql .= " order by contact_id limit 20"; $rs = common::excuteListSql($sql); } //Shipper 和Consignee 的查询,但是表contact_v ,从ocean和air. 如果不做区分的话,可以上面的apex的Origin Agent/Destination Agent,合并 if (strtolower($type) == "contanct") { $sql = "SELECT company as code from contact_v where active = true and (contact_id ilike '" . common::check_input($term) . "%' or company ilike '" . common::check_input($term) . "%')"; $sql .= " order by contact_id limit 20"; $rs = common::excuteListSql($sql); } if (strtolower($type) == "sales") { $_curr_schemas = $_POST['model']; if (empty($_curr_schemas)) { $_curr_schemas = $_SESSION['ONLINE_USER']['main_schemas']; if (empty($_curr_schemas)) { $_curr_schemas = "public"; } } $sql = "SELECT salesopcode as code from $_curr_schemas.employee where salesopcode is not null and salesopcode !='' and (salesopcode ilike '" . common::check_input($term) . "%' or employee_id ilike '" . common::check_input($term) . "%')"; $sql .= " order by salesopcode limit 20"; } if (strtolower($type) == "vessel") { $vessel = $_POST['vessel']; $sql = "SELECT carrier, vessel as code, flag from vessel_infor where vessel ilike '" . common::check_input($vessel) . "%'"; $sql .= " order by vessel limit 20"; } $rs = common::excuteListSql($sql); $array = array(); foreach($rs as $v){ if(!empty($v['code'])){ $array[] = $v['code']; } } common::echo_json_encode(200,$array); exit(); } } ?>