Skip to content
Snippets Groups Projects
Commit a4edaf4f authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix sql to get next ref on expense report

parent c635baa8
No related tags found
No related merge requests found
...@@ -1207,15 +1207,14 @@ class ExpenseReport extends CommonObject ...@@ -1207,15 +1207,14 @@ class ExpenseReport extends CommonObject
$expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR; $expld_car = (empty($conf->global->NDF_EXPLODE_CHAR))?"-":$conf->global->NDF_EXPLODE_CHAR;
$num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF; $num_car = (empty($conf->global->NDF_NUM_CAR_REF))?"5":$conf->global->NDF_NUM_CAR_REF;
$sql = 'SELECT de.ref_number_int'; $sql = 'SELECT MAX(de.ref_number_int) as max';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' de'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' de';
$sql.= ' ORDER BY de.ref_number_int DESC';
$result = $this->db->query($sql); $result = $this->db->query($sql);
if($this->db->num_rows($result) > 0): if($this->db->num_rows($result) > 0):
$objp = $this->db->fetch_object($result); $objp = $this->db->fetch_object($result);
$this->ref = $objp->ref_number_int; $this->ref = $objp->max;
$this->ref++; $this->ref++;
while(strlen($this->ref) < $num_car): while(strlen($this->ref) < $num_car):
$this->ref = "0".$this->ref; $this->ref = "0".$this->ref;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment