Enhance selection of qty to transfer/correct stock

This commit is contained in:
Laurent Destailleur 2021-10-05 20:42:52 +02:00
parent 413164f5c0
commit 36a00bc1ac
5 changed files with 48 additions and 22 deletions

View File

@ -37,7 +37,8 @@ ManufacturingDate=Manufacturing date
DestructionDate=Destruction date
FirstUseDate=First use date
QCFrequency=Quality control frequency (in days)
ShowAllLots=Show all lots
HideLots=Hide lots
#Traceability - qc status
OutOfOrder=Out of order
InWorkingOrder=In working order

View File

@ -276,9 +276,9 @@ if ($action == "correct_stock") {
$user,
$id,
GETPOST("nbpiece", 'int'),
GETPOST("mouvement"),
GETPOST("label", 'san_alpha'),
GETPOST('unitprice'),
GETPOST("mouvement", 'int'),
GETPOST("label", 'alphanohtml'),
price2num(GETPOST('unitprice'), 'MT'),
$eatby,
$sellby,
$batch,
@ -291,9 +291,9 @@ if ($action == "correct_stock") {
$user,
$id,
GETPOST("nbpiece", 'int'),
GETPOST("mouvement"),
GETPOST("label", 'san_alpha'),
GETPOST('unitprice'),
GETPOST("mouvement", "int"),
GETPOST("label", 'alphanohtml'),
price2num(GETPOST('unitprice'), 'MT'),
GETPOST('inventorycode', 'alphanohtml'),
$origin_element,
$origin_id

View File

@ -561,6 +561,8 @@ if ($id > 0 || $ref) {
if($(this).text().indexOf('+') > 0) {
$(".batch_warehouse" + id_entrepot).show();
$(this).html('(-)');
jQuery("#show_all").hide();
jQuery("#hide_all").show();
}
else {
$(".batch_warehouse" + id_entrepot).hide();
@ -574,6 +576,8 @@ if ($id > 0 || $ref) {
console.log("We click on show_all");
$("[class^=batch_warehouse]").show();
$("[class^=collapse_batch]").html('(-)');
jQuery("#show_all").hide();
jQuery("#hide_all").show();
return false;
});
@ -581,6 +585,8 @@ if ($id > 0 || $ref) {
console.log("We click on hide_all");
$("[class^=batch_warehouse]").hide();
$("[class^=collapse_batch]").html('(+)');
jQuery("#hide_all").hide();
jQuery("#show_all").show();
return false;
});
@ -938,10 +944,11 @@ if (!$variants) {
if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) {
$colspan = 3;
print '<tr class="liste_titre"><td width="14%">';
print '<tr class="liste_titre"><td class="minwidth200">';
if (!empty($conf->use_javascript_ajax)) {
print '<a id="show_all" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'</a> &nbsp; ';
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a>';
print '<a id="show_all" href="#" class="hideobject">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ShowAllLots").'</a>';
//print ' &nbsp; ';
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("HideLots").'</a>';
//print '&nbsp;'.$form->textwithpicto('', $langs->trans('CollapseBatchDetailHelp'), 1, 'help', '');
}
print '</td>';
@ -1097,7 +1104,7 @@ if (!$variants) {
}
print '<td class="right" colspan="'.$colspan.'">'.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'</td>';
print '<td colspan="4"></td>';
print '<td>';
print '<td class="center">';
if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;id_entrepot='.$entrepotstatic->id.'&amp;action=transfert&amp;pdluoid='.$pdluo->id.'">';
print img_picto($langs->trans("TransferStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"');
@ -1109,7 +1116,7 @@ if (!$variants) {
//print img_edit().'</a>';
}
print '</td>';
print '<td>';
print '<td class="center">';
if ($entrepotstatic->status != $entrepotstatic::STATUS_CLOSED) {
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;id_entrepot='.$entrepotstatic->id.'&amp;action=correction&amp;pdluoid='.$pdluo->id.'">';
print img_picto($langs->trans("CorrectStock"), 'add', 'class="hideonsmartphone paddingright" style="color: #a69944"');

View File

@ -50,8 +50,25 @@ print '<script type="text/javascript" language="javascript">
}
init_price();
jQuery("#mouvement").change(function() {
console.log("We change the direction of movement");
init_price();
});
jQuery("#nbpiece").keyup(function(event) {
console.log("We enter a qty on "+event.which);
if ( event.which == 54 ) { /* char - */
console.log("We set direction to value 1");
jQuery("#nbpiece").val(jQuery("#nbpiece").val().replace("-", ""));
jQuery("#mouvement option").removeAttr("selected").change();
jQuery("#mouvement option[value=1]").attr("selected","selected").trigger("change");
jQuery("#mouvement").trigger("change");
} else if ( event.which == 187 ) { /* char + */
console.log("We set direction to value 0");
jQuery("#mouvement option").removeAttr("selected").change();
jQuery("#mouvement option[value=0]").attr("selected","selected").trigger("change");
jQuery("#mouvement").trigger("change");
}
});
});
</script>';
@ -77,10 +94,6 @@ if ($object->element == 'product') {
$ident = $conf->global->MAIN_DEFAULT_WAREHOUSE;
}
print img_picto('', 'stock').$formproduct->selectWarehouses($ident, 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100');
print ' &nbsp; <select class="button buttongen" name="mouvement" id="mouvement">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
print '</select>';
print '</td>';
}
if ($object->element == 'stock') {
@ -88,14 +101,19 @@ if ($object->element == 'stock') {
print '<td>';
print img_picto('', 'product');
$form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500');
print ' &nbsp; <select class="button buttongen" name="mouvement" id="mouvement">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
print '</select>';
print '</td>';
}
print '<td class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td>';
print '<td><input name="nbpiece" id="nbpiece" class="maxwidth75" value="'.GETPOST("nbpiece").'"></td>';
print '<td>';
if ($object->element == 'product' || $object->element == 'stock') {
print '<select name="mouvement" id="mouvement" class="minwidth100 valignmiddle">';
print '<option value="0">'.$langs->trans("Add").'</option>';
print '<option value="1"'.(GETPOST('mouvement') ? ' selected="selected"' : '').'>'.$langs->trans("Delete").'</option>';
print '</select>';
print ajax_combobox("mouvement");
}
print '<input name="nbpiece" id="nbpiece" class="center valignmiddle maxwidth75" value="'.GETPOST("nbpiece").'">';
print '</td>';
print '</tr>';
// If product is a Kit, we ask if we must disable stock change of subproducts

View File

@ -89,7 +89,7 @@ if ($object->element == 'stock') {
print '<td class="fieldrequired">'.$langs->trans("WarehouseTarget").'</td><td>';
print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1);
print '</td></tr>';
print '<tr><td class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td colspan="3"><input type="text" name="nbpiece" size="10" value="'.dol_escape_htmltag(GETPOST("nbpiece")).'"></td>';
print '<tr><td class="fieldrequired">'.$langs->trans("NumberOfUnit").'</td><td colspan="3"><input type="text" name="nbpiece" class="center maxwidth75" value="'.dol_escape_htmltag(GETPOST("nbpiece")).'"></td>';
print '</tr>';
// Serial / Eat-by date