include.ini.php 21 KB

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