diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 1234deef497..97f29de72f6 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -103,6 +103,9 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -123,9 +126,6 @@ if ($cancel) { $action = ''; } -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); - $parameters = array('socid'=>$socid, 'id_prod'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -404,13 +404,23 @@ if ($id > 0 || $ref) { print '
'; print '| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| ';
$textdesc = $langs->trans("CostPriceDescription");
$textdesc .= " ".$langs->trans("CostPriceUsage"); $text = $form->textwithpicto($langs->trans("CostPrice"), $textdesc, 1, 'help', ''); print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); - print ' | '; + print ' | '; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print ' | |
| '.$langs->trans("BuyingPriceMin").' | '; - print ''; + print ' | '; $product_fourn = new ProductFournisseur($db); if ($product_fourn->find_min_price_product_fournisseur($object->id) > 0) { if ($product_fourn->product_fourn_price_id > 0) { diff --git a/htdocs/product/price.php b/htdocs/product/price.php index bb46839e588..03867bb65e9 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -717,8 +717,18 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ $soc->id = $socid; $soc->fetch($socid); + // Type + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { + $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); + print ' | |
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| '; + print ' | |||
| '; print $langs->trans("SellingPrice"); print ' | '; print ''; @@ -791,13 +801,33 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ } } else { if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { // using this option is a bug. kept for backward compatibility + // Type + if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { + $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); + print ' | ||
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| '.$langs->trans("DefaultTaxRate").' | '; + print '|||
| '.$langs->trans("DefaultTaxRate").' | '; print ''.vatrate($object->multiprices_tva_tx[1], true).' | '; print '||
| '; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print ' | '; + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); + print ' | ||
| '.$langs->trans("DefaultTaxRate").' | '; + print ' | ||
| '.$langs->trans("DefaultTaxRate").' | '; $positiverates = ''; if (price2num($object->tva_tx)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index a00feb194a0..7fcee8f59cd 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -77,6 +77,7 @@ $batchnumber = GETPOST('batch_number', 'san_alpha'); if (!empty($batchnumber)) { $batchnumber = trim($batchnumber); } +$cost_price = GETPOST('cost_price', 'alpha'); // Security check if ($user->socid) { @@ -113,6 +114,9 @@ $hookmanager->initHooks(array('stockproductcard', 'globalcard')); $error = 0; +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->lire)); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); + if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { restrictedArea($user, 'produit', $object->id, 'product&product', '', ''); @@ -139,6 +143,21 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +if ($action == 'setcost_price') { + if ($id) { + $result = $object->fetch($id); + $object->cost_price = price2num($cost_price); + $result = $object->update($object->id, $user); + if ($result > 0) { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $action = ''; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } +} + if ($action == 'addlimitstockwarehouse' && !empty($user->rights->produit->creer)) { $seuil_stock_alerte = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); @@ -600,9 +619,9 @@ if ($id > 0 || $ref) { if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ' | ||
| '; - print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ' | '; - print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat); + print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print ' | '; + print ' | '; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); print ' | ';