From ad2a8d39c5c42a03baa6f40d24cf222eb49fb542 Mon Sep 17 00:00:00 2001 From: Florian Henry Date: Sun, 27 Oct 2013 13:30:35 +0100 Subject: [PATCH 01/13] Add nl_NL margin translation --- htdocs/langs/nl_NL/margins.lang | 52 +++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 htdocs/langs/nl_NL/margins.lang diff --git a/htdocs/langs/nl_NL/margins.lang b/htdocs/langs/nl_NL/margins.lang new file mode 100644 index 00000000000..3494ca6d643 --- /dev/null +++ b/htdocs/langs/nl_NL/margins.lang @@ -0,0 +1,52 @@ +# Dolibarr language file - en_US - marges +CHARSET=UTF-8 + +Margin=Marge +Margins=Marges +TotalMargin=Marge Totaal +MarginOnProducts=Marge / Training +MarginOnServices=Marge / Dienst +MarginRate=Marge verhouding +MarkRate=Markerings verhouding +DisplayMarginRates=Toon Marge Verhouding +DisplayMarkRates=Toon Markeringsverhouding +InputPrice=Voer Prijs in + +margin=Winst marge management +margesSetup=Winst marge management setup + +MarginDetails=Marge details + +ProductMargins=Product marge +CustomerMargins=Klant marges +AgentMargins=Acc. Manager marges + +ProductService=Trainning of Dienst +AllProducts=Alle Trainingen en Diensten +ChooseProduct/Service=Kies Training of Dienst +CommercialAgent=Commerciel Agent + +StartDate=Start datum +EndDate=Eind datum +Launch=Start + +ForceBuyingPriceIfNull=Forceer een inkoopprijs indien null +ForceBuyingPriceIfNullDetails=indien "ON", marge wodt nul (inkoopprijs = verkoopprijs), anders("OFF"), marge is gelijk verkoopprijs (inkoopprijs = 0) +MARGIN_METHODE_FOR_DISCOUNT=Marge methode voor globale discounts +UseDiscountAsProduct=Als een training +UseDiscountAsService=Als een dienst +UseDiscountOnTotal=Op subtotaal +MARGIN_METHODE_FOR_DISCOUNT_DETAILS=Definieert als een globale discount wordt behandelt als een training, een dienst, of alleen een subtotaal voor marge berekening. + +MARGIN_TYPE=Marge type +MargeBrute=Groffe marge +MargeNette=Netto marge +MARGIN_TYPE_DETAILS=Groffe marge : Verkoopprijs - Inkoopprijs
Netto marge : Verkoopprijs - Kostprijs + +CostPrice=Kostprijs +BuyingCost=Kostprijs +UnitCharges=Unit toeslag +Charges=Toeslag + +AgentContactType=Contact type used voor commissie +AgentContactTypeDetails=Definieer het contact type (gelinked op facturen) wordt geassocieerd met commercieel agent \ No newline at end of file From ba0273ccc4c6f156f758616547b054c855949cf0 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 30 Oct 2013 18:17:37 +0100 Subject: [PATCH 02/13] fix bad rounding on margin calculation and display --- ChangeLog | 2 + htdocs/core/class/commonobject.class.php | 46 +++++++++++----------- htdocs/core/tpl/objectline_view.tpl.php | 7 ++-- htdocs/margin/agentMargins.php | 23 +++++------ htdocs/margin/customerMargins.php | 48 +++++++++++------------ htdocs/margin/lib/margins.lib.php | 4 +- htdocs/margin/productMargins.php | 47 +++++++++++----------- htdocs/margin/tabs/productMargins.php | 50 ++++++++++++------------ htdocs/margin/tabs/thirdpartyMargins.php | 42 ++++++++++---------- 9 files changed, 134 insertions(+), 135 deletions(-) diff --git a/ChangeLog b/ChangeLog index 319bde9bfa1..ac0f5d5e9c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ -------------------------------------------------------------- English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.4.2 compared to 3.4.1 ***** +Fix: Bad rounding on margin calculations and display ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f6a1d7ef32c..8343c219d31 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2011-2012 Philippe Grand * Copyright (C) 2012 Marcos García * @@ -3175,14 +3175,14 @@ abstract class CommonObject } } if ($marginInfos['pa_products'] > 0) - $marginInfos['margin_rate_products'] = 100 * round($marginInfos['margin_on_products'] / $marginInfos['pa_products'],5); + $marginInfos['margin_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pa_products']; if ($marginInfos['pv_products'] > 0) - $marginInfos['mark_rate_products'] = 100 * round($marginInfos['margin_on_products'] / $marginInfos['pv_products'],5); + $marginInfos['mark_rate_products'] = 100 * $marginInfos['margin_on_products'] / $marginInfos['pv_products']; if ($marginInfos['pa_services'] > 0) - $marginInfos['margin_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pa_services'],5); + $marginInfos['margin_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pa_services']; if ($marginInfos['pv_services'] > 0) - $marginInfos['mark_rate_services'] = 100 * round($marginInfos['margin_on_services'] / $marginInfos['pv_services'],5); + $marginInfos['mark_rate_services'] = 100 * $marginInfos['margin_on_services'] / $marginInfos['pv_services']; // if credit note, margin = -1 * (abs(selling_price) - buying_price) if ($marginInfos['pv_total'] < 0) @@ -3190,9 +3190,9 @@ abstract class CommonObject else $marginInfos['total_margin'] = $marginInfos['pv_total'] - $marginInfos['pa_total']; if ($marginInfos['pa_total'] > 0) - $marginInfos['total_margin_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pa_total'],5); + $marginInfos['total_margin_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pa_total']; if ($marginInfos['pv_total'] > 0) - $marginInfos['total_mark_rate'] = 100 * round($marginInfos['total_margin'] / $marginInfos['pv_total'],5); + $marginInfos['total_mark_rate'] = 100 * $marginInfos['total_margin'] / $marginInfos['pv_total']; return $marginInfos; } @@ -3209,6 +3209,8 @@ abstract class CommonObject if (! empty($user->societe_id)) return; + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); + $marginInfo = $this->getMarginInfos($force_price); print ''; @@ -3228,34 +3230,34 @@ abstract class CommonObject //if ($marginInfo['margin_on_products'] != 0 && $marginInfo['margin_on_services'] != 0) { print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; //} print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print ''; + print ''; print ''; print '
'.$langs->trans('MarginOnProducts').''.price($marginInfo['pv_products']).''.price($marginInfo['pa_products']).''.price($marginInfo['margin_on_products']).''.price($marginInfo['pv_products'], null, null, null, null, $rounding).''.price($marginInfo['pa_products'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_products'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_products'] == '')?'n/a':price($marginInfo['margin_rate_products']).'%').''.(($marginInfo['margin_rate_products'] == '')?'n/a':price($marginInfo['margin_rate_products'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_products'] == '')?'n/a':price($marginInfo['mark_rate_products']).'%').''.(($marginInfo['mark_rate_products'] == '')?'n/a':price($marginInfo['mark_rate_products'], null, null, null, null, $rounding).'%').'
'.$langs->trans('MarginOnServices').''.price($marginInfo['pv_services']).''.price($marginInfo['pa_services']).''.price($marginInfo['margin_on_services']).''.price($marginInfo['pv_services'], null, null, null, null, $rounding).''.price($marginInfo['pa_services'], null, null, null, null, $rounding).''.price($marginInfo['margin_on_services'], null, null, null, null, $rounding).''.(($marginInfo['margin_rate_services'] == '')?'n/a':price($marginInfo['margin_rate_services']).'%').''.(($marginInfo['margin_rate_services'] == '')?'n/a':price($marginInfo['margin_rate_services'], null, null, null, null, $rounding).'%').''.(($marginInfo['mark_rate_services'] == '')?'n/a':price($marginInfo['mark_rate_services']).'%').''.(($marginInfo['mark_rate_services'] == '')?'n/a':price($marginInfo['mark_rate_services'], null, null, null, null, $rounding).'%').'
'.$langs->trans('TotalMargin').''.price($marginInfo['pv_total']).''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.price($marginInfo['pv_total'], null, null, null, null, $rounding).''.price($marginInfo['pa_total'], null, null, null, null, $rounding).''.price($marginInfo['total_margin'], null, null, null, null, $rounding).''.(($marginInfo['total_margin_rate'] == '')?'n/a':price($marginInfo['total_margin_rate']).'%').''.(($marginInfo['total_margin_rate'] == '')?'n/a':price($marginInfo['total_margin_rate'], null, null, null, null, $rounding).'%').''.(($marginInfo['total_mark_rate'] == '')?'n/a':price($marginInfo['total_mark_rate']).'%').''.(($marginInfo['total_mark_rate'] == '')?'n/a':price($marginInfo['total_mark_rate'], null, null, null, null, $rounding).'%').'
'; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index dcb46ac1857..742a1ff7061 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2011 Laurent Destailleur - * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012-2013 Christophe Battarel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -120,14 +120,15 @@ margin->enabled) && empty($user->societe_id)) { + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?> pa_ht); ?> global->DISPLAY_MARGIN_RATES)) {?> - pa_ht == 0)?'n/a':price($line->marge_tx).'%'); ?> + pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?> global->DISPLAY_MARK_RATES)) {?> - marque_tx).'%'; ?> + marque_tx, null, null, null, null, $rounding).'%'; ?> special_code == 3) { ?> diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index dc858d66b76..9836b6408c3 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -172,9 +172,6 @@ if ($result) print_liste_field_titre($langs->trans("MarkRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); print "\n"; - $cumul_achat = 0; - $cumul_vente = 0; - $cumul_qty = 0; $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) @@ -191,13 +188,13 @@ if ($result) if ($marge < 0) { - $marginRate = ($pa != 0)?-1*(100 * round($marge / $pa, 5)):'' ; - $markRate = ($pv != 0)?-1*(100 * round($marge / $pv, 5)):'' ; + $marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ; } else { - $marginRate = ($pa != 0)?(100 * round($marge / $pa, 5)):'' ; - $markRate = ($pv != 0)?(100 * round($marge / $pv, 5)):'' ; + $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } $var=!$var; @@ -214,18 +211,16 @@ if ($result) print "".$userstatic->getFullName($langs,0,0,0)."\n"; } - print "".price($pv)."\n"; - print "".price($pa)."\n"; - print "".price($marge)."\n"; + print "".price($pv, null, null, null, null, $rounding)."\n"; + print "".price($pa, null, null, null, null, $rounding)."\n"; + print "".price($marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; $i++; - $cumul_achat += round($objp->buying_price, $rounding); - $cumul_vente += round($objp->selling_price, $rounding); } } print ""; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index c42f73bb87c..e4f29260e09 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -213,7 +213,7 @@ if ($result) $cumul_achat = 0; $cumul_vente = 0; - $cumul_qty = 0; + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) @@ -230,13 +230,13 @@ if ($result) if ($marge < 0) { - $marginRate = ($pa != 0)?-1*(100 * round($marge / $pa, 5)):'' ; - $markRate = ($pv != 0)?-1*(100 * round($marge / $pv, 5)):'' ; + $marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ; } else { - $marginRate = ($pa != 0)?(100 * round($marge / $pa, 5)):'' ; - $markRate = ($pv != 0)?(100 * round($marge / $pv, 5)):'' ; + $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } $var=!$var; @@ -258,18 +258,18 @@ if ($result) print "".$companystatic->getNomUrl(1,'customer')."\n"; } - print "".price($pv)."\n"; - print "".price($pa)."\n"; - print "".price($marge)."\n"; + print "".price($pv, null, null, null, null, $rounding)."\n"; + print "".price($pa, null, null, null, null, $rounding)."\n"; + print "".price($marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; $i++; - $cumul_achat += round($objp->buying_price, $rounding); - $cumul_vente += round($objp->selling_price, $rounding); + $cumul_achat += $objp->buying_price; + $cumul_vente += $objp->selling_price; } } @@ -278,13 +278,13 @@ if ($result) $totalMargin = $cumul_vente - $cumul_achat; if ($totalMargin < 0) { - $marginRate = ($cumul_achat != 0)?-1*(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?-1*(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else { - $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; } print ''; @@ -293,13 +293,13 @@ if ($result) else print ''; print $langs->trans('TotalMargin').""; - print "".price($cumul_vente)."\n"; - print "".price($cumul_achat)."\n"; - print "".price($totalMargin)."\n"; + print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; + print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; + print "".price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; print ""; @@ -325,9 +325,9 @@ $(document).ready(function() { $("div.fiche form").submit(); }); - $("#totalMargin").html(""); - $("#marginRate").html(""); - $("#markRate").html(""); + $("#totalMargin").html(""); + $("#marginRate").html(""); + $("#markRate").html(""); }); diff --git a/htdocs/margin/lib/margins.lib.php b/htdocs/margin/lib/margins.lib.php index bfa5d530e29..6d1ded03419 100644 --- a/htdocs/margin/lib/margins.lib.php +++ b/htdocs/margin/lib/margins.lib.php @@ -125,10 +125,10 @@ function getMarginInfos($pvht, $remise_percent, $tva_tx, $localtax1_tx, $localta // calcul taux marge if ($paht_ret != 0) - $marge_tx_ret = round((100 * $marge) / $paht_ret, 3); + $marge_tx_ret = (100 * $marge) / $paht_ret; // calcul taux marque if ($pu_ht_remise != 0) - $marque_tx_ret = round((100 * $marge) / $pu_ht_remise, 3); + $marque_tx_ret = (100 * $marge) / $pu_ht_remise; return array($paht_ret, $marge_tx_ret, $marque_tx_ret); } diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 334f8f998bd..931f2f54951 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -217,7 +217,6 @@ if ($result) $cumul_achat = 0; $cumul_vente = 0; - $cumul_qty = 0; $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) @@ -233,13 +232,13 @@ if ($result) if ($marge < 0) { - $marginRate = ($pa != 0)?-1*(100 * round($marge / $pa, 5)):'' ; - $markRate = ($pv != 0)?-1*(100 * round($marge / $pv, 5)):'' ; + $marginRate = ($pa != 0)?-1*(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?-1*(100 * $marge / $pv):'' ; } else { - $marginRate = ($pa != 0)?(100 * round($marge / $pa, 5)):'' ; - $markRate = ($pv != 0)?(100 * round($marge / $pv, 5)):'' ; + $marginRate = ($pa != 0)?(100 * $marge / $pa):'' ; + $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } $var=!$var; @@ -263,18 +262,18 @@ if ($result) $text.= ' - '.$objp->label; print "".$product_static->getNomUrl(1)."\n"; } - print "".price($pv)."\n"; - print "".price($pa)."\n"; - print "".price($marge)."\n"; + print "".price($pv, null, null, null, null, $rounding)."\n"; + print "".price($pa, null, null, null, null, $rounding)."\n"; + print "".price($marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; $i++; - $cumul_achat += round($objp->buying_price, $rounding); - $cumul_vente += round($objp->selling_price, $rounding); + $cumul_achat += $objp->buying_price; + $cumul_vente += $objp->selling_price; } } @@ -284,13 +283,13 @@ if ($result) $totalMargin = $cumul_vente - $cumul_achat; if ($totalMargin < 0) { - $marginRate = ($cumul_achat != 0)?-1*(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?-1*(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else { - $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; } print ''; if ($id > 0) @@ -298,13 +297,13 @@ if ($result) else print ''; print $langs->trans('TotalMargin').""; - print "".price($cumul_vente)."\n"; - print "".price($cumul_achat)."\n"; - print "".price($totalMargin)."\n"; + print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; + print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; + print "".price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print "\n"; print ""; @@ -332,9 +331,9 @@ $(document).ready(function() { $("div.fiche form").submit(); }); - $("#totalMargin").html(""); - $("#marginRate").html(""); - $("#markRate").html(""); + $("#totalMargin").html(""); + $("#marginRate").html(""); + $("#markRate").html(""); }); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 9b31514c7c9..214cf72b86a 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -196,13 +196,13 @@ if ($id > 0 || ! empty($ref)) if ($objp->marge < 0) { - $marginRate = ($objp->buying_price != 0)?-1*(100 * round($objp->marge / $objp->buying_price, 5)):'' ; - $markRate = ($objp->selling_price != 0)?-1*(100 * round($objp->marge / $objp->selling_price, 5)):'' ; + $marginRate = ($objp->buying_price != 0)?-1*(100 * $objp->marge / $objp->buying_price):'' ; + $markRate = ($objp->selling_price != 0)?-1*(100 * $objp->marge / $objp->selling_price):'' ; } else { - $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price, 5)):'' ; - $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price, 5)):'' ; + $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; + $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; } print ""; @@ -215,19 +215,19 @@ if ($id > 0 || ! empty($ref)) print "".$objp->code_client."\n"; print ""; print dol_print_date($db->jdate($objp->datef),'day').""; - print "".price($objp->selling_price)."\n"; - print "".price($objp->buying_price)."\n"; - print "".price($objp->qty)."\n"; - print "".price($objp->marge)."\n"; + print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; + print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; + print "".price($objp->qty, null, null, null, null, $rounding)."\n"; + print "".price($objp->marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).''; print "\n"; $i++; - $cumul_achat += round($objp->buying_price, $rounding); - $cumul_vente += round($objp->selling_price, $rounding); + $cumul_achat += $objp->buying_price; + $cumul_vente += $objp->selling_price; $cumul_qty += $objp->qty; } } @@ -237,24 +237,24 @@ if ($id > 0 || ! empty($ref)) $totalMargin = $cumul_vente - $cumul_achat; if ($totalMargin < 0) { - $marginRate = ($cumul_achat != 0)?-1*(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?-1*(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else { - $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; } print ''; print ''.$langs->trans('TotalMargin').""; - print "".price($cumul_vente)."\n"; - print "".price($cumul_achat)."\n"; - print "".price($cumul_qty)."\n"; - print "".price($totalMargin)."\n"; + print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; + print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; + print "".price($cumul_qty, null, null, null, null, $rounding)."\n"; + print "".price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print ' '; print "\n"; } @@ -278,8 +278,8 @@ $db->close(); ?> diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index aead7467f83..ad2dcbe9811 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -175,7 +175,7 @@ if ($socid > 0) $cumul_achat = 0; $cumul_vente = 0; - $cumul_qty = 0; + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) @@ -187,13 +187,13 @@ if ($socid > 0) if ($objp->marge < 0) { - $marginRate = ($objp->buying_price != 0)?-1*(100 * round($objp->marge / $objp->buying_price, 5)):'' ; - $markRate = ($objp->selling_price != 0)?-1*(100 * round($objp->marge / $objp->selling_price, 5)):'' ; + $marginRate = ($objp->buying_price != 0)?-1*(100 * $objp->marge / $objp->buying_price):'' ; + $markRate = ($objp->selling_price != 0)?-1*(100 * $objp->marge / $objp->selling_price):'' ; } else { - $marginRate = ($objp->buying_price != 0)?(100 * round($objp->marge / $objp->buying_price, 5)):'' ; - $markRate = ($objp->selling_price != 0)?(100 * round($objp->marge / $objp->selling_price, 5)):'' ; + $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; + $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; } $var=!$var; @@ -206,18 +206,18 @@ if ($socid > 0) print "\n"; print ""; print dol_print_date($db->jdate($objp->datef),'day').""; - print "".price($objp->selling_price)."\n"; - print "".price($objp->buying_price)."\n"; - print "".price($objp->marge)."\n"; + print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; + print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; + print "".price($objp->marge, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).''; print "\n"; $i++; - $cumul_achat += round($objp->buying_price, $rounding); - $cumul_vente += round($objp->selling_price, $rounding); + $cumul_achat += $objp->buying_price; + $cumul_vente += $objp->selling_price; } } @@ -226,23 +226,23 @@ if ($socid > 0) $totalMargin = $cumul_vente - $cumul_achat; if ($totalMargin < 0) { - $marginRate = ($cumul_achat != 0)?-1*(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?-1*(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; } else { - $marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):''; - $markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):''; + $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; + $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; } print ''; print ''.$langs->trans('TotalMargin').""; - print "".price($cumul_vente)."\n"; - print "".price($cumul_achat)."\n"; - print "".price($totalMargin)."\n"; + print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; + print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; + print "".price($totalMargin, null, null, null, null, $rounding)."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate)."%")."\n"; + print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate)."%")."\n"; + print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; print ' '; print "\n"; } From d8216a09e10ef489f5f3e5c4677799ea0e1e82e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Oct 2013 14:39:41 +0100 Subject: [PATCH 03/13] Fix: Try a fix to avoid error on big sql --- htdocs/compta/journal/purchasesjournal.php | 4 ++++ htdocs/compta/journal/sellsjournal.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 06c2e20cba4..a0fe2ac79d5 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -96,6 +96,7 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl $p = explode(":", $conf->global->MAIN_INFO_SOCIETE_COUNTRY); $idpays = $p[0]; + $sql = "SELECT f.rowid, f.ref_supplier, f.type, f.datef, f.libelle,"; $sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type, fd.localtax1_tx, fd.localtax2_tx, fd.total_localtax1, fd.total_localtax2,"; $sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,"; @@ -111,6 +112,9 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.t else $sql.= " AND f.type IN (0,1,2,3)"; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; +// TODO Find a better trick to avoid problem with some mysql installations +if (in_array($db->type, array('mysql', 'mysqli'))) $db->query('SET SQL_BIG_SELECTS=1'); + dol_syslog("sql=".$sql); $result = $db->query($sql); if ($result) diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 53ade463f15..9381ade4e0e 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -116,6 +116,9 @@ $sql.= " AND fd.product_type IN (0,1)"; if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " ORDER BY f.rowid"; +// TODO Find a better trick to avoid problem with some mysql installations +if (in_array($db->type, array('mysql', 'mysqli'))) $db->query('SET SQL_BIG_SELECTS=1'); + dol_syslog("sql=".$sql); $result = $db->query($sql); if ($result) From 60d4033e59152d84bc616aa077f78987172e8795 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2013 17:19:25 +0100 Subject: [PATCH 04/13] Fix: Option drop tables was broken --- htdocs/admin/tools/dolibarr_export.php | 4 ++-- htdocs/admin/tools/export.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 062f1aaec73..a733d3891ca 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -219,7 +219,7 @@ print $langs->trans("BackupDescY").'

';
@@ -274,7 +274,7 @@ print $langs->trans("BackupDescY").'

';
trans('ExportStructure') ?>
diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 31d4ec7ef66..8dbd7a1912e 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -134,7 +134,8 @@ if ($what == 'mysql') if (GETPOST("drop_database")) $param.=" --add-drop-database"; if (GETPOST("sql_structure")) { - if (GETPOST("drop")) $param.=" --add-drop-table"; + if (GETPOST("drop")) $param.=" --add-drop-table=TRUE"; + else $param.=" --add-drop-table=FALSE"; } else { From ecb1f490aed98b9aa9d4855cbfef97bc1dda76c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2013 17:19:25 +0100 Subject: [PATCH 05/13] Fix: Option drop tables was broken --- htdocs/admin/tools/dolibarr_export.php | 6 +++--- htdocs/admin/tools/export.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index a0cb8af9726..63ef6376df7 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -219,7 +219,7 @@ print $langs->trans("BackupDescY").'

';
@@ -274,7 +274,7 @@ print $langs->trans("BackupDescY").'

';
trans('ExportStructure') ?>
@@ -433,4 +433,4 @@ print '
'; llxFooter(); $db->close(); -?> \ No newline at end of file +?> diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 31d4ec7ef66..8dbd7a1912e 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -134,7 +134,8 @@ if ($what == 'mysql') if (GETPOST("drop_database")) $param.=" --add-drop-database"; if (GETPOST("sql_structure")) { - if (GETPOST("drop")) $param.=" --add-drop-table"; + if (GETPOST("drop")) $param.=" --add-drop-table=TRUE"; + else $param.=" --add-drop-table=FALSE"; } else { From 84b36d1230c986ca92bb8c0a76a2bc0150e064fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2013 17:24:09 +0100 Subject: [PATCH 06/13] Prepare for 3.4.2 --- ChangeLog | 3 ++- build/debian/changelog | 2 +- build/exe/doliwamp/doliwamp.iss | 4 ++-- build/makepack-dolibarr.pl | 2 +- build/rpm/dolibarr_fedora.spec | 2 +- build/rpm/dolibarr_generic.spec | 2 +- build/rpm/dolibarr_mandriva.spec | 2 +- build/rpm/dolibarr_opensuse.spec | 2 +- htdocs/filefunc.inc.php | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac0f5d5e9c3..763e3369203 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,8 @@ English Dolibarr ChangeLog -------------------------------------------------------------- ***** ChangeLog for 3.4.2 compared to 3.4.1 ***** -Fix: Bad rounding on margin calculations and display +Fix: Bad rounding on margin calculations and display. +Fix: Option drpo table into backup was broken. ***** ChangeLog for 3.4.1 compared to 3.4.0 ***** Fix: Display buying price on line edit when no supplier price is defined diff --git a/build/debian/changelog b/build/debian/changelog index 11706ff7ff3..f8cca0e8e41 100644 --- a/build/debian/changelog +++ b/build/debian/changelog @@ -1,4 +1,4 @@ -dolibarr (3.4.1) unstable; urgency=low +dolibarr (3.4.2) unstable; urgency=low [ Laurent Destailleur (eldy) ] * New upstream release. diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 0f3391a9110..98bfeee9109 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -17,9 +17,9 @@ ; ----- Change this ----- AppName=DoliWamp ; DoliWamp-x.x.x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -AppVerName=DoliWamp-3.4.1 +AppVerName=DoliWamp-3.4.2 ; DoliWamp-x.x x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x -OutputBaseFilename=DoliWamp-3.4.1 +OutputBaseFilename=DoliWamp-3.4.2 ; Define full path from wich all relative path are defined ; You must modify this to put here your dolibarr root directory ;SourceDir=Z:\home\ldestailleur\git\dolibarrxxx diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 2da866d221a..05eef72a978 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -10,7 +10,7 @@ use Cwd; $PROJECT="dolibarr"; $MAJOR="3"; $MINOR="4"; -$BUILD="1"; # Mettre x pour release, x-dev pour dev, x-beta pour beta, x-rc pour release candidate +$BUILD="2"; # Mettre x pour release, x-dev pour dev, x-beta pour beta, x-rc pour release candidate $RPMSUBVERSION="auto"; # auto use value found into BUILD @LISTETARGET=("TGZ","ZIP","RPM_GENERIC","RPM_FEDORA","RPM_MANDRIVA","RPM_OPENSUSE","DEB","APS","EXEDOLIWAMP","SNAPSHOT"); # Possible packages diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 60756c8beb6..eb7c7305b11 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -330,5 +330,5 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog -* Sun Feb 17 2013 Laurent Destailleur 3.4.1-0.3 +* Sun Feb 17 2013 Laurent Destailleur 3.4.2-0.3 - Initial version (#723326) diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index c5feb63aba4..4bc22491755 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -558,5 +558,5 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog -* Sun Feb 17 2013 Laurent Destailleur 3.4.1-0.3 +* Sun Feb 17 2013 Laurent Destailleur 3.4.2-0.3 - Initial version (#723326) diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 6a9e1dd47d7..98ef5fa1b44 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -335,5 +335,5 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog -* Sun Feb 17 2013 Laurent Destailleur 3.4.1-0.3 +* Sun Feb 17 2013 Laurent Destailleur 3.4.2-0.3 - Initial version (#723326) diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 3b41058c416..1734ad6a4e3 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -345,5 +345,5 @@ fi # version x.y.z-0.1.a for alpha, x.y.z-0.2.b for beta, x.y.z-0.3 for release %changelog -* Sun Feb 17 2013 Laurent Destailleur 3.4.1-0.3 +* Sun Feb 17 2013 Laurent Destailleur 3.4.2-0.3 - Initial version (#723326) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 3be6cadc9ce..65895a28035 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.4.1'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.4.2'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From f8e3a3e38a730b3c543934b36911e7591c06f9c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2013 17:36:22 +0100 Subject: [PATCH 07/13] Fix: Sub level of dir must not always be visible. So I added parameter "showrelpart". Default value is old behaviour (only filenmae is visible). --- htdocs/core/class/html.formfile.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index cb8dace1734..92120f1f8bb 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -138,17 +138,17 @@ class FormFile $out .= ' ('.$langs->trans("UploadDisabled").')'; } $out .= ""; - + if ($savingdocmask) { $out .= ''; if (! empty($options)) $out .= ''.$options.''; $out .= ''; - $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/',$langs->transnoentitiesnoconv("OriginFileName"),$savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); + $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/',$langs->transnoentitiesnoconv("OriginFileName"),$savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); $out .= ''; - $out .= ''; + $out .= ''; } - + $out .= ""; $out .= ''; @@ -663,12 +663,13 @@ class FormFile * @param int $permtodelete Permission to delete * @param int $useinecm Change output for use in ecm module * @param string $textifempty Text to show if filearray is empty ('NoFileFound' if not defined) - * @param int $maxlength Maximum length of file name shown + * @param int $maxlength Maximum length of file name shown * @param string $title Title before list * @param string $url Full url to use for click links ('' = autodetect) + * @param int $showrelpart 0=Show only filename (default), 1=Show first level 1 dir * @return int <0 if KO, nb of files shown if OK */ - function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='') + function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0) { global $user, $conf, $langs, $hookmanager; global $bc; @@ -741,8 +742,7 @@ class FormFile print '&file='.$filepath.'">'; print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' '; - if ($file['level1name'] <> $object->id) - print $file['level1name'].'/'; + if ($showrelpart == 1) print $file['level1name'].'/'; print dol_trunc($file['name'],$maxlength,'middle'); print ''; print "\n"; From a9dd9d6dfcf6ede725531a678c46dbdd7dd442d4 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 3 Nov 2013 15:07:26 +0100 Subject: [PATCH 08/13] Modify the presentation of the card --- htdocs/compta/sociales/charges.php | 38 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/sociales/charges.php b/htdocs/compta/sociales/charges.php index 2ec6539db9e..adc5fb8ae74 100644 --- a/htdocs/compta/sociales/charges.php +++ b/htdocs/compta/sociales/charges.php @@ -297,20 +297,7 @@ if ($id > 0) } // Type - print "".$langs->trans("Type")."".$object->type_libelle."".$langs->trans("Payments").""; - - // Period end date - print "".$langs->trans("PeriodEndDate").""; - print ""; - if ($action == 'edit') - { - print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); - } - else - { - print dol_print_date($object->periode,"day"); - } - print ""; + print "".$langs->trans("Type")."".$object->type_libelle.""; $rowspan=5; print ''; @@ -337,8 +324,8 @@ if ($id > 0) $i = 0; $total = 0; echo ''; print ''; - print ''; - print ''; + print ''; + print ''; $var=True; while ($i < $num) @@ -349,12 +336,12 @@ if ($id > 0) print ''.img_object($langs->trans("Payment"),"payment").' '; print dol_print_date($db->jdate($objp->dp),'day')."\n"; print "\n"; - print '\n"; + print '\n"; print ""; $totalpaye += $objp->amount; $i++; } - + if ($object->paye == 0) { print "\n"; @@ -376,6 +363,19 @@ if ($id > 0) print ""; + // Period end date + print ""; + print ""; + // Due date if ($action == 'edit') { @@ -393,8 +393,6 @@ if ($id > 0) // Status print ''; - print ''; - print '
'.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
'.$langs->trans("Payments").''.$langs->trans("Type").''.$langs->trans("Amount").' 
".$objp->paiement_type.' '.$objp->num_paiement."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("PeriodEndDate").""; + if ($action == 'edit') + { + print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1); + } + else + { + print dol_print_date($object->periode,"day"); + } + print "
'.$langs->trans("Status").''.$object->getLibStatut(4).'
 
'; if ($action == 'edit') From e5fd19ffc005b1a935017028eb801e8283b96dbd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Nov 2013 10:45:43 +0100 Subject: [PATCH 09/13] Add option to salt hash passwords --- htdocs/core/lib/security.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 58bd4371b4c..e21d9c749a1 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -77,9 +77,11 @@ function dol_decode($chain) */ function dol_hash($chain,$type=0) { + global $conf; + if ($type == 1) return sha1($chain); else if ($type == 2) return sha1(md5($chain)); - else return md5($chain); + else return md5((empty($conf->global->MAIN_SECURITY_SALT)?'':$conf->global->MAIN_SECURITY_SALT).$chain); } From 32983b79eebaff8250db543ba5e665609f58b4d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Nov 2013 10:47:24 +0100 Subject: [PATCH 10/13] Sec: Add option to salt password --- htdocs/core/lib/security.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index e21d9c749a1..150a3bd3feb 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -79,9 +79,12 @@ function dol_hash($chain,$type=0) { global $conf; + // Salt value + if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; + if ($type == 1) return sha1($chain); else if ($type == 2) return sha1(md5($chain)); - else return md5((empty($conf->global->MAIN_SECURITY_SALT)?'':$conf->global->MAIN_SECURITY_SALT).$chain); + else return md5($chain); } From fd168c1214b92cf079a596e543c92c09846fc7dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Nov 2013 15:04:04 +0100 Subject: [PATCH 11/13] Doc comments --- htdocs/core/tpl/login.tpl.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index ebc6fea7626..b62ad5890be 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -25,8 +25,9 @@ if (GETPOST('dol_optimize_smallscreen')) $conf->dol_optimize_smallscreen=1; if (GETPOST('dol_no_mouse_hover')) $conf->dol_no_mouse_hover=1; if (GETPOST('dol_use_jmobile')) $conf->dol_use_jmobile=1; -$arrayofjs=array('/core/js/dst.js'); // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second -print top_htmlhead('',$langs->trans('Login').' '.$title,0,0,$arrayofjs); +$arrayofjs=array('/core/js/dst.js'); // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second +$titleofloginpage=$langs->trans('Login').' '.$title; // title is defined by dol_loginfunction in security2.lib.php +print top_htmlhead('',$titleofloginpage,0,0,$arrayofjs); ?> From 5e246107a7904aa0701170fa04bb46ff7d5129e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Nov 2013 16:31:12 +0100 Subject: [PATCH 12/13] Doxygen --- htdocs/compta/facture/class/facture.class.php | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ed7d06919ec..461b3606cd6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1,37 +1,37 @@ - * Copyright (C) 2004-2012 Laurent Destailleur -* Copyright (C) 2004 Sebastien Di Cintio -* Copyright (C) 2004 Benoit Mortier -* Copyright (C) 2005 Marc Barilley / Ocebo -* Copyright (C) 2005-2013 Regis Houssin -* Copyright (C) 2006 Andre Cianfarani -* Copyright (C) 2007 Franky Van Liedekerke -* Copyright (C) 2010-2013 Juanjo Menent -* Copyright (C) 2012 Christophe Battarel -* Copyright (C) 2012 Marcos García -* Copyright (C) 2013 Cedric Gross -* Copyright (C) 2013 Florian Henry -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2013 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Marcos García + * Copyright (C) 2013 Cedric Gross + * Copyright (C) 2013 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ /** * \file htdocs/compta/facture/class/facture.class.php -* \ingroup facture -* \brief File of class to manage invoices -*/ + * \ingroup facture + * \brief File of class to manage invoices + */ include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; require_once DOL_DOCUMENT_ROOT .'/product/class/product.class.php'; From c815bd96fbae14c064199252c017c85711544ed6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Nov 2013 16:50:41 +0100 Subject: [PATCH 13/13] Doxygen --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 86f4904be68..b3e5f8f47d8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2048,6 +2048,7 @@ abstract class CommonObject /** * Function to get extra fields of a member into $this->array_options + * This method is in most cases called by method fetch of objects but you can call it separately. * * @param int $rowid Id of line * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label()