Debug v18

This commit is contained in:
Laurent Destailleur 2023-05-03 04:51:15 +02:00
parent 2a9e670425
commit eccbe94131
6 changed files with 46 additions and 27 deletions

View File

@ -663,7 +663,7 @@ if ($id > 0 || !empty($ref)) {
if ($num) {
while ($i < $num) {
$objd = $db->fetch_object($resql);
$products_dispatched[$objd->rowid] = price2num($objd->qty, 5);
$products_dispatched[$objd->rowid] = price2num($objd->qty, 'MS');
$i++;
}
}
@ -780,6 +780,7 @@ if ($id > 0 || !empty($ref)) {
$conf->cache['product'] = array();
// Loop on each source order line (may be more or less than current number of lines in llx_commande_fournisseurdet)
while ($i < $num) {
$objp = $db->fetch_object($resql);
@ -873,7 +874,7 @@ if ($id > 0 || !empty($ref)) {
print '<td class="right">';
print '</td>'; // Qty to dispatch
print '<td>';
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
//print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // Warehouse column
@ -936,7 +937,7 @@ if ($id > 0 || !empty($ref)) {
print '<td class="right">';
print '</td>'; // Qty to dispatch
print '<td>';
//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
//print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"');
print '</td>'; // Dispatch column
print '<td></td>'; // Warehouse column

View File

@ -62,20 +62,26 @@ if (empty($dolibarr_nocache)) {
* Adds new table row for dispatching to multiple stock locations or multiple lot/serial
*
* @param index int index of product 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, mode) {
mode = mode || 'qtymissing'
console.log("fourn/js/lib_dispatch.js.php addDispatchLine Split line type="+type+" index="+index+" mode="+mode);
var $row0 = $("tr[name='"+type+'_0_'+index+"']");
var $dpopt = $row0.find('.hasDatepicker').first().datepicker('option', 'all'); // get current datepicker options to apply the same to the cloned datepickers
var $row = $row0.clone(true); // clone first batch line to jQuery object
var nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; // position of line for batch
var nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length; // count nb of tr line with attribute name that starts with 'batch_' or 'dispatch_', and end with _index
var qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()); // Qty ordered is same for all rows
var qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val());
console.log("fourn/js/lib_dispatch.js.php Split line type="+type+" index="+index+" mode="+mode+" qtyOrdered="+qtyOrdered+" qty="+qty);
var qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val());
if (isNaN(qty)) {
qty = '';
}
console.log("fourn/js/lib_dispatch.js.php addDispatchLine Split line nbrTrs="+nbrTrs+" qtyOrdered="+qtyOrdered+" qty="+qty);
var qtyDispatched;
@ -90,7 +96,7 @@ function addDispatchLine(index, type, mode) {
mode = 'lessone';
}
}
console.log("qtyDispatched=" + qtyDispatched + " qtyOrdered=" + qtyOrdered);
console.log("qtyDispatched=" + qtyDispatched + " qtyOrdered=" + qtyOrdered+ " qty=" + qty);
if (qty <= 1) {
window.alert("Remain quantity to dispatch is too low to be split");
@ -187,7 +193,6 @@ function addDispatchLine(index, type, mode) {
*
* element requires arbitrary data qty (value before change), type (type of dispatch) and index (index of product line)
*/
function onChangeDispatchLineQty(element) {
var type = $(element).data('type'),
qty = parseFloat($(element).data('expected')),
@ -208,7 +213,8 @@ function onChangeDispatchLineQty(element) {
if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) {
$("#qty_dispatched_0_" + index).val(qtyDispatched + qtyChanged);
} else {
$(element).val($(element).data('expected'));
/*console.log("eee");
$(element).val($(element).data('expected'));*/
}
$(element).data('expected', $(element).val());
}

View File

@ -52,6 +52,6 @@ ReceptionExist=A reception exists
ReceptionBackToDraftInDolibarr=Reception %s back to draft
ReceptionClassifyClosedInDolibarr=Reception %s classified Closed
ReceptionUnClassifyCloseddInDolibarr=Reception %s re-open
ResetQtyToDispatch=Reset all quantities to dispatch
RestoreWithCurrentQtySaved=Fill quantities with lastest saved values
ReceptionUpdated=Reception sucessfully updated
DispatchCard=Dispatch card
DispatchCard=Reception distribution

View File

@ -415,7 +415,6 @@ if (empty($reshook)) {
/*
* View
*/

View File

@ -735,7 +735,9 @@ if (empty($reshook)) {
* View
*/
llxHeader('', $langs->trans('Reception'), 'Reception');
$title = $object->ref.' - '.$langs->trans('Reception');
llxHeader('', $title, 'Reception');
$form = new Form($db);
$formfile = new FormFile($db);

View File

@ -297,7 +297,7 @@ $formproduct = new FormProduct($db);
$warehouse_static = new Entrepot($db);
$supplierorderdispatch = new CommandeFournisseurDispatch($db);
$title = $object->ref." - ".$langs->trans('OrderDispatch');
$title = $object->ref." - ".$langs->trans('DispatchCard');
$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
$morejs = array('/fourn/js/lib_dispatch.js.php');
@ -427,8 +427,9 @@ if ($id > 0 || !empty($ref)) {
print '</tr>';
print '</table>';
print '<br><center>';
print '<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto("", 'eraser', 'class="pictofixedwidth"').$langs->trans("ResetQtyToDispatch").'</a></td>';
print '<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto("", 'eraser', 'class="pictofixedwidth"').$langs->trans("Reset").'</a></td>';
print '<a href="#" id="resetalltoexpected" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto("", 'autofill', 'class="pictofixedwidth"').$langs->trans("RestoreWithCurrentQtySaved").'</a></td>';
// Link to clear qty
print '<a href="#" id="autoreset" class="marginrightonly paddingright marginleftonly paddingleft">'.img_picto("", 'eraser', 'class="pictofixedwidth"').$langs->trans("ClearQtys").'</a></td>';
print '<center>';
print '<br>';
@ -453,7 +454,7 @@ if ($id > 0 || !empty($ref)) {
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
// Set $products_dispatched with qty dispatched for each product id
// Get list of lines from the original Order into $products_dispatched with qty dispatched for each product id
$products_dispatched = array();
$sql = "SELECT l.rowid, cfd.fk_product, sum(cfd.qty) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
@ -469,17 +470,17 @@ if ($id > 0 || !empty($ref)) {
if ($num) {
while ($i < $num) {
$objd = $db->fetch_object($resql);
$products_dispatched[$objd->rowid] = price2num($objd->qty, 5);
$products_dispatched[$objd->rowid] = price2num($objd->qty, 'MS');
$i++;
}
}
$db->free($resql);
}
//$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, SUM(l.qty) as qty,";
$sql = "SELECT l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref AS sref, l.qty as qty,";
$sql .= " p.ref, p.label, p.tobatch, p.fk_default_warehouse";
// Enable hooks to alter the SQL query (SELECT)
$parameters = array();
$reshook = $hookmanager->executeHooks(
@ -492,14 +493,12 @@ if ($id > 0 || !empty($ref)) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
$sql .= $hookmanager->resPrint;
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid";
$sql .= " WHERE l.fk_commande = ".((int) $objectsrc->id);
if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$sql .= " AND l.product_type = 0";
}
// Enable hooks to alter the SQL query (WHERE)
$parameters = array();
$reshook = $hookmanager->executeHooks(
@ -520,7 +519,6 @@ if ($id > 0 || !empty($ref)) {
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$numline = 1;
if ($num) {
print '<tr class="liste_titre">';
@ -543,6 +541,7 @@ if ($id > 0 || !empty($ref)) {
print '<td class="right">'.$langs->trans("QtyOrdered").'</td>';
print '<td class="right">'.$langs->trans("QtyDispatchedShort").'</td>';
print ' <td class="right">'.$langs->trans("QtyToDispatchShort");
//print '<br><a href="#" id="autoreset">'.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').$langs->trans("Reset").'</a></td>';
print '<td width="32"></td>';
if (!empty($conf->global->SUPPLIER_ORDER_CAN_UPDATE_BUYINGPRICE_DURING_RECEIPT)) {
@ -586,6 +585,7 @@ if ($id > 0 || !empty($ref)) {
$conf->cache['product'] = array();
// Loop on each source order line (may be more or less than current number of lines in llx_commande_fournisseurdet)
while ($i < $num) {
$objp = $db->fetch_object($resql);
@ -611,7 +611,7 @@ if ($id > 0 || !empty($ref)) {
print '<!-- Line to dispatch '.$suffix.' -->'."\n";
// hidden fields for js function
print '<input id="qty_ordered'.$suffix.'" type="hidden" value="'.$objp->qty.'">';
print '<input id="qty_dispatched'.$suffix.'" type="hidden" data-dispatched="'.(float) $alreadydispatched.'" value="'.(float) $alreadydispatched.'">';
print '<input id="qty_dispatched'.$suffix.'" type="hidden" data-dispatched="'.((float) $alreadydispatched).'" value="'.(float) $alreadydispatched.'">';
print '<tr class="oddeven">';
if (empty($conf->cache['product'][$objp->fk_product])) {
@ -644,7 +644,7 @@ if ($id > 0 || !empty($ref)) {
print $linktoprod;
print "</td>";
print '<td class="dispatch_batch_number">';
print $langs->trans("ProductDoesNotUseBatchSerial");
print '<span class="opacitymedium small">'.$langs->trans("ProductDoesNotUseBatchSerial").'</small>';
print '</td>';
if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) {
print '<td class="dispatch_dlc"></td>';
@ -682,7 +682,11 @@ if ($id > 0 || !empty($ref)) {
$sql = "SELECT cfd.rowid, cfd.qty, cfd.fk_entrepot, cfd.batch, cfd.eatby, cfd.sellby, cfd.fk_product";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd";
$sql .= " WHERE cfd.fk_commandefourndet = ".(int) $objp->rowid;
$sql .= " WHERE cfd.fk_reception = ".((int) $object->id);
$sql .= " AND cfd.fk_commande = ".((int) $objectsrc->id);
$sql .= " AND cfd.fk_commandefourndet = ".(int) $objp->rowid;
//print $sql;
$resultsql = $db->query($sql);
$j = 0;
if ($resultsql) {
@ -691,6 +695,7 @@ if ($id > 0 || !empty($ref)) {
while ($j < $numd) {
$suffix = "_".$j."_".$i;
$objd = $db->fetch_object($resultsql);
if (isModEnabled('productbatch') && !empty($objd->batch)) {
$type = 'batch';
@ -862,6 +867,7 @@ if ($id > 0 || !empty($ref)) {
}
$suffix = "_".$j."_".$i;
}
if ($j == 0) {
if (isModEnabled('productbatch') && !empty($objp->batch)) {
$type = 'batch';
@ -1105,19 +1111,23 @@ if ($id > 0 || !empty($ref)) {
$(".autoresettr").each(function(){
id = $(this).attr("name");
idtab = id.split("_");
if($(this).data("remove") == "clear"){
if ($(this).data("remove") == "clear"){
console.log("We clear the object to expected value")
$("#qty_"+idtab[1]+"_"+idtab[2]).val("");
/*
qtyexpected = $("#qty_"+idtab[1]+"_"+idtab[2]).data("expected")
console.log(qtyexpected);
$("#qty_"+idtab[1]+"_"+idtab[2]).val(qtyexpected);
qtydispatched = $("#qty_dispatched_0_"+idtab[2]).data("dispatched")
$("#qty_dispatched_0_"+idtab[2]).val(qtydispatched);
*/
} else {
console.log("We remove the object")
$(this).remove();
$("tr[name^=\'"+idtab[0]+"_\'][name$=\'_"+idtab[2]+"\']:last .splitbutton").show();
}
});
return false;
});
$("#resetalltoexpected").click(function(){
@ -1125,6 +1135,7 @@ if ($id > 0 || !empty($ref)) {
console.log("We reset to expected "+$(this).attr("id")+" qty to dispatch");
$(this).val($(this).data("expected"));
});
return false;
});
$(".resetline").click(function(){