Skip to content

Commit

Permalink
Fix: PostgreSQL compatibilty
Browse files Browse the repository at this point in the history
Conflicts:
	htdocs/compta/prelevement/class/bonprelevement.class.php
  • Loading branch information
Juanjo Menent committed Jan 16, 2015
1 parent c5df4fd commit 93d3ffb
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions htdocs/compta/prelevement/class/bonprelevement.class.php
Expand Up @@ -893,31 +893,31 @@ function Create($banque=0, $agence=0, $mode='real')
*/
if (!$error)
{
$ref = "T".substr($year,-2).$month;

$sql = "SELECT CAST(RIGHT(ref,2) AS SIGNED INTEGER)";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
$sql.= " WHERE ref LIKE '".$ref."%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " ORDER BY ref DESC LIMIT 1";

dol_syslog(get_class($this)."::Create", LOG_DEBUG);
$resql = $this->db->query($sql);

if ($resql)
{
$row = $this->db->fetch_row($resql);
}
else
{
$error++;
dol_syslog("Erreur recherche reference");
}

$ref = $ref . substr("00".($row[0]+1), -2);
$ref = substr($year,-2).$month;

$sql = "SELECT substring(ref from char_length(ref) - 1)";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons";
$sql.= " WHERE ref LIKE '%".$ref."%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " ORDER BY ref DESC LIMIT 1";

dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);

if ($resql)
{
$row = $this->db->fetch_row($resql);
}
else
{
$error++;
dol_syslog("Erreur recherche reference");
}

$filebonprev = $ref;
$ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT);

$filebonprev = $ref;

// Create withdraw receipt in database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons (";
$sql.= " ref, entity, datec";
Expand Down

0 comments on commit 93d3ffb

Please sign in to comment.