include.ini.php 21 KB

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