Merge pull request #14989 from FHenry/dev_finish_packingfeature
fix : finish packging feature (allow to edit packaging quantity)
This commit is contained in:
commit
b27c95bab0
@ -654,6 +654,10 @@ class modProduct extends DolibarrModules
|
||||
));
|
||||
}
|
||||
|
||||
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
|
||||
$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.packaging' => 'PackagingForThisProduct'));
|
||||
}
|
||||
|
||||
$this->import_convertvalue_array[$r] = array(
|
||||
'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'),
|
||||
'sp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
|
||||
@ -692,6 +696,11 @@ class modProduct extends DolibarrModules
|
||||
'sp.multicurrency_price'=>''
|
||||
));
|
||||
}
|
||||
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
|
||||
$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
|
||||
'sp.packagning'=>'1',
|
||||
));
|
||||
}
|
||||
|
||||
$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
|
||||
}
|
||||
|
||||
@ -1664,9 +1664,9 @@ class CommandeFournisseur extends CommonOrder
|
||||
{
|
||||
$coeff = intval($qty / $prod->packaging) + 1;
|
||||
$qty = $prod->packaging * $coeff;
|
||||
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
|
||||
}
|
||||
}
|
||||
setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
|
||||
}
|
||||
} else {
|
||||
$product_type = $type;
|
||||
|
||||
@ -272,7 +272,7 @@ class ProductFournisseur extends Product
|
||||
$charges = price2num($charges, 'MU');
|
||||
$qty = price2num($qty, 'MS');
|
||||
$unitBuyPrice = price2num($buyprice / $qty, 'MU');
|
||||
$packaging = ($this->packaging < $qty) ? $qty : $this->packaging;
|
||||
$packaging = price2num((($this->packaging < $qty) ? $qty : $this->packaging), 'MS');
|
||||
|
||||
$error = 0;
|
||||
$now = dol_now();
|
||||
|
||||
@ -339,6 +339,7 @@ UseProductFournDesc=Add a feature to define the descriptions of products defined
|
||||
ProductSupplierDescription=Vendor description for the product
|
||||
UseProductSupplierPackaging=Use packaging on supplier prices (recalculate quantities according to packaging set on supplier price when adding/updating line in supplier documents)
|
||||
PackagingForThisProduct=Packaging
|
||||
PackagingForThisProductDesc=On supplier order, you will automaticly order this quantity (or a multiple of this quantity). Cannot be less than minimum buying quantity
|
||||
QtyRecalculatedWithPackaging=The quantity of the line were recalculated according to supplier packaging
|
||||
|
||||
#Attributes
|
||||
|
||||
@ -169,7 +169,7 @@ if (empty($reshook))
|
||||
$supplier_description = GETPOST('supplier_description', 'alpha');
|
||||
$barcode = GETPOST('barcode', 'alpha');
|
||||
$fk_barcode_type = GETPOST('fk_barcode_type', 'int');
|
||||
$packaging = GETPOST('packaging', 'int');
|
||||
$packaging = price2num(GETPOST("packaging", 'alphanohtml'), 'MS');
|
||||
|
||||
if ($tva_tx == '')
|
||||
{
|
||||
@ -230,12 +230,6 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($packaging)) $packaging = 1;
|
||||
|
||||
if ($packaging < $quantity) $packaging = $quantity;
|
||||
|
||||
$object->packaging = $packaging;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$db->begin();
|
||||
@ -296,6 +290,10 @@ if (empty($reshook))
|
||||
|
||||
$newprice = price2num(GETPOST("price", "alpha"));
|
||||
|
||||
if (empty($packaging)) $packaging = 1;
|
||||
if ($packaging < $quantity) $packaging = $quantity;
|
||||
$object->packaging = $packaging;
|
||||
|
||||
if ($conf->multicurrency->enabled)
|
||||
{
|
||||
$multicurrency_tx = price2num(GETPOST("multicurrency_tx", 'alpha'));
|
||||
@ -529,6 +527,23 @@ if ($id > 0 || $ref)
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
|
||||
// Packaging
|
||||
print '<tr>';
|
||||
|
||||
print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("PackagingForThisProduct"), $langs->trans("PackagingForThisProductDesc")).'</td>';
|
||||
print '<td>';
|
||||
$packaging = GETPOSTISSET('packaging') ? price2num(GETPOST('packaging', 'nohtml'), 'MS') : ((empty($rowid))?"1":price2num($object->packaging, 'MS'));
|
||||
print '<input class="flat" name="packaging" size="5" value="'.$packaging.'">';
|
||||
|
||||
// Units
|
||||
if ($conf->global->PRODUCT_USE_UNITS) {
|
||||
$unit = $object->getLabelOfUnit();
|
||||
if ($unit !== '') {
|
||||
print ' '.$langs->trans($unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Vat rate
|
||||
$default_vat = '';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user