'."\n";
+ print '
'."\n";
print $form->editfieldkey("NotePrivate", $note_private, $value_private, $object, $permission, $typeofdata, $moreparam, '', 0);
print '
'."\n";
print '
'."\n";
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index d86b68f11e4..6ca038a8a3d 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -441,6 +441,7 @@ class CommandeFournisseur extends CommonOrder
*/
public function fetch_lines($only_product = 0)
{
+ global $conf;
// phpcs:enable
//$result=$this->fetch_lines();
$this->lines = array();
@@ -453,8 +454,12 @@ class CommandeFournisseur extends CommonOrder
$sql .= " l.fk_unit,";
$sql .= " l.date_start, l.date_end,";
$sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql.= ", pfp.rowid as fk_pfp, pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON l.fk_product = pfp.fk_product and l.ref = pfp.ref_fourn";
$sql .= " WHERE l.fk_commande = ".$this->id;
if ($only_product) $sql .= ' AND p.fk_product_type = 0';
$sql .= " ORDER BY l.rang, l.rowid";
@@ -505,7 +510,13 @@ class CommandeFournisseur extends CommonOrder
$line->ref_fourn = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
$line->ref_supplier = $objp->ref_supplier; // The supplier ref of price when product was added. May have change since
- $line->date_start = $this->db->jdate($objp->date_start);
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ $line->fk_fournprice = $objp->fk_pfp;
+ $line->packaging = $objp->packaging;
+ }
+
+ $line->date_start = $this->db->jdate($objp->date_start);
$line->date_end = $this->db->jdate($objp->date_end);
$line->fk_unit = $objp->fk_unit;
@@ -1685,6 +1696,26 @@ class CommandeFournisseur extends CommonOrder
return -1;
}
}
+
+ // redefine quantity according to packaging
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ $prod = new Product($this->db, $fk_product);
+ $prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid));
+ if ($qty < $prod->packaging)
+ {
+ $qty = $prod->packaging;
+ }
+ else
+ {
+ if (($qty % $prod->packaging) > 0)
+ {
+ $coeff = intval($qty/$prod->packaging) + 1;
+ $qty = $prod->packaging * $coeff;
+ setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
+ }
+ }
+ }
}
else
{
@@ -2636,6 +2667,25 @@ class CommandeFournisseur extends CommonOrder
$this->line->fk_commande = $this->id;
//$this->line->label=$label;
$this->line->desc = $desc;
+
+ // redefine quantity according to packaging
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ if ($qty < $this->line->packaging)
+ {
+ $qty = $this->line->packaging;
+ }
+ else
+ {
+ if (($qty % $this->line->packaging) > 0)
+ {
+ $coeff = intval($qty/$this->line->packaging) + 1;
+ $qty = $this->line->packaging * $coeff;
+ setEventMessage($langs->trans('QtyRecalculatedWithPackaging'), 'mesgs');
+ }
+ }
+ }
+
$this->line->qty = $qty;
$this->line->ref_supplier = $ref_supplier;
@@ -3390,6 +3440,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
*/
public function fetch($rowid)
{
+ global $conf;
+
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code,';
$sql .= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref,';
$sql .= ' cd.remise, cd.remise_percent, cd.subprice,';
@@ -3398,8 +3450,12 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql .= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
$sql .= ' cd.date_start, cd.date_end, cd.fk_unit,';
$sql .= ' cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql.= ", pfp.rowid as fk_pfp, pfp.packaging";
$sql .= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON cd.fk_product = pfp.fk_product and cd.ref = pfp.ref_fourn";
$sql .= ' WHERE cd.rowid = '.$rowid;
$result = $this->db->query($sql);
if ($result)
@@ -3437,6 +3493,11 @@ class CommandeFournisseurLigne extends CommonOrderLine
$this->product_ref = $objp->product_ref;
$this->product_libelle = $objp->product_libelle;
$this->product_desc = $objp->product_desc;
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ $this->packaging = $objp->packaging;
+ $this->fk_fournprice = $objp->fk_pfp;
+ }
$this->date_start = $this->db->jdate($objp->date_start);
$this->date_end = $this->db->jdate($objp->date_end);
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index 717a617b0ca..6c139d73707 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -273,6 +273,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;
$error = 0;
$now = dol_now();
@@ -359,6 +360,7 @@ class ProductFournisseur extends Product
$sql .= " supplier_reputation = ".(empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
$sql .= " barcode = ".(empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
$sql .= " fk_barcode_type = ".(empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", packaging = ".(empty($packaging) ? 1 : $packaging);
$sql .= " WHERE rowid = ".$this->product_fourn_price_id;
// TODO Add price_base_type and price_ttc
@@ -408,6 +410,7 @@ class ProductFournisseur extends Product
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price(";
$sql .= " multicurrency_price, multicurrency_unitprice, multicurrency_tx, fk_multicurrency, multicurrency_code,";
$sql .= "datec, fk_product, fk_soc, ref_fourn, desc_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation, barcode, fk_barcode_type)";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", packaging";
$sql .= " values(";
$sql .= (isset($multicurrency_buyprice) ? "'".$this->db->escape(price2num($multicurrency_buyprice))."'" : 'null').",";
$sql .= (isset($multicurrency_unitBuyPrice) ? "'".$this->db->escape(price2num($multicurrency_unitBuyPrice))."'" : 'null').",";
@@ -435,6 +438,7 @@ class ProductFournisseur extends Product
$sql .= (empty($supplier_reputation) ? 'NULL' : "'".$this->db->escape($supplier_reputation)."'").",";
$sql .= (empty($barcode) ? 'NULL' : "'".$this->db->escape($barcode)."'").",";
$sql .= (empty($fk_barcode_type) ? 'NULL' : "'".$this->db->escape($fk_barcode_type)."'");
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", ".(empty($this->packaging) ? 1 : $this->db->escape($this->packaging)) ;
$sql .= ")";
$this->product_fourn_price_id = 0;
@@ -501,6 +505,7 @@ class ProductFournisseur extends Product
$sql .= " pfp.supplier_reputation, pfp.fk_user, pfp.datec,";
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code,";
$sql .= " pfp.barcode, pfp.fk_barcode_type";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql .= " WHERE pfp.rowid = ".(int) $rowid;
@@ -544,6 +549,12 @@ class ProductFournisseur extends Product
$this->fourn_barcode = $obj->barcode;
$this->fourn_fk_barcode_type = $obj->fk_barcode_type;
}
+
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
+ $this->packaging = $obj->packaging;
+ if ($this->packaging < $this->fourn_qty) $this->packaging = $this->fourn_qty;
+ }
+
if (empty($ignore_expression) && !empty($this->fk_supplier_price_expression))
{
$priceparser = new PriceParser($this->db);
@@ -598,7 +609,8 @@ class ProductFournisseur extends Product
$sql .= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation,";
$sql .= " pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code, pfp.datec, pfp.tms,";
$sql .= " pfp.barcode, pfp.fk_barcode_type";
- $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging";
+ $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp, ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
$sql .= " AND pfp.fk_soc = s.rowid";
$sql .= " AND s.status=1"; // only enabled company selected
@@ -647,6 +659,11 @@ class ProductFournisseur extends Product
$prodfourn->fourn_multicurrency_id = $record["fk_multicurrency"];
$prodfourn->fourn_multicurrency_code = $record["multicurrency_code"];
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) {
+ $prodfourn->packaging = $record["packaging"];
+ if ($prodfourn->packaging < $prodfourn->fourn_qty) $prodfourn->packaging = $prodfourn->fourn_qty;
+ }
+
if ($conf->barcode->enabled) {
$prodfourn->barcode = $record["barcode"];
$prodfourn->fk_barcode_type = $record["fk_barcode_type"];
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index b9293b6187c..9b96d5bef54 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -331,6 +331,10 @@ PossibleValues=Possible values
GoOnMenuToCreateVairants=Go on menu %s - %s to prepare attribute variants (like colors, size, ...)
UseProductFournDesc=Add a feature to define the descriptions of products defined by the vendors in addition to descriptions for customers
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
+QtyRecalculatedWithPackaging=The quantity of the line were recalculated according to supplier packaging
+
#Attributes
VariantAttributes=Variant attributes
ProductAttributes=Variant attributes for products
diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php
index 4d34037704f..85ad63e19e0 100644
--- a/htdocs/mrp/mo_agenda.php
+++ b/htdocs/mrp/mo_agenda.php
@@ -139,7 +139,7 @@ if ($object->id > 0)
// ------------------------------------------------------------
$linkback = '
'.$langs->trans("BackToList").'';
- $morehtmlref='
';
+ $morehtmlref = '
';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
@@ -175,7 +175,7 @@ if ($object->id > 0)
}
}
}
- $morehtmlref.='
';
+ $morehtmlref .= '
';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php
index 2bf6636cd6f..d5b6283a584 100644
--- a/htdocs/mrp/mo_document.php
+++ b/htdocs/mrp/mo_document.php
@@ -34,12 +34,12 @@ dol_include_once('/mrp/class/mo.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php');
// Load translation files required by the page
-$langs->loadLangs(array("mrp","companies","other","mails"));
+$langs->loadLangs(array("mrp", "companies", "other", "mails"));
-$action=GETPOST('action', 'aZ09');
-$confirm=GETPOST('confirm');
-$id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
+$action = GETPOST('action', 'aZ09');
+$confirm = GETPOST('confirm');
+$id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
$ref = GETPOST('ref', 'alpha');
// Security check - Protection if external user
@@ -55,31 +55,31 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined,
$offset = $conf->liste_limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (! $sortorder) $sortorder="ASC";
-if (! $sortfield) $sortfield="name";
+if (!$sortorder) $sortorder = "ASC";
+if (!$sortfield) $sortfield = "name";
//if (! $sortfield) $sortfield="position_name";
// Initialize technical objects
-$object=new Mo($db);
+$object = new Mo($db);
$extrafields = new ExtraFields($db);
-$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('modocument','globalcard')); // Note that conf->hooks_modules contains array
+$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('modocument', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
//if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->id);
-if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity?$object->entity:$conf->entity] . "/mo/" . dol_sanitizeFileName($object->ref);
+if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity ? $object->entity : $conf->entity]."/mo/".dol_sanitizeFileName($object->ref);
/*
* Actions
*/
-include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
+include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
/*
@@ -89,8 +89,8 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
$form = new Form($db);
$formproject = new FormProjets($db);
-$title=$langs->trans("Mo").' - '.$langs->trans("Files");
-$help_url='';
+$title = $langs->trans("Mo").' - '.$langs->trans("Files");
+$help_url = '';
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
@@ -105,18 +105,18 @@ if ($object->id)
// Build file list
- $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1);
- $totalsize=0;
- foreach($filearray as $key => $file)
+ $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
+ $totalsize = 0;
+ foreach ($filearray as $key => $file)
{
- $totalsize+=$file['size'];
+ $totalsize += $file['size'];
}
// Object card
// ------------------------------------------------------------
- $linkback = '
' . $langs->trans("BackToList") . '';
+ $linkback = '
'.$langs->trans("BackToList").'';
- $morehtmlref='
';
+ $morehtmlref = '
';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
@@ -152,7 +152,7 @@ if ($object->id)
}
}
}
- $morehtmlref.='
';
+ $morehtmlref .= '
';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -176,12 +176,12 @@ if ($object->id)
$modulepart = 'mrp';
$permission = $user->rights->mrp->write;
$permtoedit = $user->rights->mrp->write;
- $param = '&id=' . $object->id;
+ $param = '&id='.$object->id;
//$relativepathwithnofile='mo/' . dol_sanitizeFileName($object->id).'/';
- $relativepathwithnofile='mo/' . dol_sanitizeFileName($object->ref).'/';
+ $relativepathwithnofile = 'mo/'.dol_sanitizeFileName($object->ref).'/';
- include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
}
else
{
diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php
index 99d9d62d6dc..e22d3e4b610 100644
--- a/htdocs/mrp/mo_note.php
+++ b/htdocs/mrp/mo_note.php
@@ -30,20 +30,20 @@ dol_include_once('/mrp/class/mo.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php');
// Load translation files required by the page
-$langs->loadLangs(array("mrp","companies"));
+$langs->loadLangs(array("mrp", "companies"));
// Get parameters
-$id = GETPOST('id', 'int');
+$id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
-$action = GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
// Initialize technical objects
-$object=new Mo($db);
+$object = new Mo($db);
$extrafields = new ExtraFields($db);
-$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('monote','globalcard')); // Note that conf->hooks_modules contains array
+$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('monote', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
@@ -54,10 +54,10 @@ $extrafields->fetch_name_optionals_label($object->table_element);
//$result = restrictedArea($user, 'mrp', $id);
// Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity] . "/" . $object->id;
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id;
-$permissionnote=1;
+$permissionnote = 1;
//$permissionnote=$user->rights->mrp->creer; // Used by the include of actions_setnotes.inc.php
@@ -66,7 +66,7 @@ $permissionnote=1;
* Actions
*/
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
/*
@@ -77,10 +77,10 @@ $form = new Form($db);
$formproject = new FormProjets($db);
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes';
-$help_url='';
+$help_url = '';
llxHeader('', $langs->trans('Mo'), $help_url);
-if ($id > 0 || ! empty($ref))
+if ($id > 0 || !empty($ref))
{
$object->fetch_thirdparty();
@@ -90,9 +90,9 @@ if ($id > 0 || ! empty($ref))
// Object card
// ------------------------------------------------------------
- $linkback = '
' . $langs->trans("BackToList") . '';
+ $linkback = '
'.$langs->trans("BackToList").'';
- $morehtmlref='
';
+ $morehtmlref = '
';
// Ref customer
//$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
//$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1);
@@ -128,7 +128,7 @@ if ($id > 0 || ! empty($ref))
}
}
}
- $morehtmlref.='
';
+ $morehtmlref .= '
';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -137,7 +137,7 @@ if ($id > 0 || ! empty($ref))
print '
';
- $cssclass="titlefield";
+ $cssclass = "titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '
';
diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php
index 3df07bf36c3..d1a4f6bcf6f 100644
--- a/htdocs/product/admin/product.php
+++ b/htdocs/product/admin/product.php
@@ -156,6 +156,18 @@ if ($action == 'other')
$resql_new = $db->query($sql_new);
}
}
+
+ $value = GETPOST('activate_useProdSupplierPackaging', 'alpha');
+ $res = dolibarr_set_const($db, "PRODUCT_USE_SUPPLIER_PACKAGING", $value, 'chaine', 0, '', $conf->entity);
+ if ($value) {
+ $sql_test = "SELECT count(packaging) as cpt FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE 1";
+ $resql = $db->query($sql_test);
+ if (!$resql && $db->lasterrno == 'DB_ERROR_NOSUCHFIELD') // if the field does not exist, we create it
+ {
+ $sql_new = "ALTER TABLE ".MAIN_DB_PREFIX."product_fournisseur_price ADD COLUMN packaging double(24,8) DEFAULT 1";
+ $resql_new = $db->query($sql_new);
+ }
+ }
}
if ($action == 'specimen') // For products
@@ -676,6 +688,13 @@ if (! empty($conf->fournisseur->enabled))
print $form->selectyesno("activate_useProdFournDesc", (! empty($conf->global->PRODUIT_FOURN_TEXTS)?$conf->global->PRODUIT_FOURN_TEXTS:0), 1);
print '';
print '';
+
+ print '
';
+ print '| '.$langs->trans("UseProductSupplierPackaging").' | ';
+ print '';
+ print $form->selectyesno("activate_useProdSupplierPackaging", (! empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)?$conf->global->PRODUCT_USE_SUPPLIER_PACKAGING:0), 1);
+ print ' | ';
+ print '
';
}
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 17a1e4952ce..3c47bd47765 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1724,6 +1724,7 @@ class Product extends CommonObject
$sql .= " pfp.fk_product, pfp.ref_fourn, pfp.desc_fourn, pfp.fk_soc, pfp.tva_tx, pfp.fk_supplier_price_expression";
$sql .= " ,pfp.default_vat_code";
$sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql .= " WHERE pfp.rowid = ".$prodfournprice;
if ($qty > 0) { $sql .= " AND pfp.quantity <= ".$qty;
@@ -1766,6 +1767,7 @@ class Product extends CommonObject
$this->fourn_multicurrency_tx = $obj->multicurrency_tx;
$this->fourn_multicurrency_id = $obj->fk_multicurrency;
$this->fourn_multicurrency_code = $obj->multicurrency_code;
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $this->packaging = $obj->packaging;
$result = $obj->fk_product;
return $result;
}
@@ -1776,6 +1778,7 @@ class Product extends CommonObject
$sql .= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.desc_fourn as desc_supplier, pfp.tva_tx, pfp.fk_supplier_price_expression";
$sql .= " ,pfp.default_vat_code";
$sql .= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code";
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $sql.= ", pfp.packaging";
$sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp";
$sql .= " WHERE pfp.fk_product = ".$product_id;
if ($fourn_ref != 'none') { $sql .= " AND pfp.ref_fourn = '".$fourn_ref."'";
@@ -1824,7 +1827,8 @@ class Product extends CommonObject
$this->fourn_multicurrency_tx = $obj->multicurrency_tx;
$this->fourn_multicurrency_id = $obj->fk_multicurrency;
$this->fourn_multicurrency_code = $obj->multicurrency_code;
- $result = $obj->fk_product;
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) $this->packaging = $obj->packaging;
+ $result = $obj->fk_product;
return $result;
}
else
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 0abb57d8951..7ff90dc296a 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -170,6 +170,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');
if ($tva_tx == '')
{
@@ -232,6 +233,12 @@ if (empty($reshook))
}
}
+ if (empty($packaging)) $packaging = 1;
+
+ if ($packaging < $quantity) $packaging = $quantity;
+
+ $object->packaging = $packaging;
+
if (!$error)
{
$db->begin();
@@ -882,6 +889,7 @@ SCRIPT;
print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center ');
}
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING)) print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ');
// fetch optionals attributes and labels
@@ -1012,6 +1020,14 @@ SCRIPT;
print '';
}
+ // Packaging
+ if (!empty($conf->global->PRODUCT_USE_SUPPLIER_PACKAGING))
+ {
+ print '
';
+ print price2num($productfourn->packaging);
+ print ' | ';
+ }
+
// Date
print '
';
print dol_print_date(($productfourn->fourn_date_modification ? $productfourn->fourn_date_modification : $productfourn->date_modification), "dayhour");
diff --git a/htdocs/user/note.php b/htdocs/user/note.php
index dc2f11b96fa..ab4df07e193 100644
--- a/htdocs/user/note.php
+++ b/htdocs/user/note.php
@@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'aZ09');
-$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'usernote'; // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'usernote'; // To manage different context of search
// Load translation files required by page
$langs->loadLangs(array('companies', 'members', 'bills', 'users'));
@@ -39,25 +39,25 @@ $object->fetch($id, '', '', 1);
$object->getrights();
// If user is not user read and no permission to read other users, we stop
-if (($object->id != $user->id) && (! $user->rights->user->user->lire)) accessforbidden();
+if (($object->id != $user->id) && (!$user->rights->user->user->lire)) accessforbidden();
// Security check
-$socid=0;
+$socid = 0;
if ($user->socid > 0) $socid = $user->socid;
-$feature2 = (($socid && $user->rights->user->self->creer)?'':'user');
+$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user');
$result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
-$hookmanager->initHooks(array('usercard','usernote','globalcard'));
+$hookmanager->initHooks(array('usercard', 'usernote', 'globalcard'));
/*
* Actions
*/
-$parameters=array('id'=>$socid);
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+$parameters = array('id'=>$socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
@@ -118,7 +118,7 @@ if ($id)
print "id."\">";
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
- $doleditor=new DolEditor('note_private', $object->note_private, '', 280, 'dolibarr_notes', 'In', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%');
+ $doleditor = new DolEditor('note_private', $object->note_private, '', 280, 'dolibarr_notes', 'In', true, false, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_8, '90%');
$doleditor->Create();
}
else
|