FIX Duplicate select2 when we split a supplier order receipt item

This commit is contained in:
Laurent Destailleur
2018-06-16 17:18:17 +02:00
parent 5524784421
commit 7ad086bbdf
3 changed files with 14 additions and 10 deletions

View File

@@ -2517,7 +2517,8 @@ elseif (! empty($object->id))
print '<table class="noborder" width="100%">';
//print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Receive").'</td></tr>';
print '<tr><td>'.$langs->trans("DeliveryDate").'</td><td>';
print $form->select_date('','',1,1,'',"commande",1,1,1);
$datepreselected = dol_now();
print $form->select_date($datepreselected,'',1,1,'',"commande",1,1,1);
print "</td></tr>\n";
print "<tr><td class=\"fieldrequired\">".$langs->trans("Delivery")."</td><td>\n";

View File

@@ -626,11 +626,11 @@ if ($id > 0 || ! empty($ref)) {
print '<td>';
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 class="nowraponall">';
$dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year'));
$form->select_date($dlcdatesuffix, 'dlc' . $suffix, '', '', 1, "");
print '</td>';
print '<td>';
print '<td class="nowraponall">';
$dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo' . $suffix . 'month'), GETPOST('dluo' . $suffix . 'day'), GETPOST('dluo' . $suffix . 'year'));
$form->select_date($dluodatesuffix, 'dluo' . $suffix, '', '', 1, "");
print '</td>';
@@ -685,9 +685,9 @@ if ($id > 0 || ! empty($ref)) {
// Warehouse
print '<td align="right">';
if (count($listwarehouses) > 1) {
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1);
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
} elseif (count($listwarehouses) == 1) {
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1);
print $formproduct->selectWarehouses(GETPOST("entrepot" . $suffix)?GETPOST("entrepot" . $suffix):($objp->fk_default_warehouse?$objp->fk_default_warehouse:''), "entrepot" . $suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix);
} else {
$langs->load("errors");
print $langs->trans("ErrorNoWarehouseDefined");
@@ -852,7 +852,7 @@ if ($id > 0 || ! empty($ref)) {
print '</td>';
}
// date
print '<td>' . dol_print_date($objp->datec) . '</td>';
print '<td>' . dol_print_date($objp->datec, "dayhour") . '</td>';
print "</tr>\n";

View File

@@ -32,10 +32,10 @@ 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
console.log("fourn/js/lib_dispatch.js 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_0_"+index).val()), // Qty ordered is same for all rows
qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows
qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()),
qtyDispatched;
@@ -62,8 +62,11 @@ function addDispatchLine(index, type, mode)
$row.attr('name',type+'_'+nbrTrs+'_'+index);
//insert new row before last row
$("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row);
//remove cloned select2 with duplicate id.
$("#s2id_entrepot_"+nbrTrs+'_'+index).detach();
$("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); // old way to find duplicated select2 component
$(".csswarehouse_"+nbrTrs+"_"+index+":first-child").parents("span.selection").parents(".select2").detach();
/* Suffix of lines are: _ trs.length _ index */
$("#qty_"+nbrTrs+"_"+index).focus();
$("#qty_dispatched_0_"+index).val(qtyDispatched);