From 4c7907b773b321ce5f589014641dce2a6b5ddd98 Mon Sep 17 00:00:00 2001 From: simnandez Date: Sun, 15 Sep 2013 11:47:31 +0200 Subject: [PATCH 1/6] [ task #1060 ] Register fields localtax(1|2)_type into details tables --- ChangeLog | 1 + .../commande/doc/pdf_einstein.modules.php | 17 ++++++++++------- .../commande/doc/pdf_proforma.modules.php | 15 +++++++++------ .../modules/facture/doc/pdf_crabe.modules.php | 19 +++++++++++-------- .../modules/propale/doc/pdf_azur.modules.php | 17 ++++++++++------- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 58aaf22595e..b9762661f07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -53,6 +53,7 @@ For users: - New: User permissions on margin module - New: Add ref supplier into muscadet model - New: Can use tag {mm} before {yy} even when there is a reset into numbering masks. +- New: [ task #1060 ] Register fields localtax(1|2)_type into details tables For translators: - Qual: Normalized sort order of all languages files with english reference files. diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index b7866212b79..a954c68c906 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -377,11 +377,14 @@ class pdf_einstein extends ModelePDFCommandes $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index f90871b2471..35d7dd3f9fc 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand * Copyright (C) 2010-2013 Juanjo Menent @@ -377,11 +377,14 @@ class pdf_proforma extends ModelePDFCommandes $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 7c8f7307255..0f2ac346e69 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -378,12 +378,15 @@ class pdf_crabe extends ModelePDFFactures if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; - - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 6a3d0709963..a8b8a8dfdb6 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel * * This program is free software; you can redistribute it and/or modify @@ -432,11 +432,14 @@ class pdf_azur extends ModelePDFPropales $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) From 59783cf5567c81faed0d6054d9ba161b1ab4fc44 Mon Sep 17 00:00:00 2001 From: simnandez Date: Sun, 15 Sep 2013 11:52:57 +0200 Subject: [PATCH 2/6] [ task #1060 ] Register fields localtax(1|2)_type into details tables --- .../pdf/pdf_muscadet.modules.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index e08f9418c21..923930d5252 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2013 Juanjo Menent * * 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 @@ -377,11 +377,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (! empty($object->remise_percent)) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; $vatrate=(string) $object->lines[$i]->tva_tx; - // TODO : store local taxes types into object lines and remove this - $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); - if ((! isset($localtax1_type)) || $localtax1_type=='') $localtax1_type = $localtaxtmp_array[0]; - if ((! isset($localtax2_type)) || $localtax2_type=='') $localtax2_type = $localtaxtmp_array[2]; - //end TODO + + // Retrieve type from database for backward compatibility with old records + if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax + { + $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } // retrieve global local tax if ($localtax1_type && $localtax1ligne != 0) From d9d90f108866793b33b5d4c5399fb38964f5badb Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Sun, 15 Sep 2013 12:04:46 +0200 Subject: [PATCH 3/6] Fix: Supplier price displayed on document lines didnt take discount Conflicts: htdocs/fourn/ajax/getSupplierPrices.php --- ChangeLog | 1 + htdocs/fourn/ajax/getSupplierPrices.php | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9762661f07..71a00e7b6eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -127,6 +127,7 @@ Fix: Edit propal line was losing product supplier price id Fix: Delete linked element to supplier invoice when deleted Fix: [ bug #1061 ] Bad info shipped products Fix: [ bug #1062 ] Documents lost in propals and contracts validating +Fix: Supplier price displayed on document lines didnt take discount Qual: Add travis-ci integration diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index b19ddb2996f..65f3eb9ee79 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -48,7 +48,7 @@ if (! empty($idprod)) { $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration,"; $sql.= " pfp.ref_fourn,"; - $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice, pfp.charges, pfp.unitcharges,"; + $sql.= " pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice, pfp.charges, pfp.unitcharges,"; $sql.= " s.nom"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = pfp.fk_product"; @@ -72,13 +72,15 @@ if (! empty($idprod)) { $objp = $db->fetch_object($result); + $price = $objp->fprice * (1 - $objp->remise_percent / 100); + $unitprice = $objp->unitprice * (1 - $objp->remise_percent / 100); + $title = $objp->nom.' - '.$objp->ref_fourn.' - '; if ($objp->quantity == 1) { - $title.= price($objp->fprice,0,$langs,0,0,-1,$conf->currency)."/"; - - $price = $objp->fprice; + $title.= price($price); + $title.= $langs->getCurrencySymbol($conf->currency)."/"; } $title.= $objp->quantity.' '; @@ -94,18 +96,18 @@ if (! empty($idprod)) if ($objp->quantity > 1) { $title.=" - "; - $title.= price($objp->unitprice,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); + $title.= price($unitprice).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit")); - $price = $objp->unitprice; + $price = $unitprice; } if ($objp->unitcharges > 0 && ($conf->global->MARGIN_TYPE == "2")) { $title.=" + "; - $title.= price($objp->unitcharges,0,$langs,0,0,-1,$conf->currency); + $title.= price($objp->unitcharges).$langs->getCurrencySymbol($conf->currency); $price += $objp->unitcharges; } if ($objp->duration) $label .= " - ".$objp->duration; - $label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); + $label = price($price).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit")); $prices[] = array("id" => $objp->idprodfournprice, "price" => price($price,0,'',0), "label" => $label, "title" => $title); $i++; From e970c01b1b344e78acb0ecf23e107a107981e68f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2013 12:17:45 +0200 Subject: [PATCH 4/6] Code comment Fix translation --- htdocs/core/menus/standard/eldy_menu.php | 13 ++++++++++--- htdocs/langs/fr_FR/other.lang | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 4d52dfaceeb..e7c101b52e4 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -166,14 +166,16 @@ class MenuManager { // We add sub entry print str_pad('',1).'
  • '; // ui-btn to highlight on clic - print ''; + print ''; print str_pad('',12,' '); if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") print $langs->trans("Access"); // No translation else print $langs->trans(ucfirst($val['mainmenu'])."Dashboard"); print ''; print '
  • '."\n"; } - foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'] { $relurl2=dol_buildpath($val2['url'],1); $relurl2=preg_replace('/__LOGIN__/',$user->login,$relurl2); @@ -183,7 +185,12 @@ class MenuManager if (in_array($canonurl2,array('/admin/index.php','/admin/tools/index.php','/core/tools.php'))) $relurl2=''; if ($val2['level']==0) print str_pad('',$val2['level']+1).''; // ui-btn to highlight on clic else print str_pad('',$val2['level']+1).'
  • '; // ui-btn to highlight on clic - if ($relurl2) print ''; + if ($relurl2) + { + print ''; + } print str_pad('',($val2['level']+1)*12,' '); print $val2['titre']; if ($relurl2) print ''; diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 516eafc4f52..8954079ce31 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -126,7 +126,7 @@ SizeUnitmm=mm SizeUnitinch=pouce SizeUnitfoot=pied SizeUnitpoint=point -BugTracker=Gestionnaire de défauts +BugTracker=Suivi de tickets SendNewPasswordDesc=Ce formulaire permet d'envoyer un nouveau mot de passe. Il sera envoyé à l'adresse email de votre utilisateur.
    La modification du mot de passe ne sera effective qu'après validation par le destinataire en suivant le lien de confirmation inclut dans ce mail.
    Surveillez votre messagerie. BackToLoginPage=Retour page de connexion AuthenticationDoesNotAllowSendNewPassword=Le mode d'authentification de Dolibarr est configuré à "%s".
    Dans ce mode, Dolibarr n'a pas la possibilité de connaître ni de modifier votre mot de passe.
    Contactez votre administrateur pour connaitre les modalités de changement. From 5e969536c076e7a7b79c2d75b4768e35cbc53db7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2013 12:34:22 +0200 Subject: [PATCH 5/6] Fix: bad sql syntax --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index f24c7bf28c6..884fcd8d4ad 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -181,7 +181,7 @@ class ProductFournisseur extends Product { $sql = "UPDATE ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " SET fk_user = " . $user->id." ,"; - $sql.= " ref_fourn = \"" . $this->db->escape($ref_fourn) . "\","; + $sql.= " ref_fourn = '" . $this->db->escape($ref_fourn) . "',"; $sql.= " price = ".price2num($buyprice).","; $sql.= " quantity = ".$qty.","; $sql.= " remise_percent = ".$remise_percent.","; From b20b82df3d40f95d05326678399358015870ef69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 15 Sep 2013 13:04:38 +0200 Subject: [PATCH 6/6] Fix: we must use conf-currency as parameter of method price instead of using langs->getCurrencySymbol --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/fourn/ajax/getSupplierPrices.php | 23 +++++++---------------- htdocs/fourn/facture/fiche.php | 2 +- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c81afc72ad9..d8bdb60d8a4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1775,8 +1775,8 @@ class Form { $opt.= price($objp->fprice,1,$langs,0,0,-1,$conf->currency)."/".$objp->quantity; $outval.= price($objp->fprice,0,$langs,0,0,-1,$conf->currency)."/".$objp->quantity; - $opt.= $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding - $outval.= $langs->transnoentities("Units"); + $opt.= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding + $outval.= ' '.$langs->transnoentities("Units"); } if ($objp->quantity >= 1) diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 65f3eb9ee79..dc39538fe7b 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -79,35 +79,26 @@ if (! empty($idprod)) if ($objp->quantity == 1) { - $title.= price($price); - $title.= $langs->getCurrencySymbol($conf->currency)."/"; + $title.= price($price,0,$langs,0,0,-1,$conf->currency)."/"; } + $title.= $objp->quantity.' '.($objp->quantity == 1 ? $langs->trans("Unit") : $langs->trans("Units")); - $title.= $objp->quantity.' '; - - if ($objp->quantity == 1) - { - $title.= strtolower($langs->trans("Unit")); - } - else - { - $title.= strtolower($langs->trans("Units")); - } if ($objp->quantity > 1) { $title.=" - "; - $title.= price($unitprice).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit")); + $title.= price($unitprice,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); $price = $unitprice; } - if ($objp->unitcharges > 0 && ($conf->global->MARGIN_TYPE == "2")) { + if ($objp->unitcharges > 0 && ($conf->global->MARGIN_TYPE == "2")) + { $title.=" + "; - $title.= price($objp->unitcharges).$langs->getCurrencySymbol($conf->currency); + $title.= price($objp->unitcharges,0,$langs,0,0,-1,$conf->currency); $price += $objp->unitcharges; } if ($objp->duration) $label .= " - ".$objp->duration; - $label = price($price).$langs->getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit")); + $label = price($price,0,$langs,0,0,-1,$conf->currency)."/".$langs->trans("Unit"); $prices[] = array("id" => $objp->idprodfournprice, "price" => price($price,0,'',0), "label" => $label, "title" => $title); $i++; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 4e52c474149..7de2b910237 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -2221,7 +2221,7 @@ else /* * Linked object block - */ + */ $somethingshown=$object->showLinkedObjectBlock(); print '
    ';