Skip to content

Commit

Permalink
Fix error management
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Apr 14, 2017
1 parent e2c31b5 commit cbc6684
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions htdocs/expensereport/class/expensereport.class.php
Expand Up @@ -129,6 +129,13 @@ function create($user, $notrigger=0)

$error = 0;

// Check parameters
if (empty($this->date_debut) || empty($this->date_fin))
{
$this->error='ErrorFieldRequired';
return -1;
}

$fuserid = $this->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
if (empty($fuserid)) $fuserid = $user->id;

Expand Down Expand Up @@ -170,15 +177,13 @@ function create($user, $notrigger=0)
$sql.= ", ".$conf->entity;
$sql.= ")";

dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
$this->ref='(PROV'.$this->id.')';

$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET ref='".$this->ref."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create sql=".$sql);
$resql=$this->db->query($sql);
if (!$resql) $error++;

Expand Down

0 comments on commit cbc6684

Please sign in to comment.