Fix: PostgreSQL compatibilty

This commit is contained in:
Juanjo Menent 2015-01-16 17:41:56 +01:00
parent d1a0187f82
commit fe5533d1c3

View File

@ -890,11 +890,11 @@ class BonPrelevement extends CommonObject
*/ */
if (!$error) if (!$error)
{ {
$ref = "T".substr($year,-2).$month; $ref = substr($year,-2).$month;
$sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)"; $sql = "SELECT substring(ref from char_length(ref) - 1)";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
$sql.= " WHERE ref LIKE '".$ref."%'"; $sql.= " WHERE ref LIKE '%".$ref."%'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
$sql.= " ORDER BY ref DESC LIMIT 1"; $sql.= " ORDER BY ref DESC LIMIT 1";
@ -911,7 +911,7 @@ class BonPrelevement extends CommonObject
dol_syslog("Erreur recherche reference"); dol_syslog("Erreur recherche reference");
} }
$ref = $ref . substr("00".($row[0]+1), -2); $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT);
$filebonprev = $ref; $filebonprev = $ref;