New: update field "qty" with minimum qty for this supplier price
This commit is contained in:
parent
878f54b1e9
commit
577a853b9b
@ -1424,6 +1424,7 @@ class Form
|
||||
$outkey=$objp->idprodfournprice;
|
||||
$outref=$objp->ref;
|
||||
$outval='';
|
||||
$outqty=1;
|
||||
|
||||
$opt = '<option value="'.$objp->idprodfournprice.'"';
|
||||
if ($selected && $selected == $objp->idprodfournprice) $opt.= ' selected="selected"';
|
||||
@ -1451,6 +1452,7 @@ class Form
|
||||
|
||||
$opt.= price($objp->fprice).' '.$currencytext."/".$objp->quantity;
|
||||
$outval.= price($objp->fprice).' '.$currencytextnoent."/".$objp->quantity;
|
||||
$outqty=$objp->quantity;
|
||||
if ($objp->quantity == 1)
|
||||
{
|
||||
$opt.= strtolower($langs->trans("Unit"));
|
||||
@ -1488,7 +1490,7 @@ class Form
|
||||
// "key" value of json key array is used by jQuery automatically as selected value
|
||||
// "label" value of json key array is used by jQuery automatically as text for combo box
|
||||
$outselect.=$opt;
|
||||
array_push($outjson, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'disabled'=>(empty($objp->idprodfournprice)?true:false)));
|
||||
array_push($outjson, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'disabled'=>(empty($objp->idprodfournprice)?true:false)));
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -66,7 +66,13 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
$("#'.$htmlname.'").val(item.key).trigger("change");
|
||||
}
|
||||
var label = item.label.toString();
|
||||
return { label: label, value: item.value, id: item.key, disabled: item.disabled }
|
||||
var update = {};
|
||||
if (options.update) {
|
||||
$.each(options.update, function(key, value) {
|
||||
update[key] = item[value];
|
||||
});
|
||||
}
|
||||
return { label: label, value: item.value, id: item.key, update: update, disabled: item.disabled }
|
||||
}));
|
||||
}, "json");
|
||||
},
|
||||
@ -74,6 +80,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
minLength: '.$minLength.',
|
||||
select: function( event, ui ) {
|
||||
$("#'.$htmlname.'").val(ui.item.id).trigger("change");
|
||||
// Disable an element
|
||||
if (options.disabled) {
|
||||
if (ui.item.disabled) {
|
||||
$("#" + options.disabled).attr("disabled", "disabled");
|
||||
@ -84,6 +91,12 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
$("#" + options.disabled).removeAttr("disabled");
|
||||
}
|
||||
}
|
||||
// Update an element
|
||||
if (ui.item.update) {
|
||||
$.each(ui.item.update, function(key, value) {
|
||||
$("#" + key).val(value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}).data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
|
||||
@ -1530,7 +1530,11 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="3">';
|
||||
|
||||
$ajaxoptions=array('disabled' => 'addPredefinedProductButton', 'error' => $langs->trans("NoPriceDefinedForThisSupplier"));
|
||||
$ajaxoptions=array(
|
||||
'update' => array('pqty' => 'qty'),
|
||||
'disabled' => 'addPredefinedProductButton',
|
||||
'error' => $langs->trans("NoPriceDefinedForThisSupplier")
|
||||
);
|
||||
$form->select_produits_fournisseurs($object->fourn_id, '', 'idprodfournprice', '', '', $ajaxoptions);
|
||||
|
||||
if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '<br>';
|
||||
@ -1547,7 +1551,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$doleditor->Create();
|
||||
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" size="2" name="pqty" value="'.(GETPOST('pqty')?GETPOST('pqty'):'1').'"></td>';
|
||||
print '<td align="right"><input type="text" size="2" id="pqty" name="pqty" value="'.(GETPOST('pqty')?GETPOST('pqty'):'1').'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input type="text" size="1" name="p_remise_percent" value="'.(GETPOST('p_remise_percent')?GETPOST('p_remise_percent'):$soc->remise_client).'">%</td>';
|
||||
print '<td align="center" colspan="4"><input type="submit" id="addPredefinedProductButton" class="button" value="'.$langs->trans('Add').'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -1806,7 +1806,11 @@ else
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td colspan="4">';
|
||||
|
||||
$ajaxoptions=array('disabled' => 'addPredefinedProductButton', 'error' => $langs->trans("NoPriceDefinedForThisSupplier"));
|
||||
$ajaxoptions=array(
|
||||
'update' => array('pqty' => 'qty'),
|
||||
'disabled' => 'addPredefinedProductButton',
|
||||
'error' => $langs->trans("NoPriceDefinedForThisSupplier")
|
||||
);
|
||||
$form->select_produits_fournisseurs($object->socid, '', 'idprodfournprice', '', '', $ajaxoptions);
|
||||
|
||||
if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) print '<br>';
|
||||
@ -1823,7 +1827,7 @@ else
|
||||
$doleditor->Create();
|
||||
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="1" size="1"></td>';
|
||||
print '<td align="right"><input type="text" id="pqty" name="qty" value="1" size="1"></td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center" valign="middle" colspan="2"><input type="submit" id="addPredefinedProductButton" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user