From 44882f40352a864bad90ec65c2f1b5ce7c886745 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 5 Nov 2014 17:03:53 +0100 Subject: [PATCH] improve "hide margin infos" button : hide ALL informations relatives to margin AND store the state of the button in a cookie instead of shared config option --- htdocs/core/class/commonobject.class.php | 23 ++++++++++++++--------- htdocs/core/tpl/objectline_create.tpl.php | 12 ++++++------ htdocs/core/tpl/objectline_edit.tpl.php | 10 +++++----- htdocs/core/tpl/objectline_view.tpl.php | 6 +++--- htdocs/langs/en_US/margins.lang | 1 + htdocs/langs/fr_FR/margins.lang | 2 ++ 6 files changed, 31 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a9c39fa790f..df6d7988560 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2525,14 +2525,14 @@ abstract class CommonObject if (! empty($conf->margin->enabled) && empty($user->societe_id)) { if ($conf->global->MARGIN_TYPE == "1") - print ''.$langs->trans('BuyingPrice').''; + print ''.$langs->trans('BuyingPrice').''; else - print ''.$langs->trans('CostPrice').''; + print ''.$langs->trans('CostPrice').''; if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) - print ''.$langs->trans('MarginRate').''; + print ''.$langs->trans('MarginRate').''; if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) - print ''.$langs->trans('MarkRate').''; + print ''.$langs->trans('MarkRate').''; } // Total HT @@ -3012,11 +3012,16 @@ abstract class CommonObject $marginInfo = $this->getMarginInfos($force_price); - if (! empty($conf->global->MARGININFO_HIDE_SHOW)) - { - print ""; - if ($conf->global->MARGININFO_HIDE_SHOW == 2) print ''; // hide by default - } + print $langs->trans('ShowMarginInfos').' : '; + $hidemargininfos = $_COOKIE['DOLUSER_MARGININFO_HIDE_SHOW']; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + + print ''; + if (!empty($hidemargininfos)) print ''; print ''; print ''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6af092c7e92..86ef648bf94 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -61,7 +61,7 @@ if (in_array($object->element,array('propal','facture','invoice','commande','ord if (! empty($usemargins)) { ?> - rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''; - if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''; + if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''; + if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''; } ?> @@ -217,7 +217,7 @@ else { if (! empty($usemargins)) { ?> - '; + echo ''; $coldisplay++; } if (! empty($conf->global->DISPLAY_MARK_RATES)) { - echo ''; + echo ''; $coldisplay++; } } diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 68a19c0bb73..fbe2870a6a4 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -125,7 +125,7 @@ $coldisplay=-1; // We remove first td if (! empty($usemargins)) { ?> - '; + echo ''; else - echo ''; + echo ''; $coldisplay++; } elseif (! empty($conf->global->DISPLAY_MARK_RATES)) @@ -149,9 +149,9 @@ $coldisplay=-1; // We remove first td $mark_rate = (isset($_POST["np_markRate"])?$_POST["np_markRate"]:price($line->marque_tx)); // if credit note, dont allow to modify margin if ($line->subprice < 0) - echo ''; + echo ''; else - echo ''; + echo ''; $coldisplay++; } } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 777732aa192..1c8bb07f560 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -141,13 +141,13 @@ if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0; if (! empty($conf->margin->enabled) && empty($user->societe_id)) { $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?> - + global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) {?> - + global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> - + special_code == 3) { ?> diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index 38b6482a4f3..0cf9bc34410 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -41,3 +41,4 @@ AgentContactType=Commercial agent contact type AgentContactTypeDetails=Define what contact type (linked on invoices) will be used for margin report per sale representative rateMustBeNumeric=Rate must be a numeric value markRateShouldBeLesserThan100=Mark rate should be lower than 100 +ShowMarginInfos=Show margin infos \ No newline at end of file diff --git a/htdocs/langs/fr_FR/margins.lang b/htdocs/langs/fr_FR/margins.lang index dabd381ab1a..42951e5979e 100644 --- a/htdocs/langs/fr_FR/margins.lang +++ b/htdocs/langs/fr_FR/margins.lang @@ -48,3 +48,5 @@ Charges=Charges AgentContactType=Type de contact agent commercial AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera utilisé pour le rapport de marges par agent commercial + +ShowMarginInfos=Afficher les infos liées aux marges \ No newline at end of file
+ '; if ($conf->global->MARGIN_TYPE == "1") @@ -72,8 +72,8 @@ if (in_array($object->element,array('propal','facture','invoice','commande','ord ?> '.$langs->trans('MarginRate').''.$langs->trans('MarkRate').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'  + product->enabled) || ! empty($conf->service->enabled)) { ?> @@ -232,12 +232,12 @@ else { { if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { - echo '%%%% + product->enabled) || ! empty($conf->service->enabled)) { ?> @@ -139,9 +139,9 @@ $coldisplay=-1; // We remove first td $margin_rate = (isset($_POST["np_marginRate"])?$_POST["np_marginRate"]:(($line->pa_ht == 0)?'':price($line->marge_tx))); // if credit note, dont allow to modify margin if ($line->subprice < 0) - echo ''.$margin_rate.'%'.$margin_rate.'%%%'.$mark_rate.'%'.$mark_rate.'%%%
pa_ht); ?>
pa_ht); ?> pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?>pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?> marque_tx, null, null, null, null, $rounding).'%'; ?>marque_tx, null, null, null, null, $rounding).'%'; ?>