From c555a2c5889bbb881aa6c47eb58ad5cc34e6fed6 Mon Sep 17 00:00:00 2001 From: JC Prieto Date: Thu, 27 Feb 2020 09:32:22 +0100 Subject: [PATCH 1/7] Update translate.class.php Resolve bug #9105 When load() function loads translation file from an external modules, adds a \r simbol at the end of each line. --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 0ce761d12b8..22ae1787ee4 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -282,7 +282,7 @@ class Translate * and split the rest until a line feed. * This is more efficient than fgets + explode + trim by a factor of ~2. */ - while ($line = fscanf($fp, "%[^= ]%*[ =]%[^\n]")) + while ($line = fscanf($fp, "%[^= ]%*[ =]%[^\n\r]")) { if (isset($line[1])) { From 6ee8fa4e8a836b434d830c865b03f80b9bee7ed1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 1 Mar 2020 18:33:13 +0100 Subject: [PATCH 2/7] NEW: api invoice get by ref --- .../facture/class/api_invoices.class.php | 186 ++++++++++++------ 1 file changed, 123 insertions(+), 63 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e68966f4663..3c5c1838e6d 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2020 Thibault FOUCART * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,11 +64,66 @@ class Invoices extends DolibarrApi */ public function get($id, $contact_list = 1) { + return $this->_fetch($id, '', '', '', $contact_list); + } + + /** + * Get properties of an invoice object by ref + * + * Return an array with invoice informations + * + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException + */ + public function getByRef($ref, $contact_list = 1) + { + return $this->_fetch('', $ref, '', '', $contact_list); + } + + /** + * Get properties of an invoice object by ref_ext + * + * Return an array with invoice informations + * + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref_ext/{ref_ext} + * + * @throws RestException + */ + public function getByRefExt($ref_ext, $contact_list = 1) + { + return $this->_fetch('', '', $ref_ext, '', $contact_list); + } + + /** + * Get properties of an order object + * + * Return an array with order informations + * + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param string $ref_int Internal reference of other objec + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1) + { if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - $result = $this->invoice->fetch($id); + $result = $this->invoice->fetch($id, $ref, $ref_ext, $ref_int); if (!$result) { throw new RestException(404, 'Invoice not found'); } @@ -87,7 +143,7 @@ class Invoices extends DolibarrApi $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); - } + } /** * List invoices @@ -242,10 +298,10 @@ class Invoices extends DolibarrApi * @url POST /createfromorder/{orderid} * * @return int - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 + * @throws 400 + * @throws 401 + * @throws 404 + * @throws 405 */ public function createInvoiceFromOrder($orderid) { @@ -318,9 +374,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 Invoice not found + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 */ public function putLine($id, $lineid, $request_data = null) { @@ -382,9 +439,8 @@ class Invoices extends DolibarrApi * @url POST {id}/contact/{contactid}/{type} * * @return int - * - * @throws RestException 401 - * @throws RestException 404 + * @throws 401 + * @throws 404 */ public function postContact($id, $contactid, $type) { @@ -424,10 +480,9 @@ class Invoices extends DolibarrApi * @url DELETE {id}/contact/{rowid} * * @return array - * - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws 401 + * @throws 404 + * @throws 500 */ public function deleteContact($id, $rowid) { @@ -464,10 +519,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 + * @throws 400 + * @throws 401 + * @throws 404 + * @throws 405 */ public function deleteLine($id, $lineid) { @@ -592,9 +647,10 @@ class Invoices extends DolibarrApi * * @return int * - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 400 + * @throws 200 + * @throws 401 + * @throws 404 + * @throws 400 */ public function postLine($id, $request_data = null) { @@ -673,10 +729,11 @@ class Invoices extends DolibarrApi * * @return array * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 * */ public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) @@ -722,10 +779,11 @@ class Invoices extends DolibarrApi * * @return array * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 * */ public function settodraft($id, $idwarehouse = -1) @@ -825,10 +883,11 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 */ public function settopaid($id, $close_code = '', $close_note = '') { @@ -875,10 +934,11 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 */ public function settounpaid($id) { @@ -923,10 +983,11 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws RestException 304 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 500 + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 */ public function markAsCreditAvailable($id) { @@ -1098,10 +1159,10 @@ class Invoices extends DolibarrApi * @url POST {id}/usediscount/{discountid} * * @return int - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 + * @throws 400 + * @throws 401 + * @throws 404 + * @throws 405 */ public function useDiscount($id, $discountid) { @@ -1144,10 +1205,10 @@ class Invoices extends DolibarrApi * @url POST {id}/usecreditnote/{discountid} * * @return int - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 + * @throws 400 + * @throws 401 + * @throws 404 + * @throws 405 */ public function useCreditNote($id, $discountid) { @@ -1189,11 +1250,10 @@ class Invoices extends DolibarrApi * @url GET {id}/payments * * @return array - * - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 - * @throws RestException 405 + * @throws 400 + * @throws 401 + * @throws 404 + * @throws 405 */ public function getPayments($id) { @@ -1239,9 +1299,9 @@ class Invoices extends DolibarrApi * @url POST {id}/payments * * @return int Payment ID - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 404 + * @throws 400 + * @throws 401 + * @throws 404 */ public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { @@ -1358,10 +1418,10 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID - * @throws RestException 400 - * @throws RestException 401 - * @throws RestException 403 - * @throws RestException 404 + * @throws 400 + * @throws 401 + * @throws 403 + * @throws 404 */ public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { From b074c689a652b81d27d2db9ca9c4c441c3b8617a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 1 Mar 2020 17:35:12 +0000 Subject: [PATCH 3/7] Fixing style errors. --- htdocs/compta/facture/class/api_invoices.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 3c5c1838e6d..9a8c91b9cf2 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -66,7 +66,7 @@ class Invoices extends DolibarrApi { return $this->_fetch($id, '', '', '', $contact_list); } - + /** * Get properties of an invoice object by ref * @@ -102,7 +102,7 @@ class Invoices extends DolibarrApi { return $this->_fetch('', '', $ref_ext, '', $contact_list); } - + /** * Get properties of an order object * From de30410adc28b405470eb35a532e8109a7f30a16 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 1 Mar 2020 18:43:20 +0100 Subject: [PATCH 4/7] Update api_invoices.class.php --- .../facture/class/api_invoices.class.php | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 9a8c91b9cf2..d36022068df 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -298,10 +298,10 @@ class Invoices extends DolibarrApi * @url POST /createfromorder/{orderid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function createInvoiceFromOrder($orderid) { @@ -374,10 +374,9 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 Invoice not found */ public function putLine($id, $lineid, $request_data = null) { @@ -439,8 +438,9 @@ class Invoices extends DolibarrApi * @url POST {id}/contact/{contactid}/{type} * * @return int - * @throws 401 - * @throws 404 + * + * @throws RestException 401 + * @throws RestException 404 */ public function postContact($id, $contactid, $type) { @@ -480,9 +480,10 @@ class Invoices extends DolibarrApi * @url DELETE {id}/contact/{rowid} * * @return array - * @throws 401 - * @throws 404 - * @throws 500 + * + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function deleteContact($id, $rowid) { @@ -519,10 +520,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function deleteLine($id, $lineid) { @@ -647,10 +648,10 @@ class Invoices extends DolibarrApi * * @return int * - * @throws 200 - * @throws 401 - * @throws 404 - * @throws 400 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function postLine($id, $request_data = null) { @@ -729,11 +730,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * */ public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) @@ -779,11 +779,10 @@ class Invoices extends DolibarrApi * * @return array * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 * */ public function settodraft($id, $idwarehouse = -1) @@ -883,11 +882,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function settopaid($id, $close_code = '', $close_note = '') { @@ -934,11 +932,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 304 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 */ public function settounpaid($id) { @@ -983,11 +980,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function markAsCreditAvailable($id) { @@ -1205,10 +1201,11 @@ class Invoices extends DolibarrApi * @url POST {id}/usecreditnote/{discountid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function useCreditNote($id, $discountid) { @@ -1250,10 +1247,11 @@ class Invoices extends DolibarrApi * @url GET {id}/payments * * @return array - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function getPayments($id) { @@ -1299,9 +1297,10 @@ class Invoices extends DolibarrApi * @url POST {id}/payments * * @return int Payment ID - * @throws 400 - * @throws 401 - * @throws 404 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 */ public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { @@ -1418,10 +1417,11 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID - * @throws 400 - * @throws 401 - * @throws 403 - * @throws 404 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 403 + * @throws RestException 404 */ public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { From 844775501d12573daf650fc18b1f6c51701ea22d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 1 Mar 2020 18:46:12 +0100 Subject: [PATCH 5/7] Update api_invoices.class.php --- .../compta/facture/class/api_invoices.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index d36022068df..af69fd79008 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -651,7 +651,7 @@ class Invoices extends DolibarrApi * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 - * @throws RestException 500 + * @throws RestException 400 */ public function postLine($id, $request_data = null) { @@ -980,10 +980,10 @@ class Invoices extends DolibarrApi * * @return array An invoice object * - * @throws RestException 400 + * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 - * @throws RestException 405 + * @throws RestException 500 */ public function markAsCreditAvailable($id) { @@ -1155,10 +1155,11 @@ class Invoices extends DolibarrApi * @url POST {id}/usediscount/{discountid} * * @return int - * @throws 400 - * @throws 401 - * @throws 404 - * @throws 405 + * + * @throws RestException 400 + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 405 */ public function useDiscount($id, $discountid) { From be8ed42450d80788af7878f506865474afeb775c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 1 Mar 2020 23:17:40 +0100 Subject: [PATCH 6/7] NEW: Bookkeeping - Add link to document & pdf --- htdocs/accountancy/bookkeeping/list.php | 56 ++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index bd5b780a0b6..14b4b4d1493 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -538,6 +539,7 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) { */ $formother = new FormOther($db); +$formfile = new FormFile($db); $title_page = $langs->trans("Bookkeeping"); @@ -914,7 +916,59 @@ while ($i < min($num, $limit)) // Document ref if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''.$line->doc_ref.''; + if ($line->doc_type == 'customer_invoice') + { + $langs->loadLangs(array('bills')); + + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $objectstatic = new Facture($db); + $modulepart = 'facture'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$line->fk_doc; + $documentlink = $formfile->getDocumentsLink($modulepart, $filename, $filedir); + } + elseif ($line->doc_type == 'supplier_invoice') + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $objectstatic = new FactureFournisseur($db); + $modulepart = 'invoice_supplier'; + + $filename = dol_sanitizeFileName($line->doc_ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $subdir = get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($modulepart, $subdir, $filedir); + } + elseif ($line->doc_type == 'expense_report') + { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $objectstatic = new ExpenseReport($db); + $modulepart = 'expensereport'; + + $filename=dol_sanitizeFileName($line->doc_ref); + $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$line->fk_doc; + $documentlink = $formfile->getDocumentsLink($modulepart, $filename, $filedir); + } + + print ''; + + print ''; + // Picto + Ref + print '
'; + + if(! empty($objectstatic->id)) + { + print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + } else { + print $line->doc_ref; + } + + print $documentlink; + print '
'; + + print "\n"; if (!$i) $totalarray['nbfield']++; } From cdca4ca0aa49c2274cc8c38d09f354f1ca7910fc Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 2 Mar 2020 09:01:25 +0100 Subject: [PATCH 7/7] NEW: Bookkeeping - Add link to document & pdf --- htdocs/accountancy/bookkeeping/list.php | 34 ++++++++++++++++--------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 14b4b4d1493..9b6ad2fbbb0 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -922,34 +922,45 @@ while ($i < min($num, $limit)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $objectstatic = new Facture($db); - $modulepart = 'facture'; + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'facture'; $filename = dol_sanitizeFileName($line->doc_ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$line->fk_doc; - $documentlink = $formfile->getDocumentsLink($modulepart, $filename, $filedir); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); } elseif ($line->doc_type == 'supplier_invoice') { + $langs->loadLangs(array('bills')); + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; $objectstatic = new FactureFournisseur($db); - $modulepart = 'invoice_supplier'; + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'invoice_supplier'; $filename = dol_sanitizeFileName($line->doc_ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $subdir = get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); - $documentlink = $formfile->getDocumentsLink($modulepart, $subdir, $filedir); + $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); } elseif ($line->doc_type == 'expense_report') { + $langs->loadLangs(array('trips')); + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $objectstatic = new ExpenseReport($db); - $modulepart = 'expensereport'; + $objectstatic->fetch($line->fk_doc); + //$modulepart = 'expensereport'; $filename=dol_sanitizeFileName($line->doc_ref); $filedir=$conf->expensereport->dir_output . '/' . dol_sanitizeFileName($line->doc_ref); - $urlsource=$_SERVER['PHP_SELF'].'?id='.$line->fk_doc; - $documentlink = $formfile->getDocumentsLink($modulepart, $filename, $filedir); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$objectstatic->id; + $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + } + else + { + // Other type } print ''; @@ -958,14 +969,13 @@ while ($i < min($num, $limit)) // Picto + Ref print ''; - if(! empty($objectstatic->id)) + if($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') { print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print $documentlink; } else { print $line->doc_ref; } - - print $documentlink; print ''; print "\n";