include.ini.php 21 KB

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