From 7f0d81d255a58bdc0c7316b2eea21696c3c3cec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 8 Nov 2015 15:12:31 +0100 Subject: [PATCH 1/7] Missing changes of PR #3927 --- htdocs/product/price.php | 159 +++++++++++++++++++++++---------------- 1 file changed, 95 insertions(+), 64 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 497f676ae8c..114f6a8df53 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -431,13 +431,34 @@ $titre = $langs->trans("CardProduct" . $object->type); $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'price', $titre, 0, $picto); -dol_banner_tab($object, 'ref', '', ($user->societe_id?0:1), 'ref'); +print ''; +// Ref +print ''; +print ''; +print ''; -print '
'; +// Label +print '
'; -print '
'; -print '
' . $langs->trans("Ref") . ''; +print $form->showrefnav($object, 'ref', '', 1, 'ref'); +print '
' . $langs->trans("Label") . '' . $object->label . '
'; +$isphoto = $object->is_photo_available($conf->product->multidir_output [$object->entity]); + +$nblignes = 5; +if ($isphoto) { + // Photo + print ''; +} + +print ''; + +// Status (to sell) +print ''; // MultiPrix if (! empty($conf->global->PRODUIT_MULTIPRICES)) @@ -450,7 +471,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) $soc->fetch($socid); // Selling price - print ''; + print '' . $langs->trans("SellingPrice") . ''; print ''; + print ''; } else { // TVA - print ''; + print ''; } print ''; @@ -613,7 +634,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) else { // TVA - print ''; + print ''; // Price print '
'; + print $object->show_photos($conf->product->multidir_output [$object->entity], 1, 1, 0, 0, 0, 80); + print '
' . $langs->trans("Status") . ' (' . $langs->trans("Sell") . ')'; +print $object->getLibStatut(2, 0); +print '
' . $langs->trans("SellingPrice") . '
'; if ($object->multiprices_base_type[$soc->price_level] == 'TTC') { print price($object->multiprices_ttc[$soc->price_level]); @@ -491,12 +512,12 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { // We show only vat for level 1 - print '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx [1], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->multiprices_tva_tx [1], true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
'.$langs->trans("PriceLevel").''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("VATRate") . '' . vatrate($object->tva_tx . ($object->tva_npr ? '*' : ''), true) . '
' . $langs->trans("SellingPrice") . ''; @@ -711,10 +732,6 @@ else print "
\n"; -print ''; -print '
'; - - dol_fiche_end(); @@ -793,7 +810,7 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se print '

'; } -if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights->service->creer)) +if ($action == 'edit_price' && $object->getRights()->creer) { print load_fiche_titre($langs->trans("NewPrice"), ''); @@ -809,7 +826,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print ''; // VAT - print ''; @@ -817,7 +834,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print ''; - print ''; print ''; @@ -825,7 +842,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> // Only show price mode and expression selector if module is enabled if (! empty($conf->dynamicprices->enabled)) { // Price mode selector - print ''; + // This code hides the numeric price input if is not selected, loads the editor page if editor button is pressed - print ''; + + rights->produit->creer || $user->rights-> print 'global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { + print ' colspan="2"'; + } + print '>'; if ($object->price_base_type == 'TTC') { - print ''; + print ''; } - print ''; + print ''; print '
' . $langs->trans("VATRate") . ''; + print '
' . $langs->trans("VATRate") . ''; print $form->load_tva("tva_tx", $object->tva_tx, $mysoc, '', $object->id, $object->tva_npr); print '
'; print $langs->trans('PriceBase'); print ''; + print ''; print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); print '
'.$langs->trans("PriceMode").''; + print '
'.$langs->trans("PriceMode").''; $price_expression = new PriceExpression($db); $price_expression_list = array(0 => $langs->trans("PriceNumeric")); //Put the numeric mode as first option foreach ($price_expression->list_price_expression() as $entry) { @@ -835,17 +852,18 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print $form->selectarray('eid', $price_expression_list, $price_expression_preselection); print ' 
'.$langs->trans("PriceExpressionEditor").'
'; print '
'; $text = $langs->trans('SellingPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - print ''; + print ''; if ($object->price_base_type == 'TTC') { print ''; } else { @@ -874,16 +893,21 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print '
'; $text = $langs->trans('MinPrice'); print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print ''; + print ''; } else { - print ''; + print ''; } if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { - print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().'
'; @@ -927,65 +951,72 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> id . '" method="POST">'; + print ''; + print ''; + print ''; - for($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) - { + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { + print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; + } - if ($i > 1) print '
'; - elseif (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($conf->global->PRODUIT_MULTIPRICES_ALLOW_AUTOCALC_PRICELEVEL)) { - print $langs->trans('UseMultipriceRules'). ' price_autogen ? 'checked' : '').'>

'; - } - print ''; - print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) - { - print ''; - } - - print ''; + print '
'; + print ' + '; + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { + print ''; + } + print ' + '; + if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { + print ''; + } + print ''; + + for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i ++) { + $var = !$var; + + print ''; + print ''; // VAT - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // This option is kept for backward compatibility but has no sense - { - print ''; + print ''; } - + // Selling price - print ''; + print ''; // Min price - print ''; } - print ''; - - print '
'.$langs->trans("PriceLevel").''.$langs->trans("VATRate").''.$langs->trans("SellingPrice").''.$langs->trans("MinPrice").'
'; + print $form->textwithpicto($langs->trans('SellingPrice') . ' ' . $i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print '
' . $langs->trans("VATRate") . ''; + if (empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) { + print ''; + } else { + // This option is kept for backward compatibility but has no sense + print ''; print $form->load_tva("tva_tx[" . $i.']', $object->multiprices_tva_tx[$i], $mysoc, '', $object->id); - print '
'; - $text = $langs->trans('SellingPrice') . ' ' . $i; - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); - print ''; + print ''; if ($object->multiprices_base_type [$i] == 'TTC') { print ''; } else { print ''; } print ' '.$form->selectPriceBaseType($object->multiprices_base_type [$i], "multiprices_base_type[" . $i."]"); - print '
'; - $text = $langs->trans('MinPrice') . ' ' . $i; - print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + print ''; if ($object->multiprices_base_type [$i] == 'TTC') { - print ''; + print ''; } else { - print ''; + print ''; } if ( !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { print ''.$langs->trans("MinimumRecommendedPrice", price($maxpricesupplier,0,'',1,-1,-1,'auto')).' '.img_warning().'
'; + print ''; + print ''; } - print '
'; + print '
'; print ''; print '   '; print '
'; From 9bc4b9f0bc45867fa8346396ec25987038319a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 8 Nov 2015 16:45:42 +0100 Subject: [PATCH 2/7] Moved update function after updatePrice --- htdocs/product/price.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 114f6a8df53..3c37530ea3e 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -179,12 +179,6 @@ if (empty($reshook)) ); } - if (!$error && $object->update($object->id, $user) < 1) { - $error++; - setEventMessage($object->error, 'errors'); - $action = 'edit_price'; - } - if (!$error) { $db->begin(); @@ -215,6 +209,11 @@ if (empty($reshook)) } } + if (!$error && $object->update($object->id, $user) < 0) { + $error++; + setEventMessage($object->error, 'errors'); + } + if (empty($error)) { $action = ''; setEventMessage($langs->trans("RecordSaved")); From 9cdf45e0a6e6a65fd7eb275ee879643c6af5b518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 8 Nov 2015 16:54:54 +0100 Subject: [PATCH 3/7] Fixed JS compatibility with multiprices price generator --- htdocs/product/price.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 3c37530ea3e..b7c714c9887 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -929,8 +929,8 @@ if ($action == 'edit_price' && $object->getRights()->creer)