include.ini.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <?php
  2. if (extension_loaded('zlib')) {
  3. ini_set('zlib.output_compression', 'On');
  4. ini_set('zlib.output_compression_level', '9');
  5. }
  6. if (!empty($_REQUEST['sessionid'])) {
  7. session_id($_REQUEST['sessionid']);
  8. }
  9. //error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
  10. error_reporting(0);
  11. session_start();
  12. ini_set("magic_quotes_runtime", 0);
  13. define('IN_ONLINE', TRUE);
  14. define('DS', DIRECTORY_SEPARATOR);
  15. define('WEB_ROOT', str_replace(DS, '/', str_replace(str_replace("/", DS, $_SERVER['DOCUMENT_ROOT']), '', realpath(dirname(__FILE__)))));
  16. define('ONLINE_ROOT', realpath(dirname(__FILE__)) . DS);
  17. define('ADODB_PATH', ONLINE_ROOT . 'libs' . DS . 'ADOdb-5.20.17' . DS);
  18. define('C_PATH', ONLINE_ROOT . 'service' . DS);
  19. define('FILE_UPLOAD_PAHT', "upload" . DS);
  20. // define('DOCUMENT_AIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
  21. // define('DOCUMENT_OCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
  22. // define('DOCUMENT_SFSAIR_UPLOAD_PATH', "D:" . DS . "DOC_AIR" . DS);
  23. // define('DOCUMENT_SFSOCEAN_UPLOAD_PATH', "D:" . DS . "DOC" . DS);
  24. define('DOCUMENT_AIR_UPLOAD_PATH', "/DOC_AIR" . DS);
  25. define('DOCUMENT_OCEAN_UPLOAD_PATH', "/DOC" . DS);
  26. define('DOCUMENT_SFSAIR_UPLOAD_PATH', "/DOC_AIR" . DS);
  27. define('DOCUMENT_SFSOCEAN_UPLOAD_PATH', "/DOC" . DS);
  28. if (preg_match("/(bot|crawl|spider|slurp)/i", $_SERVER['HTTP_USER_AGENT'])) {
  29. header('HTTP/1.1 403 Forbidden');
  30. exit;
  31. }
  32. if (function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get"))
  33. @date_default_timezone_set(@date_default_timezone_get());
  34. header('Content-type: text/html; Charset=utf-8');
  35. include_once ADODB_PATH . 'toexport.inc.php';
  36. include_once ADODB_PATH . 'adodb.inc.php';
  37. include_once ONLINE_ROOT . 'libs' . DS . 'config.ini.php';
  38. include_once ONLINE_ROOT . 'utils' . DS . 'utils.class.php';
  39. include_once ONLINE_ROOT . 'utils' . DS . 'common.class.php';
  40. include_once ONLINE_ROOT . 'utils' . DS . 'dms_edoc.class.php';
  41. include_once ONLINE_ROOT . 'libs' . DS . 'phpXLSWriter' . DS . "xlsxwriter.class.php";
  42. //确保每次进入是干净的,不会影响判断
  43. common::set("tableName", "");
  44. //测试服务器
  45. if(utils::startWith($_SERVER["HTTP_HOST"],"online-beta.kln.com")){
  46. define('SERVER_PAHT', 'https://online-beta.kln.com/online_backend/');
  47. define('SERVER_Vue_PAHT', 'https://online-beta.kln.com/');
  48. }elseif(utils::startWith($_SERVER["HTTP_HOST"],"online.kln.com")){
  49. define('SERVER_PAHT', 'https://online.kln.com/online_backend/');
  50. define('SERVER_Vue_PAHT', 'https://online.kln.com/');
  51. }else{
  52. //本地测试demo
  53. define('SERVER_PAHT', 'http://192.168.0.161/Customer_Service_Online/');
  54. define('SERVER_Vue_PAHT', 'http://192.168.0.161/k_new_online/');
  55. }
  56. $tar = common::excuteObjectSql("select item_value from config where item='Current_Used_Company'");
  57. if (!empty($tar["item_value"])&&$tar["item_value"]=="TOPOCEAN") {
  58. define("Soure", 'TopOcean');
  59. }else{
  60. define("Soure", 'Apex');
  61. }
  62. function _isApexLogin() {
  63. return strtolower($_SESSION['ONLINE_USER']['user_type']) == "employee";
  64. //return false;
  65. }
  66. function _isAdmin() {
  67. return $_SESSION['ONLINE_USER']['is_super'] == 't';
  68. }
  69. function _isRevenueDisplay() {
  70. return $_SESSION['ONLINE_USER']['revenue_active'] == 't';
  71. }
  72. function _isDesensitizationKln() {
  73. return $_SESSION['ONLINE_USER']['is_desensitization_kln'] == 't';
  74. }
  75. function _isNewUser() {
  76. return _isCustomerLogin() && empty($_SESSION['ONLINE_USER']['permission']);
  77. }
  78. function _isCustomerLogin() {
  79. return strtolower($_SESSION['ONLINE_USER']['user_type']) == 'customer';
  80. }
  81. function _getLoginName() {
  82. return $_SESSION['ONLINE_USER']['user_login'];
  83. }
  84. function _getLoginEamil() {
  85. return $_SESSION['ONLINE_USER']['email'];
  86. }
  87. function _getLoginEmployeeEamil() {
  88. return $_SESSION['ONLINE_USER']['employee_email'];
  89. }
  90. function _isAdminHandNew($user) {
  91. return $user['is_super'] == 't';
  92. }
  93. function _canViewAMSLog($schemas = "public") {
  94. if ($schemas == "public") {
  95. return strtolower($_SESSION['ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
  96. } else {
  97. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_amslog']) == 't' || _isAdmin();
  98. }
  99. }
  100. function _canViewISFLog($schemas = "public") {
  101. if ($schemas == "public") {
  102. return strtolower($_SESSION['ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
  103. } else {
  104. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_see_isflog']) == 't' || _isAdmin();
  105. }
  106. }
  107. function _isDocAdmin($username) {
  108. return strtolower($username) == "doc.alice" || strtolower($username) == "apexdoc.admin"
  109. || strtolower($username) == "doc.patty1" || strtolower($username) == "maria" || strtolower($username) == "it.andywu"
  110. || strtolower($username) == "doc.riley" || strtolower($username) == "doc.amy" || strtolower($username) == "doc.vicky"
  111. || strtolower($username) == "doc.leah" || strtolower($username) == "doc.yuki" || strtolower($username) == "doc.yoyo";
  112. }
  113. function _isVipReportAdmin($username) {
  114. return strtolower($username) == "doc.alice" || strtolower($username) == "maria"
  115. || strtolower($username) == "chud" || strtolower($username) == "doc.sansa1"
  116. || strtolower($username) == "doc.tianna" || strtolower($username) == "it.andywu"
  117. || strtolower($username) == "ra.admin" || strtolower($username) == "jon.walker@kln.com"
  118. || strtolower($username) == "mark.szymanowski@kln.com" || strtolower($username) == "cynthia.sy.lee@kln.com";
  119. }
  120. function _isTranslationReviewerAdmin($username) {
  121. return strtolower($username) == "chud"
  122. || strtolower($username) == "leslie.rouesnel@kln.com"
  123. || strtolower($username) == "julians"
  124. || strtolower($username) == "arantxa.velez@kln.com"
  125. || strtolower($username) == "luis.flores@kln.com"
  126. || strtolower($username) == "it.andywu"
  127. || strtolower($username) == "ra.admin"
  128. || strtolower($username) == "lina.pena@kln.com"
  129. || strtolower($username) == "sergio.castillo@kln.com"
  130. || strtolower($username) == "vander.moreira@kln.com"
  131. || strtolower($username) == "rafaela.costa@kln.com";
  132. }
  133. function _customerFilerSearchHandNew($tableName,$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') {
  134. $tt = $user['customer_search_type'];
  135. $sales = $user['ocean_sales'];
  136. if (empty($tt)) {
  137. return "1<>1";
  138. }
  139. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  140. $_contact_id = _getContactIDHandNew($user, $schemas);
  141. if (empty($_contact_id)) {
  142. return "1<>1";
  143. }
  144. $sqlWhere1 = "";
  145. if (utils::checkExist($tt, 's') && !empty($s)) {
  146. if (empty($sqlWhere1)) {
  147. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  148. } else {
  149. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  150. }
  151. }
  152. if (utils::checkExist($tt, 'c') && !empty($c)) {
  153. if (empty($sqlWhere1)) {
  154. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  155. } else {
  156. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  157. }
  158. }
  159. //暂时注释掉,ocean_booking 没有这个字段
  160. // if (utils::checkExist($tt, 'b') && !empty($b)) {
  161. // if (empty($sqlWhere1)) {
  162. // $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  163. // } else {
  164. // $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  165. // }
  166. // }
  167. if (utils::checkExist($tt, 'n') && !empty($n)) {
  168. if (empty($sqlWhere1)) {
  169. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  170. } else {
  171. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  172. }
  173. }
  174. //controlling_customer_code
  175. // if (utils::checkExist($tt, 't')) {
  176. // if (empty($sqlWhere1)) {
  177. // $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  178. // } else {
  179. // $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  180. // }
  181. // }
  182. if (utils::checkExist($tt, 't')) {
  183. if (empty($sqlWhere1)) {
  184. $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
  185. } else {
  186. $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
  187. }
  188. }
  189. if (empty($sqlWhere1))
  190. return "1<>1";
  191. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  192. if (!empty($user['customer_destination']) && !empty($p)) {
  193. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  194. }
  195. if (!empty($user['customer_destination_country'])) {
  196. $sqlWhere1 .= " and ( transport_mode = 'air' or LOWER(SUBSTRING(place_of_delivery_un, 1, 2)) " . common::getInNotInSql($user['customer_destination']).")";
  197. }
  198. if (!empty($user['customer_discharge']) && !empty($d)) {
  199. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  200. }
  201. if (strtolower($sales) == 'all' || empty($sales)) {
  202. } else {
  203. if (utils::checkExist($sales, ";")) {
  204. $sql = "1!=1";
  205. $tt = explode(";", $sales);
  206. foreach ($tt as $t) {
  207. $t = trim($t);
  208. if (!empty($t))
  209. $sql .= " or sales_rep ilike '" . $t . "%'";
  210. }
  211. $sqlWhere1 .= " and ($sql)";
  212. } else
  213. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  214. }
  215. return $sqlWhere1;
  216. }
  217. function _getContactIDHandNew_Air($user, $schemas = "public") {
  218. $contact_id_user = _getCompanyContactHandNew_Air($user);
  219. $id = "";
  220. if ($schemas == "public") {
  221. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  222. } else {
  223. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  224. }
  225. foreach ($contact_id as $v) {
  226. if (empty($id))
  227. $id = trim($v['contacts_id']);
  228. else
  229. $id .= ";" . $v['contacts_id'];
  230. }
  231. if (!empty($contact_id_user)) {
  232. $id .= ";" . $contact_id_user;
  233. }
  234. return $id;
  235. }
  236. function _getCompanyContactHandNew_Air($user, $schemas = "public") {
  237. if ($schemas == "public") {
  238. return $user['air_customers'];
  239. } else {
  240. return $user[$schemas . '_ONLINE_USER']['air_customers'];
  241. }
  242. }
  243. function _getCompanyHandNew($user, $schemas = "public") {
  244. if ($schemas == "public") {
  245. return $user['company'];
  246. } else {
  247. if (empty($user['company'])) {
  248. return $user['company_name'];
  249. } else {
  250. return $user['company'];
  251. }
  252. }
  253. }
  254. function _getContactIDHandNew($user, $schemas = "public") {
  255. $contact_id_user = _getCompanyContactHandNew($user);
  256. $id = "";
  257. if ($schemas == "public") {
  258. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  259. } else {
  260. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  261. }
  262. foreach ($contact_id as $v) {
  263. if (empty($id))
  264. $id = trim($v['contacts_id']);
  265. else
  266. $id .= ";" . $v['contacts_id'];
  267. }
  268. if (!empty($contact_id_user)) {
  269. $id .= ";" . $contact_id_user;
  270. }
  271. return $id;
  272. }
  273. function _getCompanyContactHandNew($user, $schemas = "public") {
  274. if ($schemas == "public") {
  275. return $user['contact_id_user'];
  276. } else {
  277. return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
  278. }
  279. }
  280. function _isDemo() {
  281. return $_SESSION['ONLINE_USER']['is_demo'] == "t";
  282. }
  283. function _is_only_vgm() {
  284. if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
  285. return TRUE;
  286. }
  287. return FALSE;
  288. }
  289. function _get_schemas() {
  290. return $_SESSION['schemas_list'];
  291. }
  292. function _getViewDocType($schemas = "public") {
  293. if ($schemas == "public") {
  294. return $_SESSION['ONLINE_USER']['view_doc_type'];
  295. } else {
  296. return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
  297. }
  298. }
  299. function _getAirViewDocType($schemas = "public") {
  300. if ($schemas == "public") {
  301. return $_SESSION['ONLINE_USER']['view_air_doc_type'];
  302. } else {
  303. return $_SESSION[$schemas . '_ONLINE_USER']['view_air_doc_type'];
  304. }
  305. }
  306. function _canEdiVgm($schemas = "public") {
  307. if ($schemas == "public") {
  308. return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  309. } else {
  310. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  311. }
  312. }
  313. function _getAirStation($schemas = "public") {
  314. if ($schemas == "public") {
  315. return $_SESSION['ONLINE_USER']['air_station'];
  316. } else {
  317. return $_SESSION[$schemas . '_ONLINE_USER']['air_station'];
  318. }
  319. }
  320. function _getAirStationOr($schemas = "public") {
  321. if ($schemas == "public") {
  322. return $_SESSION['ONLINE_USER']['air_station_or'];
  323. } else {
  324. return $_SESSION[$schemas . '_ONLINE_USER']['air_station_or'];
  325. }
  326. }
  327. function _getAirSales($schemas = "public") {
  328. if ($schemas == "public") {
  329. return $_SESSION['ONLINE_USER']['air_sales'];
  330. } else {
  331. return $_SESSION[$schemas . '_ONLINE_USER']['air_sales'];
  332. }
  333. }
  334. function _getAirSalesOr($schemas = "public") {
  335. if ($schemas == "public") {
  336. return $_SESSION['ONLINE_USER']['air_sales_or'];
  337. } else {
  338. return $_SESSION[$schemas . '_ONLINE_USER']['air_sales_or'];
  339. }
  340. }
  341. function _customerAirSearchType($schemas = "public") {
  342. if ($schemas == "public") {
  343. return $_SESSION['ONLINE_USER']['air_customer_search_type'];
  344. } else {
  345. return $_SESSION[$schemas . '_ONLINE_USER']['air_customer_search_type'];
  346. }
  347. }
  348. function _getAirContactID($schemas = "public") {
  349. if ($schemas == "public") {
  350. return $_SESSION['ONLINE_USER']['air_customers'];
  351. } else {
  352. return $_SESSION[$schemas . '_ONLINE_USER']['air_customers'];
  353. }
  354. }
  355. function _customerAirFilerSearch($tableName,$schemas = "public", $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id') {
  356. $tt = _customerAirSearchType($schemas);
  357. if (empty($tt))
  358. return "1<>1";
  359. $_contact_id = _getAirContactID($schemas);
  360. if (empty($_contact_id)) {
  361. return "1<>1";
  362. }
  363. $sqlWhere1 = "";
  364. if (utils::checkExist($tt, 's') && !empty($s)) {
  365. if (empty($sqlWhere1)) {
  366. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  367. } else {
  368. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  369. }
  370. }
  371. if (utils::checkExist($tt, 'c') && !empty($c)) {
  372. if (empty($sqlWhere1)) {
  373. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  374. } else {
  375. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  376. }
  377. }
  378. if (utils::checkExist($tt, 'b') && !empty($b)) {
  379. if (empty($sqlWhere1)) {
  380. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  381. } else {
  382. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  383. }
  384. }
  385. if (utils::checkExist($tt, 'n') && !empty($n)) {
  386. if (empty($sqlWhere1)) {
  387. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  388. } else {
  389. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  390. }
  391. }
  392. //controlling_customer_code
  393. // if (utils::checkExist($tt, 't')) {
  394. // if (empty($sqlWhere1)) {
  395. // $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  396. // } else {
  397. // $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  398. // }
  399. // }
  400. if (utils::checkExist($tt, 't')) {
  401. if (empty($sqlWhere1)) {
  402. $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
  403. } else {
  404. $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
  405. }
  406. }
  407. if (empty($sqlWhere1))
  408. return "1<>1";
  409. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  410. return $sqlWhere1;
  411. }
  412. /**
  413. * 员工的有关的group_name 和contact id 权限配置查询 ocean air 合并写
  414. * @return string sql
  415. */
  416. function _employeeFilerSearch($tableName,$ocean_air,$contact_field,$group_name_field,$schemas = "public", $p = 'place_of_delivery', $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id', $d = 'port_of_discharge_code'){
  417. if($ocean_air == "ocean"){
  418. $tt = _employeeSearchType($schemas,"employee_search_type");
  419. }else{
  420. $tt = _employeeSearchType($schemas,"employee_air_search_type");
  421. }
  422. if (empty($tt))
  423. return "1<>1";
  424. $_contact_id = _getEmployeeContactID($schemas,$contact_field,$group_name_field);
  425. if (empty($_contact_id)) {
  426. return "1<>1";
  427. }
  428. $sqlWhere1 = "";
  429. if (utils::checkExist($tt, 's') && !empty($s)) {
  430. if (empty($sqlWhere1)) {
  431. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  432. } else {
  433. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  434. }
  435. }
  436. if (utils::checkExist($tt, 'c') && !empty($c)) {
  437. if (empty($sqlWhere1)) {
  438. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  439. } else {
  440. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  441. }
  442. }
  443. if (utils::checkExist($tt, 'b') && !empty($b)) {
  444. if (empty($sqlWhere1)) {
  445. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  446. } else {
  447. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  448. }
  449. }
  450. if (utils::checkExist($tt, 'n') && !empty($n)) {
  451. if (empty($sqlWhere1)) {
  452. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  453. } else {
  454. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  455. }
  456. }
  457. //controlling_customer_code
  458. // if($ocean_air == "ocean"){
  459. // if (utils::checkExist($tt, 't')) {
  460. // if (empty($sqlWhere1)) {
  461. // $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  462. // } else {
  463. // $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  464. // }
  465. // }
  466. // }else{
  467. // if (utils::checkExist($tt, 't')) {
  468. // if (empty($sqlWhere1)) {
  469. // $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  470. // } else {
  471. // $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = ".$tableName.".serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)";
  472. // }
  473. // }
  474. // }
  475. if (utils::checkExist($tt, 't')) {
  476. if (empty($sqlWhere1)) {
  477. $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
  478. } else {
  479. $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
  480. }
  481. }
  482. if (empty($sqlWhere1))
  483. return "1<>1";
  484. return $sqlWhere1 = "(" . $sqlWhere1 . ")";
  485. }
  486. function _isCustomerLoginHandNew($user) {
  487. return strtolower($user["user_type"]) == 'customer';
  488. }
  489. function _employeeSearchType($schemas = "public",$filed) {
  490. if ($schemas == "public") {
  491. return $_SESSION['ONLINE_USER'][$filed];
  492. } else {
  493. return $_SESSION[$schemas . '_ONLINE_USER'][$filed];
  494. }
  495. }
  496. function _getEmployeeContactID($schemas = "public",$contact_field,$group_name_field) {
  497. if(!empty($contact_field)){
  498. $contact_id_user = _getEmployeeCompanyContact($schemas,$contact_field);
  499. }
  500. $id = "";
  501. if(!empty(_getEmployeeCompany($schemas,$group_name_field))){
  502. if ($schemas == "public") {
  503. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getEmployeeCompany($schemas,$group_name_field)));
  504. } else {
  505. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getEmployeeCompany($schemas,$group_name_field)));
  506. }
  507. }
  508. foreach ($contact_id as $v) {
  509. if (empty($id))
  510. $id = trim($v['contacts_id']);
  511. else
  512. $id .= ";" . $v['contacts_id'];
  513. }
  514. if (!empty($contact_id_user)) {
  515. $id .= ";" . $contact_id_user;
  516. }
  517. return $id;
  518. }
  519. function _getEmployeeCompanyContact($schemas = "public",$contact_field) {
  520. if ($schemas == "public") {
  521. return $_SESSION['ONLINE_USER'][$contact_field];
  522. } else {
  523. return $_SESSION[$schemas . '_ONLINE_USER'][$contact_field];
  524. }
  525. }
  526. function _getEmployeeCompany($schemas = "public",$group_name_field) {
  527. if ($schemas == "public") {
  528. return $_SESSION['ONLINE_USER'][$group_name_field];
  529. } else {
  530. return $_SESSION[$schemas . '_ONLINE_USER'][$group_name_field];
  531. }
  532. }
  533. ?>