include.ini.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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 _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') {
  121. $tt = $user['customer_search_type'];
  122. $sales = $user['ocean_sales'];
  123. if (empty($tt)) {
  124. return "1<>1";
  125. }
  126. //error_log("_customerFilerSearchHandNew -- " . $schemas);
  127. $_contact_id = _getContactIDHandNew($user, $schemas);
  128. if (empty($_contact_id)) {
  129. return "1<>1";
  130. }
  131. $sqlWhere1 = "";
  132. if (utils::checkExist($tt, 's') && !empty($s)) {
  133. if (empty($sqlWhere1)) {
  134. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  135. } else {
  136. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  137. }
  138. }
  139. if (utils::checkExist($tt, 'c') && !empty($c)) {
  140. if (empty($sqlWhere1)) {
  141. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  142. } else {
  143. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  144. }
  145. }
  146. //暂时注释掉,ocean_booking 没有这个字段
  147. // if (utils::checkExist($tt, 'b') && !empty($b)) {
  148. // if (empty($sqlWhere1)) {
  149. // $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  150. // } else {
  151. // $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  152. // }
  153. // }
  154. if (utils::checkExist($tt, 'n') && !empty($n)) {
  155. if (empty($sqlWhere1)) {
  156. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  157. } else {
  158. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  159. }
  160. }
  161. //controlling_customer_code
  162. // if (utils::checkExist($tt, 't')) {
  163. // if (empty($sqlWhere1)) {
  164. // $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)";
  165. // } else {
  166. // $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)";
  167. // }
  168. // }
  169. if (utils::checkExist($tt, 't')) {
  170. if (empty($sqlWhere1)) {
  171. $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
  172. } else {
  173. $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
  174. }
  175. }
  176. if (empty($sqlWhere1))
  177. return "1<>1";
  178. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  179. if (!empty($user['customer_destination']) && !empty($p)) {
  180. $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']);
  181. }
  182. if (!empty($user['customer_destination_country'])) {
  183. $sqlWhere1 .= " and ( transport_mode = 'air' or LOWER(SUBSTRING(place_of_delivery_un, 1, 2)) " . common::getInNotInSql($user['customer_destination']).")";
  184. }
  185. if (!empty($user['customer_discharge']) && !empty($d)) {
  186. $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']);
  187. }
  188. if (strtolower($sales) == 'all' || empty($sales)) {
  189. } else {
  190. if (utils::checkExist($sales, ";")) {
  191. $sql = "1!=1";
  192. $tt = explode(";", $sales);
  193. foreach ($tt as $t) {
  194. $t = trim($t);
  195. if (!empty($t))
  196. $sql .= " or sales_rep ilike '" . $t . "%'";
  197. }
  198. $sqlWhere1 .= " and ($sql)";
  199. } else
  200. $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'";
  201. }
  202. return $sqlWhere1;
  203. }
  204. function _getContactIDHandNew_Air($user, $schemas = "public") {
  205. $contact_id_user = _getCompanyContactHandNew_Air($user);
  206. $id = "";
  207. if ($schemas == "public") {
  208. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  209. } else {
  210. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  211. }
  212. foreach ($contact_id as $v) {
  213. if (empty($id))
  214. $id = trim($v['contacts_id']);
  215. else
  216. $id .= ";" . $v['contacts_id'];
  217. }
  218. if (!empty($contact_id_user)) {
  219. $id .= ";" . $contact_id_user;
  220. }
  221. return $id;
  222. }
  223. function _getCompanyContactHandNew_Air($user, $schemas = "public") {
  224. if ($schemas == "public") {
  225. return $user['air_customers'];
  226. } else {
  227. return $user[$schemas . '_ONLINE_USER']['air_customers'];
  228. }
  229. }
  230. function _getCompanyHandNew($user, $schemas = "public") {
  231. if ($schemas == "public") {
  232. return $user['company'];
  233. } else {
  234. if (empty($user['company'])) {
  235. return $user['company_name'];
  236. } else {
  237. return $user['company'];
  238. }
  239. }
  240. }
  241. function _getContactIDHandNew($user, $schemas = "public") {
  242. $contact_id_user = _getCompanyContactHandNew($user);
  243. $id = "";
  244. if ($schemas == "public") {
  245. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user)));
  246. } else {
  247. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas)));
  248. }
  249. foreach ($contact_id as $v) {
  250. if (empty($id))
  251. $id = trim($v['contacts_id']);
  252. else
  253. $id .= ";" . $v['contacts_id'];
  254. }
  255. if (!empty($contact_id_user)) {
  256. $id .= ";" . $contact_id_user;
  257. }
  258. return $id;
  259. }
  260. function _getCompanyContactHandNew($user, $schemas = "public") {
  261. if ($schemas == "public") {
  262. return $user['contact_id_user'];
  263. } else {
  264. return $user[$schemas . '_ONLINE_USER']['contact_id_user'];
  265. }
  266. }
  267. function _isDemo() {
  268. return $_SESSION['ONLINE_USER']['is_demo'] == "t";
  269. }
  270. function _is_only_vgm() {
  271. if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") {
  272. return TRUE;
  273. }
  274. return FALSE;
  275. }
  276. function _get_schemas() {
  277. return $_SESSION['schemas_list'];
  278. }
  279. function _getViewDocType($schemas = "public") {
  280. if ($schemas == "public") {
  281. return $_SESSION['ONLINE_USER']['view_doc_type'];
  282. } else {
  283. return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type'];
  284. }
  285. }
  286. function _getAirViewDocType($schemas = "public") {
  287. if ($schemas == "public") {
  288. return $_SESSION['ONLINE_USER']['view_air_doc_type'];
  289. } else {
  290. return $_SESSION[$schemas . '_ONLINE_USER']['view_air_doc_type'];
  291. }
  292. }
  293. function _canEdiVgm($schemas = "public") {
  294. if ($schemas == "public") {
  295. return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  296. } else {
  297. return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin();
  298. }
  299. }
  300. function _getAirStation($schemas = "public") {
  301. if ($schemas == "public") {
  302. return $_SESSION['ONLINE_USER']['air_station'];
  303. } else {
  304. return $_SESSION[$schemas . '_ONLINE_USER']['air_station'];
  305. }
  306. }
  307. function _getAirStationOr($schemas = "public") {
  308. if ($schemas == "public") {
  309. return $_SESSION['ONLINE_USER']['air_station_or'];
  310. } else {
  311. return $_SESSION[$schemas . '_ONLINE_USER']['air_station_or'];
  312. }
  313. }
  314. function _getAirSales($schemas = "public") {
  315. if ($schemas == "public") {
  316. return $_SESSION['ONLINE_USER']['air_sales'];
  317. } else {
  318. return $_SESSION[$schemas . '_ONLINE_USER']['air_sales'];
  319. }
  320. }
  321. function _getAirSalesOr($schemas = "public") {
  322. if ($schemas == "public") {
  323. return $_SESSION['ONLINE_USER']['air_sales_or'];
  324. } else {
  325. return $_SESSION[$schemas . '_ONLINE_USER']['air_sales_or'];
  326. }
  327. }
  328. function _customerAirSearchType($schemas = "public") {
  329. if ($schemas == "public") {
  330. return $_SESSION['ONLINE_USER']['air_customer_search_type'];
  331. } else {
  332. return $_SESSION[$schemas . '_ONLINE_USER']['air_customer_search_type'];
  333. }
  334. }
  335. function _getAirContactID($schemas = "public") {
  336. if ($schemas == "public") {
  337. return $_SESSION['ONLINE_USER']['air_customers'];
  338. } else {
  339. return $_SESSION[$schemas . '_ONLINE_USER']['air_customers'];
  340. }
  341. }
  342. function _customerAirFilerSearch($tableName,$schemas = "public", $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id') {
  343. $tt = _customerAirSearchType($schemas);
  344. if (empty($tt))
  345. return "1<>1";
  346. $_contact_id = _getAirContactID($schemas);
  347. if (empty($_contact_id)) {
  348. return "1<>1";
  349. }
  350. $sqlWhere1 = "";
  351. if (utils::checkExist($tt, 's') && !empty($s)) {
  352. if (empty($sqlWhere1)) {
  353. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  354. } else {
  355. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  356. }
  357. }
  358. if (utils::checkExist($tt, 'c') && !empty($c)) {
  359. if (empty($sqlWhere1)) {
  360. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  361. } else {
  362. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  363. }
  364. }
  365. if (utils::checkExist($tt, 'b') && !empty($b)) {
  366. if (empty($sqlWhere1)) {
  367. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  368. } else {
  369. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  370. }
  371. }
  372. if (utils::checkExist($tt, 'n') && !empty($n)) {
  373. if (empty($sqlWhere1)) {
  374. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  375. } else {
  376. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  377. }
  378. }
  379. //controlling_customer_code
  380. // if (utils::checkExist($tt, 't')) {
  381. // if (empty($sqlWhere1)) {
  382. // $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)";
  383. // } else {
  384. // $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)";
  385. // }
  386. // }
  387. if (utils::checkExist($tt, 't')) {
  388. if (empty($sqlWhere1)) {
  389. $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
  390. } else {
  391. $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
  392. }
  393. }
  394. if (empty($sqlWhere1))
  395. return "1<>1";
  396. $sqlWhere1 = "(" . $sqlWhere1 . ")";
  397. return $sqlWhere1;
  398. }
  399. /**
  400. * 员工的有关的group_name 和contact id 权限配置查询 ocean air 合并写
  401. * @return string sql
  402. */
  403. 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'){
  404. if($ocean_air == "ocean"){
  405. $tt = _employeeSearchType($schemas,"employee_search_type");
  406. }else{
  407. $tt = _employeeSearchType($schemas,"employee_air_search_type");
  408. }
  409. if (empty($tt))
  410. return "1<>1";
  411. $_contact_id = _getEmployeeContactID($schemas,$contact_field,$group_name_field);
  412. if (empty($_contact_id)) {
  413. return "1<>1";
  414. }
  415. $sqlWhere1 = "";
  416. if (utils::checkExist($tt, 's') && !empty($s)) {
  417. if (empty($sqlWhere1)) {
  418. $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id);
  419. } else {
  420. $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id);
  421. }
  422. }
  423. if (utils::checkExist($tt, 'c') && !empty($c)) {
  424. if (empty($sqlWhere1)) {
  425. $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id);
  426. } else {
  427. $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id);
  428. }
  429. }
  430. if (utils::checkExist($tt, 'b') && !empty($b)) {
  431. if (empty($sqlWhere1)) {
  432. $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id);
  433. } else {
  434. $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id);
  435. }
  436. }
  437. if (utils::checkExist($tt, 'n') && !empty($n)) {
  438. if (empty($sqlWhere1)) {
  439. $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id);
  440. } else {
  441. $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id);
  442. }
  443. }
  444. //controlling_customer_code
  445. // if($ocean_air == "ocean"){
  446. // if (utils::checkExist($tt, 't')) {
  447. // if (empty($sqlWhere1)) {
  448. // $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)";
  449. // } else {
  450. // $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)";
  451. // }
  452. // }
  453. // }else{
  454. // if (utils::checkExist($tt, 't')) {
  455. // if (empty($sqlWhere1)) {
  456. // $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)";
  457. // } else {
  458. // $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)";
  459. // }
  460. // }
  461. // }
  462. if (utils::checkExist($tt, 't')) {
  463. if (empty($sqlWhere1)) {
  464. $sqlWhere1 = " lower(customer_code) " . common::getInNotInSql($_contact_id);
  465. } else {
  466. $sqlWhere1 .= " or lower(customer_code) " . common::getInNotInSql($_contact_id);
  467. }
  468. }
  469. if (empty($sqlWhere1))
  470. return "1<>1";
  471. return $sqlWhere1 = "(" . $sqlWhere1 . ")";
  472. }
  473. function _isCustomerLoginHandNew($user) {
  474. return strtolower($user["user_type"]) == 'customer';
  475. }
  476. function _employeeSearchType($schemas = "public",$filed) {
  477. if ($schemas == "public") {
  478. return $_SESSION['ONLINE_USER'][$filed];
  479. } else {
  480. return $_SESSION[$schemas . '_ONLINE_USER'][$filed];
  481. }
  482. }
  483. function _getEmployeeContactID($schemas = "public",$contact_field,$group_name_field) {
  484. if(!empty($contact_field)){
  485. $contact_id_user = _getEmployeeCompanyContact($schemas,$contact_field);
  486. }
  487. $id = "";
  488. if(!empty(_getEmployeeCompany($schemas,$group_name_field))){
  489. if ($schemas == "public") {
  490. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getEmployeeCompany($schemas,$group_name_field)));
  491. } else {
  492. $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getEmployeeCompany($schemas,$group_name_field)));
  493. }
  494. }
  495. foreach ($contact_id as $v) {
  496. if (empty($id))
  497. $id = trim($v['contacts_id']);
  498. else
  499. $id .= ";" . $v['contacts_id'];
  500. }
  501. if (!empty($contact_id_user)) {
  502. $id .= ";" . $contact_id_user;
  503. }
  504. return $id;
  505. }
  506. function _getEmployeeCompanyContact($schemas = "public",$contact_field) {
  507. if ($schemas == "public") {
  508. return $_SESSION['ONLINE_USER'][$contact_field];
  509. } else {
  510. return $_SESSION[$schemas . '_ONLINE_USER'][$contact_field];
  511. }
  512. }
  513. function _getEmployeeCompany($schemas = "public",$group_name_field) {
  514. if ($schemas == "public") {
  515. return $_SESSION['ONLINE_USER'][$group_name_field];
  516. } else {
  517. return $_SESSION[$schemas . '_ONLINE_USER'][$group_name_field];
  518. }
  519. }
  520. ?>