diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index f79c9fe49b4..f99809d4091 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -133,7 +133,7 @@ if ($id > 0 || !empty($ref)) {
// Security check
$isdraft = (isset($object->statut) && ($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
-$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande', 'fk_soc', 'rowid', $isdraft);
+$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande', 'fk_soc', 'rowid', $isdraft);
// Common permissions
$usercanread = ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire);
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 50508f171df..fc07217846f 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -94,7 +94,7 @@ if (empty($conf->reception->enabled)) {
}
// $id is id of a purchase order.
-$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
+$result = restrictedArea($user, 'fournisseur', $object, 'commande_fournisseur', 'commande');
if (!isModEnabled('stock')) {
accessforbidden();
@@ -978,7 +978,8 @@ if ($id > 0 || !empty($ref)) {
// Qty to dispatch
print '
';
- print '';
+ print ''.img_picto($langs->trans("Reset"), 'eraser', 'class="pictofixedwidth opacitymedium"').'';
+ print '';
print ' | ';
print '';
@@ -1115,14 +1116,30 @@ if ($id > 0 || !empty($ref)) {
$("select[name^=entrepot_]").val(fk_default_warehouse).change();
});
- jQuery("#autoreset").click(function() {';
- $i = 0;
- while ($i < $nbproduct) {
- print ' jQuery("#qty_0_'.$i.'").val("");';
- $i++;
- }
- print '
+ $("#autoreset").click(function() {
+ $(".qtydispatchinput").each(function(){
+ id = $(this).attr("id");
+ idtab = id.split("_");
+ if(idtab[1] == 0){
+ console.log(idtab);
+ $(this).val("");
+ $("#qty_dispatched_0_"+idtab[2]).val("0");
+ } else {
+ obj = $(this).parent().parent();
+ nameobj = obj.attr("name");
+ nametab = nameobj.split("_");
+ obj.remove();
+ $("tr[name^=\'"+nametab[0]+"_\'][name$=\'_"+nametab[2]+"\']:last .splitbutton").show();
+ }
+ });
});
+
+ $(".resetline").click(function(){
+ id = $(this).attr("id");
+ id = id.split("reset_");
+ console.log("Reset trigger for id = qty_"+id[1]);
+ $("#qty_"+id[1]).val("");
+ });
});
';
diff --git a/htdocs/fourn/js/lib_dispatch.js.php b/htdocs/fourn/js/lib_dispatch.js.php
index ff822543ddb..7d711d3a19a 100644
--- a/htdocs/fourn/js/lib_dispatch.js.php
+++ b/htdocs/fourn/js/lib_dispatch.js.php
@@ -133,6 +133,21 @@ function addDispatchLine(index, type, mode)
$("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide();
$("tr[name^='"+type+"_'][name$='_"+index+"']:last .splitbutton").show();
+ $("#reset_"+(nbrTrs)+"_"+index).click(function(){
+ id = $(this).attr("id");
+ id = id.split("reset_");
+ idrow = id[1];
+ idlast = $("tr[name^='"+type+"_'][name$='_"+index+"']:last .qtydispatchinput").attr("id");
+ if (idlast == $("#qty_"+idrow).attr("id")) {
+ console.log("Remove trigger for tr name = "+type+"_"+idrow);
+ $('tr[name="'+type+'_'+idrow+'"').remove();
+ $("tr[name^='"+type+"_'][name$='_"+index+"']:last .splitbutton").show();
+ } else {
+ console.log("Reset trigger for id = #qty_"+idrow);
+ $("#qty_"+idrow).val("");
+ }
+ });;
+
if (mode === 'lessone')
{
qty = 1; // keep 1 in old line
|