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

@ -150,10 +150,10 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
$db->begin();
$pos = 0;
foreach ($_POST as $key => $value)
foreach ($_POST as $key => $value)
{
// without batch module enabled
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg))
{
$pos ++;
@ -184,7 +184,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
}
}
// with batch module enabled
if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg))
if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg))
{
$pos ++;
@ -260,6 +260,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner)
}
}
/*
* View
*/
@ -284,13 +285,13 @@ if ($id > 0 || ! empty($ref)) {
$head = ordersupplier_prepare_head($object);
$title = $langs->trans("SupplierOrder");
dol_fiche_head($head, 'dispatch', $title, 0, 'order');
dol_fiche_head($head, 'dispatch', $title, -1, 'order');
// Supplier order card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
@ -331,14 +332,14 @@ if ($id > 0 || ! empty($ref)) {
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
// Date
@ -362,7 +363,7 @@ if ($id > 0 || ! empty($ref)) {
print "</table>";
print '</div>';
// if ($mesg) print $mesg;
print '<br>';
@ -382,7 +383,7 @@ if ($id > 0 || ! empty($ref)) {
print '<form method="POST" action="dispatch.php?id=' . $object->id . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="dispatch">';
print '<div class="div-table-responsive">';
print '<table class="noborder" width="100%">';
@ -434,6 +435,7 @@ if ($id > 0 || ! empty($ref)) {
print '<td align="right">' . $langs->trans("QtyOrdered") . '</td>';
print '<td align="right">' . $langs->trans("QtyDispatchedShort") . '</td>';
print '<td align="right">' . $langs->trans("QtyToDispatchShort") . '</td>';
print '<td width="32"></td>';
print '<td align="right">' . $langs->trans("Warehouse") . '</td>';
print "</tr>\n";
@ -443,7 +445,7 @@ if ($id > 0 || ! empty($ref)) {
print '<td>' . $langs->trans("batch_number") . '</td>';
print '<td>' . $langs->trans("EatByDate") . '</td>';
print '<td>' . $langs->trans("SellByDate") . '</td>';
print '<td colspan="4">&nbsp;</td>';
print '<td colspan="5">&nbsp;</td>';
print "</tr>\n";
}
}
@ -456,7 +458,7 @@ if ($id > 0 || ! empty($ref)) {
while ( $i < $num ) {
$objp = $db->fetch_object($resql);
// On n'affiche pas les produits personnalises
// On n'affiche pas les produits libres
if (! $objp->fk_product > 0) {
$nbfreeproduct++;
} else {
@ -511,7 +513,11 @@ if ($id > 0 || ! empty($ref)) {
if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) {
$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 '</tr>';
@ -519,7 +525,7 @@ if ($id > 0 || ! empty($ref)) {
print '<td>';
print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp->rowid . '">';
print '<input name="product_batch' . $suffix . '" type="hidden" value="' . $objp->fk_product . '">';
print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
if (! empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested !
{
@ -536,7 +542,7 @@ if ($id > 0 || ! empty($ref)) {
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>';
$dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year'));
@ -549,15 +555,19 @@ if ($id > 0 || ! empty($ref)) {
print '<td colspan="2">&nbsp</td>'; // Qty ordered + qty already dispatached
} else {
$type = 'dispatch';
print '<td align="right">' . img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"') . '</td>'; // Dispatch column
print '<td></td>';
print '<td align="right">';
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 class="oddeven" name="' . $type . $suffix . '">';
print '<td colspan="6">';
print '<input name="fk_commandefourndet' . $suffix . '" type="hidden" value="' . $objp->rowid . '">';
print '<input name="product' . $suffix . '" type="hidden" value="' . $objp->fk_product . '">';
print '<!-- This is a up (may include discount or not depending on STOCK_EXCLUDE_DISCOUNT_FOR_PMP. will be used for PMP calculation) -->';
if (! empty($conf->global->SUPPLIER_ORDER_EDIT_BUYINGPRICE_DURING_RECEIPT)) // Not tested !
{
@ -567,23 +577,38 @@ if ($id > 0 || ! empty($ref)) {
{
print '<input class="maxwidth75" name="pu' . $suffix . '" type="hidden" value="' . price2num($up_ht_disc, 'MU') . '">';
}
// hidden fields for js function
print '<input id="qty_ordered' . $suffix . '" type="hidden" value="' . $objp->qty . '">';
print '<input id="qty_dispatched' . $suffix . '" type="hidden" value="' . ( float ) $products_dispatched[$objp->rowid] . '">';
print '</td>';
}
// Dispatch
// Qty to dispatch
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 '</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>';
// Warehouse
print '<td align="right">';
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) {
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 {
$langs->load("errors");
print $langs->trans("ErrorNoWarehouseDefined");
@ -604,10 +629,10 @@ if ($id > 0 || ! empty($ref)) {
print '</div>';
print "<br>\n";
if ($nbproduct)
if ($nbproduct)
{
$checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($object->statuts[5]));
print '<br><div class="center">';
print $langs->trans("Comment") . ' : ';
print '<input type="text" class="minwidth400" maxlength="128" name="comment" value="';
@ -616,7 +641,7 @@ if ($id > 0 || ! empty($ref)) {
print '" class="flat"><br>';
print '<input type="checkbox" checked="checked" name="closeopenorder"> '.$checkboxlabel;
print '<br><input type="submit" class="button" value="' . $langs->trans("DispatchVerb") . '"';
if (count($listwarehouses) <= 0)
print ' disabled';
@ -628,7 +653,7 @@ if ($id > 0 || ! empty($ref)) {
if (! $nbproduct) {
if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED))
print '<div class="opacitymedium">'.$langs->trans("NoPredefinedProductToDispatch").'</div>'; // No predefined line at all
else
else
print '<div class="opacitymedium">'.$langs->trans("NoMorePredefinedProductToDispatch").'</div>'; // No predefined line that remain to be dispatched.
}
@ -637,7 +662,7 @@ if ($id > 0 || ! empty($ref)) {
dol_fiche_end();
// List of lines already dispatched
$sql = "SELECT p.ref, p.label,";
$sql .= " e.rowid as warehouse_id, e.label as entrepot,";

View File

@ -100,7 +100,7 @@ if ($object->id > 0)
$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
@ -114,7 +114,7 @@ if ($object->id > 0)
// Supplier order card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
@ -155,13 +155,13 @@ if ($object->id > 0)
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
@ -170,8 +170,8 @@ if ($object->id > 0)
print "</div>\n";
dol_fiche_end();
$modulepart = 'commande_fournisseur';
$permission = $user->rights->fournisseur->commande->creer;
$permtoedit = $user->rights->fournisseur->commande->creer;

View File

@ -100,7 +100,7 @@ $now=dol_now();
$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
@ -197,7 +197,7 @@ if (!empty($object->id))
$param='&id='.$object->id;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
print load_fiche_titre($langs->trans("ActionsOnOrder"),'','');
// List of actions on element

View File

@ -75,19 +75,19 @@ if ($id > 0 || ! empty($ref))
if ($result >= 0)
{
$object->fetch_thirdparty();
$author = new User($db);
$author->fetch($object->user_author_id);
$head = ordersupplier_prepare_head($object);
$title=$langs->trans("SupplierOrder");
dol_fiche_head($head, 'note', $title, 0, 'order');
dol_fiche_head($head, 'note', $title, -1, 'order');
// Supplier order card
$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Ref supplier
$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
@ -128,19 +128,19 @@ if ($id > 0 || ! empty($ref))
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
dol_fiche_end();
}
else

View File

@ -26,16 +26,20 @@
*
* @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 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
nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch
qtyOrdered = parseFloat($("#qty_ordered_"+(nbrTrs - 1)+"_"+index).val()),
qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()),
qtyDispatched;
if (type === 'batch')
if (mode === 'lessone')
{
qtyDispatched = parseFloat($("#qty_dispatched_"+(nbrTrs - 1)+"_"+index).val()) + 1;
}
@ -63,15 +67,22 @@ function addDispatchLine(index,type)
/* Suffix of lines are: _ trs.length _ index */
$("#qty_"+nbrTrs+"_"+index).focus();
$("#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-1)+"_"+index).val(1);
}
else
{
$("#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();
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';