Fix reception of product interface

This commit is contained in:
Laurent Destailleur 2017-06-27 13:57:41 +02:00
parent 1fafa4017d
commit 77ba5a8c24
6 changed files with 92 additions and 56 deletions

View File

@ -260,6 +260,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
} }
} }
/* /*
* View * View
*/ */
@ -284,7 +285,7 @@ if ($id > 0 || ! empty($ref)) {
$head = ordersupplier_prepare_head($object); $head = ordersupplier_prepare_head($object);
$title = $langs->trans("SupplierOrder"); $title = $langs->trans("SupplierOrder");
dol_fiche_head($head, 'dispatch', $title, 0, 'order'); dol_fiche_head($head, 'dispatch', $title, -1, 'order');
// Supplier order card // Supplier order card
@ -434,6 +435,7 @@ if ($id > 0 || ! empty($ref)) {
print '<td align="right">' . $langs->trans("QtyOrdered") . '</td>'; print '<td align="right">' . $langs->trans("QtyOrdered") . '</td>';
print '<td align="right">' . $langs->trans("QtyDispatchedShort") . '</td>'; print '<td align="right">' . $langs->trans("QtyDispatchedShort") . '</td>';
print '<td align="right">' . $langs->trans("QtyToDispatchShort") . '</td>'; print '<td align="right">' . $langs->trans("QtyToDispatchShort") . '</td>';
print '<td width="32"></td>';
print '<td align="right">' . $langs->trans("Warehouse") . '</td>'; print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
print "</tr>\n"; print "</tr>\n";
@ -443,7 +445,7 @@ if ($id > 0 || ! empty($ref)) {
print '<td>' . $langs->trans("batch_number") . '</td>'; print '<td>' . $langs->trans("batch_number") . '</td>';
print '<td>' . $langs->trans("EatByDate") . '</td>'; print '<td>' . $langs->trans("EatByDate") . '</td>';
print '<td>' . $langs->trans("SellByDate") . '</td>'; print '<td>' . $langs->trans("SellByDate") . '</td>';
print '<td colspan="4">&nbsp;</td>'; print '<td colspan="5">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
@ -456,7 +458,7 @@ if ($id > 0 || ! empty($ref)) {
while ( $i < $num ) { while ( $i < $num ) {
$objp = $db->fetch_object($resql); $objp = $db->fetch_object($resql);
// On n'affiche pas les produits personnalises // On n'affiche pas les produits libres
if (! $objp->fk_product > 0) { if (! $objp->fk_product > 0) {
$nbfreeproduct++; $nbfreeproduct++;
} else { } else {
@ -511,7 +513,11 @@ if ($id > 0 || ! empty($ref)) {
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) { if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
$type = 'batch'; $type = 'batch';
print '<td align="right">' . img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column print '<td align="right">';
print '</td>'; // Qty to dispatch
print '<td>';
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // Warehouse column print '<td></td>'; // Warehouse column
print '</tr>'; print '</tr>';
@ -536,7 +542,7 @@ if ($id > 0 || ! empty($ref)) {
print '</td>'; print '</td>';
print '<td>'; print '<td>';
print '<input type="text" id="lot_number' . $suffix . '" name="lot_number' . $suffix . '" size="40" value="' . GETPOST('lot_number' . $suffix) . '">'; print '<input type="text" class="inputlotnumber" id="lot_number' . $suffix . '" name="lot_number' . $suffix . '" size="40" value="' . GETPOST('lot_number' . $suffix) . '">';
print '</td>'; print '</td>';
print '<td>'; print '<td>';
$dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year')); $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year'));
@ -549,8 +555,12 @@ if ($id > 0 || ! empty($ref)) {
print '<td colspan="2">&nbsp</td>'; // Qty ordered + qty already dispatached print '<td colspan="2">&nbsp</td>'; // Qty ordered + qty already dispatached
} else { } else {
$type = 'dispatch'; $type = 'dispatch';
print '<td align="right">' . img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column print '<td align="right">';
print '<td></td>'; print '</td>'; // Qty to dispatch
print '<td>';
//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // Warehouse column
print '</tr>'; print '</tr>';
print '<tr class="oddeven" name="' . $type . $suffix . '">'; print '<tr class="oddeven" name="' . $type . $suffix . '">';
@ -573,17 +583,32 @@ if ($id > 0 || ! empty($ref)) {
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">'; print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">';
print '</td>'; print '</td>';
} }
// Dispatch
// Qty to dispatch
print '<td align="right">'; print '<td align="right">';
print '<input id="qty' . $suffix . '" name="qty' . $suffix . '" type="text" size="8" value="' . (GETPOST('qty' . $suffix) != '' ? GETPOST('qty' . $suffix) : $remaintodispatch) . '">'; print '<input id="qty' . $suffix . '" name="qty' . $suffix . '" type="text" size="8" value="' . (GETPOST('qty' . $suffix) != '' ? GETPOST('qty' . $suffix) : $remaintodispatch) . '">';
print '</td>';
print '<td>';
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
$type = 'batch';
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
}
else
{
$type = 'dispatch';
print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
}
print '</td>'; print '</td>';
// Warehouse // Warehouse
print '<td align="right">'; print '<td align="right">';
if (count($listwarehouses) > 1) { if (count($listwarehouses) > 1) {
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 1, 0, $objp->fk_product); print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1);
} elseif (count($listwarehouses) == 1) { } elseif (count($listwarehouses) == 1) {
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product); print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1);
} else { } else {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("ErrorNoWarehouseDefined"); print $langs->trans("ErrorNoWarehouseDefined");

View File

@ -100,7 +100,7 @@ if ($object->id > 0)
$head = ordersupplier_prepare_head($object); $head = ordersupplier_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('SupplierOrder'), 0, 'order'); dol_fiche_head($head, 'documents', $langs->trans('SupplierOrder'), -1, 'order');
// Construit liste des fichiers // Construit liste des fichiers

View File

@ -100,7 +100,7 @@ $now=dol_now();
$head = ordersupplier_prepare_head($object); $head = ordersupplier_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("SupplierOrder"), 0, 'order'); dol_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order');
// Supplier order card // Supplier order card

View File

@ -82,7 +82,7 @@ if ($id > 0 || ! empty($ref))
$head = ordersupplier_prepare_head($object); $head = ordersupplier_prepare_head($object);
$title=$langs->trans("SupplierOrder"); $title=$langs->trans("SupplierOrder");
dol_fiche_head($head, 'note', $title, 0, 'order'); dol_fiche_head($head, 'note', $title, -1, 'order');
// Supplier order card // Supplier order card

View File

@ -26,16 +26,20 @@
* *
* @param index int index of produt line. 0 = first product line * @param index int index of produt line. 0 = first product line
* @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch) * @param type string type of dispatch (batch = batch dispatch, dispatch = non batch dispatch)
* @param mode string 'qtymissing' will create new line with qty missing, 'lessone' will keep 1 in old line and the rest in new one
*/ */
function addDispatchLine(index,type) function addDispatchLine(index, type, mode)
{ {
mode = mode || 'qtymissing'
console.log("Split line type="+type+" index="+index+" mode="+mode);
var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object
nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch
qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()), qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()),
qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()), qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()),
qtyDispatched; qtyDispatched;
if (type === 'batch') if (mode === 'lessone')
{ {
qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1; qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1;
} }
@ -63,15 +67,22 @@ function addDispatchLine(index,type)
/* Suffix of lines are: _ trs.length _ index */ /* Suffix of lines are: _ trs.length _ index */
$("#qty_"+nbrTrs+"_"+index).focus(); $("#qty_"+nbrTrs+"_"+index).focus();
$("#qty_dispatched_"+(nbrTrs)+"_"+index).val(qtyDispatched); $("#qty_dispatched_"+(nbrTrs)+"_"+index).val(qtyDispatched);
if (type === 'batch')
//hide all buttons then show only the last one
$("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide();
$("tr[name^='"+type+"_'][name$='_"+index+"']:last .splitbutton").show();
if (mode === 'lessone')
{ {
$("#qty_"+(nbrTrs)+"_"+index).val(qty-1); $("#qty_"+(nbrTrs)+"_"+index).val(qty-1);
$("#qty_"+(nbrTrs-1)+"_"+index).val(1); $("#qty_"+(nbrTrs-1)+"_"+index).val(1);
} }
else else
{ {
$("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched); $("#qty_"+nbrTrs+"_"+index).val(qtyOrdered - qtyDispatched);
} }
//set focus on lot of new line (if it exists)
$("#lot_number_"+(nbrTrs)+"_"+index).focus();
} }
} }

View File

@ -75,7 +75,7 @@ print load_fiche_titre($title,$linkback,'title_setup');
$head = product_lot_admin_prepare_head(); $head = product_lot_admin_prepare_head();
dol_fiche_head($head, 'attributes', $textobject, 0, 'stock'); dol_fiche_head($head, 'attributes', $textobject, -1, 'stock');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';