Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-03-02 21:51:49 +01:00
commit b4dd5dd063
3 changed files with 131 additions and 6 deletions

View File

@ -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,69 @@ while ($i < min($num, $limit))
// Document ref
if (!empty($arrayfields['t.doc_ref']['checked']))
{
print '<td class="nowrap">'.$line->doc_ref.'</td>';
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);
$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='.$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);
$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($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);
$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='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
}
else
{
// Other type
}
print '<td class="nowrap">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref
print '<td class="nobordernopadding nowrap">';
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 '</td></tr></table>';
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}

View File

@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
/* Copyright (C) 2020 Thibault FOUCART <support@ptibogxiv.net>
*
* 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
@ -424,7 +480,7 @@ class Invoices extends DolibarrApi
* @url DELETE {id}/contact/{rowid}
*
* @return array
*
*
* @throws RestException 401
* @throws RestException 404
* @throws RestException 500
@ -592,6 +648,7 @@ class Invoices extends DolibarrApi
*
* @return int
*
* @throws RestException 304
* @throws RestException 401
* @throws RestException 404
* @throws RestException 400
@ -1098,6 +1155,7 @@ class Invoices extends DolibarrApi
* @url POST {id}/usediscount/{discountid}
*
* @return int
*
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@ -1144,6 +1202,7 @@ class Invoices extends DolibarrApi
* @url POST {id}/usecreditnote/{discountid}
*
* @return int
*
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@ -1189,7 +1248,7 @@ class Invoices extends DolibarrApi
* @url GET {id}/payments
*
* @return array
*
*
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@ -1239,6 +1298,7 @@ class Invoices extends DolibarrApi
* @url POST {id}/payments
*
* @return int Payment ID
*
* @throws RestException 400
* @throws RestException 401
* @throws RestException 404
@ -1358,6 +1418,7 @@ class Invoices extends DolibarrApi
* @url POST /paymentsdistributed
*
* @return int Payment ID
*
* @throws RestException 400
* @throws RestException 401
* @throws RestException 403

View File

@ -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]))
{