|
|
@@ -619,8 +619,19 @@ class common {
|
|
|
$sql .= utils::getInSql($o);
|
|
|
}
|
|
|
if (!empty($d) && strtolower($d) != 'all') {
|
|
|
- $sql .= " and lower(agent)";
|
|
|
- $sql .= utils::getInSql($d);
|
|
|
+ //$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 .= " )";
|
|
|
}
|
|
|
$sqlWhere .= " and (" . $sql . ")";
|
|
|
}
|
|
|
@@ -667,8 +678,19 @@ class common {
|
|
|
$sqlWhere .= utils::getInSql($o_or);
|
|
|
}
|
|
|
if (!empty($d_or)) {
|
|
|
- $sqlWhere .= " or lower(agent)";
|
|
|
- $sqlWhere .= utils::getInSql($d_or);
|
|
|
+ //$sqlWhere .= " or lower(agent)";
|
|
|
+ //$sqlWhere .= utils::getInSql($d_or);
|
|
|
+ $inClause = utils::getInSql($d_or);
|
|
|
+ $sqlWhere .= " OR (";
|
|
|
+ $sqlWhere .= " LOWER(agent) " . $inClause;
|
|
|
+ //$sqlWhere .= " OR LOWER(to_other_stations) " . $inClause;
|
|
|
+ $sqlWhere .= " OR EXISTS(SELECT 1 FROM ".$schemas.".ocean where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
|
|
|
+ $sqlWhere .= " OR EXISTS (";
|
|
|
+ $sqlWhere .= " SELECT 1 FROM ".$schemas.".ocean_agent ";
|
|
|
+ $sqlWhere .= " WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
|
|
|
+ $sqlWhere .= " AND LOWER(ocean_agent.edi_agent) " . $inClause;
|
|
|
+ $sqlWhere .= " )";
|
|
|
+ $sqlWhere .= " )";
|
|
|
}
|
|
|
if (!empty($sales_or)) {
|
|
|
if (utils::checkExist($sales_or, ";")) {
|
|
|
@@ -748,8 +770,19 @@ class common {
|
|
|
$sql .= utils::getInSql($o);
|
|
|
}
|
|
|
if (!empty($d) && strtolower($d) != 'all') {
|
|
|
- $sql .= " and lower(agent)";
|
|
|
- $sql .= utils::getInSql($d);
|
|
|
+ //$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 .= " )";
|
|
|
}
|
|
|
$sqlWhere .= " and (" . $sql . ")";
|
|
|
}
|
|
|
@@ -790,8 +823,20 @@ class common {
|
|
|
$sqlWhere .= utils::getInSql($o_or);
|
|
|
}
|
|
|
if (!empty($d_or)) {
|
|
|
- $sqlWhere .= " or lower(agent)";
|
|
|
- $sqlWhere .= utils::getInSql($d_or);
|
|
|
+ //$sqlWhere .= " or lower(agent)";
|
|
|
+ //$sqlWhere .= utils::getInSql($d_or);
|
|
|
+
|
|
|
+ $inClause = utils::getInSql($d_or);
|
|
|
+ $sqlWhere .= " OR (";
|
|
|
+ $sqlWhere .= " LOWER(agent) " . $inClause;
|
|
|
+ //$sqlWhere .= " OR LOWER(to_other_stations) " . $inClause;
|
|
|
+ $sqlWhere .= " OR EXISTS(SELECT 1 FROM ".$schames.".ocean where ocean.serial_no = ".$tableName.".serial_no AND LOWER(ocean.to_other_stations) " . $inClause.")" ;
|
|
|
+ $sqlWhere .= " OR EXISTS (";
|
|
|
+ $sqlWhere .= " SELECT 1 FROM ".$schames.".ocean_agent ";
|
|
|
+ $sqlWhere .= " WHERE ocean_agent.serial_no = ".$tableName.".serial_no ";
|
|
|
+ $sqlWhere .= " AND LOWER(ocean_agent.edi_agent) " . $inClause;
|
|
|
+ $sqlWhere .= " )";
|
|
|
+ $sqlWhere .= " )";
|
|
|
}
|
|
|
if (!empty($sales_or)) {
|
|
|
if (utils::checkExist($sales_or, ";")) {
|