diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 307294d5422..9d9eebae245 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -2042,25 +2042,25 @@ if ($action == 'create') {
if (!empty($object->lines)) {
$i = 0; $total = 0;
- print '
';
// Num
- print '| ';
+ print ' | ';
print $numline;
print ' | ';
// Date
- print ''.dol_print_date($db->jdate($line->date), 'day').' | ';
+ print ''.dol_print_date($db->jdate($line->date), 'day').' | ';
// Project
if (!empty($conf->projet->enabled)) {
- print '';
+ print ' | ';
if ($line->fk_project > 0) {
$projecttmp->id = $line->fk_project;
$projecttmp->ref = $line->projet_ref;
@@ -2118,26 +2118,26 @@ if ($action == 'create') {
}
// Type of fee
- print ' | ';
+ print ' | ';
$labeltype = ($langs->trans(($line->type_fees_code)) == $line->type_fees_code ? $line->type_fees_libelle : $langs->trans($line->type_fees_code));
print $labeltype;
print ' | ';
// IK
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
- print '';
+ print ' | ';
print dol_getIdFromCode($db, $line->fk_c_exp_tax_cat, 'c_exp_tax_cat', 'rowid', 'label');
print ' | ';
}
// Comment
- print ''.dol_nl2br($line->comments).' | ';
+ print '';
// VAT rate
- print ''.vatrate($line->vatrate.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), true).' | ';
+ print ''.vatrate($line->vatrate.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), true).' | ';
// Unit price HT
- print '';
+ print ' | ';
if (!empty($line->value_unit_ht)) {
print price($line->value_unit_ht);
} else {
@@ -2147,17 +2147,17 @@ if ($action == 'create') {
}
print ' | ';
- print ''.price($line->value_unit).' | ';
+ print ''.price($line->value_unit).' | ';
- print ''.dol_escape_htmltag($line->qty).' | ';
+ print ''.dol_escape_htmltag($line->qty).' | ';
if ($action != 'editline') {
- print ''.price($line->total_ht).' | ';
- print ''.price($line->total_ttc).' | ';
+ print ''.price($line->total_ht).' | ';
+ print ''.price($line->total_ttc).' | ';
}
// Column with preview
- print '';
+ print ' | ';
if ($line->fk_ecm_files > 0) {
$modulepart = 'expensereport';
$maxheightmini = 32;
@@ -2227,13 +2227,13 @@ if ($action == 'create') {
}
print ' | ';
- print '';
+ print ' | ';
print !empty($line->rule_warning_message) ? img_warning(html_entity_decode($line->rule_warning_message)) : ' ';
print ' | ';
// Ajout des boutons de modification/suppression
if (($object->status < ExpenseReport::STATUS_VALIDATED || $object->status == ExpenseReport::STATUS_REFUSED) && $user->rights->expensereport->creer) {
- print '';
+ print ' | ';
print 'id.'&action=editline&token='.newToken().'&rowid='.$line->rowid.'">';
print img_edit();
@@ -2420,7 +2420,7 @@ if ($action == 'create') {
// Add line with link to add new file or attach to an existing file
print '';
- print '| ';
+ print ' | ';
print ''.$langs->trans("UploadANewFileNow");
print img_picto($langs->trans("UploadANewFileNow"), 'chevron-down', '', false, 0, 0, '', 'marginleftonly');
print '';
@@ -2473,21 +2473,21 @@ if ($action == 'create') {
include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_linktofile.tpl.php';
include DOL_DOCUMENT_ROOT.'/expensereport/tpl/expensereport_addfile.tpl.php';
- print ' | ';
+ print ' ';
print ' | ';
- print ''.$langs->trans('Date').' | ';
+ print ''.$langs->trans('Date').' | ';
if (!empty($conf->projet->enabled)) {
print ''.$form->textwithpicto($langs->trans('Project'), $langs->trans("ClosedProjectsAreHidden")).' | ';
}
- print ''.$langs->trans('Type').' | ';
+ print ''.$langs->trans('Type').' | ';
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
print ''.$langs->trans('CarCategory').' | ';
}
- print ''.$langs->trans('Description').' | ';
- print ''.$langs->trans('VAT').' | ';
- print ''.$langs->trans('PriceUHT').' | ';
- print ''.$langs->trans('PriceUTTC').' | ';
- print ''.$langs->trans('Qty').' | ';
+ print ''.$langs->trans('Description').' | ';
+ print ''.$langs->trans('VAT').' | ';
+ print ''.$langs->trans('PriceUHT').' | ';
+ print ''.$langs->trans('PriceUTTC').' | ';
+ print ''.$langs->trans('Qty').' | ';
print ' | ';
print ' | ';
print ' | ';
diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php
index be49b0a8c0c..b85691c586d 100644
--- a/htdocs/expensereport/class/expensereport.class.php
+++ b/htdocs/expensereport/class/expensereport.class.php
@@ -2752,6 +2752,17 @@ class ExpenseReportLine
if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'expensereport_det');
+
+ if (!$error && !$notrigger) {
+ // Call triggers
+ $result = $this->call_trigger('EXPENSE_REPORT_DET_CREATE', $user);
+ if ($result < 0) {
+ $error++;
+ }
+ // End call triggers
+ }
+
+
if (!$fromaddline) {
$tmpparent = new ExpenseReport($this->db);
$tmpparent->fetch($this->fk_expensereport);
@@ -2908,4 +2919,39 @@ class ExpenseReportLine
return -2;
}
}
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Call trigger based on this instance.
+ * Some context information may also be provided into array property this->context.
+ * NB: Error from trigger are stacked in interface->errors
+ * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction.
+ *
+ * @param string $triggerName trigger's name to execute
+ * @param User $user Object user
+ * @return int Result of run_triggers
+ */
+ public function call_trigger($triggerName, $user)
+ {
+ // phpcs:enable
+ global $langs, $conf;
+
+ if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
+ include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
+ $langs = new Translate('', $conf);
+ }
+
+ include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
+ $interface = new Interfaces($this->db);
+ $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf);
+
+ if ($result < 0) {
+ if (!empty($this->errors)) {
+ $this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
+ } else {
+ $this->errors = $interface->errors;
+ }
+ }
+ return $result;
+ }
}
|