From aab9734f52926f86c1332729f0f466277673f598 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Mar 2019 18:03:08 +0100 Subject: [PATCH] WIP Save link to file in expensereport lines --- htdocs/expensereport/card.php | 15 ++++++++++----- .../expensereport/class/expensereport.class.php | 5 ++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 93425a65e68..fdb46b95ed9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1091,12 +1091,17 @@ if (empty($reshook)) // First save uploaded file $fk_ecm_files = 0; - if (! empty($_FILES)) + if (GETPOSTISSET('attachfile')) { - // Get ID of ECM file - $idofecmfile = 0; - - $fk_ecm_files = $idofecmfile; + $arrayoffiles=GETPOST('attachfile','array'); + if (is_array($arrayoffiles) && ! empty($arrayoffiles[0])) + { + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $relativepath='expensereport/'.$object->ref.'/'.$arrayoffiles[0]; + $ecmfiles=new EcmFiles($db); + $ecmfiles->fetch(0, '', $relativepath); + $fk_ecm_files = $ecmfiles->id; + } } // if VAT is not used in Dolibarr, set VAT rate to 0 because VAT rate is necessary. diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 7c8d7eb209e..b4da3ec760f 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1696,7 +1696,7 @@ class ExpenseReport extends CommonObject * @param int $fk_project Project id * @param int $fk_c_exp_tax_cat Car category id * @param int $type Type line - * @param int $fk_ecm_files Id of ECM file to link to this expensereport line + * @param int $fk_ecm_files Id of ECM file to link to this expensereport line * @return int <0 if KO, >0 if OK */ public function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0, $fk_ecm_files = 0) @@ -2500,6 +2500,9 @@ class ExpenseReportLine public $total_tva; public $total_ttc; + public $fk_ecm_files; + + /** * Constructor *