| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- <?php
- if (extension_loaded('zlib')) {
- ini_set('zlib.output_compression', 'On');
- ini_set('zlib.output_compression_level', '9');
- }
- if (!empty($_REQUEST['sessionid'])) {
- session_id($_REQUEST['sessionid']);
- }
- error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
- error_reporting(0);
- session_start();
- ini_set("magic_quotes_runtime", 0);
- define('IN_ONLINE', TRUE);
- define('DS', DIRECTORY_SEPARATOR);
- define('WEB_ROOT', str_replace(DS, '/', str_replace(str_replace("/", DS, $_SERVER['DOCUMENT_ROOT']), '', realpath(dirname(__FILE__)))));
- define('ONLINE_ROOT', realpath(dirname(__FILE__)) . DS);
- define('ADODB_PATH', ONLINE_ROOT . 'libs' . DS . 'ADOdb-5.20.17' . DS);
- define('C_PATH', ONLINE_ROOT . 'service' . DS);
- define('FILE_UPLOAD_PAHT', "upload" . DS);
- // define('DOCUMENT_AIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
- // define('DOCUMENT_OCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
- // define('DOCUMENT_SFSAIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
- // define('DOCUMENT_SFSOCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
- define('DOCUMENT_AIR_UPLOAD_PATH', "/DOC_AIR" . DS);
- define('DOCUMENT_OCEAN_UPLOAD_PATH', "/DOC" . DS);
- define('DOCUMENT_SFSAIR_UPLOAD_PATH', "/DOC_AIR" . DS);
- define('DOCUMENT_SFSOCEAN_UPLOAD_PATH', "/DOC" . DS);
- if (preg_match("/(bot|crawl|spider|slurp)/i", $_SERVER['HTTP_USER_AGENT'])) {
- header('HTTP/1.1 403 Forbidden');
- exit;
- }
- if (function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get"))
- @date_default_timezone_set(@date_default_timezone_get());
- header('Content-type: text/html; Charset=utf-8');
- include_once ADODB_PATH . 'toexport.inc.php';
- include_once ADODB_PATH . 'adodb.inc.php';
- include_once ONLINE_ROOT . 'libs' . DS . 'config.ini.php';
- include_once ONLINE_ROOT . 'utils' . DS . 'utils.class.php';
- include_once ONLINE_ROOT . 'utils' . DS . 'common.class.php';
- include_once ONLINE_ROOT . 'libs' . DS . 'phpXLSWriter' . DS . "xlsxwriter.class.php";
- //测试服务器
- if(utils::startWith($_SERVER["HTTP_HOST"],"online-beta.kln.com")){
- define('SERVER_PAHT', 'https://online-beta.kln.com/online_backend/');
- define('SERVER_Vue_PAHT', 'https://online-beta.kln.com/');
- }elseif(utils::startWith($_SERVER["HTTP_HOST"],"online.kln.com")){
- define('SERVER_PAHT', 'https://online.kln.com/online_backend/');
- define('SERVER_Vue_PAHT', 'https://online.kln.com/');
- }else{
- //本地测试demo
- define('SERVER_PAHT', 'http://192.168.0.161/Customer_Service_Online/');
- define('SERVER_Vue_PAHT', 'http://192.168.0.161/k_new_online/');
- }
- $tar = common::excuteObjectSql("select item_value from config where item='Current_Used_Company'");
- if (!empty($tar["item_value"])&&$tar["item_value"]=="TOPOCEAN") {
- define("Soure", 'TopOcean');
- }else{
- define("Soure", 'Apex');
- }
- function _isApexLogin() {
- return strtolower($_SESSION['ONLINE_USER']['user_type']) == "employee";
- //return false;
- }
- function _isAdmin() {
- return $_SESSION['ONLINE_USER']['is_super'] == 't';
- }
- function _isRevenueDisplay() {
- return $_SESSION['ONLINE_USER']['revenue_active'] == 't';
- }
- function _isNewUser() {
- return _isCustomerLogin() && empty($_SESSION['ONLINE_USER']['permission']);
- }
- function _isCustomerLogin() {
- return strtolower($_SESSION['ONLINE_USER']['user_type']) == 'customer';
- }
- function _getLoginName() {
- return $_SESSION['ONLINE_USER']['user_login'];
- }
- function _getLoginEamil() {
- return $_SESSION['ONLINE_USER']['email'];
- }
- function _getLoginEmployeeEamil() {
- return $_SESSION['ONLINE_USER']['employee_email'];
- }
- function _isAdminHandNew($user) {
- return $user['is_super'] == 't';
- }
- function _canViewAMSLog($schemas = "public") {
- if ($schemas == "public") {
- return strtolower($_SESSION['ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
- } else {
- return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
- }
- }
- function _canViewISFLog($schemas = "public") {
- if ($schemas == "public") {
- return strtolower($_SESSION['ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
- } else {
- return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
- }
- }
- function _isDocAdmin($username) {
- return strtolower($username) == "doc.alice" || strtolower($username) == "apexdoc.admin"
- || strtolower($username) == "doc.patty1" || strtolower($username) == "maria" || strtolower($username) == "it.andywu"
- || strtolower($username) == "doc.riley" || strtolower($username) == "doc.amy" || strtolower($username) == "doc.vicky"
- || strtolower($username) == "doc.leah" || strtolower($username) == "doc.yuki" || strtolower($username) == "doc.yoyo";
- }
- function _customerFilerSearchHandNew($user, $schemas = "public", $p = 'place_of_delivery', $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id', $d = 'port_of_discharge_code') {
- $tt = $user['customer_search_type'];
- $sales = $user['ocean_sales'];
- if (empty($tt)) {
- return "1<>1";
- }
- //error_log("_customerFilerSearchHandNew -- " . $schemas);
- $_contact_id = _getContactIDHandNew($user, $schemas);
- if (empty($_contact_id)) {
- return "1<>1";
- }
- $sqlWhere1 = "";
- if (utils::checkExist($tt, 's') && !empty($s)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
- }
- }
- if (utils::checkExist($tt, 'c') && !empty($c)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
- }
- }
- //暂时注释掉,ocean_booking 没有这个字段
- // if (utils::checkExist($tt, 'b') && !empty($b)) {
- // if (empty($sqlWhere1)) {
- // $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
- // } else {
- // $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
- // }
- // }
- if (utils::checkExist($tt, 'n') && !empty($n)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
- }
- }
- if (empty($sqlWhere1))
- return "1<>1";
- $sqlWhere1 = "(" . $sqlWhere1 . ")";
- if (!empty($user['customer_destination']) && !empty($p)) {
- $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
- }
- if (!empty($user['customer_discharge']) && !empty($d)) {
- $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
- }
- if (strtolower($sales) == 'all' || empty($sales)) {
-
- } else {
- if (utils::checkExist($sales, ";")) {
- $sql = "1!=1";
- $tt = explode(";", $sales);
- foreach ($tt as $t) {
- $t = trim($t);
- if (!empty($t))
- $sql .= " or sales_rep ilike '" . $t . "%'";
- }
- $sqlWhere1 .= " and ($sql)";
- } else
- $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
- }
- return $sqlWhere1;
- }
- function _getContactIDHandNew_Air($user, $schemas = "public") {
- $contact_id_user = _getCompanyContactHandNew_Air($user);
- $id = "";
- if ($schemas == "public") {
- $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
- } else {
- $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
- }
- foreach ($contact_id as $v) {
- if (empty($id))
- $id = trim($v['contacts_id']);
- else
- $id .= ";" . $v['contacts_id'];
- }
- if (!empty($contact_id_user)) {
- $id .= ";" . $contact_id_user;
- }
- return $id;
- }
- function _getCompanyContactHandNew_Air($user, $schemas = "public") {
- if ($schemas == "public") {
- return $user['air_customers'];
- } else {
- return $user[$schemas . '_ONLINE_USER']['air_customers'];
- }
- }
- function _getCompanyHandNew($user, $schemas = "public") {
- if ($schemas == "public") {
- return $user['company'];
- } else {
- if (empty($user['company'])) {
- return $user['company_name'];
- } else {
- return $user['company'];
- }
- }
- }
- function _getContactIDHandNew($user, $schemas = "public") {
- $contact_id_user = _getCompanyContactHandNew($user);
- $id = "";
- if ($schemas == "public") {
- $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
- } else {
- $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
- }
- foreach ($contact_id as $v) {
- if (empty($id))
- $id = trim($v['contacts_id']);
- else
- $id .= ";" . $v['contacts_id'];
- }
- if (!empty($contact_id_user)) {
- $id .= ";" . $contact_id_user;
- }
- return $id;
- }
- function _getCompanyContactHandNew($user, $schemas = "public") {
- if ($schemas == "public") {
- return $user['contact_id_user'];
- } else {
- return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
- }
- }
- function _isDemo() {
- return $_SESSION['ONLINE_USER']['is_demo'] == "t";
- }
- function _is_only_vgm() {
- if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
- return TRUE;
- }
- return FALSE;
- }
- function _get_schemas() {
- return $_SESSION['schemas_list'];
- }
- function _getViewDocType($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['view_doc_type'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
- }
- }
- function _getAirViewDocType($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['view_air_doc_type'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['view_air_doc_type'];
- }
- }
- function _canEdiVgm($schemas = "public") {
- if ($schemas == "public") {
- return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
- } else {
- return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
- }
- }
- function _getAirStation($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['air_station'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['air_station'];
- }
- }
- function _getAirStationOr($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['air_station_or'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['air_station_or'];
- }
- }
- function _getAirSales($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['air_sales'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['air_sales'];
- }
- }
- function _getAirSalesOr($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['air_sales_or'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['air_sales_or'];
- }
- }
- function _customerAirSearchType($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['air_customer_search_type'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['air_customer_search_type'];
- }
- }
- function _getAirContactID($schemas = "public") {
- if ($schemas == "public") {
- return $_SESSION['ONLINE_USER']['air_customers'];
- } else {
- return $_SESSION[$schemas . '_ONLINE_USER']['air_customers'];
- }
- }
- function _customerAirFilerSearch($schemas = "public", $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id') {
- $tt = _customerAirSearchType($schemas);
- if (empty($tt))
- return "1<>1";
- $_contact_id = _getAirContactID($schemas);
- if (empty($_contact_id)) {
- return "1<>1";
- }
- $sqlWhere1 = "";
- if (utils::checkExist($tt, 's') && !empty($s)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
- }
- }
- if (utils::checkExist($tt, 'c') && !empty($c)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
- }
- }
- if (utils::checkExist($tt, 'b') && !empty($b)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
- }
- }
- if (utils::checkExist($tt, 'n') && !empty($n)) {
- if (empty($sqlWhere1)) {
- $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
- } else {
- $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
- }
- }
- if (empty($sqlWhere1))
- return "1<>1";
- $sqlWhere1 = "(" . $sqlWhere1 . ")";
- return $sqlWhere1;
- }
- function _isCustomerLoginHandNew($user) {
- return strtolower($user["user_type"]) == 'customer';
- }
- ?>
|