Merge pull request #17343 from atm-gauthier/develop_new_collapse_batch_detail

NEW : collapse batch detail
This commit is contained in:
Laurent Destailleur 2021-05-25 23:04:50 +02:00 committed by GitHub
commit f252748dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 73 additions and 7 deletions

View File

@ -743,6 +743,21 @@ if ($conf->use_javascript_ajax) {
}
print "</td>\n";
print "</tr>\n";
if (!empty($conf->productbatch->enabled)) {
print '<tr class="oddeven">';
print '<td>' . $langs->trans("ShowAllBatchByDefault") . '</td>';
print '<td class="right">';
if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_SHOW_ALL_BATCH_BY_DEFAULT');
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_SHOW_ALL_BATCH_BY_DEFAULT", $arrval, $conf->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT);
}
print "</td>\n";
print "</tr>\n";
}
print '</table>';
print '</form>';

View File

@ -244,21 +244,21 @@ if (!empty($conf->projet->enabled)) {
if (!empty($conf->contrat->enabled)) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."contrat as c on f.fk_contrat = c.rowid";
}
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (f.rowid = ef.fk_object)";
}
if (empty($conf->global->FICHINTER_DISABLE_DETAILS) && $atleastonefieldinlines) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."fichinterdet as fd ON fd.fk_fichinter = f.rowid";
}
// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;
if (!$user->rights->societe->client->voir && empty($socid)) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.fk_soc = s.rowid";

View File

@ -252,4 +252,6 @@ ReOpen=Reopen
ConfirmFinish=Do you confirm the closing of the inventory ? This will generate all stock movements to update your stock to the real qty you entered into the inventory.
ObjectNotFound=%s not found
MakeMovementsAndClose=Generate movements and close
AutofillWithExpected=Fill real quantity with expected quantity
AutofillWithExpected=Fill real quantity with expected quantity
ShowAllBatchByDefault=By default, show batch details on product "stock" tab
CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration

View File

@ -91,7 +91,7 @@ NoPredefinedProductToDispatch=Pas de produits prédéfinis dans cet objet. Aucun
DispatchVerb=Ventiler
StockLimitShort=Limite pour alerte
StockLimit=Limite stock pour alerte
StockLimitDesc=(empty) means no warning.<br>0 can be used to trigger a warning as soon as the stock is empty.
StockLimitDesc=(vide) n'affichera aucune icone d'alerte. <br>0 peut être saisi pour afficher une alerte en cas de stock nul.
PhysicalStock=Stock physique
RealStock=Stock réel
RealStockDesc=Le stock physique ou réel est le stock présent dans les entrepôts.
@ -255,3 +255,5 @@ ConfirmFinish=Confirmez-vous la clôture de linventaire? Ceci générera tous
ObjectNotFound=%s introuvable
MakeMovementsAndClose=Générer les mouvements et fermer
AutofillWithExpected=Remplir la quantité réelle avec la quantité prévue
ShowAllBatchByDefault=Dérouler par défaut le détail des lots dans l'onglet "stock"
CollapseBatchDetailHelp=Vous pouvez définir l'affichage par défaut du détail des lots dans la configuration du module stocks

View File

@ -9,6 +9,7 @@
* Copyright (C) 2014-2015 Cédric Gross <c.gross@kreiz-it.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
*
* 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
@ -530,6 +531,44 @@ if ($id > 0 || $ref) {
llxHeader('', $title, $helpurl);
?>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$(".collapse_batch").click(function() {
var id_entrepot = $(this).attr('id').replace('ent', '');
if($(this).text().indexOf('+') > 0) {
$(".batch_warehouse" + id_entrepot).show();
$(this).html('(-)&nbsp;');
}
else {
$(".batch_warehouse" + id_entrepot).hide();
$(this).html('(+)&nbsp;');
}
return false;
});
$("#show_all").click(function() {
$("[class^=batch_warehouse]").show();
$("[class^=collapse_batch]").html('(-)&nbsp;');
return false;
});
$("#hide_all").click(function() {
$("[class^=batch_warehouse]").hide();
$("[class^=collapse_batch]").html('(+)&nbsp;');
return false;
});
});
</script>
<?php
if ($result > 0) {
$head = product_prepare_head($object);
$titre = $langs->trans("CardProduct".$object->type);
@ -868,7 +907,11 @@ if (!$variants) {
print '</tr>';
if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) {
$colspan = 3;
print '<tr class="liste_titre"><td class="width25"></td>';
print '<tr class="liste_titre"><td width="14%">';
print '<a id="show_all" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'</a><br>';
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a>&nbsp;';
print $form->textwithpicto('', $langs->trans('CollapseBatchDetailHelp'), 1, 'help', '');
print '</td>';
print '<td class="right">'.$langs->trans("batch_number").'</td>';
if (empty($conf->global->PRODUCT_DISABLE_EATBY)) {
$colspan--;
@ -923,7 +966,11 @@ if (!$variants) {
$stock_real = price2num($obj->reel, 'MS');
print '<tr class="oddeven">';
print '<td colspan="4">'.$entrepotstatic->getNomUrl(1).'</td>';
print '<td colspan="4">';
if (!empty($conf->productbatch->enabled)) {
print '<a class="collapse_batch" id="ent' . $entrepotstatic->id . '" href="#">' . (empty($conf->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT) ? '(+)' : '(-)') . '&nbsp;</a>';
}
print $entrepotstatic->getNomUrl(1).'</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>';
@ -993,7 +1040,7 @@ if (!$variants) {
print '<td></td>';
print '</tr>';
} else {
print "\n".'<tr><td class="left">';
print "\n".'<tr style="display:'.(empty($conf->global->STOCK_SHOW_ALL_BATCH_BY_DEFAULT) ? 'none' : 'visible').';" class="batch_warehouse'.$entrepotstatic->id.'"><td class="left">';
print '</td>';
print '<td class="right nowraponall">';
print $product_lot_static->getNomUrl(1);