Try to add more log to debug expense report creation error
This commit is contained in:
parent
b710e28ffa
commit
799271daa5
@ -235,23 +235,24 @@ class ExpenseReport extends CommonObject
|
|||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->lines) && count($this->lines)>0)
|
if (! $error)
|
||||||
{
|
{
|
||||||
foreach ($this->lines as $i => $val)
|
if (is_array($this->lines) && count($this->lines)>0)
|
||||||
{
|
{
|
||||||
$newndfline=new ExpenseReportLine($this->db);
|
foreach ($this->lines as $i => $val)
|
||||||
$newndfline=$this->lines[$i];
|
{
|
||||||
$newndfline->fk_expensereport=$this->id;
|
//$newndfline=new ExpenseReportLine($this->db);
|
||||||
if (! $error)
|
$newndfline=$this->lines[$i];
|
||||||
{
|
$newndfline->fk_expensereport=$this->id;
|
||||||
$result=$newndfline->insert();
|
$result=$newndfline->insert();
|
||||||
}
|
if ($result < 0)
|
||||||
if ($result < 0)
|
{
|
||||||
{
|
$this->error = $newndfline->error;
|
||||||
$error++;
|
$error++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
@ -2638,10 +2639,10 @@ class ExpenseReportLine
|
|||||||
/**
|
/**
|
||||||
* Function to get total amount in expense reports for a same rule
|
* Function to get total amount in expense reports for a same rule
|
||||||
*
|
*
|
||||||
* @param ExpenseReportRule $rule object rule to check
|
* @param ExpenseReportRule $rule object rule to check
|
||||||
* @param int $fk_user user author id
|
* @param int $fk_user user author id
|
||||||
* @param string $mode day|EX_DAY / month|EX_MON / year|EX_YEA to get amount
|
* @param string $mode day|EX_DAY / month|EX_MON / year|EX_YEA to get amount
|
||||||
* @return amount
|
* @return amount Amount
|
||||||
*/
|
*/
|
||||||
public function getExpAmount(ExpenseReportRule $rule, $fk_user, $mode = 'day')
|
public function getExpAmount(ExpenseReportRule $rule, $fk_user, $mode = 'day')
|
||||||
{
|
{
|
||||||
@ -2654,10 +2655,10 @@ class ExpenseReportLine
|
|||||||
if (!empty($this->id)) $sql.= ' AND d.rowid <> '.$this->id;
|
if (!empty($this->id)) $sql.= ' AND d.rowid <> '.$this->id;
|
||||||
$sql .= ' AND d.fk_c_type_fees = '.$rule->fk_c_type_fees;
|
$sql .= ' AND d.fk_c_type_fees = '.$rule->fk_c_type_fees;
|
||||||
if ($mode == 'day' || $mode == 'EX_DAY') $sql .= ' AND d.date = \''.dol_print_date($this->date, '%Y-%m-%d').'\'';
|
if ($mode == 'day' || $mode == 'EX_DAY') $sql .= ' AND d.date = \''.dol_print_date($this->date, '%Y-%m-%d').'\'';
|
||||||
elseif ($mode == 'mon' || $mode == 'EX_MON') $sql .= ' AND DATE_FORMAT(d.date, \'%Y-%m\') = \''.dol_print_date($this->date, '%Y-%m').'\'';
|
elseif ($mode == 'mon' || $mode == 'EX_MON') $sql .= ' AND DATE_FORMAT(d.date, \'%Y-%m\') = \''.dol_print_date($this->date, '%Y-%m').'\''; // @TODO DATE_FORMAT is forbidden
|
||||||
elseif ($mode == 'year' || $mode == 'EX_YEA') $sql .= ' AND DATE_FORMAT(d.date, \'%Y\') = \''.dol_print_date($this->date, '%Y').'\'';
|
elseif ($mode == 'year' || $mode == 'EX_YEA') $sql .= ' AND DATE_FORMAT(d.date, \'%Y\') = \''.dol_print_date($this->date, '%Y').'\''; // @TODO DATE_FORMAT is forbidden
|
||||||
|
|
||||||
dol_syslog('ExpenseReportLine::getExpAmountByDay sql='.$sql);
|
dol_syslog('ExpenseReportLine::getExpAmount');
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -2674,19 +2675,18 @@ class ExpenseReportLine
|
|||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $amount + $this->total_ttc;
|
return $amount + $this->total_ttc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update
|
* update
|
||||||
*
|
*
|
||||||
* @param User $fuser User
|
* @param User $user User
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function update($fuser)
|
public function update(User $user)
|
||||||
{
|
{
|
||||||
global $fuser,$langs,$conf;
|
global $langs,$conf;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user