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

develop
This commit is contained in:
Laurent Destailleur 2022-10-06 12:20:32 +02:00
commit 0bb4c5701a
19 changed files with 84 additions and 65 deletions

View File

@ -25,6 +25,7 @@ WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product * The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product
* Trigger ORDER_SUPPLIER_DISPATCH is removed, use ORDER_SUPPLIER_RECEIVE and/or LINEORDER_SUPPLIER_DISPATCH instead. * Trigger ORDER_SUPPLIER_DISPATCH is removed, use ORDER_SUPPLIER_RECEIVE and/or LINEORDER_SUPPLIER_DISPATCH instead.
* All functions fetch_all() are deprecated for naming consitency, use fetchAll() instead

View File

@ -1048,7 +1048,7 @@ if (empty($reshook)) {
$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) { if ($result) {
// If there is some prices specific to the customer // If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {

View File

@ -1412,7 +1412,7 @@ class Propal extends CommonObject
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$prodcustprice = new Productcustomerprice($this->db); $prodcustprice = new Productcustomerprice($this->db);
$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $objsoc->id); $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $objsoc->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) { if ($result) {
// If there is some prices specific to the customer // If there is some prices specific to the customer
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {

View File

@ -790,7 +790,7 @@ if (empty($reshook)) {
$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result >= 0) { if ($result >= 0) {
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines[0]->price); $pu_ht = price($prodcustprice->lines[0]->price);

View File

@ -22,9 +22,9 @@
*/ */
/** /**
* \file htdocs/compta/prelevement/class/bonprelevement.class.php * \file htdocs/compta/prelevement/class/bonprelevement.class.php
* \ingroup prelevement * \ingroup prelevement
* \brief File of withdrawal receipts class * \brief File of withdrawal receipts class
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
@ -419,8 +419,8 @@ class BonPrelevement extends CommonObject
} else { } else {
$paiement = new Paiement($this->db); $paiement = new Paiement($this->db);
} }
$paiement->datepaye = $date; $paiement->datepaye = $date;
$paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice
if ($this->type == 'bank-transfer') { if ($this->type == 'bank-transfer') {
$paiement->paiementid = 2; $paiement->paiementid = 2;
@ -757,14 +757,14 @@ class BonPrelevement extends CommonObject
$error = 0; $error = 0;
$datetimeprev = time(); $datetimeprev = dol_now('gmt');
//Choice the date of the execution direct debit //Choice the date of the execution direct debit
if (!empty($executiondate)) { if (!empty($executiondate)) {
$datetimeprev = $executiondate; $datetimeprev = $executiondate;
} }
$month = strftime("%m", $datetimeprev); $month = dol_print_date($datetimeprev, "%m", 'gmt');
$year = strftime("%Y", $datetimeprev); $year = dol_print_date($datetimeprev, "%Y", 'gmt');
$this->invoice_in_error = array(); $this->invoice_in_error = array();
$this->thirdparty_in_error = array(); $this->thirdparty_in_error = array();
@ -1743,8 +1743,8 @@ class BonPrelevement extends CommonObject
// Date d'echeance C1 // Date d'echeance C1
fputs($this->file, " "); fputs($this->file, " ");
fputs($this->file, strftime("%d%m", $this->date_echeance)); fputs($this->file, dol_print_date($this->date_echeance, "%d%m", 'gmt'));
fputs($this->file, substr(strftime("%y", $this->date_echeance), 1)); fputs($this->file, substr(dol_print_date($this->date_echeance, "%y", 'gmt'), 1));
// Raison Sociale Destinataire C2 // Raison Sociale Destinataire C2
@ -1969,8 +1969,8 @@ class BonPrelevement extends CommonObject
// Date d'echeance C1 // Date d'echeance C1
fputs($this->file, " "); fputs($this->file, " ");
fputs($this->file, strftime("%d%m", $this->date_echeance)); fputs($this->file, dol_print_date($this->date_echeance, "%d%m", 'gmt'));
fputs($this->file, substr(strftime("%y", $this->date_echeance), 1)); fputs($this->file, substr(dol_print_date($this->date_echeance, "%y", 'gmt'), 1));
// Raison Sociale C2 // Raison Sociale C2

View File

@ -498,7 +498,7 @@ if (empty($reshook)) {
$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id); $filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $object->thirdparty->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) { if ($result) {
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines[0]->price); $pu_ht = price($prodcustprice->lines[0]->price);

View File

@ -1534,7 +1534,6 @@ abstract class CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return array with list of possible values for type of contacts * Return array with list of possible values for type of contacts
* *
@ -1548,7 +1547,6 @@ abstract class CommonObject
*/ */
public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '', $excludeelement = '') public function listeTypeContacts($source = 'internal', $option = 0, $activeonly = 0, $code = '', $element = '', $excludeelement = '')
{ {
// phpcs:enable
global $langs, $conf; global $langs, $conf;
$langs->loadLangs(array('bills', 'contracts', 'interventions', 'orders', 'projects', 'propal', 'ticket', 'agenda')); $langs->loadLangs(array('bills', 'contracts', 'interventions', 'orders', 'projects', 'propal', 'ticket', 'agenda'));

View File

@ -1567,7 +1567,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
$productCustomerPriceStatic = new Productcustomerprice($db); $productCustomerPriceStatic = new Productcustomerprice($db);
$filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid); $filter = array('fk_product' => $idprod, 'fk_soc' => $object->socid);
$nbCustomerPrices = $productCustomerPriceStatic->fetch_all('', '', 1, 0, $filter); $nbCustomerPrices = $productCustomerPriceStatic->fetchAll('', '', 1, 0, $filter);
if ($nbCustomerPrices > 0) { if ($nbCustomerPrices > 0) {
$productCustomerPrice = $productCustomerPriceStatic->lines[0]; $productCustomerPrice = $productCustomerPriceStatic->lines[0];

View File

@ -590,7 +590,7 @@ class Cronjob extends CommonObject
$sql .= " WHERE ".implode(' AND ', $sqlwhere); $sql .= " WHERE ".implode(' AND ', $sqlwhere);
} }
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);

View File

@ -188,7 +188,7 @@ if ($action == 'fetch' && !empty($id)) {
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid); $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) { if ($result) {
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {
$found = true; $found = true;

View File

@ -1039,7 +1039,7 @@ if (empty($reshook)) {
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id); $filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) { if ($result) {
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines [0]->price); $pu_ht = price($prodcustprice->lines [0]->price);

View File

@ -670,7 +670,7 @@ class Products extends DolibarrApi
if ($thirdparty_id) { if ($thirdparty_id) {
$filter['t.fk_soc'] .= $thirdparty_id; $filter['t.fk_soc'] .= $thirdparty_id;
} }
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
} }
if (empty($prodcustprice->lines)) { if (empty($prodcustprice->lines)) {

View File

@ -1872,7 +1872,7 @@ class Product extends CommonObject
$filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id); $filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id);
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
if ($result) { if ($result) {
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines[0]->price); $pu_ht = price($prodcustprice->lines[0]->price);

View File

@ -354,11 +354,31 @@ class Productcustomerprice extends CommonObject
* @param int $limit page * @param int $limit page
* @param int $offset offset * @param int $offset offset
* @param array $filter Filter for select * @param array $filter Filter for select
* @deprecated since dolibarr v17 use fetchAll
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array()) public function fetch_all($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array())
{ {
// phpcs:enable // phpcs:enable
dol_syslog(get_class($this)."::fetch_all is deprecated, use fetchAll instead", LOG_NOTICE);
return $this->fetchAll($sortorder, $sortfield, $limit, $offset, $filter);
}
/**
* Load all customer prices in memory from database
*
* @param string $sortorder order
* @param string $sortfield field
* @param int $limit page
* @param int $offset offset
* @param array $filter Filter for select
* @return int <0 if KO, >0 if OK
* @since dolibarr v17
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array())
{
global $langs; global $langs;
if (empty($sortfield)) { if (empty($sortfield)) {
@ -421,7 +441,7 @@ class Productcustomerprice extends CommonObject
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$this->lines = array(); $this->lines = array();
@ -832,7 +852,7 @@ class Productcustomerprice extends CommonObject
't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid 't.fk_product' => $this->fk_product, 't.fk_soc' => $obj->rowid
); );
$result = $prodsocprice->fetch_all('', '', 0, 0, $filter); $result = $prodsocprice->fetchAll('', '', 0, 0, $filter);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$this->error = $prodsocprice->error; $this->error = $prodsocprice->error;

View File

@ -2222,10 +2222,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all($sortorder, $sortfield, 0, 0, $filter); $nbtotalofrecords = $prodcustprice->fetchAll($sortorder, $sortfield, 0, 0, $filter);
} }
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) { if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }

View File

@ -243,7 +243,7 @@ $num = 0;
$title = $langs->trans('StockAtDate'); $title = $langs->trans('StockAtDate');
$sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price,'; $sql = 'SELECT p.rowid, p.ref, p.label, p.description, p.price, p.pmp,';
$sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,'; $sql .= ' p.price_ttc, p.price_base_type, p.fk_product_type, p.desiredstock, p.seuil_stock_alerte,';
$sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock, '; $sql .= ' p.tms as datem, p.duration, p.tobuy, p.stock, ';
if ($fk_warehouse > 0) { if ($fk_warehouse > 0) {
@ -565,12 +565,12 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
// PMP value // PMP value
print '<td class="right">'; print '<td class="right">';
if (price2num($objp->estimatedvalue, 'MT')) { if (price2num($stock * $objp->pmp, 'MT')) {
print '<span class="amount">'.price(price2num($objp->estimatedvalue, 'MT'), 1).'</span>'; print '<span class="amount">'.price(price2num($stock * $objp->pmp, 'MT'), 1).'</span>';
} else { } else {
print ''; print '';
} }
$totalbuyingprice += $objp->estimatedvalue; $totalbuyingprice += $stock * $objp->pmp;
print '</td>'; print '</td>';
// Selling value // Selling value

View File

@ -527,7 +527,7 @@ class Dolresource extends CommonObject
if ($limit) { if ($limit) {
$sql .= $this->db->plimit($limit, $offset); $sql .= $this->db->plimit($limit, $offset);
} }
dol_syslog(get_class($this)."::fetch_all", LOG_DEBUG); dol_syslog(get_class($this)."::fetchAll", LOG_DEBUG);
$this->lines = array(); $this->lines = array();
$resql = $this->db->query($sql); $resql = $this->db->query($sql);

View File

@ -169,7 +169,7 @@ if ($search_type != '') {
} }
// Including the previous script generate the correct SQL filter for all the extrafields // Including the previous script generate the correct SQL filter for all the extrafields
// we are playing with the behaviour of the Dolresource::fetch_all() by generating a fake // we are playing with the behaviour of the Dolresource::fetchAll() by generating a fake
// extrafields filter key to make it works // extrafields filter key to make it works
$filter['ef.resource'] = $sql; $filter['ef.resource'] = $sql;

View File

@ -532,10 +532,10 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $prodcustprice->fetch_all('', '', 0, 0, $filter); $nbtotalofrecords = $prodcustprice->fetchAll('', '', 0, 0, $filter);
} }
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter); $result = $prodcustprice->fetchAll($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) { if ($result < 0) {
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
} }