1"; } //error_log("_customerFilerSearchHandNew -- " . $schemas); $_contact_id = _getContactIDHandNew($user, $schemas); if (empty($_contact_id)) { return "1<>1"; } $sqlWhere1 = ""; if (utils::checkExist($tt, 's') && !empty($s)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id); } } if (utils::checkExist($tt, 'c') && !empty($c)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id); } } //暂时注释掉,ocean_booking 没有这个字段 // if (utils::checkExist($tt, 'b') && !empty($b)) { // if (empty($sqlWhere1)) { // $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id); // } else { // $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id); // } // } if (utils::checkExist($tt, 'n') && !empty($n)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id); } } //controlling_customer_code if (utils::checkExist($tt, 't')) { if (empty($sqlWhere1)) { $sqlWhere1 = " exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)"; } else { $sqlWhere1 .= " or exists(select 1 from $schemas.ocean_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)"; } } if (empty($sqlWhere1)) return "1<>1"; $sqlWhere1 = "(" . $sqlWhere1 . ")"; if (!empty($user['customer_destination']) && !empty($p)) { $sqlWhere1 .= " and lower($p) " . common::getInNotInSql($user['customer_destination']); } if (!empty($user['customer_discharge']) && !empty($d)) { $sqlWhere1 .= " and lower($d) " . common::getInNotInSql($user['customer_discharge']); } if (strtolower($sales) == 'all' || empty($sales)) { } else { if (utils::checkExist($sales, ";")) { $sql = "1!=1"; $tt = explode(";", $sales); foreach ($tt as $t) { $t = trim($t); if (!empty($t)) $sql .= " or sales_rep ilike '" . $t . "%'"; } $sqlWhere1 .= " and ($sql)"; } else $sqlWhere1 .= " and sales_rep ilike '" . $sales . "%'"; } return $sqlWhere1; } function _getContactIDHandNew_Air($user, $schemas = "public") { $contact_id_user = _getCompanyContactHandNew_Air($user); $id = ""; if ($schemas == "public") { $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user))); } else { $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas))); } foreach ($contact_id as $v) { if (empty($id)) $id = trim($v['contacts_id']); else $id .= ";" . $v['contacts_id']; } if (!empty($contact_id_user)) { $id .= ";" . $contact_id_user; } return $id; } function _getCompanyContactHandNew_Air($user, $schemas = "public") { if ($schemas == "public") { return $user['air_customers']; } else { return $user[$schemas . '_ONLINE_USER']['air_customers']; } } function _getCompanyHandNew($user, $schemas = "public") { if ($schemas == "public") { return $user['company']; } else { if (empty($user['company'])) { return $user['company_name']; } else { return $user['company']; } } } function _getContactIDHandNew($user, $schemas = "public") { $contact_id_user = _getCompanyContactHandNew($user); $id = ""; if ($schemas == "public") { $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user))); } else { $contact_id = common::excuteListSql("select contacts_id from " . $schemas . ".contacts_group_all where lower(company_name) " . utils::getInSql(_getCompanyHandNew($user, $schemas))); } foreach ($contact_id as $v) { if (empty($id)) $id = trim($v['contacts_id']); else $id .= ";" . $v['contacts_id']; } if (!empty($contact_id_user)) { $id .= ";" . $contact_id_user; } return $id; } function _getCompanyContactHandNew($user, $schemas = "public") { if ($schemas == "public") { return $user['contact_id_user']; } else { return $user[$schemas . '_ONLINE_USER']['contact_id_user']; } } function _isDemo() { return $_SESSION['ONLINE_USER']['is_demo'] == "t"; } function _is_only_vgm() { if ($_SESSION['ONLINE_USER']['is_only_vgm'] == "t") { return TRUE; } return FALSE; } function _get_schemas() { return $_SESSION['schemas_list']; } function _getViewDocType($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['view_doc_type']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['view_doc_type']; } } function _getAirViewDocType($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['view_air_doc_type']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['view_air_doc_type']; } } function _canEdiVgm($schemas = "public") { if ($schemas == "public") { return strtolower($_SESSION['ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin(); } else { return strtolower($_SESSION[$schemas . '_ONLINE_USER']['can_edi_vgm']) == 't' || _isAdmin(); } } function _getAirStation($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['air_station']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['air_station']; } } function _getAirStationOr($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['air_station_or']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['air_station_or']; } } function _getAirSales($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['air_sales']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['air_sales']; } } function _getAirSalesOr($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['air_sales_or']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['air_sales_or']; } } function _customerAirSearchType($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['air_customer_search_type']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['air_customer_search_type']; } } function _getAirContactID($schemas = "public") { if ($schemas == "public") { return $_SESSION['ONLINE_USER']['air_customers']; } else { return $_SESSION[$schemas . '_ONLINE_USER']['air_customers']; } } function _customerAirFilerSearch($schemas = "public", $s = 'shipper_id', $c = 'consignee_id', $b = 'billto_id', $n = 'notify_party_id') { $tt = _customerAirSearchType($schemas); if (empty($tt)) return "1<>1"; $_contact_id = _getAirContactID($schemas); if (empty($_contact_id)) { return "1<>1"; } $sqlWhere1 = ""; if (utils::checkExist($tt, 's') && !empty($s)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($s) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($s) " . common::getInNotInSql($_contact_id); } } if (utils::checkExist($tt, 'c') && !empty($c)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($c) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($c) " . common::getInNotInSql($_contact_id); } } if (utils::checkExist($tt, 'b') && !empty($b)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($b) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($b) " . common::getInNotInSql($_contact_id); } } if (utils::checkExist($tt, 'n') && !empty($n)) { if (empty($sqlWhere1)) { $sqlWhere1 = " lower($n) " . common::getInNotInSql($_contact_id); } else { $sqlWhere1 .= " or lower($n) " . common::getInNotInSql($_contact_id); } } //controlling_customer_code if (utils::checkExist($tt, 't')) { if (empty($sqlWhere1)) { $sqlWhere1 = " exists(select 1 from $schemas.air_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)"; } else { $sqlWhere1 .= " or exists(select 1 from $schemas.air_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($_contact_id)." limit 1)"; } } if (empty($sqlWhere1)) return "1<>1"; $sqlWhere1 = "(" . $sqlWhere1 . ")"; return $sqlWhere1; } function _isCustomerLoginHandNew($user) { return strtolower($user["user_type"]) == 'customer'; } ?>