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

This commit is contained in:
Laurent Destailleur 2020-01-04 14:21:56 +01:00
commit eca91af2ca
2 changed files with 23 additions and 7 deletions

View File

@ -2636,12 +2636,13 @@ class Product extends CommonObject
/**
* Charge tableau des stats expedition client pour le produit/service
*
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut Id statut pour filtrer sur un statut
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @return array Tableau des stats
* @param int $socid Id societe pour filtrer sur une societe
* @param string $filtrestatut [=''] Ids order status separated by comma
* @param int $forVirtualStock Ignore rights filter for virtual stock calculation.
* @param string $filterShipmentStatus [=''] Ids shipment status separated by comma
* @return int <0 if KO, >0 if OK (Tableau des stats)
*/
public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0)
public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $filterShipmentStatus = '')
{
// phpcs:enable
global $conf,$user;
@ -2671,6 +2672,7 @@ class Product extends CommonObject
if ($filtrestatut <> '') {
$sql.= " AND c.fk_statut in (".$filtrestatut.")";
}
if (!empty($filterShipmentStatus)) $sql.= " AND e.fk_statut IN (" . $filterShipmentStatus . ")";
$result = $this->db->query($sql);
if ($result ) {
@ -4464,7 +4466,14 @@ class Product extends CommonObject
}
if (! empty($conf->expedition->enabled))
{
$result=$this->load_stats_sending(0, '1,2', 1);
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
$filterShipmentStatus = '';
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
$filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED;
} elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$filterShipmentStatus = Expedition::STATUS_CLOSED;
}
$result = $this->load_stats_sending(0, '1,2', 1, $filterShipmentStatus);
if ($result < 0) dol_print_error($this->db, $this->error);
$stock_sending_client=$this->stats_expedition['qty'];
}

View File

@ -666,8 +666,15 @@ if ($id > 0 || $ref)
// Number of product from customer order already sent (partial shipping)
if (!empty($conf->expedition->enabled)) {
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
$filterShipmentStatus = '';
if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) {
$filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED;
} elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) {
$filterShipmentStatus = Expedition::STATUS_CLOSED;
}
if ($found) $helpondiff .= '<br>'; else $found = 1;
$result = $object->load_stats_sending(0, '2', 1);
$result = $object->load_stats_sending(0, '2', 1, $filterShipmentStatus);
$helpondiff .= $langs->trans("ProductQtyInShipmentAlreadySent") . ': ' . $object->stats_expedition['qty'];
}