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

This commit is contained in:
Laurent Destailleur 2021-12-09 09:54:09 +01:00
commit f4d7cbe045
2 changed files with 22 additions and 5 deletions

View File

@ -1082,7 +1082,7 @@ if (empty($reshook)) {
}
// Set status of reception (complete, partial, ...)
if ($action == 'livraison' && $usercanreceived) {
if ($action == 'livraison' && $usercanreceive) {
if ($cancel) {
$action = '';
} else {
@ -2510,7 +2510,7 @@ if ($action == 'create') {
}
if (in_array($object->statut, array(3, 4, 5))) {
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceived) {
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) && $usercanreceive) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id.'">'.$labelofbutton.'</a></div>';
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$labelofbutton.'</a></div>';
@ -2528,7 +2528,7 @@ if ($action == 'create') {
// Classify received (this does not record reception)
if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) {
if ($usercanreceived) {
if ($usercanreceive) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&token='.newToken().'&action=classifyreception#classifyreception">'.$langs->trans("ClassifyReception").'</a></div>';
}
}
@ -2647,7 +2647,7 @@ if ($action == 'create') {
print '</div><div class="fichehalfright">';
if ($action == 'classifyreception') {
if ($usercanreceived && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) {
if ($usercanreceive && ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY)) {
// Set status to received (action=livraison)
print '<!-- form to record purchase order received -->'."\n";
print '<form id="classifyreception" action="card.php?id='.$object->id.'" method="post">';

View File

@ -172,9 +172,10 @@ class Products extends DolibarrApi
* @param bool $ids_only Return only IDs of product instead of all properties (faster, above all if list is long)
* @param int $variant_filter Use this param to filter list (0 = all, 1=products without variants, 2=parent of variants, 3=variants only)
* @param bool $pagination_data If this parameter is set to true the response will include pagination data. Default value is false. Page starts from 0
* @param int $includestockdata Load also information about stock (slower)
* @return array Array of product objects
*/
public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false)
public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '', $ids_only = false, $variant_filter = 0, $pagination_data = false, $includestockdata = 0)
{
global $db, $conf;
@ -249,6 +250,21 @@ class Products extends DolibarrApi
if (!$ids_only) {
$product_static = new Product($this->db);
if ($product_static->fetch($obj->rowid)) {
if ($includestockdata && DolibarrApiAccess::$user->rights->stock->lire) {
$product_static->load_stock();
if (is_array($product_static->stock_warehouse)) {
foreach ($product_static->stock_warehouse as $keytmp => $valtmp) {
if (is_array($product_static->stock_warehouse[$keytmp]->detail_batch)) {
foreach ($product_static->stock_warehouse[$keytmp]->detail_batch as $keytmp2 => $valtmp2) {
unset($product_static->stock_warehouse[$keytmp]->detail_batch[$keytmp2]->db);
}
}
}
}
}
$obj_ret[] = $this->_cleanObjectDatas($product_static);
}
} else {
@ -1948,6 +1964,7 @@ class Products extends DolibarrApi
if (empty(DolibarrApiAccess::$user->rights->stock->lire)) {
unset($object->stock_reel);
unset($object->stock_theorique);
unset($object->stock_warehouse);
}
return $object;