|
|
@@ -457,6 +457,33 @@ class common {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 不转小写
|
|
|
+ */
|
|
|
+ public static function getInNotInSqlForSearchWithoutLower($contact_id, $type = 'in') {
|
|
|
+ if (empty($contact_id))
|
|
|
+ return " =''";
|
|
|
+ $contact_id = trim($contact_id);
|
|
|
+ $contact_id = trim($contact_id, ";");
|
|
|
+ $contact_id = trim($contact_id);
|
|
|
+ if ($type == 'in') {
|
|
|
+ if (utils::checkExist($contact_id, ";")) {
|
|
|
+ $ss = "";
|
|
|
+ $aa = explode(";", $contact_id);
|
|
|
+ foreach ($aa as $k => $v) {
|
|
|
+ $v = trim($v);
|
|
|
+ if (empty($ss))
|
|
|
+ $ss = "'" . common::check_input($v) . "'";
|
|
|
+ else
|
|
|
+ $ss .= ",'" . common::check_input($v) . "'";
|
|
|
+ }
|
|
|
+ return $ss;
|
|
|
+ } else {
|
|
|
+ return "'" . common::check_input($contact_id) . "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
* Encrypt a SQL query statement used to be passed as a parameter to get excel output
|
|
|
encode :DeCode('str','E');
|
|
|
@@ -621,17 +648,9 @@ class common {
|
|
|
if (!empty($d) && strtolower($d) != 'all') {
|
|
|
//$sql .= " and lower(agent)";
|
|
|
//$sql .= utils::getInSql($d);
|
|
|
- $inClause = utils::getInSql($d);
|
|
|
- $sql .= " AND (";
|
|
|
- $sql .= " LOWER(agent) " . $inClause;
|
|
|
- //$sql .= " OR LOWER(to_other_stations) " . $inClause;
|
|
|
- $sql .= " OR EXISTS(SELECT 1 FROM ".$schemas.".ocean where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
|
|
|
- $sql .= " OR EXISTS (";
|
|
|
- $sql .= " SELECT 1 FROM ".$schemas.".ocean_agent ";
|
|
|
- $sql .= " WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
|
|
|
- $sql .= " AND LOWER(ocean_agent.edi_agent) " . $inClause;
|
|
|
- $sql .= " )";
|
|
|
- $sql .= " )";
|
|
|
+ $inClause = common::getInNotInSqlForSearchWithoutLower($d);
|
|
|
+ $arrayLiteral = 'ARRAY[' . $inClause . ']::text[]';
|
|
|
+ $sql .= " and edi_agent && $arrayLiteral";
|
|
|
}
|
|
|
$sqlWhere .= " and (" . $sql . ")";
|
|
|
}
|
|
|
@@ -772,17 +791,9 @@ class common {
|
|
|
if (!empty($d) && strtolower($d) != 'all') {
|
|
|
//$sql .= " and lower(agent)";
|
|
|
//$sql .= utils::getInSql($d);
|
|
|
- $inClause = utils::getInSql($d);
|
|
|
- $sql .= " AND (";
|
|
|
- $sql .= " LOWER(agent) " . $inClause;
|
|
|
- //$sql .= " OR LOWER(to_other_stations) " . $inClause;
|
|
|
- $sql .= " OR EXISTS(SELECT 1 FROM ".$schames.".ocean where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
|
|
|
- $sql .= " OR EXISTS (";
|
|
|
- $sql .= " SELECT 1 FROM ".$schames.".ocean_agent ";
|
|
|
- $sql .= " WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
|
|
|
- $sql .= " AND LOWER(ocean_agent.edi_agent) " . $inClause;
|
|
|
- $sql .= " )";
|
|
|
- $sql .= " )";
|
|
|
+ $inClause = common::getInNotInSqlForSearchWithoutLower($d);
|
|
|
+ $arrayLiteral = 'ARRAY[' . $inClause . ']::text[]';
|
|
|
+ $sql .= " and edi_agent && $arrayLiteral";
|
|
|
}
|
|
|
$sqlWhere .= " and (" . $sql . ")";
|
|
|
}
|
|
|
@@ -2618,24 +2629,12 @@ class common {
|
|
|
$sqlWhere = " 1<>1 ";
|
|
|
foreach($customerType as $value){
|
|
|
//controlling_customer_code
|
|
|
- if ($value == 'customer_code') {
|
|
|
- if ($specialType == "container_bar") {
|
|
|
- $tempSql = " case when order_from = 'public'
|
|
|
- then (exists(select 1 from public.ocean_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
+ if ($value == 'customer_code' && $specialType == "container_bar") {
|
|
|
+ $tempSql = " case when order_from = 'public'
|
|
|
+ then (exists(select 1 from public.ocean_extend ex where ex.serial_no = online_container.serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
when order_from = 'sfs'
|
|
|
- then (exists(select 1 from sfs.ocean_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
+ then (exists(select 1 from sfs.ocean_extend ex where ex.serial_no = online_container.serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
else 1<>1 end ";
|
|
|
- } else {
|
|
|
- $tempSql = " case when transport_mode = 'sea' and order_from = 'public'
|
|
|
- then (exists(select 1 from public.ocean_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
- when transport_mode = 'sea' and order_from = 'sfs'
|
|
|
- then (exists(select 1 from sfs.ocean_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
- when transport_mode = 'air' and order_from = 'public'
|
|
|
- then (exists(select 1 from public.air_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
- when transport_mode = 'air' and order_from = 'sfs'
|
|
|
- then (exists(select 1 from sfs.air_extend ex where ex.serial_no = serial_no and lower(ex.customer_code) " . common::getInNotInSql($contactId)." limit 1))
|
|
|
- else 1<>1 end ";
|
|
|
- }
|
|
|
$sqlWhere .= " or ($tempSql)";
|
|
|
} else {
|
|
|
$sqlWhere .= " or lower(".$value.") ". common::getInNotInSql($contactId);
|