Debug ENTREPOT_EXTRA_STATUS

This commit is contained in:
Laurent Destailleur 2021-06-24 11:51:10 +02:00
parent e23ce0bb97
commit 2c4fd9e409
6 changed files with 48 additions and 33 deletions

View File

@ -167,8 +167,8 @@ MovementTransferStock=Stock transfer of product %s into another warehouse
InventoryCodeShort=Inv./Mov. code
NoPendingReceptionOnSupplierOrder=No pending reception due to open purchase order
ThisSerialAlreadyExistWithDifferentDate=This lot/serial number (<strong>%s</strong>) already exists but with different eatby or sellby date (found <strong>%s</strong> but you enter <strong>%s</strong>).
OpenAll=Open for all actions
OpenInternal=Open only for internal actions
OpenAnyMovement=Open (all movement)
OpenInternal=Open (only internal movement)
UseDispatchStatus=Use a dispatch status (approve/refuse) for product lines on purchase order reception
OptionMULTIPRICESIsOn=Option "several prices per segment" is on. It means a product has several selling price so value for sell can't be calculated
ProductStockWarehouseCreated=Stock limit for alert and desired optimal stock correctly created

View File

@ -169,8 +169,8 @@ MovementTransferStock=Transfert de stock du produit %s dans un autre entrepôt
InventoryCodeShort=Code Inv./Mouv.
NoPendingReceptionOnSupplierOrder=Pas de réception en attente consécutive à des commandes fournisseurs
ThisSerialAlreadyExistWithDifferentDate=Ce lot/numéro de série (<strong>%s</strong>) existe déjà mais avec des dates de consommation ou péremption différente (trouvé <strong>%s</strong> mais vous avez entré <strong>%s</strong>).
OpenAll=Accepte tous les mouvements
OpenInternal=Limité aux mouvements internes
OpenAnyMovement=Ouvert (tous les mouvements)
OpenInternal=Ouvert (limité aux mouvements internes)
UseDispatchStatus=Utiliser un statut de contrôle (approuvé / refusé) pour les lignes de produits lors de la réception de la commande
OptionMULTIPRICESIsOn=L'option "plusieurs prix par tranches" est activée. Cela signifie qu'un produit à plusieurs prix de vente donc sa valeur de vente ne peut être calculée.
ProductStockWarehouseCreated=Alerte de limite de stock et de stock désiré ajoutée

View File

@ -5154,9 +5154,10 @@ class Product extends CommonObject
/**
* Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products)
* This function need a lot of load. If you use it on list, use a cache to execute it once for each product id.
* If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible.
* If ENTREPOT_EXTRA_STATUS is set, filtering on warehouse status is possible.
*
* @param string $option '' = Load all stock info, also from closed and internal warehouses, 'nobatch', 'novirtual'
* You can also filter on 'warehouseclosed', 'warehouseopen', 'warehouseinternal'
* @param int $includedraftpoforvirtual Include draft status of PO for virtual stock calculation
* @return int < 0 if KO, > 0 if OK
* @see load_virtual_stock(), loadBatchInfo()
@ -5170,16 +5171,20 @@ class Product extends CommonObject
$this->stock_warehouse = array();
$this->stock_theorique = 0;
// Set filter on warehouse status
$warehouseStatus = array();
if (preg_match('/warehouseclosed/', $option)) {
$warehouseStatus[] = Entrepot::STATUS_CLOSED;
$warehouseStatus[Entrepot::STATUS_CLOSED] = Entrepot::STATUS_CLOSED;
}
if (preg_match('/warehouseopen/', $option)) {
$warehouseStatus[] = Entrepot::STATUS_OPEN_ALL;
$warehouseStatus[Entrepot::STATUS_OPEN_ALL] = Entrepot::STATUS_OPEN_ALL;
}
if (preg_match('/warehouseinternal/', $option)) {
$warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL;
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
$warehouseStatus[Entrepot::STATUS_OPEN_INTERNAL] = Entrepot::STATUS_OPEN_INTERNAL;
} else {
$warehouseStatus[Entrepot::STATUS_OPEN_ALL] = Entrepot::STATUS_OPEN_ALL;
}
}
$sql = "SELECT ps.rowid, ps.reel, ps.fk_entrepot";
@ -5188,7 +5193,7 @@ class Product extends CommonObject
$sql .= " WHERE w.entity IN (".getEntity('stock').")";
$sql .= " AND w.rowid = ps.fk_entrepot";
$sql .= " AND ps.fk_product = ".$this->id;
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS) && count($warehouseStatus)) {
if (count($warehouseStatus)) {
$sql .= " AND w.statut IN (".$this->db->sanitize(implode(',', $warehouseStatus)).")";
}

View File

@ -332,7 +332,7 @@ if ($action == 'create') {
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print '<select name="statut" class="flat">';
print '<select id="warehousestatus" name="statut" class="flat">';
foreach ($object->statuts as $key => $value) {
if ($key == 1) {
print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
@ -341,6 +341,7 @@ if ($action == 'create') {
}
}
print '</select>';
print ajax_combobox('warehousestatus');
print '</td></tr>';
// Other attributes
@ -678,13 +679,13 @@ if ($action == 'create') {
}
}
//print '<td>'.dol_print_date($objp->datem).'</td>';
print '<tr class="oddeven">';
$parameters = array('obj'=>$objp);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "<td>";
$productstatic->id = $objp->rowid;
$productstatic->ref = $objp->ref;
$productstatic->label = $objp->produit;
@ -701,11 +702,13 @@ if ($action == 'create') {
$productstatic->accountancy_code_buy = $objp->accountancy_code_buy;
$productstatic->accountancy_code_buy_intra = $objp->accountancy_code_buy_intra;
$productstatic->accountancy_code_buy_export = $objp->accountancy_code_buy_export;
print "<td>";
print $productstatic->getNomUrl(1, 'stock', 16);
print '</td>';
// Label
print '<td>'.$objp->produit.'</td>';
print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($objp->produit).'">'.dol_escape_htmltag($objp->produit).'</td>';
print '<td class="right">';
$valtoshow = price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function
@ -723,10 +726,10 @@ if ($action == 'create') {
print '</td>';
}
// Price buy PMP
print '<td class="right">'.price(price2num($objp->ppmp, 'MU')).'</td>';
print '<td class="right nowraponall">'.price(price2num($objp->ppmp, 'MU')).'</td>';
// Total PMP
print '<td class="right">'.price(price2num($objp->ppmp * $objp->value, 'MT')).'</td>';
print '<td class="right amount nowraponall">'.price(price2num($objp->ppmp * $objp->value, 'MT')).'</td>';
$totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
// Price sell min
@ -871,7 +874,7 @@ if ($action == 'create') {
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>';
print '<select name="statut" class="flat">';
print '<select id="warehousestatus" name="statut" class="flat">';
foreach ($object->statuts as $key => $value) {
if ($key == $object->statut) {
print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
@ -880,6 +883,8 @@ if ($action == 'create') {
}
}
print '</select>';
print ajax_combobox('warehousestatus');
print '</td></tr>';
// Other attributes

View File

@ -173,7 +173,7 @@ class Entrepot extends CommonObject
$this->statuts[self::STATUS_CLOSED] = 'Closed2';
if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
$this->statuts[self::STATUS_OPEN_ALL] = 'OpenAll';
$this->statuts[self::STATUS_OPEN_ALL] = 'OpenAnyMovement';
$this->statuts[self::STATUS_OPEN_INTERNAL] = 'OpenInternal';
} else {
$this->statuts[self::STATUS_OPEN_ALL] = 'Opened';

View File

@ -916,6 +916,7 @@ if (!$variants) {
print '<td></td>';
print '<td></td>';
print '</tr>';
if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) {
$colspan = 3;
print '<tr class="liste_titre"><td width="14%">';
@ -979,6 +980,8 @@ if (!$variants) {
$stock_real = price2num($obj->reel, 'MS');
print '<tr class="oddeven">';
// Warehouse
print '<td colspan="4">';
print $entrepotstatic->getNomUrl(1);
if (!empty($conf->use_javascript_ajax) && !empty($conf->productbatch->enabled) && $object->hasbatch()) {
@ -987,25 +990,28 @@ if (!$variants) {
print '</a>';
}
print '</td>';
print '<td class="right">'.$stock_real.($stock_real < 0 ? ' '.img_warning() : '').'</td>';
// PMP
print '<td class="right">'.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').'</td>';
print '<td class="right nowraponall">'.(price2num($object->pmp) ? price2num($object->pmp, 'MU') : '').'</td>';
// Value purchase
print '<td class="right">'.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').'</td>';
print '<td class="right amount nowraponall">'.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').'</td>';
// Sell price
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print price(price2num($object->price, 'MU'), 1);
} else {
print $langs->trans("Variable");
print price(price2num($object->price, 'MU'), 1);
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
print $form->textwithpicto('', $langs->trans("Variable"));
}
print '</td>';
// Value sell
print '<td class="right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print price(price2num($object->price * $obj->reel, 'MT'), 1);
} else {
print $langs->trans("Variable");
print '<td class="right amount nowraponall">';
print price(price2num($object->price * $obj->reel, 'MT'), 1);
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
print $form->textwithpicto('', $langs->trans("Variable"));
}
print '</td>';
print '<td></td>';
@ -1117,10 +1123,9 @@ if (!$variants) {
print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : '&nbsp;';
print '</td>';
print '<td class="liste_total right">';
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print ($total ? price($totalvaluesell / $total, 1) : '&nbsp;');
} else {
print $langs->trans("Variable");
print ($total ? price($totalvaluesell / $total, 1) : '&nbsp;');
if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
print $form->textwithpicto('', $langs->trans("Variable"));
}
print '</td>';
// Value to sell