Fix: Another fix on sql request generation.

This commit is contained in:
Laurent Destailleur 2012-11-21 19:00:06 +01:00
parent 06a8ba2be2
commit c49fea217f

View File

@ -253,18 +253,18 @@ class Export
// build the input field on depend of the type of file // build the input field on depend of the type of file
switch ($InfoFieldList[0]) { switch ($InfoFieldList[0]) {
case 'Text': case 'Text':
if (strpos($ValueField, "%") > 0) if (! (strpos($ValueField, '%') === false))
$szFilterQuery=" ".$NameField." like '".$ValueField."'"; $szFilterQuery.=" ".$NameField." LIKE '".$ValueField."'";
else else
$szFilterQuery=" ".$NameField."='".$ValueField."'"; $szFilterQuery.=" ".$NameField."='".$ValueField."'";
break; break;
case 'Date': case 'Date':
if (strpos($ValueField, "+") > 0) if (strpos($ValueField, "+") > 0)
{ {
// mode plage // mode plage
$ValueArray = explode("+", $ValueField); $ValueArray = explode("+", $ValueField);
$szFilterQuery= $this->conditionDate($NameField,$ValueArray[0],">="); $szFilterQuery ="(".$this->conditionDate($NameField,$ValueArray[0],">=");
$szFilterQuery.=" and ".$this->conditionDate($NameField,$ValueArray[1],"<="); $szFilterQuery.=" AND ".$this->conditionDate($NameField,$ValueArray[1],"<=").")";
} }
else else
{ {
@ -282,8 +282,8 @@ class Export
{ {
// mode plage // mode plage
$ValueArray = explode("+", $ValueField); $ValueArray = explode("+", $ValueField);
$szFilterQuery=$NameField.">=".$ValueArray[0]; $szFilterQuery ="(".$NameField.">=".$ValueArray[0];
$szFilterQuery.=" and ".$NameField."<=".$ValueArray[1]; $szFilterQuery.=" AND ".$NameField."<=".$ValueArray[1].")";
} }
else else
{ {
@ -337,9 +337,9 @@ class Export
{ {
$szFilterField=''; $szFilterField='';
$InfoFieldList = explode(":", $TypeField); $InfoFieldList = explode(":", $TypeField);
// build the input field on depend of the type of file // build the input field on depend of the type of file
switch ($InfoFieldList[0]) switch ($InfoFieldList[0])
{ {
case 'Text': case 'Text':
case 'Date': case 'Date':
@ -387,13 +387,13 @@ class Export
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
if ($obj->$InfoFieldList[2] == '-') if ($obj->$InfoFieldList[2] == '-')
{ {
// Discard entry '-' // Discard entry '-'
$i++; $i++;
continue; continue;
} }
$labeltoshow=dol_trunc($obj->$InfoFieldList[2],18); $labeltoshow=dol_trunc($obj->$InfoFieldList[2],18);
if (!empty($ValueField) && $ValueField == $obj->rowid) if (!empty($ValueField) && $ValueField == $obj->rowid)
{ {