From 689e6ec415f485b554fc7fd3092deb09e8c017bf Mon Sep 17 00:00:00 2001 From: fmarcet Date: Thu, 2 Mar 2017 18:56:47 +0100 Subject: [PATCH 001/609] Fix: when refs are numbers, it is not the same '0138' than '138' --- htdocs/product/class/product.class.php | 4 ++-- htdocs/projet/class/project.class.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a61406c90d7..266ae301de9 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -12,7 +12,7 @@ * Copyright (C) 2014 Henry Florian * Copyright (C) 2014-2016 Philippe Grand * Copyright (C) 2014 Ion agorria - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -816,7 +816,7 @@ class Product extends CommonObject // End call triggers } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->product->dir_output) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index b242f7d6b06..07727032c39 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -301,7 +302,7 @@ class Project extends CommonObject } } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref)) + if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->projet->dir_output) From aba6da585057ac8bfe100e064d7fb92d56b32e8c Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 17 Jul 2017 17:46:11 +0200 Subject: [PATCH 002/609] New: Better extrafields filter on lists --- htdocs/adherents/list.php | 12 +++++++--- htdocs/comm/propal/list.php | 13 +++++++---- htdocs/commande/list.php | 13 +++++++---- htdocs/compta/bank/index.php | 12 +++++++--- htdocs/compta/facture/fiche-rec.php | 12 +++++++--- htdocs/compta/facture/list.php | 13 +++++++---- htdocs/contact/list.php | 12 +++++++--- htdocs/contrat/list.php | 13 +++++++---- htdocs/contrat/services.php | 12 +++++++--- htdocs/expedition/list.php | 13 +++++++---- htdocs/expensereport/list.php | 12 +++++++--- htdocs/fichinter/list.php | 12 +++++++--- htdocs/fourn/commande/list.php | 13 +++++++---- htdocs/fourn/facture/list.php | 13 +++++++---- .../modulebuilder/template/myobject_list.php | 12 +++++++--- htdocs/product/list.php | 23 +++++++++++++++++-- htdocs/product/stock/mouvement.php | 12 +++++++--- htdocs/product/stock/productlot_list.php | 12 +++++++--- htdocs/projet/list.php | 10 ++++++-- htdocs/projet/tasks/list.php | 12 +++++++--- htdocs/resource/list.php | 12 +++++++--- htdocs/societe/list.php | 8 +++---- htdocs/supplier_proposal/list.php | 13 +++++++---- htdocs/user/index.php | 12 +++++++--- 24 files changed, 222 insertions(+), 79 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index ec6bb85710c..d2f4947e17e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -530,15 +531,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index a8e3d23565f..1ad71b738ab 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -663,15 +663,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index daefc3c4cce..1af02e1fc5d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -938,15 +938,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 0c24d25e064..f645822ca05 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -347,15 +348,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 221167a485a..8125cf07e31 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -8,6 +8,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Meziane Sof + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -1740,15 +1741,20 @@ else $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 2716e3a87b1..ea3779850dd 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015-2016 Ferran Marcet + * Copyright (C) 2015-2017 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -903,15 +903,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 1293a258fab..eaf91167c4b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -597,15 +598,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attribute_computed[$key])) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index a82535bfbb7..8b94774f9b9 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2015 Claudio Aschieri * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -475,15 +475,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index 3d5db42495a..f1a5bea6ed4 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -459,15 +460,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index c4a07580a9a..33e336d979f 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -384,15 +384,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index bbf2266ab13..a69b0dd2649 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -424,15 +425,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 0404f976328..5cf32906ecc 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2011-2012 Juanjo Menent * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -364,15 +365,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index bafdeeab4db..d04cede7107 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -974,15 +974,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 30d31c0ea02..675594398f8 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -8,7 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015-2007 Juanjo Menent * Copyright (C) 2015 Abbes Bahfir - * Copyright (C) 2015-2016 Ferran Marcet + * Copyright (C) 2015-2017 Ferran Marcet * Copyright (C) 2017 Josep Lluís Amador * * This program is free software; you can redistribute it and/or modify @@ -814,15 +814,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index ef3cb110224..3a1c8d30a02 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 Ferran Marcet * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -350,15 +351,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attribute_computed[$key])) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 1512fda7b4f..46806764d1d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -593,7 +593,26 @@ else { foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) print ''; + if (! empty($arrayfields["ef.".$key]['checked'])) { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; + print ''; + } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } + print ''; + } } } // Fields from hook diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 469c2f292e7..40f00a0772b 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -834,15 +835,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 61e9438c929..69f11be28b7 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -362,15 +363,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9c78387f95b..de27484b180 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -571,10 +572,15 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 7bff02fa864..82605f86765 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2006-2010 Regis Houssin + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -551,15 +552,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attribute_computed[$key])) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 5ec9eabbfb1..1f0ec5d9e25 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -1,5 +1,6 @@ + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -214,15 +215,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3bde7f09967..45d2656a7e3 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -6,7 +6,7 @@ * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry * Copyright (C) 2016 Josep Lluis Amador - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -831,13 +831,13 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + if (in_array($typeofextrafield, array('varchar', 'int', 'double')) && empty($extrafields->attribute_computed[$key])) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } else diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index e401fdbe710..6c193d8e875 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2010-2011 Philippe Grand * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * * 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 @@ -665,15 +665,20 @@ if ($resql) $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 9c82216d5be..6eb88478f1a 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Marcos García + * Copyright (C) 2017 Ferran Marcet * * 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 @@ -385,15 +386,20 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + if ('varchar' == $typeofextrafield) $searchclass='searchstring'; + else $searchclass='searchnum'; print ''; } + else + { + // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') + echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); + } print ''; } } From f60489b76651f45597ee6aed0a8372082618bdd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 17 Dec 2017 23:06:26 +0100 Subject: [PATCH 003/609] FIX #4875 Dolimail thirdparty code is integrated into Dolibarr core code Close #4875 --- htdocs/core/actions_sendmails.inc.php | 99 --------------------------- 1 file changed, 99 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 5a8d32efde5..423c81ab0ca 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -105,7 +105,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $trackid = GETPOST('trackid','aZ09'); $subject='';$actionmsg='';$actionmsg2=''; - if (! empty($conf->dolimail->enabled)) $langs->load("dolimail@dolimail"); $langs->load('mails'); if (is_object($object)) @@ -129,36 +128,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $thirdparty=$object; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; - elseif (! empty($conf->dolimail->enabled)) - { - $dolimail = new Dolimail($db); - $possibleaccounts=$dolimail->get_societe_by_email($_POST['sendto'],"1"); - $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople - if (!$possibleaccounts && !$possibleuser) - { - setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); - } - elseif (count($possibleaccounts)>1) - { - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - - setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); - } - else - { - if($possibleaccounts){ - $sendtosocid=$possibleaccounts[1]['id']; - $result=$object->fetch($sendtosocid); - }elseif($possibleuser){ - $sendtosocid=$possibleuser[0]['id']; - - $result=$uobject->fetch($sendtosocid); - $object=$uobject; - } - - } - } } else dol_print_error('','Use actions_sendmails.in.php for an element/object that is not supported'); } @@ -318,49 +287,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $filename = $attachedfiles['names']; $mimetype = $attachedfiles['mimes']; - - // Feature to push mail sent into Sent folder - if (! empty($conf->dolimail->enabled)) - { - $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# ' // TODO Use a better way to define Sent dir. - if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - else - { - $mbid = $mailfromid[1]; - - /*IMAP Postbox*/ - $mailboxconfig = new IMAP($db); - $mailboxconfig->fetch($mbid); - if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref(); - - $mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox; - $mailboxconfig->userfolder_fetch(); - - if ($mailboxconfig->mailbox_save_sent_mails == 1) - { - - $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key); - if (!$folder) $folder = "Sent"; // Default Sent folder - - $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); - if (FALSE === $mailboxconfig->mbox) - { - $info = FALSE; - $err = $langs->trans('Error3_Imap_Connection_Error'); - setEventMessages($err,$mailboxconfig->element, null, 'errors'); - } - else - { - $mailboxconfig->mailboxid=$_POST['frommail']; - $mailboxconfig->foldername=$folder; - $from = $mailfromid[0] . $mailfromid[2]; - $imap=1; - } - - } - } - } - // Make substitution in email content $substitutionarray=getCommonSubstitutionArray($langs, 0, null, $object); $substitutionarray['__EMAIL__'] = $sendto; @@ -394,26 +320,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $error=0; - // FIXME This must be moved into the trigger for action $trigger_name - if (! empty($conf->dolimail->enabled)) - { - $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ? - if ($mid) - { - // set imap flag answered if it is an answered mail - $dolimail=new DoliMail($db); - $dolimail->id = $mid; - $res=$dolimail->set_prop($user, 'answered',1); - } - if ($imap==1) - { - // write mail to IMAP Server - $movemail = $mailboxconfig->putMail($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$folder,$deliveryreceipt,$mailfile); - if ($movemail) setEventMessages($langs->trans("MailMovedToImapFolder",$folder), null, 'mesgs'); - else setEventMessages($langs->trans("MailMovedToImapFolder_Warning",$folder), null, 'warnings'); - } - } - // Initialisation of datas if (is_object($object)) { @@ -453,11 +359,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); setEventMessages($mesg, null, 'mesgs'); - if ($conf->dolimail->enabled) - { - header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').'&'.($paramname2?$paramname2:'mid').'='.$parm2val); - exit; - } header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'')); exit; } From 77d410708538a8c15e79340862e9c620cc4c71b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2018 17:44:37 +0100 Subject: [PATCH 004/609] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 629e80e5a82..ff567803ae4 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -416,22 +416,15 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } - if ($error) - { - dol_print_error($db); - } - else - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessages($mesg, null, 'mesgs'); + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessages($mesg, null, 'mesgs'); $moreparam=''; if (isset($paramname2) || isset($paramval2)) $moreparam.= '&'.($paramname2?$paramname2:'mid').'='.$paramval2; header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.(is_object($object)?$object->id:'').$moreparam); exit; - } } else { From 5dde72e3dd12d53b5ae45c4f6496d102f518d563 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2018 17:45:05 +0100 Subject: [PATCH 005/609] Update actions_sendmails.inc.php --- htdocs/core/actions_sendmails.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index ff567803ae4..d478dc6bc06 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -364,8 +364,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$mailfile->sendfile(); if ($result) { - $error=0; - // Two hooks are available into method $mailfile->sendfile, so dedicated code is no more required /* if (! empty($conf->dolimail->enabled)) From c389a43460238698cef2fa934fbfe1dd40a26d2d Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 15 Feb 2018 12:14:46 +0100 Subject: [PATCH 006/609] New: Add totals on orders supplier list --- htdocs/fourn/commande/list.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 731c26af038..15bd981f001 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * * 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 @@ -1150,6 +1150,26 @@ if ($resql) print "\n"; $i++; } + // Show total line + if (isset($totalarray['totalhtfield'])) + { + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if ($i == 1) + { + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; + } + elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).''; + elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).''; + elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).''; + else print ''; + } + print ''; + } print "\n"; print ''; print "\n"; From 994a03d90911a36adb7e8d5961bf2fc41816365f Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 15 Feb 2018 12:18:48 +0100 Subject: [PATCH 007/609] Same as oficial develop --- htdocs/compta/facture/fiche-rec.php | 364 ---------------------------- 1 file changed, 364 deletions(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index c87594fcc56..af81e797252 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -9,7 +9,6 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Meziane Sof * Copyright (C) 2017 Frédéric France - * Copyright (C) 2017 Ferran Marcet * * 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 @@ -1745,369 +1744,6 @@ else print ''; } - else - { - /* - * List mode - */ - $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre, f.total, f.tva as total_vat, f.total_ttc, f.frequency,"; - $sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when,"; - $sql.= " f.datec, f.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; - if (! $user->rights->societe->client->voir && ! $socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - if (! $user->rights->societe->client->voir && ! $socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; - } - if ($search_ref) $sql .= natural_search('f.titre', $search_ref); - if ($search_societe) $sql .= natural_search('s.nom', $search_societe); - if ($search_montant_ht != '') $sql.= natural_search('f.total', $search_montant_ht, 1); - if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_vat, 1); - if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); - if ($search_frequency > 0) $sql.= natural_search('f.frequency', $search_frequency); - if ($search_frequency == '1') $sql.= ' AND f.frequency > 0'; - if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)'; - - if ($month > 0) - { - if ($year > 0 && empty($day)) - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; - else if ($year > 0 && ! empty($day)) - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'"; - else - $sql.= " AND date_format(f.date_last_gen, '%m') = '".$month."'"; - } - else if ($year > 0) - { - $sql.= " AND f.date_last_gen BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; - } - if ($month_date_when > 0) - { - if ($year_date_when > 0 && empty($day_date_when)) - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,$month_date_when,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,$month_date_when,false))."'"; - else if ($year_date_when > 0 && ! empty($day_date_when)) - $sql.= " AND f.date_date_when_reglement BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date_when, $day_date_when, $year_date_when))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date_when, $day_date_when, $year_date_when))."'"; - else - $sql.= " AND date_format(f.date_when, '%m') = '".$month_date_when."'"; - } - else if ($year_date_when > 0) - { - $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'"; - } - - $nbtotalofrecords = ''; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) - { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - } - - $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($limit+1,$offset); - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($socid) $param.='&socid='.$socid; - if ($day) $param.='&day='.$day; - if ($month) $param.='&month='.$month; - if ($year) $param.='&year=' .$year; - if ($day_date_when) $param.='&day_date_when='.$day_date_when; - if ($month_date_when) $param.='&month_date_when='.$month_date_when; - if ($year_date_when) $param.='&year_date_when=' .$year_date_when; - if ($search_ref) $param.='&search_ref=' .$search_ref; - if ($search_societe) $param.='&search_societe=' .$search_societe; - if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht; - if ($search_montant_vat != '') $param.='&search_montant_vat='.$search_montant_vat; - if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc; - if ($search_frequency > 0) $param.='&search_frequency=' .$search_frequency; - if ($option) $param.="&option=".$option; - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - - $massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"))); - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - //$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); - - print '
'."\n"; - if ($optioncss != '') print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($langs->trans("RepeatableInvoices"),$page,$_SERVER['PHP_SELF'],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'title_accountancy.png',0,'','',$limit); - - print $langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

'; - - $i = 0; - - print '
'; - print ''."\n"; - - // Filters lines - print ''; - // Ref - if (! empty($arrayfields['f.titre']['checked'])) - { - print ''; - } - // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.total']['checked'])) - { - // Amount - print ''; - } - if (! empty($arrayfields['f.tva']['checked'])) - { - // Amount - print ''; - } - if (! empty($arrayfields['f.total_ttc']['checked'])) - { - // Amount - print ''; - } - if (! empty($arrayfields['f.frequency']['checked'])) - { - // Recurring or not - print ''; - } - if (! empty($arrayfields['f.nb_gen_done']['checked'])) - { - // Nb generation - print ''; - } - // Date invoice - if (! empty($arrayfields['f.date_last_gen']['checked'])) - { - print ''; - } - // Date due - if (! empty($arrayfields['f.date_when']['checked'])) - { - print ''; - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } - } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (! empty($arrayfields['f.datec']['checked'])) - { - print ''; - } - // Date modification - if (! empty($arrayfields['f.tms']['checked'])) - { - print ''; - } - // Action column - print ''; - print "\n"; - - - print ''; - if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'],$_SERVER['PHP_SELF'],"f.titre","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER['PHP_SELF'],"s.nom","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'],$_SERVER['PHP_SELF'],"f.total","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'],$_SERVER['PHP_SELF'],"f.tva","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'],$_SERVER['PHP_SELF'],"f.total_ttc","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'],$_SERVER['PHP_SELF'],"f.frequency","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'],$_SERVER['PHP_SELF'],"f.nb_gen_done","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'],$_SERVER['PHP_SELF'],"f.date_last_gen","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'],$_SERVER['PHP_SELF'],"f.date_when","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; - print "\n"; - - - if ($num > 0) - { - $var=true; - while ($i < min($num,$limit)) - { - $objp = $db->fetch_object($resql); - - $companystatic->id=$objp->socid; - $companystatic->name=$objp->name; - - print ''; - - if (! empty($arrayfields['f.titre']['checked'])) - { - print '\n"; - } - if (! empty($arrayfields['s.nom']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.total']['checked'])) - { - print ''."\n"; - } - if (! empty($arrayfields['f.tva']['checked'])) - { - print ''."\n"; - } - if (! empty($arrayfields['f.total_ttc']['checked'])) - { - print ''."\n"; - } - if (! empty($arrayfields['f.frequency']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.nb_gen_done']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.date_last_gen']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.date_when']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.datec']['checked'])) - { - print ''; - } - if (! empty($arrayfields['f.tms']['checked'])) - { - print ''; - } - // Action column - print '"; - print "\n"; - $i++; - } - } - else - { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } - print ''; - } - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->selectyesno('search_frequency', $search_frequency, 1, false, 1); - print ''; - print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year?$year:-1,'year',1, 20, 5); - print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($year_date_when?$year_date_when:-1,'year_date_when',1, 20, 5); - print ''; - if (in_array($typeofextrafield, array('varchar', 'int', 'double'))) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if ('varchar' == $typeofextrafield) $searchclass='searchstring'; - else $searchclass='searchnum'; - print ''; - } - else - { - // for the type as 'checkbox', 'chkbxlst', 'sellist' we should use code instead of id (example: I declare a 'chkbxlst' to have a link with dictionnairy, I have to extend it with the 'code' instead 'rowid') - echo $extrafields->showInputField($key, $search_array_options['search_options_'.$key], '', '', 'search_'); - } - print ''; - print ''; - print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); - print $searchpicto; - print '
'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->titre; - print "'.$companystatic->getNomUrl(1,'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''.yn($objp->frequency?1:0).''; - print ($objp->frequency ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : ''.$langs->trans('NA').''); - print ''; - print ($objp->frequency ? dol_print_date($db->jdate($objp->date_last_gen),'day') : ''.$langs->trans('NA').''); - print ''; - print ($objp->frequency ? dol_print_date($db->jdate($objp->date_when),'day') : ''.$langs->trans('NA').''); - print ''; - print dol_print_date($db->jdate($objp->datec),'dayhour'); - print ''; - print dol_print_date($db->jdate($objp->tms),'dayhour'); - print ''; - if ($user->rights->facture->creer) - { - if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) - { - print ''; - print $langs->trans("CreateBill").''; - } - else - { - print $langs->trans("DateIsNotEnough"); - } - } - else - { - print " "; - } - print "
'.$langs->trans("NoRecordFound").'
"; - print "
"; - print "
"; - - $db->free($resql); - } - else - { - dol_print_error($db); - } - } - } llxFooter(); From d300b943e122df7e4793fdf86c5c73dba3693335 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 23 Feb 2018 15:10:25 +0100 Subject: [PATCH 008/609] Fix wrong price on supplier order line --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index d952eb771da..4441d7159af 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1089,7 +1089,7 @@ if (empty($reshook)) $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product > 0 ? $lines[$i]->fk_product : 0, - $productsupplier->product_fourn_price_id, + 0, $productsupplier->ref_supplier, $lines[$i]->remise_percent, 'HT', From ebb4da8417549128c4e358aae38bf94f4908a4c2 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Mon, 5 Mar 2018 16:58:35 +0100 Subject: [PATCH 009/609] Fix keep supplier proposal price in supplier order --- .../class/fournisseur.commande.class.php | 2 +- htdocs/fourn/commande/card.php | 68 +++++++++---------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7c7837e75fe..4d492bf2bbe 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1417,7 +1417,7 @@ class CommandeFournisseur extends CommonOrder if ($fk_product > 0) { - if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) + if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED) && $origin !== 'supplier_proposal') { // Check quantity is enough dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." fourn_ref=".$fourn_ref); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4441d7159af..aa833d49b6e 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1044,8 +1044,6 @@ if (empty($reshook)) $fk_parent_line = 0; $num = count($lines); - $productsupplier = new ProductFournisseur($db); - for($i = 0; $i < $num; $i ++) { @@ -1068,45 +1066,41 @@ if (empty($reshook)) $lines[$i]->fetch_optionals($lines[$i]->rowid); $array_option = $lines[$i]->array_options; } + + $tva_tx = $lines[$i]->tva_tx; - $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid); - if ($result>=0) + if ($origin=="commande") { - $tva_tx = $lines[$i]->tva_tx; - - if ($origin=="commande") - { - $soc=new societe($db); - $soc->fetch($socid); - $tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id); - } - - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->qty, - $tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->fk_product > 0 ? $lines[$i]->fk_product : 0, - 0, - $productsupplier->ref_supplier, - $lines[$i]->remise_percent, - 'HT', - 0, - $lines[$i]->product_type, - '', - '', - null, - null, - array(), - $lines[$i]->fk_unit, - 0, - $element, - !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid - ); + $soc=new societe($db); + $soc->fetch($socid); + $tva_tx=get_default_tva($soc, $mysoc, $lines[$i]->fk_product, $productsupplier->product_fourn_price_id); } + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product > 0 ? $lines[$i]->fk_product : 0, + 0, + $lines[$i]->ref_fourn, + $lines[$i]->remise_percent, + 'HT', + 0, + $lines[$i]->product_type, + '', + '', + null, + null, + array(), + $lines[$i]->fk_unit, + 0, + $element, + !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid + ); + if ($result < 0) { $error++; break; From 5971cd8e59d435c15e5f0b30531a60d87e038a85 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Mon, 5 Mar 2018 17:18:03 +0100 Subject: [PATCH 010/609] Fix label goes in desc and lost fourn ref --- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- htdocs/fourn/commande/card.php | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4d492bf2bbe..eacc27e29c1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1368,7 +1368,7 @@ class CommandeFournisseur extends CommonOrder * @param int $origin_id Id of origin object * @return int <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0, $origin='', $origin_id=0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0, $origin='', $origin_id=0, $label='') { global $langs,$mysoc,$conf; @@ -1401,7 +1401,7 @@ class CommandeFournisseur extends CommonOrder $pu=$pu_ttc; } $desc=trim($desc); - $ref_supplier=''; // Ref of supplier price when we add line + $ref_supplier=$fourn_ref; // Ref of supplier price when we add line // Check parameters if ($qty < 1 && ! $fk_product) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index aa833d49b6e..fe26bcdc672 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1050,8 +1050,8 @@ if (empty($reshook)) if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0) continue; - $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); - $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->libelle); + $label = (! empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); + $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); // Reset fk_parent_line for no child products and special product @@ -1098,7 +1098,8 @@ if (empty($reshook)) $lines[$i]->fk_unit, 0, $element, - !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid + !empty($lines[$i]->id) ? $lines[$i]->id : $lines[$i]->rowid, + $label ); if ($result < 0) { From 53ce297ab343ac6f00d66b9c23850f68de6e1473 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 9 Mar 2018 09:30:11 +0100 Subject: [PATCH 011/609] Fix travis - missing documentation of new param --- htdocs/fourn/class/fournisseur.commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index eacc27e29c1..0aa6acc1ede 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1366,6 +1366,7 @@ class CommandeFournisseur extends CommonOrder * @param string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object + * @param string $label Label * @return int <=0 if KO, >0 if OK */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0, $origin='', $origin_id=0, $label='') From 34145ed4432416943ee2d00532822a674b9fa7c2 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Sun, 11 Mar 2018 21:58:32 +0100 Subject: [PATCH 012/609] Do not display multicurrency cols if currency of object is same as main currency --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4d44a4b6fec..9c1cd3cb6bd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3370,7 +3370,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''; if ($inputalsopricewithtax) print ''.$langs->trans('PriceUTTC').''; @@ -3409,7 +3409,7 @@ abstract class CommonObject print ''.$langs->trans('TotalHTShort').''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''; if ($outputalsopricetotalwithtax) print ''.$langs->trans('TotalTTCShort').''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f14af2b838f..1deef2e2412 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -65,7 +65,7 @@ if ($nolinesbefore) { trans('VAT'); ?> trans('PriceUHT'); ?> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> trans('PriceUHTCurrency'); ?> @@ -266,7 +266,7 @@ else { "> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> "> @@ -402,7 +402,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index d982516bd67..80d8c617c44 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -122,7 +122,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++; print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 0a20c2679a1..984af537ea9 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,7 +138,7 @@ if (empty($usemargins)) $usemargins=0; subprice); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> multicurrency_subprice); ?> @@ -204,7 +204,7 @@ if (empty($usemargins)) $usemargins=0; trans('Option'); ?> total_ht); ?> - multicurrency->enabled)) { ?> + multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> multicurrency_total_ht); ?> From dc6f4c1f4d51a9a46516953ddf34adf74607884d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 11:48:30 +0100 Subject: [PATCH 013/609] NEW : option to send email to salaries --- htdocs/admin/mails.php | 10 ++ htdocs/core/actions_sendmails.inc.php | 31 ++++- htdocs/core/class/html.formmail.class.php | 49 +++++++- htdocs/core/tpl/card_presend.tpl.php | 18 +++ htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/mails.lang | 2 + .../modulebuilder/template/myobject_list.php | 1 + htdocs/user/class/user.class.php | 106 +++++++++++++++++- 8 files changed, 214 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 7d4e382723c..71b1487ab44 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -71,6 +71,7 @@ if ($action == 'update' && empty($_POST["cancel"])) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_FORCE_SENDTO", GETPOST("MAIN_MAIL_FORCE_SENDTO"),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MAIL_ENABLED_USER_DEST_SELECT", GETPOST("MAIN_MAIL_ENABLED_USER_DEST_SELECT"),'chaine',0,'',$conf->entity); // Send mode parameters dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',$conf->entity); @@ -271,6 +272,12 @@ if ($action == 'edit') print ''; print ''; + + //Add user to select destinaries list + print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''; + print $form->selectyesno('MAIN_MAIL_ENABLED_USER_DEST_SELECT',$conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT,1); + print ''; + // Separator print ' '; @@ -541,6 +548,9 @@ else if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO) && ! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); print ''; + //Add user to select destinaries list + print ''.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).''; + // Separator print ' '; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9f5224a71d3..3498bbc132c 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -170,6 +170,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $sendtocc=''; $sendtobcc=''; $sendtoid = array(); + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $sendtouserid=array(); + } // Define $sendto $receiver=$_POST['receiver']; @@ -192,14 +195,25 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($val == 'thirdparty') // Id of third party { $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } - elseif ($val) // Id du contact + } elseif ($val) // Id du contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); $sendtoid[] = $val; } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $receiveruser=$_POST['receiveruser']; + if (is_array($receiveruser) && count($receiveruser)>0) + { + $fuserdest = new User($db); + foreach($receiveruser as $key=>$val) + { + $tmparray[] = $fuserdest->user_get_property($key,'email'); + $sendtouserid[] = $key; + } + } + } $sendto=implode(',',$tmparray); // Define $sendtocc @@ -230,6 +244,19 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $receiveruser=$_POST['receiveccruser']; + + if (is_array($receiveruser) && count($receiveruser)>0) + { + $fuserdest = new User($db); + foreach($receiveruser as $key=>$val) + { + $tmparray[] = $fuserdest->user_get_property($key,'email'); + $sendtouserid[] = $key; + } + } + } $sendtocc=implode(',',$tmparray); if (dol_strlen($sendto)) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 5ff93994e73..b2f64f4298d 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -81,6 +81,9 @@ class FormMail extends Form var $substit_lines=array(); var $param=array(); + public $withtouser=array(); + public $withtoccuser=array(); + var $error; public $lines_model; @@ -332,7 +335,7 @@ class FormMail extends Form $out.= "\n".'
'."\n"; if ($this->withform == 1) { - $out.= '
'."\n"; + $out.= ''."\n"; $out.= ''; $out.= ''; @@ -623,6 +626,28 @@ class FormMail extends Form $out.= "\n"; } + // To User + if (! empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) + { + $out.= ''; + $out.= $langs->trans("MailToSalaries"); + $out.= ''; + + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withtouser; + foreach($tmparray as $key => $val) + { + $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + } + $withtoselected=GETPOST("receiveruser",'none'); // Array of selected value + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') + { + $withtoselected = array_keys($tmparray); + } + $out.= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); + $out.= "\n"; + } + // withoptiononeemailperrecipient if (! empty($this->withoptiononeemailperrecipient)) { @@ -667,6 +692,28 @@ class FormMail extends Form $out.= "\n"; } + // To User cc + if (! empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) + { + $out.= ''; + $out.= $langs->trans("MailToCCSalaries"); + $out.= ''; + + // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time + $tmparray = $this->withtoccuser; + foreach($tmparray as $key => $val) + { + $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + } + $withtoselected=GETPOST("receiverccuser",'none'); // Array of selected value + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action','aZ09') == 'presend') + { + $withtoselected = array_keys($tmparray); + } + $out.= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); + $out.= "\n"; + } + // CCC if (! empty($this->withtoccc) || is_array($this->withtoccc)) { diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 43cacab0e1c..ca852a46499 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -147,6 +147,24 @@ if ($action == 'presend') $liste[$key] = $value; } } + if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $listeuser=array(); + $fuserdest = new User($db); + + $result= $fuserdest->fetchAll('ASC', 't.lastname', 0, 0, array('customsql'=>'t.statut=1 AND t.employee=1 AND t.email IS NOT NULL AND t.email<>\'\'')); + if ($result>0 && is_array($fuserdest->users) && count($fuserdest->users)>0) { + foreach($fuserdest->users as $uuserdest) { + $listeuser[$uuserdest->id] = $uuserdest->user_get_property($uuserdest->id,'email'); + } + } elseif ($result<0) { + setEventMessages(null, $fuserdest->errors,'errors'); + } + if (count($listeuser)>0) { + $formmail->withtouser = $listeuser; + $formmail->withtoccuser = $listeuser; + } + + } $formmail->withto = GETPOST('sendto') ? GETPOST('sendto') : $liste; $formmail->withtocc = $liste; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 3a7e8a7d14a..71ade0f2058 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -273,6 +273,7 @@ MAIN_MAIL_ERRORS_TO=Email used as 'Errors-To' field in emails sent MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all emails sendings (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) +MAIN_MAIL_ENABLED_USER_DEST_SELECT=Add salaries users with email into allowed destinaries list MAIN_MAIL_SENDMODE=Method to use to send EMails MAIN_MAIL_SMTPS_ID=SMTP ID if authentication required MAIN_MAIL_SMTPS_PW=SMTP Password if authentication required diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 3c512ca7286..3425ea7d603 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -11,7 +11,9 @@ MailFrom=Sender MailErrorsTo=Errors to MailReply=Reply to MailTo=Receiver(s) +MailToSalaries=To salarie(s) MailCC=Copy to +MailToCCSalaries=Copy to salarie(s) MailCCC=Cached copy to MailTopic=EMail topic MailText=Message diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index c1867fb87f7..70a07002955 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -202,6 +202,7 @@ $help_url=''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("MyObjects")); +// TODO : move this SQL request into fetchAll class method // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f3c8f03329f..10091853134 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1,4 +1,6 @@ * Copyright (c) 2002-2003 Jean-Louis Bergamo * Copyright (c) 2004-2012 Laurent Destailleur @@ -115,7 +117,7 @@ class User extends CommonObject public $lastsearch_values_tmp; // To store current search criterias for user public $lastsearch_values; // To store last saved search criterias for user - public $users; // To store all tree of users hierarchy + public $users = array(); // To store all tree of users hierarchy public $parentof; // To store an array of all parents for all ids. private $cache_childids; @@ -135,6 +137,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; + /** * Constructor de la classe * @@ -3011,5 +3014,106 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + /** + * Return property of contact from its id + * + * @param int $rowid id of contact + * @param string $mode 'email' or 'mobile' + * @return string Email of contact with format: "Full name " + */ + function user_get_property($rowid,$mode) + { + $user_property=''; + + if (empty($rowid)) return ''; + + $sql = "SELECT rowid, email, user_mobile, civility, lastname, firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."user"; + $sql.= " WHERE rowid = '".$rowid."'"; + + $resql=$this->db->query($sql); + if ($resql) + { + $nump = $this->db->num_rows($resql); + + if ($nump) + { + $obj = $this->db->fetch_object($resql); + + if ($mode == 'email') $user_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">"; + else if ($mode == 'mobile') $user_property = $obj->user_mobile; + } + return $user_property; + } + else + { + dol_print_error($this->db); + } + } + + /** + * Load all objects into $this->lines + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter=array()) + { + global $conf; + + + $sql="SELECT t.rowid"; + $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; + $sql.= " WHERE 1"; + + //Manage filter + if (!empty($filter)){ + foreach($filter as $key => $value) { + if (strpos($key,'date')) { + $sql.= ' AND '.$key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='customsql') { + $sql.= ' AND '.$value; + } else { + $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; + } + } + } + $sql.= $this->db->order($sortfield,$sortorder); + if ($limit) $sql.= $this->db->plimit($limit+1,$offset); + + dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->users=array(); + $num = $this->db->num_rows($resql); + if ($num) + { + while ($obj = $this->db->fetch_object($resql)) + { + $line = new self($this->db); + $result = $line->fetch($obj->rowid); + if ($result>0 && !empty($line->id)) { + $this->users[$obj->rowid] = clone $line; + } + } + $this->db->free($resql); + } + return $num; + } + else + { + $this->errors[] = $this->db->lasterror(); + return -1; + } + + } + } From d3ae285c0c3b2a480893dfe46ed44d7cb44a6844 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 22:58:17 +0100 Subject: [PATCH 014/609] finish work --- htdocs/core/actions_sendmails.inc.php | 3 +++ htdocs/core/class/html.formmail.class.php | 2 +- .../triggers/interface_50_modAgenda_ActionsAuto.class.php | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 3498bbc132c..fc21202959c 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -457,6 +457,9 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (is_array($attachedfiles) && count($attachedfiles)>0) { $object->attachedfiles = $attachedfiles; } + if (is_array($sendtouserid) && count($sendtouserid)>0 && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { + $object->sendtouserid = $sendtouserid; + } // Call of triggers if (! empty($trigger_name)) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b2f64f4298d..2b1c94889e3 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -335,7 +335,7 @@ class FormMail extends Form $out.= "\n".'
'."\n"; if ($this->withform == 1) { - $out.= ''."\n"; + $out.= ''."\n"; $out.= ''; $out.= ''; diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 78053a0631c..6922189abc4 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -889,6 +889,10 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->fk_element = $elementid; $actioncomm->elementtype = $elementtype; + if (property_exists($object,'sendtouserid') && is_array($object->sendtouserid) && count($object->sendtouserid)>0) { + $actioncomm->userassigned=$object->sendtouserid; + } + $ret=$actioncomm->create($user); // User creating action if ($ret > 0 && $conf->global->MAIN_COPY_FILE_IN_EVENT_AUTO) From c8d309e5998c6dddbb55fd523c6dba9f6125dcf7 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 23:00:33 +0100 Subject: [PATCH 015/609] clean --- htdocs/core/actions_sendmails.inc.php | 3 ++- htdocs/user/class/user.class.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index fc21202959c..dd6eeee4361 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -195,7 +195,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($val == 'thirdparty') // Id of third party { $tmparray[] = $thirdparty->name.' <'.$thirdparty->email.'>'; - } elseif ($val) // Id du contact + } + elseif ($val) // Id du contact { $tmparray[] = $thirdparty->contact_get_property((int) $val,'email'); $sendtoid[] = $val; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 10091853134..6cc7007615a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1,6 +1,4 @@ * Copyright (c) 2002-2003 Jean-Louis Bergamo * Copyright (c) 2004-2012 Laurent Destailleur From 487ef3b7c94786436b257e849b92c17ba0870a58 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 23:01:20 +0100 Subject: [PATCH 016/609] cealn again --- htdocs/user/class/user.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6cc7007615a..75bc87f61a7 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -135,7 +135,6 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - /** * Constructor de la classe * From 4ebb1385334ec103bdb456a7c7567b32077c6016 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 21 Mar 2018 23:03:22 +0100 Subject: [PATCH 017/609] last ones --- htdocs/user/class/user.class.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 75bc87f61a7..82b10426622 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -115,7 +115,7 @@ class User extends CommonObject public $lastsearch_values_tmp; // To store current search criterias for user public $lastsearch_values; // To store last saved search criterias for user - public $users = array(); // To store all tree of users hierarchy + public $users = array(); // To store all tree of users hierarchy public $parentof; // To store an array of all parents for all ids. private $cache_childids; @@ -3012,11 +3012,11 @@ class User extends CommonObject } /** - * Return property of contact from its id + * Return property of user from its id * * @param int $rowid id of contact * @param string $mode 'email' or 'mobile' - * @return string Email of contact with format: "Full name " + * @return string Email of user with format: "Full name " */ function user_get_property($rowid,$mode) { @@ -3049,7 +3049,7 @@ class User extends CommonObject } /** - * Load all objects into $this->lines + * Load all objects into $this->users * * @param string $sortorder sort order * @param string $sortfield sort field @@ -3062,7 +3062,6 @@ class User extends CommonObject { global $conf; - $sql="SELECT t.rowid"; $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; $sql.= " WHERE 1"; From 7c70f9ed03f6ebb4c61a90f4d561ef8b97e12977 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Apr 2018 20:23:47 +0200 Subject: [PATCH 018/609] Fix option STOCK_SUPPORTS_SERVICES --- htdocs/product/card.php | 61 ++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f65898bda68..a3e52f33cd5 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1240,8 +1240,8 @@ else else if ($object->id > 0) { // Fiche en mode edition - if ($action == 'edit' && $usercancreate) - { + if ($action == 'edit' && $usercancreate) + { //WYSIWYG Editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -1302,11 +1302,15 @@ else print ''; // Batch number managment - if ($conf->productbatch->enabled) { - print ''.$langs->trans("ManageLotSerial").''; - $statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); - print $form->selectarray('status_batch',$statutarray,$object->status_batch); - print ''; + if ($conf->productbatch->enabled) + { + if ($object->isProduct() || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print ''.$langs->trans("ManageLotSerial").''; + $statutarray=array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch")); + print $form->selectarray('status_batch',$statutarray,$object->status_batch); + print ''; + } } // Barcode @@ -1391,7 +1395,6 @@ else print 'duration_unit=='m'?' checked':'').'>'.$langs->trans("Month"); print '  '; print 'duration_unit=='y'?' checked':'').'>'.$langs->trans("Year"); - print ''; } else @@ -1612,7 +1615,7 @@ else { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); - } + } if ($action == 'editbarcodetype') { $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'fk_barcode_type'); @@ -1718,35 +1721,19 @@ else } print ''; - // Status (to sell) - /* - print ''.$langs->trans("Status").' ('.$langs->trans("Sell").')'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); - } else { - print $object->getLibStatut(2,0); - } - print ''; - - // Status (to buy) - print ''.$langs->trans("Status").' ('.$langs->trans("Buy").')'; - if (! empty($conf->use_javascript_ajax) && $user->rights->produit->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); - } else { - print $object->getLibStatut(2,1); - } - print ''; - */ - // Batch number management (to batch) - if (! empty($conf->productbatch->enabled)) { - print ''.$langs->trans("ManageLotSerial").''; - if (! empty($conf->use_javascript_ajax) && $usercancreate && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { - print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); - } else { - print $object->getLibStatut(0,2); - } - print ''; + if (! empty($conf->productbatch->enabled)) + { + if ($object->isProduct() || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) + { + print ''.$langs->trans("ManageLotSerial").''; + if (! empty($conf->use_javascript_ajax) && $usercancreate && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { + print ajax_object_onoff($object, 'status_batch', 'tobatch', 'ProductStatusOnBatch', 'ProductStatusNotOnBatch'); + } else { + print $object->getLibStatut(0,2); + } + print ''; + } } // Description From 47dcc0d5c6569562155d3dde921e36846bf28874 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 4 Apr 2018 20:32:36 +0200 Subject: [PATCH 019/609] fix notrigger ignored on BILL_CREATE --- htdocs/compta/facture/class/facture.class.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 601b1d29495..b73307277c8 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -746,10 +746,16 @@ class Facture extends CommonInvoice } else if ($reshook < 0) $error++;*/ - // Call trigger - $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; - // End call triggers + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('BILL_CREATE',$user); + if ($result < 0) $error++; + // End call triggers + } + } if (! $error) { From 2207e5e470dea45ca3dcae09f1e5536f752fb4cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Apr 2018 19:23:36 +0200 Subject: [PATCH 020/609] Fix tooltip --- htdocs/comm/action/list.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index c58c34f3d72..5ea3d2c9e0b 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -234,7 +234,7 @@ $sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= " a.fk_contact, a.note, a.percent as percent,"; $sql.= " a.fk_element, a.elementtype,"; $sql.= " c.code as type_code, c.libelle as type_label,"; -$sql.= " sp.lastname, sp.firstname"; +$sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; @@ -606,9 +606,14 @@ if ($resql) print ''; if ($obj->fk_contact > 0) { + $contactstatic->id=$obj->fk_contact; + $contactstatic->email=$obj->email; $contactstatic->lastname=$obj->lastname; $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; + $contactstatic->phone_pro=$obj->phone_pro; + $contactstatic->phone_mobile=$obj->phone_mobile; + $contactstatic->phone_perso=$obj->phone_perso; + $contactstatic->country_id=$obj->country_id; print $contactstatic->getNomUrl(1,'',28); } else From 920891ba70443db5150ec0232d08b3956563067f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 00:01:24 +0200 Subject: [PATCH 021/609] Fix edit of default opportunit percent --- htdocs/projet/card.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 5ff65eae816..bd8709affaa 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1014,11 +1014,21 @@ elseif ($object->id > 0) jQuery("#divtocloseproject").hide(); } - /* Change percent of default percent of new status is higher */ - if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent)) + /* Change percent with default percent (defaultpercent) if new status (defaultpercent) is higher than current (jQuery("#opp_percent").val()) */ + console.log("oldpercent="+oldpercent); + if (oldpercent != \'\' && (parseFloat(defaultpercent) < parseFloat(oldpercent))) { if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\'); - jQuery("#opp_percent").val(defaultpercent); + if (parseFloat(oldpercent) != 100) { jQuery("#opp_percent").val(oldpercent); } + else { jQuery("#opp_percent").val(defaultpercent); } + } + else + { + if ((parseFloat(jQuery("#opp_percent").val()) < parseFloat(defaultpercent))); + { + if (jQuery("#opp_percent").val() != \'\' && oldpercent != \'\') jQuery("#oldopppercent").text(\' - '.dol_escape_js($langs->transnoentities("PreviousValue")).': \'+oldpercent+\' %\'); + jQuery("#opp_percent").val(defaultpercent); + } } } From a78c064461aa9f21f5f977a73de759cf4ea7df7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20J?= Date: Wed, 4 Apr 2018 12:32:49 +0200 Subject: [PATCH 022/609] Fix CommandeFournisseur::getDispachedLines line ID & return quantity --- htdocs/fourn/class/fournisseur.commande.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a58f33502aa..bdafbe6c629 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1963,7 +1963,7 @@ class CommandeFournisseur extends CommonOrder // List of already dispatched lines $sql = "SELECT p.ref, p.label,"; $sql.= " e.rowid as warehouse_id, e.ref as entrepot,"; - $sql.= " cfd.rowid as dispatchlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; + $sql.= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p,"; $sql.= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; @@ -1981,7 +1981,15 @@ class CommandeFournisseur extends CommonOrder while ($i < $num) { $objp = $this->db->fetch_object($resql); - if ($objp) $ret[]=array('id'=>$objp->dispatchedlineid, 'productid'=>$objp->fk_product, 'warehouseid'=>$objp->warehouse_id); + if ($objp) + { + $ret[] = array( + 'id' => $objp->dispatchedlineid, + 'productid' => $objp->fk_product, + 'warehouseid' => $objp->warehouse_id, + 'qty' => $objp->qty, + ); + } $i++; } From 1009a629d905beab33f0022dd371367f50d278b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 13:20:09 +0200 Subject: [PATCH 023/609] Try better Fix for #8432 --- htdocs/comm/action/class/api_agendaevents.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 7fd76b5d1a9..b507d9c72b9 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -115,13 +115,17 @@ class AgendaEvents extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists $sql = "SELECT t.id as rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + if (! empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if (! empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if (! empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter From f56438112fb5c7dd7f32cd74cf4a67627b09bce8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 17:22:14 +0200 Subject: [PATCH 024/609] FIX CWE-89 --- htdocs/expensereport/list.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index caae068461a..053d293db83 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -72,7 +72,7 @@ $search_user = GETPOST('search_user','int'); $search_amount_ht = GETPOST('search_amount_ht','alpha'); $search_amount_vat = GETPOST('search_amount_vat','alpha'); $search_amount_ttc = GETPOST('search_amount_ttc','alpha'); -$search_status = (GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); +$search_status = (GETPOST('search_status','intcomma')!=''?GETPOST('search_status','intcomma'):GETPOST('statut','intcomma')); $month_start = GETPOST("month_start","int"); $year_start = GETPOST("year_start","int"); $month_end = GETPOST("month_end","int"); @@ -305,11 +305,7 @@ if ($search_amount_ttc != '') $sql.= natural_search('d.total_ttc', $search_amoun // User if ($search_user != '' && $search_user >= 0) $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; // Status -if ($search_status != '' && $search_status >= 0) -{ - if (strstr($search_status, ',')) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; - else $sql.=" AND d.fk_statut = ".$search_status; -} +if ($search_status != '' && $search_status >= 0) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) From 1623fea6182225ecbd230312d67f38f8a391c9da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 17:22:14 +0200 Subject: [PATCH 025/609] FIX SQL Injection CWE-89 --- htdocs/expensereport/list.php | 8 ++------ htdocs/holiday/list.php | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index caae068461a..053d293db83 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -72,7 +72,7 @@ $search_user = GETPOST('search_user','int'); $search_amount_ht = GETPOST('search_amount_ht','alpha'); $search_amount_vat = GETPOST('search_amount_vat','alpha'); $search_amount_ttc = GETPOST('search_amount_ttc','alpha'); -$search_status = (GETPOST('search_status','alpha')!=''?GETPOST('search_status','alpha'):GETPOST('statut','alpha')); +$search_status = (GETPOST('search_status','intcomma')!=''?GETPOST('search_status','intcomma'):GETPOST('statut','intcomma')); $month_start = GETPOST("month_start","int"); $year_start = GETPOST("year_start","int"); $month_end = GETPOST("month_end","int"); @@ -305,11 +305,7 @@ if ($search_amount_ttc != '') $sql.= natural_search('d.total_ttc', $search_amoun // User if ($search_user != '' && $search_user >= 0) $sql.= " AND u.rowid = '".$db->escape($search_user)."'"; // Status -if ($search_status != '' && $search_status >= 0) -{ - if (strstr($search_status, ',')) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; - else $sql.=" AND d.fk_statut = ".$search_status; -} +if ($search_status != '' && $search_status >= 0) $sql.=" AND d.fk_statut IN (".$db->escape($search_status).")"; // RESTRICT RIGHTS if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index c7227e16472..d99afde8c3d 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -85,7 +85,7 @@ if (! $sortorder) $sortorder="DESC"; $sall = trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); -$search_ref = GETPOST('search_ref','alpha'); +$search_ref = GETPOST('search_ref','alphanohtml'); $search_day_create = GETPOST('search_day_create','int'); $search_month_create = GETPOST('search_month_create','int'); $search_year_create = GETPOST('search_year_create','int'); @@ -185,7 +185,7 @@ $order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset); // Ref if(!empty($search_ref)) { - $filter.= " AND cp.rowid = ".$db->escape($search_ref); + $filter.= " AND cp.rowid = ".(int) $db->escape($search_ref); } // Start date From 2d1183cbb75a5c7da73a779b216668e014b9fa73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 17:58:30 +0200 Subject: [PATCH 026/609] FIX can bypass the CSRF protection with url with domain inside --- htdocs/filefunc.inc.php | 22 ++++++++++++++++------ htdocs/main.inc.php | 3 ++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index fd2afa56fd1..e78d9e48508 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -151,13 +151,23 @@ if (empty($dolibarr_strict_mode)) $dolibarr_strict_mode=0; // For debug in php s // Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck)) { - if (! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST']) - && (empty($_SERVER['HTTP_REFERER']) || ! preg_match('/'.preg_quote($_SERVER['HTTP_HOST'],'/').'/i', $_SERVER['HTTP_REFERER']))) + if (! empty($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET' && ! empty($_SERVER['HTTP_HOST'])) { - //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; - print "Access refused by CSRF protection in main.inc.php. Referer of form is outside server that serve the POST.\n"; - print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n"; - die; + $csrfattack=false; + if (empty($_SERVER['HTTP_REFERER'])) $csrfattack=true; // An evil browser was used + else + { + $tmpa=parse_url($_SERVER['HTTP_HOST']); + $tmpb=parse_url($_SERVER['HTTP_REFERER']); + if ($tmpa['host'] != $tmpb['host']) $csrfattack=true; + } + if ($csrfattack) + { + //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_POST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER']; + print "Access refused by CSRF protection in main.inc.php. Referer of form is outside server that serve the POST.\n"; + print "If you access your server behind a proxy using url rewriting, you might check that all HTTP header is propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file).\n"; + die; + } } // Another test is done later on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on. } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2439a9fd6e0..d6705b7832b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -332,7 +332,8 @@ if (! defined('NOTOKENRENEWAL')) $token = dol_hash(uniqid(mt_rand(),TRUE)); // Generates a hash of a random number $_SESSION['newtoken'] = $token; } -if (! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) // Check validity of token, only if option enabled (this option breaks some features sometimes) +if ((! defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && ! empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN)) + || defined('CSRFCHECK_WITH_TOKEN')) // Check validity of token, only if option MAIN_SECURITY_CSRF_WITH_TOKEN enabled or if constant CSRFCHECK_WITH_TOKEN is set { if ($_SERVER['REQUEST_METHOD'] == 'POST' && ! GETPOST('token','alpha')) // Note, offender can still send request by GET { From 417c07a6e81e68e3012864a002bf747e83d688bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 18:33:51 +0200 Subject: [PATCH 027/609] Fix REFLECTED XSS --- htdocs/core/actions_linkedfiles.inc.php | 2 +- htdocs/main.inc.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 4e9e0063dc3..affbd1ec964 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -27,7 +27,7 @@ // Submit file/link -if (GETPOST('sendit','none') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if (! empty($_FILES)) { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index d6705b7832b..2ff276f36f7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -73,7 +73,7 @@ if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* deprecated in PHP * * @param string $val Value * @param string $type 1=GET, 0=POST, 2=PHP_SELF - * @return int >0 if there is an injection + * @return int >0 if there is an injection, 0 if none */ function test_sql_and_script_inject($val, $type) { @@ -128,17 +128,17 @@ function test_sql_and_script_inject($val, $type) * * @param string $var Variable name * @param string $type 1=GET, 0=POST, 2=PHP_SELF - * @return boolean||null true if there is an injection. Stop code if injection found. + * @return boolean|null true if there is no injection. Stop code if injection found. */ function analyseVarsForSqlAndScriptsInjection(&$var, $type) { if (is_array($var)) { - foreach ($var as $key => $value) + foreach ($var as $key => $value) // Warning, $key may also be used for attacks { - if (analyseVarsForSqlAndScriptsInjection($value,$type)) + if (analyseVarsForSqlAndScriptsInjection($key, $type) && analyseVarsForSqlAndScriptsInjection($value, $type)) { - $var[$key] = $value; + //$var[$key] = $value; // This is useless } else { @@ -150,7 +150,7 @@ function analyseVarsForSqlAndScriptsInjection(&$var, $type) } else { - return (test_sql_and_script_inject($var,$type) <= 0); + return (test_sql_and_script_inject($var, $type) <= 0); } } From 1a321e19c89183c409b1e281e77769b1887ba952 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Apr 2018 19:12:13 +0200 Subject: [PATCH 028/609] FIX XSS in company setup page --- htdocs/admin/company.php | 44 +++++++++--------- htdocs/contact/card.php | 74 +++++++++++++++---------------- htdocs/core/lib/functions.lib.php | 4 +- htdocs/main.inc.php | 2 + 4 files changed, 63 insertions(+), 61 deletions(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 62c3dbd73b7..94c2cd72b40 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -78,7 +78,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("town",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("zipcode",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_STATE", GETPOST("state_id",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_MONNAIE", GETPOST("currency",'aZ09'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL", GETPOST("tel",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX", GETPOST("fax",'alpha'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL", GETPOST("mail",'alpha'),'chaine',0,'',$conf->entity); @@ -154,26 +154,26 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } } - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SIRET", GETPOST("siret",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_APE", GETPOST("ape",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_RCS", GETPOST("rcs",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_PROFID5", GETPOST("MAIN_INFO_PROFID5",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object",'nohtml'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START",'int'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_TVAOPTION", GETPOST("optiontva",'aZ09'),'chaine',0,'',$conf->entity); // Local taxes - dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", GETPOST("optionlocaltax1",'alpha'),'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", GETPOST("optionlocaltax2",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION", GETPOST("optionlocaltax1",'aZ09'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION", GETPOST("optionlocaltax2",'aZ09'),'chaine',0,'',$conf->entity); if($_POST["optionlocaltax1"]=="localtax1on") { @@ -183,9 +183,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } else { - dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1','alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX1", GETPOST('lt1','aZ09'),'chaine',0,'',$conf->entity); } - dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC1", GETPOST("clt1",'aZ09'),'chaine',0,'',$conf->entity); } if($_POST["optionlocaltax2"]=="localtax2on") { @@ -195,9 +195,9 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } else { - dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2','alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_VALUE_LOCALTAX2", GETPOST('lt2','aZ09'),'chaine',0,'',$conf->entity); } - dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2",'alpha'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db,"MAIN_INFO_LOCALTAX_CALC2", GETPOST("clt2",'aZ09'),'chaine',0,'',$conf->entity); } if ($action != 'updateedit' && ! $error) @@ -409,7 +409,7 @@ if ($action == 'edit' || $action == 'updateedit') // IDs of the company (country-specific) print ''; - print ''; + print ''; $langs->load("companies"); @@ -562,7 +562,7 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; print ''; - print ''; + print ''; print ''; print "\n"; @@ -595,7 +595,7 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print '
'.$langs->trans("VATManagement").''.$langs->trans("Description").''.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; print ''; - print ''; + print ''; print ''; print "\n"; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index bc0031b5992..36152275a64 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -176,26 +176,26 @@ if (empty($reshook)) $object->entity = (GETPOSTISSET('entity')?GETPOST('entity', 'int'):$conf->entity); $object->socid = GETPOST("socid",'int'); - $object->lastname = GETPOST("lastname"); - $object->firstname = GETPOST("firstname"); - $object->civility_id = GETPOST("civility_id",'alpha'); - $object->poste = GETPOST("poste"); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); - $object->town = GETPOST("town"); + $object->lastname = GETPOST("lastname",'alpha'); + $object->firstname = GETPOST("firstname",'alpha'); + $object->civility_id = GETPOST("civility_id",'alpha'); + $object->poste = GETPOST("poste",'alpha'); + $object->address = GETPOST("address",'alpha'); + $object->zip = GETPOST("zipcode",'alpha'); + $object->town = GETPOST("town",'alpha'); $object->country_id = GETPOST("country_id",'int'); $object->state_id = GETPOST("state_id",'int'); - $object->skype = GETPOST("skype"); + $object->skype = GETPOST("skype",'alpha'); $object->email = GETPOST("email",'alpha'); - $object->phone_pro = GETPOST("phone_pro"); - $object->phone_perso = GETPOST("phone_perso"); - $object->phone_mobile = GETPOST("phone_mobile"); - $object->fax = GETPOST("fax"); + $object->phone_pro = GETPOST("phone_pro",'alpha'); + $object->phone_perso = GETPOST("phone_perso",'alpha'); + $object->phone_mobile = GETPOST("phone_mobile",'alpha'); + $object->fax = GETPOST("fax",'alpha'); $object->jabberid = GETPOST("jabberid",'alpha'); $object->no_email = GETPOST("no_email",'int'); $object->priv = GETPOST("priv",'int'); - $object->note_public = GETPOST("note_public"); - $object->note_private = GETPOST("note_private"); + $object->note_public = GETPOST("note_public",'none'); + $object->note_private = GETPOST("note_private",'none'); $object->statut = 1; //Defult status to Actif // Note: Correct date should be completed with location to have exact GM time of birth. @@ -340,33 +340,33 @@ if (empty($reshook)) $object->oldcopy = clone $object; - $object->old_lastname = GETPOST("old_lastname"); - $object->old_firstname = GETPOST("old_firstname"); + $object->old_lastname = GETPOST("old_lastname",'alpha'); + $object->old_firstname = GETPOST("old_firstname",'alpha'); $object->socid = GETPOST("socid",'int'); - $object->lastname = GETPOST("lastname"); - $object->firstname = GETPOST("firstname"); - $object->civility_id = GETPOST("civility_id",'alpha'); - $object->poste = GETPOST("poste"); + $object->lastname = GETPOST("lastname",'alpha'); + $object->firstname = GETPOST("firstname",'alpha'); + $object->civility_id = GETPOST("civility_id",'alpha'); + $object->poste = GETPOST("poste",'alpha'); - $object->address = GETPOST("address"); - $object->zip = GETPOST("zipcode"); - $object->town = GETPOST("town"); - $object->state_id = GETPOST("state_id",'int'); + $object->address = GETPOST("address",'alpha'); + $object->zip = GETPOST("zipcode",'alpha'); + $object->town = GETPOST("town",'alpha'); + $object->state_id = GETPOST("state_id",'int'); $object->fk_departement = GETPOST("state_id",'int'); // For backward compatibility $object->country_id = GETPOST("country_id",'int'); $object->email = GETPOST("email",'alpha'); $object->skype = GETPOST("skype",'alpha'); - $object->phone_pro = GETPOST("phone_pro"); - $object->phone_perso = GETPOST("phone_perso"); - $object->phone_mobile = GETPOST("phone_mobile"); - $object->fax = GETPOST("fax"); + $object->phone_pro = GETPOST("phone_pro",'alpha'); + $object->phone_perso = GETPOST("phone_perso",'alpha'); + $object->phone_mobile = GETPOST("phone_mobile",'alpha'); + $object->fax = GETPOST("fax",'alpha'); $object->jabberid = GETPOST("jabberid",'alpha'); $object->no_email = GETPOST("no_email",'int'); $object->priv = GETPOST("priv",'int'); - $object->note_public = GETPOST("note_public"); - $object->note_private = GETPOST("note_private"); + $object->note_public = GETPOST("note_public",'none'); + $object->note_private = GETPOST("note_private",'none'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -540,9 +540,9 @@ else // Name print ''; - print ''; + print ''; print ''; - print ''; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -594,8 +594,8 @@ else if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->zip)) == 0) $object->zip = $objsoc->zip; // Predefined with third party if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->town)) == 0) $object->town = $objsoc->town; // Predefined with third party print ''; // Country @@ -635,7 +635,7 @@ else // EMail if (($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party print ''; - print ''; + print ''; if (! empty($conf->mailing->enabled)) { print ''; @@ -649,13 +649,13 @@ else // Instant message and no email print ''; - print ''; + print ''; // Skype if (! empty($conf->skype->enabled)) { print ''; - print ''; + print ''; } // Visibility diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 20ab5aad7a9..a75c9176893 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -549,10 +549,10 @@ function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NU case 'array': if (! is_array($out) || empty($out)) $out=array(); break; - case 'nohtml': + case 'nohtml': // Recommended for most scalar parameters $out=dol_string_nohtmltag($out, 0); break; - case 'alphanohtml': // Recommended for search params + case 'alphanohtml': // Recommended for search parameters if (! is_array($out)) { $out=trim($out); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2ff276f36f7..629e0108045 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -101,6 +101,7 @@ function test_sql_and_script_inject($val, $type) // More on https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet $inj += preg_match('/'; @@ -210,12 +218,12 @@ $account_to=''; $label=''; $amount=''; -if($error) +if ($error) { $account_from = GETPOST('account_from','int'); $account_to = GETPOST('account_to','int'); $label = GETPOST('label','alpha'); - $amount = GETPOST('amount','int'); + $amount = GETPOST('amount','alpha'); } print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_bank.png'); @@ -246,9 +254,9 @@ print "\n"; print "\n"; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print "
'.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").''.$langs->transcountry("LocalTax1Management",$mysoc->country_code).''.$langs->trans("Description").' 
lastname).'" autofocus="autofocus">lastname).'" autofocus="autofocus">firstname).'">
firstname).'">
/ '; - print $formcompany->select_ziptown((GETPOST("zipcode")?GETPOST("zipcode"):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6).' '; - print $formcompany->select_ziptown((GETPOST("town")?GETPOST("town"):$object->town),'town',array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((GETPOST("zipcode",'alpha')?GETPOST("zipcode",'alpha'):$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6).' '; + print $formcompany->select_ziptown((GETPOST("town",'alpha')?GETPOST("town",'alpha'):$object->town),'town',array('zipcode','selectcountry_id','state_id')); print '
email).'">email).'">
jabberid).'">
jabberid).'">
skype).'">
skype).'">
"; $form->select_date((! empty($dateo)?$dateo:''),'','','','','add'); print "
"; From 5a34a229347487a7fe453bf5e31365503817e663 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 13:04:52 +0200 Subject: [PATCH 039/609] Code comment --- htdocs/core/class/html.formfile.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index f3ee31653f7..55e8a5dcb51 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -841,9 +841,10 @@ class FormFile $out=''; $this->infofiles=array('nboffiles'=>0,'extensions'=>array(),'files'=>array()); + // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) + // @TODO Why not showing all files by just removing the '[^\-]+' at end of regex ? $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; - - $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) + $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview //var_dump($file_list); // For ajax treatment From 259f3b3020ab50a2941ad63abaf3872ed9502731 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 13:23:26 +0200 Subject: [PATCH 040/609] Add hidden option MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP --- htdocs/core/class/html.formfile.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 69faa73b7de..0e125a7b944 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -863,8 +863,15 @@ class FormFile } // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files and get only generated files) - // @TODO Why not showing all files by just removing the '[^\-]+' at end of regex ? - $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; + // @TODO Why not showing by default all files by just removing the '[^\-]+' at end of regex ? + if (! empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) + { + $filterforfilesearch = preg_quote(basename($modulesubdir),'/'); + } + else + { + $filterforfilesearch = preg_quote(basename($modulesubdir),'/').'[^\-]+'; + } $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // We also discard .meta and .png preview //var_dump($file_list); From 4d2d9193b9e000b2b3e46ea5b65ae5f44e00c398 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 15:47:13 +0200 Subject: [PATCH 041/609] Work on VAT reports to use option MAIN_INFO_VAT_RETURN --- htdocs/compta/localtax/clients.php | 47 ++++--- htdocs/compta/localtax/index.php | 124 +++++++++++------ htdocs/compta/localtax/list.php | 16 ++- htdocs/compta/localtax/quadri_detail.php | 36 +++-- htdocs/compta/tva/clients.php | 163 ++++++++--------------- htdocs/compta/tva/index.php | 99 +++++++++----- htdocs/compta/tva/list.php | 2 +- htdocs/compta/tva/quadri.php | 8 +- htdocs/compta/tva/quadri_detail.php | 34 +++-- htdocs/core/lib/tax.lib.php | 6 + htdocs/langs/en_US/compta.lang | 13 +- 11 files changed, 300 insertions(+), 248 deletions(-) diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 70d52c3d9d3..3dc3e2777c2 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -28,15 +28,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $local=GETPOST('localTaxType', 'int'); // Date range -$year=GETPOST("year"); +$year=GETPOST("year","int"); if (empty($year)) { $year_current = strftime("%Y",dol_now()); @@ -45,43 +42,48 @@ if (empty($year)) $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q=GETPOST("q"); if (empty($q)) { - if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); } + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } -$min = GETPOST("min"); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); + + /* * View */ @@ -98,6 +100,9 @@ foreach($listofparams as $param) llxHeader('','','','',0,0,'','',$morequerystring); + +$name=$langs->transcountry($local==1?"LT1ReportByCustomers":"LT2ReportByCustomers", $mysoc->country_code); + $fsearch.='
'; $fsearch.=' '; $fsearch.=' '; @@ -108,7 +113,6 @@ $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; // Affiche en-tete du rapport if ($calc==0 || $calc==1) // Calculate on invoice for goods and services { - $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); @@ -126,7 +130,6 @@ if ($calc==0 || $calc==1) // Calculate on invoice for goods and services } if ($calc==2) // Invoice for goods, payment for services { - $nom=$langs->transcountry($local==1?"LT1ReportByCustomersInInputOutputMode":"LT2ReportByCustomersInInputOutputMode",$mysoc->country_code); $calcmode=$langs->trans("CalcModeLT2Debt"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index cfcb117b0a8..39d8a1dfa6a 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -25,32 +25,58 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -$langs->loadLangs(array("other","compta","banks","bills","companies")); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $localTaxType=GETPOST('localTaxType', 'int'); +// Date range $year=GETPOST("year","int"); -if ($year == 0) +if (empty($year)) { - $year_current = strftime("%Y",time()); - $year_start = $year_current; + $year_current = strftime("%Y",dol_now()); + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q"); + if (empty($q)) + { + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + else + { + $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); + $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + } + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -// Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit -$modetax = $conf->global->TAX_MODE; -if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha'); /** * print function @@ -103,6 +129,8 @@ function pt ($db, $sql, $date) * View */ +$form=new Form($db); +$company_static=new Societe($db); $tva = new Tva($db); if($localTaxType==1) { @@ -121,34 +149,35 @@ if($localTaxType==1) { $CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2; } +$description = ''; +// Show report header $name = $langs->trans("ReportByMonth"); $description = $langs->trans($LT); $calcmode = $langs->trans("LTReportBuildWithOptionDefinedInModule").' '; $calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')
'; + +//if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); + $builddate=dol_now(); + llxHeader('', $name); -$textprevyear="".img_previous().""; -$textnextyear=" ".img_next().""; - +//$textprevyear="".img_previous().""; +//$textnextyear=" ".img_next().""; //print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'title_accountancy.png'); -report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); +//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); print '
'; -//print load_fiche_titre($langs->trans("Summary"), '', ''); +print '
'; -print ''; -print ''; - -print '
'; print load_fiche_titre($langs->transcountry($LTSummary,$mysoc->country_code), '', ''); -print ' '; -print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); -print '
'; print ''; print ''; @@ -163,16 +192,26 @@ if($CalcLT==1) { if($CalcLT==2) { print ""; } - print ""; print "\n"; print "\n"; -$y = $year_current ; +$tmp=dol_getdate($date_start); +$y = $tmp['year']; +$m = $tmp['mon']; +$tmp=dol_getdate($date_end); +$yend = $tmp['year']; +$mend = $tmp['mon']; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; -$i=0; -for ($m = 1 ; $m < 13 ; $m++ ) { +$i=0; $mcursor=0; +while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop +{ + $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + if ($m == 13) $y++; + if ($m > 12) $m -= 12; + $mcursor++; + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); @@ -187,20 +226,23 @@ for ($m = 1 ; $m < 13 ; $m++ ) { $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (! is_array($coll_listbuy) && $coll_listbuy == -1) { + if (! is_array($coll_listbuy) && $coll_listbuy == -1) + { $langs->load("errors"); print ''; break; } - if (! is_array($coll_listbuy) && $coll_listbuy == -2) { + if (! is_array($coll_listbuy) && $coll_listbuy == -2) + { print ''; break; } print ''; - print ''; - if($CalcLT==0) { + print ''; + + if ($CalcLT==0) { $x_coll = 0; foreach($coll_listsell as $vatrate=>$val) { $x_coll+=$val[$localTaxType==1?'localtax1':'localtax2']; @@ -247,7 +289,8 @@ for ($m = 1 ; $m < 13 ; $m++ ) { print "\n"; $i++; - if ($i > 2) { + if ($i > 2) + { print ''; print ''; if($CalcLT==0) { @@ -272,7 +315,10 @@ print ''; print '
".$langs->transcountry($LTCustomer,$mysoc->country_code)."".$langs->trans("TotalToPay")." 
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'
'.$langs->trans("SubTotal").':
'; -print '
 '; + +print '
'; + +print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); /* * Payed @@ -281,18 +327,18 @@ print '
 '; $sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datev >= '".$db->idate(dol_get_first_day($y,1,false))."'"; -$sql.= " AND f.datev <= '".$db->idate(dol_get_last_day($y,12,false))."'"; +$sql.= " AND f.datev >= '".$db->idate($date_start)."'"; +$sql.= " AND f.datev <= '".$db->idate($date_end)."'"; $sql.= " AND localtaxtype=".$localTaxType; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); -print '
'; +print '
'; + +print '
'; -print ''; -print ''; llxFooter(); $db->close(); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 54183ef72b9..50bc87d4d27 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/compta/localtax/reglement.php + * \file htdocs/compta/localtax/list.php * \ingroup tax * \brief List of IRPF payments */ @@ -24,15 +24,15 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; -$langs->load("compta"); $langs->load("compta"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt=GETPOST("localTaxType"); + /* * View */ @@ -41,7 +41,13 @@ llxHeader(); $localtax_static = new Localtax($db); -print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code)); +$newcardbutton=''; +if ($user->rights->tax->charges->creer) +{ + $newcardbutton=''.$langs->trans('NewVATPayment').''; +} + +print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code), $newcardbutton); $sql = "SELECT rowid, amount, label, f.datev as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f "; @@ -66,7 +72,7 @@ if ($result) while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; $localtax_static->id=$obj->rowid; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 5e18c786c18..db316a1d6dc 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -38,10 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $local=GETPOST('localTaxType', 'int'); // Date range @@ -63,29 +60,31 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $q=GETPOST("q"); if (empty($q)) { - if (isset($_REQUEST["month"])) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); } + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } -$min = GETPOST("min"); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; // Security check @@ -118,11 +117,11 @@ $fsearch.=' '; $fsearch.=' '; $fsearch.=' '; +$name=$langs->transcountry($local==1?"LT1ReportByQuarters":"LT2ReportByQuarters", $mysoc->country_code); $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services { - $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode"); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); @@ -151,7 +150,6 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice } if ($conf->global->$calc==2) // Invoice for goods, payment for services { - $nom=$langs->trans($local==1?"LT1ReportByQuartersInInputOutputMode":"LT2ReportByQuartersInInputOutputMode"); $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index bd97101cc49..71376a566e1 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2006 Yannick Warnier * Copyright (C) 2014 Ferran Marcet * @@ -20,9 +20,9 @@ */ /** - * \file htdocs/compta/tva/clients.php - * \ingroup tax - * \brief Page des societes + * \file htdocs/compta/tva/clients.php + * \ingroup tax + * \brief Page of sales taxes */ require '../../main.inc.php'; @@ -32,71 +32,56 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); -$langs->load("other"); -$langs->load("admin"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); // Date range -$year=GETPOST("year"); -if (empty($year)) { +$year=GETPOST("year","int"); +if (empty($year)) +{ $year_current = strftime("%Y",dol_now()); $year_start = $year_current; } else { $year_current = $year; $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter -if (empty($date_start) || empty($date_end)) {// We define date_start and date_end +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ $q=GETPOST("q"); - if (empty($q)) { - if (isset($_REQUEST["month"])) { - $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); - $date_end=dol_get_last_day($year_start,$_REQUEST["month"],false); - } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + if (empty($q)) + { + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + else + { + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { - $date_start=dol_get_first_day($year_start,1,false); - $date_end=dol_get_last_day($year_start,3,false); - } - if ($q==2) { - $date_start=dol_get_first_day($year_start,4,false); - $date_end=dol_get_last_day($year_start,6,false); - } - if ($q==3) { - $date_start=dol_get_first_day($year_start,7,false); - $date_end=dol_get_last_day($year_start,9,false); - } - if ($q==4) { - $date_start=dol_get_first_day($year_start,10,false); - $date_end=dol_get_last_day($year_start,12,false); + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } } } -$min = price2num(GETPOST("min")); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; // Security check $socid = GETPOST('socid','int'); -if ($user->societe_id) { - $socid=$user->societe_id; -} +if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') @@ -135,6 +120,8 @@ $fsearch.=' '; $description=''; +// Show report header +$name=$langs->trans("VATReportByCustomers"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); @@ -150,68 +137,32 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); -// Affiche en-tete du rapport -if ($modetax==1) { // Calculate on invoice for goods and services - $name=$langs->trans("VATReportByCustomersInDueDebtMode"); - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); - $description.=$fsearch; - $description.='
' - . ' ' - . $langs->trans('SimpleReport') - . '' - . '
' - . ' ' - . $langs->trans('AddExtraReport') - . '' - . '
'; - $builddate=dol_now(); - //$exportlink=$langs->trans("NotYetAvailable"); +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +//$periodlink=($year_start?"".img_previous()." ".img_next()."":""); +$description.=$fsearch; +$description.='
' + . ' ' + . $langs->trans('SimpleReport') + . '' + . '
' + . ' ' + . $langs->trans('AddExtraReport') + . '' + . '
'; +$builddate=dol_now(); +//$exportlink=$langs->trans("NotYetAvailable"); - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatcust.=' ('.$langs->trans("ToPay").')'; - } - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatsup.=' ('.$langs->trans("ToGetBack").')'; - } +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("Description"); +$amountcust=$langs->trans("AmountHT"); +if ($mysoc->tva_assuj) { + $vatcust.=' ('.$langs->trans("ToPay").')'; } -if ($modetax==0) { // Invoice for goods, payment for services - $name=$langs->trans("VATReportByCustomersInInputOutputMode"); - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); - //if ($conf->global->MAIN_MODULE_COMPTABILITE || $conf->global->MAIN_MODULE_ACCOUNTING) $description.='
'.img_warning().' '.$langs->trans('OptionVatInfoModuleComptabilite'); - //if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) $description.='
'.$langs->trans("WarningDepositsNotIncluded"); - $description.=$fsearch; - $description.='
' - . ' ' - . $langs->trans('SimpleReport') - . '' - . '
' - . ' ' - . $langs->trans('AddExtraReport') - . '' - . '
'; - $builddate=dol_now(); - //$exportlink=$langs->trans("NotYetAvailable"); - - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("Description"); - $amountcust=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatcust.=' ('.$langs->trans("ToPay").')'; - } - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("Description"); - $amountsup=$langs->trans("AmountHT"); - if ($mysoc->tva_assuj) { - $vatsup.=' ('.$langs->trans("ToGetBack").')'; - } +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$langs->trans("Description"); +$amountsup=$langs->trans("AmountHT"); +if ($mysoc->tva_assuj) { + $vatsup.=' ('.$langs->trans("ToGetBack").')'; } report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 0ccd7013ba4..f6d4bdc4524 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -27,31 +27,56 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -$langs->loadLangs(array("other","compta","banks","bills","companies","admin")); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); +// Date range $year=GETPOST("year","int"); -if ($year == 0) +if (empty($year)) { - $year_current = strftime("%Y",time()); - $year_start = $year_current; + $year_current = strftime("%Y",dol_now()); + $year_start = $year_current; } else { - $year_current = $year; - $year_start = $year; + $year_current = $year; + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q"); + if (empty($q)) + { + if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + else + { + $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); + $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + } + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -// Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit -$modetax = $conf->global->TAX_MODE; -if (isset($_GET["modetax"])) $modetax=GETPOST("modetax",'alpha'); - /** * print function @@ -104,10 +129,14 @@ function pt ($db, $sql, $date) * View */ +$form=new Form($db); +$company_static=new Societe($db); $tva = new Tva($db); -$name = $langs->trans("ReportByMonth"); +$description = ''; +// Show report header +$name = $langs->trans("ReportByMonth"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); @@ -124,17 +153,19 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); + $builddate=dol_now(); + llxHeader('', $name); - -$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"').""; -$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; - +//$textprevyear="".img_previous($langs->trans("Previous"), 'class="valignbottom"').""; +//$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; //print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'title_accountancy.png'); -report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); +//report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); print '
'; @@ -152,14 +183,22 @@ print ''.$langs->trans("TotalToPay").''; print ' '."\n"; print ''."\n"; - -$y = $year_current ; - +$tmp=dol_getdate($date_start); +$y = $tmp['year']; +$m = $tmp['mon']; +$tmp=dol_getdate($date_end); +$yend = $tmp['year']; +$mend = $tmp['mon']; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; -$i=0; -for ($m = 1 ; $m < 13 ; $m++ ) +$i=0; $mcursor=0; +while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { + $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + if ($m == 13) $y++; + if ($m > 12) $m -= 12; + $mcursor++; + $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); @@ -215,7 +254,8 @@ for ($m = 1 ; $m < 13 ; $m++ ) print "\n"; $i++; - if ($i > 2) { + if ($i > 2) + { print ''; print ''.$langs->trans("SubTotal").':'; print ''.price($subtotalcoll).''; @@ -245,8 +285,8 @@ print load_fiche_titre($langs->trans("VATPaid"), '', ''); $sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; -$sql.= " AND f.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; +$sql.= " AND f.datep >= '".$db->idate($date_start)."'"; +$sql.= " AND f.datep <= '".$db->idate($date_end)."'"; $sql.= " GROUP BY dm ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); @@ -255,7 +295,6 @@ pt($db, $sql,$langs->trans("Year")." $y"); print '
'; - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { /* @@ -267,8 +306,8 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; $sql1 .= " WHERE f.entity = " . $conf->entity; - $sql1 .= " AND f.datev >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'"; - $sql1 .= " AND f.datev <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'"; + $sql1 .= " AND f.datev >= '" . $db->idate($date_start) . "'"; + $sql1 .= " AND f.datev <= '" . $db->idate($date_end) . "'"; $sql1 .= " GROUP BY dm ORDER BY dm ASC"; $result = $db->query($sql1); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 056e16b4d5b..e796ddacac7 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -35,7 +35,7 @@ $langs->load("compta"); $langs->load("bills"); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php index 6d33c358af2..e572eb7e006 100644 --- a/htdocs/compta/tva/quadri.php +++ b/htdocs/compta/tva/quadri.php @@ -29,6 +29,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); + $year = GETPOST('year', 'int'); if ($year == 0 ) { @@ -40,7 +42,7 @@ if ($year == 0 ) } // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); @@ -259,7 +261,7 @@ if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") $x_paye_sum = 0; $x_paye_ht = 0; foreach($x_both as $rate => $both){ - + print ''; print "$rate%"; print "".price($both['coll']['totalht']).""; @@ -282,7 +284,7 @@ if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") $total = $total + $diff; $subtotal = $subtotal + $diff; - + print ''; print ''; print "".price($diff)."\n"; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 92b67dbfd6f..f6286c32420 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -38,13 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; -$langs->load("bills"); -$langs->load("compta"); -$langs->load("companies"); -$langs->load("products"); -$langs->load("trips"); -$langs->load("other"); -$langs->load("admin"); +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); // Date range $year=GETPOST("year","int"); @@ -67,26 +61,28 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } else { - $month_current = strftime("%m",dol_now()); - if ($month_current >= 10) $q=4; - elseif ($month_current >= 7) $q=3; - elseif ($month_current >= 4) $q=2; - else $q=1; + $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); + if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) $date_end=dol_time_plus_duree($date_start, 3, 'm') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end=dol_time_plus_duree($date_start, 1, 'y') - 1; + else if ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end=dol_time_plus_duree($date_start, 1, 'm') - 1; } } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } -$min = GETPOST("min"); +$min = price2num(GETPOST("min","alpha")); if (empty($min)) $min = 0; // Define modetax (0 or 1) -// 0=normal, 1=option vat for services is on debit +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products $modetax = $conf->global->TAX_MODE; -if (isset($_REQUEST["modetax"])) $modetax=$_REQUEST["modetax"]; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; // Security check diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index d2bc3b37183..26c31a4eee0 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -200,6 +200,12 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire { global $conf; + // If we use date_start and date_end, we must not use $y, $m, $q + if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + { + dol_print_error('', 'Bad value of input parameter for tax_by_date'); + } + $list=array(); if ($direction == 'sell') diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 25e2849b949..24724088e45 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -165,14 +165,19 @@ RulesResultBookkeepingPersonalized=It show record in your Ledger with accounting SeePageForSetup=See menu %s for setup DepositsAreNotIncluded=- Down payment invoices are nor included DepositsAreIncluded=- Down payment invoices are included -LT2ReportByCustomersInInputOutputModeES=Report by third party IRPF -LT1ReportByCustomersInInputOutputModeES=Report by third party RE +LT1ReportByCustomers=Report tax 2 by third party +LT2ReportByCustomers=Report tax 3 by third party +LT1ReportByCustomersES=Report by third party RE +LT2ReportByCustomersES=Report by third party IRPF VATReport=Sale tax report VATReportByPeriods=Sale tax report by period +VATReportByCustomers=Sale tax report by customer VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid VATReportByQuartersInInputOutputMode=Report by Sale tax rate of the tax collected and paid -LT1ReportByQuartersInInputOutputMode=Report by RE rate -LT2ReportByQuartersInInputOutputMode=Report by IRPF rate +LT1ReportByQuarters=Report tax 2 by rate +LT2ReportByQuarters=Report tax 3 by rate +LT1ReportByQuartersES=Report by RE rate +LT2ReportByQuartersES=Report by IRPF rate SeeVATReportInInputOutputMode=See report %sVAT encasement%s for a standard calculation SeeVATReportInDueDebtMode=See report %sVAT on flow%s for a calculation with an option on the flow RulesVATInServices=- For services, the report includes the VAT regulations actually received or issued on the basis of the date of payment. From 4d94327eada0ec08300db9a48978a3c66993f03f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 16:17:40 +0200 Subject: [PATCH 042/609] Look and feel v8 --- htdocs/comm/mailing/list.php | 10 +- htdocs/don/list.php | 8 +- .../modulebuilder/template/myobject_card.php | 1 + .../modulebuilder/template/myobject_list.php | 4 +- htdocs/opensurvey/list.php | 161 ++++++++++++------ htdocs/user/group/card.php | 31 +++- htdocs/user/group/list.php | 8 +- htdocs/user/list.php | 10 +- 8 files changed, 160 insertions(+), 73 deletions(-) diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 4b01ddfaba8..f9fad78a1f0 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -106,12 +106,10 @@ if ($result) $newcardbutton=''.$langs->trans('NewMailing').''; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '',$num, '', 'title_generic.png', 0, $newcardbutton); - $i = 0; - $param = "&sall=".urlencode($sall); - if ($filteremail) $param.='&filteremail='.urlencode($filteremail); + $param = "&sall=".urlencode($sall); + if ($filteremail) $param.='&filteremail='.urlencode($filteremail); print ''; if ($optioncss != '') print ''; @@ -121,7 +119,9 @@ if ($result) print ''; print ''; - $moreforfilter = ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '',$num, '', 'title_generic.png', 0, $newcardbutton); + + $moreforfilter = ''; print '
'; print ''."\n"; diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 9c5aec63951..4d7db533e12 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -133,9 +133,7 @@ if ($resql) $newcardbutton=''.$langs->trans('NewDonation').''; - print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords, 'title_generic.png', 0, $newcardbutton); - - print ''."\n"; + print ''."\n"; if ($optioncss != '') print ''; print ''; print ''; @@ -144,7 +142,9 @@ if ($resql) print ''; print ''; - if ($search_all) + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num,$nbtotalofrecords, 'title_generic.png', 0, $newcardbutton); + + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index a9873d4c4bf..73c1b23f938 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -67,6 +67,7 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectcard'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 7a4a04286f9..d941beb6e98 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -63,7 +63,7 @@ dol_include_once('/mymodule/class/myobject.class.php'); // Load traductions files requiredby by page $langs->loadLangs(array("mymodule@mymodule","other")); -$action = GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action','aZ09')?GETPOST('action','aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm','alpha'); // Result of a confirmation @@ -84,6 +84,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; +//if (! $sortfield) $sortfield="p.date_fin"; +//if (! $sortorder) $sortorder="DESC"; // Initialize technical objects $object=new MyObject($db); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 051028c8f19..d2232019592 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -30,29 +30,37 @@ require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php"); // Security check if (!$user->rights->opensurvey->read) accessforbidden(); -$action=GETPOST('action','aZ09'); +$action = GETPOST('action','aZ09')?GETPOST('action','aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists) +$show_files = GETPOST('show_files','int'); // Show files area generated by bulk actions ? +$confirm = GETPOST('confirm','alpha'); // Result of a confirmation +$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print') + $id=GETPOST('id','alpha'); $numsondage= $id; $search_ref = GETPOST('search_ref', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_status = GETPOST('search_status', 'alpha'); -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$page = GETPOST("page",'int'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) $sortfield="p.date_fin"; if (! $sortorder) $sortorder="DESC"; -if ($page < 0) { - $page = 0; -} $langs->load("opensurvey"); + /* * Actions */ @@ -79,53 +87,21 @@ llxHeader('', $langs->trans("OpenSurveyArea")); $param=''; $fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; + + + + + + + + + $newcardbutton=''; if ($user->rights->opensurvey->read) { $newcardbutton=''.$langs->trans('NewSurvey').''; } -print_barre_liste($langs->trans("OpenSurveyArea"), $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', -1, '', 'title_generic.png', 0, $newcardbutton); - -// List of surveys into database - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; - -$moreforfilter = ''; - -print '
'; -print '
'."\n"; - -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -$arraystatus=array('-1'=>' ','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed")); -print ''; -print ''; -print ''."\n"; - -print ''; -print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.id_sondage", $param,"","",$sortfield,$sortorder); -print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "p.titre", $param,"","",$sortfield,$sortorder); -print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "p.format", $param,"","",$sortfield,$sortorder); -print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, $param,"","",$sortfield,$sortorder); -print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", $param,"",'align="right"',$sortfield,$sortorder); -print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", $param,"",'align="center"',$sortfield,$sortorder); -print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", $param,"",'align="center"',$sortfield,$sortorder); -print_liste_field_titre(''); -print ''."\n"; $sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; $sql.= " u.login, u.firstname, u.lastname"; @@ -150,8 +126,8 @@ $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); } $sql.= $db->plimit($limit+1, $offset); @@ -161,11 +137,83 @@ if (! $resql) dol_print_error($db); $num=$db->num_rows($resql); -$i = 0; $var = true; -while ($i < min($num,$limit)) -{ - $obj=$db->fetch_object($resql); + + + +// List of surveys into database + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($langs->trans("OpenSurveyArea"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionsbutton, $num, $nbtotalofrecords, 'title_generic.png', 0, $newcardbutton, '', $limit); + +$moreforfilter = ''; + +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; +else $moreforfilter = $hookmanager->resPrint; + +if (! empty($moreforfilter)) +{ + print '
'; + print $moreforfilter; + print '
'; +} + +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); + +print '
'; +print '
'. $form->selectarray('search_status', $arraystatus, $search_status).''; -$searchpicto=$form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print '
'."\n"; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +$arraystatus=array('-1'=>' ','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed")); +print ''; +print ''; +print ''."\n"; + +// Fields title label +// -------------------------------------------------------------------- +print ''; +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.id_sondage", $param,"","",$sortfield,$sortorder); +print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "p.titre", $param,"","",$sortfield,$sortorder); +print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "p.format", $param,"","",$sortfield,$sortorder); +print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, $param,"","",$sortfield,$sortorder); +print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", $param,"",'align="right"',$sortfield,$sortorder); +print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", $param,"",'align="center"',$sortfield,$sortorder); +print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", $param,"",'align="center"',$sortfield,$sortorder); +print_liste_field_titre(''); +print ''."\n"; + + + +// Loop on record +// -------------------------------------------------------------------- +$i=0; +$totalarray=array(); +while ($i < min($num, $limit)) +{ + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen + $sql2='select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->id_sondage)."'"; $resql2=$db->query($sql2); if ($resql2) @@ -181,7 +229,8 @@ while ($i < min($num,$limit)) $opensurvey_static->status=$obj->status; $opensurvey_static->date_fin=$db->jdate($obj->date_fin); - print ''; + // Show here line of result + print ''; // Ref print ''; $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)?1:0); // Get if user is available or not for each day -$holiday = new Holiday($db); - $isavailable=array(); if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) { @@ -512,7 +510,14 @@ if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This $cssweekend='weekend'; } -print ''; +$tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + +$cssonholiday=''; +if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; +elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; +elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + +print ''; print ''; print ''; print "\n"; @@ -522,8 +527,10 @@ $colspan = 8; if ($conf->use_javascript_ajax) { print ''; - print ''; + print ''; @@ -531,12 +538,17 @@ if ($conf->use_javascript_ajax) $idw = $tmparray['wday']; $cssweekend=''; - /*if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { $cssweekend='weekend'; - }*/ + } - print ''; + $cssonholiday=''; + if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + + print ''; print ' @@ -620,8 +632,10 @@ if (count($tasksarray) > 0) if ($conf->use_javascript_ajax) { print ''; - print ''; + print ''; @@ -629,12 +643,17 @@ if (count($tasksarray) > 0) $idw = $tmparray['wday']; $cssweekend=''; - /*if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { $cssweekend='weekend'; - }*/ + } - print ''; + $cssonholiday=''; + if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; + + print ''; print ' diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index a52ea4fd6d8..b7d731d786b 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -314,6 +314,7 @@ $projectstatic=new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); +$holiday = new Holiday($db); $title=$langs->trans("TimeSpent"); @@ -417,6 +418,38 @@ print ''; print '
'; + +$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); + +// Get if user is available or not for each day +$isavailable=array(); +if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) +{ + $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); + if (count($tmparray) >= 2) + { + $numstartworkingday = $tmparray[0]; + $numendworkingday = $tmparray[1]; + } +} + +for ($idw=0; $idw<7; $idw++) +{ + $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 + $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); + + // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow + //$tmparray = dol_getdate($dayinloop); + //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); + //print dol_print_date($dayinloop, 'dayhour').' '; + //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; + //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; + + $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); + $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day +} + + $moreforfilter=''; // Filter on categories @@ -448,7 +481,6 @@ if (! empty($moreforfilter)) print ''; } - print '
'; print '
'. $form->selectarray('search_status', $arraystatus, $search_status).''; +$searchpicto=$form->showFilterButtons(); +print $searchpicto; +print '
'; diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 935c5028d20..3f350b7773e 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -45,12 +45,14 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $langs->load("users"); $langs->load("other"); -$id=GETPOST('id', 'int'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); -$userid=GETPOST('user', 'int'); +$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); +$confirm = GETPOST('confirm', 'alpha'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'groupcard'; // To manage different context of search +$userid = GETPOST('user', 'int'); + // Security check $result = restrictedArea($user, 'user', $id, 'usergroup&usergroup', 'user'); @@ -86,6 +88,21 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + if ($cancel) + { + if (! empty($backtopage)) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: ".DOL_URL_ROOT.'/user/group/list.php'); + exit; + } + $action=''; + } + // Action remove group if ($action == 'confirm_delete' && $confirm == "yes") { @@ -296,7 +313,11 @@ if ($action == 'create') dol_fiche_end(); - print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; print ""; } diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index ba7b30c9ca8..29bd19a25ae 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -130,6 +130,12 @@ if ($resql) $text = $langs->trans("ListOfGroups"); + $newcardbutton=''; + if ($user->rights->propal->creer) + { + $newcardbutton=''.$langs->trans('NewGroup').''; + } + print '
'."\n"; if ($optioncss != '') print ''; print ''; @@ -140,7 +146,7 @@ if ($resql) print ''; print ''; - print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); if ($sall) { diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 4386b97ac8f..2020af40323 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -271,6 +271,12 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $text = $langs->trans("ListOfUsers"); +$newcardbutton=''; +if ($user->rights->propal->creer) +{ + $newcardbutton=''.$langs->trans('NewUser').''; +} + print ''."\n"; if ($optioncss != '') print ''; print ''; @@ -281,7 +287,9 @@ print ''; print ''; print ''; -print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + + +print_barre_liste($text, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $nbtotalofrecords, 'title_generic', 0, $newcardbutton, '', $limit); if ($sall) { From f659b623165e339b53f7d7af4666cca586edfa2c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 17:14:23 +0200 Subject: [PATCH 043/609] CSS --- htdocs/projet/activity/perday.php | 43 +++++++++---- htdocs/projet/activity/perweek.php | 97 +++++++++++++++++++----------- htdocs/theme/eldy/style.css.php | 3 + htdocs/theme/md/style.css.php | 3 + 4 files changed, 99 insertions(+), 47 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index b61c5aff922..43720614a2e 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -302,7 +302,7 @@ $projectstatic=new Project($db); $project = new Project($db); $taskstatic = new Task($db); $thirdpartystatic = new Societe($db); - +$holiday = new Holiday($db); $prev = dol_getdate($daytoparse - (24 * 3600)); $prev_year = $prev['year']; @@ -487,8 +487,6 @@ print '
'.$langs->trans("HourStart").''.$langs->trans("Duration").''.$langs->trans("Duration").''.$langs->trans("Note").'
'; + print ''; print $langs->trans("Total"); + print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
 
 
'; + print ''; print $langs->trans("Total"); + print ''; //print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print '
 
 
'."\n"; @@ -461,7 +493,7 @@ print ''; print ''; print ''; print ''; -for($idw=0;$idw<7;$idw++) +for ($idw=0;$idw<7;$idw++) { print ''; } @@ -485,44 +517,25 @@ print ''; print ''; -$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); - -// Get if user is available or not for each day -$holiday = new Holiday($db); - -$isavailable=array(); -if (! empty($conf->global->MAIN_DEFAULT_WORKING_DAYS)) -{ - $tmparray=explode('-', $conf->global->MAIN_DEFAULT_WORKING_DAYS); - if (count($tmparray) >= 2) - { - $numstartworkingday = $tmparray[0]; - $numendworkingday = $tmparray[1]; - } -} - for ($idw=0; $idw<7; $idw++) { $dayinloopfromfirstdaytoshow = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); // $firstdaytoshow is a date with hours = 0 $dayinloop = dol_time_plus_duree($startday, $idw, 'd'); - // Useless because $dayinloopwithouthours should be same than $dayinloopfromfirstdaytoshow - //$tmparray = dol_getdate($dayinloop); - //$dayinloopwithouthours=dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); - //print dol_print_date($dayinloop, 'dayhour').' '; - //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; - //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; - - $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); - $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day - $cssweekend=''; if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { $cssweekend='weekend'; } - print ''; + $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + + $cssonholiday=''; + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + + print ''; } print ''; print "\n"; @@ -540,12 +553,19 @@ if ($conf->use_javascript_ajax) for ($idw = 0; $idw < 7; $idw++) { $cssweekend=''; - /*if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { $cssweekend='weekend'; - }*/ + } - print ''; + $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + + $cssonholiday=''; + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + + print ''; } print ''; print ''; @@ -651,12 +671,19 @@ if (count($tasksarray) > 0) for ($idw = 0; $idw < 7; $idw++) { $cssweekend=''; - /*if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. + if (($idw + 1) < $numstartworkingday || ($idw + 1) > $numendworkingday) // This is a day is not inside the setup of working days, so we use a week-end css. { $cssweekend='weekend'; - }*/ + } - print ''; + $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); + + $cssonholiday=''; + if (! $isavailable[$tmpday]['morning'] && ! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayallday '; + elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; + elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; + + print ''; } print ''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 5c9c861c97e..47369f7c92f 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -414,6 +414,9 @@ td.leftborder, td.hide0 { td.leftborder, td.hide6 { border-right: 1px solid #ccc; } +td.rightborder { + border-right: 1px solid #ccc; +} td.actionbuttons a { padding-left: 6px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 18d61624b8c..3b3f0ca092e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -417,6 +417,9 @@ td.leftborder, td.hide0 { td.leftborder, td.hide6 { border-right: 1px solid #ccc; } +td.rightborder { + border-right: 1px solid #ccc; +} select.flat, form.flat select { font-weight: normal; From 98b9f6bb476c10568953f11d0b26cb88674beedf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 19:12:29 +0200 Subject: [PATCH 044/609] DAV module --- htdocs/admin/dav.php | 163 +++++++++++++++++++++++++++ htdocs/core/modules/modDav.class.php | 2 +- htdocs/dav/dav.lib.php | 32 ++++++ htdocs/langs/en_US/admin.lang | 2 + 4 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 htdocs/admin/dav.php diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php new file mode 100644 index 00000000000..5b532a3822f --- /dev/null +++ b/htdocs/admin/dav.php @@ -0,0 +1,163 @@ + + * + * 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/admin/dav.php + * \ingroup dav + * \brief Page to setup DAV server + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; + + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("agenda"); + +$def = array(); +$actionsave=GETPOST('save','alpha'); + +// Sauvegardes parametres +if ($actionsave) +{ + $i=0; + + $db->begin(); + + $i+=dolibarr_set_const($db,'XXX',trim(GETPOST('XXX','alpha')),'chaine',0,'',$conf->entity); + + if ($i >= 4) + { + $db->commit(); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + $db->rollback(); + setEventMessages($langs->trans("SaveFailed"), null, 'errors'); + } +} + + + +/** + * View + */ + + +llxHeader('', $langs->trans("DAVSetup"), $wikihelp); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("DAVSetup"),$linkback,'title_setup'); + + +print ''; +print ''; + +$head=dav_admin_prepare_head(); + +dol_fiche_head($head, 'webdav', '', -1, 'action'); + +print $langs->trans("WebDAVSetupDesc")."
\n"; +print "
\n"; + +/* +print '
'.$langs->trans("ProgressDeclared"). print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')
'.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.$usertoprocess->firstname.')':'').'
'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
 
 
 
 
 
 
'; + +print ''; +print ""; +print ""; +//print ""; +print ""; +print ""; + +print ''; +print '"; +print ''; +print ""; +print ""; + +print '
".$langs->trans("Parameter")."".$langs->trans("Value")."".$langs->trans("Examples")." 
'.$langs->trans("PasswordTogetVCalExport")."'; +if (! empty($conf->use_javascript_ajax)) + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +print ' 
'; +*/ + +dol_fiche_end(); + +/*print '
'; +print "trans("Save")."\">"; +print "
"; +*/ +print "\n"; + + +clearstatcache(); + +//if ($mesg) print "
$mesg
"; +print "
"; + + +// Define $urlwithroot +$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + +// Show message +$message=''; +$url=''.$urlwithroot.'/dav/fileserver.php'; +$message.=img_picto('','object_globe.png').' '.$langs->trans("WebDavServer",'WebDAV',$url); +$message.='
'; +print $message; + +/*$message =$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login).'
'; +$message.=$langs->trans("AgendaUrlOptionsNotAutoEvent",'systemauto','systemauto').'
'; + +print info_admin($message); +*/ + +/* +if (! empty($conf->use_javascript_ajax)) +{ + print "\n".''; +} +*/ + +llxFooter(); +$db->close(); diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index 0492209f3f0..f6aeeac64c9 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -305,7 +305,7 @@ class modDav extends DolibarrModules */ public function init($options='') { - $this->_load_tables(); + //$this->_load_tables('/dav/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; diff --git a/htdocs/dav/dav.lib.php b/htdocs/dav/dav.lib.php index 326ad7995b5..719fc2a5c99 100644 --- a/htdocs/dav/dav.lib.php +++ b/htdocs/dav/dav.lib.php @@ -38,3 +38,35 @@ if(!defined('CDAV_URI_KEY')) else define('CDAV_URI_KEY', substr(md5($_SERVER['HTTP_HOST']),0,8)); } + + + + +/** + * Prepare array with list of tabs + * + * @return array Array of tabs to show + */ +function dav_admin_prepare_head() +{ + global $db, $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/dav.php?id='.$object->id; + $head[$h][1] = $langs->trans("WebDAV"); + $head[$h][2] = 'webdav'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf,$langs,$object,$head,$h,'admindav'); + + complete_head_from_modules($conf,$langs,$object,$head,$h,'admindav','remove'); + + return $head; +} + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 655e5d46884..3369b2396df 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -470,6 +470,7 @@ WatermarkOnDraftExpenseReports=Watermark on draft expense reports AttachMainDocByDefault=Set this to 1 if you want to attach main document to email by default (if applicable) FilesAttachedToEmail=Attach file SendEmailsReminders=Send agenda reminders by emails +davDescription=Add a component to be a DAV server # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management @@ -1779,6 +1780,7 @@ MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') SeveralLangugeVariatFound=Several language variants found +WebDavServer=URL of %s server : %s ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From b801a465f5a0fb17b0af786c15fd432674195deb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 19:42:47 +0200 Subject: [PATCH 045/609] Translation --- htdocs/compta/bank/ligne.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index f6740ed6fda..05f331eba99 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -437,6 +437,7 @@ if ($result) // Type of payment / Number print "".$langs->trans("Type")." / ".$langs->trans("Numero"); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ""; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { @@ -459,22 +460,10 @@ if ($result) } print ""; - // Bank of cheque - print "".$langs->trans("Bank").""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - print ''; - print ''; - } - else - { - print ''.$objp->banque.''; - } - print ""; - // Transmitter - print "".$langs->trans("CheckTransmitter").""; + print "".$langs->trans("CheckTransmitter"); + print ' ('.$langs->trans("ChequeMaker").')'; + print ""; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { print ''; @@ -487,6 +476,22 @@ if ($result) } print ""; + // Bank of cheque + print "".$langs->trans("Bank"); + print ' ('.$langs->trans("ChequeBank").')'; + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + print ''; + print ''; + } + else + { + print ''.$objp->banque.''; + } + print ""; + // Date ope print ''.$langs->trans("DateOperation").''; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) From 88890cf9f4917b54ff4d10175d7afcaaadb89cc6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 19:58:37 +0200 Subject: [PATCH 046/609] Fix link to reconcile --- htdocs/compta/bank/bankentries_list.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 397d9fd5d7b..5b9f6469f27 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -381,7 +381,8 @@ if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPO if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int'); if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); if (GETPOST("search_thirdparty",'int')) $param.='&thirdparty='.urlencode(GETPOST("search_thirdparty",'int')); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($action == 'reconcile') $param.='&action=reconcile'; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -420,19 +421,17 @@ if ($id > 0 || ! empty($ref)) if ($action != 'reconcile') { - //print '
'; - if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $newparam = $param; + $newparam = preg_replace('/search_conciliated=\d+/i','',$newparam); + $buttonreconcile = ''.$langs->trans("Conciliate").''; } else { $buttonreconcile = ''.$langs->trans("Conciliate").''; } } - - //print '
'; } } else From bacee3c2980afb65b6fcf9b4f2f8f70634f1c35a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 19:42:47 +0200 Subject: [PATCH 047/609] Translation --- htdocs/compta/bank/ligne.php | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 33621d4b9a9..5cb97be90bb 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -435,6 +435,7 @@ if ($result) // Type of payment / Number print "".$langs->trans("Type")." / ".$langs->trans("Numero"); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print ""; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { @@ -457,22 +458,10 @@ if ($result) } print ""; - // Bank of cheque - print "".$langs->trans("Bank").""; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - print ''; - print ''; - } - else - { - print ''.$objp->banque.''; - } - print ""; - // Transmitter - print "".$langs->trans("CheckTransmitter").""; + print "".$langs->trans("CheckTransmitter"); + print ' ('.$langs->trans("ChequeMaker").')'; + print ""; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) { print ''; @@ -485,6 +474,22 @@ if ($result) } print ""; + // Bank of cheque + print "".$langs->trans("Bank"); + print ' ('.$langs->trans("ChequeBank").')'; + print ""; + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + print ''; + print ''; + } + else + { + print ''.$objp->banque.''; + } + print ""; + // Date ope print ''.$langs->trans("DateOperation").''; if ($user->rights->banque->modifier || $user->rights->banque->consolidate) From 989d1c87c6e3c48c2c5ed825df8d05409fdbc664 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 19:58:37 +0200 Subject: [PATCH 048/609] Fix link to reconcile --- htdocs/compta/bank/bankentries_list.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index d773d8ce8e4..f9c958207ff 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -384,7 +384,8 @@ if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPO if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int'); if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); if (GETPOST("search_thirdparty",'int')) $param.='&thirdparty='.urlencode(GETPOST("search_thirdparty",'int')); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($action == 'reconcile') $param.='&action=reconcile'; // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -423,19 +424,17 @@ if ($id > 0 || ! empty($ref)) if ($action != 'reconcile') { - //print '
'; - if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $newparam = $param; + $newparam = preg_replace('/search_conciliated=\d+/i','',$newparam); + $buttonreconcile = ''.$langs->trans("Conciliate").''; } else { $buttonreconcile = ''.$langs->trans("Conciliate").''; } } - - //print '
'; } } else From d7d9c8c3383727cacded0e3097f3d4ff68b1dc3d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 21:04:08 +0200 Subject: [PATCH 049/609] Fix module descriptor of dav module --- htdocs/core/modules/modDav.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index f6aeeac64c9..cede86796a0 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -89,8 +89,8 @@ class modDav extends DolibarrModules 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array(''), // Set this to relative path of css file if module has its own css file - 'js' => array(''), // Set this to relative path of js file if module must load a js on all pages + 'css' => array(), // Set this to relative path of css file if module has its own css file + 'js' => array(), // Set this to relative path of js file if module must load a js on all pages 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' ); From 419b225120e3fdce83510bbdfb565cb4714c3eda Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 21:11:58 +0200 Subject: [PATCH 050/609] Clean code --- htdocs/core/modules/modCron.class.php | 14 +++++++------- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 2ce3cf9d9f6..9ffe92699d7 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -64,17 +64,17 @@ class modCron extends DolibarrModules //------------- $this->config_page_url = array("cron.php@cron"); - // Dependancies - //------------- + // Dependancies + //------------- $this->hidden = !empty($conf->global->MODULE_CRON_DISABLED); // A condition to disable module $this->depends = array(); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled + $this->requiredby = array(); // List of modules id to disable if this one is disabled $this->conflictwith = array(); // List of modules id this module is in conflict with - $this->langfiles = array("cron"); + $this->langfiles = array("cron"); - // Constants - //----------- - $this->const = array( + // Constants + //----------- + $this->const = array( 0=>array( 'CRON_KEY', 'chaine', diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index c9ef9ff828d..2024a6b68e2 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -49,6 +49,9 @@ ALTER TABLE llx_inventory ADD COLUMN import_key varchar(14); -- For 8.0 +-- delete old permission no more used +DELETE FROM llx_rights_def WHERE perms = 'main' and module = 'commercial'; + delete from llx_rights_def where perms IS NULL; delete from llx_user_rights where fk_user not IN (select rowid from llx_user); delete from llx_usergroup_rights where fk_usergroup not in (select rowid from llx_usergroup); From 893adae3466d8a9f5c6024b1f599f67cad465c3b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Apr 2018 21:45:06 +0200 Subject: [PATCH 051/609] FIX view of balance before field --- htdocs/compta/bank/bankentries_list.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 5b9f6469f27..b169a5da642 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -989,12 +989,12 @@ if ($resql) { $tmpnbfieldbeforebalance=0; $tmpnbfieldafterbalance=0; - $balancefieldfound=false; + $balancefieldfound=0; foreach($arrayfields as $key => $val) { if ($key == 'balancebefore' || $key == 'balance') { - $balancefieldfound=true; + $balancefieldfound++; continue; } if (! empty($arrayfields[$key]['checked'])) @@ -1025,9 +1025,20 @@ if ($resql) print ''; print ''; } - print ''; - print price(price2num($balance, 'MT'), 1, $langs); - print ''; + + if (! empty($arrayfields['balancebefore']['checked'])) + { + print ''; + print price(price2num($balance, 'MT'), 1, $langs); + print ''; + } + if (! empty($arrayfields['balance']['checked'])) + { + print ''; + print price(price2num($balance, 'MT'), 1, $langs); + print ''; + } + print ''; print ''; print ' '; + } if (!empty($hidden)) { $out=''; } @@ -5926,6 +5959,10 @@ abstract class CommonObject { $value=preg_replace('/./i','*',$value); } + elseif ($type == 'array') + { + $value = implode('
', $value); + } //print $type.'-'.$size; $out=$value; @@ -6614,7 +6651,14 @@ abstract class CommonObject } else if($this->isArray($info)) { - $queryarray[$field] = serialize($this->{$field}); + if(! empty($this->{$field})) { + if(! is_array($this->{$field})) { + $this->{$field} = array($this->{$field}); + } + $queryarray[$field] = serialize($this->{$field}); + } else { + $queryarray[$field] = NULL; + } } else if($this->isInt($info)) { @@ -6658,9 +6702,13 @@ abstract class CommonObject } elseif($this->isArray($info)) { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); + if(! empty($obj->{$field})) { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); + } else { + $this->{$field} = array(); + } } elseif($this->isInt($info)) { From 2bf66780cbb788a0c068f11e360de1316a52577a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 19 Apr 2018 10:25:19 +0200 Subject: [PATCH 347/609] FIX: travis + code readability --- htdocs/core/class/commonobject.class.php | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0fe540cb3ac..e3c93618b08 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5566,27 +5566,27 @@ abstract class CommonObject if(! empty($value)) { foreach($value as $option) { $out.= ' '; - $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'
'; + $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'
'; } } $out.= ''; $newInput = ' '; - $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; + $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; $out.= ' -'; + $(document).on("click", "a.'.dol_escape_js($keyprefix.$key.$keysuffix).'_del", function() { + $(this).parent().remove(); + }); + }); + '; } if (!empty($hidden)) { $out=''; @@ -5961,7 +5961,7 @@ $(document).ready(function() { } elseif ($type == 'array') { - $value = implode('
', $value); + $value = implode('
', $value); } //print $type.'-'.$size; From 39e890e2d75f76ca69d1587e2936786a5d76dbf0 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Fri, 20 Apr 2018 16:43:27 +0200 Subject: [PATCH 348/609] FIX: handle non-js users --- htdocs/core/class/commonobject.class.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e3c93618b08..478bb3ea460 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5575,18 +5575,20 @@ abstract class CommonObject $newInput = ' '; $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; - $out.= ' - '; + '; + } } if (!empty($hidden)) { $out=''; From be600690cd18eb5b57783887c5c8d006ff4c2f56 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 20 Apr 2018 16:47:49 +0200 Subject: [PATCH 349/609] Fix : Bad value for modulepart --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index a825c4709e6..ea35ba901c3 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -595,7 +595,7 @@ class FormFile $file=dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.$modulepart.'.php',0); $res=include_once $file; } - $class='Modele'.ucfirst($modulepart); + $class='ModelePDF'.ucfirst($modulepart); if (class_exists($class)) { $modellist=call_user_func($class.'::liste_modeles',$this->db); From 6afd4e67e96b0648091910be3197e15d40e47b93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 20 Apr 2018 23:46:56 +0200 Subject: [PATCH 350/609] Fix error in sources->retrieve when a stripeaccount is defined --- htdocs/stripe/class/stripe.class.php | 6 +- htdocs/stripe/payment.php | 235 ++++++++++++++------------- 2 files changed, 124 insertions(+), 117 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 2fbaa261665..3b53b4572f0 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -217,7 +217,7 @@ class Stripe extends CommonObject //$sql.= " AND sa.entity IN (".getEntity('societe').")"; $sql.= " AND sa.type = 'card'"; - dol_syslog(get_class($this) . "::fetch search stripe card id for paymentmode id=".$object->id, LOG_DEBUG); + dol_syslog(get_class($this) . "::fetch search stripe card id for paymentmode id=".$object->id.", stripeacc=".$stripeacc, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -225,13 +225,15 @@ class Stripe extends CommonObject { $obj = $this->db->fetch_object($resql); $cardref = $obj->stripe_card_ref; + dol_syslog("*************".$cardref); if ($cardref) { try { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage $card = $cu->sources->retrieve($cardref); } else { - $card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); + //$card = $cu->sources->retrieve($cardref, array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided + $card = $cu->sources->retrieve($cardref); } } catch(Exception $e) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 0b124ea9929..7e551965df7 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -240,42 +240,43 @@ if (empty($reshook)) if ($action == 'confirm_paiement' && $confirm == 'yes') { - $error=0; + $error=0; - $datepaye = dol_now(); + $datepaye = dol_now(); - $db->begin(); + $db->begin(); - // Clean parameters amount if payment is for a credit note - if (GETPOST('type') == 2) - { - foreach ($amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value,'MT'); - $amounts[$key] = -$newvalue; - } + // Clean parameters amount if payment is for a credit note + if (GETPOST('type') == 2) + { + foreach ($amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value,'MT'); + $amounts[$key] = -$newvalue; + } foreach ($multicurrency_amounts as $key => $value) // How payment is dispatch - { - $newvalue = price2num($value,'MT'); - $multicurrency_amounts[$key] = -$newvalue; - } - } + { + $newvalue = price2num($value,'MT'); + $multicurrency_amounts[$key] = -$newvalue; + } + } - if (! empty($conf->banque->enabled)) - { - // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement - if (GETPOST('accountid') <= 0) - { - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors'); - $error++; - } - } -$facture = new Facture($db); -$facture->fetch($facid); -$facture->fetch_thirdparty(); + if (! empty($conf->banque->enabled)) + { + // Si module bank actif, un compte est obligatoire lors de la saisie d'un paiement + if (GETPOST('accountid') <= 0) + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('AccountToCredit')), null, 'errors'); + $error++; + } + } - $error = 0; + $facture = new Facture($db); + $facture->fetch($facid); + $facture->fetch_thirdparty(); + + $error = 0; if (is_object($stripe) && $stripeacc) { @@ -286,56 +287,60 @@ $facture->fetch_thirdparty(); } } -$stripeamount=0; - foreach ($amounts as $key => $value) // How payment is dispatch - { -$stripeamount+=price2num($value,'MT'); -} + $stripeamount=0; + foreach ($amounts as $key => $value) // How payment is dispatch + { + $stripeamount+=price2num($value,'MT'); + } -if (preg_match('/acct_/i',$source)) -{ -$paiementcode ="VIR"; -} -elseif (preg_match('/card_/i',$source)) -{ -$paiementcode ="CB"; -} -elseif (preg_match('/src_/i',$source)) -{ -$customer2 = \Stripe\Customer::retrieve($customer->id,array("stripe_account" => $stripe->getStripeAccount($entity))); -$src = $customer2->sources->retrieve("$source"); -if ($src->type=='card'){ -$paiementcode ="CB"; -} -} -$societe = new Societe($db); -$societe->fetch($facture->socid); - dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); + if (preg_match('/acct_/i',$source)) + { + $paiementcode ="VIR"; + } + elseif (preg_match('/card_/i',$source)) + { + $paiementcode ="CB"; + } + elseif (preg_match('/src_/i',$source)) + { + $stripeacc = $stripe->getStripeAccount($entity); + $customer2 = \Stripe\Customer::retrieve($customer->id, array("stripe_account" => $stripeacc)); + //$src = $customer2->sources->retrieve("$source", array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided + $src = $customer2->sources->retrieve("$source"); + if ($src->type=='card') + { + $paiementcode ="CB"; + } + } -$charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$source,$customer->id,$stripe->getStripeAccount($conf->entity)); + $societe = new Societe($db); + $societe->fetch($facture->socid); + dol_syslog("Create charge", LOG_DEBUG, 0, '_stripe'); - if (!$error) - { - // Creation of payment line - $paiement = new Paiement($db); - $paiement->datepaye = $datepaye; - $paiement->amounts = $amounts; // Array with all payments dispatching - $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); - $paiement->num_paiement = $charge->message; - $paiement->note = GETPOST('comment'); - } + $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$source,$customer->id,$stripe->getStripeAccount($conf->entity)); - if (! $error) - { + if (!$error) + { + // Creation of payment line + $paiement = new Paiement($db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = dol_getIdFromCode($db,$paiementcode,'c_paiement'); + $paiement->num_paiement = $charge->message; + $paiement->note = GETPOST('comment'); + } - $paiement_id = $paiement->create($user, 0); - if ($paiement_id < 0) - { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($facture->lines)) + if (! $error) + { + + $paiement_id = $paiement->create($user, 0); + if ($paiement_id < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE) && count($facture->lines)) { $outputlangs = $langs; $newlang = ''; @@ -349,53 +354,53 @@ $charge=$stripe->CreatePaymentStripe($stripeamount,"EUR","invoice",$facid,$sourc $ret = $facture->fetch($facid); // Reload to get new records $facture->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } + } - if (! $error) - { - $label='(CustomerInvoicePayment)'; - if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; - $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),'',''); - if ($result < 0) - { - setEventMessages($paiement->error, $paiement->errors, 'errors'); - $error++; - } - elseif (GETPOST('closepaidinvoices')=='on') { - $facture->set_paid($user); - } - } + if (! $error) + { + $label='(CustomerInvoicePayment)'; + if (GETPOST('type') == 2) $label='(CustomerInvoicePaymentBack)'; + $result=$paiement->addPaymentToBank($user,'payment',$label,GETPOST('accountid'),'',''); + if ($result < 0) + { + setEventMessages($paiement->error, $paiement->errors, 'errors'); + $error++; + } + elseif (GETPOST('closepaidinvoices')=='on') { + $facture->set_paid($user); + } + } - if (! $error) - { - $db->commit(); + if (! $error) + { + $db->commit(); - // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card - $invoiceid=0; - foreach ($paiement->amounts as $key => $amount) - { - $facid = $key; - if (is_numeric($amount) && $amount <> 0) - { - if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment - else $invoiceid=$facid; - } - } - if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; - else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; - header('Location: '.$loc); - exit; - } - else - { - $loc = dol_buildpath('/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage().'', 1); - $db->rollback(); - header('Location: '.$loc); - } + // If payment dispatching on more than one invoice, we keep on summary page, otherwise go on invoice card + $invoiceid=0; + foreach ($paiement->amounts as $key => $amount) + { + $facid = $key; + if (is_numeric($amount) && $amount <> 0) + { + if ($invoiceid != 0) $invoiceid=-1; // There is more than one invoice payed by this payment + else $invoiceid=$facid; + } + } + if ($invoiceid > 0) $loc = DOL_URL_ROOT.'/compta/facture/card.php?facid='.$invoiceid; + else $loc = DOL_URL_ROOT.'/compta/paiement/card.php?id='.$paiement_id; + header('Location: '.$loc); + exit; + } + else + { + $loc = dol_buildpath('/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage().'', 1); + $db->rollback(); + header('Location: '.$loc); + exit; + } } } From 9b57dadc18c013834560b0eaa86b7b5a98b0a411 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 00:05:14 +0200 Subject: [PATCH 351/609] css --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 9a431c89fa8..93981a73c2e 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3720,7 +3720,7 @@ table.dp { border-style:none; background-color:transparent; padding:0px; - font-size:9px; + font-size: 0.85em; border-width:0px; color:#0B63A2; vertical-align:middle; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index f9b43f7c7db..5970ad6ef84 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3659,7 +3659,7 @@ table.dp { border-style:none; background-color:transparent; padding:0px; - font-size:9px; + font-size: 0.85em; border-width:0px; color: #eee; vertical-align:middle; From 1031fcd79650c3b232a9dea11e1bfd054c98d80c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 00:37:05 +0200 Subject: [PATCH 352/609] logs --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 53e6ed99469..ebb99385b64 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1984,6 +1984,7 @@ class Facture extends CommonInvoice $this->db->begin(); dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); + $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; $sql.= ' fk_statut='.self::STATUS_CLOSED; if (! $close_code) $sql.= ', paye=1'; @@ -1991,7 +1992,6 @@ class Facture extends CommonInvoice if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; $sql.= ' WHERE rowid = '.$this->id; - dol_syslog(get_class($this)."::set_paid", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { From f6743484dd758c1bb62c829ddaebd1b0b8961bc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 00:58:42 +0200 Subject: [PATCH 353/609] Better support of option COMPANY_AQUARIUM_CLEAN_REGEX --- htdocs/core/modules/societe/mod_codecompta_aquarium.php | 4 ++++ htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 6 insertions(+) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 5bcf3c0f929..c237be0f91c 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -77,6 +77,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $texte.= ''; $texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name,$s2)."
\n"; $texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name,$s1)."
\n"; + $texte.="
\n"; + if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_SPECIAL').' = '.yn(1)."
\n"; + //if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."
\n"; + if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; $texte.= ''; $texte.= '  '; $texte.= ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 62f6194b267..1927008bad1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1785,6 +1785,8 @@ SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a com EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') SeveralLangugeVariatFound=Several language variants found WebDavServer=URL of %s server : %s +COMPANY_AQUARIUM_REMOVE_SPECIAL=Remove special characters +COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From f0c572717f0ef5a15338a52c17d01c449e2880a2 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 21 Apr 2018 01:08:22 +0200 Subject: [PATCH 354/609] fix getcountry note: stripe account may just be call with customer not card or source --- htdocs/stripe/payment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 7e551965df7..a97d5eb4d71 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -32,6 +32,7 @@ // Load Dolibarr environment $res=@include("../main.inc.php"); // For root directory if (! $res) $res=@include("../../main.inc.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -305,7 +306,6 @@ if (empty($reshook)) { $stripeacc = $stripe->getStripeAccount($entity); $customer2 = \Stripe\Customer::retrieve($customer->id, array("stripe_account" => $stripeacc)); - //$src = $customer2->sources->retrieve("$source", array("stripe_account" => $stripeacc)); // this API fails when array stripe_account is provided $src = $customer2->sources->retrieve("$source"); if ($src->type=='card') { @@ -395,7 +395,7 @@ if (empty($reshook)) } else { - $loc = dol_buildpath('/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage().'', 1); + $loc = DOL_URL_ROOT.'/stripeconnect/payment.php?facid='.$facid.'&action=create&error='.$e->getMessage(); $db->rollback(); header('Location: '.$loc); From cc5d54faa5deb286db4cca81934fbbd7e3f51e62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 01:41:38 +0200 Subject: [PATCH 355/609] Doc --- htdocs/install/mysql/migration/repair.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 0cb9b1698d4..cd56eb3bab3 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -437,3 +437,19 @@ update llx_facturedet set product_type = 1 where product_type = 0 AND fk_product update llx_facture_fourn_det set product_type = 0 where product_type = 1 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 0); update llx_facture_fourn_det set product_type = 1 where product_type = 0 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 1); + + + + +-- Note to migrate from old counter aquarium to new one +-- drop table tmp; +-- create table tmp select rowid, code_client, concat(substr(code_client, 1, 6),'-0',substr(code_client, 8, 5)) as code_client2 from llx_societe where code_client like 'CU____-____'; +-- update llx_societe as s set code_client = (select code_client2 from tmp as t where t.rowid = s.rowid) where code_client like 'CU____-____'; +-- drop table tmp; +-- create table tmp select rowid, code_fournisseur, concat(substr(code_fournisseur, 1, 6),'-0',substr(code_fournisseur, 8, 5)) as code_fournisseur2 from llx_societe where code_fournisseur like 'SU____-____'; +-- select * from tmp; +-- update llx_societe as s set s.code_fournisseur = (select code_fournisseur2 from tmp as t where t.rowid = s.rowid) where s.code_fournisseur like 'SU____-____'; +-- update llx_societe set code_compta = concat('411', substr(code_client, 3, 2),substr(code_client, 8, 5)) where client in (1,2,3) and code_compte is not null; +-- update llx_societe set code_compta_fournisseur = concat('401', substr(code_fournisseur, 3, 2),substr(code_fournisseur, 8, 5)) where fournisseur in (1,2,3) and code_fournisseur is not null; + + From f5ef0441fd1bf50851e9202566bbd9a50c8104df Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 21 Apr 2018 11:23:02 +0200 Subject: [PATCH 356/609] fix for customer rereive and charge with sources --- htdocs/stripe/payment.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index a97d5eb4d71..1bf278965b8 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -304,8 +304,8 @@ if (empty($reshook)) } elseif (preg_match('/src_/i',$source)) { - $stripeacc = $stripe->getStripeAccount($entity); - $customer2 = \Stripe\Customer::retrieve($customer->id, array("stripe_account" => $stripeacc)); + + $customer2 = $customerstripe=$stripe->customerStripe($facture->thirdparty, $stripeacc, $servicestatus); $src = $customer2->sources->retrieve("$source"); if ($src->type=='card') { From cca4b1cbf5ab1f5d39e0c5d3eaf4f38bfe5c7093 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 11:24:45 +0200 Subject: [PATCH 357/609] NEW Optimize load of hooks classes (save 1-5Kb of memory) --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/hookmanager.class.php | 32 ++++++++++++----------- htdocs/core/class/html.formfile.class.php | 6 ++++- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f7e0d451506..7a067e7d16d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4609,7 +4609,7 @@ abstract class CommonObject $sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields"; $sql.= " WHERE fk_object = ".$rowid; - dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); + //dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 8cc2c62bee7..f3ca56c2e8f 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -80,28 +80,31 @@ class HookManager $this->contextarray=array_unique(array_merge($arraycontext,$this->contextarray)); // All contexts are concatenated - foreach($conf->modules_parts['hooks'] as $module => $hooks) + foreach($conf->modules_parts['hooks'] as $module => $hooks) // Loop on each module that brings hooks { - if ($conf->$module->enabled) + if (empty($conf->$module->enabled)) continue; + + //dol_syslog(get_class($this).'::initHooks module='.$module.' arraycontext='.join(',',$arraycontext)); + foreach($arraycontext as $context) { - foreach($arraycontext as $context) + if (is_array($hooks)) $arrayhooks=$hooks; // New system + else $arrayhooks=explode(':',$hooks); // Old system (for backward compatibility) + + if (in_array($context, $arrayhooks) || in_array('all', $arrayhooks)) // We instantiate action class only if initialized hook is handled by module { - if (is_array($hooks)) $arrayhooks=$hooks; // New system - else $arrayhooks=explode(':',$hooks); // Old system (for backward compatibility) - if (in_array($context,$arrayhooks) || in_array('all',$arrayhooks)) // We instantiate action class only if hook is required + // Include actions class overwriting hooks + if (! is_object($this->hooks[$context][$module])) // If set, class was already loaded { $path = '/'.$module.'/class/'; $actionfile = 'actions_'.$module.'.class.php'; - $pathroot = ''; - // Include actions class overwriting hooks - dol_syslog('Loading hook:' . $actionfile, LOG_INFO); + dol_syslog(get_class($this).'::initHooks Loading hook class for context '.$context.": ".$actionfile, LOG_INFO); $resaction=dol_include_once($path.$actionfile); if ($resaction) { - $controlclassname = 'Actions'.ucfirst($module); - $actionInstance = new $controlclassname($this->db); - $this->hooks[$context][$module] = $actionInstance; + $controlclassname = 'Actions'.ucfirst($module); + $actionInstance = new $controlclassname($this->db); + $this->hooks[$context][$module] = $actionInstance; } } } @@ -213,20 +216,19 @@ class HookManager $this->resNbOfHooks++; - dol_syslog(get_class($this).'::executeHooks a qualified hook was found for method='.$method.' module='.$module." action=".$action." context=".$context); - $modulealreadyexecuted[$module]=$module; // Use the $currentcontext in method to avoid running twice // Clean class (an error may have been set from a previous call of another method for same module/hook) $actionclassinstance->error=0; $actionclassinstance->errors=array(); + dol_syslog(get_class($this)."::executeHooks Qualified hook found (hooktype=".$hooktype."). We call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", action=".$action." context=".$context, LOG_DEBUG); + // Add current context to avoid method execution in bad context, you can add this test in your method : eg if($currentcontext != 'formfile') return; $parameters['currentcontext'] = $context; // Hooks that must return int (hooks with type 'addreplace') if ($hooktype == 'addreplace') { - dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG); $resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) if ($resaction < 0 || ! empty($actionclassinstance->error) || (! empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index a825c4709e6..6a707b5d91a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1038,7 +1038,11 @@ class FormFile } else { - if (! is_object($form)) $form=new Form($this->db); + if (! is_object($form)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; // The compoent may be included into ajax page that does not include the Form class + $form=new Form($this->db); + } if (! preg_match('/&id=/', $param) && isset($object->id)) $param.='&id='.$object->id; $relativepathwihtoutslashend=preg_replace('/\/$/', '', $relativepath); From cef9782179802ff8678c32ac9fbebf79c8da2444 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 12:00:55 +0200 Subject: [PATCH 358/609] Clean defined constant at begin of pages --- htdocs/admin/mails_senderprofile_list.php | 15 -------- htdocs/admin/modulehelp.php | 10 ------ htdocs/api/index.php | 5 --- htdocs/assets/list.php | 15 -------- htdocs/asterisk/wrapper.php | 2 -- htdocs/blockedlog/ajax/authority.php | 2 -- htdocs/blockedlog/ajax/block-add.php | 2 -- htdocs/blockedlog/ajax/block-info.php | 2 -- htdocs/blockedlog/ajax/check_signature.php | 2 -- htdocs/cashdesk/facturation_dhtml.php | 4 --- htdocs/compta/ajaxpayment.php | 5 --- htdocs/core/ajax/box.php | 4 +-- htdocs/core/ajax/constantonoff.php | 1 - htdocs/core/ajax/contacts.php | 3 -- htdocs/core/ajax/extraparams.php | 1 - htdocs/core/ajax/fileupload.php | 6 ---- htdocs/core/ajax/getaccountcurrency.php | 3 -- htdocs/core/ajax/loadinplace.php | 2 -- htdocs/core/ajax/price.php | 2 -- htdocs/core/ajax/row.php | 1 - htdocs/core/ajax/saveinplace.php | 2 -- htdocs/core/ajax/security.php | 1 - htdocs/core/ajax/selectsearchbox.php | 7 ++-- htdocs/core/ajax/vatrates.php | 3 -- htdocs/core/get_info.php | 1 - htdocs/core/js/lib_foot.js.php | 3 -- htdocs/core/js/lib_head.js.php | 3 -- htdocs/core/js/timepicker.js.php | 3 -- htdocs/core/search.php | 11 +++--- htdocs/dav/fileserver.php | 8 ++--- htdocs/document.php | 5 +-- htdocs/ecm/ajax/ecmdatabase.php | 2 -- htdocs/fourn/ajax/getSupplierPrices.php | 2 -- htdocs/loan/calcmens.php | 12 ++----- .../modulebuilder/template/myobject_card.php | 34 ++++++++++--------- .../modulebuilder/template/myobject_list.php | 34 +++++++++---------- htdocs/opensurvey/wizard/index.php | 6 +--- htdocs/product/ajax/products.php | 22 +++++------- htdocs/projet/jsgantt_language.js.php | 4 --- htdocs/public/agenda/agendaexport.php | 9 ++--- htdocs/public/cron/cron_run_jobs.php | 4 +-- htdocs/public/ticketsup/create_ticket.php | 27 ++++----------- htdocs/public/ticketsup/index.php | 23 ++----------- htdocs/public/website/index.php | 12 +++---- htdocs/public/website/styles.css.php | 12 +++---- htdocs/variants/ajax/getCombinations.php | 10 +++--- htdocs/variants/ajax/get_attribute_values.php | 11 +++--- htdocs/variants/ajax/orderAttribute.php | 2 +- htdocs/viewimage.php | 2 +- htdocs/website/websiteaccount_card.php | 14 -------- 50 files changed, 96 insertions(+), 280 deletions(-) diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 69d1d8a8cea..5f02ecae700 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -21,21 +21,6 @@ * \brief Page to adminsiter email sender profiles */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - - require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index dd90774a05b..b90fa10e211 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -21,17 +21,7 @@ * \brief Page to activate/disable all modules */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 353b945cfda..e66a19c981a 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -24,12 +24,7 @@ * \file htdocs/api/index.php */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php diff --git a/htdocs/assets/list.php b/htdocs/assets/list.php index c8ac1f869f1..6e390b7735a 100644 --- a/htdocs/assets/list.php +++ b/htdocs/assets/list.php @@ -22,21 +22,6 @@ * \brief List page for assets */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - - // Load Dolibarr environment require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); diff --git a/htdocs/asterisk/wrapper.php b/htdocs/asterisk/wrapper.php index 69a9a96f032..8cd5ff979a0 100644 --- a/htdocs/asterisk/wrapper.php +++ b/htdocs/asterisk/wrapper.php @@ -28,8 +28,6 @@ * write = system,call,log,verbose,command,agent,user */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); diff --git a/htdocs/blockedlog/ajax/authority.php b/htdocs/blockedlog/ajax/authority.php index 929fd8401d5..7bde15aa879 100644 --- a/htdocs/blockedlog/ajax/authority.php +++ b/htdocs/blockedlog/ajax/authority.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $res=require '../../master.inc.php'; diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index 24fd71f0514..873b904e7a2 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $res=require '../../main.inc.php'; diff --git a/htdocs/blockedlog/ajax/block-info.php b/htdocs/blockedlog/ajax/block-info.php index d4d4eef4e07..7a4ebebb2cf 100644 --- a/htdocs/blockedlog/ajax/block-info.php +++ b/htdocs/blockedlog/ajax/block-info.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); require '../../main.inc.php'; diff --git a/htdocs/blockedlog/ajax/check_signature.php b/htdocs/blockedlog/ajax/check_signature.php index 4b50474b4a9..199f9051e07 100644 --- a/htdocs/blockedlog/ajax/check_signature.php +++ b/htdocs/blockedlog/ajax/check_signature.php @@ -27,10 +27,8 @@ // Directory to scan (full path) is inside POST['dir']. if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); require '../../main.inc.php'; diff --git a/htdocs/cashdesk/facturation_dhtml.php b/htdocs/cashdesk/facturation_dhtml.php index 72fbd509535..e1a1dcc6bc8 100644 --- a/htdocs/cashdesk/facturation_dhtml.php +++ b/htdocs/cashdesk/facturation_dhtml.php @@ -24,16 +24,12 @@ */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // Change this following line to use the correct relative path (../, ../../, etc) require '../main.inc.php'; diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 27a167bc576..01fe12e50f4 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -20,16 +20,11 @@ * \brief File to return Ajax response on payment breakdown process */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) require '../main.inc.php'; diff --git a/htdocs/core/ajax/box.php b/htdocs/core/ajax/box.php index 612f38bb05b..f6bd5b5214a 100644 --- a/htdocs/core/ajax/box.php +++ b/htdocs/core/ajax/box.php @@ -26,8 +26,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; @@ -70,7 +68,7 @@ if ($boxorder && $zone != '' && $userid > 0) dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG); $result=InfoBox::saveboxorder($db,$zone,$boxorder,$userid); - if ($result > 0) + if ($result > 0) { $langs->load("boxes"); if (! GETPOST('closing')) diff --git a/htdocs/core/ajax/constantonoff.php b/htdocs/core/ajax/constantonoff.php index f79753260d7..9e9f8a0d799 100644 --- a/htdocs/core/ajax/constantonoff.php +++ b/htdocs/core/ajax/constantonoff.php @@ -26,7 +26,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index 1c7c7a56e4b..b03b9f128cf 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -23,10 +23,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; diff --git a/htdocs/core/ajax/extraparams.php b/htdocs/core/ajax/extraparams.php index f8a636e52a5..908c1ef9f11 100644 --- a/htdocs/core/ajax/extraparams.php +++ b/htdocs/core/ajax/extraparams.php @@ -25,7 +25,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); include '../../main.inc.php'; diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 6eb4d5836b8..9405aa26cf1 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -21,16 +21,10 @@ * \brief File to return Ajax response on file upload */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) require '../../main.inc.php'; diff --git a/htdocs/core/ajax/getaccountcurrency.php b/htdocs/core/ajax/getaccountcurrency.php index 40e52672c0e..2289d8e1c0f 100644 --- a/htdocs/core/ajax/getaccountcurrency.php +++ b/htdocs/core/ajax/getaccountcurrency.php @@ -22,10 +22,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 7e9e541c768..099f66ba3de 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; diff --git a/htdocs/core/ajax/price.php b/htdocs/core/ajax/price.php index d4a101fb497..577f659b2cc 100644 --- a/htdocs/core/ajax/price.php +++ b/htdocs/core/ajax/price.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require('../../main.inc.php'); diff --git a/htdocs/core/ajax/row.php b/htdocs/core/ajax/row.php index 4fe31ee7ae8..98f18df8a68 100644 --- a/htdocs/core/ajax/row.php +++ b/htdocs/core/ajax/row.php @@ -28,7 +28,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 61c2dca675b..7070d1a8799 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index cc7335618d0..fa1ce2103d4 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -27,7 +27,6 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); require '../../main.inc.php'; diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 1bc527ff555..57483848c4e 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -27,10 +27,9 @@ if (! isset($usedbyinclude) || empty($usedbyinclude)) { if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal - //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); - if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); - if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); - if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); + if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); + if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREDIRECTBYMAINTOLOGIN')) define('NOREDIRECTBYMAINTOLOGIN','1'); $res=@include '../../main.inc.php'; diff --git a/htdocs/core/ajax/vatrates.php b/htdocs/core/ajax/vatrates.php index ac9691bfa25..3826e521d06 100644 --- a/htdocs/core/ajax/vatrates.php +++ b/htdocs/core/ajax/vatrates.php @@ -22,10 +22,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; diff --git a/htdocs/core/get_info.php b/htdocs/core/get_info.php index 7b2c57b42e3..2f08a1d7d24 100644 --- a/htdocs/core/get_info.php +++ b/htdocs/core/get_info.php @@ -31,7 +31,6 @@ if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); //if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); require_once '../main.inc.php'; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 635de52b7ff..14e2c3f3dec 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -21,10 +21,7 @@ * \brief File that include javascript functions (included if option use_javascript activated) */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); if (! defined('NOLOGIN')) define('NOLOGIN',1); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 3f47e4da15d..1aa9c458e39 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -24,10 +24,7 @@ * JQuery (providing object $) and JQuery-UI (providing $datepicker) libraries must be loaded before this file. */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); if (! defined('NOLOGIN')) define('NOLOGIN',1); diff --git a/htdocs/core/js/timepicker.js.php b/htdocs/core/js/timepicker.js.php index bcd1b4d3c76..f93bb3410f2 100644 --- a/htdocs/core/js/timepicker.js.php +++ b/htdocs/core/js/timepicker.js.php @@ -21,10 +21,7 @@ * \brief File that include javascript functions for timepicker */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); if (! defined('NOLOGIN')) define('NOLOGIN',1); diff --git a/htdocs/core/search.php b/htdocs/core/search.php index e1be41b36ac..8e6017cdf3b 100644 --- a/htdocs/core/search.php +++ b/htdocs/core/search.php @@ -23,15 +23,14 @@ * \brief Wrapper that receive any search. Depending on input field, make a redirect to correct URL. */ -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); -if (! defined('NOLOGIN')) define('NOLOGIN',1); // Not disabled cause need to load personalized language +if (! defined('NOLOGIN')) define('NOLOGIN',1); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); require_once '../main.inc.php'; @@ -142,7 +141,7 @@ if (GETPOST('search_group') != '') } - + // If we are here, search was called with no supported criteria if (! empty($_SERVER['HTTP_REFERER'])) { diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index c8b71d1e3f5..a785fac0ab9 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -21,16 +21,12 @@ * \brief Server DAV */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. require ("../main.inc.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; diff --git a/htdocs/document.php b/htdocs/document.php index 50f4a61186d..0a6e5593f62 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -32,14 +32,11 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks + // For bittorent link, we don't need to load/check we are into a login session if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'bittorrent' && ! defined("NOLOGIN")) { diff --git a/htdocs/ecm/ajax/ecmdatabase.php b/htdocs/ecm/ajax/ecmdatabase.php index 6753a4299b0..666c6df9217 100644 --- a/htdocs/ecm/ajax/ecmdatabase.php +++ b/htdocs/ecm/ajax/ecmdatabase.php @@ -22,10 +22,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index a3990333d46..eeb2c1113f6 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -24,10 +24,8 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 96c8b5204b8..fbe1cecab2d 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -21,16 +21,10 @@ * \file tvi/ajax/list.php * \brief File to return datables output */ -if (! defined('NOTOKENRENEWAL')) - define('NOTOKENRENEWAL', '1'); // Disables token renewal -if (! defined('NOREQUIREMENU')) - define('NOREQUIREMENU', '1'); - // if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) - define('NOREQUIREAJAX', '1'); - // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); - // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); require '../main.inc.php'; require DOL_DOCUMENT_ROOT.'/loan/class/loanschedule.class.php'; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 3d5638bd270..49a7a2a4a5f 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -22,22 +22,24 @@ * \brief Page to create/edit/view myobject */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged + // Load Dolibarr environment $res=0; diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 619ed1cdba7..46a1f51b06f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -22,23 +22,23 @@ * \brief List page for myobject */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); - +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs +//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters +//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters +//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). +//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) +//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu +//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php +//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value +//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged // Load Dolibarr environment $res=0; diff --git a/htdocs/opensurvey/wizard/index.php b/htdocs/opensurvey/wizard/index.php index 0fdde4bbe40..f911321062b 100644 --- a/htdocs/opensurvey/wizard/index.php +++ b/htdocs/opensurvey/wizard/index.php @@ -18,12 +18,8 @@ */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index e24222da70e..cce0f4254a0 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -21,20 +21,14 @@ * \file htdocs/product/ajax/products.php * \brief File to return Ajax response on product list request */ -if (! defined('NOTOKENRENEWAL')) - define('NOTOKENRENEWAL', 1); // Disables token renewal -if (! defined('NOREQUIREMENU')) - define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) - define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) - define('NOREQUIREAJAX', '1'); -if (! defined('NOREQUIRESOC')) - define('NOREQUIRESOC', '1'); -if (! defined('NOCSRFCHECK')) - define('NOCSRFCHECK', '1'); -if (empty($_GET ['keysearch']) && ! defined('NOREQUIREHTML')) - define('NOREQUIREHTML', '1'); + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); require '../../main.inc.php'; diff --git a/htdocs/projet/jsgantt_language.js.php b/htdocs/projet/jsgantt_language.js.php index a702432998e..79280868ecb 100644 --- a/htdocs/projet/jsgantt_language.js.php +++ b/htdocs/projet/jsgantt_language.js.php @@ -20,10 +20,7 @@ * \brief Fichier de javascript de traduction pour JSGantt */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); if (! defined('NOLOGIN')) define('NOLOGIN',1); @@ -31,7 +28,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); - require_once __DIR__.'/../main.inc.php'; // Define mime type diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index c8f7f05ff23..72f1a6b9242 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -28,18 +28,15 @@ * &id=..., &idfrom=..., &idto=... */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. // C'est un wrapper, donc header vierge + /** * Header function * diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 36b21c514e9..b11bf4cc42f 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -27,9 +27,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOLOGIN')) define('NOLOGIN','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +if (! defined('NOLOGIN')) define('NOLOGIN','1'); // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/ticketsup/create_ticket.php b/htdocs/public/ticketsup/create_ticket.php index d57ff680dbf..a6fc6778f96 100644 --- a/htdocs/public/ticketsup/create_ticket.php +++ b/htdocs/public/ticketsup/create_ticket.php @@ -21,28 +21,13 @@ * \ingroup ticketsup * \brief Display public form to add new ticket */ -if (!defined('NOREQUIREUSER')) { - define('NOREQUIREUSER', '1'); -} -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOTOKENRENEWAL')) { - define('NOTOKENRENEWAL', '1'); -} - -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -// If there is no menu to show -if (!defined('NOREQUIREHTML')) { - define('NOREQUIREHTML', '1'); -} -// If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -define("NOLOGIN", 1); // This means this output page does not require to be logged. -define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOLOGIN')) define("NOLOGIN", 1); // This means this output page does not require to be logged. +if (!defined('NOCSRFCHECK')) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticketsup/class/actions_ticketsup.class.php'; diff --git a/htdocs/public/ticketsup/index.php b/htdocs/public/ticketsup/index.php index bbb0be1d471..a7649576275 100644 --- a/htdocs/public/ticketsup/index.php +++ b/htdocs/public/ticketsup/index.php @@ -21,26 +21,9 @@ * \brief Public file to add and manage ticket */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (!defined('NOCSRFCHECK')) { - define('NOCSRFCHECK', '1'); -} -// Do not check anti CSRF attack test -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -if (!defined('NOREQUIREMENU')) { - define('NOREQUIREMENU', '1'); -} -// If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (!defined("NOLOGIN")) { - define("NOLOGIN", '1'); -} -// If this page is public (can be called outside logged session) +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticketsup/class/actions_ticketsup.class.php'; diff --git a/htdocs/public/website/index.php b/htdocs/public/website/index.php index 0558268913d..795dffeb4ea 100644 --- a/htdocs/public/website/index.php +++ b/htdocs/public/website/index.php @@ -22,12 +22,12 @@ * \author Laurent Destailleur */ -define('NOTOKENRENEWAL',1); // Disables token renewal -define("NOLOGIN",1); -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +if (! defined('NOLOGIN')) define("NOLOGIN",1); +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); /** * Header empty diff --git a/htdocs/public/website/styles.css.php b/htdocs/public/website/styles.css.php index 694eaaf344f..36e93d00faf 100644 --- a/htdocs/public/website/styles.css.php +++ b/htdocs/public/website/styles.css.php @@ -21,12 +21,12 @@ * \brief Page to output style page. Called with */ -define('NOTOKENRENEWAL',1); // Disables token renewal -define("NOLOGIN",1); -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal +if (! defined('NOLOGIN')) define("NOLOGIN",1); +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); /** * Header empty diff --git a/htdocs/variants/ajax/getCombinations.php b/htdocs/variants/ajax/getCombinations.php index 5c57191c3eb..14f2c2a415c 100644 --- a/htdocs/variants/ajax/getCombinations.php +++ b/htdocs/variants/ajax/getCombinations.php @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -define('NOTOKENRENEWAL','1'); -define('NOREQUIREMENU','1'); -define('NOREQUIREHTML','1'); -define('NOREQUIREAJAX','1'); -define('NOREQUIRESOC','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/variants/ajax/get_attribute_values.php b/htdocs/variants/ajax/get_attribute_values.php index 6f3571c1856..8fd5c45fade 100644 --- a/htdocs/variants/ajax/get_attribute_values.php +++ b/htdocs/variants/ajax/get_attribute_values.php @@ -1,5 +1,4 @@ * * This program is free software; you can redistribute it and/or modify @@ -16,11 +15,11 @@ * along with this program. If not, see . */ -define('NOTOKENRENEWAL','1'); -define('NOREQUIREMENU','1'); -define('NOREQUIREHTML','1'); -define('NOREQUIREAJAX','1'); -define('NOREQUIRESOC','1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; diff --git a/htdocs/variants/ajax/orderAttribute.php b/htdocs/variants/ajax/orderAttribute.php index 95bad6a427d..92bbcc241d5 100644 --- a/htdocs/variants/ajax/orderAttribute.php +++ b/htdocs/variants/ajax/orderAttribute.php @@ -22,10 +22,10 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks require '../../main.inc.php'; + /* * View */ diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index ed4dd22e953..a53db61a83c 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -35,7 +35,7 @@ if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined('NOREQUIREHOOK')) define('NOREQUIREHOOK','1'); // Disable "main.inc.php" hooks + // Some value of modulepart can be used to get resources that are public so no login are required. if ((isset($_GET["modulepart"]) && ($_GET["modulepart"] == 'mycompany' || $_GET["modulepart"] == 'companylogo')) && ! defined("NOLOGIN")) { diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 8daab76e38c..15ced283957 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -21,20 +21,6 @@ * \brief Page to create/edit/view websiteaccount */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on. -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - // Load Dolibarr environment $res=0; // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) From 3856d64b6362757ad97b3985b1c67213fe1d123b Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 Apr 2018 12:07:19 +0200 Subject: [PATCH 359/609] update code --- htdocs/adherents/card.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index b5e7174f9b0..b2daa12ae8c 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2018 Regis Houssin * Copyright (C) 2012 Marcos García - * Copyright (C) 2012-2016 Philippe Grand + * Copyright (C) 2012-2018 Philippe Grand * Copyright (C) 2015-2016 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -41,11 +41,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -$langs->load("companies"); -$langs->load("bills"); -$langs->load("members"); -$langs->load("users"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies","bills","members","users","other")); $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel','alpha'); From c30b0da07d75853d0d422ff5f49254a43eb2f806 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 12:12:46 +0200 Subject: [PATCH 360/609] Clean code --- htdocs/product/class/product.class.php | 6 +++--- htdocs/product/list.php | 24 ++++++++++-------------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index bb245d8307c..ccb6f4f4e7d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -227,10 +227,10 @@ class Product extends CommonObject public $volume; public $volume_units; - public $accountancy_code_buy; - public $accountancy_code_buy_intra; - public $accountancy_code_buy_export; public $accountancy_code_sell; + public $accountancy_code_sell_intra; + public $accountancy_code_sell_export; + public $accountancy_code_buy; /** * Main barcode diff --git a/htdocs/product/list.php b/htdocs/product/list.php index cae788d0d7b..e5d6b145fb1 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2016 Marcos García * Copyright (C) 2013-2016 Juanjo Menent @@ -271,7 +271,7 @@ else $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.fk_product_type, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql.= ' p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,'; - $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy,'; + $sql.= ' p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,'; $sql.= ' p.datec as date_creation, p.tms as date_update, p.pmp,'; $sql.= ' MIN(pfp.unitprice) as minsellprice'; if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { @@ -317,25 +317,17 @@ else if ($search_tobatch != '' && $search_tobatch >= 0) $sql.= " AND p.tobatch = ".$db->escape($search_tobatch); if ($search_accountancy_code_sell) $sql.= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); if ($search_accountancy_code_buy) $sql.= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); - // Add where from extra fields - - if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { - $sql .= " AND pac.rowid IS NULL"; - } - + if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) $sql .= " AND pac.rowid IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; - // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,"; $sql.= " p.fk_product_type, p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock,"; - $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_buy, p.pmp'; - if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) { - $sql .= ', pac.rowid'; - } + $sql.= ' p.datec, p.tms, p.entity, p.tobatch, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy, p.pmp'; + if (!empty($conf->variants->enabled) && $search_hidechildproducts && ($search_type === 0)) $sql .= ', pac.rowid'; // Add fields from extrafields if (! empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key : ''); @@ -700,7 +692,7 @@ else $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql.= " WHERE fk_product=".$obj->rowid; - $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " AND lang='". $db->escape($langs->getDefaultLang()) ."'"; $sql.= " LIMIT 1"; $result = $db->query($sql); @@ -721,6 +713,10 @@ else $product_static->status_batch = $obj->tobatch; $product_static->entity = $obj->entity; $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { From a8c7be3fb5edb1ced838ef5b37a5b6b096bf0162 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sat, 21 Apr 2018 12:14:51 +0200 Subject: [PATCH 361/609] Typo --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index b2daa12ae8c..06eb0b2b40a 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1384,7 +1384,7 @@ else $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); $outputlangs->loadLangs(array("main", "members")); - // Get email content fro mtemplae + // Get email content from template $arraydefaultmessage=null; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; From ccd9aa8059df06f3279b2c28d879e33baf0d200f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 12:16:12 +0200 Subject: [PATCH 362/609] Fight against dolibarr warnings --- htdocs/admin/tools/dolibarr_export.php | 2 +- htdocs/admin/tools/export.php | 2 +- htdocs/comm/action/index.php | 4 ++-- htdocs/comm/action/rapport/index.php | 2 +- htdocs/comm/contact.php | 2 +- htdocs/comm/mailing/list.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/compta/bank/bankentries_list.php | 2 +- htdocs/compta/bank/releve.php | 2 +- htdocs/compta/bank/various_payment/index.php | 2 +- htdocs/compta/charges/index.php | 2 +- htdocs/compta/deplacement/index.php | 2 +- htdocs/compta/deplacement/list.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/paiement.php | 2 +- htdocs/compta/paiement/cheque/card.php | 2 +- htdocs/compta/paiement/cheque/list.php | 2 +- htdocs/compta/paiement/list.php | 2 +- htdocs/compta/paiement/tovalidate.php | 2 +- htdocs/compta/prelevement/bons.php | 2 +- htdocs/compta/prelevement/list.php | 2 +- htdocs/compta/salaries/index.php | 2 +- htdocs/compta/sociales/index.php | 2 +- htdocs/compta/sociales/payments.php | 2 +- htdocs/compta/tva/list.php | 2 +- htdocs/don/list.php | 2 +- htdocs/expensereport/index.php | 2 +- htdocs/fichinter/list.php | 2 +- htdocs/fourn/contact.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/fourn/facture/paiement.php | 4 ++-- htdocs/hrm/admin/admin_establishment.php | 2 +- htdocs/loan/index.php | 2 +- htdocs/product/reassort.php | 2 +- htdocs/product/reassortlot.php | 2 +- htdocs/product/stock/list.php | 2 +- htdocs/product/stock/massstockmove.php | 2 +- htdocs/product/stock/mouvement.php | 2 +- htdocs/product/stock/replenish.php | 2 +- htdocs/product/stock/replenishorders.php | 2 +- htdocs/product/stock/valo.php | 2 +- htdocs/public/members/public_list.php | 2 +- htdocs/societe/consumption.php | 2 +- htdocs/societe/price.php | 2 +- htdocs/stripe/charge.php | 2 +- htdocs/stripe/payment.php | 2 +- htdocs/stripe/transaction.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- 50 files changed, 52 insertions(+), 52 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index c876d7cfd9a..1c985e23090 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -37,7 +37,7 @@ $page = GETPOST('page','int'); if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; if (empty($page) || $page == -1) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $user->admin) diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index de9ccb2c048..f3d2057395f 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -41,7 +41,7 @@ $page = GETPOST("page",'int'); if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $user->admin) accessforbidden(); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 5e17f6af031..621230bf058 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -44,7 +44,7 @@ if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MA if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -$filter = GETPOST("filter",'',3); +$filter = GETPOST("filter",'alpha',3); $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; @@ -59,7 +59,7 @@ $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page","int"); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="a.datec"; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 2d72fa4c3f8..84fb6c411c8 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -38,7 +38,7 @@ $action=GETPOST('action','alpha'); $month=GETPOST('month'); $year=GETPOST('year'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 5c160bfab16..5fe55c2da21 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -34,7 +34,7 @@ $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; if ($page < 0) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; $type=GETPOST('type', 'alpha'); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index c2e9510f6f0..a85e5e4c01e 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -32,7 +32,7 @@ $result=restrictedArea($user,'mailing'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 71f15122021..761107b73c3 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -85,7 +85,7 @@ $sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alp $mesg=(GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 462b410f6ff..54fb15ffaf7 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -91,7 +91,7 @@ $num_releve=GETPOST("num_releve","alpha"); $cat=GETPOST("cat"); if (empty($dateop)) $dateop=-1; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 6a6557c5aef..3acbb1e0ca7 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -72,7 +72,7 @@ if ($user->rights->banque->consolidate && $action == 'dvprev' && ! empty($dvid)) } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/bank/various_payment/index.php b/htdocs/compta/bank/various_payment/index.php index f87413cb7e7..f92090a0259 100644 --- a/htdocs/compta/bank/various_payment/index.php +++ b/htdocs/compta/bank/various_payment/index.php @@ -38,7 +38,7 @@ $result = restrictedArea($user, 'banque', '', '', ''); $optioncss = GETPOST('optioncss','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); $search_label = GETPOST('search_label','alpha'); diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 321fad5baf6..7a11a709128 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -48,7 +48,7 @@ if (! $year && $mode != 'sconly') { $year=date("Y", time()); } $search_account = GETPOST('search_account','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index 2cd3823bacd..64c5442299f 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -45,7 +45,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="d.dated"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; /* diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 807ddfee700..fad8d93b244 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -46,7 +46,7 @@ $search_company=GETPOST('search_company','alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 3175a70a47c..1fc7fa1fb96 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -69,7 +69,7 @@ $projectid = GETPOST('projectid','int'); $year_date_when=GETPOST('year_date_when'); $month_date_when=GETPOST('month_date_when'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 4d88d29999f..3e751d97b01 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -83,7 +83,7 @@ $search_frequency=GETPOST('search_frequency','alpha'); $search_unit_frequency=GETPOST('search_unit_frequency','alpha'); $search_status=GETPOST('search_status','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 31daeef5cba..e8c34743441 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -103,7 +103,7 @@ if ($option == 'late') { } $filtre = GETPOST('filtre','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 77d9cd0a93d..8b6956a3942 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -819,7 +819,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (! GETPOST('action','aZ09')) { if ($page == -1) $page = 0 ; - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; if (! $sortorder) $sortorder='DESC'; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 8a165ebe811..8489e82ae33 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -54,7 +54,7 @@ $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="b.dateo,b.rowid"; if (empty($page) || $page == -1) { $page = 0; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; $dir=$conf->bank->dir_output.'/checkdeposits/'; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index e31c9cd6e61..c936bfb4519 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -43,7 +43,7 @@ $search_ref = GETPOST('search_ref','alpha'); $search_account = GETPOST('search_account','int'); $search_amount = GETPOST('search_amount','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 6ca9f29c16e..d6187c26ce9 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -59,7 +59,7 @@ $search_amount=GETPOST("search_amount",'alpha'); // alpha because we must be $search_company=GETPOST("search_company",'alpha'); $search_payment_num=GETPOST('search_payment_num','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 7e16b525233..f8c369f0887 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -38,7 +38,7 @@ if ($user->societe_id > 0) } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 04f70471ee2..2e20701db59 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -37,7 +37,7 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index ff6fe4e109c..3bed588e10e 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -40,7 +40,7 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'prelevement','','','bons'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index 317fb377b03..b5cdbb11a82 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -38,7 +38,7 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $search_ref = GETPOST('search_ref','int'); $search_user = GETPOST('search_user','alpha'); $search_label = GETPOST('search_label','alpha'); diff --git a/htdocs/compta/sociales/index.php b/htdocs/compta/sociales/index.php index 85560348289..d38ae348c90 100644 --- a/htdocs/compta/sociales/index.php +++ b/htdocs/compta/sociales/index.php @@ -42,7 +42,7 @@ $search_label = GETPOST('search_label','alpha'); $search_amount = GETPOST('search_amount','alpha'); $search_status = GETPOST('search_status','int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 879e9b69ee7..6abb6013095 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -45,7 +45,7 @@ $year=GETPOST("year",'int'); $filtre=GETPOST("filtre",'alpha'); if (! $year && $mode != 'sconly') { $year=date("Y", time()); } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 36d37145e49..99efc63f2d5 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -46,7 +46,7 @@ $search_account = GETPOST('search_account','int'); $month = GETPOST("month","int"); $year = GETPOST("year","int"); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index 392a9a53e9b..fff82b50179 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -34,7 +34,7 @@ $langs->load("donations"); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 77db05da49a..5fba738809a 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -48,7 +48,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="d.date_create"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; /* diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 67527487a6c..025296c6b0d 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -58,7 +58,7 @@ $result = restrictedArea($user, 'ficheinter', $id,'fichinter'); $diroutputmassaction=$conf->ficheinter->dir_output . '/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index 584b053b3ba..abc4528039d 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -50,7 +50,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; /* diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index c352a658293..b8fd5d2f054 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -108,7 +108,7 @@ if ($option == 'late') { } $filter = GETPOST('filtre','alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index cc636718bb7..94c9f14153c 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -66,7 +66,7 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="p.rowid"; $optioncss = GETPOST('optioncss','alpha'); @@ -725,7 +725,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie */ if (empty($action)) { - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page=GETPOST("page",'int'); diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 23e92b83004..8f3b6c6a838 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -61,7 +61,7 @@ if ($page == -1) { $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $form = new Form($db); $establishmenttmp=new Establishment($db); diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index b08ada94709..caefb7829a4 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -37,7 +37,7 @@ $socid = GETPOST('socid', 'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'loan', '', '', ''); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index f71601e7bc0..798038e0a91 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -56,7 +56,7 @@ $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (! $sortfield) $sortfield="p.ref"; if (! $sortorder) $sortorder="ASC"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; // Load sale and categ filters diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index fc2632fe5e2..aebfd368d1b 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -61,7 +61,7 @@ $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (! $sortfield) $sortfield="p.ref"; if (! $sortorder) $sortorder="ASC"; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; // Load sale and categ filters diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index c973640006f..3d01e7a9f06 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -37,7 +37,7 @@ $search_ref=GETPOST("sref","alpha")?GETPOST("sref","alpha"):GETPOST("search_ref" $search_label=GETPOST("snom","alpha")?GETPOST("snom","alpha"):GETPOST("search_label","alpha"); $search_status=GETPOST("search_status","int"); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); if (! $sortfield) $sortfield="e.ref"; diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index ebe1fbe5375..270217b33f9 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -64,7 +64,7 @@ if (!$sortfield) { if (!$sortorder) { $sortorder = 'ASC'; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; $listofdata=array(); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 6093a252cb6..0d0dccd4af4 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -68,7 +68,7 @@ $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 5a61e8b2a98..360a12a7c69 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -65,7 +65,7 @@ $sortfield = GETPOST('sortfield','alpha'); $sortorder = GETPOST('sortorder','alpha'); $page = GETPOST('page','int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; if (!$sortfield) { diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 8332da36eaa..c10e1117024 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -52,7 +52,7 @@ $search_datemonth = GETPOST('search_datemonth', 'int'); $search_dateday = GETPOST('search_dateday', 'int'); $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); if (!$sortorder) $sortorder = 'DESC'; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index 76e741faa1d..bfc7cd80a78 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -41,7 +41,7 @@ if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; $page = $_GET["page"]; if ($page < 0) $page = 0; -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page; $year = strftime("%Y",time()); diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index ef42b4e8d56..03bf1ae5c98 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -81,7 +81,7 @@ function llxFooterVierge() $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index 1a6a4be6199..0d13c45e5bd 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -39,7 +39,7 @@ $object = new Societe($db); if ($socid > 0) $object->fetch($socid); // Sort & Order fields -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index fc864bd5e01..f1b6b572b35 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -235,7 +235,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; diff --git a/htdocs/stripe/charge.php b/htdocs/stripe/charge.php index 39a3c3bb28b..90779d24962 100644 --- a/htdocs/stripe/charge.php +++ b/htdocs/stripe/charge.php @@ -38,7 +38,7 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; //$result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $rowid = GETPOST("rowid",'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); diff --git a/htdocs/stripe/payment.php b/htdocs/stripe/payment.php index 7e551965df7..edd853e6207 100644 --- a/htdocs/stripe/payment.php +++ b/htdocs/stripe/payment.php @@ -1065,7 +1065,7 @@ print ''; if (! GETPOST('action')) { if ($page == -1) $page = 0 ; - $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; if (! $sortorder) $sortorder='DESC'; diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index 6628a3b46cd..28848106361 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -38,7 +38,7 @@ $socid = GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; //$result = restrictedArea($user, 'salaries', '', '', ''); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $rowid = GETPOST("rowid",'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 3fd7877dae9..15392dcb1c1 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -82,7 +82,7 @@ $month=GETPOST("month"); $yearvalid=GETPOST("yearvalid"); $monthvalid=GETPOST("monthvalid"); -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); From 9eeaf5c3eba85e7b5d68c3fccf1eeac107fb048c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 12:22:21 +0200 Subject: [PATCH 363/609] dol_syslog now strftime instead of dol_print_date --- htdocs/core/modules/syslog/mod_syslog_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 688f963f455..b8cc257a7d9 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -166,7 +166,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface $this->lastTime = $now; } - $message = dol_print_date(time(),"%Y-%m-%d %H:%M:%S").$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; + $message = strftime("%Y-%m-%d %H:%M:%S", time()).$delay." ".sprintf("%-7s", $logLevels[$content['level']])." ".sprintf("%-15s", $content['ip'])." ".($this->ident>0?str_pad('',$this->ident,' '):'').$content['message']; fwrite($filefd, $message."\n"); fclose($filefd); @chmod($logfile, octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK)); From c81c744aaf078321d9f6e47d0f25469a4605fc06 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 13:14:58 +0200 Subject: [PATCH 364/609] Clean deprecated var --- htdocs/comm/action/list.php | 2 +- .../facture/class/facture-rec.class.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 1 + htdocs/contrat/class/contrat.class.php | 21 +++++++------------ 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index deb81238c54..ed8a27f2d3d 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -64,7 +64,7 @@ $dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth','int'), GETPOST('dateendday' if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); -$filter = GETPOST("filter",'',3); +$filter = GETPOST("filter",'alpha',3); $filtert = GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 5a4360e327c..c3ece4a2ee5 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -475,7 +475,6 @@ class FactureRec extends CommonInvoice $line->id = $objp->rowid; $line->rowid = $objp->rowid; - $line->label = $objp->custom_label; // Label line $line->desc = $objp->description; // Description line $line->description = $objp->description; // Description line $line->product_type = $objp->product_type; // Type of line @@ -488,6 +487,8 @@ class FactureRec extends CommonInvoice $line->qty = $objp->qty; $line->subprice = $objp->subprice; + $line->label = $objp->custom_label; // @deprecated + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ebb99385b64..89f9055a776 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2565,6 +2565,7 @@ class Facture extends CommonInvoice // Deprecation warning if ($label) { dol_syslog(__METHOD__ . ": using line label is deprecated", LOG_WARNING); + //var_dump(debug_backtrace(false));exit; } global $mysoc, $conf, $langs; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 215dc185ac4..20f03162d13 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -767,17 +767,7 @@ class Contrat extends CommonObject $line->fk_user_cloture = $objp->fk_user_cloture; $line->fk_unit = $objp->fk_unit; - $line->ref = $objp->product_ref; // deprecated - if (empty($objp->fk_product)) - { - $line->label = ''; // deprecated - $line->libelle = $objp->description; // deprecated - } - else - { - $line->label = $objp->product_label; // deprecated - $line->libelle = $objp->product_label; // deprecated - } + $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Ref product $line->product_desc = $objp->product_desc; // Description product $line->product_label = $objp->product_label; // Label product @@ -2459,12 +2449,15 @@ class ContratLigne extends CommonObjectLine var $fk_contrat; var $fk_product; var $statut; // 0 inactive, 4 active, 5 closed - var $type; // 0 for product, 1 for service + var $type; // 0 for product, 1 for service + /** + * @var string + * @deprecated + */ var $label; /** * @var string - * @deprecated Use $label instead - * @see label + * @deprecated */ public $libelle; From 98cb95cc415521e325e272f944525bd420574044 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 13:19:12 +0200 Subject: [PATCH 365/609] Fix deprecated labels --- htdocs/install/mysql/migration/repair.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index cd56eb3bab3..0724dba9667 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -439,7 +439,10 @@ update llx_facture_fourn_det set product_type = 1 where product_type = 0 AND fk_ - +-- UPDATE llx_contratdet set label = NULL WHERE label IS NOT NULL; +-- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL; + + -- Note to migrate from old counter aquarium to new one -- drop table tmp; From 394b988a4e2b6a1b53069ab97f2892035ea5182d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 14:41:31 +0200 Subject: [PATCH 366/609] FIX key in getEntity for supplier proposals --- htdocs/comm/index.php | 2 +- htdocs/product/class/product.class.php | 2 +- htdocs/product/stats/supplier_proposal.php | 2 +- .../class/supplier_proposal.class.php | 10 +++++----- htdocs/supplier_proposal/index.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 255bb036c93..48d989d0cdc 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -228,7 +228,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_statut = 0"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; + $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ccb6f4f4e7d..7c683a35121 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2767,7 +2767,7 @@ class Product extends CommonObject else $sql.=" AND d.fk_product > 0"; if ($filteronproducttype >= 0) $sql.= " AND prod.rowid = d.fk_product AND prod.fk_product_type =".$filteronproducttype; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; + $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid > 0) $sql.= " AND p.fk_soc = ".$socid; $sql.=$morefilter; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 07e8015d846..a580685c768 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -137,7 +137,7 @@ if ($id > 0 || ! empty($ref)) if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; $sql .= " WHERE p.fk_soc = s.rowid"; - $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql .= " AND d.fk_supplier_proposal = p.rowid"; $sql .= " AND d.fk_product =" . $product->id; if (! empty($search_month)) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 991e3ad5af8..17981be69b9 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -2109,16 +2109,16 @@ class SupplierProposal extends CommonObject $sql = "SELECT p.rowid, p.ref, p.datec as datec"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; $clause = " AND"; } - $sql.= $clause." p.entity = ".$conf->entity; + $sql.= $clause." p.entity IN (".getEntity('supplier_proposal').")"; if ($mode == 'opened') $sql.= " AND p.fk_statut = 1"; if ($mode == 'signed') $sql.= " AND p.fk_statut = 2"; - if ($user->societe_id) $sql.= " AND p.fk_soc = ".$user->societe_id; + if ($user->socid) $sql.= " AND p.fk_soc = ".$user->socid; $resql=$this->db->query($sql); if ($resql) @@ -2266,13 +2266,13 @@ class SupplierProposal extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; - if (!$user->rights->societe->client->voir && !$user->societe_id) + if (!$user->rights->societe->client->voir && !$user->socid) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql.= " WHERE sc.fk_user = " .$user->id; $clause = "AND"; } - $sql.= " ".$clause." p.entity = ".$conf->entity; + $sql.= " ".$clause." p.entity IN (".getEntity('supplier_proposal').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 4b25dfb82ac..68a575c5df8 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -84,7 +84,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; -$sql.= " AND p.entity = ".$conf->entity; +$sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; if ($user->societe_id) $sql.=' AND p.fk_soc = '.$user->societe_id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; $sql.= " AND p.fk_statut IN (0,1,2,3,4)"; @@ -303,7 +303,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos $sql.= ", ".MAIN_DB_PREFIX."supplier_proposal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.fk_soc = s.rowid"; - $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql.= " AND p.fk_statut = 1"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; From 411949a6bbf42072924fc670b344d8d56b019a54 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 15:08:46 +0200 Subject: [PATCH 367/609] Optimize constructors --- htdocs/comm/propal/class/propal.class.php | 32 ++-- htdocs/fourn/class/fournisseur.class.php | 9 +- htdocs/product/class/product.class.php | 21 +-- htdocs/societe/class/client.class.php | 7 +- htdocs/societe/class/societe.class.php | 170 +++++++++--------- .../class/supplier_proposal.class.php | 31 ++-- 6 files changed, 132 insertions(+), 138 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 12ce42a8d03..9cdf621bef9 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -218,18 +218,6 @@ class Propal extends CommonObject $this->remise_absolue = 0; $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; - - $langs->load("propal"); - $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); - $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); - $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); - $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); - $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); - $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); - $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); - $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); - $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); - $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); } @@ -3091,10 +3079,24 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($statut,$mode=1) + function LibStatut($statut,$mode=1) { - global $langs; - $langs->load("propal"); + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("propal"); + $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); + $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); + $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); + $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); + $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); + $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); + $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); + $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); + $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); + $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + } $statuttrans=''; if ($statut==self::STATUS_DRAFT) $statuttrans='statut0'; diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 7364199fca5..ba486e066cc 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -34,8 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; class Fournisseur extends Societe { var $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method - - + + /** * Constructor * @@ -44,10 +44,9 @@ class Fournisseur extends Societe function __construct($db) { $this->db = $db; + $this->client = 0; - $this->fournisseur = 0; - $this->effectif_id = 0; - $this->forme_juridique_code = 0; + $this->fournisseur = 1; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7c683a35121..2f36fd59035 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -160,16 +160,16 @@ class Product extends CommonObject //! Average price value for product entry into stock (PMP) public $pmp; - /** + /** * Stock alert * @var int */ - public $seuil_stock_alerte; + public $seuil_stock_alerte=0; /** * Ask for replenishment when $desiredstock < $stock_reel */ - public $desiredstock; + public $desiredstock=0; /* * Service expiration @@ -185,13 +185,13 @@ class Product extends CommonObject * Status indicates whether the product is on sale '1' or not '0' * @var int */ - public $status; + public $status=0; /** * Status indicate whether the product is available for purchase '1' or not '0' * @var int */ - public $status_buy; + public $status_buy=0; /** * Status indicates whether the product is a finished product '1' or a raw material '0' @@ -203,7 +203,7 @@ class Product extends CommonObject * We must manage lot/batch number, sell-by date and so on : '1':yes '0':no * @var int */ - public $status_batch; + public $status_batch=0; /** * Customs code @@ -266,7 +266,7 @@ class Product extends CommonObject //! Product ID already linked to a reference supplier public $product_id_already_linked; - public $nbphoto; + public $nbphoto=0; //! Contains detail of stock of product into each warehouse public $stock_warehouse=array(); @@ -332,14 +332,7 @@ class Product extends CommonObject global $langs; $this->db = $db; - $this->status = 0; - $this->status_buy = 0; - $this->nbphoto = 0; - $this->stock_reel = 0; - $this->seuil_stock_alerte = 0; - $this->desiredstock = 0; $this->canvas = ''; - $this->status_batch=0; } /** diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php index 6db71eb4218..59eea72c2c7 100644 --- a/htdocs/societe/class/client.class.php +++ b/htdocs/societe/class/client.class.php @@ -29,9 +29,9 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; */ class Client extends Societe { - var $next_prev_filter="te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method + public $next_prev_filter="te.client in (1,2,3)"; // Used to add a filter in Form::showrefnav method - var $cacheprospectstatus=array(); + public $cacheprospectstatus=array(); /** @@ -42,6 +42,9 @@ class Client extends Societe function __construct($db) { $this->db = $db; + + $this->client = 3; + $this->fournisseur = 0; } /** diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1fb99e3c5d2..32f29522268 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -107,22 +107,22 @@ class Societe extends CommonObject * Thirdparty status : 0=activity ceased, 1= in activity * @var int */ - var $status; + public $status=1; /** * Id of department * @var int */ - var $state_id; - var $state_code; - var $state; + public $state_id; + public $state_code; + public $state; /** * Id of region * @var int */ - var $region_code; - var $region; + public $region_code; + public $region; /** * State code @@ -130,54 +130,54 @@ class Societe extends CommonObject * @deprecated Use state_code instead * @see state_code */ - var $departement_code; + public $departement_code; /** * @var string * @deprecated Use state instead * @see state */ - var $departement; + public $departement; /** * @var string * @deprecated Use country instead * @see country */ - var $pays; + public $pays; /** * Phone number * @var string */ - var $phone; + public $phone; /** * Fax number * @var string */ - var $fax; + public $fax; /** * Email * @var string */ - var $email; + public $email; /** * Skype username * @var string */ - var $skype; + public $skype; /** * Webpage * @var string */ - var $url; + public $url; //! barcode /** * Barcode value * @var string */ - var $barcode; + public $barcode; // 6 professional id (usage depends on country) @@ -185,68 +185,68 @@ class Societe extends CommonObject * Professional ID 1 (Ex: Siren in France) * @var string */ - var $idprof1; + public $idprof1; /** * Professional ID 2 (Ex: Siret in France) * @var string */ - var $idprof2; + public $idprof2; /** * Professional ID 3 (Ex: Ape in France) * @var string */ - var $idprof3; + public $idprof3; /** * Professional ID 4 (Ex: RCS in France) * @var string */ - var $idprof4; + public $idprof4; /** * Professional ID 5 * @var string */ - var $idprof5; + public $idprof5; /** * Professional ID 6 * @var string */ - var $idprof6; + public $idprof6; - var $prefix_comm; + public $prefix_comm; - var $tva_assuj; + public $tva_assuj=1; /** * Intracommunitary VAT ID * @var string */ - var $tva_intra; + public $tva_intra; // Local taxes - var $localtax1_assuj; - var $localtax1_value; - var $localtax2_assuj; - var $localtax2_value; + public $localtax1_assuj; + public $localtax1_value; + public $localtax2_assuj; + public $localtax2_value; - var $managers; - var $capital; - var $typent_id; - var $typent_code; - var $effectif; - var $effectif_id; - var $forme_juridique_code; - var $forme_juridique; + public $managers; + public $capital; + public $typent_id=0; + public $typent_code; + public $effectif; + public $effectif_id=0; + public $forme_juridique_code; + public $forme_juridique=0; - var $remise_percent; - var $remise_supplier_percent; - var $mode_reglement_supplier_id; - var $cond_reglement_supplier_id; - var $fk_prospectlevel; - var $name_bis; + public $remise_percent; + public $remise_supplier_percent; + public $mode_reglement_supplier_id; + public $cond_reglement_supplier_id; + public $fk_prospectlevel; + public $name_bis; //Log data @@ -254,127 +254,127 @@ class Societe extends CommonObject * Date of last update * @var string */ - var $date_modification; + public $date_modification; /** * User that made last update * @var string */ - var $user_modification; + public $user_modification; /** * Date of creation * @var string */ - var $date_creation; + public $date_creation; /** * User that created the thirdparty * @var User */ - var $user_creation; + public $user_creation; - var $specimen; + public $specimen; /** * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * @var int */ - var $client; + public $client=0; /** * 0=no prospect, 1=prospect * @var int */ - var $prospect; + public $prospect=0; /** * 0=no supplier, 1=supplier * @var int */ - var $fournisseur; + public $fournisseur; /** * Client code. E.g: CU2014-003 * @var string */ - var $code_client; + public $code_client; /** * Supplier code. E.g: SU2014-003 * @var string */ - var $code_fournisseur; + public $code_fournisseur; /** * Accounting code for client * @var string */ - var $code_compta; + public $code_compta; /** * Accounting code for suppliers * @var string */ - var $code_compta_fournisseur; + public $code_compta_fournisseur; /** * @var string * @deprecated Note is split in public and private notes * @see note_public, note_private */ - var $note; + public $note; /** * Private note * @var string */ - var $note_private; + public $note_private; /** * Public note * @var string */ - var $note_public; + public $note_public; //! code statut prospect - var $stcomm_id; - var $statut_commercial; + public $stcomm_id; + public $statut_commercial; /** * Assigned price level * @var int */ - var $price_level; - var $outstanding_limit; + public $price_level; + public $outstanding_limit; /** * Min order amounts */ - var $order_min_amount; - var $supplier_order_min_amount; + public $order_min_amount; + public $supplier_order_min_amount; /** * Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives. * @var int */ - var $commercial_id; + public $commercial_id; /** * Id of parent thirdparty (if one) * @var int */ - var $parent; + public $parent; /** * Default language code of thirdparty (en_US, ...) * @var string */ - var $default_lang; + public $default_lang; - var $ref; - var $ref_int; + public $ref; + public $ref_int; /** * External user reference. * This is to allow external systems to store their id and make self-developed synchronizing functions easier to * build. * @var string */ - var $ref_ext; + public $ref_ext; /** * Import key. @@ -382,45 +382,39 @@ class Societe extends CommonObject * to an import process * @var string */ - var $import_key; + public $import_key; /** * Supplier WebServices URL * @var string */ - var $webservices_url; + public $webservices_url; /** * Supplier WebServices Key * @var string */ - var $webservices_key; + public $webservices_key; - var $logo; - var $logo_small; - var $logo_mini; + public $logo; + public $logo_small; + public $logo_mini; - var $array_options; + public $array_options; // Incoterms - var $fk_incoterms; - var $location_incoterms; - var $libelle_incoterms; //Used into tooltip + public $fk_incoterms; + public $location_incoterms; + public $libelle_incoterms; //Used into tooltip // Multicurrency - var $fk_multicurrency; - var $multicurrency_code; + public $fk_multicurrency; + public $multicurrency_code; // END MODULEBUILDER PROPERTIES - /** - * To contains a clone of this when we need to save old properties of object - * @var Societe - */ - var $oldcopy; - /** * Constructor * @@ -1972,7 +1966,7 @@ class Societe extends CommonObject if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips $name=$this->name?$this->name:$this->nom; - + if(!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)){ if(empty($option) && $this->client > 0) $option = 'customer'; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 17981be69b9..fbbbce0f9a8 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -191,18 +191,6 @@ class SupplierProposal extends CommonObject $this->remise = 0; $this->remise_percent = 0; $this->remise_absolue = 0; - - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); } @@ -2072,9 +2060,24 @@ class SupplierProposal extends CommonObject */ function LibStatut($statut,$mode=1) { - global $langs; - $langs->load("supplier_proposal"); + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelstatut_short[1]=$langs->trans("Opened"); + $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); + } + $statuttrans=''; if ($statut==0) $statuttrans='statut0'; if ($statut==1) $statuttrans='statut1'; if ($statut==2) $statuttrans='statut3'; From 912d5c53f2bb3d603cd557bd33af1c89c357e321 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 15:46:55 +0200 Subject: [PATCH 368/609] Standardize code --- htdocs/comm/propal/card.php | 7 ++- htdocs/comm/propal/class/propal.class.php | 12 ++-- .../class/bonprelevement.class.php | 60 +++++++++---------- htdocs/don/class/don.class.php | 30 ++++++---- htdocs/fichinter/class/fichinter.class.php | 57 +++++++++--------- htdocs/fichinter/list.php | 1 + htdocs/fichinter/stats/index.php | 1 + .../class/fournisseur.commande.class.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 26 +++----- htdocs/fourn/commande/dispatch.php | 4 +- htdocs/fourn/commande/index.php | 3 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/index.php | 7 +-- .../class/supplier_proposal.class.php | 11 ++-- 14 files changed, 108 insertions(+), 115 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 8be7fa249b8..004b32a83fc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1745,11 +1745,12 @@ if ($action == 'create') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->labelstatut [2],3=>$object->labelstatut [3])), - array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) + array('type' => 'select','name' => 'statut','label' => $langs->trans("CloseAs"),'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"),'value' => '') // Field to complete private note (not replace) ); - if (! empty($conf->notification->enabled)) { + if (! empty($conf->notification->enabled)) + { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); $formquestion = array_merge($formquestion, array( diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 9cdf621bef9..b6e9d1411c5 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -142,9 +142,9 @@ class Propal extends CommonObject public $cond_reglement_code; public $mode_reglement_code; - public $remise; - public $remise_percent; - public $remise_absolue; + public $remise = 0; + public $remise_percent = 0; + public $remise_absolue = 0; public $fk_address; public $address_type; public $address; @@ -198,6 +198,7 @@ class Propal extends CommonObject */ const STATUS_BILLED = 4; // Todo rename into STATUS_CLOSE ? + /** * Constructor * @@ -210,12 +211,11 @@ class Propal extends CommonObject global $conf,$langs; $this->db = $db; + $this->socid = $socid; $this->id = $propalid; + $this->products = array(); - $this->remise = 0; - $this->remise_percent = 0; - $this->remise_absolue = 0; $this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION; } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 57cf518db16..245b25be3b6 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -99,14 +99,6 @@ class BonPrelevement extends CommonObject $this->methodes_trans[0] = "Internet"; $this->_fetched = 0; - - - $langs->load("withdrawals"); - $this->labelstatut[0]=$langs->trans("StatusWaiting"); - $this->labelstatut[1]=$langs->trans("StatusTrans"); - $this->labelstatut[2]=$langs->trans("StatusCredited"); - - return 1; } /** @@ -1310,14 +1302,14 @@ class BonPrelevement extends CommonObject */ // SEPA Initialisation $CrLf = "\n"; - + $now = dol_now(); - + $dateTime_ECMA = dol_print_date($now, '%Y-%m-%dT%H:%M:%S'); $date_actu = $now; if (!empty($executiondate)) $date_actu=$executiondate; - + $dateTime_YMD = dol_print_date($date_actu, '%Y%m%d'); $dateTime_YMDHMS = dol_print_date($date_actu, '%Y%m%d%H%M%S'); $fileDebiteurSection = ''; @@ -1890,48 +1882,52 @@ class BonPrelevement extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + if (empty($this->labelstatut)) + { + global $langs; + $langs->load("withdrawals"); + $this->labelstatut[0]=$langs->trans("StatusWaiting"); + $this->labelstatut[1]=$langs->trans("StatusTrans"); + $this->labelstatut[2]=$langs->trans("StatusCredited"); + } if ($mode == 0) { - return $langs->trans($this->labelstatut[$statut]); + return $this->labelstatut[$statut]; } - if ($mode == 1) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + return $this->labelstatut[$statut]; } if ($mode == 2) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } if ($mode == 3) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6'); } if ($mode == 4) { - if ($statut==0) return img_picto($langs->trans($this->labelstatut[$statut]),'statut1').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==1) return img_picto($langs->trans($this->labelstatut[$statut]),'statut3').' '.$langs->trans($this->labelstatut[$statut]); - if ($statut==2) return img_picto($langs->trans($this->labelstatut[$statut]),'statut6').' '.$langs->trans($this->labelstatut[$statut]); + if ($statut==0) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut==1) return img_picto($this->labelstatut[$statut],'statut3').' '.$this->labelstatut[$statut]; + if ($statut==2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; } if ($mode == 5) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } if ($mode == 6) { - if ($statut==0) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut1'); - if ($statut==1) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut3'); - if ($statut==2) return $langs->trans($this->labelstatut[$statut]).' '.img_picto($langs->trans($this->labelstatut[$statut]),'statut6'); + if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut3'); + if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); } } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 4be83ffa30a..78e3a57f436 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -52,6 +52,10 @@ class Don extends CommonObject var $fk_typepayment; var $num_payment; var $date_valid; + var $modepaymentid = 0; + + var $labelstatut; + var $labelstatutshort; /** * @deprecated @@ -59,6 +63,7 @@ class Don extends CommonObject */ var $commentaire; + /** * Constructor * @@ -69,17 +74,6 @@ class Don extends CommonObject global $langs; $this->db = $db; - $this->modepaymentid = 0; - - $langs->load("donations"); - $this->labelstatut[-1]=$langs->trans("Canceled"); - $this->labelstatut[0]=$langs->trans("DonationStatusPromiseNotValidated"); - $this->labelstatut[1]=$langs->trans("DonationStatusPromiseValidated"); - $this->labelstatut[2]=$langs->trans("DonationStatusPaid"); - $this->labelstatutshort[-1]=$langs->trans("Canceled"); - $this->labelstatutshort[0]=$langs->trans("DonationStatusPromiseNotValidatedShort"); - $this->labelstatutshort[1]=$langs->trans("DonationStatusPromiseValidatedShort"); - $this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort"); } @@ -103,7 +97,19 @@ class Don extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + if (empty($this->labelstatut) || empty($this->labelstatushort)) + { + global $langs; + $langs->load("donations"); + $this->labelstatut[-1]=$langs->trans("Canceled"); + $this->labelstatut[0]=$langs->trans("DonationStatusPromiseNotValidated"); + $this->labelstatut[1]=$langs->trans("DonationStatusPromiseValidated"); + $this->labelstatut[2]=$langs->trans("DonationStatusPaid"); + $this->labelstatutshort[-1]=$langs->trans("Canceled"); + $this->labelstatutshort[0]=$langs->trans("DonationStatusPromiseNotValidatedShort"); + $this->labelstatutshort[1]=$langs->trans("DonationStatusPromiseValidatedShort"); + $this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort"); + } if ($mode == 0) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 9f596e61279..25f2e691265 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -55,9 +55,10 @@ class Fichinter extends CommonObject var $datet; var $datem; var $duration; - var $statut; // 0=draft, 1=validated, 2=invoiced, 3=Terminate + var $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate var $description; - var $fk_contrat; + var $fk_contrat = 0; + var $fk_project = 0; var $extraparams=array(); var $lines = array(); @@ -87,24 +88,8 @@ class Fichinter extends CommonObject function __construct($db) { $this->db = $db; - $this->products = array(); - $this->fk_project = 0; - $this->fk_contrat = 0; - $this->statut = 0; - // List of language codes for status - $this->statuts[0]='Draft'; - $this->statuts[1]='Validated'; - $this->statuts[2]='StatusInterInvoiced'; - $this->statuts[3]='Done'; - $this->statuts_short[0]='Draft'; - $this->statuts_short[1]='Validated'; - $this->statuts_short[2]='StatusInterInvoiced'; - $this->statuts_short[3]='Done'; - $this->statuts_logo[0]='statut0'; - $this->statuts_logo[1]='statut1'; - $this->statuts_logo[2]='statut6'; - $this->statuts_logo[3]='statut6'; + $this->products = array(); } /** @@ -634,22 +619,40 @@ class Fichinter extends CommonObject */ function LibStatut($statut,$mode=0) { - global $langs; + // Init/load array of translation of status + if (empty($this->statuts) || empty($this->statuts_short)) + { + global $langs; + $langs->load("fichinter"); + + $this->statuts[0]=$langs->trans('Draft'); + $this->statuts[1]=$langs->trans('Validated'); + $this->statuts[2]=$langs->trans('StatusInterInvoiced'); + $this->statuts[3]=$langs->trans('Done'); + $this->statuts_short[0]=$langs->trans('Draft'); + $this->statuts_short[1]=$langs->trans('Validated'); + $this->statuts_short[2]=$langs->trans('StatusInterInvoiced'); + $this->statuts_short[3]=$langs->trans('Done'); + $this->statuts_logo[0]='statut0'; + $this->statuts_logo[1]='statut1'; + $this->statuts_logo[2]='statut6'; + $this->statuts_logo[3]='statut6'; + } if ($mode == 0) - return $langs->trans($this->statuts[$statut]); + return $this->statuts[$statut]; if ($mode == 1) - return $langs->trans($this->statuts_short[$statut]); + return $this->statuts_short[$statut]; if ($mode == 2) - return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]).' '.$langs->trans($this->statuts_short[$statut]); + return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts_short[$statut]; if ($mode == 3) - return img_picto($langs->trans($this->statuts_short[$statut]), $this->statuts_logo[$statut]); + return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]); if ($mode == 4) - return img_picto($langs->trans($this->statuts_short[$statut]),$this->statuts_logo[$statut]).' '.$langs->trans($this->statuts[$statut]); + return img_picto($this->statuts_short[$statut], $this->statuts_logo[$statut]).' '.$this->statuts[$statut]; if ($mode == 5) - return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); + return ''.$this->statuts_short[$statut].' '.img_picto($this->statuts[$statut],$this->statuts_logo[$statut]); if ($mode == 6) - return ''.$langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); + return ''.$this->statuts[$statut].' '.img_picto($this->statuts[$statut],$this->statuts_logo[$statut]); return ''; } diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 025296c6b0d..9f4d14f0669 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -380,6 +380,7 @@ if ($resql) if (! empty($arrayfields['f.fk_statut']['checked'])) { print ''; + $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus=$objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 1c0ba5764ed..7f45be6a624 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -255,6 +255,7 @@ print '
'; print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); // Status print ''.$langs->trans("Status").''; + $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus=$objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 print $form->selectarray('object_status', $liststatus, $object_status, 1, 0, 0, '', 1); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4b795862e9b..676dd8d542c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -189,7 +189,7 @@ class CommandeFournisseur extends CommonOrder $this->db = $db; $this->products = array(); - // List of language codes for status + // TODO Move in LibStatut $this->statuts[0] = 'StatusOrderDraft'; $this->statuts[1] = 'StatusOrderValidated'; $this->statuts[2] = 'StatusOrderApproved'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 3f8fee2d5ad..7d8b09a17ce 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -89,16 +89,16 @@ class FactureFournisseur extends CommonInvoice public $tms; // Last update date public $date; // Invoice date public $date_echeance; // Max payment date - public $amount; - public $remise; - public $tva; + public $amount=0; + public $remise=0; + public $tva=0; public $localtax1; public $localtax2; - public $total_ht; - public $total_tva; - public $total_localtax1; - public $total_localtax2; - public $total_ttc; + public $total_ht=0; + public $total_tva=0; + public $total_localtax1=0; + public $total_localtax2=0; + public $total_ttc=0; /** * @deprecated * @see note_private, note_public @@ -202,16 +202,6 @@ class FactureFournisseur extends CommonInvoice { $this->db = $db; - $this->amount = 0; - $this->remise = 0; - $this->tva = 0; - $this->total_localtax1 = 0; - $this->total_localtax2 = 0; - $this->total_ht = 0; - $this->total_tva = 0; - $this->total_ttc = 0; - $this->propalid = 0; - $this->products = array(); } diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 837e32f9ff6..1e35af900e6 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -701,7 +701,7 @@ if ($id > 0 || ! empty($ref)) { if ($nbproduct) { - $checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv($object->statuts[5])); + $checkboxlabel=$langs->trans("CloseReceivedSupplierOrdersAutomatically", $langs->transnoentitiesnoconv('StatusOrderReceivedAll')); print '
'; print $langs->trans("Comment") . ' : '; @@ -844,7 +844,7 @@ if ($id > 0 || ! empty($ref)) { } // date print '' . dol_print_date($objp->datec) . ''; - + print "\n"; $i ++; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index ca395d0cf47..412f0c94b09 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -187,9 +187,8 @@ if ($resql) { $row = $db->fetch_row($resql); - print ''; - print ''.$langs->trans($commandestatic->statuts[$row[1]]).''; + print ''.$commandestatic->LibStatut($row[1]).''; print ''.$row[0].' '.$commandestatic->LibStatut($row[1],3).''; print "\n"; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index c2d60a73ea3..f0c5acdcf3e 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -472,7 +472,7 @@ if ($status) { if ($status == '1,2,3') $title.=' - '.$langs->trans("StatusOrderToProcessShort"); if ($status == '6,7') $title.=' - '.$langs->trans("StatusOrderCanceled"); - else $title.=' - '.$langs->trans($commandestatic->statuts[$status]); + else $title.=' - '.$commandestatic->LibStatut($status); } if ($search_billed > 0) $title.=' - '.$langs->trans("Billed"); diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index 8f34077ab34..e353739790d 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -57,7 +57,6 @@ print '
'; // Orders -$commande = new CommandeFournisseur($db); $sql = "SELECT count(cf.rowid), cf.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf,"; $sql.= " ".MAIN_DB_PREFIX."societe as s"; @@ -76,17 +75,15 @@ if ($resql) print ''; print ''; print "\n"; - $var=True; while ($i < $num) { $row = $db->fetch_row($resql); - print ''; - print ''; + print ''; print ''; - print ''; + print ''; print "\n"; $i++; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index fbbbce0f9a8..b88d24070c6 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -124,9 +124,9 @@ class SupplierProposal extends CommonObject var $cond_reglement_code; var $mode_reglement_code; - var $remise; - var $remise_percent; - var $remise_absolue; + var $remise = 0; + var $remise_percent = 0; + var $remise_absolue = 0; var $products=array(); var $extraparams=array(); @@ -185,12 +185,11 @@ class SupplierProposal extends CommonObject global $conf,$langs; $this->db = $db; + $this->socid = $socid; $this->id = $supplier_proposalid; + $this->products = array(); - $this->remise = 0; - $this->remise_percent = 0; - $this->remise_absolue = 0; } From 06e51703b1f9ff15cb5cc826080ce6cfff225644 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 16:01:05 +0200 Subject: [PATCH 369/609] Clean constructors --- .../class/fournisseur.commande.class.php | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 676dd8d542c..4bc5cdcc993 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -184,23 +184,9 @@ class CommandeFournisseur extends CommonOrder */ public function __construct($db) { - global $conf; - $this->db = $db; - $this->products = array(); - // TODO Move in LibStatut - $this->statuts[0] = 'StatusOrderDraft'; - $this->statuts[1] = 'StatusOrderValidated'; - $this->statuts[2] = 'StatusOrderApproved'; - if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess'; - else $this->statuts[3] = 'StatusOrderOnProcessWithValidation'; - $this->statuts[4] = 'StatusOrderReceivedPartially'; - $this->statuts[5] = 'StatusOrderReceivedAll'; - $this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled - $this->statuts[7] = 'StatusOrderCanceled'; // Process running->canceled - //$this->statuts[8] = 'StatusOrderBilled'; // Everything is finished, order received totally and bill received - $this->statuts[9] = 'StatusOrderRefused'; + $this->products = array(); } @@ -587,24 +573,41 @@ class CommandeFournisseur extends CommonOrder */ function LibStatut($statut,$mode=0,$billed=0) { - global $langs; - $langs->load('orders'); + if (empty($this->statuts) || empty($statutshort)) + { + global $langs; + $langs->load('orders'); + + $this->statuts[0] = 'StatusOrderDraft'; + $this->statuts[1] = 'StatusOrderValidated'; + $this->statuts[2] = 'StatusOrderApproved'; + if (empty($conf->global->SUPPLIER_ORDER_USE_DISPATCH_STATUS)) $this->statuts[3] = 'StatusOrderOnProcess'; + else $this->statuts[3] = 'StatusOrderOnProcessWithValidation'; + $this->statuts[4] = 'StatusOrderReceivedPartially'; + $this->statuts[5] = 'StatusOrderReceivedAll'; + $this->statuts[6] = 'StatusOrderCanceled'; // Approved->Canceled + $this->statuts[7] = 'StatusOrderCanceled'; // Process running->canceled + //$this->statuts[8] = 'StatusOrderBilled'; // Everything is finished, order received totally and bill received + $this->statuts[9] = 'StatusOrderRefused'; + + // List of language codes for status + $statutshort[0] = 'StatusOrderDraftShort'; + $statutshort[1] = 'StatusOrderValidatedShort'; + $statutshort[2] = 'StatusOrderApprovedShort'; + $statutshort[3] = 'StatusOrderOnProcessShort'; + $statutshort[4] = 'StatusOrderReceivedPartiallyShort'; + $statutshort[5] = 'StatusOrderReceivedAllShort'; + $statutshort[6] = 'StatusOrderCanceledShort'; + $statutshort[7] = 'StatusOrderCanceledShort'; + $statutshort[9] = 'StatusOrderRefusedShort'; + } + + $langs->load('orders'); $billedtext=''; //if ($statut==5 && $this->billed == 1) $statut = 8; if ($billed == 1) $billedtext=$langs->trans("Billed"); - // List of language codes for status - $statutshort[0] = 'StatusOrderDraftShort'; - $statutshort[1] = 'StatusOrderValidatedShort'; - $statutshort[2] = 'StatusOrderApprovedShort'; - $statutshort[3] = 'StatusOrderOnProcessShort'; - $statutshort[4] = 'StatusOrderReceivedPartiallyShort'; - $statutshort[5] = 'StatusOrderReceivedAllShort'; - $statutshort[6] = 'StatusOrderCanceledShort'; - $statutshort[7] = 'StatusOrderCanceledShort'; - $statutshort[9] = 'StatusOrderRefusedShort'; - if ($mode == 0) { return $langs->trans($this->statuts[$statut]); From a0152f8e7a7eae142de26dbe9cfad27c5d02850e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 21 Apr 2018 16:07:40 +0200 Subject: [PATCH 370/609] Better template --- .../template/class/myobject.class.php | 49 ++++++++++--------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index b6aa06cb273..9815d664ae3 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -335,62 +335,65 @@ class MyObject extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ function getLibStatut($mode=0) { - return $this->LibStatut($this->status,$mode); + return $this->LibStatut($this->status, $mode); } /** * Return the status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ - static function LibStatut($status,$mode=0) + static function LibStatut($status, $mode=0) { - global $langs; + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } if ($mode == 0) { - $prefix=''; - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + return $this->labelstatus[$status]; } if ($mode == 1) { - if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + return $this->labelstatus[$status]; } if ($mode == 2) { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; + if ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; } if ($mode == 3) { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4'); + if ($status == 0) return img_picto($this->labelstatus[$status],'statut5'); } if ($mode == 4) { - if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + if ($status == 1) return img_picto($this->labelstatus[$status],'statut4').' '.$this->labelstatus[$status]; + if ($status == 0) return img_picto($this->labelstatus[$status],'statut5').' '.$this->labelstatus[$status]; } if ($mode == 5) { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); + if ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); } if ($mode == 6) { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut4'); + if ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status],'statut5'); } } From d8e7c98a8dff7b816adb17c61bf68823d1309911 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 22 Apr 2018 05:56:31 +0200 Subject: [PATCH 371/609] Add nature "inventory" & hide in ventilation journal --- htdocs/core/menus/standard/eldy.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d66f916bb78..e3a2ca4515d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1059,12 +1059,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($objp->nature == 4 && ! empty($conf->banque->enabled)) $nature="bank"; if ($objp->nature == 5 && ! empty($conf->expensereport->enabled)) $nature="expensereports"; if ($objp->nature == 1) $nature="various"; + if ($objp->nature == 8) $nature="inventory"; if ($objp->nature == 9) $nature="hasnew"; // To enable when page exists if ($conf->global->MAIN_FEATURES_LEVEL < 2) { - if ($nature == 'various' || $nature == 'hasnew') $nature=''; + if ($nature == 'various' || $nature == 'hasnew' || $nature == 'inventory') $nature=''; } if ($nature) From 034f7d56e4d147f66c5a130909e48019d6b2e6f0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 22 Apr 2018 06:49:04 +0200 Subject: [PATCH 372/609] Invert credit debit --- htdocs/accountancy/bookkeeping/card.php | 2 +- htdocs/langs/en_US/accountancy.lang | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 51829c004f1..f0cc48a4878 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -694,7 +694,7 @@ if ($action == 'create') } else { - print ''; + print ''; } print '   '; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 876e6b37837..83be8d8e423 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -216,7 +216,7 @@ ValidateHistory=Bind Automatically AutomaticBindingDone=Automatic binding done ErrorAccountancyCodeIsAlreadyUse=Error, you cannot delete this accounting account because it is used -MvtNotCorrectlyBalanced=Movement not correctly balanced. Credit = %s. Debit = %s +MvtNotCorrectlyBalanced=Movement not correctly balanced. Debit = %s | Credit = %s FicheVentilation=Binding card GeneralLedgerIsWritten=Transactions are written in the Ledger GeneralLedgerSomeRecordWasNotRecorded=Some of the transactions could not be journalized. If there is no other error message, this is probably because they were already journalized. From d37df8e0b5a7dc3dedcdb3968d11d9bb572e45a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 09:21:30 +0200 Subject: [PATCH 373/609] Try travis without dist: precise --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff1b30f06e0..fb1c6660673 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: precise to have php 5.3 available -dist: precise +#dist: precise sudo: required language: php From 05f4e3c68e486308c11ceb9538ee95cb7a7fb687 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 22 Apr 2018 11:14:01 +0200 Subject: [PATCH 374/609] update code --- htdocs/contrat/admin/contract_extrafields.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index 3fb55acc2ca..a33d020d74d 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -4,7 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * * 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 @@ -31,9 +31,8 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -$langs->load("companies"); -$langs->load("admin"); -$langs->load("contracts"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies","admin","contracts")); $extrafields = new ExtraFields($db); $form = new Form($db); From 769a1f507b26bedb1c9e5e2f769f5f0038f45a6a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 11:26:59 +0200 Subject: [PATCH 375/609] Debug asset module --- htdocs/admin/menus.php | 6 +----- htdocs/assets/admin/assets_extrafields.php | 2 +- htdocs/assets/admin/assets_type_extrafields.php | 2 +- htdocs/assets/admin/setup.php | 5 +---- htdocs/core/menus/init_menu_auguria.sql | 10 +++++----- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 5e0b6fac6f6..7ffaa9a110a 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -30,11 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $action=GETPOST('action','aZ09'); $cancel=GETPOST('cancel','alpha'); -$langs->load("companies"); -$langs->load("products"); -$langs->load("admin"); -$langs->load("users"); -$langs->load("other"); +$langs->loadLangs(array("companies","products","admin","users","other")); // Security check if (! $user->admin) accessforbidden(); diff --git a/htdocs/assets/admin/assets_extrafields.php b/htdocs/assets/admin/assets_extrafields.php index 85c596b6e37..426da1c239f 100644 --- a/htdocs/assets/admin/assets_extrafields.php +++ b/htdocs/assets/admin/assets_extrafields.php @@ -65,7 +65,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); $head = AssetsAdminPrepareHead(); -dol_fiche_head($head, 'attributes', $langs->trans("Assets"), 0, 'generic'); +dol_fiche_head($head, 'attributes', $langs->trans("Assets"), -1, 'generic'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/assets/admin/assets_type_extrafields.php b/htdocs/assets/admin/assets_type_extrafields.php index 8d136ed1278..62878c9d8b5 100644 --- a/htdocs/assets/admin/assets_type_extrafields.php +++ b/htdocs/assets/admin/assets_type_extrafields.php @@ -66,7 +66,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); $head = AssetsAdminPrepareHead(); -dol_fiche_head($head, 'attributes_type', $langs->trans("Assets"), 0, 'generic'); +dol_fiche_head($head, 'attributes_type', $langs->trans("Assets"), -1, 'generic'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/assets/admin/setup.php b/htdocs/assets/admin/setup.php index 19de7b3b752..8708396fb7f 100644 --- a/htdocs/assets/admin/setup.php +++ b/htdocs/assets/admin/setup.php @@ -60,10 +60,7 @@ print load_fiche_titre($langs->trans("AssetsSetup"),$linkback,'title_setup'); $head = AssetsAdminPrepareHead(); -dol_fiche_head($head, 'settings', $langs->trans("Assets"), 0, 'generic'); - -// Setup page goes here -echo $langs->trans("AssetsSetupPage"); +dol_fiche_head($head, 'settings', $langs->trans("Assets"), -1, 'generic'); if ($action == 'edit') diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 807bd3f0125..a1ea9088dc7 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -14,7 +14,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('propal|commande|fournisseur|contrat|ficheinter', '$conf->propal->enabled || $conf->commande->enabled || $conf->supplier_order->enabled || $conf->contrat->enabled || $conf->ficheinter->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 40, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('facture|don|tax|salaries|loan|banque', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->supplier_invoice->enabled || $conf->loan->enabled || $conf->banque->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'billing', '', 0, '/compta/index.php?mainmenu=billing&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->facture->lire|| $user->rights->don->lire || $user->rights->tax->charges->lire || $user->rights->salaries->read || $user->rights->loan->read || $user->rights->banque->lire', '', 2, 50, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('banque|prelevement', '$conf->banque->enabled || $conf->prelevement->enabled', 14__+MAX_llx_menu__, __HANDLER__, 'top', 'bank', '', 0, '/compta/bank/list.php?mainmenu=bank&leftmenu=bank', 'MenuBankCash', -1, 'banks', '$user->rights->banque->lire || $user->rights->prelevement->bons->lire', '', 0, 52, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|assets', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->assets->enabled || $conf->facture->enabled || $conf->don->enabled || $conf->tax->enabled || $conf->salaries->enabled || $conf->supplier_invoice->enabled || $conf->loan->enabled || $conf->banque->enabled', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'Accountancy', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->assets->read', '', 2, 54, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('comptabilite|accounting|assets', '$conf->comptabilite->enabled || $conf->accounting->enabled || $conf->accounting->assets', 9__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=accountancy', 'Accountancy', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->mouvements->lire || $user->rights->assets->read', '', 2, 54, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__); @@ -276,10 +276,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2715__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyuser.php?leftmenu=ca', 'ByUsers', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->comptabilite->enabled && $leftmenu=="ca"', __HANDLER__, 'left', 2716__+MAX_llx_menu__, 'accountancy', '', 2703__+MAX_llx_menu__, '/compta/stats/cabyprodserv.php?leftmenu=ca', 'ByProductsAndServices', 2, 'main', '$user->rights->compta->resultat->lire || $user->rights->accounting->comptarapport->lire', '', 0, 1, __ENTITY__); -- Assets -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled', __HANDLER__, 'left', 2800__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuAssets', 0, 'assets', '$user->rights->assets->read', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2801__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuNewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/type.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuTypeAssets', 1, 'assets', '$user->rights->assets->write', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'accountancy', '', 2800__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuListAssets', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled', __HANDLER__, 'left', 3000__+MAX_llx_menu__, 'accountancy', 'assets', 10__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuAssets', 0, 'assets', '$user->rights->assets->read', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 3001__+MAX_llx_menu__, 'accountancy', '', 3000__+MAX_llx_menu__, '/assets/card.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuNewAsset', 1, 'assets', '$user->rights->assets->write', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 3002__+MAX_llx_menu__, 'accountancy', '', 3000__+MAX_llx_menu__, '/assets/type.php?leftmenu=assets&mainmenu=accountancy&action=create', 'MenuTypeAssets', 1, 'assets', '$user->rights->assets->write', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->assets->enabled && $leftmenu=="assets"', __HANDLER__, 'left', 3003__+MAX_llx_menu__, 'accountancy', '', 3000__+MAX_llx_menu__, '/assets/list.php?leftmenu=assets&mainmenu=accountancy', 'MenuListAssets', 1, 'assets', '$user->rights->assets->read', '', 2, 1, __ENTITY__); -- Check deposit insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=bank', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1712__+MAX_llx_menu__, 'accountancy', '', 1711__+MAX_llx_menu__, '/compta/paiement/cheque/card.php?leftmenu=checks&action=new', 'NewCheckDeposit', 1, 'compta', '$user->rights->banque->lire', '', 2, 0, __ENTITY__); From f83369d268b36a26d630b4b39134e0bf906cadb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 11:27:26 +0200 Subject: [PATCH 376/609] Remove travis warnings --- htdocs/core/modules/modAgenda.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index f6577463208..8108c8ef66b 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -245,7 +245,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'Agenda', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.($conf->global->AGENDA_DEFAULT_VIEW!='show_list'?$conf->global->AGENDA_DEFAULT_VIEW:'show_month').'&mainmenu=agenda&leftmenu=agenda', + 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>140, 'perms'=>'$user->rights->agenda->myactions->read', @@ -257,7 +257,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuToDoMyActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.($conf->global->AGENDA_DEFAULT_VIEW!='show_list'?$conf->global->AGENDA_DEFAULT_VIEW:'show_month').'&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', + 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', 'langs'=>'agenda', 'position'=>141, 'perms'=>'$user->rights->agenda->myactions->read', @@ -269,7 +269,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuDoneMyActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.($conf->global->AGENDA_DEFAULT_VIEW!='show_list'?$conf->global->AGENDA_DEFAULT_VIEW:'show_month').'&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', + 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', 'langs'=>'agenda', 'position'=>142, 'perms'=>'$user->rights->agenda->myactions->read', @@ -281,7 +281,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuToDoActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.($conf->global->AGENDA_DEFAULT_VIEW!='show_list'?$conf->global->AGENDA_DEFAULT_VIEW:'show_month').'&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', + 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', 'langs'=>'agenda', 'position'=>143, 'perms'=>'$user->rights->agenda->allactions->read', @@ -293,7 +293,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuDoneActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.($conf->global->AGENDA_DEFAULT_VIEW!='show_list'?$conf->global->AGENDA_DEFAULT_VIEW:'show_month').'&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', + 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', 'langs'=>'agenda', 'position'=>144, 'perms'=>'$user->rights->agenda->allactions->read', From fc7c9adec643277b3305a6bce5639b8b73214a21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 11:32:05 +0200 Subject: [PATCH 377/609] Test travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fb1c6660673..b26366b945f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -268,6 +268,7 @@ script: # Ensure we catch errors set -e wget http://127.0.0.1 + cat index.html if [ "$DEBUG" = true ]; then cat index.html fi From 338bf9b05cce5dfe5dba4034dd85fb1163135108 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 11:47:15 +0200 Subject: [PATCH 378/609] Show travis test of server --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b26366b945f..79ee103521b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: precise to have php 5.3 available -#dist: precise +dist: precise sudo: required language: php @@ -264,14 +264,14 @@ before_script: script: - | - echo "Checking webserver availability" + echo "Checking webserver availability by a wget -O - http://127.0.0.1" # Ensure we catch errors set -e - wget http://127.0.0.1 - cat index.html - if [ "$DEBUG" = true ]; then - cat index.html - fi + wget -O - http://127.0.0.1 > test.html + head test.html + echo "Checking webserver availability by a wget -O - http://127.0.0.1/index.php" + wget -O - http://127.0.0.1/index.php > test.php + head test.php set +e echo From 06cbc191038ebbf0720d568c289017699e43c6f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 12:10:53 +0200 Subject: [PATCH 379/609] Add meta generator in install pages --- .travis.yml | 6 ++++++ htdocs/install/inc.php | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 79ee103521b..c921547b82e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -269,7 +269,13 @@ script: set -e wget -O - http://127.0.0.1 > test.html head test.html + set +e + echo + +- | echo "Checking webserver availability by a wget -O - http://127.0.0.1/index.php" + # Ensure we catch errors + set -e wget -O - http://127.0.0.1/index.php > test.php head test.php set +e diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index d821ad2b454..7c2895eb835 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -391,8 +391,9 @@ function pHeader($subtitle,$next,$action='set',$param='',$forcejqueryurl='',$css print ''."\n"; print ''."\n"; print ''."\n"; - print ''."\n"; + print ''."\n"; print ''."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; From 6394996cd5ef7dea162433724dae16159ee405cd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 12:37:01 +0200 Subject: [PATCH 380/609] Try to use Trusty --- .travis.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index c921547b82e..15ccc7de16b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: precise to have php 5.3 available -dist: precise +dist: trusty sudo: required language: php @@ -267,20 +267,12 @@ script: echo "Checking webserver availability by a wget -O - http://127.0.0.1" # Ensure we catch errors set -e + # The wget should return a page with line ' wget -O - http://127.0.0.1 > test.html head test.html set +e echo -- | - echo "Checking webserver availability by a wget -O - http://127.0.0.1/index.php" - # Ensure we catch errors - set -e - wget -O - http://127.0.0.1/index.php > test.php - head test.php - set +e - echo - - | echo "Checking PHP syntax errors" # Ensure we catch errors From 1a8fbb9700ca641aa885144348826f6649be248c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 12:55:09 +0200 Subject: [PATCH 381/609] Show apache default file --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 15ccc7de16b..4fadf37ae43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -256,9 +256,7 @@ before_script: # configure apache virtual hosts sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default - if [ "$DEBUG" = true ]; then - sudo cat /etc/apache2/sites-available/default - fi + sudo cat /etc/apache2/sites-available/default sudo service apache2 restart echo From 49fcd70c5b12835541bb8e2523fe18a1b5ff1da6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 13:15:35 +0200 Subject: [PATCH 382/609] Try fix travis --- build/travis-ci/apache.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/travis-ci/apache.conf b/build/travis-ci/apache.conf index 5ba713924f2..a74e1f16124 100644 --- a/build/travis-ci/apache.conf +++ b/build/travis-ci/apache.conf @@ -9,10 +9,10 @@ # Wire up Apache to use Travis CI's php-fpm. - - AddHandler php5-fcgi .php - Action php5-fcgi /php5-fcgi - Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi - FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization - + # + # AddHandler php5-fcgi .php + # Action php5-fcgi /php5-fcgi + # Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi + # FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization + # From 6efb9f0ae028b9c30baa8743ea3c14ce4c3b4d04 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 13:38:09 +0200 Subject: [PATCH 383/609] Back to travis ok --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4fadf37ae43..c99086552c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: precise to have php 5.3 available -dist: trusty +dist: precise sudo: required language: php From 46e448a08688ebc1b2aa577d689cdad0424bea43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 17:57:20 +0200 Subject: [PATCH 384/609] Fix default agenda view --- htdocs/comm/action/index.php | 11 +++++++---- htdocs/core/modules/modAgenda.class.php | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 621230bf058..0fedb83d524 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Eric Seigne - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2014 Cedric GROSS @@ -85,8 +85,8 @@ $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $day=GETPOST("day","int")?GETPOST("day","int"):0; $pid=GETPOST("projectid","int",3); -$status=GETPOST("status"); -$type=GETPOST("type"); +$status=GETPOST("status",'aZ09'); // status may be 0, 50, 100, 'todo' +$type=GETPOST("type",'az09'); $maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('actioncode','array')) @@ -102,7 +102,10 @@ if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->glob if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); - +if ($action == 'default') +{ + $action = ((! empty($conf->global->AGENDA_DEFAULT_VIEW) && $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month'); +} if (GETPOST('viewcal') && $action != 'show_day' && $action != 'show_week') { $action='show_month'; $day=''; } // View by month diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 8108c8ef66b..5078f81ad05 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -245,7 +245,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'Agenda', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda', 'langs'=>'agenda', 'position'=>140, 'perms'=>'$user->rights->agenda->myactions->read', @@ -257,7 +257,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuToDoMyActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filter=mine', 'langs'=>'agenda', 'position'=>141, 'perms'=>'$user->rights->agenda->myactions->read', @@ -269,7 +269,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuDoneMyActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filter=mine', 'langs'=>'agenda', 'position'=>142, 'perms'=>'$user->rights->agenda->myactions->read', @@ -281,7 +281,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuToDoActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=todo&filtert=-1', 'langs'=>'agenda', 'position'=>143, 'perms'=>'$user->rights->agenda->allactions->read', @@ -293,7 +293,7 @@ class modAgenda extends DolibarrModules 'type'=>'left', 'titre'=>'MenuDoneActions', 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php?action='.((empty($conf->global->AGENDA_DEFAULT_VIEW) || $conf->global->AGENDA_DEFAULT_VIEW!='show_list') ? $conf->global->AGENDA_DEFAULT_VIEW : 'show_month').'&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', + 'url'=>'/comm/action/index.php?action=default&mainmenu=agenda&leftmenu=agenda&status=done&filtert=-1', 'langs'=>'agenda', 'position'=>144, 'perms'=>'$user->rights->agenda->allactions->read', From 7f8f55a54b3cb44d8a408976e3ed1675853cdf41 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 18:12:19 +0200 Subject: [PATCH 385/609] Show version in travis settings --- .travis.yml | 38 +++++++++++++++++-------------- dev/setup/codesniffer/ruleset.xml | 8 +++---- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index c99086552c6..7c0d782280f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -173,22 +173,27 @@ before_script: echo - | - if [ "$DEBUG" = true ]; then - echo "Debugging informations" - # Check PHP - php -i - # Check PHP CodeSniffer installation - which phpcs - phpcs --version - phpcs -i - # Check PHPUnit installation - which phpunit - phpunit --version - # Check MySQL - mysql --version - mysql -e "SELECT VERSION();" - echo - fi + echo "Versions information" + # Check PHP + echo "PHP version" + php -i | head - + # Check PHP CodeSniffer installation + echo "PHPCS version" + which phpcs + phpcs --version | head - + phpcs -i | head - + # Check PHPUnit installation + echo "PHPUnit version" + which phpunit + phpunit --version | head - + # Check Apache version + echo "Apache version" + apache2 -v | head - + # Check MariaDb + echo "MariaDb version" + mysql --version | head - + mysql -e "SELECT VERSION();" | head - + echo - | echo "Setting up database" @@ -335,7 +340,6 @@ script: - | echo "Unit testing" - phpunit --version # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. set -e phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index e5485b280ae..5e2337fd67e 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -138,9 +138,7 @@ - - 0 - + @@ -156,8 +154,8 @@ - - + + From 58fa42b3470020845edef08968db08eafc798892 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 18:34:33 +0200 Subject: [PATCH 386/609] Try to use trusty fro travis --- .travis.yml | 23 +++++++++++++++++++++-- build/travis-ci/apache.conf | 21 ++++++++++++--------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c0d782280f..bb47d26088e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: precise to have php 5.3 available -dist: precise +dist: trusty sudo: required language: php @@ -140,7 +140,8 @@ install: echo "Adding path of binaries tools installed by composer to the PATH" export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" echo - + + before_script: - | @@ -149,6 +150,22 @@ before_script: echo Home dir is `echo ~` echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR + +- sudo apt-get update +- sudo apt-get install apache2 libapache2-mod-fastcgi +# enable php-fpm +- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf +- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf +- sudo a2enmod rewrite actions fastcgi alias +- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini +- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars +- sudo chown -R travis:travis /var/lib/apache2/fastcgi +- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm +# configure apache virtual hosts +- sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf +- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf +- sudo service apache2 restart + - | echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" phpenv config-add /tmp/xdebug.ini @@ -265,6 +282,8 @@ before_script: sudo service apache2 restart echo + + script: - | echo "Checking webserver availability by a wget -O - http://127.0.0.1" diff --git a/build/travis-ci/apache.conf b/build/travis-ci/apache.conf index a74e1f16124..a4965c40d68 100644 --- a/build/travis-ci/apache.conf +++ b/build/travis-ci/apache.conf @@ -1,18 +1,21 @@ DocumentRoot %TRAVIS_BUILD_DIR%/htdocs - + Options FollowSymLinks MultiViews ExecCGI AllowOverride All - Order deny,allow - Allow from all + Require all granted # Wire up Apache to use Travis CI's php-fpm. - # - # AddHandler php5-fcgi .php - # Action php5-fcgi /php5-fcgi - # Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi - # FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization - # + + AddHandler php5-fcgi .php + Action php5-fcgi /php5-fcgi + Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi + FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization + + + Require all granted + + From 21add1c10b3c755557e32b76366073c97b555a4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 18:43:28 +0200 Subject: [PATCH 387/609] Try to use trusty fro travis --- .travis.yml | 266 ++++++++++++++++++++++++++-------------------------- 1 file changed, 133 insertions(+), 133 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb47d26088e..a5d9ad84323 100644 --- a/.travis.yml +++ b/.travis.yml @@ -144,143 +144,143 @@ install: before_script: -- | - echo Start travis - echo Current dir is `pwd` - echo Home dir is `echo ~` - echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR + - | + echo Start travis + echo Current dir is `pwd` + echo Home dir is `echo ~` + echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR -- sudo apt-get update -- sudo apt-get install apache2 libapache2-mod-fastcgi -# enable php-fpm -- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf -- sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf -- sudo a2enmod rewrite actions fastcgi alias -- echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini -- sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars -- sudo chown -R travis:travis /var/lib/apache2/fastcgi -- ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm -# configure apache virtual hosts -- sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf -- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf -- sudo service apache2 restart - -- | - echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" - phpenv config-add /tmp/xdebug.ini - echo - -- | - echo "Setting up PHP" - echo - echo "Set timezone" - echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - if [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then - #echo - #echo "Enabling APC for PHP <= 5.4" - # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6! - #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - echo - echo "Enabling Memcached for PHP <= 5.4" - # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly! - echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - fi - phpenv rehash - echo - -- | - echo "Versions information" - # Check PHP - echo "PHP version" - php -i | head - - # Check PHP CodeSniffer installation - echo "PHPCS version" - which phpcs - phpcs --version | head - - phpcs -i | head - - # Check PHPUnit installation - echo "PHPUnit version" - which phpunit - phpunit --version | head - - # Check Apache version - echo "Apache version" - apache2 -v | head - - # Check MariaDb - echo "MariaDb version" - mysql --version | head - - mysql -e "SELECT VERSION();" | head - - echo - -- | - echo "Setting up database" - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then - echo "MySQL" - mysql -e 'DROP DATABASE IF EXISTS travis;' - mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' - mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' - mysql -e 'FLUSH PRIVILEGES;' - mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - fi - if [ "$DB" = 'postgresql' ]; then - #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr - pgloader mysql://root@127.0.0.1/travis postgresql:///travis - fi - # TODO: SQLite - echo - -- | - export CONF_FILE=htdocs/conf/conf.php - echo "Setting up Dolibarr $CONF_FILE" - echo ' $CONF_FILE - echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE - echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE - echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE - echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE - echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE - echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then - echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE - fi - if [ "$DB" = 'postgresql' ]; then - echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE - fi - # TODO: SQLite - echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE - cat $CONF_FILE - echo - -- | - echo "Create documents directory and set permissions" - # and admin/temp subdirectory needed for unit tests - mkdir -p documents/admin/temp - echo "first line" > documents/dolibarr.log - echo - -- | - echo "Setting up Apache + FPM" + - sudo apt-get update + - sudo apt-get install apache2 libapache2-mod-fastcgi # enable php-fpm - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - # Copy the included pool - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf - fi - if [ "$DEBUG" = true ]; then - cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - fi - sudo a2enmod rewrite actions fastcgi alias - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - if [ "$DEBUG" = true ]; then - cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - fi - ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm + - sudo cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf + - sudo cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf + - sudo a2enmod rewrite actions fastcgi alias + - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars + - sudo chown -R travis:travis /var/lib/apache2/fastcgi + - ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm # configure apache virtual hosts - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default - sudo cat /etc/apache2/sites-available/default - sudo service apache2 restart - echo + - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf + - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf + - sudo service apache2 restart + + - | + echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" + phpenv config-add /tmp/xdebug.ini + echo + + - | + echo "Setting up PHP" + echo + echo "Set timezone" + echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + if [ "$TRAVIS_PHP_VERSION" = '5.4' ]; then + #echo + #echo "Enabling APC for PHP <= 5.4" + # Documentation says it should be available for PHP <= 5.6 but it's not for 5.5 and 5.6! + #echo 'extension = apc.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + echo + echo "Enabling Memcached for PHP <= 5.4" + # Documentation says it should be available for all PHP versions but it's not for 5.5 and 5.6, 7.0, 7.1, 7.2 and nightly! + echo 'extension = memcached.so' >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + fi + phpenv rehash + echo + + - | + echo "Versions information" + # Check PHP + echo "PHP version" + php -i | head - + # Check PHP CodeSniffer installation + echo "PHPCS version" + which phpcs + phpcs --version | head - + phpcs -i | head - + # Check PHPUnit installation + echo "PHPUnit version" + which phpunit + phpunit --version | head - + # Check Apache version + echo "Apache version" + apache2 -v | head - + # Check MariaDb + echo "MariaDb version" + mysql --version | head - + mysql -e "SELECT VERSION();" | head - + echo + + - | + echo "Setting up database" + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then + echo "MySQL" + mysql -e 'DROP DATABASE IF EXISTS travis;' + mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql -e 'FLUSH PRIVILEGES;' + mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + fi + if [ "$DB" = 'postgresql' ]; then + #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + pgloader mysql://root@127.0.0.1/travis postgresql:///travis + fi + # TODO: SQLite + echo + + - | + export CONF_FILE=htdocs/conf/conf.php + echo "Setting up Dolibarr $CONF_FILE" + echo ' $CONF_FILE + echo '$'dolibarr_main_url_root=\'http://127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_document_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $CONF_FILE + echo '$'dolibarr_main_data_root=\'$TRAVIS_BUILD_DIR/documents\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_host=\'127.0.0.1\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_name=\'travis\'';' >> $CONF_FILE + echo '$'dolibarr_main_db_user=\'travis\'';' >> $CONF_FILE + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then + echo '$'dolibarr_main_db_type=\'mysqli\'';' >> $CONF_FILE + fi + if [ "$DB" = 'postgresql' ]; then + echo '$'dolibarr_main_db_type=\'pgsql\'';' >> $CONF_FILE + fi + # TODO: SQLite + echo '$'dolibarr_main_authentication=\'dolibarr\'';' >> $CONF_FILE + cat $CONF_FILE + echo + + - | + echo "Create documents directory and set permissions" + # and admin/temp subdirectory needed for unit tests + mkdir -p documents/admin/temp + echo "first line" > documents/dolibarr.log + echo + + - | + echo "Setting up Apache + FPM" + # enable php-fpm + cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + # Copy the included pool + cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf + fi + if [ "$DEBUG" = true ]; then + cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf + fi + sudo a2enmod rewrite actions fastcgi alias + echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + if [ "$DEBUG" = true ]; then + cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini + fi + ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm + # configure apache virtual hosts + sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default + sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default + sudo cat /etc/apache2/sites-available/default + sudo service apache2 restart + echo From fec9303d18532c6bd60dcc0531217c23d706888f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 18:51:03 +0200 Subject: [PATCH 388/609] Remove useless $var --- htdocs/compta/prelevement/demandes.php | 2 -- htdocs/compta/prelevement/index.php | 3 --- htdocs/compta/stats/index.php | 2 -- htdocs/core/modules/printing/printgcp.modules.php | 5 ++--- htdocs/core/modules/printing/printipp.modules.php | 5 ++--- htdocs/don/index.php | 3 --- htdocs/expensereport/payment/card.php | 8 +++----- htdocs/fourn/card.php | 8 +------- htdocs/fourn/commande/index.php | 14 ++------------ htdocs/fourn/commande/orderstoinvoice.php | 7 +++---- htdocs/fourn/index.php | 13 +++---------- htdocs/product/stats/commande_fournisseur.php | 5 ++--- htdocs/product/stats/facture_fournisseur.php | 1 - htdocs/product/stats/propal.php | 4 +--- htdocs/product/stats/supplier_proposal.php | 4 +--- htdocs/societe/price.php | 8 ++------ htdocs/supplier_proposal/index.php | 5 +---- 17 files changed, 23 insertions(+), 74 deletions(-) diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 04ec746d7f6..765e0cf4fa8 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -129,8 +129,6 @@ if ($resql) print ''; print ''; - $var = True; - $users = array(); while ($i < min($num,$limit)) diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index 271ce4da7fe..64e1991064d 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -71,7 +71,6 @@ print '
'; $thirdpartystatic=new Societe($db); $invoicestatic=new Facture($db); $bprev = new BonPrelevement($db); -$var=true; print '
'.$langs->trans("Orders").''.$langs->trans("Nb").' 
'.$langs->trans($commande->statuts[$row[1]]).''.$commandestatic->LibStatut($row[1]).''.$row[0].''.$commande->LibStatut($row[1],3).''.$commandestatic->LibStatut($row[1],3).'
'; print ''; @@ -117,7 +116,6 @@ if ($resql) print ''; if ($num) { - $var = True; while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); @@ -184,7 +182,6 @@ if ($result) { $num = $db->num_rows($result); $i = 0; - $var=True; print"\n\n"; print '
'.$langs->trans("Statistics").'
'.$langs->trans("InvoiceWaitingWithdraw").' ('.$num.')
'; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 598de2ba490..a4c32302a47 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -551,7 +551,6 @@ print ''; if ($num) { - $var = True; $total_ttc_Rac = $totalam_Rac = $total_Rac = 0; while ($i < $num) { @@ -602,7 +601,6 @@ print ''; if ($num) { - $var = True; $total_pr = 0; while ($i < $num) { diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 6e007b22b55..d2db656a6f2 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -461,15 +461,14 @@ class printing_printgcp extends PrintingDriver $html .= ''; $html .= ''; $html .= ''."\n"; - $var = True; + $jobs = $responsedata['jobs']; //$html .= '
'.print_r($jobs['0'],true).'
'; if (is_array($jobs)) { foreach ($jobs as $value) { - $var = !$var; - $html .= ''; + $html .= ''; $html .= ''; $dates=dol_print_date((int) substr($value['createTime'], 0, 10), 'dayhour'); $html .= ''; diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index 2c7a3cb2a05..3fc0d505e70 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -287,12 +287,11 @@ class printing_printipp extends PrintingDriver $html .= ''; $html .= ''."\n"; $jobs = $ipp->jobs_attributes; - $var = True; + //$html .= '
'.print_r($jobs,true).'
'; foreach ($jobs as $value ) { - $var = !$var; - $html .= ''; + $html .= ''; $html .= ''; $html .= ''; $html .= ''; diff --git a/htdocs/don/index.php b/htdocs/don/index.php index b72e63f7797..d9bee39723c 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -150,7 +150,6 @@ print ''; $total=0; $totalnb=0; -$var=true; foreach ($listofstatus as $status) { @@ -200,10 +199,8 @@ if ($resql) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index d2f3a4c3567..871805564c5 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -73,7 +73,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere $db->begin(); $result=$object->valide(); - + if ($result > 0) { $db->commit(); @@ -112,7 +112,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->expensere llxHeader('', $langs->trans("ExpenseReportPayment")); -if ($id > 0) +if ($id > 0) { $result=$object->fetch($id); if (! $result) dol_print_error($db,'Failed to get payment id '.$id); @@ -240,8 +240,6 @@ if ($resql) if ($num > 0) { - $var=True; - while ($i < $num) { $objp = $db->fetch_object($resql); @@ -277,7 +275,7 @@ if ($resql) $i++; } } - + print "
'.$langs->trans("Status").''.$langs->trans("Cancel").'
'.$value['id'].''.$dates.'Cancel
'.$value->job_id->_value0.''.$value->job_originating_user_name->_value0.''.$value->printer_uri->_value0.'
\n"; print '
'; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 14b9a490da9..6dff84c5742 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -430,8 +430,6 @@ if ($object->id > 0) print $boxstat; - $var=true; - $MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Lien recap @@ -549,12 +547,10 @@ if ($object->id > 0) print ''; } - $var = True; while ($i < $num && $i <= $MAXLIST) { $obj = $db->fetch_object($resql); - print ''; print ''; $proposalstatic->id = $obj->rowid; @@ -654,12 +650,10 @@ if ($object->id > 0) print ''; } - $var = True; while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object($resql); - print ''; print ''; $orderstatic->id = $obj->rowid; @@ -727,7 +721,7 @@ if ($object->id > 0) print ''; print ''; } - $var=True; + while ($i < min($num,$MAXLIST)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 412f0c94b09..4eead48abf4 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -55,7 +55,6 @@ print '
'; if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - $var=false; print '
'; print ''; print ''; @@ -86,8 +85,6 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $var=True; - $total=0; $totalinprocess=0; $dataseries=array(); @@ -181,7 +178,6 @@ if ($resql) print ''; print ''; print "\n"; - $var=True; while ($i < $num) { @@ -230,11 +226,10 @@ if (! empty($conf->fournisseur->enabled)) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); + print ''; print '"; @@ -271,13 +266,11 @@ if ($resql) print '
'.$langs->trans("Status").''.$langs->trans("Nb").'
'; print "rowid."\">".img_object($langs->trans("ShowOrder"),"order").' '.$obj->ref."
'; print ''; print "\n"; - $var=True; while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; print ''; @@ -398,11 +389,10 @@ print ''; - $var = True; $generic_commande = new CommandeFournisseur($db); - while ( $i < $num ) { + while ($i < $num) { $objp = $db->fetch_object($resql); - $var = ! $var; - print ''; + + print ''; print ''; $i = 0; - $var = true; while ($i < $num) { - $obj = $db->fetch_object($resql); + print ''; $i = 0; $tot_ttc = 0; - $var = True; + while ($i < $num && $i < 20) { $obj = $db->fetch_object($resql); @@ -256,12 +255,8 @@ if ($resql) print '\n"; print "\n"; - $var=True; - while ($obj = $db->fetch_object($resql) ) { - - print ''; print '\n"; @@ -293,12 +288,10 @@ if (count($companystatic->SupplierCategories)) print '\n"; - $var=True; foreach ($companystatic->SupplierCategories as $rowid => $label) { - - print "\n"; + print ''."\n"; print '\n"; if ($num > 0) { - $var = True; + while ( $i < $num && $i < $conf->liste_limit ) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; + print ''; print ''; + print ''; print ''; + print ''; print ''; print ''; - $var = True; - foreach ( $prodcustprice->lines as $line ) { - print ''; + print ''; $staticprod = new Product($db); $staticprod->fetch($line->fk_product); @@ -558,11 +556,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { if (count($prodcustprice->lines) > 0) { - $var = False; - foreach ($prodcustprice->lines as $line) { - print ""; + print ''; $staticprod = new Product($db); $staticprod->fetch($line->fk_product); diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 68a575c5df8..17565e7f140 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -184,11 +184,10 @@ if (! empty($conf->supplier_proposal->enabled)) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); + print ''; $supplier_proposalstatic->id=$obj->rowid; @@ -242,10 +241,8 @@ if ($resql) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; From f513e3a1791e4ab0960e1a677397e0b18c3132ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 19:00:18 +0200 Subject: [PATCH 389/609] Fix travis --- .travis.yml | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5d9ad84323..1541ffd4871 100644 --- a/.travis.yml +++ b/.travis.yml @@ -150,22 +150,6 @@ before_script: echo Home dir is `echo ~` echo TRAVIS_BUILD_DIR is $TRAVIS_BUILD_DIR - - - sudo apt-get update - - sudo apt-get install apache2 libapache2-mod-fastcgi - # enable php-fpm - - sudo cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - - sudo cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf - - sudo a2enmod rewrite actions fastcgi alias - - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars - - sudo chown -R travis:travis /var/lib/apache2/fastcgi - - ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm - # configure apache virtual hosts - - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf - - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf - - sudo service apache2 restart - - | echo "Re-enabling Xdebug for PHP CodeSniffer and PHP Unit" phpenv config-add /tmp/xdebug.ini @@ -258,8 +242,27 @@ before_script: echo "first line" > documents/dolibarr.log echo + + - echo "Setting up Apache + FPM" + - sudo apt-get update + - sudo apt-get install apache2 libapache2-mod-fastcgi + # enable php-fpm + - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf + - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf + - sudo a2enmod rewrite actions fastcgi alias + - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini + - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars + - sudo chown -R travis:travis /var/lib/apache2/fastcgi + - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm + # configure apache virtual hosts + - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf + - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf + - sudo cat /etc/apache2/sites-available/000-default.conf + - sudo service apache2 restart + + - | - echo "Setting up Apache + FPM" + echo "Setting up Apache + FPM (old)" # enable php-fpm cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then From 69adf73f4fde841ec74b14e2f130cf70d7f278de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 19:27:37 +0200 Subject: [PATCH 390/609] Clean code from $var = True --- .travis.yml | 32 +++++-------------- htdocs/admin/facture.php | 12 +------ htdocs/admin/system/dbtable.php | 5 ++- htdocs/admin/system/filecheck.php | 2 +- htdocs/admin/tools/listsessions.php | 4 --- htdocs/admin/triggers.php | 2 -- htdocs/bookmarks/list.php | 2 -- htdocs/comm/contact.php | 3 -- htdocs/comm/mailing/index.php | 12 ++----- htdocs/compta/bank/categ.php | 5 ++- htdocs/compta/bank/releve.php | 2 -- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/compta/paiement/tovalidate.php | 1 - htdocs/compta/payment_sc/card.php | 3 -- htdocs/compta/prelevement/create.php | 2 -- htdocs/core/lib/sendings.lib.php | 3 +- htdocs/core/modules/export/modules_export.php | 3 +- .../modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/import/modules_import.php | 19 ++++++----- .../modules/rapport/pdf_paiement.class.php | 2 -- htdocs/don/payment/card.php | 3 -- htdocs/fourn/contact.php | 3 -- htdocs/fourn/facture/impayees.php | 1 - htdocs/fourn/facture/paiement.php | 2 -- htdocs/fourn/paiement/card.php | 2 -- htdocs/fourn/product/list.php | 2 +- htdocs/loan/card.php | 1 - htdocs/loan/payment/card.php | 11 +++---- htdocs/loan/payment/payment.php | 3 -- htdocs/margin/customerMargins.php | 4 --- htdocs/margin/productMargins.php | 4 --- htdocs/margin/tabs/productMargins.php | 2 -- htdocs/margin/tabs/thirdpartyMargins.php | 3 -- .../product/canvas/service/tpl/list.tpl.php | 3 +- htdocs/product/index.php | 4 +-- htdocs/product/stats/commande.php | 2 -- htdocs/product/stats/contrat.php | 1 - htdocs/product/stats/facture.php | 1 - htdocs/product/stock/card.php | 3 +- htdocs/product/stock/index.php | 1 - htdocs/public/donations/donateurs_code.php | 4 --- htdocs/public/members/public_list.php | 1 - htdocs/societe/notify/index.php | 4 +-- htdocs/societe/societecontact.php | 2 -- .../admin/supplier_proposal_extrafields.php | 2 -- .../supplier_proposaldet_extrafields.php | 2 -- 46 files changed, 39 insertions(+), 150 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1541ffd4871..c66a338e9c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -248,40 +248,24 @@ before_script: - sudo apt-get install apache2 libapache2-mod-fastcgi # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf - - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf + if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + # Copy the included pool + sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf + fi - sudo a2enmod rewrite actions fastcgi alias - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars - sudo chown -R travis:travis /var/lib/apache2/fastcgi - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm - # configure apache virtual hosts + # configure apache virtual hosts for precise + - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default + - sudo cat /etc/apache2/sites-available/default + # configure apache virtual hosts for trusty - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf - sudo cat /etc/apache2/sites-available/000-default.conf - sudo service apache2 restart - - - | - echo "Setting up Apache + FPM (old)" - # enable php-fpm - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - # Copy the included pool - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.d/www.conf - fi - if [ "$DEBUG" = true ]; then - cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php-fpm.conf - fi - sudo a2enmod rewrite actions fastcgi alias - echo "cgi.fix_pathinfo = 1" >> ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - if [ "$DEBUG" = true ]; then - cat ~/.phpenv/versions/$PHP_VERSION_NAME/etc/php.ini - fi - ~/.phpenv/versions/$PHP_VERSION_NAME/sbin/php-fpm - # configure apache virtual hosts - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/default - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default - sudo cat /etc/apache2/sites-available/default sudo service apache2 restart echo diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 9ffe45dec40..4fab390a4cc 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -284,8 +284,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -316,7 +314,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - $var = !$var; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -507,7 +503,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print ''; @@ -169,14 +165,12 @@ if ($result) $num = $db->num_rows($result); if ($num > 0) - { - $var = true; + { $i = 0; - while ($i < $num ) + while ($i < $num ) { $obj = $db->fetch_object($result); - print ''; print ''; diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 83e1f15ef36..fb514120d57 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -101,11 +101,10 @@ if ($result) $num = $db->num_rows($result); $i = 0; $total = 0; - $var=True; while ($i < $num) { $objp = $db->fetch_object($result); - + print ''; print ''; if (GETPOST('action','aZ09') == 'edit' && GETPOST("categid")== $objp->rowid) @@ -136,7 +135,7 @@ if ($result) */ if ($action != 'edit') { - + print ''; print ''; print ''; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 3acbb1e0ca7..5e9f98be02d 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -395,7 +395,6 @@ if (empty($numref)) $result = $db->query($sql); if ($result) { - $var=True; $numrows = $db->num_rows($result); $i = 0; @@ -572,7 +571,6 @@ else $result = $db->query($sql); if ($result) { - $var=False; $numrows = $db->num_rows($result); $i = 0; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 89f9055a776..84461ab0493 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2363,7 +2363,7 @@ class Facture extends CommonInvoice if (!empty($conf->global->INVOICE_USE_SITUATION)) { - $final = True; + $final = true; $nboflines = count($this->lines); while (($i < $nboflines) && $final) { $final = ($this->lines[$i]->situation_percent == 100); diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index f8c369f0887..43fa2e48212 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -94,7 +94,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=True; print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, $_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num); diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index ea9bc5af42a..8e76a219c3d 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -245,13 +245,10 @@ if ($resql) if ($num > 0) { - $var=True; - while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; // Ref print ''; print ''; - $var=True; - while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index 2a9f79b8399..71c287f7119 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -241,11 +241,10 @@ function show_list_sending_receive($origin,$origin_id,$filter='') } print "\n"; - $var=True; while ($i < $num) { - $objp = $db->fetch_object($resql); + print ''; // Sending id diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 8cbb3850c2b..5d7e0ecac84 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -54,7 +54,6 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac $handle=opendir($dir); // Recherche des fichiers drivers exports disponibles - $var=True; $i=0; if (is_resource($handle)) { @@ -72,7 +71,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac if (class_exists($classname)) { $module = new $classname($db); - + // Picto $this->picto[$module->id]=$module->picto; // Driver properties diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index b5ee2fba63b..05a832fc716 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -342,7 +342,7 @@ class pdf_crabe extends ModelePDFFactures // Situation invoice handling if ($object->situation_cycle_ref) { - $this->situationinvoice = True; + $this->situationinvoice = true; $progress_width = 18; $this->posxtva -= $progress_width; $this->posxup -= $progress_width; diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index cd70a3456bb..548bb128193 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -59,7 +59,7 @@ class ModeleImports { } - + /** * getDriverId * @@ -69,7 +69,7 @@ class ModeleImports { return $this->id; } - + /** * getDriverLabel * @@ -79,7 +79,7 @@ class ModeleImports { return $this->label; } - + /** * getDriverDesc * @@ -89,7 +89,7 @@ class ModeleImports { return $this->desc; } - + /** * getDriverExtension * @@ -99,7 +99,7 @@ class ModeleImports { return $this->extension; } - + /** * getDriverVersion * @@ -109,7 +109,7 @@ class ModeleImports { return $this->version; } - + /** * getDriverLabel * @@ -119,7 +119,7 @@ class ModeleImports { return $this->label_lib; } - + /** * getLibVersion * @@ -129,8 +129,8 @@ class ModeleImports { return $this->version_lib; } - - + + /** * Charge en memoire et renvoie la liste des modeles actifs * @@ -146,7 +146,6 @@ class ModeleImports $handle=opendir($dir); // Recherche des fichiers drivers imports disponibles - $var=True; $i=0; if (is_resource($handle)) { diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 2594a4a0b6a..a645b105610 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -248,13 +248,11 @@ class pdf_paiement { $num = $this->db->num_rows($result); $i = 0; - $var=True; while ($i < $num) { $objp = $this->db->fetch_object($result); - $lines[$i][0] = $objp->facnumber; $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true); $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 68d29fe3dc1..e4a7ef5c5d4 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -226,13 +226,10 @@ if ($resql) if ($num > 0) { - $var=True; - while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; // Ref print '\n"; - $var=True; $i = 0; while ($i < min($num,$limit)) { $obj = $db->fetch_object($result); - - print ''; print ''; diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index fd081d5616d..c1c4be9fb76 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -223,7 +223,6 @@ if ($user->rights->fournisseur->facture->lire) if ($num > 0) { - $var=True; $total_ht=0; $total_ttc=0; $total_paid=0; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 94c9f14153c..ca8983b8c92 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -524,7 +524,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ''; print ''; - $var=True; $total=0; $total_ttc=0; $totalrecu=0; @@ -794,7 +793,6 @@ if (empty($action)) { $num = $db->num_rows($resql); $i = 0; - $var=True; $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 529feb86897..daa452d0c29 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -288,8 +288,6 @@ if ($result > 0) if ($num > 0) { - $var=True; - $facturestatic=new FactureFournisseur($db); while ($i < $num) diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index c71825eda0f..9348a2a8b70 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -253,7 +253,7 @@ if ($resql) print "\n"; $oldid = ''; - $var=True; + while ($i < min($num,$limit)) { $objp = $db->fetch_object($resql); diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index 59b4da544db..53cf9e7cb82 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -702,7 +702,6 @@ if ($id > 0) print ''; print ''; - $var=True; while ($i < $num) { $objp = $db->fetch_object($resql); diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 206e3e64de7..47efb9c8cde 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -40,7 +40,7 @@ if ($user->societe_id) $socid=$user->societe_id; //$result = restrictedArea($user, 'facture', $id,''); $payment = new PaymentLoan($db); -if ($id > 0) +if ($id > 0) { $result=$payment->fetch($id); if (! $result) dol_print_error($db,'Failed to get payment id '.$id); @@ -76,7 +76,7 @@ if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->loan->wri $db->begin(); $result=$payment->valide(); - + if ($result > 0) { $db->commit(); @@ -141,7 +141,7 @@ if ($action == 'delete') if ($action == 'valide') { $facid = $_GET['facid']; - print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); + print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); } @@ -220,13 +220,10 @@ if ($resql) if ($num > 0) { - $var=True; - while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; // Ref print '
'.$langs->trans("UserWithApproveOrderGrant").'
'; $userstatic->id=$obj->rowid; @@ -329,10 +322,8 @@ if ($resql) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); print '
'.$langs->trans("OrdersToProcess").' '; print ''; diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index 13a40d9fe64..4c229518eba 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -542,13 +542,12 @@ if (($action != 'create' && $action != 'add') && !$error) { print '
'; $generic_commande->id = $objp->rowid; diff --git a/htdocs/fourn/index.php b/htdocs/fourn/index.php index e353739790d..033bcc63a2a 100644 --- a/htdocs/fourn/index.php +++ b/htdocs/fourn/index.php @@ -126,11 +126,10 @@ if (! empty($conf->fournisseur->enabled)) print ''.$langs->trans("DraftOrders").' '.$num.'
'; $commandestatic->id=$obj->rowid; $commandestatic->ref=$obj->ref; @@ -183,7 +182,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture- print ''.$langs->trans("DraftBills").' '.$num.'
'.$langs->trans("DateModification")."
'.img_object($langs->trans("ShowSupplier"),"company").''; print " socid."\">".$obj->name."
'; print $langs->trans("Category"); print "
'; $categstatic->id=$rowid; $categstatic->ref=$label; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 4526af86f96..63bb9028a4e 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -220,12 +220,11 @@ if ($id > 0 || ! empty($ref)) { print "
'; $supplierorderstatic->id = $objp->commandeid; $supplierorderstatic->ref = $objp->ref; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 47ca357b0cd..e17d03fe7e9 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -213,7 +213,6 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 3173a04ee55..36dcc945fe1 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -216,13 +216,11 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); - $var = ! $var; - print '
'; $propalstatic->id=$objp->propalid; $propalstatic->ref=$objp->ref; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index a580685c768..587d024b4c4 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -216,13 +216,11 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); - $var = ! $var; - print '
'; $propalstatic->id=$objp->propalid; $propalstatic->ref=$objp->ref; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index f1b6b572b35..e35cf186ae3 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -452,11 +452,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print ' 
'; echo preg_replace('/\-.*$/','',preg_replace('/mod_facture_/','',preg_replace('/\.php$/','',$file))); print "\n"; @@ -470,7 +467,6 @@ print "
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -598,7 +593,6 @@ print ''; print ''; print ''; -$var=True; print ''; print ''; print ''; print ''; print "\n"; -$var=true; // Force date validation -$var=! $var; print ''; print ''; print ''; @@ -717,7 +708,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index d6e05ed2e72..cef493c95f8 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -66,7 +66,6 @@ else if ($resql) { $num = $db->num_rows($resql); - $var=True; $i=0; while ($i < $num) { @@ -109,7 +108,7 @@ else //$sql = "DESCRIBE ".$table; $sql = "SHOW FULL COLUMNS IN ".$db->escape($table); - + $resql = $db->query($sql); if ($resql) { @@ -129,7 +128,7 @@ else print ""; - + print ''; print ''; $i++; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 6fd623bf1bb..597569abcb1 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -86,7 +86,7 @@ if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signa // Test if remote test is ok -$enableremotecheck = True; +$enableremotecheck = true; if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=False; $enableremotecheck = true; diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index 76f7debf3e7..70b0987732b 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -137,12 +137,8 @@ if ($savehandler == 'files') print_liste_field_titre(''); print "\n"; - $var=True; - foreach ($listofsessions as $key => $sessionentry) { - - print ''; // Login diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index 58ca4e0eded..ca14869cb2e 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -65,10 +65,8 @@ print getTitleFieldOfList($langs->trans("Active"), 0, $_SERVER["PHP_SELF"], 'act print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder, '', 1)."\n"; print ''; -$var=True; foreach ($triggers as $trigger) { - print ''; print ''; print ''; diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 0253efb3a3d..fa46f683e50 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -125,12 +125,10 @@ if ($resql) print_liste_field_titre(''); print "\n"; - $var=True; while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; // Id diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 5fe55c2da21..1460abe9823 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -144,14 +144,11 @@ if ($resql) print ''; print "\n"; - $var=True; $i = 0; while ($i < min($num,$limit)) { $obj = $db->fetch_object($resql); - - print ''; print ''; diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 52eacf6c115..4175c4e4446 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -52,7 +52,6 @@ print '
'; //if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo //{ // Recherche emails - $var=false; print ''; print ''; print '
'; @@ -662,7 +656,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql.= " WHERE clos = 0"; $sql.= " AND courant = 1"; $sql.= " AND entity IN (".getEntity('bank_account').")"; -$var=True; + $resql=$db->query($sql); if ($resql) { @@ -670,7 +664,6 @@ if ($resql) $i = 0; while ($i < $num) { - $row = $db->fetch_row($resql); print ''.$langs->trans("Value").' 
".(isset($link[$row[0]][0])?$link[$row[0]][0]:'')."."; print (isset($link[$row[0]][1])?$link[$row[0]][1]:'')."
'.$trigger['picto'].''.$trigger['file'].'
'.img_object($langs->trans("ShowContact"),"contact"); print ' '.$obj->name.'
'; @@ -62,7 +61,7 @@ print '
'; print '
'; print ''; - + print "
'; print $langs->trans("Other").':

\n"; //} @@ -74,7 +73,6 @@ print '
'.$langs->trans("TargetsStatistic $dir=DOL_DOCUMENT_ROOT."/core/modules/mailings"; $handle=opendir($dir); -$var=True; if (is_resource($handle)) { while (($file = readdir($handle))!==false) @@ -106,8 +104,6 @@ if (is_resource($handle)) // Si le module mailing est qualifi� if ($qualified) { - $var = !$var; - foreach ($mailmodule->getSqlArrayForStats() as $sql) { print '
'.img_object($langs->trans("ShowEMail"),"email").' '.$obj->rowid.'
'.$objp->rowid.'
 
'; diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index c94a786917f..c1d87a4c1b5 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -298,8 +298,6 @@ if ($result) print ''.$langs->trans("Date").''.$langs->trans("Amount").'
'; diff --git a/htdocs/fourn/contact.php b/htdocs/fourn/contact.php index abc4528039d..a334442e9ab 100644 --- a/htdocs/fourn/contact.php +++ b/htdocs/fourn/contact.php @@ -105,14 +105,11 @@ if ($result) print_liste_field_titre("Phone"); print "
'.img_object($langs->trans("ShowContact"),"contact").' '.$obj->lastname.''.$langs->trans('MulticurrencyPaymentAmount').'
'.$langs->trans("LoanCapital").'
'; @@ -250,7 +247,7 @@ if ($resql) $i++; } } - + print "
\n"; $db->free($resql); diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index bea15f288a0..8faac08fb60 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -245,9 +245,6 @@ if ($action == 'create') print ''.$langs->trans("Amount").''; print "\n"; - $var=True; - - print ''; if ($loan->datestart > 0) diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index b216db9d430..dfa97bd7536 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -283,8 +283,6 @@ if ($result) if ($num > 0) { - $var=True; - while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); @@ -304,8 +302,6 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - - print ''; if ($client) { print ''; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index ef99e593b82..ad1fc773bd3 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -258,8 +258,6 @@ if ($result) if ($num > 0) { - $var=True; - while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); @@ -278,8 +276,6 @@ if ($result) $markRate = ($pv != 0)?(100 * $marge / $pv):'' ; } - - print ''; if ($id > 0) { print ''; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 605a4272081..94eff1911e7 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -193,11 +193,9 @@ if ($id > 0 || ! empty($ref)) $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) { - $var=True; while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); - $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 5d80814099d..eb61e4ec41f 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -199,7 +199,6 @@ if ($socid > 0) if ($num > 0) { - $var=True; while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); @@ -207,8 +206,6 @@ if ($socid > 0) $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; - - print ''; print ''; $invoicestatic->id=$objp->facid; diff --git a/htdocs/product/canvas/service/tpl/list.tpl.php b/htdocs/product/canvas/service/tpl/list.tpl.php index 9951c71fcc3..ef6d461fc5c 100644 --- a/htdocs/product/canvas/service/tpl/list.tpl.php +++ b/htdocs/product/canvas/service/tpl/list.tpl.php @@ -89,10 +89,9 @@ if (empty($conf) || ! is_object($conf)) - > + $value) { foreach($fieldlist as $field) { diff --git a/htdocs/product/index.php b/htdocs/product/index.php index fd29143613a..1254af2213b 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -307,8 +307,6 @@ if ($result) print ''.$transRecordedType.''; - $var=True; - while ($i < $num) { $objp = $db->fetch_object($result); @@ -337,7 +335,7 @@ if ($result) $product_static->label = $objp->label; $product_static->type=$objp->fk_product_type; $product_static->entity = $objp->entity; - $product_static->status_batch = $objp->tobatch; + $product_static->status_batch = $objp->tobatch; print $product_static->getNomUrl(1,'',16); print "\n"; print ''.dol_trunc($objp->label,32).''; diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index dc3d9a9b7d6..2d01a2f6e9c 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -211,12 +211,10 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); - print ''; print ''; $orderstatic->id=$objp->commandeid; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index ef3723e2e55..ed4d989011e 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -177,7 +177,6 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 794d939bc6e..47abbee30a0 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -234,7 +234,6 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; while ($i < min($num,$conf->liste_limit)) { $objp = $db->fetch_object($result); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 1566e5d36c0..4fccbf4622f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -460,7 +460,6 @@ else { $num = $db->num_rows($resql); $i = 0; - $var=True; while ($i < $num) { $objp = $db->fetch_object($resql); @@ -491,7 +490,7 @@ else $productstatic->label = $objp->produit; $productstatic->type=$objp->type; $productstatic->entity=$objp->entity; - $productstatic->status_batch=$objp->tobatch; + $productstatic->status_batch=$objp->tobatch; print $productstatic->getNomUrl(1,'stock',16); print ''; diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index 36f9e1a7f7c..a1414ab06ac 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -86,7 +86,6 @@ if ($result) { $entrepot=new Entrepot($db); - $var=True; while ($i < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index 3780481e23c..3d8057cbe85 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -73,14 +73,10 @@ if ($resql) print "".$langs->trans("Amount").""; print "\n"; - $var=True; - $bc[1]='bgcolor="#f5f5f5"'; - $bc[0]='bgcolor="#f0f0f0"'; while ($i < $num) { $objp = $db->fetch_object($resql); - print ''; if ($objp->public) { diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index 03bf1ae5c98..b3438e8be02 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -139,7 +139,6 @@ if ($result) print_liste_field_titre("Photo", $_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder,'public_'); print "\n"; - $var=True; while ($i < $num && $i < $conf->liste_limit) { $objp = $db->fetch_object($result); diff --git a/htdocs/societe/notify/index.php b/htdocs/societe/notify/index.php index 1a46f62d202..3326e431178 100644 --- a/htdocs/societe/notify/index.php +++ b/htdocs/societe/notify/index.php @@ -85,13 +85,11 @@ if ($result) print_liste_field_titre("Contact",$_SERVER["PHP_SELF"],"c.lastname","","",'valign="center"',$sortfield,$sortorder); print_liste_field_titre("Action",$_SERVER["PHP_SELF"],"a.titre","","",'valign="center"',$sortfield,$sortorder); print "\n"; - $var=True; + while ($i < $num) { $obj = $db->fetch_object($result); - - print ''; print "socid."\">".$obj->name."\n"; print "".dolGetFirstLastname($obj->firstname, $obj->lastname)."\n"; diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index 6b3e833abb0..dfe78041f8a 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -253,7 +253,6 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("EndSubscription",$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder); print "\n"; - $var=True; $i=0; while ($i < $num && $i < $conf->liste_limit) { @@ -269,7 +268,6 @@ if ($id > 0 || ! empty($ref)) $companyname=$objp->company; - print ''; // Ref diff --git a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php index 8d9429051f8..cea668cfae2 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposal_extrafields.php @@ -87,10 +87,8 @@ print ''.$langs->trans("Required").''; print ' '; print "\n"; -$var=True; foreach($extrafields->attribute_type as $key => $value) { - print ''; print "".$extrafields->attribute_pos[$key]."\n"; print "".$extrafields->attribute_label[$key]."\n"; diff --git a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php index 75a0374a14c..41101ec7759 100644 --- a/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php +++ b/htdocs/supplier_proposal/admin/supplier_proposaldet_extrafields.php @@ -91,10 +91,8 @@ print ''.$langs->trans("Required").''; print ' '; print "\n"; -$var=True; foreach($extrafields->attribute_type as $key => $value) { - print ''; print "".$extrafields->attribute_label[$key]."\n"; print "".$key."\n"; From 1cd1368571fe07c091abfb97c5adbf0843207768 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 19:32:47 +0200 Subject: [PATCH 391/609] Fix travis file --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c66a338e9c5..122eb232e1f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -266,9 +266,6 @@ before_script: - sudo cat /etc/apache2/sites-available/000-default.conf - sudo service apache2 restart - sudo service apache2 restart - echo - script: From f9ed228e456bfc59e43fc5aa37ee5086ecb73a45 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 19:38:24 +0200 Subject: [PATCH 392/609] Fix travis file --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 122eb232e1f..6ea263fd671 100644 --- a/.travis.yml +++ b/.travis.yml @@ -248,6 +248,7 @@ before_script: - sudo apt-get install apache2 libapache2-mod-fastcgi # enable php-fpm - sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.conf + - | if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then # Copy the included pool sudo cp ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/$(phpenv version-name)/etc/php-fpm.d/www.conf From db665cdfcd9a6295373410e67f6e8adfca8ff800 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 19:43:24 +0200 Subject: [PATCH 393/609] Fix travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6ea263fd671..7ffe4ca9980 100644 --- a/.travis.yml +++ b/.travis.yml @@ -259,7 +259,7 @@ before_script: - sudo chown -R travis:travis /var/lib/apache2/fastcgi - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm # configure apache virtual hosts for precise - - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$TRAVIS_BUILD_DIR?g" --in-place /etc/apache2/sites-available/default + - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default - sudo cat /etc/apache2/sites-available/default # configure apache virtual hosts for trusty - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf From c5a389052669330acbc8e69cf5f1f6026260f0c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 19:48:43 +0200 Subject: [PATCH 394/609] Fix travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ffe4ca9980..6f54232a1d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -259,8 +259,8 @@ before_script: - sudo chown -R travis:travis /var/lib/apache2/fastcgi - ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm # configure apache virtual hosts for precise - - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default - - sudo cat /etc/apache2/sites-available/default + #- sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/default + #- sudo cat /etc/apache2/sites-available/default # configure apache virtual hosts for trusty - sudo cp -f build/travis-ci/apache.conf /etc/apache2/sites-available/000-default.conf - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf From e834eff049fa30ddcd34bab334f62360b1baeb7e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 20:03:24 +0200 Subject: [PATCH 395/609] FIX #8650 --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 6749d4be51c..efb47ede029 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -707,3 +707,6 @@ create table llx_facture_rec_extrafields ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); + +UPDATE llx_cronjob set entity = 1 where entity = 0 and label in ('RecurringInvoices', 'SendEmailsReminders'); +UPDATE llx_cronjob set entity = 0 where entity = 1 and label in ('PurgeDeleteTemporaryFilesShort', 'MakeLocalDatabaseDumpShort'); From 32511422abae7621e5d12c80ce6725399eb10e0b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 20:08:29 +0200 Subject: [PATCH 396/609] Fix PSR2 --- htdocs/admin/system/filecheck.php | 2 +- htdocs/compta/bank/bankentries_list.php | 2 +- htdocs/compta/facture/class/facture-rec.class.php | 2 +- htdocs/core/actions_setmoduleoptions.inc.php | 4 ++-- htdocs/core/class/doleditor.class.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/public/payment/paymentok.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 597569abcb1..76202c2df2b 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -87,7 +87,7 @@ if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signa // Test if remote test is ok $enableremotecheck = true; -if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=False; +if (preg_match('/beta|alpha|rc/i', DOL_VERSION) || ! empty($conf->global->MAIN_ALLOW_INTEGRITY_CHECK_ON_UNSTABLE)) $enableremotecheck=false; $enableremotecheck = true; print '
'; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 7d5935c189a..3179a6486e9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -912,7 +912,7 @@ if ($resql) if (! empty($arrayfields['b.conciliated']['checked'])) { print ''; - print $form->selectyesno('search_conciliated', $search_conciliated, 1, False, 1); + print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1); print ''; } print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c3ece4a2ee5..1e8997fdae4 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -108,7 +108,7 @@ class FactureRec extends CommonInvoice if (empty($this->frequency)) { $this->frequency=0; - $this->date_when=NULL; + $this->date_when=null; } diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index eadce1dc74c..03ff1491e49 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -31,13 +31,13 @@ if ($action == 'update' && is_array($arrayofparameters)) { $db->begin(); - $ok=True; + $ok=true; foreach($arrayofparameters as $key => $val) { $result=dolibarr_set_const($db,$key,GETPOST($key, 'alpha'),'chaine',0,'',$conf->entity); if ($result < 0) { - $ok=False; + $ok=false; break; } } diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index aa500ab64df..860d89afea8 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -153,7 +153,7 @@ class DolEditor { global $conf,$langs; - $fullpage=False; + $fullpage=false; if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) { $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 05a832fc716..0e11be1a8fa 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -182,7 +182,7 @@ class pdf_crabe extends ModelePDFFactures $this->localtax2=array(); $this->atleastoneratenotnull=0; $this->atleastonediscount=0; - $this->situationinvoice=False; + $this->situationinvoice=false; } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 389daafcd15..78cf69d8337 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -222,7 +222,7 @@ if (! empty($conf->paypal->enabled)) $TAXAMT=urldecode($resArray["TAXAMT"]); $NOTE=urldecode($resArray["NOTE"]); - $ispaymentok=True; + $ispaymentok=true; } else { From b049cf194da53fa272936eb76814fb6f74ed169e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 20:17:27 +0200 Subject: [PATCH 397/609] Fix PSR2 --- dev/tools/test/testtcpdf.php | 2 +- dev/tools/test/testutf.php | 2 +- test/phpunit/WebservicesInvoicesTest.php | 32 +++++++++++----------- test/phpunit/WebservicesThirdpartyTest.php | 6 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dev/tools/test/testtcpdf.php b/dev/tools/test/testtcpdf.php index ad67bce8af9..e14dae9c2a3 100755 --- a/dev/tools/test/testtcpdf.php +++ b/dev/tools/test/testtcpdf.php @@ -101,7 +101,7 @@ $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks -$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); +$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); diff --git a/dev/tools/test/testutf.php b/dev/tools/test/testutf.php index cb83f431b93..c626a92a57d 100644 --- a/dev/tools/test/testutf.php +++ b/dev/tools/test/testutf.php @@ -76,7 +76,7 @@ $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks -$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); +$pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM); //set image scale factor //$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index 75cc767b8ee..d2d02bde974 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -182,12 +182,12 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase $WS_METHOD = 'createInvoice'; $body = array ( - "id" => NULL, - "ref" => NULL, + "id" => null, + "ref" => null, "ref_ext" => "ref-phpunit-2", "thirdparty_id" => self::$socid, - "fk_user_author" => NULL, - "fk_user_valid" => NULL, + "fk_user_author" => null, + "fk_user_valid" => null, "date" => "2015-04-19 20:16:53", "date_due" => "", "date_creation" => "", @@ -201,11 +201,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase "note_private" => "Synchronised from Prestashop", "note_public" => "", "status" => "1", - "close_code" => NULL , - "close_note" => NULL, - "project_id" => NULL, + "close_code" => null , + "close_note" => null, + "project_id" => null, "lines" => array( - array("id" => NULL, + array("id" => null, "type" => 0, "desc" => "Horloge Vinyle Serge", "vat_rate" => 20, @@ -339,12 +339,12 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase // update status to 2 $body = array ( - "id" => NULL, - "ref" => NULL, + "id" => null, + "ref" => null, "ref_ext" => "ref-phpunit-2", "thirdparty_id" => self::$socid, - "fk_user_author" => NULL, - "fk_user_valid" => NULL, + "fk_user_author" => null, + "fk_user_valid" => null, "date" => "2015-04-19 20:16:53", "date_due" => "", "date_creation" => "", @@ -358,12 +358,12 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase "note_private" => "Synchronised from Prestashop", "note_public" => "", "status" => "2", - "close_code" => NULL , - "close_note" => NULL, - "project_id" => NULL, + "close_code" => null , + "close_note" => null, + "project_id" => null, "lines" => array( array( - "id" => NULL, + "id" => null, "type" => 0, "desc" => "Horloge Vinyle Serge", "vat_rate" => 20, diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index e0e22125afe..f974622e013 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -161,11 +161,11 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase 'entity'=>''); $body = array ( - "id" => NULL, + "id" => null, "ref" => "name", "ref_ext" => "12", - "fk_user_author" => NULL, - "status" => NULL, + "fk_user_author" => null, + "status" => null, "client" => 1, "supplier" => 0, "customer_code" => "CU0901-5678", From e9a2894727f755175cfddf965399dbe49f3c040e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 Apr 2018 20:57:43 +0200 Subject: [PATCH 398/609] Fix PSR2 --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/lib/files.lib.php | 4 ++-- htdocs/fourn/commande/card.php | 4 ++-- scripts/accountancy/export-thirdpartyaccount.php | 10 +++------- test/phpunit/WebservicesInvoicesTest.php | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7a067e7d16d..84c25573e85 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6605,7 +6605,7 @@ abstract class CommonObject { if(empty($this->{$field})) { - $queryarray[$field] = NULL; + $queryarray[$field] = null; } else { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index bd3b570799c..3d3f38eca2c 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1139,7 +1139,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n if (preg_match('/\.\./',$file) || preg_match('/[<>|]/',$file)) { dol_syslog("Refused to delete file ".$file, LOG_WARNING); - return False; + return false; } if (empty($nohook)) @@ -1238,7 +1238,7 @@ function dol_delete_dir($dir,$nophperrors=0) if (preg_match('/\.\./',$dir) || preg_match('/[<>|]/',$dir)) { dol_syslog("Refused to delete dir ".$dir, LOG_WARNING); - return False; + return false; } $dir_osencoded=dol_osencode($dir); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index cec2b306c4e..033cf251d4e 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2660,7 +2660,7 @@ elseif (! empty($object->id)) // Ensure that price is equal and warn user if it's not $supplier_price = price($result_product["product"]["price_net"]); //Price of client tab in supplier dolibarr - $local_price = NULL; //Price of supplier as stated in product suppliers tab on this dolibarr, NULL if not found + $local_price = null; //Price of supplier as stated in product suppliers tab on this dolibarr, NULL if not found $product_fourn = new ProductFournisseur($db); $product_fourn_list = $product_fourn->list_product_fournisseur_price($line->fk_product); @@ -2675,7 +2675,7 @@ elseif (! empty($object->id)) } } - if ($local_price != NULL && $local_price != $supplier_price) { + if ($local_price != null && $local_price != $supplier_price) { setEventMessages($line_id.$langs->trans("RemotePriceMismatch")." ".$supplier_price." - ".$local_price, null, 'warnings'); } diff --git a/scripts/accountancy/export-thirdpartyaccount.php b/scripts/accountancy/export-thirdpartyaccount.php index e5ba6bad702..2d557768d7d 100755 --- a/scripts/accountancy/export-thirdpartyaccount.php +++ b/scripts/accountancy/export-thirdpartyaccount.php @@ -201,13 +201,9 @@ if ($resql) { print '' . $langs->trans("Phone") . ''; print '' . $langs->trans("Fax") . ''; - $var = True; - - while ( $obj = $db->fetch_object($resql) ) { - - $var = ! $var; - - print ''; + while ($obj = $db->fetch_object($resql)) + { + print ''; print ''; $thirdpartystatic->id = $obj->rowid; $thirdpartystatic->name = $obj->name; diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index d2d02bde974..fe896894d86 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -291,7 +291,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase // Test URL $result=''; - $parameters = array('authentication'=>$authentication,'id'=>NULL,'ref'=>NULL,'ref_ext'=>'ref-phpunit-2'); + $parameters = array('authentication'=>$authentication, 'id'=>null, 'ref'=>null, 'ref_ext'=>'ref-phpunit-2'); print __METHOD__." call method ".$WS_METHOD."\n"; try { $result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,''); From 7065d16d8575fd9f86735f3b8317bc4e91409620 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 10:35:11 +0200 Subject: [PATCH 399/609] FIX Error in ContractLigne not return to Contract --- htdocs/contrat/class/contrat.class.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 20f03162d13..8e6f6af33ce 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -237,7 +237,13 @@ class Contrat extends CommonObject */ function active_line($user, $line_id, $date, $date_end='', $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } @@ -252,7 +258,13 @@ class Contrat extends CommonObject */ function close_line($user, $line_id, $date_end, $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } From 8256bd1889e2daee5040f71a673f87ffdec3f453 Mon Sep 17 00:00:00 2001 From: Julien BARRET Date: Mon, 23 Apr 2018 11:39:34 +0200 Subject: [PATCH 400/609] Fix Year selector issue in turnover statistics page --- htdocs/compta/stats/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index a4c32302a47..b9a7db32b51 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -114,7 +114,7 @@ if ($modecompta=="CREANCES-DETTES") $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -128,7 +128,7 @@ else if ($modecompta=="RECETTES-DEPENSES") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); @@ -141,7 +141,7 @@ else if ($modecompta=="BOOKKEEPING") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCATotalSaleJournal"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); From 6d552a2ae6931fcf8d0bff8920b302ae652f4ce4 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Mon, 23 Apr 2018 15:05:37 +0200 Subject: [PATCH 401/609] Add ordersupplierdispatch hook --- htdocs/fourn/commande/dispatch.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index c6a6034c684..3fb62407814 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -62,6 +62,8 @@ if (empty($conf->stock->enabled)) { accessforbidden(); } +$hookmanager->initHooks(array('ordersupplierdispatch')); + // Recuperation de l'id de projet $projectid = 0; if ($_GET["projectid"]) @@ -85,6 +87,10 @@ if ($id > 0 || ! empty($ref)) { * Actions */ +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) { $error=0; @@ -430,6 +436,9 @@ if ($id > 0 || ! empty($ref)) { print '' . $author->getNomUrl(1, '', 0, 0, 0) . ''; print ''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print ""; print '
'; From 01f76d0e08dc00c32fc6a59ea538ab0b1ab05cc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 15:06:30 +0200 Subject: [PATCH 402/609] FIX cron script disabled if module disabled --- scripts/cron/cron_run_jobs.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 246fd3d75b4..5113e5971b0 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -75,6 +75,13 @@ $now=dol_now(); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . $now . " *****\n"; +// Check module cron is activated +if (empty($conf->cron->enabled)) +{ + print "Error: module Scheduled jobs (cron) not activated\n"; + exit(-1); +} + // Check security key if ($key != $conf->global->CRON_KEY) { From 77d9ff033af3b49ab950371d971adb358a419214 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 15:06:30 +0200 Subject: [PATCH 403/609] FIX cron script disabled if module disabled --- scripts/cron/cron_run_jobs.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 246fd3d75b4..5113e5971b0 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -75,6 +75,13 @@ $now=dol_now(); @set_time_limit(0); print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . $now . " *****\n"; +// Check module cron is activated +if (empty($conf->cron->enabled)) +{ + print "Error: module Scheduled jobs (cron) not activated\n"; + exit(-1); +} + // Check security key if ($key != $conf->global->CRON_KEY) { From 315d5bad3903e7c48dc1941163282b335b7c2ff5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 10:35:11 +0200 Subject: [PATCH 404/609] FIX Error in ContractLigne not return to Contract --- htdocs/contrat/class/contrat.class.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 85128ea8a69..a460f6aff51 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -237,7 +237,13 @@ class Contrat extends CommonObject */ function active_line($user, $line_id, $date, $date_end='', $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } @@ -252,7 +258,13 @@ class Contrat extends CommonObject */ function close_line($user, $line_id, $date_end, $comment='') { - return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); + if ($result < 0) + { + $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; + $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; + } + return $result; } From f402753fa31338c5af555748fdd9163f2aba598d Mon Sep 17 00:00:00 2001 From: Thomas OURSEL Date: Mon, 23 Apr 2018 15:14:34 +0200 Subject: [PATCH 405/609] Fix french holidays (Easter related) --- htdocs/core/lib/date.lib.php | 46 +++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 931f30ce998..8a52941091e 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -562,56 +562,70 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') { $countryfound=1; - // Definition des dates feriees fixes + // Définition des dates fériées fixes if($jour == 1 && $mois == 1) $ferie=true; // 1er janvier if($jour == 1 && $mois == 5) $ferie=true; // 1er mai if($jour == 8 && $mois == 5) $ferie=true; // 5 mai if($jour == 14 && $mois == 7) $ferie=true; // 14 juillet - if($jour == 15 && $mois == 8) $ferie=true; // 15 aout + if($jour == 15 && $mois == 8) $ferie=true; // 15 août if($jour == 1 && $mois == 11) $ferie=true; // 1 novembre if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre - // Calcul du jour de paques + // Calcul du jour de Pâques $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; - // Paques + // Pâques - // Calcul du jour de l ascension (38 jours apres Paques) + // Calcul du jour du lundi de Pâques + $date_lundi_paques = mktime( + date("H", $date_paques), + date("i", $date_paques), + date("s", $date_paques), + date("m", $date_paques), + date("d", $date_paques) + 1, + date("Y", $date_paques) + ); + $jour_lundi_ascension = date("d", $date_lundi_paques); + $mois_lundi_ascension = date("m", $date_lundi_paques); + if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; + // Lundi de Pâques + + // Calcul du jour de l'ascension (38 jours apres Pâques) $date_ascension = mktime( date("H", $date_paques), date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), - date("d", $date_paques) + 38, + date("d", $date_paques) + 39, date("Y", $date_paques) ); $jour_ascension = date("d", $date_ascension); $mois_ascension = date("m", $date_ascension); if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; - //Ascension + // Ascension - // Calcul de Pentecote (11 jours apres Paques) + // Calcul de Pentecôte (11 jours apres Pâques) $date_pentecote = mktime( - date("H", $date_ascension), - date("i", $date_ascension), - date("s", $date_ascension), - date("m", $date_ascension), - date("d", $date_ascension) + 11, - date("Y", $date_ascension) + date("H", $date_paques), + date("i", $date_paques), + date("s", $date_paques), + date("m", $date_paques), + date("d", $date_paques) + 49, + date("Y", $date_paques) ); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; - //Pentecote + // Pentecôte // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; - //Samedi (6) et dimanche (0) + // Samedi (6) et dimanche (0) } // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday. From 657fa48c3f6270f6095d1c3209b15bb6d9fde24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 23 Apr 2018 15:31:55 +0200 Subject: [PATCH 406/609] Update api_products.class.php --- htdocs/product/class/api_products.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index b21a6a34046..2e53237659d 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -289,7 +289,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve category list : '.$categories->error); + throw new RestException(503, 'Error when retrieve category list : '.array_merge(array($categories->error), $categories->errors)); } return $result; @@ -323,7 +323,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve prices list : '.$categories->error); + throw new RestException(503, 'Error when retrieve prices list : '.array_merge(array($this->product->error), $this->product->errors)); } return array( @@ -365,7 +365,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve prices list : '.$categories->error); + throw new RestException(503, 'Error when retrieve prices list : '.array_merge(array($this->product->error), $this->product->errors)); } throw new RestException(501, 'Feature not yet available'); @@ -400,7 +400,7 @@ class Products extends DolibarrApi } if ($result < 0) { - throw new RestException(503, 'Error when retrieve prices list : '.$categories->error); + throw new RestException(503, 'Error when retrieve prices list : '.array_merge(array($this->product->error), $this->product->errors)); } return array( From 11d739494df83b3b282d23daf49cb9005c852d0a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 23 Apr 2018 15:51:21 +0200 Subject: [PATCH 407/609] clean code --- htdocs/accountancy/admin/accountmodel.php | 4 +--- htdocs/accountancy/admin/categories_list.php | 2 -- htdocs/accountancy/admin/journals_list.php | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index a06d8a3f8d1..fc3c74af9d0 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -683,7 +683,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; @@ -1062,7 +1061,6 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') global $form; global $region_id; global $elementList,$sourceList; - global $bc; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index dedc55b3fd5..3e30e680890 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -471,7 +471,6 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $var=false; $fieldlist=explode(',',$tabfield[$id]); @@ -565,7 +564,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 8aea0463fc3..0a36fd376dc 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -432,7 +432,6 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $var=false; $fieldlist=explode(',',$tabfield[$id]); @@ -512,7 +511,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; From bcf5c5d78a502c8dffe58112f655d72ea108308c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 23 Apr 2018 16:04:52 +0200 Subject: [PATCH 408/609] clean code --- .../adherents/tpl/linkedobjectblock.tpl.php | 3 +- htdocs/admin/system/constall.php | 2 +- htdocs/admin/tools/eaccelerator.php | 35 +++++++------------ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index f89b8da20f6..a3033ec090d 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -36,13 +36,12 @@ $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("members"); -$var=true; $total=0; foreach($linkedObjectBlock as $key => $objectlink) { ?> - > + trans("Subscription"); ?> getNomUrl(1); ?> diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index eee003b0872..82e8481c2dd 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -140,7 +140,7 @@ $configfilelib=array( 'Limit nb of email sent by page', 'Strict mode is on/off' ); -$var=true; + print ''; print ''; print ''; diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 68d56bd2ded..d3253c02514 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -116,8 +116,7 @@ function revcompare($x, $y) */ function create_script_table($list) { - global $sortby,$bc,$langs; - $var=true; + global $sortby,$langs; if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { $order = GETPOST('order'); @@ -173,7 +172,6 @@ function create_script_table($list) } foreach($list as $script) { - $var = ! $var; print ''; print ''; print ''; @@ -194,8 +192,7 @@ function create_script_table($list) */ function create_key_table($list) { - global $bc,$langs; - $var=true; + global $langs; print '
'.$langs->trans("Label").''.$langs->trans("Parameter").'
'.dol_trunc($script['file'],80,'left').''.dol_print_date($script['mtime'],'dayhour').'
'; print ''; @@ -206,7 +203,6 @@ function create_key_table($list) print ''; foreach($list as $key) { - $var = !$var; print ''; print ''; print ''; @@ -229,54 +225,49 @@ function create_key_table($list) $form=new Form($db); print load_fiche_titre('Dolibarr eAccelerator '.$info['version'].' control panel','','title_setup'); -$var=true; - print '
'; - print '
'.dol_trunc($key['name'],80,'left').''.dol_print_date($key['created'],'dayhour').'
'; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; print '
Information
Caching enabled'.($info['cache']?'yes':'no').'
Optimizer enabled'.$info['optimizer']?'yes':'no'.'
Memory usage'.number_format(100 * $info['memoryAllocated']/$info['memorySize'], 2).'%('.number_format($info['memoryAllocated'] / (1024*1024), 2).'MB / '.number_format($info['memorySize']/(1024*1024), 2).'MB)
Free memory in reserved cache'.number_format($info['memoryAvailable']/(1024*1024), 2).'MB
Cached scripts'.$info['cachedScripts'].'
Removed scripts'.$info['removedScripts'].'
Cached keys'.(isset($info['cachedKeys'])?$info['cachedKeys']:'').'
'; -$var=true; - $resCached = @eaccelerator_cached_scripts(); // If success return an array $resRemoved = @eaccelerator_removed_scripts(); @@ -288,12 +279,11 @@ if (is_array($resCached) || is_array($resRemoved)) { print 'Actions'; if (is_array($resCached)) { - $var = ! $var; print ''; print "Caching"; print ''; print ""; - $var = ! $var; + print ''; print "Optimizer"; print ''; @@ -301,17 +291,16 @@ if (is_array($resCached) || is_array($resRemoved)) { } if (is_array($resRemoved)) { - $var = ! $var; print ''; print "Clear cache"; print ''; print ""; - $var = ! $var; + print ''; print "Clean cache"; print ''; print ""; - $var = ! $var; + print ''; print "Purge cache"; print ''; From 9e9d52a662f258d1a0f0538490bdbbe6efce3a4c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 23 Apr 2018 16:23:30 +0200 Subject: [PATCH 409/609] clean and update code --- htdocs/admin/agenda_extsites.php | 2 -- htdocs/admin/barcode.php | 3 --- htdocs/admin/chequereceipts.php | 15 +++------------ htdocs/admin/clicktodial.php | 2 -- htdocs/admin/commande.php | 4 ---- htdocs/admin/contract.php | 12 +++--------- htdocs/admin/delais.php | 5 +---- 7 files changed, 7 insertions(+), 36 deletions(-) diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 4c1b49d75e6..f40ab648e42 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -148,7 +148,6 @@ print "
\n"; $selectedvalue=$conf->global->AGENDA_DISABLE_EXT; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; -$var=true; print ""; print ""; @@ -202,7 +201,6 @@ print ''; print ""; $i=1; -$var=true; while ($i <= $MAXAGENDA) { $key=$i; diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 313a852e384..db2b85fa986 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -157,7 +157,6 @@ foreach($dirbarcode as $reldir) /* * CHOIX ENCODAGE */ -$var=true; print '
'; print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); @@ -185,7 +184,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=true; while ($i < $num) { @@ -277,7 +275,6 @@ print ""; print ''; print ""; -$var=true; print '
'.$langs->trans("Color").'
'; print ''; print ''; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 86b38283649..0d2363f60c8 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2013-2014 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify @@ -31,11 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; -$langs->load("admin"); -$langs->load("companies"); -$langs->load("bills"); -$langs->load("other"); -$langs->load("banks"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","companies","bills","other","banks")); if (!$user->admin) accessforbidden(); @@ -133,8 +130,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -166,7 +161,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - $var = !$var; print ''; print ''; print ''; print "\n"; -$var=true; - -$var=! $var; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index e9224ba4688..582131b22f3 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -72,8 +72,6 @@ print ''; print ''; print ''; -$var=true; - print '
'.$langs->trans("Parameter").'
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -254,9 +248,6 @@ print ''.$langs->trans("Parameters").'  
'; print ''; print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 5db56c82aa2..cd4f4ca4ab2 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -286,7 +286,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -406,7 +405,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -537,7 +535,6 @@ print ''; print ''; print "\n"; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -545,7 +542,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 83c3634c35c..82fa51e5ca8 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -28,9 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load("contracts"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","errors","contracts")); if (!$user->admin) accessforbidden(); @@ -220,7 +219,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -339,7 +337,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -377,7 +374,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print ''; print ''; print ''; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -480,7 +475,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; + print ''; + print ''; + print ''; + } + print '
'.$langs->trans("Name").'
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -472,7 +468,6 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 37f66427225..4cf423b317f 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -144,7 +144,7 @@ if ($action == 'update') $plus=''; if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values - for($i=0;$i<4;$i++) { + for($i=0; $i<4; $i++) { if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity); } @@ -172,7 +172,6 @@ if ($action == 'edit') print ''; print ''; print ''; - $var=true; print ''; print ''; @@ -215,7 +214,6 @@ else print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; print ''; - $var=true; foreach($modules as $module => $delays) { @@ -241,7 +239,6 @@ else print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; print ''; - $var=false; print ''; print ''; From 4aa822d0f6ca82b53d513c9a8a0514bca799cf12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 16:49:27 +0200 Subject: [PATCH 410/609] better message --- scripts/cron/cron_run_jobs.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 5113e5971b0..5eb56defead 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -73,7 +73,7 @@ $error=0; $now=dol_now(); @set_time_limit(0); -print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . $now . " *****\n"; +print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." ***** userlogin=" . $userlogin . " ***** " . dol_print_date($now, 'dayrfc') . " *****\n"; // Check module cron is activated if (empty($conf->cron->enabled)) @@ -161,7 +161,7 @@ $nbofjobs=count($qualifiedjobs); $nbofjobslaunchedok=0; $nbofjobslaunchedko=0; -if(is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) +if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) { // Loop over job foreach($qualifiedjobs as $line) @@ -215,6 +215,10 @@ if(is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) } } } +else +{ + echo "cron_run_jobs.php no qualified job found\n"; +} $db->close(); From 00c8ea6c316dba4e0a0fb60ea2ede3a058030824 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 16:52:50 +0200 Subject: [PATCH 411/609] better message --- scripts/cron/cron_run_jobs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php index 5eb56defead..d9d6b5f9b56 100755 --- a/scripts/cron/cron_run_jobs.php +++ b/scripts/cron/cron_run_jobs.php @@ -172,7 +172,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) //If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database if (($line->datenextrun < $now) && (empty($line->datestart) || $line->datestart <= $now) && (empty($line->dateend) || $line->dateend >= $now)) { - dol_syslog("cron_run_jobs.php:: to run line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); $cronjob=new Cronjob($db); $result=$cronjob->fetch($line->id); @@ -211,7 +211,7 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs)>0)) } else { - dol_syslog("cron_run_jobs.php:: job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); + dol_syslog("cron_run_jobs.php job not qualified line->datenextrun:".dol_print_date($line->datenextrun,'dayhourrfc')." line->datestart:".dol_print_date($line->datestart,'dayhourrfc')." line->dateend:".dol_print_date($line->dateend,'dayhourrfc')." now:".dol_print_date($now,'dayhourrfc')); } } } From f95e5078c103a0f4a81fba85b37940a23df70802 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 21:33:49 +0200 Subject: [PATCH 412/609] FIX Can't edit option PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY --- htdocs/projet/admin/project.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/projet/admin/project.php b/htdocs/projet/admin/project.php index b1cf4d9773b..4135d547be3 100644 --- a/htdocs/projet/admin/project.php +++ b/htdocs/projet/admin/project.php @@ -274,12 +274,11 @@ elseif ($action == 'updateoptions') $conf->global->PROJECT_USE_SEARCH_TO_SELECT = $companysearch; } } -} -else if ($action == "linkOtherCompany") -{ - $projectToSelect = GETPOST('projectToSelect'); - - dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value + if (GETPOST('PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY')) + { + $projectToSelect = GETPOST('projectToSelect','alpha'); + dolibarr_set_const($db, 'PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY', $projectToSelect, 'chaine', 0, '', $conf->entity); //Allow to disable this configuration if empty value + } } From 0a5e6069375baf320383b23f1b9efff822b6e2fd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 22:53:57 +0200 Subject: [PATCH 413/609] FIX extrafields price and double were lost during a failed post. --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a8e4956a10d..21631b86cac 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5783,9 +5783,9 @@ abstract class CommonObject } else { $value = $this->array_options["options_" . $key]; // No GET, no POST, no default value, so we take value of object. } + //var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value); break; } - //var_dump($value); if ($extrafields->attribute_type[$key] == 'separate') { @@ -5810,12 +5810,12 @@ abstract class CommonObject // Convert date into timestamp format (value in memory must be a timestamp) if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$this->db->jdate($this->array_options['options_'.$key]); } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attribute_type[$key],array('price','double'))) { - $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix,'int',3)):$this->array_options['options_'.$key]; + $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)):$this->array_options['options_'.$key]; } $labeltoshow = $langs->trans($label); From fdb3a11f3492ce30bae8380fd29163d6b8812c22 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 Apr 2018 22:56:40 +0200 Subject: [PATCH 414/609] FIX extrafields price and double were lost during a failed post. --- htdocs/core/class/extrafields.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 7d6de9bda7f..2216c0fd7aa 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1779,13 +1779,14 @@ class ExtraFields } else if (in_array($key_type,array('price','double'))) { - $value_arr=GETPOST("options_".$key); + $value_arr=GETPOST("options_".$key, 'alpha'); $value_key=price2num($value_arr); } else { $value_key=GETPOST("options_".$key); } + $object->array_options["options_".$key]=$value_key; } From 736c56705b98d364be3e17d1b881523fee70ca93 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 24 Apr 2018 10:02:26 +0200 Subject: [PATCH 415/609] FIX : Related contact printed in societe agenda --- htdocs/core/lib/company.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 663821db0c2..b38f770e071 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -1468,7 +1468,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); $out.=getTitleFieldOfList(''); - $out.=getTitleFieldOfList(''); + $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], 'a.fk_contact', '', $param, '', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); $out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); $out.=''; @@ -1609,7 +1609,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $out.=''; // Contact pour cette action - if (! empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) + if (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) { $contactstatic->lastname=$histo[$key]['lastname']; $contactstatic->firstname=$histo[$key]['firstname']; From 271e50ccf40d5c5139215c1015d5edf63877a97c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 10:06:13 +0200 Subject: [PATCH 416/609] CSS --- htdocs/theme/eldy/style.css.php | 11 +++++------ htdocs/theme/md/style.css.php | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 93981a73c2e..b7fa85d5194 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -994,9 +994,6 @@ select.selectarrowonleft option { text-overflow: ellipsis; white-space: nowrap; } - div.fiche { - margin-top: px !important; - } div.titre { /* margin-top: 12px; */ /* line-height: 2em; */ @@ -1229,8 +1226,8 @@ div.fiche { div.fiche { margin-: dol_optimize_smallscreen)?'25':'6')); ?>px; margin-: dol_optimize_smallscreen)?'24':'6')); ?>px; - dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'."\n"; ?> - dol_hide_leftmenu)) print 'margin-bottom: 12px;'."\n"; ?> + + } body.onlinepaymentbody div.fiche { /* For online payment page */ margin: 20px !important; @@ -1280,7 +1277,6 @@ div.secondcolumn div.box { div.fiche { margin-: px; margin-: px; - dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> } div.fichecenter { width: 100%; @@ -3230,6 +3226,9 @@ span.boxstatstext img, a.dashboardlineindicatorlate img { a img { border: 0; } +.boxstatsindicator.thumbstat150 { /* If we remove this, box position is ko on ipad */ + display: inline-flex; +} span.boxstatsindicator { font-size: 130%; font-weight: normal; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 5970ad6ef84..fdc0a3e908b 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1234,7 +1234,7 @@ div.fiche { div.fiche { margin-: dol_optimize_smallscreen)?'24':'6')); ?>px; margin-: dol_optimize_smallscreen)?'22':'6')); ?>px; - dol_hide_leftmenu) && ! empty($conf->dol_hide_topmenu)) print 'margin-top: 4px;'; ?> + margin-bottom: 15px; } body.onlinepaymentbody div.fiche { /* For online payment page */ @@ -3190,6 +3190,9 @@ span.boxstatstext { color: #000; /* opacity: 0.7; */ /* a bug if browser make z-index infintie when opacity is set so we disable it */ } +.boxstatsindicator.thumbstat150 { /* If we remove this, box position is ko on ipad */ + display: inline-flex; +} span.boxstatsindicator { font-size: 110%; font-weight: normal; From decb93efa6f11db0e2eb02af37e6a00e7814f9b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 10:17:57 +0200 Subject: [PATCH 417/609] Fix NOIPCHECK --- htdocs/document.php | 21 ++++++++++++--------- htdocs/viewimage.php | 16 +++++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index 0a6e5593f62..725d079a9f6 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -38,22 +38,25 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // For bittorent link, we don't need to load/check we are into a login session -if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'bittorrent' && ! defined("NOLOGIN")) +if (isset($_GET["modulepart"]) && $_GET["modulepart"] == 'bittorrent') { - define("NOLOGIN",1); - define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // For direct external download link, we don't need to load/check we are into a login session -if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) +if (isset($_GET["hashp"])) { - define("NOLOGIN",1); - define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // Some value of modulepart can be used to get resources that are public so no login are required. -if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') && ! defined("NOLOGIN")) +if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { - define("NOLOGIN",1); - define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } /** diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index a53db61a83c..ffc0f3a6af5 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -37,19 +37,25 @@ if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Some value of modulepart can be used to get resources that are public so no login are required. -if ((isset($_GET["modulepart"]) && ($_GET["modulepart"] == 'mycompany' || $_GET["modulepart"] == 'companylogo')) && ! defined("NOLOGIN")) +if ((isset($_GET["modulepart"]) && ($_GET["modulepart"] == 'mycompany' || $_GET["modulepart"] == 'companylogo'))) { - define("NOLOGIN",'1'); + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // For direct external download link, we don't need to load/check we are into a login session if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) { - define("NOLOGIN",1); + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // Some value of modulepart can be used to get resources that are public so no login are required. -if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias') && ! defined("NOLOGIN")) +if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { - define("NOLOGIN",'1'); + if (! defined("NOLOGIN")) define("NOLOGIN",1); + if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. + if (! defined("NOIPCHECK")) define("NOIPCHECK",1); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For multicompany $entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); if (is_numeric($entity)) define("DOLENTITY", $entity); From be1089914e06add54b6d27ebdb07a82a98f1bedb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 10:27:57 +0200 Subject: [PATCH 418/609] Fix picto --- htdocs/barcode/codeinit.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 5e684b4091d..806a88325fb 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -212,7 +212,8 @@ if ($conf->societe->enabled) { $nbno=$nbtotal=0; - print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','object_company'); + print load_fiche_titre($langs->trans("BarcodeInitForThirdparties"),'','title_companies'); + print '
'."\n"; $sql="SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."societe where barcode IS NULL or barcode = ''"; $resql=$db->query($sql); @@ -253,7 +254,7 @@ if ($conf->product->enabled || $conf->product->service) $nbno=$nbtotal=0; - print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','object_product'); + print load_fiche_titre($langs->trans("BarcodeInitForProductsOrServices"),'','title_products'); print '
'."\n"; $sql ="SELECT count(rowid) as nb, fk_product_type, datec"; From 5f4e2dc565e94b7e6cd1d9431a2ed6d85e2791a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 24 Apr 2018 11:01:17 +0200 Subject: [PATCH 419/609] variant on services --- htdocs/core/lib/product.lib.php | 2 +- htdocs/product/card.php | 2 +- htdocs/variants/combinations.php | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index eedb994baed..731f8859eba 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -97,7 +97,7 @@ function product_prepare_head($object) $head[$h][2] = 'referers'; $h++; - if (!empty($conf->variants->enabled) && $object->isProduct()) { + if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { global $db; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 549eca022b0..a0ab4508d9c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1771,7 +1771,7 @@ else } //Parent product. - if (!empty($conf->variants->enabled) && $object->isProduct()) { + if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 04f53e55d21..3460718c680 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -71,7 +71,7 @@ if ($cancel) { unset($_SESSION['addvariant_'.$object->id]); } -if (! $object->isProduct()) { +if (! $object->isProduct() && ! $object->isService()) { header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2)); exit(); } @@ -523,12 +523,13 @@ if (! empty($id) || ! empty($ref))
- - - - -
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_METEO").'' . yn($conf->global->MAIN_DISABLE_METEO) . '
>
- isProduct()) { + print '
'; } print dol_fiche_end(); @@ -678,7 +679,7 @@ if (! empty($id) || ! empty($ref)) trans('Product') ?> trans('Combination') ?> trans('PriceImpact') ?> - trans('WeightImpact') ?> + isProduct()) print''.$langs->trans('WeightImpact').''; ?> trans('OnSell') ?> trans('OnBuy') ?> @@ -714,7 +715,7 @@ if (! empty($id) || ! empty($ref)) } ?> variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?> - variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight') ?> + isProduct()) print ''.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight').''; ?> getLibStatut(2, 0) ?> getLibStatut(2, 1) ?> From fcf91b6c8c98a8250398cc98cdc55cbded2092b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 11:12:12 +0200 Subject: [PATCH 420/609] Look and feel v8 --- htdocs/societe/paymentmodes.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index fe1456fd820..0baffe090d2 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -784,6 +784,8 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print ''; print '
'; + dol_fiche_end(); + print '
'; // List of Stripe payment modes @@ -792,7 +794,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $morehtmlright=''; if (! empty($conf->global->STRIPE_ALLOW_LOCAL_CARD)) { - $morehtmlright=''.$langs->trans("Add").''; + $morehtmlright=''.$langs->trans("Add").' '; } print load_fiche_titre($langs->trans('StripePaymentModes').($stripeacc?' (Stripe connection with Stripe OAuth Connect account '.$stripeacc.')':' (Stripe connection with keys from Stripe module setup)'), $morehtmlright, ''); @@ -1041,12 +1043,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' // List of bank accounts print '
'; - $morehtmlright=''.$langs->trans("Add").''; + $morehtmlright=''.$langs->trans("Add").' '; print load_fiche_titre($langs->trans("BankAccounts"), $morehtmlright, ''); $rib_list = $object->get_all_rib(); - $var = false; if (is_array($rib_list)) { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -1235,11 +1236,11 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' dol_print_error($db); } - dol_fiche_end(); - if (empty($conf->global->SOCIETE_DISABLE_BUILDDOC)) { + print '
'; + print '
'; print ''; // ancre @@ -1251,8 +1252,6 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' $genallowed=$user->rights->societe->lire; $delallowed=$user->rights->societe->creer; - $var=true; - print $formfile->showdocuments('company', $object->id, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 0, 0, 0, 28, 0, 'entity='.$object->entity, 0, '', $object->default_lang); // Show direct download link From 461ae46cc4eabedfdf17ebabb26e05ed8f68509e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Apr 2018 11:37:57 +0200 Subject: [PATCH 421/609] FIX When on a high page and searching for a small result, list was not visible. --- htdocs/accountancy/admin/account.php | 5 +++++ htdocs/accountancy/admin/fiscalyear.php | 5 +++++ htdocs/accountancy/admin/productaccount.php | 6 ++++++ htdocs/accountancy/customer/lines.php | 7 ++++++- htdocs/accountancy/customer/list.php | 5 +++++ htdocs/accountancy/expensereport/lines.php | 5 +++++ htdocs/accountancy/expensereport/list.php | 5 +++++ htdocs/accountancy/supplier/lines.php | 5 +++++ htdocs/accountancy/supplier/list.php | 5 +++++ htdocs/adherents/list.php | 5 +++++ htdocs/adherents/subscription/list.php | 5 +++++ htdocs/adherents/type.php | 11 +++++++++-- htdocs/admin/mails_senderprofile_list.php | 5 +++++ htdocs/admin/tools/listevents.php | 5 +++++ htdocs/assets/list.php | 5 +++++ htdocs/assets/type.php | 11 +++++++++-- htdocs/categories/class/categorie.class.php | 14 ++++++-------- htdocs/comm/action/list.php | 5 +++++ htdocs/comm/action/rapport/index.php | 5 +++++ htdocs/comm/mailing/cibles.php | 6 ++++++ htdocs/comm/propal/list.php | 6 ++++++ htdocs/commande/customer.php | 6 ++++++ htdocs/commande/list.php | 6 ++++++ htdocs/compta/facture/invoicetemplate_list.php | 8 +++++++- htdocs/compta/facture/list.php | 5 +++++ htdocs/compta/paiement/cheque/list.php | 5 +++++ htdocs/compta/paiement/list.php | 5 +++++ htdocs/compta/paiement/tovalidate.php | 5 +++++ htdocs/compta/prelevement/bons.php | 5 +++++ htdocs/compta/prelevement/card.php | 5 +++++ htdocs/compta/prelevement/factures.php | 5 +++++ htdocs/compta/prelevement/fiche-rejet.php | 5 +++++ htdocs/compta/prelevement/list.php | 5 +++++ htdocs/contact/list.php | 5 +++++ htdocs/contrat/list.php | 5 +++++ htdocs/contrat/services_list.php | 5 +++++ htdocs/cron/list.php | 5 +++++ htdocs/don/list.php | 7 +++++++ htdocs/expedition/list.php | 8 +++++++- htdocs/expensereport/list.php | 6 ++++++ htdocs/fichinter/list.php | 5 +++++ htdocs/fourn/commande/list.php | 5 +++++ htdocs/fourn/facture/list.php | 5 +++++ htdocs/fourn/facture/paiement.php | 5 +++++ htdocs/fourn/product/list.php | 10 +++++++++- htdocs/loan/index.php | 5 +++++ htdocs/margin/checkMargins.php | 9 +++++---- htdocs/modulebuilder/template/myobject_list.php | 13 ++++++------- htdocs/opensurvey/list.php | 12 +++++------- htdocs/product/inventory/list.php | 11 +++++------ htdocs/product/list.php | 7 +++++++ htdocs/product/reassort.php | 5 +++++ htdocs/product/reassortlot.php | 5 +++++ htdocs/product/stock/mouvement.php | 5 +++++ htdocs/product/stock/productlot_list.php | 5 +++++ htdocs/projet/list.php | 5 +++++ htdocs/projet/tasks/list.php | 5 +++++ htdocs/societe/agenda.php | 2 +- htdocs/societe/list.php | 5 +++++ htdocs/societe/notify/card.php | 5 +++++ htdocs/societe/website.php | 5 +++++ htdocs/supplier_proposal/list.php | 5 +++++ htdocs/ticketsup/class/api_ticketsups.class.php | 15 +++++++-------- htdocs/ticketsup/list.php | 11 +++++------ htdocs/user/notify/card.php | 5 +++++ 65 files changed, 352 insertions(+), 55 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index ac45b3993a4..690e9fad1f1 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -188,6 +188,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/admin/fiscalyear.php b/htdocs/accountancy/admin/fiscalyear.php index f3a6c9feb75..3910e1148b4 100644 --- a/htdocs/accountancy/admin/fiscalyear.php +++ b/htdocs/accountancy/admin/fiscalyear.php @@ -94,6 +94,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 7f48ad81ef8..eb4d331f228 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -256,7 +256,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + $sql .= $db->plimit($limit + 1, $offset); dol_syslog("/accountancy/admin/productaccount.php:: sql=" . $sql, LOG_DEBUG); diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index b62b4e8f5ca..7bc929a7e6b 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -242,6 +242,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); @@ -334,7 +339,7 @@ if ($result) { $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; - + $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; $product_static->type = $objp->type; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 378b62c05b8..f7485e701b7 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -289,6 +289,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index 7ab29657172..93073a62bd4 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -208,6 +208,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index a4d2ed81b56..2abd3fdc776 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -237,6 +237,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index a55c15952dc..a3e71cea0af 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -241,6 +241,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index aad7f514d50..4a52cb9a0e4 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -288,6 +288,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index aa6763654e3..13d0cbd30c5 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -262,6 +262,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($resql); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } // Add limit $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 43311a0b1e2..bf15230d47e 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -145,6 +145,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 2ef18ca3ca8..b0b5eee67ed 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -487,6 +487,9 @@ if ($rowid > 0) { $sql.=" AND datefin < '".$db->idate($now)."'"; } + + $sql.= " ".$db->order($sortfield,$sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -494,9 +497,13 @@ if ($rowid > 0) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($result); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } - // Add order and limit - $sql.= " ".$db->order($sortfield,$sortorder); + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 2221c05a6b2..5f0288525a0 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -230,6 +230,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index ac520ce22b3..48d3ef57fd5 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -184,6 +184,11 @@ $nbtotalofrecords = ''; { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } }*/ $sql.= $db->plimit($conf->liste_limit+1, $offset); diff --git a/htdocs/assets/list.php b/htdocs/assets/list.php index b3bc1886fc7..2b68a1b6782 100644 --- a/htdocs/assets/list.php +++ b/htdocs/assets/list.php @@ -225,6 +225,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/assets/type.php b/htdocs/assets/type.php index f9e725acafa..c1a6d849c01 100644 --- a/htdocs/assets/type.php +++ b/htdocs/assets/type.php @@ -464,6 +464,9 @@ if ($rowid > 0) { $sql.=" AND datefin < '".$db->idate($now)."'"; } + + $sql.= " ".$db->order($sortfield,$sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -471,9 +474,13 @@ if ($rowid > 0) $resql = $db->query($sql); if ($resql) $nbtotalofrecords = $db->num_rows($result); else dol_print_error($db); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } - // Add order and limit - $sql.= " ".$db->order($sortfield,$sortorder); + $sql.= " ".$db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 71240d63d8f..5fa8d267830 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -895,24 +895,22 @@ class Categorie extends CommonObject $sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND sub.'.$subcol_name.' = '.$id; + $sql.= $this->db->order($sortfield, $sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $this->db->query($sql); $nbtotalofrecords = $this->db->num_rows($result); - } - - $sql.= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 { $page = 0; + $offset = 0; } - $offset = $limit * $page; - - $sql.= $this->db->plimit($limit + 1, $offset); } + $sql.= $this->db->plimit($limit + 1, $offset); + $result = $this->db->query($sql); if ($result) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ed8a27f2d3d..36630b93092 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -318,6 +318,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 84fb6c411c8..93cbae527f1 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -93,6 +93,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1,$offset); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 48949881659..676c9c3e98e 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -425,7 +425,13 @@ if ($object->fetch($id) >= 0) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + //$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets $sql .= $db->plimit($limit+1, $offset); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 761107b73c3..78aa5a0d9cb 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -335,6 +335,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index 205efc3ad91..2d97b06238b 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -102,6 +102,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 19640dc0ec0..5e3f9bade62 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -342,6 +342,12 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 3e751d97b01..3e077e8a749 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -273,14 +273,20 @@ else if ($search_year_date_when > 0) $sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($search_year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($search_year_date_when,12,false))."'"; } +$sql.= $db->order($sortfield, $sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } -$sql.= $db->order($sortfield, $sortorder); $sql.= $db->plimit($limit+1,$offset); $resql = $db->query($sql); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index e8c34743441..61383941c10 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -515,6 +515,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1,$offset); diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index c936bfb4519..b9e8cac609a 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -117,6 +117,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 553c62b1d97..f001d84a27d 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -192,6 +192,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 43fa2e48212..031a0ff354a 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -85,6 +85,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index 2e20701db59..02c6e7b08f0 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -87,6 +87,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index ed0977ebabf..a6d739f1f0c 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -322,6 +322,11 @@ if ($id > 0 || $ref) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 64811c7604a..d446e64fe9b 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -170,6 +170,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 82431e3bdd2..2fbaaf7fbcb 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -169,6 +169,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 3bed588e10e..10634670f5f 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -111,6 +111,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 3d1fa3dcaef..0660b394f1b 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -349,6 +349,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index d1f4dd262ed..b3ee34731cc 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -301,6 +301,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 9a4c21b145b..0fc475c19fb 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -257,6 +257,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql .= $db->plimit($limit + 1, $offset); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 8d448d5f514..81e9d57c03b 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -276,6 +276,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/don/list.php b/htdocs/don/list.php index fff82b50179..334d1f219c2 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -113,12 +113,19 @@ if (trim($search_name) != '') if ($search_amount) $sql.= natural_search('d.amount', $search_amount, 1); $sql.= $db->order($sortfield,$sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + $sql.= $db->plimit($limit+1, $offset); $resql = $db->query($sql); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index bdf2607f803..a3d44d7072a 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -233,14 +233,20 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; +$sql.= $db->order($sortfield,$sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } -$sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1,$offset); //print $sql; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 75ab5fc8b9b..2bc7a624514 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -329,7 +329,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + $sql.= $db->plimit($limit+1, $offset); //print $sql; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index c6d052f08b1..87d8b366ef8 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -230,6 +230,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index f0c5acdcf3e..c72c31b3a99 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -584,6 +584,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index b8fd5d2f054..95bbfe48e19 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -412,6 +412,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index ca8983b8c92..a47b76e4af8 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -784,6 +784,11 @@ if (empty($action)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/fourn/product/list.php b/htdocs/fourn/product/list.php index 9348a2a8b70..47bc949a758 100644 --- a/htdocs/fourn/product/list.php +++ b/htdocs/fourn/product/list.php @@ -157,14 +157,22 @@ if ($fourn_id > 0) { $sql .= " AND ppf.fk_soc = ".$fourn_id; } + +$sql .= $db->order($sortfield,$sortorder); + // Count total nb of records without orderby and limit $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } -$sql .= $db->order($sortfield,$sortorder); + $sql .= $db->plimit($limit + 1, $offset); dol_syslog("fourn/product/list.php:", LOG_DEBUG); diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index caefb7829a4..7a6bee5d79f 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -91,6 +91,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/margin/checkMargins.php b/htdocs/margin/checkMargins.php index 0952efb2507..d1c682540ff 100644 --- a/htdocs/margin/checkMargins.php +++ b/htdocs/margin/checkMargins.php @@ -205,10 +205,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { dol_syslog(__FILE__, LOG_DEBUG); $result = $db->query($sql); - if ($result) { - $nbtotalofrecords = $db->num_rows($result); - } else { - setEventMessages($db->lasterror, null, 'errors'); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; } } diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 46a1f51b06f..cbac5339384 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -262,14 +262,13 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } -// if total resultset is smaller then paging size (filtering), goto and load page 0 -if (($page * $limit) > $nbtotalofrecords) -{ - $page = 0; - $offset = 0; -} -// if total resultset is smaller the limit, no need to do paging. +// if total resultset is smaller than limit, no need to do paging adn restart select with limits. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index eb7f827972e..77934e68744 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -115,13 +115,6 @@ $sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p. $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; -// Count total nb of records -$nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); -} $sql.= " WHERE p.entity IN (".getEntity('survey').")"; if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; @@ -136,6 +129,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index f1ecf079041..4a6ca485686 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -233,12 +233,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} -// if total resultset is smaller then paging size (filtering), goto and load page 0 -if (($page * $limit) > $nbtotalofrecords) -{ - $page = 0; - $offset = 0; + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } // if total resultset is smaller the limit, no need to do paging. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e5d6b145fb1..11be839aa4f 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -338,12 +338,19 @@ else $sql.=$hookmanager->resPrint; //if (GETPOST("toolowstock")) $sql.= " HAVING SUM(s.reel) < p.seuil_stock_alerte"; // Not used yet $sql.= $db->order($sortfield,$sortorder); + $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } + $sql.= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 798038e0a91..88b9f2080aa 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -155,6 +155,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index aebfd368d1b..423d0f4015d 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -167,6 +167,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1, $offset); diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 3758f5e96c7..883cd316c76 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -473,6 +473,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 562bc23804a..c9ac6269dbd 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -253,6 +253,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 08c8bb0aa2f..94a3850fe33 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -373,6 +373,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 654fa4d805c..b15207513ef 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -327,6 +327,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 10a3221f546..f992206ef23 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -164,7 +164,7 @@ if ($socid > 0) { if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) { - $newcardbutton.=''.$langs->trans("AddAction"); + $newcardbutton.=''.$langs->trans("AddAction"); $newcardbutton.= ''; $newcardbutton.= ''; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 41484e2ea87..58043bc511c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -485,6 +485,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/societe/notify/card.php b/htdocs/societe/notify/card.php index 31622c1b9d9..cd8212ae327 100644 --- a/htdocs/societe/notify/card.php +++ b/htdocs/societe/notify/card.php @@ -432,6 +432,11 @@ if ($result > 0) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 8f3ea9c2588..97b31e09010 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -292,6 +292,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 15392dcb1c1..6cc5b54f050 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -332,6 +332,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit + 1,$offset); diff --git a/htdocs/ticketsup/class/api_ticketsups.class.php b/htdocs/ticketsup/class/api_ticketsups.class.php index ee696b34505..98af42fd262 100644 --- a/htdocs/ticketsup/class/api_ticketsups.class.php +++ b/htdocs/ticketsup/class/api_ticketsups.class.php @@ -258,16 +258,15 @@ class Ticketsups extends DolibarrApi if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - } - - if ($limit) { - if ($page < 0) { - $page = 0; + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; } - $offset = $limit * $page; - - $sql.= $db->plimit($limit + 1, $offset); } + + $sql.= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); diff --git a/htdocs/ticketsup/list.php b/htdocs/ticketsup/list.php index 61dcf45ba83..d2127fd875f 100644 --- a/htdocs/ticketsup/list.php +++ b/htdocs/ticketsup/list.php @@ -255,12 +255,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); -} -// if total resultset is smaller then paging size (filtering), goto and load page 0 -if (($page * $limit) > $nbtotalofrecords) -{ - $page = 0; - $offset = 0; + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } // if total resultset is smaller the limit, no need to do paging. if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 096567d728a..2bcf4fc0663 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -411,6 +411,11 @@ if ($result > 0) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } } $sql.= $db->plimit($limit+1, $offset); From 64dde1595b71838db9160f549ac4fe09f4c1672a Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 24 Apr 2018 11:48:26 +0200 Subject: [PATCH 422/609] FIX : Credit note links set from source invoice links --- htdocs/compta/facture/card.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ec14ec3da14..dbce9c2e76d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -983,15 +983,13 @@ if (empty($reshook)) // Add link between credit note and origin if(! empty($object->fk_facture_source)) { $facture_source->fetch($object->fk_facture_source); - } - $facture_source->fetchObjectLinked(); + $facture_source->fetchObjectLinked(); - if(! empty($facture_source->linkedObjectsIds)) { - $linkedObjectIds = $facture_source->linkedObjectsIds; - $sourcetype = key($linkedObjectIds); - $fk_origin = current($facture_source->linkedObjectsIds[$sourcetype]); - - $object->add_object_linked($sourcetype, $fk_origin); + if(! empty($facture_source->linkedObjectsIds)) { + foreach($facture_source->linkedObjectsIds as $sourcetype => $TIds) { + $object->add_object_linked($sourcetype, current($TIds)); + } + } } } } From 6fc444e045fb9a67cda6354e32b16ff3b86caadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 24 Apr 2018 12:08:17 +0200 Subject: [PATCH 423/609] we can see what we are doing --- htdocs/variants/combinations.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 3460718c680..dbc413542c4 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -327,11 +327,31 @@ if (! empty($id) || ! empty($ref)) if ($action == 'add') { $title = $langs->trans('NewProductCombination'); + print dol_fiche_head(); + $features = $_SESSION['addvariant_'.$object->id]; + //First, sanitize + print '
'; + if (! empty($features)) { + foreach ($features as $feature) { + + $explode = explode(':', $feature); + + if ($prodattr->fetch($explode[0]) < 0) { + continue; + } + + if ($prodattr_val->fetch($explode[1]) < 0) { + continue; + } + + print '' . $prodattr->label . ':'. $prodattr_val->value . ' '; + } + } + print '
'; + print dol_fiche_end(); } else { $title = $langs->trans('EditProductCombination'); } - - print '
'; print_fiche_titre($title); if ($action == 'add') { @@ -346,8 +366,8 @@ if (! empty($id) || ! empty($ref)) foreach ($prodattr_all as $each) { $prodattr_alljson[$each->id] = $each; } - - ?> + + ?> '; -} -*/ llxFooter(); $db->close(); diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index cede86796a0..77525a0b0d1 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -96,7 +96,7 @@ class modDav extends DolibarrModules // Data directories to create when module is enabled. // Example: this->dirs = array("/dav/temp","/dav/subdir"); - $this->dirs = array("/dav/temp","/dav/public"); + $this->dirs = array("/dav/temp","/dav/public","/dav/private"); // Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module. $this->config_page_url = array("dav.php"); diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index a785fac0ab9..cd19fc294ec 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -52,7 +52,9 @@ if(empty($conf->dav->enabled)) // settings $publicDir = $conf->dav->dir_output.'/public'; -$tmpDir = $conf->dav->dir_output.'/tmp'; +$privateDir = $conf->dav->dir_output.'/private'; +$tmpDir = $conf->dav->dir_temp; +//var_dump($tmpDir);exit; // Authentication callback function $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) @@ -96,7 +98,8 @@ $nodes = array(); // Enable directories and features according to DAV setup // / Public docs -$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/public'); +if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) $nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/public'); +$nodes[] = new \Sabre\DAV\FS\Directory($dolibarr_main_data_root. '/dav/private'); // Principals Backend //$principalBackend = new \Sabre\DAVACL\PrincipalBackend\Dolibarr($user,$db); @@ -120,8 +123,14 @@ $baseUri = DOL_URL_ROOT.'/dav/fileserver.php/'; if (isset($baseUri)) $server->setBaseUri($baseUri); // Add authentication function -$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend)); - +if ((empty($conf->global->DAV_ALLOW_PUBLIC_DIR) + || ! preg_match('/'.preg_quote(DOL_URL_ROOT.'/dav/fileserver.php/public','/').'/', $_SERVER["PHP_SELF"])) + && ! preg_match('/^sabreAction=asset&assetName=[a-zA-Z0-9%\-\/]+\.(png|css|woff|ico|ttf)$/', $_SERVER["QUERY_STRING"]) // URL for Sabre browser resources + ) +{ + //var_dump($_SERVER["QUERY_STRING"]);exit; + $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend)); +} // Support for LOCK and UNLOCK $lockBackend = new \Sabre\DAV\Locks\Backend\File($tmpDir . '/.locksdb'); $lockPlugin = new \Sabre\DAV\Locks\Plugin($lockBackend); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1927008bad1..f8bae299f17 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1206,6 +1206,9 @@ MustBeUnique=Must be unique? MustBeMandatory=Mandatory to create third parties? MustBeInvoiceMandatory=Mandatory to validate invoices? TechnicalServicesProvided=Technical services provided +#####DAV ##### +WebDAVSetupDesc=This is the links to access the WebDAV directory. It contains a "public" dir open to any user knowing the URL (if public directory accessis allowed) and a "private" directory that need an existing login account/password to access to. +WebDavServer=Root URL of %s server : %s ##### Webcal setup ##### WebCalUrlForVCalExport=An export link to %s format is available at following link: %s ##### Invoices ##### @@ -1784,7 +1787,6 @@ MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') SeveralLangugeVariatFound=Several language variants found -WebDavServer=URL of %s server : %s COMPANY_AQUARIUM_REMOVE_SPECIAL=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) ##### Resource #### From 59d0e9a64f281a14171c12b2be4db04ae079578a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Apr 2018 12:36:16 +0200 Subject: [PATCH 437/609] trans --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f8bae299f17..b02d90207cf 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1207,7 +1207,7 @@ MustBeMandatory=Mandatory to create third parties? MustBeInvoiceMandatory=Mandatory to validate invoices? TechnicalServicesProvided=Technical services provided #####DAV ##### -WebDAVSetupDesc=This is the links to access the WebDAV directory. It contains a "public" dir open to any user knowing the URL (if public directory accessis allowed) and a "private" directory that need an existing login account/password to access to. +WebDAVSetupDesc=This is the links to access the WebDAV directory. It contains a "public" dir open to any user knowing the URL (if public directory access allowed) and a "private" directory that need an existing login account/password to access to. WebDavServer=Root URL of %s server : %s ##### Webcal setup ##### WebCalUrlForVCalExport=An export link to %s format is available at following link: %s From 75a4891113d629ad1aee12370983632e8539ce2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Apr 2018 15:47:42 +0200 Subject: [PATCH 438/609] Add az09comma to sanitize sortfield/sortorder --- htdocs/core/lib/functions.lib.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4cbb3043bda..d8fa9651d98 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -542,6 +542,13 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu if (preg_match('/[^a-z0-9_\-\.]+/i',$out)) $out=''; } break; + case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh + if (! is_array($out)) + { + $out=trim($out); + if (preg_match('/[^a-z0-9_\-\.,]+/i',$out)) $out=''; + } + break; case 'array': if (! is_array($out) || empty($out)) $out=array(); break; From 83b762b681c6dfdceb809d26ce95f3667b614739 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Apr 2018 16:01:06 +0200 Subject: [PATCH 439/609] FIX CVE-2018-9019 --- htdocs/accountancy/admin/accountmodel.php | 40 +++-------------- htdocs/accountancy/admin/categories.php | 2 +- htdocs/accountancy/admin/categories_list.php | 45 +++++++------------- htdocs/accountancy/admin/journals_list.php | 23 ++-------- htdocs/admin/dict.php | 14 +++--- htdocs/admin/mails_templates.php | 21 ++------- htdocs/admin/website.php | 19 +-------- htdocs/core/lib/functions.lib.php | 8 ++-- 8 files changed, 42 insertions(+), 130 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index f3924f73a76..df4f5d7c3f5 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -45,7 +45,7 @@ $langs->loadLangs(array("errors","admin","companies","resource","holiday","compt $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); +$id=31; $rowid=GETPOST('rowid','alpha'); $code=GETPOST('code','alpha'); @@ -58,8 +58,8 @@ $listoffset=GETPOST('listoffset'); $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $active = 1; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +$sortfield = GETPOST("sortfield",'aZ09comma'); +$sortorder = GETPOST("sortorder",'aZ09comma'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $listlimit * $page ; @@ -84,59 +84,48 @@ $hookmanager->initHooks(array('admin')); $tabname=array(); $tabname[31]= MAIN_DB_PREFIX."accounting_system"; -$tabname[32]= MAIN_DB_PREFIX."c_accounting_category"; // Dictionary labels $tablib=array(); $tablib[31]= "Pcg_version"; -$tablib[32]= "DictionaryAccountancyCategory"; // Requests to extract data $tabsql=array(); $tabsql[31]= "SELECT s.rowid as rowid, pcg_version, s.label, s.fk_country as country_id, c.code as country_code, c.label as country, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_country as c WHERE s.fk_country=c.rowid and c.active=1"; -$tabsql[32]= "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.sens, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1"; // Criteria to sort dictionaries $tabsqlsort=array(); $tabsqlsort[31]="pcg_version ASC"; -$tabsqlsort[32]="position ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); $tabfield[31]= "pcg_version,label,country_id,country"; -$tabfield[32]= "code,label,range_account,sens,category_type,formula,position,country_id,country"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); $tabfieldvalue[31]= "pcg_version,label,country"; -$tabfieldvalue[32]= "code,label,range_account,sens,category_type,formula,position,country"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); $tabfieldinsert[31]= "pcg_version,label,fk_country"; -$tabfieldinsert[32]= "code,label,range_account,sens,category_type,formula,position,fk_country"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on // "nameoffield" if id field is not "rowid" or has not autoincrement on $tabrowid=array(); $tabrowid[31]= ""; -$tabrowid[32]= ""; // Condition to show dictionary in setup page $tabcond=array(); $tabcond[31]= ! empty($conf->accounting->enabled); -$tabcond[32]= ! empty($conf->accounting->enabled); // List of help for fields $tabhelp=array(); $tabhelp[31] = array('pcg_version'=>$langs->trans("EnterAnyCode")); -$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); $tabfieldcheck[31] = array(); -$tabfieldcheck[32] = array(); // Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact") @@ -484,7 +473,7 @@ print "
\n"; // Confirmation de la suppression de la ligne if ($action == 'delete') { - print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); + print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page?'page='.urlencode($page).'&':'').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1); } //var_dump($elementList); @@ -503,24 +492,9 @@ if ($id) $sql.= " c.rowid = ".$search_country_id; } - if ($sortfield) - { - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); //print $sql; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 7ab463e3179..9c40802c925 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -88,7 +88,7 @@ $formaccounting = new FormAccounting($db); llxheader('', $langs->trans('AccountingCategory')); -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; print load_fiche_titre($langs->trans('AccountingCategory'), $linkback); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index fb7561dda94..40ea103a12f 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -54,8 +54,8 @@ $listoffset=GETPOST('listoffset'); $listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000; $active = 1; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +$sortfield = GETPOST("sortfield",'aZ09comma'); +$sortorder = GETPOST("sortorder",'aZ09comma'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $listlimit * $page ; @@ -300,7 +300,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; } else { $rowidcol="rowid"; } - $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; dol_syslog("delete", LOG_DEBUG); $result = $db->query($sql); @@ -324,10 +324,10 @@ if ($action == $acts[0]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -344,10 +344,10 @@ if ($action == $acts[1]) else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -364,10 +364,10 @@ if ($action == 'activate_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -384,10 +384,10 @@ if ($action == 'disable_favorite') else { $rowidcol="rowid"; } if ($rowid) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$this->db->escape($rowid)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = '".$db->escape($rowid)."'"; } elseif ($code) { - $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$this->db->escape($code)."'"; + $sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE code = '".$db->escape($code)."'"; } $result = $db->query($sql); @@ -437,24 +437,9 @@ if ($id) $sql.= " (a.fk_country = ".$search_country_id." OR a.fk_country = 0)"; } - if ($sortfield) - { - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); //print $sql; @@ -793,7 +778,7 @@ if ($id) print ''; if (empty($obj->formula)) { - print ''; + print ''; print $langs->trans("ListOfAccounts"); print ''; } diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 7612e7b261a..971fdc20811 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -36,7 +36,7 @@ $langs->load("accountancy"); $action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view'; $confirm=GETPOST('confirm','alpha'); -$id=GETPOST('id','int'); +$id=35; $rowid=GETPOST('rowid','alpha'); $code=GETPOST('code','alpha'); @@ -400,24 +400,9 @@ if ($id) $sql=$tabsql[$id]; $sql.= " WHERE a.entity = ".$conf->entity; - if ($sortfield) - { - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + // If sort order is "country", we use country_code instead + if ($sortfield == 'country') $sortfield='country_code'; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); $fieldlist=explode(',',$tabfield[$id]); diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 438c7cd5227..72ac51e1799 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -965,14 +965,14 @@ if (empty($id)) print "
\n"; -$param = '&id='.$id; -if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; +$param = '&id='.urlencode($id); +if ($search_country_id > 0) $param.= '&search_country_id='.urlencode($search_country_id); if ($search_code != '') $param.= '&search_code='.urlencode($search_country_id); if ($entity != '') $param.= '&entity=' . (int) $entity; $paramwithsearch = $param; -if ($sortorder) $paramwithsearch.= '&sortorder='.$sortorder; -if ($sortfield) $paramwithsearch.= '&sortfield='.$sortfield; -if (GETPOST('from')) $paramwithsearch.= '&from='.GETPOST('from','alpha'); +if ($sortorder) $paramwithsearch.= '&sortorder='.urlencode($sortorder); +if ($sortfield) $paramwithsearch.= '&sortfield='.urlencode($sortfield); +if (GETPOST('from')) $paramwithsearch.= '&from='.urlencode(GETPOST('from','alpha')); // Confirmation de la suppression de la ligne @@ -999,10 +999,10 @@ if ($id) { // If sort order is "country", we use country_code instead if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; + $sql.= " ORDER BY ".$db->escape($sortfield); if ($sortorder) { - $sql.=" ".strtoupper($sortorder); + $sql.=" ".strtoupper($db->escape($sortorder)); } $sql.=", "; // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index fb2729bb77b..24bd6a7b8fe 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -430,24 +430,9 @@ if ($search_type_template != '' && $search_type_template != '-1') $sql.=natural_ if ($search_lang) $sql.=natural_search('lang', $search_lang); if ($search_fk_user != '' && $search_fk_user != '-1') $sql.=natural_search('fk_user', $search_fk_user, 2); if ($search_topic) $sql.=natural_search('topic', $search_topic); -if ($sortfield) -{ - // If sort order is "country", we use country_code instead - if ($sortfield == 'country') $sortfield='country_code'; - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); -} -else { - $sql.=" ORDER BY "; -} -$sql.=$tabsqlsort[$id]; +// If sort order is "country", we use country_code instead +if ($sortfield == 'country') $sortfield='country_code'; +$sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($listlimit+1,$offset); //print $sql; diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 9811052509a..e13bd4a2312 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -419,24 +419,7 @@ if ($id) { // Complete requete recherche valeurs avec critere de tri $sql=$tabsql[$id]; - - if ($sortfield) - { - // If sort order is "country", we use country_code instead - $sql.= " ORDER BY ".$sortfield; - if ($sortorder) - { - $sql.=" ".strtoupper($sortorder); - } - $sql.=", "; - // Clear the required sort criteria for the tabsqlsort to be able to force it with selected value - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.' '.$sortorder.',/i','',$tabsqlsort[$id]); - $tabsqlsort[$id]=preg_replace('/([a-z]+\.)?'.$sortfield.',/i','',$tabsqlsort[$id]); - } - else { - $sql.=" ORDER BY "; - } - $sql.=$tabsqlsort[$id]; + $sql.=$db->order($sortfield,$sortorder); $sql.=$db->plimit($limit+1, $offset); //print $sql; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 37e957c868c..a22a9675ff6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -578,12 +578,12 @@ function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NU { //var_dump($paramname.' - '.$out.' '.$user->default_values[$relativepathstring]['filters'][$paramname]); - // We save search key only if: - // - not empty, or - // - if value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not). + // We save search key only if $out not empty that means: + // - posted value not empty, or + // - if posted value is empty and a default value exists that is not empty (it means we did a filter to an empty value when default was not). //if (! empty($out) || ! empty($user->default_values[$relativepathstring]['filters'][$paramname])) - if (! empty($out)) + if ($out != '') // $out = '0' like 'abc' is a search criteria to keep { $user->lastsearch_values_tmp[$relativepathstring][$paramname]=$out; } From 991d5c4215cdda8908dae7847d5bdf1396560814 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Wed, 25 Apr 2018 16:04:21 +0200 Subject: [PATCH 440/609] NEW : Adds a contact to an invoice Adds a contact to an invoice using the REST API --- .../facture/class/api_invoices.class.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index f3aab82422f..2a4e2075b2f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -562,6 +562,59 @@ class Invoices extends DolibarrApi return $updateRes; } + /** + * Adds a contact to an invoice + * + * @param int $id Order ID + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING + * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) + * @param int $notrigger Disable all triggers + * + * @url POST {id}/contacts + * + * @return array + * + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 + * + */ + function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->add_contact($fk_socpeople,$type_contact,$source,$notrigger); + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->invoice); + } + + + /** * Sets an invoice as draft * From c044d9ab584705e231a1ee03ad87b13fb5d60730 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 25 Apr 2018 16:20:09 +0200 Subject: [PATCH 441/609] FIX: actioncomm export: type filtering not working --- htdocs/core/modules/modAgenda.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 83175bcdefc..5f78b229461 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -378,7 +378,7 @@ class modAgenda extends DolibarrModules $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", 'ac.durationp'=>"Duree", - 'cac.libelle'=>"List:c_actioncomm:libelle:id", + 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text'); @@ -400,7 +400,7 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda',1).')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); - $this->export_sql_end[$r] .=' ORDER BY ac.datep'; + $this->export_sql_order[$r]=' ORDER BY ac.datep'; } From 39aef07c6bb31fcd77cd735460313ed3a01acac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Apr 2018 17:14:18 +0200 Subject: [PATCH 442/609] FIX Only voters can send comments in public survey page --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/langs/en_US/opensurvey.lang | 3 ++- htdocs/public/opensurvey/studs.php | 22 ++++++++++++++++------ htdocs/theme/eldy/style.css.php | 3 +++ htdocs/theme/md/style.css.php | 3 +++ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d8fa9651d98..dcf4b6fb998 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3097,7 +3097,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ //if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on'))) if (empty($srconly) && in_array($pictowithoutext, array( - 'bank', 'close_title', 'delete', 'edit', 'filter', 'grip', 'grip_title', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', + 'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow') )) { $fakey = $pictowithoutext; diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index 1f8a90b5657..0819a077f71 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -57,4 +57,5 @@ ErrorInsertingComment=There was an error while inserting your comment MoreChoices=Enter more choices for the voters SurveyExpiredInfo=The poll has been closed or voting delay has expired. EmailSomeoneVoted=%s has filled a line.\nYou can find your poll at the link: \n%s -ShowSurvey=Show survey \ No newline at end of file +ShowSurvey=Show survey +UserMustBeSameThanUserUsedToVote=You must have voted and use the same user name, that the one used to vote, to post a comment \ No newline at end of file diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 742b949e27c..32cb5f2e1ba 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -66,22 +66,28 @@ if (GETPOST('ajoutcomment','alpha')) $error=0; - if (! GETPOST('comment','none')) + $comment = GETPOST("comment",'none'); + $comment_user = GETPOST('commentuser','nohtml'); + + if (! $comment) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); } - if (! GETPOST('commentuser','nohtml')) + if (! $comment_user) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); } + if (! in_array($comment_user, $listofvoters)) + { + setEventMessages($langs->trans("UserMustBeSameThanUserUsedToVote"), null, 'errors'); + $error++; + } + if (! $error) { - $comment = GETPOST("comment",'none'); - $comment_user = GETPOST('commentuser','nohtml'); - $resql = $object->addComment($comment, $comment_user); if (! $resql) dol_print_error($db); @@ -729,8 +735,12 @@ if ($comments) print "
" . $langs->trans("CommentsOfVoters") . ":
\n"; foreach ($comments as $obj) { + // ligne d'un usager pré-authentifié + //$mod_ok = (in_array($obj->name, $listofvoters)); + print '
'; - if (in_array($obj->usercomment, $listofvoters)) print ' '.img_picto('', 'delete.png').' '; + if (in_array($obj->usercomment, $listofvoters)) print ' '.img_picto('', 'delete.png', '', false, 0, 0, '', 'nomarginleft').' '; + //else print img_picto('', 'ellipsis-h', '', false, 0, 0, '', 'nomarginleft').' '; print dol_htmlentities($obj->usercomment).': '.dol_nl2br(dol_htmlentities($obj->comment))."
"; } } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index b7fa85d5194..578ec142ad5 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -722,6 +722,9 @@ select.flat.selectlimit { .marginleftonly { margin-left: 10px !important; } +.nomarginleft { + margin-left: 0px !important; +} .selectlimit, .selectlimit:focus { border-left: none !important; border-top: none !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index fdc0a3e908b..0cafac9a6c2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -716,6 +716,9 @@ select.flat.selectlimit { .marginleftonly { margin-left: 10px !important; } +.nomarginleft { + margin-left: 0px !important; +} .selectlimit, .selectlimit:focus { border-left: none !important; border-top: none !important; From 6b2bd934694432ba87bb7acdde1e2591fc52d3a4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Apr 2018 17:59:05 +0200 Subject: [PATCH 443/609] NEW Add dol_is_link function --- htdocs/core/lib/files.lib.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3d3f38eca2c..744a1326e69 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -454,6 +454,18 @@ function dol_is_file($pathoffile) return is_file($newpathoffile); } +/** + * Return if path is a symbolic link + * + * @param string $pathoffile Path of file + * @return boolean True or false + */ +function dol_is_link($pathoffile) +{ + $newpathoffile=dol_osencode($pathoffile); + return is_link($newpathoffile); +} + /** * Return if path is an URL * From 21a18da43b5b96ddf78e1a515667f3dd89893894 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 Apr 2018 21:06:51 +0200 Subject: [PATCH 444/609] We can disable the "favorites" in select combo of countries --- htdocs/core/class/html.form.class.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ba0057324e9..e143def17ee 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -642,16 +642,17 @@ class Form /** * Return combo list of activated countries, into language of user * - * @param string $selected Id or Code or Label of preselected country - * @param string $htmlname Name of html select object - * @param string $htmloption Options html on select object - * @param integer $maxlength Max length for labels (0=no limit) - * @param string $morecss More css class - * @param string $usecodeaskey 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key - * @param int $showempty Show empty choice - * @return string HTML string with select + * @param string $selected Id or Code or Label of preselected country + * @param string $htmlname Name of html select object + * @param string $htmloption Options html on select object + * @param integer $maxlength Max length for labels (0=no limit) + * @param string $morecss More css class + * @param string $usecodeaskey 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key + * @param int $showempty Show empty choice + * @param int $disablefavorites Disable favorites + * @return string HTML string with select */ - function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1) + function select_country($selected='', $htmlname='country_id', $htmloption='', $maxlength=0, $morecss='minwidth300', $usecodeaskey='', $showempty=1, $disablefavorites=0) { global $conf,$langs; @@ -692,13 +693,14 @@ class Form $i++; } - array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); + if (empty($disablefavorites)) array_multisort($favorite, SORT_DESC, $label, SORT_ASC, $countryArray); + else $countryArray = dol_sort_array($countryArray, 'label'); foreach ($countryArray as $row) { if (empty($showempty) && empty($row['rowid'])) continue; - if ($row['favorite'] && $row['code_iso']) $atleastonefavorite++; + if (empty($disablefavorites) && $row['favorite'] && $row['code_iso']) $atleastonefavorite++; if (empty($row['favorite']) && $atleastonefavorite) { $atleastonefavorite=0; From 36616cdd5047788b6b7d9a05ca0eec49cd1c9639 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 10:07:27 +0200 Subject: [PATCH 445/609] FIX When time is entered without hour, edit keeps this --- htdocs/core/class/html.form.class.php | 6 ++++-- htdocs/projet/tasks.php | 6 +++--- htdocs/projet/tasks/time.php | 14 +++++++++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e143def17ee..ccd873ece8a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4776,8 +4776,8 @@ class Form * * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date (emptydate must be 0). * @param string $prefix Prefix for fields name - * @param int $h 1=Show also hours (-1 has same effect, but hour and minutes are prefilled with 23:59 if $set_time = -1) - * @param int $m 1=Show also minutes + * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty + * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty * @param int $empty 0=Fields required, 1=Empty inputs are allowed, 2=Empty inputs are allowed for hours only * @param string $form_name Not used * @param int $d 1=Show days, month, years @@ -4850,6 +4850,8 @@ class Form $smin = !isset($conf->global->MAIN_DEFAULT_DATE_MIN) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_MIN; $ssec = !isset($conf->global->MAIN_DEFAULT_DATE_SEC) ? ($h == -1 ? '59' : '') : $conf->global->MAIN_DEFAULT_DATE_SEC; } + if ($h == 3) $shour = ''; + if ($m == 3) $smin = ''; // You can set MAIN_POPUP_CALENDAR to 'eldy' or 'jquery' $usecalendar='combo'; diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index e29a1d6826e..67dd84a1572 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -464,16 +464,16 @@ else if ($id > 0 || ! empty($ref)) { if ($object->public || $userWrite > 0) { - $linktocreatetask = ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } else { - $linktocreatetask = ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } } else { - $linktocreatetask = ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 701a74760dd..0f2ec5f9fcd 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -420,16 +420,16 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { if ($projectstatic->public || $userWrite > 0) { - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; } else { - $linktocreatetime = ''.$langs->trans('AddTime').''; + $linktocreatetime = ''.$langs->trans('AddTime').''; } } else { - $linktocreatetime = ''.$langs->trans('AddTime').''; + $linktocreatetime = ''.$langs->trans('AddTime').''; } //} } @@ -949,7 +949,11 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; if ($_GET['action'] == 'editline' && $_GET['lineid'] == $task_time->rowid) { - print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); + if (empty($task_time->task_date_withhour)) + { + print $form->select_date(($date2?$date2:$date1),'timeline',3,3,2,"timespent_date",1,0,1); + } + else print $form->select_date(($date2?$date2:$date1),'timeline',1,1,2,"timespent_date",1,0,1); } else { @@ -1086,7 +1090,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print $hookmanager->resPrint; // Action column - print ''; + print ''; if ($action == 'editline' && $_GET['lineid'] == $task_time->rowid) { print ''; From d988585f86da831de2498922a3b3f25d350e4cc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 11:03:50 +0200 Subject: [PATCH 446/609] Save spaces in timesheet report page --- htdocs/core/lib/project.lib.php | 26 ++++++++++++---------- htdocs/projet/activity/perday.php | 35 ++++++++++++++++++------------ htdocs/projet/activity/perweek.php | 29 +++++++++++++++++-------- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index c82839d8499..06d0b7aa6d3 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -893,8 +893,9 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { print ''."\n"; - print ''; - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print ''; + print $projectstatic->getNomUrl(1,'',0,''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); if ($projectstatic->title) { print ' - '; @@ -916,14 +917,14 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr */ // Project - print ""; + /*print ""; if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - print ""; + print "";*/ // Thirdparty - print ''; + /*print ''; if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project', 10); - print ''; + print '';*/ // Ref print ''; @@ -1176,8 +1177,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ if (empty($oldprojectforbreak) || ($oldprojectforbreak != -1 && $oldprojectforbreak != $projectstatic->id)) { print ''."\n"; - print ''; - print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + print ''; + print $projectstatic->getNomUrl(1,'',0,''.$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); + if ($thirdpartystatic->id > 0) print ' - '.$thirdpartystatic->getNomUrl(1); if ($projectstatic->title) { print ' - '; @@ -1199,14 +1201,14 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ */ // Project - print ''; + /*print ''; if ($oldprojectforbreak == -1) print $projectstatic->getNomUrl(1,'',0,$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project]); - print ""; + print "";*/ // Thirdparty - print ''; + /*print ''; if ($thirdpartystatic->id > 0) print $thirdpartystatic->getNomUrl(1, 'project'); - print ''; + print '';*/ // Ref print ''; diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 43720614a2e..9dd57d3c776 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -409,7 +409,7 @@ print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print '
'; print ' '; -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth150onsmartphone'); print ''; print '
'; @@ -433,9 +433,22 @@ $moreforfilter.='
'; $moreforfilter.='
'.$langs->trans('User'). '
'; $includeonly='hierachyme'; if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); -$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); +$moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200 marginleftonly'); $moreforfilter.='
'; +if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) +{ + $moreforfilter.='
'; + $moreforfilter.='
'.$langs->trans('Project'). '
'; + $moreforfilter.=''; + $moreforfilter.='
'; + + $moreforfilter.='
'; + $moreforfilter.='
'.$langs->trans('ThirdParty'). '
'; + $moreforfilter.=''; + $moreforfilter.='
'; +} + if (! empty($moreforfilter)) { print '
'; @@ -451,9 +464,8 @@ print '
'; print ''."\n"; print ''; -print ''; -print ''; -//print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; print ''; print ''; @@ -470,9 +482,8 @@ print ''; print "\n"; print ''; -print ''; -print ''; -//print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; print ''; print ''; @@ -522,7 +533,7 @@ print ''; print ''; print "\n"; -$colspan = 8; +$colspan = 6+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2);; if ($conf->use_javascript_ajax) { @@ -607,13 +618,9 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; - print ''; - print ''; - print ''; - print ''; print ''; print '"; print "\n"; - $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); + $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); $action = "tvaclient"; $object = &$coll_list; @@ -247,7 +248,7 @@ if($calc ==0 || $calc == 1){ $company_static=new Societe($db); - $coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); + $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); $parameters["direction"] = 'buy'; $parameters["type"] = 'localtax'.$local; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 39d8a1dfa6a..2364290403b 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -212,8 +213,8 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu if ($m > 12) $m -= 12; $mcursor++; - $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $coll_listsell = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); @@ -241,7 +242,7 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu print ''; print ''; - + if ($CalcLT==0) { $x_coll = 0; foreach($coll_listsell as $vatrate=>$val) { diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index db316a1d6dc..8d7843b5cea 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -22,8 +22,7 @@ /** * \file htdocs/compta/tva/quadri_detail.php * \ingroup tax - * \brief Trimestrial page - detailed version - * TODO Deal with recurrent invoices as well + * \brief Local tax by rate */ global $mysoc; @@ -31,18 +30,21 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); $local=GETPOST('localTaxType', 'int'); // Date range -$year=GETPOST("year"); +$year=GETPOST("year","int"); if (empty($year)) { $year_current = strftime("%Y",dol_now()); @@ -51,16 +53,15 @@ if (empty($year)) $year_current = $year; $year_start = $year; } - -$date_start = dol_mktime( 0, 0, 0, GETPOST( "date_startmonth" ), GETPOST( "date_startday" ), GETPOST( "date_startyear" ) ); -$date_end = dol_mktime( 23, 59, 59, GETPOST( "date_endmonth" ), GETPOST( "date_endday" ), GETPOST( "date_endyear" ) ); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,$_REQUEST["month"],false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -83,7 +84,9 @@ if (empty($min)) $min = 0; // Define modetax (0 or 1) // 0=normal, 1=option vat for services is on debit, 2=option on payments for products -$modetax = $conf->global->TAX_MODE; +//$modetax = $conf->global->TAX_MODE; +$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; +$modetax=$conf->global->$calc; if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); if (empty($modetax)) $modetax=0; @@ -92,121 +95,123 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -/** + + +/* * View */ + +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); -foreach($listofparams as $param) +foreach ($listofparams as $param) { if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); } -llxHeader('','','','',0,0,'','',$morequerystring); - -$form=new Form($db); - -$company_static=new Societe($db); -$invoice_customer=new Facture($db); -$invoice_supplier=new FactureFournisseur($db); -$product_static=new Product($db); -$payment_static=new Paiement($db); -$paymentfourn_static=new PaiementFourn($db); +llxHeader('',$langs->trans("LocalTaxReport"),'','',0,0,'','',$morequerystring); $fsearch.=' '; $fsearch.=' '; $fsearch.=' '; $name=$langs->transcountry($local==1?"LT1ReportByQuarters":"LT2ReportByQuarters", $mysoc->country_code); -$calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; - -if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services -{ - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $prevyear=$year_start; $prevquarter=$q; - if ($prevquarter > 1) $prevquarter--; - else { $prevquarter=4; $prevyear--; } - $nextyear=$year_start; $nextquarter=$q; - if ($nextquarter < 4) $nextquarter++; - else { $nextquarter=1; $nextyear++; } - - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); - else $description.='
'.$langs->trans("DepositsAreIncluded"); - $description.=$fsearch; - $builddate=dol_now(); - - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("ProductOrService"); - $amountcust=$langs->trans("AmountHT"); - $vatcust=$langs->trans("VATReceived"); - if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')'; - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("ProductOrService"); - $amountsup=$langs->trans("AmountHT"); - $vatsup=$langs->trans("VATPaid"); - if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; +$calcmode=''; +if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); +$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; } -if ($conf->global->$calc==2) // Invoice for goods, payment for services -{ - $calcmode=$calc==0?$langs->trans("CalcModeLT".$local):$langs->trans("CalcModeLT".$local."Rec"); - $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $prevyear=$year_start; $prevquarter=$q; - if ($prevquarter > 1) $prevquarter--; - else { $prevquarter=4; $prevyear--; } - $nextyear=$year_start; $nextquarter=$q; - if ($nextquarter < 4) $nextquarter++; - else { $nextquarter=1; $nextyear++; } - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); - else $description.=' '.$langs->trans("DepositsAreIncluded"); - $description.=$fsearch; - $builddate=dol_now(); - - $elementcust=$langs->trans("CustomersInvoices"); - $productcust=$langs->trans("ProductOrService"); - $amountcust=$langs->trans("AmountHT"); - $vatcust=$langs->trans("VATReceived"); - if ($mysoc->tva_assuj) $vatcust.=' ('.$langs->trans("ToPay").')'; - $elementsup=$langs->trans("SuppliersInvoices"); - $productsup=$langs->trans("ProductOrService"); - $amountsup=$langs->trans("AmountHT"); - $vatsup=$langs->trans("VATPaid"); - if ($mysoc->tva_assuj) $vatsup.=' ('.$langs->trans("ToGetBack").')'; +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; } +$description.=$fsearch; +$builddate=dol_now(); + +/*if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.='
'.$langs->trans("DepositsAreNotIncluded"); +} +*/ +if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +// Customers invoices +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("ProductOrService"); +$amountcust=$langs->trans("AmountHT"); +$vatcust=$langs->trans("VATReceived"); +$namecust=$langs->trans("Name"); +if ($mysoc->tva_assuj) { + $vatcust.=' ('.$langs->trans("ToPay").')'; +} + +// Suppliers invoices +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$productcust; +$amountsup=$amountcust; +$vatsup=$langs->trans("VATPaid"); +$namesup=$namecust; +if ($mysoc->tva_assuj) { + $vatsup.=' ('.$langs->trans("ToGetBack").')'; +} + + report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); if($local==1){ $vatcust=$langs->transcountry("LocalTax1", $mysoc->country_code); $vatsup=$langs->transcountry("LocalTax1", $mysoc->country_code); + $vatexpensereport=$langs->transcountry("LocalTax1", $mysoc->country_code); }else{ $vatcust=$langs->transcountry("LocalTax2", $mysoc->country_code); $vatsup=$langs->transcountry("LocalTax2", $mysoc->country_code); + $vatexpensereport=$langs->transcountry("LocalTax2", $mysoc->country_code); } // VAT Received and paid +echo '
'.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").''.$langs->trans("Note").'
'; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index b7d731d786b..37c5b789669 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -411,7 +411,7 @@ print '
'; $formproject->selectTasks($socid?$socid:-1, $taskid, 'taskid', 32, 0, 1, 1); print '
'; print ' '; -print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth200'); +print $formcompany->selectTypeContact($object, '', 'type','internal','rowid', 0, 'maxwidth150onsmartphone'); print ''; print ''; @@ -471,6 +471,19 @@ if (empty($user->rights->user->user->lire)) $includeonly=array($user->id); $moreforfilter.=$form->select_dolusers($search_usertoprocessid?$search_usertoprocessid:$usertoprocess->id, 'search_usertoprocessid', $user->rights->user->user->lire?0:0, null, 0, $includeonly, null, 0, 0, 0, '', 0, '', 'maxwidth200'); $moreforfilter.=''; +if (empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) +{ + $moreforfilter.='
'; + $moreforfilter.='
'.$langs->trans('Project'). '
'; + $moreforfilter.=''; + $moreforfilter.='
'; + + $moreforfilter.='
'; + $moreforfilter.='
'.$langs->trans('ThirdParty'). '
'; + $moreforfilter.=''; + $moreforfilter.='
'; +} + if (! empty($moreforfilter)) { print '
'; @@ -485,9 +498,8 @@ print '
'; print ''."\n"; print ''; -print ''; -print ''; -//print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; print ''; print ''; @@ -505,9 +517,8 @@ print ''; print "\n"; print ''; -print ''; -print ''; -//print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; print ''; print ''; @@ -540,7 +551,7 @@ for ($idw=0; $idw<7; $idw++) print ''; print "\n"; -$colspan=7; +$colspan=5+(empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)?0:2); if ($conf->use_javascript_ajax) { @@ -634,7 +645,7 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; for ($idw = 0; $idw < 7; $idw++) From bf829a4f9febf3ea0d393fbc8cfdbde011cfcaeb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 11:12:41 +0200 Subject: [PATCH 447/609] NEW Add name of day in the timesheet input page per day. --- htdocs/projet/activity/perday.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 9dd57d3c776..dbf99903110 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -357,6 +357,7 @@ $param.=($search_task_label?'&search_task_label='.$search_task_label:''); // Show navigation bar $nav =''.img_previous($langs->trans("Previous"))."\n"; +$nav.=dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"%A").' '; $nav.=" ".dol_print_date(dol_mktime(0,0,0,$month,$day,$year),"day")." \n"; $nav.=''.img_next($langs->trans("Next"))."\n"; $nav.="   (".$langs->trans("Today").")"; From bf3b99163de14b9a4cbf185713ba4ba2e011f00f Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Thu, 26 Apr 2018 11:59:59 +0200 Subject: [PATCH 448/609] NEW : Adds a payment for the list of invoices given as parameter Adds a payment for the list of invoices given as parameter ie : 1 payment for x invoice --- .../facture/class/api_invoices.class.php | 99 ++++++++----------- 1 file changed, 42 insertions(+), 57 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 2a4e2075b2f..667190051de 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -957,7 +957,7 @@ class Invoices extends DolibarrApi * * The model schema is defined by the PaymentData class. * - * @param int $id Id of invoice + * @param array $ids {@from body} Id of invoice {@type int} * @param string $datepaye {@from body} Payment date {@type timestamp} * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} @@ -967,72 +967,60 @@ class Invoices extends DolibarrApi * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * - * @url POST {id}/payments + * @url POST /payments * - * @return int Payment ID + * @return array Payment ID * @throws 400 * @throws 401 * @throws 404 */ - function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { + function addPayment($ids, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { global $conf; - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; - if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($id)) { + foreach($ids as $id) { + if(empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); } - } - - if(empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); - } - - - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); - $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $payment_data; + if (! empty($conf->banque->enabled)) { + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + if(empty($paiementid)) { + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = $newvalue; + } + } $this->db->begin(); - - $amounts = array(); - $multicurrency_amounts = array(); - - // Clean parameters amount if payment is for a credit note - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = -$resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = -$newvalue; - } else { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = $resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = $newvalue; - } - - // Creation of payment line $paiement = new Paiement($this->db); $paiement->datepaye = $datepaye; @@ -1042,17 +1030,14 @@ class Invoices extends DolibarrApi $paiement->paiementcode = dol_getIdFromCode($this->db,$paiementid,'c_paiement','id','code',1); $paiement->num_paiement = $num_paiement; $paiement->note = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } - if (! empty($conf->banque->enabled)) { $label='(CustomerInvoicePayment)'; - if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); } From 00fb4300fc547ec9aec02ab51443eb8ae6d453d8 Mon Sep 17 00:00:00 2001 From: Neil Orley Date: Thu, 26 Apr 2018 12:03:55 +0200 Subject: [PATCH 449/609] FIX : return type change from array to int --- htdocs/compta/facture/class/api_invoices.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 667190051de..a8c29a76754 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -969,7 +969,7 @@ class Invoices extends DolibarrApi * * @url POST /payments * - * @return array Payment ID + * @return int Payment ID * @throws 400 * @throws 401 * @throws 404 From 45c8bbbf74f76995de5bd6cdd6a81db9feb42f8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 12:42:02 +0200 Subject: [PATCH 450/609] NEW Can filter on progression in timesheet --- htdocs/projet/activity/perday.php | 5 ++++- htdocs/projet/activity/perweek.php | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index dbf99903110..9e1c743f77f 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -70,6 +70,7 @@ $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); $search_project_ref=GETPOST('search_project_ref', 'alpha'); $search_thirdparty=GETPOST('search_thirdparty', 'alpha'); +$search_declared_progress=GETPOST('search_declared_progress', 'alpha'); $monthofday=GETPOST('addtimemonth'); $dayofday=GETPOST('addtimeday'); @@ -113,6 +114,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_task_label = ''; $search_project_ref = ''; $search_thirdparty = ''; + $search_declared_progress = ''; } if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) { @@ -331,6 +333,7 @@ if ($search_project_ref) $morewherefilter.=natural_search("p.ref", $search_proje if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all task of opened project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks @@ -469,7 +472,7 @@ if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print 'global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 37c5b789669..61656d79eb5 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -70,6 +70,7 @@ $search_task_ref=GETPOST('search_task_ref', 'alpha'); $search_task_label=GETPOST('search_task_label', 'alpha'); $search_project_ref=GETPOST('search_project_ref', 'alpha'); $search_thirdparty=GETPOST('search_thirdparty', 'alpha'); +$search_declared_progress=GETPOST('search_declared_progress', 'alpha'); $startdayarray=dol_get_first_day_week($day, $month, $year); @@ -124,6 +125,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_task_label = ''; $search_project_ref = ''; $search_thirdparty = ''; + $search_declared_progress = ''; } if (GETPOST("button_search_x",'alpha') || GETPOST("button_search.x",'alpha') || GETPOST("button_search",'alpha')) { @@ -290,6 +292,7 @@ if ($action == 'addtime' && $user->rights->projet->lire) $param.=($search_project_ref?'&search_project_ref='.$search_project_ref:''); $param.=($search_usertoprocessid > 0?'&search_usertoprocessid='.$search_usertoprocessid:''); $param.=($search_thirdparty?'&search_thirdparty='.$search_thirdparty:''); + $param.=($search_declared_progress?'&search_declared_progress='.$search_declared_progress:''); $param.=($search_task_ref?'&search_task_ref='.$search_task_ref:''); $param.=($search_task_label?'&search_task_label='.$search_task_label:''); @@ -333,6 +336,7 @@ if ($search_project_ref) $morewherefilter.=natural_search("p.ref", $search_proje if ($search_task_ref) $morewherefilter.=natural_search("t.ref", $search_task_ref); if ($search_task_label) $morewherefilter.=natural_search(array("t.ref", "t.label"), $search_task_label); if ($search_thirdparty) $morewherefilter.=natural_search("s.nom", $search_thirdparty); +if ($search_declared_progress) $morewherefilter.=natural_search("t.progress", $search_declared_progress, 1); $tasksarray=$taskstatic->getTasksArray(0, 0, ($project->id?$project->id:0), $socid, 0, $search_project_ref, $onlyopenedproject, $morewherefilter, ($search_usertoprocessid?$search_usertoprocessid:0)); // We want to see all tasks of open project i am allowed to see and that match filter, not only my tasks. Later only mine will be editable later. if ($morewherefilter) // Get all task without any filter, so we can show total of time spent for not visible tasks @@ -502,7 +506,7 @@ if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print 'global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; for ($idw=0;$idw<7;$idw++) From 966419254d409232db2d986f0a53977c964946f2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 26 Apr 2018 15:44:15 +0200 Subject: [PATCH 451/609] clean code --- htdocs/admin/ldap.php | 10 ---------- htdocs/admin/ldap_members.php | 31 ----------------------------- htdocs/admin/ldap_members_types.php | 7 ------- htdocs/admin/ldap_users.php | 27 ------------------------- 4 files changed, 75 deletions(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 5655c0c2714..141273a8f8c 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -102,7 +102,6 @@ if (! function_exists("ldap_connect")) } -$var=true; $form=new Form($db); @@ -180,7 +179,6 @@ print ''; print "\n"; // Type - print ''; // Version - print ''; // Serveur primaire - print ''; // Serveur secondaire - print ''; // Port - print ''; // DNserver - print ''; // Utiliser TLS - print ''; print "\n"; // DNAdmin - print ''; // Pass - print ''; -echo '
'.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("RefTask").''.$langs->trans("Project").''.$langs->trans("ThirdParty").''.$langs->trans("Task").''.$langs->trans("PlannedWorkload").''.$langs->trans("ProgressDeclared").'
'; + print ''; print $langs->trans("OtherFilteredTasks"); print ''.$langs->trans("Example").'
'.$langs->trans("Type").''; $arraylist=array(); $arraylist['activedirectory']='Active Directory'; @@ -190,7 +188,6 @@ print $form->selectarray('type',$arraylist,$conf->global->LDAP_SERVER_TYPE); print ' 
'.$langs->trans("Version").''; $arraylist=array(); $arraylist['3']='Version 3'; @@ -199,21 +196,18 @@ print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION',$arraylist,$conf->global- print ''.$langs->trans("LDAPServerProtocolVersion").'
'; print $langs->trans("LDAPPrimaryServer").''; print ''; print ''.$langs->trans("LDAPServerExample").'
'; print $langs->trans("LDAPSecondaryServer").''; print ''; print ''.$langs->trans("LDAPServerExample").'
'.$langs->trans("LDAPServerPort").''; if (! empty($conf->global->LDAP_SERVER_PORT)) { @@ -226,13 +220,11 @@ else print ''.$langs->trans("LDAPServerPortExample").'
'.$langs->trans("LDAPServerDn").''; print ''; print ''.$langs->trans("LDAPServerDnExample").'
'.$langs->trans("LDAPServerUseTLS").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); @@ -245,13 +237,11 @@ print ''.$langs->trans("ForANonAnonymousAccess").'
'.$langs->trans("LDAPAdminDn").''; print ''; print ''.$langs->trans("LDAPAdminDnExample").'
'.$langs->trans("LDAPPassword").''; if (! empty($conf->global->LDAP_ADMIN_PASS)) { diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index a6385c9690c..d363d8811e4 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -133,17 +133,13 @@ dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"), -1); print $langs->trans("LDAPDescMembers").'
'; print '
'; - print ''; -$var=true; - print ''; print ''; print "\n"; // DN Pour les adherents - print ''; @@ -151,7 +147,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -159,7 +154,6 @@ print ''; print ''; // Filter, used to filter search - print ''; @@ -169,7 +163,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeMembers").'
'.$langs->trans("LDAPMemberDn").''; print ''; print ''.$langs->trans("LDAPMemberDnExample").' 
'.$langs->trans("LDAPMemberObjectClassList").''; print ''; print ''.$langs->trans("LDAPMemberObjectClassListExample").' 
'.$langs->trans("LDAPFilterConnection").''; print ''; print ''.$langs->trans("LDAPFilterConnectionExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -180,7 +173,6 @@ print "\n"; // Filtre // Common name - print ''; @@ -188,7 +180,6 @@ print ''; @@ -196,7 +187,6 @@ print ''; @@ -204,7 +194,6 @@ print ''; print ''; // Login unix - print ''; @@ -212,7 +201,6 @@ print ''; @@ -220,7 +208,6 @@ print ''; @@ -228,7 +215,6 @@ print ''; print ''; // Password crypted - print ''; @@ -236,7 +222,6 @@ print ''; print ''; // Mail - print ''; @@ -244,7 +229,6 @@ print ''; @@ -260,7 +244,6 @@ print ''; print ''; // Mobile - print ''; @@ -268,7 +251,6 @@ print ''; print ''; // Skype - print ''; @@ -276,7 +258,6 @@ print ''; print ''; // Fax - print ''; @@ -284,7 +265,6 @@ print ''; print ''; // Company - print ''; @@ -292,7 +272,6 @@ print ''; print ''; // Address - print ''; @@ -300,7 +279,6 @@ print ''; print ''; // ZIP - print ''; @@ -308,7 +286,6 @@ print ''; print ''; // TOWN - print ''; @@ -316,7 +293,6 @@ print ''; print ''; // COUNTRY - print ''; @@ -324,7 +300,6 @@ print ''; print ''; // Description - print ''; @@ -332,7 +307,6 @@ print ''; print ''; // Public Note - print ''; @@ -348,7 +322,6 @@ print ''; print ''; // Status - print ''; @@ -364,7 +337,6 @@ print ''; print ''; // First subscription amount - print ''; @@ -372,7 +344,6 @@ print ''; print ''; // Last subscription date - print ''; @@ -380,7 +351,6 @@ print ''; print ''; // Last subscription amount - print ''; @@ -388,7 +358,6 @@ print ''; print ''; // End last subscriptions - print ''; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 2c08ec9fae8..b5f278a8968 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -108,14 +108,12 @@ print ''; $form=new Form($db); print '
'.$langs->trans("LDAPDolibarrMapping").'
'.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").' 
'.$langs->trans("LDAPFieldLoginUnix").''; print ''; print ''.$langs->trans("LDAPFieldLoginExample").''.$langs->trans("LDAPFieldLoginSamba").''; print ''; print ''.$langs->trans("LDAPFieldLoginSambaExample").''.$langs->trans("LDAPFieldPasswordNotCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldPasswordCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").' 
'.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").' 
'.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").' 
'.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").' 
'.$langs->trans("LDAPFieldCompany").''; print ''; print ''.$langs->trans("LDAPFieldCompanyExample").' 
'.$langs->trans("LDAPFieldAddress").''; print ''; print ''.$langs->trans("LDAPFieldAddressExample").' 
'.$langs->trans("LDAPFieldZip").''; print ''; print ''.$langs->trans("LDAPFieldZipExample").' 
'.$langs->trans("LDAPFieldTown").''; print ''; print ''.$langs->trans("LDAPFieldTownExample").' 
'.$langs->trans("LDAPFieldCountry").''; print ''; print '  
'.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").' 
'.$langs->trans("LDAPFieldNotePublic").''; print ''; print ''.$langs->trans("LDAPFieldNotePublicExample").' 
'.$langs->trans("LDAPFieldStatus").''; print ''; print '  
'.$langs->trans("LDAPFieldFirstSubscriptionAmount").''; print ''; print '  
'.$langs->trans("LDAPFieldLastSubscriptionDate").''; print ''; print '  
'.$langs->trans("LDAPFieldLastSubscriptionAmount").''; print ''; print '  
'.$langs->trans("LDAPFieldEndLastSubscription").''; print ''; print ' 
'; -$var=true; print ''; print ''; print "\n"; // DN pour les types de membres - print ''; @@ -123,7 +121,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -133,7 +130,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeMembersTypes").'
'.$langs->trans("LDAPMemberTypeDn").''; print ''; print ''.$langs->trans("LDAPMemberTypepDnExample").' 
'.$langs->trans("LDAPMemberTypeObjectClassList").''; print ''; print ''.$langs->trans("LDAPMemberTypeObjectClassListExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -144,7 +140,6 @@ print "\n"; // Filtre // Common name - print ''; @@ -152,7 +147,6 @@ print ''; @@ -160,7 +154,6 @@ print ''; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index a2e40abfed2..1181d2860fb 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -124,17 +124,13 @@ print $langs->trans("LDAPDescUsers").'
'; print '
'; - - print '
'.$langs->trans("LDAPDolibarrMapping").'
'.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldCommonNameExample").''.$langs->trans("LDAPFieldDescription").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").''.$langs->trans("LDAPFieldGroupMembers").''; print ''; print ''.$langs->trans("LDAPFieldGroupMembersExample").'
'; -$var=true; print ''; print ''; print "\n"; // DN Pour les utilisateurs - print ''; @@ -142,7 +138,6 @@ print ''; print ''; // List of object class used to define attributes in structure - print ''; @@ -150,7 +145,6 @@ print ''; print ''; // Filter, used to filter search - print ''; @@ -160,7 +154,6 @@ print ''; print '
'.$langs->trans("LDAPSynchronizeUsers").'
'.$langs->trans("LDAPUserDn").''; print ''; print ''.$langs->trans("LDAPUserDnExample").' 
'.$langs->trans("LDAPUserObjectClassList").''; print ''; print ''.$langs->trans("LDAPUserObjectClassListExample").' 
'.$langs->trans("LDAPFilterConnection").''; print ''; print ''.$langs->trans("LDAPFilterConnectionExample").'
'; print '
'; print ''; -$var=true; print ''; print ''; @@ -169,7 +162,6 @@ print ''; print "\n"; // Common name - print ''; @@ -177,7 +169,6 @@ print ''; @@ -185,7 +176,6 @@ print ''; @@ -193,7 +183,6 @@ print ''; @@ -201,7 +190,6 @@ print ''; @@ -209,7 +197,6 @@ print ''; @@ -217,7 +204,6 @@ print ''; print ''; // Password crypted - print ''; @@ -225,7 +211,6 @@ print ''; print ''; // Mail - print ''; @@ -233,7 +218,6 @@ print ''; @@ -241,7 +225,6 @@ print ''; @@ -249,7 +232,6 @@ print ''; @@ -257,7 +239,6 @@ print ''; @@ -265,7 +246,6 @@ print ''; @@ -273,7 +253,6 @@ print ''; print ''; // Address - print ''; @@ -281,7 +260,6 @@ print ''; print ''; // ZIP - print ''; @@ -289,7 +267,6 @@ print ''; print ''; // TOWN - print ''; @@ -297,7 +274,6 @@ print ''; print ''; // COUNTRY - print ''; @@ -305,7 +281,6 @@ print ''; print ''; // Title - print ''; @@ -313,7 +288,6 @@ print ''; print ''; // Note - print ''; @@ -321,7 +295,6 @@ print ''; print ''; // Sid - print ''; From 14e68ea8f91deb15c0dc45b1fc234781a422db15 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Thu, 26 Apr 2018 16:42:08 +0200 Subject: [PATCH 452/609] Allow qty to be negative --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d2511d2125c..4cd851bc08e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1703,7 +1703,7 @@ class CommandeFournisseur extends CommonOrder $this->error='ErrorBadValueForParameterWarehouse'; return -1; } - if ($qty <= 0) + if ($qty == 0) { $this->error='ErrorBadValueForParameterQty'; return -1; From 761d2b3667dc6bddb8c0ecf6ca950532be548f85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 17:44:36 +0200 Subject: [PATCH 453/609] FIX Not approved holidays must not be visible into timesheet --- htdocs/holiday/class/holiday.class.php | 10 ++++++---- htdocs/projet/activity/perday.php | 3 ++- htdocs/projet/activity/perweek.php | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 950c297fb3b..c8f73111021 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -779,25 +779,27 @@ class Holiday extends CommonObject /** - * Check a user is not on holiday for a particular timestamp + * Check that a user is not on holiday for a particular timestamp * * @param int $fk_user Id user * @param timestamp $timestamp Time stamp date for a day (YYYY-MM-DD) without hours (= 12:00AM in english and not 12:00PM that is 12:00) + * @param string $status Filter on holiday status. '-1' = no filter. * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP */ - function verifDateHolidayForTimestamp($fk_user, $timestamp) + function verifDateHolidayForTimestamp($fk_user, $timestamp, $status='-1') { global $langs, $conf; $isavailablemorning=true; $isavailableafternoon=true; - $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday"; + $sql = "SELECT cp.rowid, cp.date_debut as date_start, cp.date_fin as date_end, cp.halfday, cp.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday as cp"; $sql.= " WHERE cp.entity IN (".getEntity('holiday').")"; $sql.= " AND cp.fk_user = ".(int) $fk_user; - $sql.= " AND date_debut <= '".$this->db->idate($timestamp)."' AND date_fin >= '".$this->db->idate($timestamp)."'"; + $sql.= " AND cp.date_debut <= '".$this->db->idate($timestamp)."' AND cp.date_fin >= '".$this->db->idate($timestamp)."'"; + if ($status != '-1') $sql.=" AND cp.statut IN (".$this->db->escape($status).")"; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index f30b0ac4757..7615ee75c20 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -496,7 +496,8 @@ $restrictviewformytask=(empty($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED $holiday = new Holiday($db); $isavailable=array(); -$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse); // $daytoparse is a date with hours = 0 +$statusofholidaytocheck = '3'; +$isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $daytoparse, $statusofholiday); // $daytoparse is a date with hours = 0 $isavailable[$daytoparse]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day if (count($tasksarray) > 0) diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index a3c8c9ebe54..f60eaf89375 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -503,7 +503,8 @@ for ($i=0;$i<7;$i++) //print dol_print_date($dayinloopwithouthours, 'dayhour').' '; //print dol_print_date($dayinloopfromfirstdaytoshow, 'dayhour').'
'; - $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow); + $statusofholidaytocheck = '3'; + $isavailablefordayanduser = $holiday->verifDateHolidayForTimestamp($usertoprocess->id, $dayinloopfromfirstdaytoshow, $statusofholidaytocheck); $isavailable[$dayinloopfromfirstdaytoshow]=$isavailablefordayanduser; // in projectLinesPerWeek later, we are using $firstdaytoshow and dol_time_plus_duree to loop on each day print '
'; } From 46a8511c69a9d485f4e05edc20cdfc0554eac0e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 Apr 2018 18:25:57 +0200 Subject: [PATCH 454/609] Look and feel v8 (delete button in end of list) --- htdocs/holiday/card.php | 19 ++++++++----------- htdocs/holiday/class/holiday.class.php | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index c653c756bba..e5b35b5a434 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1279,20 +1279,15 @@ else print '
'; // Boutons d'actions - if ($cancreate && $object->statut == 1) + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) { print ''.$langs->trans("EditCP").''; } - if ($cancreate && $object->statut == 1) // If draft + if ($cancreate && $object->statut == Holiday::STATUS_DRAFT) // If draft { print ''.$langs->trans("Validate").''; } - if ($user->rights->holiday->delete && ($object->statut == 1 || $object->statut == 4 || $object->statut == 5)) // If draft or canceled or refused - { - print ''.$langs->trans("DeleteCP").''; - } - - if ($object->statut == 2) // If validated + if ($object->statut == Holiday::STATUS_VALIDATED) // If validated { if ($user->id == $object->fk_validator) { @@ -1305,17 +1300,19 @@ else print ''.$langs->trans("ActionRefuseCP").''; } } - if (($user->id == $object->fk_validator || in_array($object->fk_user, $childids) || ! empty($user->rights->holiday->write_all)) && ($object->statut == 2 || $object->statut == 3)) // Status validated or approved { if (($object->date_debut > dol_now()) || $user->admin) print ''.$langs->trans("ActionCancelCP").''; else print ''.$langs->trans("ActionCancelCP").''; } - - if ($cancreate && $object->statut == 4) + if ($cancreate && $object->statut == Holiday::STATUS_CANCELED) { print ''.$langs->trans("SetToDraft").''; } + if ($user->rights->holiday->delete && ($object->statut == Holiday::STATUS_DRAFT || $object->statut == Holiday::STATUS_CANCELED || $object->statut == Holiday::STATUS_REFUSED)) // If draft or canceled or refused + { + print ''.$langs->trans("DeleteCP").''; + } print '
'; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c034db59c57..490db17fef0 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -71,6 +71,27 @@ class Holiday extends CommonObject var $optValue = ''; var $optRowid = ''; + /** + * Draft status + */ + const STATUS_DRAFT = 1; + /** + * Validated status + */ + const STATUS_VALIDATED = 2; + /** + * Approved + */ + const STATUS_APPROVED = 3; + /** + * Canceled + */ + const STATUS_CANCELED = 4; + /** + * Refused + */ + const STATUS_REFUSED = 5; + /** * Constructor From 1fb6f797275569a8a04d5c7596a4e1f2bc59ac7b Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Fri, 27 Apr 2018 09:14:52 +0200 Subject: [PATCH 455/609] Update dispatch.php Only without batch module enabled --- htdocs/fourn/commande/dispatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 1e35af900e6..ba37547ea9f 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -237,7 +237,7 @@ if ($action == 'dispatch' && $user->rights->fournisseur->commande->receptionner) $fk_commandefourndet = "fk_commandefourndet_" . $reg[1] . '_' . $reg[2]; // We ask to move a qty - if (GETPOST($qty) > 0) { + if (GETPOST($qty) != 0) { if (! (GETPOST($ent, 'int') > 0)) { dol_syslog('No dispatch for line ' . $key . ' as no warehouse choosed'); $text = $langs->transnoentities('Warehouse') . ', ' . $langs->transnoentities('Line') . ' ' . ($numline); From 59e5545aa7d7368eafb1ac47d3e9756814773859 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 09:18:25 +0200 Subject: [PATCH 456/609] Fix phpunit --- htdocs/core/lib/price.lib.php | 19 +++++-- .../class/fournisseur.commande.class.php | 3 +- test/phpunit/CommandeFournisseurTest.php | 54 +++++++++++++++++-- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index eb332b44611..de5379f46ec 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -155,11 +155,22 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // pu calculation from pu_devise if pu empty - if(empty($pu) && !empty($pu_devise)) { - $pu = $pu_devise / $multicurrency_tx; + if (empty($pu) && !empty($pu_devise)) { + if (! empty($multicurrency_tx)) $pu = $pu_devise / $multicurrency_tx; + else + { + dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (multicurrency_tx empty when pu_devise not) ', LOG_ERR); + return array(); + } } - if(empty($pu_devise) && !empty($multicurrency_tx)) { - $pu_devise = $pu * $multicurrency_tx; + // pu_devise calculation from pu + if (empty($pu_devise) && !empty($multicurrency_tx)) { + if (is_numeric($pu) && is_numeric($multicurrency_tx)) $pu_devise = $pu * $multicurrency_tx; + else + { + dol_syslog('Price.lib::calcul_price_total function called with bad parameters combination (pu or multicurrency_tx are not numeric)', LOG_ERR); + return array(); + } } // initialize total (may be HT or TTC depending on price_base_type) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d2511d2125c..0ae72b8f96d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1445,7 +1445,7 @@ class CommandeFournisseur extends CommonOrder $error = 0; - dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit"); + dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $info_bits $notrigger $date_start $date_end $fk_unit $pu_ht_devise $origin $origin_id"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters @@ -1500,6 +1500,7 @@ class CommandeFournisseur extends CommonOrder // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + if ($result > 0) { $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 33271a07dcc..7b2f3f07e2b 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -142,26 +142,32 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase $ref_fourn='SUPPLIER_REF_PHPUNIT'; $tva_tx=19.6; - // Create supplier price + // Delete existing supplier prices + // TODO + + // Create 1 supplier price with min qty = 10; $result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice $this->assertGreaterThanOrEqual(1, $result); $result=$product->update_buyprice($quantity, 20, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0); $this->assertGreaterThanOrEqual(0, $result); - // Create supplier order with a too low quantity + // Create supplier order with a too low quantity and option SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY is on + $conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY = 1; + $localobject=new CommandeFournisseur($db); $localobject->initAsSpecimen(); $localobject->lines=array(); // Overwrite lines of order $line=new CommandeFournisseurLigne($db); - $line->desc=$langs->trans("Description")." specimen line too low"; + $line->desc=$langs->trans("Description")." specimen line with qty too low"; $line->qty=1; // So lower than $quantity + $line->subprice=100; $line->fk_product=$product->id; $line->ref_fourn=$ref_fourn; $localobject->lines[]=$line; $result=$localobject->create($user); print __METHOD__." result=".$result."\n"; - $this->assertEquals(-1, $result); // must be -1 because quantity is lower than minimum of supplier price + $this->assertEquals(-1, $result, 'Creation of too low quantity'); // must be -1 because quantity is lower than minimum of supplier price $sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''"; $db->query($sql); @@ -173,6 +179,7 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase $line=new CommandeFournisseurLigne($db); $line->desc=$langs->trans("Description")." specimen line ok"; $line->qty=10; // So enough quantity + $line->subprice=100; $line->fk_product=$product->id; $line->ref_fourn=$ref_fourn; $localobject2->lines[]=$line; @@ -181,6 +188,45 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertGreaterThan(0, $result); + + // Create supplier order with a too low quantity but option SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY is off + $conf->global->SUPPLIER_ORDER_WITH_PREDEFINED_PRICES_ONLY = 0; + + $localobject3=new CommandeFournisseur($db); + $localobject3->initAsSpecimen(); + $localobject3->lines=array(); // Overwrite lines of order + $line=new CommandeFournisseurLigne($db); + $line->desc=$langs->trans("Description")." specimen line with qty too low"; + $line->qty=1; // So lower than $quantity + $line->subprice=100; + $line->fk_product=$product->id; + $line->ref_fourn=$ref_fourn; + $localobject3->lines[]=$line; + + $result=$localobject3->create($user); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThan(0, $result, 'Creation of too low quantity should be ok'); // must be id of line because there is no test on minimum quantity + + $sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''"; + $db->query($sql); + + // Create supplier order + $localobject4=new CommandeFournisseur($db); + $localobject4->initAsSpecimen(); // This create 5 lines of first product found for socid 1 + $localobject4->lines=array(); // Overwrite lines of order + $line=new CommandeFournisseurLigne($db); + $line->desc=$langs->trans("Description")." specimen line ok"; + $line->qty=10; // So enough quantity + $line->subprice=100; + $line->fk_product=$product->id; + $line->ref_fourn=$ref_fourn; + $localobject4->lines[]=$line; + + $result=$localobject4->create($user); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThan(0, $result); + + return $result; } From e1cfe0e2dd2356ac5bf08696db02eab34e840832 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 09:49:15 +0200 Subject: [PATCH 457/609] Update date.lib.php --- htdocs/core/lib/date.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 86f2b5d727a..9e654edbaff 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -583,7 +583,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $ { $countryfound=1; - // Définition des dates fériées fixes + // Definition of fixed working days if($jour == 1 && $mois == 1) $ferie=true; // 1er janvier if($jour == 1 && $mois == 5) $ferie=true; // 1er mai if($jour == 8 && $mois == 5) $ferie=true; // 5 mai @@ -593,14 +593,14 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $ if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre - // Calcul du jour de Pâques + // Calculation for easter date $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; // Pâques - // Calcul du jour du lundi de Pâques + // Calculation for the monday of easter date $date_lundi_paques = mktime( date("H", $date_paques), date("i", $date_paques), @@ -614,7 +614,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $ if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; // Lundi de Pâques - // Calcul du jour de l'ascension (38 jours apres Pâques) + // Calcul du jour de l'ascension (38 days after easter day) $date_ascension = mktime( date("H", $date_paques), date("i", $date_paques), @@ -628,7 +628,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $ if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; // Ascension - // Calcul de Pentecôte (11 jours apres Pâques) + // Calculation of "Pentecote" (11 days after easter day) $date_pentecote = mktime( date("H", $date_paques), date("i", $date_paques), From dde86628e709fa3a8726bce2bbb98f4eeb5c5e7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 09:49:52 +0200 Subject: [PATCH 458/609] Update date.lib.php --- htdocs/core/lib/date.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 9e654edbaff..a3f945a05a4 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -584,14 +584,14 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $ $countryfound=1; // Definition of fixed working days - if($jour == 1 && $mois == 1) $ferie=true; // 1er janvier - if($jour == 1 && $mois == 5) $ferie=true; // 1er mai - if($jour == 8 && $mois == 5) $ferie=true; // 5 mai - if($jour == 14 && $mois == 7) $ferie=true; // 14 juillet - if($jour == 15 && $mois == 8) $ferie=true; // 15 août - if($jour == 1 && $mois == 11) $ferie=true; // 1 novembre - if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre - if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre + if($jour == 1 && $mois == 1) $ferie=true; // 1er january + if($jour == 1 && $mois == 5) $ferie=true; // 1er may + if($jour == 8 && $mois == 5) $ferie=true; // 5 may + if($jour == 14 && $mois == 7) $ferie=true; // 14 july + if($jour == 15 && $mois == 8) $ferie=true; // 15 august + if($jour == 1 && $mois == 11) $ferie=true; // 1 november + if($jour == 11 && $mois == 11) $ferie=true; // 11 november + if($jour == 25 && $mois == 12) $ferie=true; // 25 december // Calculation for easter date $date_paques = easter_date($annee); From 42722da82463dc4088966ff12c65c0ac56896d24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 09:55:44 +0200 Subject: [PATCH 459/609] Update date.lib.php --- htdocs/core/lib/date.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index a3f945a05a4..ee3b575d5d1 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -640,7 +640,7 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR', $ $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; - // Pentecôte + // "Pentecote" // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); From aa30b946b67ae182332605b6fb023da2c81c4f33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 10:18:22 +0200 Subject: [PATCH 460/609] Fix from #8677 --- htdocs/compta/stats/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index a4c32302a47..846de3a2611 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -71,7 +71,6 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $month_end=$month_start-1; if ($month_end < 1) $month_end=12; - else $year_end++; } else $month_end=$month_start; $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); From c40b50ca719dd0aef496a1320f2541d7c511721f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 10:23:09 +0200 Subject: [PATCH 461/609] Fix typo --- htdocs/compta/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index a665e976145..eb26015615c 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -492,7 +492,7 @@ for ($annee = $year_start ; $annee <= $year_end ; $annee++) } if (! $total[$annee-1] && $total[$annee]) { - print '
'; + print ''; } if (! $total[$annee-1] && ! $total[$annee]) { From df9f4d319334a1f67c9eb62380dd377add9c787e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 10:40:27 +0200 Subject: [PATCH 462/609] Revert "NEW : Adds a contact to an invoice with REST API" --- .../facture/class/api_invoices.class.php | 148 +++++++----------- 1 file changed, 55 insertions(+), 93 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index a8c29a76754..f3aab82422f 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -562,59 +562,6 @@ class Invoices extends DolibarrApi return $updateRes; } - /** - * Adds a contact to an invoice - * - * @param int $id Order ID - * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link - * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING - * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) - * @param int $notrigger Disable all triggers - * - * @url POST {id}/contacts - * - * @return array - * - * @throws 200 - * @throws 304 - * @throws 401 - * @throws 404 - * @throws 500 - * - */ - function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger=0) - { - if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $result = $this->invoice->add_contact($fk_socpeople,$type_contact,$source,$notrigger); - if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); - } - - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - return $this->_cleanObjectDatas($this->invoice); - } - - - /** * Sets an invoice as draft * @@ -957,7 +904,7 @@ class Invoices extends DolibarrApi * * The model schema is defined by the PaymentData class. * - * @param array $ids {@from body} Id of invoice {@type int} + * @param int $id Id of invoice * @param string $datepaye {@from body} Payment date {@type timestamp} * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} @@ -967,60 +914,72 @@ class Invoices extends DolibarrApi * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * - * @url POST /payments + * @url POST {id}/payments * * @return int Payment ID * @throws 400 * @throws 401 * @throws 404 */ - function addPayment($ids, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { + function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { global $conf; + require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; + if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - foreach($ids as $id) { - if(empty($id)) { + if(empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); - } - if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! empty($conf->banque->enabled)) { + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); } - $request_data = (object) $payment_data; - if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); - } - } - if(empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); - } - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); - $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - // Clean parameters amount if payment is for a credit note - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = -$resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = -$newvalue; - } else { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = $resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = $newvalue; - } - } + } + + if(empty($paiementid)) { + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + } + + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $this->db->begin(); + + $amounts = array(); + $multicurrency_amounts = array(); + + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = $newvalue; + } + + // Creation of payment line $paiement = new Paiement($this->db); $paiement->datepaye = $datepaye; @@ -1030,14 +989,17 @@ class Invoices extends DolibarrApi $paiement->paiementcode = dol_getIdFromCode($this->db,$paiementid,'c_paiement','id','code',1); $paiement->num_paiement = $num_paiement; $paiement->note = $comment; + $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } + if (! empty($conf->banque->enabled)) { $label='(CustomerInvoicePayment)'; + if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); } From 290635838323f6d3f95942f9e7834251570803d9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 27 Apr 2018 10:42:10 +0200 Subject: [PATCH 463/609] Fix: use "socpeople" instead "societe" --- htdocs/comm/action/index.php | 2 +- htdocs/comm/contact.php | 2 +- htdocs/contact/class/contact.class.php | 5 ++++- htdocs/contact/list.php | 2 +- htdocs/core/boxes/box_contacts.php | 2 +- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/class/html.form.class.php | 2 +- .../modules/mailings/advthirdparties.modules.php | 2 +- htdocs/core/modules/mailings/contacts1.modules.php | 14 +++++++------- htdocs/core/modules/modSociete.class.php | 2 +- htdocs/ticketsup/class/ticketsup.class.php | 2 +- 11 files changed, 21 insertions(+), 18 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 0fedb83d524..d967d94e9e1 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -680,7 +680,7 @@ if ($showbirthday) $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday'; $sql.= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp'; $sql.= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))'; - $sql.= " AND sp.entity IN (".getEntity('societe').")"; + $sql.= " AND sp.entity IN (".getEntity('socpeople').")"; if ($action == 'show_day') { $sql.= ' AND MONTH(birthday) = '.$month; diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 1460abe9823..fe2e3027dcf 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -78,7 +78,7 @@ if (! $user->rights->societe->client->voir && ! $socid) $sql .= " ".MAIN_DB_PREF $sql.= " ".MAIN_DB_PREFIX."socpeople as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc"; $sql.= " WHERE s.fk_stcomm = st.id"; -$sql.= " AND p.entity IN (".getEntity('societe').")"; +$sql.= " AND p.entity IN (".getEntity('socpeople').")"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($type == "c") $sql.= " AND s.client IN (1, 3)"; if ($type == "p") $sql.= " AND s.client IN (2, 3)"; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index e63cfa3da99..5053e07212f 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -687,7 +687,10 @@ class Contact extends CommonObject $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; if ($id) $sql.= " WHERE c.rowid = ". $id; - elseif ($ref_ext) $sql .= " WHERE c.ref_ext = '".$this->db->escape($ref_ext)."'"; + elseif ($ref_ext) { + $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; + $sql .= " AND c.ref_ext = '".$this->db->escape($ref_ext)."'"; + } $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 0660b394f1b..8719c77f1b4 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -260,7 +260,7 @@ if (! empty($search_categ)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_conta if (! empty($search_categ_thirdparty)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ if (! empty($search_categ_supplier)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; -$sql.= ' WHERE p.entity IN ('.getEntity('societe').')'; +$sql.= ' WHERE p.entity IN ('.getEntity('socpeople').')'; if (!$user->rights->societe->client->voir && !$socid) //restriction { $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)"; diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 936d269f82a..a8dc7f1231d 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -85,7 +85,7 @@ class box_contacts extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($user->societe_id) $sql.= " AND sp.fk_soc = ".$user->societe_id; $sql.= " ORDER BY sp.tms DESC"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b70f5d424c..0fbd5b05949 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1116,7 +1116,7 @@ abstract class CommonObject $sql.= " WHERE ec.element_id = ".$id; $sql.= " AND ec.fk_socpeople = c.rowid"; if ($source == 'internal') $sql.= " AND c.entity IN (0,".$conf->entity.")"; - if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")"; + if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('socpeople').")"; $sql.= " AND ec.fk_c_type_contact = tc.rowid"; $sql.= " AND tc.element = '".$element."'"; $sql.= " AND tc.source = '".$source."'"; @@ -5582,7 +5582,7 @@ abstract class CommonObject $("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() { $("'.dol_escape_js($newInput).'").insertBefore(this); }); - + $(document).on("click", "a.'.dol_escape_js($keyprefix.$key.$keysuffix).'_del", function() { $(this).parent().remove(); }); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ccd873ece8a..c02ada175fd 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1332,7 +1332,7 @@ class Form if ($showsoc > 0) $sql.= " , s.nom as company"; $sql.= " FROM ".MAIN_DB_PREFIX ."socpeople as sp"; if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid; if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0"; $sql.= " ORDER BY sp.lastname ASC"; diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index e6f0255b9d9..38636396da5 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -122,7 +122,7 @@ class mailing_advthirdparties extends MailingTargets { $sql= "SELECT socp.rowid as id, socp.email as email, socp.lastname as lastname, socp.firstname as firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as socp"; - $sql.= " WHERE socp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE socp.entity IN (".getEntity('socpeople').")"; if (count($contactid)>0) { $sql.= " AND socp.rowid IN (".implode(',',$contactid).")"; } diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 8aae15b9cc8..90d81dca4a5 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -71,7 +71,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0] = "SELECT '".$langs->trans("NbOfCompaniesContacts")."' as label,"; $statssql[0].= " count(distinct(c.email)) as nb"; $statssql[0].= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $statssql[0].= " WHERE c.entity IN (".getEntity('societe').")"; + $statssql[0].= " WHERE c.entity IN (".getEntity('socpeople').")"; $statssql[0].= " AND c.email != ''"; // Note that null != '' is false $statssql[0].= " AND c.no_email = 0"; $statssql[0].= " AND c.statut = 1"; @@ -95,7 +95,7 @@ class mailing_contacts1 extends MailingTargets $sql = "SELECT count(distinct(c.email)) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - $sql.= " WHERE c.entity IN (".getEntity('societe').")"; + $sql.= " WHERE c.entity IN (".getEntity('socpeople').")"; $sql.= " AND c.email != ''"; // Note that null != '' is false $sql.= " AND c.no_email = 0"; $sql.= " AND c.statut = 1"; @@ -123,7 +123,7 @@ class mailing_contacts1 extends MailingTargets // Add filter on job position $sql = "SELECT sp.poste, count(distinct(sp.email)) AS nb"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; /*$sql.= " AND sp.email != ''"; // Note that null != '' is false $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1";*/ @@ -161,7 +161,7 @@ class mailing_contacts1 extends MailingTargets $sql.= " WHERE sp.statut = 1"; // Note that null != '' is false //$sql.= " AND sp.no_email = 0"; //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('societe').")"; + //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_socpeople = sp.rowid"; $sql.= " GROUP BY c.label"; @@ -236,7 +236,7 @@ class mailing_contacts1 extends MailingTargets $sql.= " WHERE sp.statut = 1"; // Note that null != '' is false //$sql.= " AND sp.no_email = 0"; //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('societe').")"; + //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_soc = sp.fk_soc"; $sql.= " GROUP BY c.label"; @@ -278,7 +278,7 @@ class mailing_contacts1 extends MailingTargets $sql.= " WHERE sp.statut = 1"; // Note that null != '' is false //$sql.= " AND sp.no_email = 0"; //$sql.= " AND sp.email != ''"; - //$sql.= " AND sp.entity IN (".getEntity('societe').")"; + //$sql.= " AND sp.entity IN (".getEntity('socpeople').")"; $sql.= " AND cs.fk_categorie = c.rowid"; $sql.= " AND cs.fk_soc = sp.fk_soc"; $sql.= " GROUP BY c.label"; @@ -374,7 +374,7 @@ class mailing_contacts1 extends MailingTargets if ($filter_category_customer <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_societe as c2s"; if ($filter_category_supplier <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie as c3"; if ($filter_category_supplier <> 'all') $sql.= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s"; - $sql.= " WHERE sp.entity IN (".getEntity('societe').")"; + $sql.= " WHERE sp.entity IN (".getEntity('socpeople').")"; $sql.= " AND sp.email <> ''"; $sql.= " AND sp.no_email = 0"; $sql.= " AND sp.statut = 1"; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 711e2ead71c..8df1bb4a8bb 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -322,7 +322,7 @@ class modSociete extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON c.fk_departement = d.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON c.fk_pays = co.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = c.rowid'; - $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('societe').')'; + $this->export_sql_end[$r] .=' WHERE c.entity IN ('.getEntity('socpeople').')'; if (is_object($user) && empty($user->rights->societe->client->voir)) { $this->export_sql_end[$r] .=' AND (sc.fk_user = '.$user->id.' '; if (! empty($conf->global->SOCIETE_EXPORT_SUBORDINATES_CHILDS)) { diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index d8922a94b24..a8b8e7f5479 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -1934,7 +1934,7 @@ class Ticketsup extends CommonObject // Generation requete recherche $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "socpeople"; - $sql .= " WHERE entity IN (" . getEntity('ticketsup', 1) . ")"; + $sql .= " WHERE entity IN (" . getEntity('socpeople') . ")"; if (!empty($socid)) { $sql .= " AND fk_soc='" . $this->db->escape($socid) . "'"; } From 469d909126e14f9a873a66e1b5a2a3f1370e1b36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 10:46:09 +0200 Subject: [PATCH 464/609] Revert "Revert "NEW : Adds a contact to an invoice with REST API"" --- .../facture/class/api_invoices.class.php | 150 +++++++++++------- 1 file changed, 94 insertions(+), 56 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index f3aab82422f..a8c29a76754 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -562,6 +562,59 @@ class Invoices extends DolibarrApi return $updateRes; } + /** + * Adds a contact to an invoice + * + * @param int $id Order ID + * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link + * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING + * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) + * @param int $notrigger Disable all triggers + * + * @url POST {id}/contacts + * + * @return array + * + * @throws 200 + * @throws 304 + * @throws 401 + * @throws 404 + * @throws 500 + * + */ + function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger=0) + { + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->invoice->add_contact($fk_socpeople,$type_contact,$source,$notrigger); + if ($result < 0) { + throw new RestException(500, 'Error : '.$this->invoice->error); + } + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$this->invoice->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + return $this->_cleanObjectDatas($this->invoice); + } + + + /** * Sets an invoice as draft * @@ -904,7 +957,7 @@ class Invoices extends DolibarrApi * * The model schema is defined by the PaymentData class. * - * @param int $id Id of invoice + * @param array $ids {@from body} Id of invoice {@type int} * @param string $datepaye {@from body} Payment date {@type timestamp} * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} @@ -914,72 +967,60 @@ class Invoices extends DolibarrApi * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * - * @url POST {id}/payments + * @url POST /payments * * @return int Payment ID * @throws 400 * @throws 401 * @throws 404 */ - function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { + function addPayment($ids, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { global $conf; - require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; - if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($id)) { + foreach($ids as $id) { + if(empty($id)) { throw new RestException(400, 'Invoice ID is mandatory'); - } - - if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); } - } - - if(empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); - } - - - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - - // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); - $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); - + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $payment_data; + if (! empty($conf->banque->enabled)) { + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + if(empty($paiementid)) { + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = $newvalue; + } + } $this->db->begin(); - - $amounts = array(); - $multicurrency_amounts = array(); - - // Clean parameters amount if payment is for a credit note - if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = -$resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = -$newvalue; - } else { - $resteapayer = price2num($resteapayer,'MT'); - $amounts[$id] = $resteapayer; - // Multicurrency - $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); - $multicurrency_amounts[$id] = $newvalue; - } - - // Creation of payment line $paiement = new Paiement($this->db); $paiement->datepaye = $datepaye; @@ -989,17 +1030,14 @@ class Invoices extends DolibarrApi $paiement->paiementcode = dol_getIdFromCode($this->db,$paiementid,'c_paiement','id','code',1); $paiement->num_paiement = $num_paiement; $paiement->note = $comment; - $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) { $this->db->rollback(); throw new RestException(400, 'Payment error : '.$paiement->error); } - if (! empty($conf->banque->enabled)) { $label='(CustomerInvoicePayment)'; - if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); } From e3142fff39325431eb3379596d2c840e9a9dd963 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 11:38:31 +0200 Subject: [PATCH 465/609] NEW Add method to register distributed payments on invoices --- .../facture/class/api_invoices.class.php | 219 +++++++++++++++--- 1 file changed, 181 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index a8c29a76754..35f7e966104 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -569,7 +569,7 @@ class Invoices extends DolibarrApi * @param int $fk_socpeople Id of thirdparty contact (if source = 'external') or id of user (if souce = 'internal') to link * @param string $type_contact Type of contact (code). Must a code found into table llx_c_type_contact. For example: BILLING * @param string $source external=Contact extern (llx_socpeople), internal=Contact intern (llx_user) - * @param int $notrigger Disable all triggers + * @param int $notrigger Disable all triggers * * @url POST {id}/contacts * @@ -952,14 +952,13 @@ class Invoices extends DolibarrApi return $result; } - /** - * Add payment line to a specific invoice + + /** + * Add payment line to a specific invoice with the remain to pay as amount. * - * The model schema is defined by the PaymentData class. - * - * @param array $ids {@from body} Id of invoice {@type int} - * @param string $datepaye {@from body} Payment date {@type timestamp} - * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param int $id Id of invoice + * @param string $datepaye {@from body} Payment date {@type timestamp} + * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} * @param int $accountid {@from body} Account Id {@min 1} * @param string $num_paiement {@from body} Payment number (optional) @@ -967,44 +966,186 @@ class Invoices extends DolibarrApi * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') * @param string $chqbank {@from body} Issuer bank name (optional) * - * @url POST /payments + * @url POST {id}/payments * * @return int Payment ID * @throws 400 * @throws 401 * @throws 404 */ - function addPayment($ids, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { + function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') { + global $conf; + + require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; + + if(! DolibarrApiAccess::$user->rights->facture->creer) { + throw new RestException(403); + } + if(empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory'); + } + + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + if (! empty($conf->banque->enabled)) { + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + + if(empty($paiementid)) { + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + } + + + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } + + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + + $this->db->begin(); + + $amounts = array(); + $multicurrency_amounts = array(); + + // Clean parameters amount if payment is for a credit note + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = -$resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = -$newvalue; + } else { + $resteapayer = price2num($resteapayer,'MT'); + $amounts[$id] = $resteapayer; + // Multicurrency + $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); + $multicurrency_amounts[$id] = $newvalue; + } + + + // Creation of payment line + $paiement = new Paiement($this->db); + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id + $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching + $paiement->paiementid = $paiementid; + $paiement->paiementcode = dol_getIdFromCode($this->db,$paiementid,'c_paiement','id','code',1); + $paiement->num_paiement = $num_paiement; + $paiement->note = $comment; + + $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices + if ($paiement_id < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Payment error : '.$paiement->error); + } + + if (! empty($conf->banque->enabled)) { + $label='(CustomerInvoicePayment)'; + + if($paiement->paiementcode == 'CHQ' && empty($chqemetteur)) { + throw new RestException(400, 'Emetteur is mandatory when payment code is '.$paiement->paiementcode); + } + if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) $label='(CustomerInvoicePaymentBack)'; // Refund of a credit note + $result=$paiement->addPaymentToBank(DolibarrApiAccess::$user,'payment',$label,$accountid,$chqemetteur,$chqbank); + if ($result < 0) + { + $this->db->rollback(); + throw new RestException(400, 'Add payment to bank error : '.$paiement->error); + } + } + + $this->db->commit(); + + return $paiement_id; + } + + /** + * Add a payment to pay partially or completely one or several invoices. + * Warning: Take care that all invoices are owned by the same customer. + * + * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice. Example {"1": "99.99", "2": "10"} + * @param string $datepaye {@from body} Payment date {@type timestamp} + * @param int $paiementid {@from body} Payment mode Id {@min 1} + * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} + * @param int $accountid {@from body} Account Id {@min 1} + * @param string $num_paiement {@from body} Payment number (optional) + * @param string $comment {@from body} Note (optional) + * @param string $chqemetteur {@from body} Payment issuer (mandatory if paiementcode = 'CHQ') + * @param string $chqbank {@from body} Issuer bank name (optional) + * + * @url POST /paymentsdistributed + * + * @return int Payment ID + * @throws 400 + * @throws 401 + * @throws 403 + * @throws 404 + */ + function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement='', $comment='', $chqemetteur='', $chqbank='') + { global $conf; + require_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; + if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(403); } - foreach($ids as $id) { - if(empty($id)) { - throw new RestException(400, 'Invoice ID is mandatory'); - } - if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $payment_data; - if (! empty($conf->banque->enabled)) { - if(empty($accountid)) { - throw new RestException(400, 'Account ID is mandatory'); - } - } - if(empty($paiementid)) { - throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); - } - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } - // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); - $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); - $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + foreach($arrayofamounts as $id => $amount) { + if(empty($id)) { + throw new RestException(400, 'Invoice ID is mandatory. Fill the invoice id and amount into arrayofamounts parameter. For example: {"1": "99.99", "2": "10"}'); + } + if( ! DolibarrApi::_checkAccessToResource('facture',$id)) { + throw new RestException(403, 'Access not allowed on invoice ID '.$id.' for login '.DolibarrApiAccess::$user->login); + } + } + + if (! empty($conf->banque->enabled)) { + if(empty($accountid)) { + throw new RestException(400, 'Account ID is mandatory'); + } + } + if(empty($paiementid)) { + throw new RestException(400, 'Paiement ID or Paiement Code is mandatory'); + } + + $this->db->begin(); + + $amounts = array(); + $multicurrency_amounts = array(); + + // Loop on each invoice to pay + foreach($arrayofamounts as $id => $amount) + { + $result = $this->invoice->fetch($id); + if( ! $result ) { + $this->db->rollback(); + throw new RestException(404, 'Invoice ID '.$id.' not found'); + } + + // Calculate amount to pay + $totalpaye = $this->invoice->getSommePaiement(); + $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); + $totaldeposits = $this->invoice->getSumDepositsUsed(); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + if ($amount != 'remain') + { + if ($amount > $resteapayer) + { + $this->db->rollback(); + throw new RestException(400, 'Payment amount on invoice ID '.$id.' ('.$amount.') is higher than remain to pay ('.$resteapayer.')'); + } + $resteapayer = $amount; + } // Clean parameters amount if payment is for a credit note if ($this->invoice->type == Facture::TYPE_CREDIT_NOTE) { $resteapayer = price2num($resteapayer,'MT'); @@ -1019,8 +1160,8 @@ class Invoices extends DolibarrApi $newvalue = price2num($this->invoice->multicurrency_total_ttc,'MT'); $multicurrency_amounts[$id] = $newvalue; } - } - $this->db->begin(); + } + // Creation of payment line $paiement = new Paiement($this->db); $paiement->datepaye = $datepaye; @@ -1049,7 +1190,9 @@ class Invoices extends DolibarrApi throw new RestException(400, 'Add payment to bank error : '.$paiement->error); } } + $this->db->commit(); + return $paiement_id; } From e88c67ab11dbcc28eafca745ab888460247f1998 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 11:52:10 +0200 Subject: [PATCH 466/609] Update actions_addupdatedelete.inc.php --- htdocs/core/actions_addupdatedelete.inc.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index e44be848179..608927bba12 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -26,7 +26,6 @@ // $object must be defined // $permissiontoadd must be defined // $permissiontodelete must be defined -// $backurlforcard must be defined // $backurlforlist must be defined // $backtopage may be defined From fef5a2487081113e8875d2bb156919ec0798c5ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 11:52:40 +0200 Subject: [PATCH 467/609] Update myobject_card.php --- htdocs/modulebuilder/template/myobject_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 764302a8bbc..536226d9f31 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -118,7 +118,7 @@ if (empty($reshook)) $permissiontoadd = $user->rights->mymodule->write; $permissiontodelete = $user->rights->mymodule->delete; - if(empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id=__ID__'; + if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id=__ID__'; $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); // Actions cancel, add, update or delete From 4c87cbf6441933396314757e2c66b8c7c179010d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 12:14:51 +0200 Subject: [PATCH 468/609] Update card.php --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index fe26bcdc672..fa1cef8fe0e 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1050,7 +1050,7 @@ if (empty($reshook)) if (empty($lines[$i]->subprice) || $lines[$i]->qty <= 0) continue; - $label = (! empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); + $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : $lines[$i]->product_desc); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); From ecd84f6c4592c029f2bd268913f4406ae63a598f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 12:18:45 +0200 Subject: [PATCH 469/609] Update fournisseur.commande.class.php --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 0aa6acc1ede..e79d1e06a6e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1418,7 +1418,7 @@ class CommandeFournisseur extends CommonOrder if ($fk_product > 0) { - if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED) && $origin !== 'supplier_proposal') + if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) { // Check quantity is enough dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." fourn_ref=".$fourn_ref); From d179cafa9ce0c7a04772bc22c904875940b2de35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 12:19:32 +0200 Subject: [PATCH 470/609] Update fournisseur.commande.class.php --- htdocs/fourn/class/fournisseur.commande.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e79d1e06a6e..09f47f385f4 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1366,10 +1366,9 @@ class CommandeFournisseur extends CommonOrder * @param string $pu_ht_devise Amount in currency * @param string $origin 'order', ... * @param int $origin_id Id of origin object - * @param string $label Label * @return int <=0 if KO, >0 if OK */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0, $origin='', $origin_id=0, $label='') + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit=null, $pu_ht_devise=0, $origin='', $origin_id=0) { global $langs,$mysoc,$conf; From c50700470b0845efa0e7e55d83823d5a08684d59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 12:51:39 +0200 Subject: [PATCH 471/609] Remove deprecated file --- htdocs/compta/tva/quadri.php | 319 ----------------------------------- 1 file changed, 319 deletions(-) delete mode 100644 htdocs/compta/tva/quadri.php diff --git a/htdocs/compta/tva/quadri.php b/htdocs/compta/tva/quadri.php deleted file mode 100644 index e572eb7e006..00000000000 --- a/htdocs/compta/tva/quadri.php +++ /dev/null @@ -1,319 +0,0 @@ - - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2006 Yannick Warnier - * Copyright (C) 2005-2009 Regis Houssin - * - * 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/tva/quadri.php - * \ingroup tax - * \brief Trimestrial page - * TODO Deal with recurrent invoices as well - */ - -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; - -$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); - -$year = GETPOST('year', 'int'); -if ($year == 0 ) -{ - $year_current = strftime("%Y",time()); - $year_start = $year_current; -} else { - $year_current = $year; - $year_start = $year; -} - -// Security check -$socid = GETPOST('socid','int'); -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'tax', '', '', 'charges'); - - -/** - * Gets VAT to collect for the given month of the given year - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. - * This function also accounts recurrent invoices. - * - * @param DoliDB $db Database handler - * @param int $y Year - * @param int $q Year quarter (1-4) - * @return array - */ -function tva_coll($db,$y,$q) -{ - global $conf; - - if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") - { - // if vat paid on due invoices - $sql = "SELECT d.fk_facture as facid, f.facnumber as facnum, d.tva_tx as rate, d.total_ht as totalht, d.total_tva as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."facturedet as d" ; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; - $sql.= " AND f.rowid = d.fk_facture "; - $sql.= " AND date_format(f.datef,'%Y') = '".$y."'"; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3); - $sql.= " AND date_format(f.datef,'%m') <= ".($q*3).")"; - $sql.= " ORDER BY rate, facid"; - - } - else - { - // if vat paid on paiments - } - - $resql = $db->query($sql); - - if ($resql) - { - $list = array(); - $rate = -1; - while($assoc = $db->fetch_array($resql)) - { - if($assoc['rate'] != $rate){ //new rate - $list[$assoc['rate']]['totalht'] = $assoc['totalht']; - $list[$assoc['rate']]['vat'] = $assoc['amount']; - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - }else{ - $list[$assoc['rate']]['totalht'] += $assoc['totalht']; - $list[$assoc['rate']]['vat'] += $assoc['amount']; - if(!in_array($assoc['facid'],$list[$assoc['rate']]['facid'])){ - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - } - } - $rate = $assoc['rate']; - } - return $list; - } - else - { - dol_print_error($db); - } -} - - -/** - * Gets VAT to pay for the given month of the given year - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Year quarter (1-4) - * @return array - */ -function tva_paye($db, $y,$q) -{ - global $conf; - - if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") - { - // Si on paye la tva sur les factures dues (non brouillon) - $sql = "SELECT d.fk_facture_fourn as facid, f.ref_supplier as facnum, d.tva_tx as rate, d.total_ht as totalht, d.tva as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; - $sql.= ", ".MAIN_DB_PREFIX."facture_fourn_det as d" ; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 1 "; - $sql.= " AND f.rowid = d.fk_facture_fourn "; - $sql.= " AND date_format(f.datef,'%Y') = '".$y."'"; - $sql.= " AND (round(date_format(f.datef,'%m')) > ".(($q-1)*3); - $sql.= " AND round(date_format(f.datef,'%m')) <= ".($q*3).")"; - $sql.= " ORDER BY rate, facid "; - } - else - { - // Si on paye la tva sur les payments - } - - $resql = $db->query($sql); - if ($resql) - { - $list = array(); - $rate = -1; - while($assoc = $db->fetch_array($resql)) - { - if($assoc['rate'] != $rate){ //new rate - $list[$assoc['rate']]['totalht'] = $assoc['totalht']; - $list[$assoc['rate']]['vat'] = $assoc['amount']; - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - }else{ - $list[$assoc['rate']]['totalht'] += $assoc['totalht']; - $list[$assoc['rate']]['vat'] += $assoc['amount']; - if(!in_array($assoc['facid'],$list[$assoc['rate']]['facid'])){ - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - } - } - $rate = $assoc['rate']; - } - return $list; - - } - else - { - dol_print_error($db); - } -} - - -/** - * View - */ - -llxHeader(); - -$textprevyear="".img_previous().""; -$textnextyear=" ".img_next().""; - -print load_fiche_titre($langs->trans("VAT"),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear"); - - -echo '
'.$langs->trans("LDAPDolibarrMapping").''.$langs->trans("LDAPNamingAttribute").'
'.$langs->trans("LDAPFieldFullname").''; print ''; print ''.$langs->trans("LDAPFieldFullnameExample").''.$langs->trans("LDAPFieldName").''; print ''; print ''.$langs->trans("LDAPFieldNameExample").''; // Firstname - print '
'.$langs->trans("LDAPFieldFirstName").''; print ''; print ''.$langs->trans("LDAPFieldFirstNameExample").''.$langs->trans("LDAPFieldLoginUnix").''; print ''; print ''.$langs->trans("LDAPFieldLoginExample").''; // Login samba - print '
'.$langs->trans("LDAPFieldLoginSamba").''; print ''; print ''.$langs->trans("LDAPFieldLoginSambaExample").''.$langs->trans("LDAPFieldPasswordNotCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldPasswordCrypted").''; print ''; print ''.$langs->trans("LDAPFieldPasswordExample").' 
'.$langs->trans("LDAPFieldMail").''; print ''; print ''.$langs->trans("LDAPFieldMailExample").''; // Phone - print '
'.$langs->trans("LDAPFieldPhone").''; print ''; print ''.$langs->trans("LDAPFieldPhoneExample").''; // Mobile - print '
'.$langs->trans("LDAPFieldMobile").''; print ''; print ''.$langs->trans("LDAPFieldMobileExample").''.$langs->trans("LDAPFieldSkype").''; print ''; print ''.$langs->trans("LDAPFieldSkypeExample").''; // Fax - print '
'.$langs->trans("LDAPFieldFax").''; print ''; print ''.$langs->trans("LDAPFieldFaxExample").''; // Company - print '
'.$langs->trans("LDAPFieldCompany").''; print ''; print ''.$langs->trans("LDAPFieldCompanyExample").' 
'.$langs->trans("LDAPFieldAddress").''; print ''; print ''.$langs->trans("LDAPFieldAddressExample").' 
'.$langs->trans("LDAPFieldZip").''; print ''; print ''.$langs->trans("LDAPFieldZipExample").' 
'.$langs->trans("LDAPFieldTown").''; print ''; print ''.$langs->trans("LDAPFieldTownExample").' 
'.$langs->trans("LDAPFieldCountry").''; print ''; print '  
'.$langs->trans("LDAPFieldTitle").''; print ''; print ''.$langs->trans("LDAPFieldTitleExample").' 
'.$langs->trans("Note").''; print ''; print ''.$langs->trans("LDAPFieldDescriptionExample").' 
'.$langs->trans("LDAPFieldSid").''; print ''; print ''.$langs->trans("LDAPFieldSidExample").''.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'
+zzzz'.$total[$annee-1].$langs->trans('Inf').'%+'.$langs->trans('Inf').'%
'; -echo ''; - -echo ''; - -print "
'; -print load_fiche_titre($langs->trans("VATSummary")); -echo '
"; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print ""; -print "\n"; - -if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") -{ - $y = $year_current; - - $total = 0; $subtotal = 0; - $i=0; - $subtot_coll_total = 0; - $subtot_coll_vat = 0; - $subtot_paye_total = 0; - $subtot_paye_vat = 0; - for ($q = 1 ; $q <= 4 ; $q++) { - print ""; - $var=true; - - $x_coll = tva_coll($db, $y, $q); - $x_paye = tva_paye($db, $y, $q); - $x_both = array(); - //now, from these two arrays, get another array with one rate per line - foreach(array_keys($x_coll) as $my_coll_rate){ - $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; - $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; - $x_both[$my_coll_rate]['paye']['totalht'] = 0; - $x_both[$my_coll_rate]['paye']['vat'] = 0; - $x_both[$my_coll_rate]['coll']['links'] = ''; - foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy){ - $x_both[$my_coll_rate]['coll']['links'] .= '..'.substr($x_coll[$my_coll_rate]['facnum'][$id],-2).' '; - } - } - foreach(array_keys($x_paye) as $my_paye_rate){ - $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; - $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; - if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){ - $x_both[$my_paye_rate]['coll']['total_ht'] = 0; - $x_both[$my_paye_rate]['coll']['vat'] = 0; - } - $x_both[$my_paye_rate]['paye']['links'] = ''; - foreach($x_paye[$my_paye_rate]['facid'] as $id=>$dummy){ - $x_both[$my_paye_rate]['paye']['links'] .= '..'.substr($x_paye[$my_paye_rate]['facnum'][$id],-2).' '; - } - } - //now we have an array (x_both) indexed by rates for coll and paye - - $x_coll_sum = 0; - $x_coll_ht = 0; - $x_paye_sum = 0; - $x_paye_ht = 0; - foreach($x_both as $rate => $both){ - - print ''; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - print ""; - $x_coll_sum += $both['coll']['vat']; - $x_paye_sum += $both['paye']['vat']; - $subtot_coll_total += $both['coll']['totalht']; - $subtot_coll_vat += $both['coll']['vat']; - $subtot_paye_total += $both['paye']['totalht']; - $subtot_paye_vat += $both['paye']['vat']; - } - - $diff = $x_coll_sum - $x_paye_sum; - $total = $total + $diff; - $subtotal = $subtotal + $diff; - - - print ''; - print ''; - print "\n"; - print "\n"; - - $i++; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - -} -else -{ - print ''; - print ''; -} - -print '
".$langs->trans("Year")." $year_current".$langs->trans("Income")."".$langs->trans("VATToPay")."".$langs->trans("Invoices")."".$langs->trans("Outcome")."".$langs->trans("VATToCollect")."".$langs->trans("Invoices")."".$langs->trans("TotalToPay")."
".$langs->trans("Quadri")." $q (".dol_print_date(dol_mktime(0,0,0,(($q-1)*3)+1,1,$y),"%b %Y").' - '.dol_print_date(dol_mktime(0,0,0,($q*3),1,$y),"%b %Y").")
$rate%".price($both['coll']['totalht'])."".price($both['coll']['vat'])."".$both['coll']['links']."".price($both['paye']['totalht'])."".price($both['paye']['vat'])."".$both['paye']['links']."
".price($diff)."
'.$langs->trans("Total").':'.price($subtot_coll_total).''.price($subtot_coll_vat).''.price($subtot_paye_total).''.price($subtot_paye_vat).''.price($total).''; - print '
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureIsSupportedInInOutModeOnly").'
'; -echo '
'; - -llxFooter(); -$db->close(); From c35a190f1d32e4f77b02c38c4cfc509d101865fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 13:31:11 +0200 Subject: [PATCH 472/609] update some tools --- dev/tools/github_authors_peryear.sh | 10 ++++++++-- dev/tools/github_commits_perversion.sh | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/dev/tools/github_authors_peryear.sh b/dev/tools/github_authors_peryear.sh index 99b28d4d417..1f3a7fea5f6 100755 --- a/dev/tools/github_authors_peryear.sh +++ b/dev/tools/github_authors_peryear.sh @@ -1,7 +1,13 @@ #!/bin/sh -FROM=2016-01-01 -TO=2016-12-31 +if [ "x$1" = "x" ]; then + echo "Usage: $0 YEAR" + exit +fi + + +FROM=$1-01-01 +TO=$1-12-31 echo "git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l" git log --since $FROM --before $TO | grep ^Author | sort -u -f -i -b | wc -l diff --git a/dev/tools/github_commits_perversion.sh b/dev/tools/github_commits_perversion.sh index 40ddafee617..bf76e68bc43 100755 --- a/dev/tools/github_commits_perversion.sh +++ b/dev/tools/github_commits_perversion.sh @@ -1,10 +1,11 @@ #/bin/bash -Releases=("3.8" "3.9" "4.0" "5.0", "develop") -Dates=("2010-01-01", "2011-01-01", "2012-01-01", "2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01") +Releases=("3.8" "3.9" "4.0" "5.0" "6.0" " 7.0" "develop") +Dates=("2013-01-01", "2014-01-01", "2015-01-01", "2016-07-01", "2017-02-01", "2017-07-01", "2018-02-01", "2050-01-01") let "counter = 1" for i in "${Releases[@]}" do + echo "=== $counter git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]}" git shortlog -s -n --after=${Dates[counter-1]} --before=${Dates[counter]} echo -n "Total $i: " git log --pretty=oneline --after=${Dates[counter-1]} --before=${Dates[counter]} | wc -l From 257dc1cf77ee3fe954a505fa6c8a77b2cda86315 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 27 Apr 2018 18:43:41 +0200 Subject: [PATCH 473/609] Work on rewriting VAT reports --- htdocs/compta/localtax/clients.php | 5 +- htdocs/compta/localtax/index.php | 7 +- htdocs/compta/localtax/quadri_detail.php | 650 ++++++++-------- htdocs/compta/tva/clients.php | 921 ++++++++++++++--------- htdocs/compta/tva/index.php | 5 +- htdocs/compta/tva/quadri_detail.php | 36 +- htdocs/core/lib/tax.lib.php | 531 +++++++++++-- htdocs/core/menus/standard/eldy.lib.php | 1 - htdocs/langs/en_US/compta.lang | 1 + 9 files changed, 1385 insertions(+), 772 deletions(-) diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 3dc3e2777c2..3c8a2a9aef6 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -26,6 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -163,7 +164,7 @@ if($calc ==0 || $calc == 2) print "
".$vatcust."
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'
'; $y = $year_current; $total = 0; $i=0; +$columns = 5; // Load arrays of datas -$x_coll = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = tax_by_date('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); - -echo '
'; +$x_coll = tax_by_rate('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_rate('localtax' . $local, $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { $langs->load("errors"); if ($x_coll == -1) - print ''; + print ''; else if ($x_coll == -2) - print ''; + print ''; else - print ''; + print ''; } else { @@ -226,6 +231,7 @@ else $invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; $invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; $invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); $x_both[$my_coll_rate]['coll']['detail'][] = array( 'id' =>$x_coll[$my_coll_rate]['facid'][$id], 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], @@ -237,20 +243,24 @@ else 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], + 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], + 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], 'localtax1'=> $x_coll[$my_coll_rate]['localtax1_list'][$id], 'localtax2'=> $x_coll[$my_coll_rate]['localtax2_list'][$id], 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], - 'link' =>$invoice_customer->getNomUrl(1,'',12)); + 'link' =>$invoice_customer->getNomUrl(1,'',12) + ); } } // tva paid - foreach(array_keys($x_paye) as $my_paye_rate){ + foreach(array_keys($x_paye) as $my_paye_rate) { $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; - if(!isset($x_both[$my_paye_rate]['coll']['totalht'])){ + if(!isset($x_both[$my_paye_rate]['coll']['totalht'])) { $x_both[$my_paye_rate]['coll']['totalht'] = 0; $x_both[$my_paye_rate]['coll']['vat'] = 0; } @@ -273,35 +283,39 @@ else 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], + 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), 'localtax1'=> $x_paye[$my_paye_rate]['localtax1_list'][$id], 'localtax2'=> $x_paye[$my_paye_rate]['localtax2_list'][$id], 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], - 'link' =>$invoice_supplier->getNomUrl(1,'',12)); + 'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); } } //now we have an array (x_both) indexed by rates for coll and paye + //print table headers for this quadri - incomes first + $x_coll_sum = 0; $x_coll_ht = 0; $x_paye_sum = 0; $x_paye_ht = 0; - $span=3; - if ($modetax == 0) $span+=2; + $span=$columns; + if ($modetax != 1) $span+=2; - if($conf->global->$calc ==0 || $conf->global->$calc == 2){ + //if ($modetax == 0 || $modetax == 2) + //{ // Customers invoices print ''; print ''; print ''; - if ($modetax == 0) - { - print ''; - print ''; - } + if ($modetax != 2) print ''; + if ($modetax != 1) print ''; print ''; print ''; print ''; @@ -317,8 +331,6 @@ else if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate - $var=true; - if($rate!=0){ print ""; print ''; @@ -326,116 +338,116 @@ else } foreach($x_both[$rate]['coll']['detail'] as $index => $fields) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)){ - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; - - - print ''; - - // Ref - print ''; - - // Description - print ''; - // Total HT - if ($modetax == 0) - { - print ''; + + // Ref + print ''; + + // Description + print ''; - } - // Payment - $ratiopaymentinvoice=1; - if ($modetax == 0) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + // Total HT + if ($modetax != 2) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + print ''; + } + + // Total collected print ''; + + // Localtax + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } - - // Total collected - print ''; - - // Localtax - print ''; - print ''; - - $subtot_coll_total_ht += $temp_ht; - $subtot_coll_vat += $temp_vat; - $x_coll_sum += $temp_vat; } } - } - if($rate!=0){ - // Total customers for this vat rate - print ''; - print ''; - print ''; - if ($modetax == 0) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; - } + + // Total customers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; } if (count($x_coll) == 0) // Show a total ine if nothing shown @@ -457,15 +469,15 @@ else print ''; print '
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("FeatureNotYetAvailable").'
'.$langs->trans("Error").'
'.$langs->trans("Error").'
'.$elementcust.''.$productcust.''.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("BI").''.$vatcust.'
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$fields['link'].''; - if ($fields['pid']) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); - } - else - { - if ($type) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) - { - if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); - elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); - else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); - } - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; - // Show range - print_date_range($fields['ddate_start'],$fields['ddate_end']); - } - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) + print '
'.$fields['link'].''; + if ($fields['pid']) { - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + } + else + { + if ($type) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) + { + if ($reg[1]=='DEPOSIT') $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + elseif ($reg[1]=='CREDIT_NOTE') $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + else $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); } print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + } + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $payment_static->id=$fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NotUsedForGoods"); + } + else { + print price($fields['payment_amount']); + if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $payment_static->id=$fields['payment_id']; - print $payment_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NotUsedForGoods"); - } - else { - print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; - } + $temp_ht=$fields['totalht']; + if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT')); print ''; + $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; + print price(price2num($temp_vat,'MT')); + //print price($fields['vat']); + print '
'; - $temp_ht=$fields['totalht']; - if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht,'MT')); - print ''; - $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; - print price(price2num($temp_vat,'MT')); - //print price($fields['vat']); - print '
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
 
'; $diff=$x_coll_sum; - } + //} - if($conf->global->$calc ==0 || $conf->global->$calc == 1){ + //if($conf->global->$calc ==0 || $conf->global->$calc == 1){ echo ''; //print table headers for this quadri - expenses now print ''; print ''; print ''; - if ($modetax == 0) + if ($modetax != 1) { print ''; print ''; @@ -479,9 +491,8 @@ else $subtot_paye_total_ht = 0; $subtot_paye_vat = 0; - if(is_array($x_both[$rate]['paye']['detail'])) + if (is_array($x_both[$rate]['paye']['detail'])) { - $var=true; if($rate!=0){ print ""; print ''; @@ -489,149 +500,144 @@ else } foreach($x_both[$rate]['paye']['detail'] as $index=>$fields) { - if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)){ - // Define type - $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); - // Try to enhance type detection using date_start and date_end for free lines where type - // was not saved. - if (! empty($fields['ddate_start'])) $type=1; - if (! empty($fields['ddate_end'])) $type=1; - - - print ''; - - // Ref - print ''; - - // Description - print ''; - // Total HT - if ($modetax == 0) - { - print ''; + + // Ref + print ''; + + // Description + print ''; - } - - // Payment - $ratiopaymentinvoice=1; - if ($modetax == 0) - { - if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); - print ''; + + // Total HT + if ($modetax != 2) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; + } + + // VAT paid + print ''; + + // Localtax + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } - - // VAT paid - print ''; - - // Localtax - print ''; - print ''; - - $subtot_paye_total_ht += $temp_ht; - $subtot_paye_vat += $temp_vat; - $x_paye_sum += $temp_vat; } } - } - if($rate!=0){ - // Total suppliers for this vat rate - print ''; - print ''; - print ''; - if ($modetax == 0) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; - } + + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; + print ''; } - if (count($x_paye) == 0) // Show a total ine if nothing shown - { - print ''; - print ''; - print ''; - if ($modetax == 0) - { - print ''; - print ''; - } - print ''; - print ''; - print ''; + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; } print '
'.$elementsup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$fields['link'].''; - if ($fields['pid']) + if(($local==1 && $fields['localtax1']!=0) || ($local==2 && $fields['localtax2']!=0)) { - $product_static->id=$fields['pid']; - $product_static->ref=$fields['pref']; - $product_static->type=$fields['ptype']; - print $product_static->getNomUrl(1); - if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); - } - else - { - if ($type) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + // Define type + $type=($fields['dtype']?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($fields['ddate_start'])) $type=1; + if (! empty($fields['ddate_end'])) $type=1; - // Show range - print_date_range($fields['ddate_start'],$fields['ddate_end']); - } - print ''; - print price($fields['totalht']); - if (price2num($fields['ftotal_ttc'])) + print '
'.$fields['link'].''; + if ($fields['pid']) { - //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; - $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); - //print ' ('.round($ratiolineinvoice*100,2).'%)'; - } - print ''; - if ($fields['payment_amount'] && $fields['ftotal_ttc']) - { - $paymentfourn_static->id=$fields['payment_id']; - print $paymentfourn_static->getNomUrl(2); - } - if ($type == 0) - { - print $langs->trans("NotUsedForGoods"); + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['ptype']; + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); } else { - print price($fields['payment_amount']); - if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + if ($type) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); } print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id=$fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + if ($type == 0) + { + print $langs->trans("NA"); + } + else + { + print price(price2num($fields['payment_amount'],'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + } + print ''; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT'),1); + print ''; + $temp_vat=($local==1?$fields['localtax1']:$fields['localtax2'])*$ratiopaymentinvoice;; + print price(price2num($temp_vat,'MT'),1); + //print price($fields['vat']); + print '
'; - $temp_ht=$fields['totalht']; - if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice; - print price(price2num($temp_ht,'MT')); - print ''; - $temp_vat= $local==1?$fields['localtax1']:$fields['localtax2']; - print price(price2num($temp_vat,'MT')); - //print price($fields['vat']); - print '
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
 '.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
 '.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
 '.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
'; - $diff=$x_paye_sum; - } + //} - if($conf->global->$calc ==0){$diff=$x_coll_sum - $x_paye_sum;} - echo ''; - // Total to pay - print '

'; - print '
'; - //$diff = $local==1?$x_coll_sum:$x_paye_sum; - print ''; - print ''; - print '\n"; - print "\n"; - - echo '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.price(price2num($diff,'MT'))."
'; + // Total to pay + print '

'; + print ''; + $diff = $x_coll_sum - $x_paye_sum; + print ''; + print ''; + print '\n"; + print "\n"; $i++; } +print '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.price(price2num($diff,'MT'))."
'; llxFooter(); $db->close(); diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 71376a566e1..734f4880e48 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -30,7 +30,14 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -84,10 +91,6 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES') -$modecompta = $conf->global->ACCOUNTING_MODE; -if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); - /* @@ -96,13 +99,19 @@ if (GETPOST("modecompta")) $modecompta=GETPOST("modecompta"); $form=new Form($db); $company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); -foreach($listofparams as $param) { - if (GETPOST($param)!='') { - $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); - } +foreach ($listofparams as $param) +{ + if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); } $special_report = false; @@ -118,15 +127,28 @@ $fsearch.=' '; $fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; $fsearch.=' '; -$description=''; - // Show report header -$name=$langs->trans("VATReportByCustomers"); +$name=$langs->trans("VATReportByThirdParties"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); $calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; +} +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; +} +$builddate=dol_now(); if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); @@ -137,23 +159,24 @@ if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { } if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); -$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description.=$fsearch; -$description.='
' - . ' ' - . $langs->trans('SimpleReport') - . '' - . '
' - . ' ' - . $langs->trans('AddExtraReport') - . '' - . '
'; -$builddate=dol_now(); -//$exportlink=$langs->trans("NotYetAvailable"); +if (! empty($conf->global->TAX_REPORT_EXTRA_REPORT)) +{ + $description.='
' + . ' ' + . $langs->trans('SimpleReport') + . '' + . '
' + . ' ' + . $langs->trans('AddExtraReport') + . '' + . '
'; +} $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("Description"); +$namerate=$langs->trans("VATRate"); $amountcust=$langs->trans("AmountHT"); if ($mysoc->tva_assuj) { $vatcust.=' ('.$langs->trans("ToPay").')'; @@ -172,152 +195,547 @@ $vatsup=$langs->trans("VATPaid"); // VAT Received -//print "
"; -//print load_fiche_titre($vatcust); - print ""; -print ""; -print '"; -print '"; -print ""; -print ""; -print ""; -print "\n"; -$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); +$y = $year_current; +$total = 0; +$i=0; +$columns = 5; -$action = "tvaclient"; -$object = &$coll_list; -$parameters["mode"] = $modetax; -$parameters["start"] = $date_start; -$parameters["end"] = $date_end; -$parameters["direction"] = 'sell'; -$parameters["type"] = 'vat'; +// Load arrays of datas +$x_coll = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_thirdparty('vat', $db, 0, $date_start, $date_end, $modetax, 'buy'); -// Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('externalbalance')); -$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - -if (is_array($coll_list)) { - $var=true; - $total = 0; $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - - $intra = str_replace($find,$replace,$coll->tva_intra); - if(empty($intra)) { - if($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ''; - print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; - $company_static->client=1; - print ''; - $find = array(' ','.'); - $replace = array('',''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; - } - } - $x_coll_sum = $total; - - print ''; - print ''; - print ''; - print ''; -} else { +if (! is_array($x_coll) || ! is_array($x_paye)) +{ $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else if ($coll_list == -2) { - print ''; + if ($x_coll == -1) { + print ''; + } else if ($x_coll == -2) { + print ''; } else { - print ''; + print ''; } -} - -//print '
'.$langs->trans("Num")."'.$langs->trans("Customer")."".$langs->trans("VATIntra")."".$langs->trans("AmountHTVATRealReceived")."".$vatcust."
'.$i."'.$company_static->getNomUrl(1,'customer').''.$intra."".price($coll->amount)."".price($coll->tva)."
'.$langs->trans("Total").':'.price($totalamount).''.price($total).'
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
' . $langs->trans("Error") . '
'; - - -// VAT Paid - -//print "
"; -//print load_fiche_titre($vatsup); - -//print ""; -print ""; -print '"; -print '"; -print ""; -print ""; -print ""; -print "\n"; - -$company_static=new Societe($db); - -$coll_list = vat_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); - -$parameters["direction"] = 'buy'; -$reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if (is_array($coll_list)) { - $var=true; - $total = 0; $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - - $intra = str_replace($find,$replace,$coll->tva_intra); - if (empty($intra)) { - if ($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ''; - print '"; - $company_static->id=$coll->socid; - $company_static->name=$coll->name; - $company_static->fournisseur=1; - print ''; - $find = array(' ','.'); - $replace = array('',''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; +} else { + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach(array_keys($x_coll) as $my_coll_thirdpartyid) + { + $x_both[$my_coll_thirdpartyid]['coll']['totalht'] = $x_coll[$my_coll_thirdpartyid]['totalht']; + $x_both[$my_coll_thirdpartyid]['coll']['vat'] = $x_coll[$my_coll_thirdpartyid]['vat']; + $x_both[$my_coll_thirdpartyid]['paye']['totalht'] = 0; + $x_both[$my_coll_thirdpartyid]['paye']['vat'] = 0; + $x_both[$my_coll_thirdpartyid]['coll']['links'] = ''; + $x_both[$my_coll_thirdpartyid]['coll']['detail'] = array(); + foreach($x_coll[$my_coll_thirdpartyid]['facid'] as $id=>$dummy) { + $invoice_customer->id=$x_coll[$my_coll_thirdpartyid]['facid'][$id]; + $invoice_customer->ref=$x_coll[$my_coll_thirdpartyid]['facnum'][$id]; + $invoice_customer->type=$x_coll[$my_coll_thirdpartyid]['type'][$id]; + $company_static->fetch($x_coll[$my_coll_thirdpartyid]['company_id'][$id]); + $x_both[$my_coll_thirdpartyid]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_thirdpartyid]['facid'][$id], + 'descr' =>$x_coll[$my_coll_thirdpartyid]['descr'][$id], + 'pid' =>$x_coll[$my_coll_thirdpartyid]['pid'][$id], + 'pref' =>$x_coll[$my_coll_thirdpartyid]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_thirdpartyid]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_thirdpartyid]['dtype'][$id], + 'drate' =>$x_coll[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_coll[$my_coll_thirdpartyid]['datef'][$id], + 'datep' =>$x_coll[$my_coll_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_coll[$my_coll_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_thirdpartyid]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_thirdpartyid]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_customer->getNomUrl(1,'',12) + ); } } - $x_paye_sum = $total; + // tva paid + foreach (array_keys($x_paye) as $my_paye_thirdpartyid) { + $x_both[$my_paye_thirdpartyid]['paye']['totalht'] = $x_paye[$my_paye_thirdpartyid]['totalht']; + $x_both[$my_paye_thirdpartyid]['paye']['vat'] = $x_paye[$my_paye_thirdpartyid]['vat']; + if (!isset($x_both[$my_paye_thirdpartyid]['coll']['totalht'])) { + $x_both[$my_paye_thirdpartyid]['coll']['totalht'] = 0; + $x_both[$my_paye_thirdpartyid]['coll']['vat'] = 0; + } + $x_both[$my_paye_thirdpartyid]['paye']['links'] = ''; + $x_both[$my_paye_thirdpartyid]['paye']['detail'] = array(); - print ''; - print ''; - print ''; + foreach ($x_paye[$my_paye_thirdpartyid]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_thirdpartyid]['ptype'][$id] == 'ExpenseReportPayment') + { + $expensereport->id=$x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $expensereport->ref=$x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $expensereport->type=$x_paye[$my_paye_thirdpartyid]['type'][$id]; + + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'ddate_start' =>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$expensereport->getNomUrl(1) + ); + } + else + { + $invoice_supplier->id=$x_paye[$my_paye_thirdpartyid]['facid'][$id]; + $invoice_supplier->ref=$x_paye[$my_paye_thirdpartyid]['facnum'][$id]; + $invoice_supplier->type=$x_paye[$my_paye_thirdpartyid]['type'][$id]; + $company_static->fetch($x_paye[$my_paye_thirdpartyid]['company_id'][$id]); + $x_both[$my_paye_thirdpartyid]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_thirdpartyid]['facid'][$id], + 'descr' =>$x_paye[$my_paye_thirdpartyid]['descr'][$id], + 'pid' =>$x_paye[$my_paye_thirdpartyid]['pid'][$id], + 'pref' =>$x_paye[$my_paye_thirdpartyid]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_thirdpartyid]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_thirdpartyid]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_thirdpartyid]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_thirdpartyid]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_thirdpartyid]['dtype'][$id], + 'drate' =>$x_paye[$my_coll_thirdpartyid]['drate'][$id], + 'datef' =>$x_paye[$my_paye_thirdpartyid]['datef'][$id], + 'datep' =>$x_paye[$my_paye_thirdpartyid]['datep'][$id], + 'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_paye[$my_paye_thirdpartyid]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_thirdpartyid]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_thirdpartyid]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_thirdpartyid]['vat_list'][$id], + 'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye + + + //print table headers for this quadri - incomes first + + $x_coll_sum = 0; + $x_coll_ht = 0; + $x_paye_sum = 0; + $x_paye_ht = 0; + + $span=$columns; + if ($modetax != 1) $span+=2; + + //print ''; + + // Customers invoices + print ''; + print ''; + print ''; + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''; + else print ''; + print ''; + print ''; + if ($modetax != 1) + { + print ''; + print ''; + } + print ''; + print ''; print ''; + $action = "tvadetail"; + $parameters["mode"] = $modetax; + $parameters["start"] = $date_start; + $parameters["end"] = $date_end; + $parameters["type"] = 'vat'; + + $object = array(&$x_coll, &$x_paye, &$x_both); + // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('externalbalance')); + $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + foreach (array_keys($x_coll) as $thirdparty_id) { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; + + if (is_array($x_both[$thirdparty_id]['coll']['detail'])) + { + + // VAT Rate + print ""; + print ''; + print ''."\n"; + + foreach ($x_both[$thirdparty_id]['coll']['detail'] as $index => $fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + + print ''; + + // Ref + print ''; + + // Invoice date + print ''; + + // Payment date + if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment' || $conf->global->TAX_MODE_SELL_SERVICE == 'payment') print ''; + else print ''; + + // Rate + print ''; + + // Description + print ''; + + // Total HT + if ($modetax != 1) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; + } + + // Total collected + print ''; + + // VAT + print ''; + print ''; + + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + // Total customers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + + if (count($x_coll) == 0) // Show a total ine if nothing shown + { + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + + // Blank line + print ''; + + // Print table headers for this quadri - expenses now + print ''; + print ''; + print ''; + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''; + else print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''."\n"; + + foreach (array_keys($x_paye) as $thirdparty_id) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; + + if (is_array($x_both[$thirdparty_id]['paye']['detail'])) + { + print ""; + print ''; + print ''."\n"; + + foreach ($x_both[$thirdparty_id]['paye']['detail'] as $index=>$fields) { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + + print ''; + + // Ref + print ''; + + // Invoice date + print ''; + + // Payment date + if ($conf->global->TAX_MODE_BUY_PRODUCT == 'payment' || $conf->global->TAX_MODE_BUY_SERVICE == 'payment') print ''; + else print ''; + + // Company name + print ''; + + // Description + print ''; + + // Total HT + if ($modetax != 1) + { + print ''; + } + + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + print ''; + } + + // VAT paid + print ''; + + // VAT + print ''; + print ''; + + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + // Total suppliers for this vat rate + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + + if (count($x_paye) == 0) { // Show a total line if nothing shown + print ''; + print ''; + print ''; + if ($modetax != 1) { + print ''; + print ''; + } + print ''; + print ''; + print ''; + } + print '
'.$langs->trans("Num")."'.$langs->trans("Supplier")."".$langs->trans("VATIntra")."".$langs->trans("AmountHTVATRealPaid")."".$vatsup."
'.$i."'.$company_static->getNomUrl(1,'supplier').''.$intra."".price($coll->amount)."".price($coll->tva)."
'.$langs->trans("Total").':'.price($totalamount).''.price($total).'
'..')
'.$elementcust.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").''.$namerate.''.$productcust.''.$amountcust.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("AmountHTVATRealReceived").''.$vatcust.'
'; + if (is_numeric($thirdparty_id)) + { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } + else + { + $tmpid = preg_replace('/userid_/','',$thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print '
'.$fields['link'].'' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['drate'] . ''; + if ($fields['pid']) + { + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + } + } + else + { + if ($type) { + $text = img_object($langs->trans('Service'),'service'); + } else { + $text = img_object($langs->trans('Product'),'product'); + } + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { + if ($reg[1]=='DEPOSIT') { + $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1]=='CREDIT_NOTE') { + $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); + } + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $payment_static->id=$fields['payment_id']; + print $payment_static->getNomUrl(2); + } + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'],'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + } + print ''; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT'),1); + print ''; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + print price(price2num($temp_vat,'MT'),1); + //print price($fields['vat']); + print '
'.$langs->trans("Total").':  '.price(price2num($subtot_coll_total_ht,'MT')).''.price(price2num($subtot_coll_vat,'MT')).'
'.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
 
'.$elementsup.''.$langs->trans("DateInvoice").''.$langs->trans("DatePayment").''.$namesup.''.$productsup.''.$amountsup.''.$langs->trans("Payment").' ('.$langs->trans("PercentOfInvoice").')'.$langs->trans("AmountHTVATRealPaid").''.$vatsup.'
'; + if (is_numeric($thirdparty_id)) + { + $company_static->fetch($thirdparty_id); + print $langs->trans("ThirdParty").': '.$company_static->getNomUrl(1); + } + else + { + $tmpid = preg_replace('/userid_/','',$thirdparty_id); + $user_static->fetch($tmpid); + print $langs->trans("User").': '.$user_static->getNomUrl(1); + } + print '
'.$fields['link'].'' . dol_print_date($fields['datef'], 'day') . '' . dol_print_date($fields['datep'], 'day') . '' . $fields['company_link'] . ''; + if ($fields['pid']) + { + $product_static->id=$fields['pid']; + $product_static->ref=$fields['pref']; + $product_static->type=$fields['dtype']; // We force with the type of line to have type how line is registered + print $product_static->getNomUrl(1); + if (dol_string_nohtmltag($fields['descr'])) { + print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + } + } + else + { + if ($type) { + $text = img_object($langs->trans('Service'),'service'); + } else { + $text = img_object($langs->trans('Product'),'product'); + } + if (preg_match('/^\((.*)\)$/',$fields['descr'],$reg)) { + if ($reg[1]=='DEPOSIT') { + $fields['descr']=$langs->transnoentitiesnoconv('Deposit'); + } elseif ($reg[1]=='CREDIT_NOTE') { + $fields['descr']=$langs->transnoentitiesnoconv('CreditNote'); + } else { + $fields['descr']=$langs->transnoentitiesnoconv($reg[1]); + } + } + print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),24); + + // Show range + print_date_range($fields['ddate_start'],$fields['ddate_end']); + } + print ''; + print price($fields['totalht']); + if (price2num($fields['ftotal_ttc'])) + { + //print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - "; + $ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']); + //print ' ('.round($ratiolineinvoice*100,2).'%)'; + } + print ''; + if ($fields['payment_amount'] && $fields['ftotal_ttc']) + { + $paymentfourn_static->id=$fields['payment_id']; + print $paymentfourn_static->getNomUrl(2); + } + + if (($type == 0 && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) + { + print $langs->trans("NA"); + } + else + { + if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + print price(price2num($fields['payment_amount'],'MT')); + if (isset($fields['payment_amount'])) { + print ' ('.round($ratiopaymentinvoice*100,2).'%)'; + } + } + print ''; + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + print price(price2num($temp_ht,'MT'),1); + print ''; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + print price(price2num($temp_vat,'MT'),1); + //print price($fields['vat']); + print '
'.$langs->trans("Total").':  '.price(price2num($subtot_paye_total_ht,'MT')).''.price(price2num($subtot_paye_vat,'MT')).'
'.$langs->trans("Total").':  '.price(price2num(0,'MT')).''.price(price2num(0,'MT')).'
'; // Total to pay @@ -325,198 +743,15 @@ if (is_array($coll_list)) { print ''; $diff = $x_coll_sum - $x_paye_sum; print ''; - print ''; + print ''; print '\n"; print "\n"; -} else { - $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else if ($coll_list == -2) { - print ''; - } else { - print ''; - } + $i++; } print '
'.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.$langs->trans("TotalToPay").($q?', '.$langs->trans("Quadri").' '.$q:'').''.price(price2num($diff,'MT'))."
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
'; -if ($special_report) { - // Get country 2-letters code - global $mysoc; - $country_id = $mysoc->country_id; - $country = new Ccountry($db); - $country->fetch($country_id); - - // Print listing of other-country customers as additional report - // This matches tax requirements to list all same-country customers (only) - print '

'.$langs->trans('OtherCountriesCustomersReport').'

'; - print $langs->trans('BasedOnTwoFirstLettersOfVATNumberBeingDifferentFromYourCompanyCountry'); - $coll_list = vat_by_thirdparty($db, 0, $date_start, $date_end, $modetax, 'sell'); - - print ""; - print ""; - print '"; - print '"; - print ""; - print ""; - print ""; - print "\n"; - - if (is_array($coll_list)) { - $var = true; - $total = 0; - $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if (substr($coll->tva_intra, 0, 2) == $country->code) { - // Only use different-country VAT codes - continue; - } - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - $var = !$var; - $intra = str_replace($find, $replace, $coll->tva_intra); - if (empty($intra)) { - if ($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ""; - print '"; - $company_static->id = $coll->socid; - $company_static->name = $coll->name; - $company_static->client = 1; - print ''; - $find = array(' ', '.'); - $replace = array('', ''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; - } - } - $x_coll_sum = $total; - - print ''; - print ''; - print ''; - print ''; - } else { - $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else { - if ($coll_list == -2) { - print ''; - } else { - print ''; - } - } - } - print '
' . $langs->trans("Num") . "' . $langs->trans("Customer") . "" . $langs->trans("VATIntra") . "" . $langs->trans("AmountHTVATRealReceived") . "" . $vatcust . "
' . $i . "' . $company_static->getNomUrl(1, - 'customer') . '' . $intra . "" . price($coll->amount) . "" . price($coll->tva) . "
' . $langs->trans("Total") . ':' . price($totalamount) . '' . price($total) . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
'; - - // Print listing of same-country customers as additional report - // This matches tax requirements to list all same-country customers (only) - print '

'.$langs->trans('SameCountryCustomersWithVAT').'

'; - print $langs->trans('BasedOnTwoFirstLettersOfVATNumberBeingTheSameAsYourCompanyCountry'); - $coll_list = vat_by_thirdparty($db, 0, $date_start, $date_end, $modetax, 'sell'); - - print ""; - print ""; - print '"; - print '"; - print ""; - print ""; - print ""; - print "\n"; - - if (is_array($coll_list)) { - $var = true; - $total = 0; - $totalamount = 0; - $i = 1; - foreach ($coll_list as $coll) { - if (substr($coll->tva_intra, 0, 2) != $country->code) { - // Only use same-country VAT codes - continue; - } - if ($min == 0 or ($min > 0 && $coll->amount > $min)) { - $var = !$var; - $intra = str_replace($find, $replace, $coll->tva_intra); - if (empty($intra)) { - if ($coll->assuj == '1') { - $intra = $langs->trans('Unknown'); - } else { - //$intra = $langs->trans('NotRegistered'); - $intra = ''; - } - } - print ""; - print '"; - $company_static->id = $coll->socid; - $company_static->name = $coll->name; - $company_static->client = 1; - print ''; - $find = array(' ', '.'); - $replace = array('', ''); - print '"; - print ""; - print ""; - $totalamount = $totalamount + $coll->amount; - $total = $total + $coll->tva; - print "\n"; - $i++; - } - } - $x_coll_sum = $total; - - print ''; - print ''; - print ''; - print ''; - } else { - $langs->load("errors"); - if ($coll_list == -1) { - if ($modecompta == 'CREANCES-DETTES') - { - print ''; - } - else - { - print ''; - } - } else { - if ($coll_list == -2) { - print ''; - } else { - print ''; - } - } - } - print '
' . $langs->trans("Num") . "' . $langs->trans("Customer") . "" . $langs->trans("VATIntra") . "" . $langs->trans("AmountHTVATRealReceived") . "" . $vatcust . "
' . $i . "' . $company_static->getNomUrl(1, 'customer') . '' . $intra . "" . price($coll->amount) . "" . price($coll->tva) . "
' . $langs->trans("Total") . ':' . price($totalamount) . '' . price($total) . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . $langs->trans("Error") . '
'; -} llxFooter(); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 1c9632fac61..d22d252f39c 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; $langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin")); @@ -199,8 +200,8 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu if ($m > 12) $m -= 12; $mcursor++; - $coll_listsell = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = tax_by_date('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $coll_listsell = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $coll_listbuy = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); $action = "tva"; $object = array(&$coll_listsell, &$coll_listbuy); diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index e04f4d83ee8..28b2878998f 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -22,7 +22,7 @@ /** * \file htdocs/compta/tva/quadri_detail.php * \ingroup tax - * \brief Trimestrial page - detailed version + * \brief VAT by rate */ require '../../main.inc.php'; @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -55,10 +56,10 @@ $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GE // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start,empty($conf->global->SOCIETE_FISCAL_MONTH_START)?1:$conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -96,6 +97,16 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); * View */ +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + $morequerystring=''; $listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); foreach ($listofparams as $param) @@ -105,16 +116,6 @@ foreach ($listofparams as $param) llxHeader('',$langs->trans("VATReport"),'','',0,0,'','',$morequerystring); -$form=new Form($db); - -$company_static=new Societe($db); -$invoice_customer=new Facture($db); -$invoice_supplier=new FactureFournisseur($db); -$expensereport=new ExpenseReport($db); -$product_static=new Product($db); -$payment_static=new Paiement($db); -$paymentfourn_static=new PaiementFourn($db); -$paymentexpensereport_static=new PaymentExpenseReport($db); //print load_fiche_titre($langs->trans("VAT"),""); @@ -185,6 +186,7 @@ $vatcust=$langs->trans("VATReceived"); $vatsup=$langs->trans("VATPaid"); $vatexpensereport=$langs->trans("VATPaid"); + // VAT Received and paid print ''; @@ -194,8 +196,8 @@ $i=0; $columns = 5; // Load arrays of datas -$x_coll = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); -$x_paye = tax_by_date('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); +$x_coll = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = tax_by_rate('vat', $db, 0, 0, $date_start, $date_end, $modetax, 'buy'); if (! is_array($x_coll) || ! is_array($x_paye)) { @@ -362,7 +364,6 @@ if (! is_array($x_coll) || ! is_array($x_paye)) if (is_array($x_both[$rate]['coll']['detail'])) { // VAT Rate - $var=true; print ""; print ''; print ''."\n"; @@ -504,7 +505,7 @@ if (! is_array($x_coll) || ! is_array($x_paye)) print ''; } - if (count($x_coll) == 0) // Show a total ine if nothing shown + if (count($x_coll) == 0) // Show a total line if nothing shown { print ''; print ''; @@ -544,7 +545,6 @@ if (! is_array($x_coll) || ! is_array($x_paye)) if (is_array($x_both[$rate]['paye']['detail'])) { - $var=true; print ""; print ''; print ''."\n"; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 99737322267..216b2c7ea33 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -77,107 +77,467 @@ function tax_prepare_head(ChargeSociales $object) /** * Look for collectable VAT clients in the chosen year (and month) * + * @param string $type Tax type, either 'vat', 'localtax1' or 'localtax2' * @param DoliDB $db Database handle * @param int $y Year * @param string $date_start Start date * @param string $date_end End date - * @param int $modetax 0 or 1 (option vat on debit, 1 => $modecompta = 'CREANCES-DETTES') + * @param int $modetax Not used * @param string $direction 'sell' or 'buy' * @param int $m Month - * @return array List of customers third parties with vat, -1 if no accountancy module, -2 if not yet developped, -3 if error + * @param int $q Quarter + * @return array Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error */ -function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction, $m=0) +function tax_by_thirdparty($type='vat', $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0) { global $conf; - $list=array(); + // If we use date_start and date_end, we must not use $y, $m, $q + if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) + { + dol_print_error('', 'Bad value of input parameter for tax_by_rate'); + } + $list=array(); if ($direction == 'sell') { - $invoicetable='facture'; - $total_ht='total'; - $total_tva='tva'; + $invoicetable='facture'; + $invoicedettable='facturedet'; + $fk_facture='fk_facture'; + $fk_facture2='fk_facture'; + $fk_payment='fk_paiement'; + $total_tva='total_tva'; + $paymenttable='paiement'; + $paymentfacturetable='paiement_facture'; + $invoicefieldref='facnumber'; } if ($direction == 'buy') { - $invoicetable='facture_fourn'; - $total_ht='total_ht'; - $total_tva='total_tva'; + $invoicetable='facture_fourn'; + $invoicedettable='facture_fourn_det'; + $fk_facture='fk_facture_fourn'; + $fk_facture2='fk_facturefourn'; + $fk_payment='fk_paiementfourn'; + $total_tva='tva'; + $paymenttable='paiementfourn'; + $paymentfacturetable='paiementfourn_facturefourn'; + $invoicefieldref='ref'; } + if ( strpos( $type, 'localtax' ) === 0 ) { + $f_rate = $type . '_tx'; + } else { + $f_rate = 'tva_tx'; + } + + $total_localtax1='total_localtax1'; + $total_localtax2='total_localtax2'; + + + // CAS DES BIENS/PRODUITS + // Define sql request $sql=''; - if ($modetax == 1) + if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_PRODUCT == 'invoice')) { - // If vat paid on due invoices (non draft) - $sql = "SELECT s.rowid as socid, s.nom as name, s.tva_intra as tva_intra, s.tva_assuj as assuj,"; - $sql.= " sum(f.$total_ht) as amount, sum(f.".$total_tva.") as tva,"; - $sql.= " sum(f.localtax1) as localtax1,"; - $sql.= " sum(f.localtax2) as localtax2"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE f.entity = " . $conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - if ($y && $m) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; - } - else if ($y) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; - } - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND s.rowid = f.fk_soc"; - $sql.= " GROUP BY s.rowid, s.nom, s.tva_intra, s.tva_assuj"; + // Count on delivery date (use invoice date as delivery is unknown) + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql.= " d.date_start as date_start, d.date_end as date_end,"; + $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " 0 as payment_id, 0 as payment_amount"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND s.rowid = f.fk_soc"; + if ($y && $m) + { + $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; + $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; + } + else if ($y) + { + $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; + $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; + } + if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; + if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql.= " AND (d.product_type = 0"; // Limit to products + $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else { - // Tva sur factures payes (should be on payment) -/* $sql = "SELECT s.rowid as socid, s.nom as nom, s.tva_intra as tva_intra, s.tva_assuj as assuj,"; - $sql.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (2)"; // Paid (partially or completely) - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; - else $sql.= " AND f.type IN (0,1,2,3,5)"; - if ($y && $m) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; - } - else if ($y) - { - $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; - $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; - } - if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; - $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; - $sql.= " GROUP BY s.rowid as socid, s.nom as nom, s.tva_intra as tva_intra, s.tva_assuj as assuj"; -*/ + // Count on payments date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql.= " d.date_start as date_start, d.date_end as date_end,"; + $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql.= " pa.datep as datep"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND s.rowid = f.fk_soc"; + $sql.= " AND pf.".$fk_facture2." = f.rowid"; + $sql.= " AND pa.rowid = pf.".$fk_payment; + if ($y && $m) + { + $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; + $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; + } + else if ($y) + { + $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; + $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; + } + if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; + if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql.= " AND (d.product_type = 0"; // Limit to products + $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } if (! $sql) return -1; - - dol_syslog("Tax.lib:thirdparty", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) + if ($sql == 'TODO') return -2; + if ($sql != 'TODO') { - while($assoc = $db->fetch_object($resql)) - { - $list[] = $assoc; - } - $db->free($resql); - return $list; + dol_syslog("Tax.lib.php::tax_by_thirdparty", LOG_DEBUG); + + $resql = $db->query($sql); + if ($resql) + { + $company_id = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; + if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; + if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; + if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid + { + $oldrowid=$assoc['rowid']; + $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; + $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; + $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; + } + $list[$assoc['company_id']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['company_id']]['dtype'][] = $assoc['dtype']; + $list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']); + $list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']); + $list[$assoc['company_id']]['company_name'][] = $assoc['company_name']; + $list[$assoc['company_id']]['company_id'][] = $assoc['company_id']; + $list[$assoc['company_id']]['drate'][] = $assoc['rate']; + $list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['company_id']]['facid'][] = $assoc['facid']; + $list[$assoc['company_id']]['facnum'][] = $assoc['facnum']; + $list[$assoc['company_id']]['type'][] = $assoc['type']; + $list[$assoc['company_id']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['company_id']]['descr'][] = $assoc['descr']; + + $list[$assoc['company_id']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['company_id']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['company_id']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['company_id']]['pid'][] = $assoc['pid']; + $list[$assoc['company_id']]['pref'][] = $assoc['pref']; + $list[$assoc['company_id']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['company_id']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['company_id']]['payment_amount'][] = $assoc['payment_amount']; + + $company_id = $assoc['company_id']; + } + } + else + { + dol_print_error($db); + return -3; + } + } + + + // CAS DES SERVICES + + // Define sql request + $sql=''; + if (($direction == 'sell' && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice') + || ($direction == 'buy' && $conf->global->TAX_MODE_BUY_SERVICE == 'invoice')) + { + // Count on invoice date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql.= " d.date_start as date_start, d.date_end as date_end,"; + $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " 0 as payment_id, 0 as payment_amount"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " AND f.fk_statut in (1,2)"; // Validated or paid (partially or completely) + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND s.rowid = f.fk_soc"; + if ($y && $m) + { + $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; + $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; + } + else if ($y) + { + $sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'"; + $sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'"; + } + if ($q) $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; + if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; + $sql.= " AND (d.product_type = 1"; // Limit to services + $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else { - dol_print_error($db); - return -3; + // Count on payments date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql .=" d.".$total_localtax1." as total_localtax1, d.".$total_localtax2." as total_localtax2, "; + $sql.= " d.date_start as date_start, d.date_end as date_end,"; + $sql.= " f.".$invoicefieldref." as facnum, f.type, f.total_ttc as ftotal_ttc, f.datef, s.nom as company_name, s.rowid as company_id,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount,"; + $sql.= " pa.datep as datep"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql.= " ".MAIN_DB_PREFIX."societe as s,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE f.entity = " . $conf->entity; + $sql.= " AND f.fk_statut in (1,2)"; // Paid (partially or completely) + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2,5)"; + else $sql.= " AND f.type IN (0,1,2,3,5)"; + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND s.rowid = f.fk_soc"; + $sql.= " AND pf.".$fk_facture2." = f.rowid"; + $sql.= " AND pa.rowid = pf.".$fk_payment; + if ($y && $m) + { + $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; + $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; + } + else if ($y) + { + $sql.= " AND pa.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; + $sql.= " AND pa.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; + } + if ($q) $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; + if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; + $sql.= " AND (d.product_type = 1"; // Limit to services + $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; + $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } + + if (! $sql) + { + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); + return -1; // -1 = Not accountancy module enabled + } + if ($sql == 'TODO') return -2; // -2 = Feature not yet available + if ($sql != 'TODO') + { + dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $company_id = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; + if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; + if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; + if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid + { + $oldrowid=$assoc['rowid']; + $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; + $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; + $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; + } + $list[$assoc['company_id']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['company_id']]['dtype'][] = $assoc['dtype']; + $list[$assoc['company_id']]['datef'][] = $db->jdate($assoc['datef']); + $list[$assoc['company_id']]['datep'][] = $db->jdate($assoc['datep']); + $list[$assoc['company_id']]['company_name'][] = $assoc['company_name']; + $list[$assoc['company_id']]['company_id'][] = $assoc['company_id']; + $list[$assoc['company_id']]['drate'][] = $assoc['rate']; + $list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['company_id']]['facid'][] = $assoc['facid']; + $list[$assoc['company_id']]['facnum'][] = $assoc['facnum']; + $list[$assoc['company_id']]['type'][] = $assoc['type']; + $list[$assoc['company_id']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['company_id']]['descr'][] = $assoc['descr']; + + $list[$assoc['company_id']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['company_id']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['company_id']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['company_id']]['pid'][] = $assoc['pid']; + $list[$assoc['company_id']]['pref'][] = $assoc['pref']; + $list[$assoc['company_id']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['company_id']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['company_id']]['payment_amount'][] = $assoc['payment_amount']; + + $company_id = $assoc['company_id']; + } + } + else + { + dol_print_error($db); + return -3; + } + } + + + // CASE OF EXPENSE REPORT + + if ($direction == 'buy') // buy only for expense reports + { + // Define sql request + $sql=''; + + // Count on payments date + $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; + $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; + $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; + $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; + $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; + $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport_det as d ON d.fk_expensereport = e.rowid "; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_expensereport as p ON p.fk_expensereport = e.rowid "; + $sql.= " WHERE e.entity = " . $conf->entity; + $sql.= " AND e.fk_statut in (6)"; + if ($y && $m) + { + $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,$m,false))."'"; + $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,$m,false))."'"; + } + else if ($y) + { + $sql.= " AND p.datep >= '".$db->idate(dol_get_first_day($y,1,false))."'"; + $sql.= " AND p.datep <= '".$db->idate(dol_get_last_day($y,12,false))."'"; + } + if ($q) $sql.= " AND (date_format(p.datep,'%m') > ".(($q-1)*3)." AND date_format(p.datep,'%m') <= ".($q*3).")"; + if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; + $sql.= " AND (d.product_type = -1"; + $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service + $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; + $sql.= " ORDER BY e.rowid"; + + if (! $sql) + { + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); + return -1; // -1 = Not accountancy module enabled + } + if ($sql == 'TODO') return -2; // -2 = Feature not yet available + if ($sql != 'TODO') + { + dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $company_id = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['company_id']]['totalht'])) $list[$assoc['company_id']]['totalht']=0; + if (! isset($list[$assoc['company_id']]['vat'])) $list[$assoc['company_id']]['vat']=0; + if (! isset($list[$assoc['company_id']]['localtax1'])) $list[$assoc['company_id']]['localtax1']=0; + if (! isset($list[$assoc['company_id']]['localtax2'])) $list[$assoc['company_id']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid + { + $oldrowid=$assoc['rowid']; + $list[$assoc['company_id']]['totalht'] += $assoc['total_ht']; + $list[$assoc['company_id']]['vat'] += $assoc['total_vat']; + $list[$assoc['company_id']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['company_id']]['localtax2'] += $assoc['total_localtax2']; + } + + $list[$assoc['company_id']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['company_id']]['dtype'][] = 'ExpenseReportPayment'; + $list[$assoc['company_id']]['datef'][] = $assoc['datef']; + $list[$assoc['company_id']]['company_name'][] = ''; + $list[$assoc['company_id']]['company_id'][] = ''; + $list[$assoc['company_id']]['user_id'][] = $assoc['fk_user_author']; + $list[$assoc['company_id']]['drate'][] = $assoc['rate']; + $list[$assoc['company_id']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['company_id']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['company_id']]['facid'][] = $assoc['facid']; + $list[$assoc['company_id']]['facnum'][] = $assoc['facnum']; + $list[$assoc['company_id']]['type'][] = $assoc['type']; + $list[$assoc['company_id']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['company_id']]['descr'][] = $assoc['descr']; + + $list[$assoc['company_id']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['company_id']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['company_id']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['company_id']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['company_id']]['pid'][] = $assoc['pid']; + $list[$assoc['company_id']]['pref'][] = $assoc['pref']; + $list[$assoc['company_id']]['ptype'][] = 'ExpenseReportPayment'; + + $list[$assoc['company_id']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['company_id']]['payment_amount'][] = $assoc['payment_amount']; + + $company_id = $assoc['company_id']; + } + } + else + { + dol_print_error($db); + return -3; + } + } + } + + return $list; } /** @@ -191,19 +551,19 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction * @param int $q Quarter * @param string $date_start Start date * @param string $date_end End date - * @param int $modetax 0 or 1 (option vat on debit) + * @param int $modetax Not used * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) * @param int $m Month - * @return array List of quarters with vat + * @return array Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error */ -function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) +function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m=0) { global $conf; // If we use date_start and date_end, we must not use $y, $m, $q if (($date_start || $date_end) && (! empty($y) || ! empty($m) || ! empty($q))) { - dol_print_error('', 'Bad value of input parameter for tax_by_date'); + dol_print_error('', 'Bad value of input parameter for tax_by_rate'); } $list=array(); @@ -242,6 +602,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $total_localtax1='total_localtax1'; $total_localtax2='total_localtax2'; + // CAS DES BIENS/PRODUITS // Define sql request @@ -280,6 +641,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -320,6 +682,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 0"; // Limit to products $sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of products + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } @@ -327,7 +690,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($sql == 'TODO') return -2; if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); if ($resql) @@ -425,6 +788,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture; } else @@ -465,18 +829,19 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND pa.datep >= '".$db->idate($date_start)."' AND pa.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = 1"; // Limit to services $sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service + $sql.= " AND (d.".$f_rate." <> 0 OR d.".$total_tva." <> 0)"; $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; } if (! $sql) { - dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -534,8 +899,10 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire } } - // Expense Report - if ($direction == 'buy') + + // CASE OF EXPENSE REPORT + + if ($direction == 'buy') // buy only for expense reports { // Define sql request $sql=''; @@ -543,7 +910,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire // Count on payments date $sql = "SELECT d.rowid, d.product_type as dtype, e.rowid as facid, d.$f_rate as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.total_tva as total_vat, e.note_private as descr,"; $sql .=" d.total_localtax1 as total_localtax1, d.total_localtax2 as total_localtax2, "; - $sql.= " e.date_debut as date_start, e.date_fin as date_end,"; + $sql.= " e.date_debut as date_start, e.date_fin as date_end, e.fk_user_author,"; $sql.= " e.ref as facnum, e.total_ttc as ftotal_ttc, e.date_create, d.fk_c_type_fees as type,"; $sql.= " p.fk_bank as payment_id, p.amount as payment_amount, p.rowid as pid, e.ref as pref"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as e "; @@ -565,17 +932,18 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire if ($date_start && $date_end) $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql.= " AND (d.product_type = -1"; $sql.= " OR e.date_debut is NOT null OR e.date_fin IS NOT NULL)"; // enhance detection of service + $sql.= " AND (d.".$f_rate." <> 0 OR d.total_tva <> 0)"; $sql.= " ORDER BY e.rowid"; if (! $sql) { - dol_syslog("Tax.lib.php::tax_by_date no accountancy module enabled".$sql,LOG_ERR); + dol_syslog("Tax.lib.php::tax_by_rate no accountancy module enabled".$sql,LOG_ERR); return -1; // -1 = Not accountancy module enabled } if ($sql == 'TODO') return -2; // -2 = Feature not yet available if ($sql != 'TODO') { - dol_syslog("Tax.lib.php::tax_by_date", LOG_DEBUG); + dol_syslog("Tax.lib.php::tax_by_rate", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -602,6 +970,7 @@ function tax_by_date($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['datef'][] = $assoc['datef']; $list[$assoc['rate']]['company_name'][] = ''; $list[$assoc['rate']]['company_id'][] = ''; + $list[$assoc['rate']]['user_id'][] = $assoc['fk_user_author']; $list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']); $list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e3a2ca4515d..71901d2fcef 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -903,7 +903,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i',$leftmenu)) $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); global $mysoc; - //Local Taxes //Local Taxes 1 if($mysoc->useLocalTax(1) && (isset($mysoc->localtax1_assuj) && $mysoc->localtax1_assuj=="1")) { diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 24724088e45..7f98b8797e8 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -171,6 +171,7 @@ LT1ReportByCustomersES=Report by third party RE LT2ReportByCustomersES=Report by third party IRPF VATReport=Sale tax report VATReportByPeriods=Sale tax report by period +VATReportByThirdParties=Sale tax report by third parties VATReportByCustomers=Sale tax report by customer VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid VATReportByQuartersInInputOutputMode=Report by Sale tax rate of the tax collected and paid From 7cedf55c273d36353540c70a5d0fc01f8e94cab4 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 27 Apr 2018 20:54:48 +0200 Subject: [PATCH 474/609] FIX : missing english name for object 'product' is used by API to check perms and return a 401 error even if user has correct permissions --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index a901dd817d5..c9968bb459f 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -384,7 +384,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh if ($feature == 'project') $feature='projet'; if ($feature == 'task') $feature='projet_task'; - $check = array('adherent','banque','don','user','usergroup','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) + $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object From 07b9a9b44d999e5e606de5afd493ede148d129a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Apr 2018 13:08:09 +0200 Subject: [PATCH 475/609] Better US english --- htdocs/langs/en_US/accountancy.lang | 12 +++---- htdocs/langs/en_US/admin.lang | 40 ++++++++++----------- htdocs/langs/en_US/bills.lang | 2 +- htdocs/langs/en_US/commercial.lang | 4 +-- htdocs/langs/en_US/companies.lang | 40 ++++++++++----------- htdocs/langs/en_US/compta.lang | 9 ++--- htdocs/langs/en_US/ecm.lang | 4 +-- htdocs/langs/en_US/errors.lang | 10 +++--- htdocs/langs/en_US/install.lang | 2 +- htdocs/langs/en_US/main.lang | 16 ++++----- htdocs/langs/en_US/margins.lang | 4 +-- htdocs/langs/en_US/orders.lang | 40 ++++++++++----------- htdocs/langs/en_US/supplier_proposal.lang | 24 ++++++------- htdocs/langs/en_US/suppliers.lang | 44 +++++++++++------------ htdocs/langs/en_US/workflow.lang | 4 +-- 15 files changed, 128 insertions(+), 127 deletions(-) diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 83be8d8e423..f3acb7ac39c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -40,11 +40,11 @@ AccountWithNonZeroValues=Accounts with non zero values ListOfAccounts=List of accounts MainAccountForCustomersNotDefined=Main accounting account for customers not defined in setup -MainAccountForSuppliersNotDefined=Main accounting account for suppliers not defined in setup +MainAccountForSuppliersNotDefined=Main accounting account for veo not defined in setup MainAccountForUsersNotDefined=Main accounting account for users not defined in setup MainAccountForVatPaymentNotDefined=Main accounting account for VAT payment not defined in setup -AccountancyArea=Accountancy area +AccountancyArea=Accounting area AccountancyAreaDescIntro=Usage of the accountancy module is done in several step: AccountancyAreaDescActionOnce=The following actions are usually executed one time only, or once per year... AccountancyAreaDescActionOnceBis=Next steps should be done to save you time in future by suggesting you the correct default accounting account when making the journalization (writing record in Journals and General ledger) @@ -90,7 +90,7 @@ MenuProductsAccounts=Product accounts ProductsBinding=Products accounts Ventilation=Binding to accounts CustomersVentilation=Customer invoice binding -SuppliersVentilation=Supplier invoice binding +SuppliersVentilation=Vendor invoice binding ExpenseReportsVentilation=Expense report binding CreateMvts=Create new transaction UpdateMvts=Modification of a transaction @@ -186,7 +186,7 @@ ListeMvts=List of movements ErrorDebitCredit=Debit and Credit cannot have a value at the same time AddCompteFromBK=Add accounting accounts to the group ReportThirdParty=List third party account -DescThirdPartyReport=Consult here the list of the third party customers and suppliers and their accounting accounts +DescThirdPartyReport=Consult here the list of the third party customers and vendors and their accounting accounts ListAccounts=List of the accounting accounts UnknownAccountForThirdparty=Unknown third party account. We will use %s UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error @@ -205,8 +205,8 @@ DescVentilDoneCustomer=Consult here the list of the lines of invoices customers DescVentilTodoCustomer=Bind invoice lines not already bound with a product accounting account ChangeAccount=Change the product/service accounting account for selected lines with the following accounting account: Vide=- -DescVentilSupplier=Consult here the list of supplier invoice lines bound or not yet bound to a product accounting account -DescVentilDoneSupplier=Consult here the list of the lines of invoices supplier and their accounting account +DescVentilSupplier=Consult here the list of vndor invoice lines bound or not yet bound to a product accounting account +DescVentilDoneSupplier=Consult here the list of the lines of invoices vendors and their accounting account DescVentilTodoExpenseReport=Bind expense report lines not already bound with a fee accounting account DescVentilExpenseReport=Consult here the list of expense report lines bound (or not) to a fee accounting account DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button "%s". If account was not set on fees dictionary or if you still has some lines not bound to any account, you will have to make a manual binding from the menu "%s". diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index b02d90207cf..0b192e96429 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -269,7 +269,7 @@ MAIN_MAIL_SMTP_SERVER=SMTP/SMTPS Host (By default in php.ini: %s) MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike=SMTP/SMTPS Port (Not defined into PHP on Unix like systems) MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike=SMTP/SMTPS Host (Not defined into PHP on Unix like systems) MAIN_MAIL_EMAIL_FROM=Sender email for automatic emails (By default in php.ini: %s) -MAIN_MAIL_ERRORS_TO=Email used as 'Errors-To' field in emails sent +MAIN_MAIL_ERRORS_TO=Eemail used for error returns emails (fields 'Errors-To' in emails sent) MAIN_MAIL_AUTOCOPY_TO= Send systematically a hidden carbon-copy of all sent emails to MAIN_DISABLE_ALL_MAILS=Disable all emails sendings (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) @@ -292,7 +292,7 @@ ModuleSetup=Module setup ModulesSetup=Modules/Application setup ModuleFamilyBase=System ModuleFamilyCrm=Customer Relation Management (CRM) -ModuleFamilySrm=Supplier Relation Management (SRM) +ModuleFamilySrm=Vendor Relation Management (SRM) ModuleFamilyProducts=Products Management (PM) ModuleFamilyHr=Human Resource Management (HR) ModuleFamilyProjects=Projects/Collaborative work @@ -563,14 +563,14 @@ Module700Name=Donations Module700Desc=Donation management Module770Name=Expense reports Module770Desc=Management and claim expense reports (transportation, meal, ...) -Module1120Name=Supplier commercial proposal -Module1120Desc=Request supplier commercial proposal and prices +Module1120Name=Vendor commercial proposal +Module1120Desc=Request vndor commercial proposal and prices Module1200Name=Mantis Module1200Desc=Mantis integration Module1520Name=Document Generation Module1520Desc=Mass mail document generation Module1780Name=Tags/Categories -Module1780Desc=Create tags/category (products, customers, suppliers, contacts or members) +Module1780Desc=Create tags/category (products, customers, vendors, contacts or members) Module2000Name=WYSIWYG editor Module2000Desc=Allow to edit some text area using an advanced editor (Based on CKEditor) Module2200Name=Dynamic Prices @@ -1191,11 +1191,11 @@ UserMailRequired=EMail required to create a new user HRMSetup=HRM module setup ##### Company setup ##### CompanySetup=Companies module setup -CompanyCodeChecker=Module for third parties code generation and checking (customer or supplier) -AccountCodeManager=Module for accounting code generation (customer or supplier) +CompanyCodeChecker=Module for third parties code generation and checking (customer or vendor) +AccountCodeManager=Module for accounting code generation (customer or vendor) NotificationsDesc=EMails notifications feature allows you to silently send automatic mail, for some Dolibarr events. Targets of notifications can be defined: NotificationsDescUser=* per users, one user at time. -NotificationsDescContact=* per third parties contacts (customers or suppliers), one contact at time. +NotificationsDescContact=* per third parties contacts (customers or vendors), one contact at time. NotificationsDescGlobal=* or by setting global target emails in module setup page. ModelModules=Documents templates DocumentModelOdt=Generate documents from OpenDocuments templates (.ODT or .ODS files for OpenOffice, KOffice, TextEdit,...) @@ -1235,15 +1235,15 @@ FreeLegalTextOnProposal=Free text on commercial proposals WatermarkOnDraftProposal=Watermark on draft commercial proposals (none if empty) BANK_ASK_PAYMENT_BANK_DURING_PROPOSAL=Ask for bank account destination of proposal ##### SupplierProposal ##### -SupplierProposalSetup=Price requests suppliers module setup -SupplierProposalNumberingModules=Price requests suppliers numbering models -SupplierProposalPDFModules=Price requests suppliers documents models -FreeLegalTextOnSupplierProposal=Free text on price requests suppliers -WatermarkOnDraftSupplierProposal=Watermark on draft price requests suppliers (none if empty) +SupplierProposalSetup=Price requests vendors module setup +SupplierProposalNumberingModules=Price requests vendors numbering models +SupplierProposalPDFModules=Price requests vendors documents models +FreeLegalTextOnSupplierProposal=Free text on price requests vendors +WatermarkOnDraftSupplierProposal=Watermark on draft price requests vendors (none if empty) BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL=Ask for bank account destination of price request WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER=Ask for Warehouse Source for order ##### Suppliers Orders ##### -BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER=Ask for bank account destination of supplier order +BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_ORDER=Ask for bank account destination of purchase order ##### Orders ##### OrdersSetup=Order management setup OrdersNumberingModules=Orders numbering models @@ -1633,8 +1633,8 @@ ChequeReceiptsNumberingModule=Cheque Receipts Numbering module MultiCompanySetup=Multi-company module setup ##### Suppliers ##### SuppliersSetup=Supplier module setup -SuppliersCommandModel=Complete template of supplier order (logo...) -SuppliersInvoiceModel=Complete template of supplier invoice (logo...) +SuppliersCommandModel=Complete template of prchase order (logo...) +SuppliersInvoiceModel=Complete template of vendor invoice (logo...) SuppliersInvoiceNumberingModel=Supplier invoices numbering models IfSetToYesDontForgetPermission=If set to yes, don't forget to provide permissions to groups or users allowed for the second approval ##### GeoIPMaxmind ##### @@ -1671,7 +1671,7 @@ NoAmbiCaracAutoGeneration=Do not use ambiguous characters ("1","l","i","|","0"," SalariesSetup=Setup of module salaries SortOrder=Sort order Format=Format -TypePaymentDesc=0:Customer payment type, 1:Supplier payment type, 2:Both customers and suppliers payment type +TypePaymentDesc=0:Customer payment type, 1:Vndor payment type, 2:Both customers and vendors payment type IncludePath=Include path (defined into variable %s) ExpenseReportsSetup=Setup of module Expense Reports TemplatePDFExpenseReports=Document templates to generate expense report document @@ -1730,9 +1730,9 @@ MailToSendOrder=Customer orders MailToSendInvoice=Customer invoices MailToSendShipment=Shipments MailToSendIntervention=Interventions -MailToSendSupplierRequestForQuotation=Supplier quotations -MailToSendSupplierOrder=Supplier orders -MailToSendSupplierInvoice=Supplier invoices +MailToSendSupplierRequestForQuotation=Quotation request +MailToSendSupplierOrder=Purchase orders +MailToSendSupplierInvoice=Vendor invoices MailToSendContract=Contracts MailToThirdparty=Third parties MailToMember=Members diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 8471cd22fe6..b4891579763 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -299,7 +299,7 @@ DiscountOfferedBy=Granted by DiscountStillRemaining=Discounts or credits available DiscountAlreadyCounted=Discounts or credits already consumed CustomerDiscounts=Customer discounts -SupplierDiscounts=Supplier discounts +SupplierDiscounts=Vendors discounts BillAddress=Bill address HelpEscompte=This discount is a discount granted to customer because its payment was made before term. HelpAbandonBadCustomer=This amount has been abandoned (customer said to be a bad customer) and is considered as an exceptional loose. diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index 24f5bc100f6..9f2e16857de 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -60,8 +60,8 @@ ActionAC_CLO=Close ActionAC_EMAILING=Send mass email ActionAC_COM=Send customer order by mail ActionAC_SHIP=Send shipping by mail -ActionAC_SUP_ORD=Send supplier order by mail -ActionAC_SUP_INV=Send supplier invoice by mail +ActionAC_SUP_ORD=Send purchase order by mail +ActionAC_SUP_INV=Send vendor invoice by mail ActionAC_OTH=Other ActionAC_OTH_AUTO=Automatically inserted events ActionAC_MANUAL=Manually inserted events diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 3473667fe55..b3c458833d9 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -8,11 +8,11 @@ ConfirmDeleteContact=Are you sure you want to delete this contact and all inheri MenuNewThirdParty=New third party MenuNewCustomer=New customer MenuNewProspect=New prospect -MenuNewSupplier=New supplier +MenuNewSupplier=New vendor MenuNewPrivateIndividual=New private individual -NewCompany=New company (prospect, customer, supplier) -NewThirdParty=New third party (prospect, customer, supplier) -CreateDolibarrThirdPartySupplier=Create a third party (supplier) +NewCompany=New company (prospect, customer, vendor) +NewThirdParty=New third party (prospect, customer, vendor) +CreateDolibarrThirdPartySupplier=Create a third party (vendor) CreateThirdPartyOnly=Create third party CreateThirdPartyAndContact=Create a third party + a child contact ProspectionArea=Prospection area @@ -37,7 +37,7 @@ ThirdPartyProspectsStats=Prospects ThirdPartyCustomers=Customers ThirdPartyCustomersStats=Customers ThirdPartyCustomersWithIdProf12=Customers with %s or %s -ThirdPartySuppliers=Suppliers +ThirdPartySuppliers=Vendors ThirdPartyType=Third party type Individual=Private individual ToCreateContactWithSameName=Will create automatically a contact/address with same information than third party under the third party. In most cases, even if your third party is a physical people, creating a third party alone is enough. @@ -80,7 +80,7 @@ VATIsUsed=Sales tax is used VATIsUsedWhenSelling=This define if this thirdparty includes a sale tax or not when it makes an invoice to its own customers VATIsNotUsed=Sales tax is not used CopyAddressFromSoc=Fill address with third party address -ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor supplier, no available refering objects +ThirdpartyNotCustomerNotSupplierSoNoRef=Thirdparty neither customer nor vendor, no available refering objects ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts=Thirdparty neither customer nor supplier, discounts are not available PaymentBankAccount=Payment bank account OverAllProposals=Proposals @@ -99,9 +99,9 @@ LocalTax2ES=IRPF TypeLocaltax1ES=RE Type TypeLocaltax2ES=IRPF Type WrongCustomerCode=Customer code invalid -WrongSupplierCode=Supplier code invalid +WrongSupplierCode=Vendor code invalid CustomerCodeModel=Customer code model -SupplierCodeModel=Supplier code model +SupplierCodeModel=Vendor code model Gencod=Bar code ##### Professional ID ##### ProfId1Short=Prof. id 1 @@ -267,7 +267,7 @@ Prospect=Prospect CustomerCard=Customer Card Customer=Customer CustomerRelativeDiscount=Relative customer discount -SupplierRelativeDiscount=Relative supplier discount +SupplierRelativeDiscount=Relative vendor discount CustomerRelativeDiscountShort=Relative discount CustomerAbsoluteDiscountShort=Absolute discount CompanyHasRelativeDiscount=This customer has a default discount of %s%% @@ -284,8 +284,8 @@ HasCreditNoteFromSupplier=You have credit notes for %s %s from this suppl CompanyHasNoAbsoluteDiscount=This customer has no discount credit available CustomerAbsoluteDiscountAllUsers=Absolute customer discounts (granted by all users) CustomerAbsoluteDiscountMy=Absolute customer discounts (granted by yourself) -SupplierAbsoluteDiscountAllUsers=Absolute supplier discounts (granted by all users) -SupplierAbsoluteDiscountMy=Absolute supplier discounts (granted by yourself) +SupplierAbsoluteDiscountAllUsers=Absolute vendor discounts (granted by all users) +SupplierAbsoluteDiscountMy=Absolute vendor discounts (granted by yourself) DiscountNone=None Supplier=Supplier AddContact=Create contact @@ -304,13 +304,13 @@ DeleteACompany=Delete a company PersonalInformations=Personal data AccountancyCode=Accounting account CustomerCode=Customer code -SupplierCode=Supplier code +SupplierCode=Vendor code CustomerCodeShort=Customer code -SupplierCodeShort=Supplier code +SupplierCodeShort=Vendor code CustomerCodeDesc=Customer code, unique for all customers -SupplierCodeDesc=Supplier code, unique for all suppliers +SupplierCodeDesc=Vendor code, unique for all vendors RequiredIfCustomer=Required if third party is a customer or prospect -RequiredIfSupplier=Required if third party is a supplier +RequiredIfSupplier=Required if third party is a vendor ValidityControledByModule=Validity controled by module ThisIsModuleRules=This is rules for this module ProspectToContact=Prospect to contact @@ -338,7 +338,7 @@ MyContacts=My contacts Capital=Capital CapitalOf=Capital of %s EditCompany=Edit company -ThisUserIsNot=This user is not a prospect, customer nor supplier +ThisUserIsNot=This user is not a prospect, customer nor vendor VATIntraCheck=Check VATIntraCheckDesc=The link %s allows to ask the european VAT checker service. An external internet access from server is required for this service to work. VATIntraCheckURL=http://ec.europa.eu/taxation_customs/vies/vieshome.do @@ -396,7 +396,7 @@ ImportDataset_company_4=Third parties/Sales representatives (Assign sales repres PriceLevel=Price level DeliveryAddress=Delivery address AddAddress=Add address -SupplierCategory=Supplier category +SupplierCategory=Vendor category JuridicalStatus200=Independent DeleteFile=Delete file ConfirmDeleteFile=Are you sure you want to delete this file? @@ -406,7 +406,7 @@ FiscalYearInformation=Information on the fiscal year FiscalMonthStart=Starting month of the fiscal year YouMustAssignUserMailFirst=You must create email for this user first to be able to add emails notifications for him. YouMustCreateContactFirst=To be able to add email notifications, you must first define contacts with valid emails for the third party -ListSuppliersShort=List of suppliers +ListSuppliersShort=List of vendors ListProspectsShort=List of prospects ListCustomersShort=List of customers ThirdPartiesArea=Third parties and contact area @@ -420,7 +420,7 @@ CurrentOutstandingBill=Current outstanding bill OutstandingBill=Max. for outstanding bill OutstandingBillReached=Max. for outstanding bill reached OrderMinAmount=Minimum amount for order -MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. +MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for vendor code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. LeopardNumRefModelDesc=The code is free. This code can be modified at any time. ManagingDirectors=Manager(s) name (CEO, director, president...) MergeOriginThirdparty=Duplicate third party (third party you want to delete) @@ -431,4 +431,4 @@ SaleRepresentativeLogin=Login of sales representative SaleRepresentativeFirstname=First name of sales representative SaleRepresentativeLastname=Last name of sales representative ErrorThirdpartiesMerge=There was an error when deleting the third parties. Please check the log. Changes have been reverted. -NewCustomerSupplierCodeProposed=New customer or supplier code suggested on duplicate code +NewCustomerSupplierCodeProposed=New customer or vendor code suggested on duplicate code diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 7f98b8797e8..1e457cedcd2 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -80,12 +80,12 @@ AccountancyTreasuryArea=Accountancy/Treasury area NewPayment=New payment Payments=Payments PaymentCustomerInvoice=Customer invoice payment -PaymentSupplierInvoice=Supplier invoice payment +PaymentSupplierInvoice=Vendor invoice payment PaymentSocialContribution=Social/fiscal tax payment PaymentVat=VAT payment ListPayment=List of payments ListOfCustomerPayments=List of customer payments -ListOfSupplierPayments=List of supplier payments +ListOfSupplierPayments=List of vendor payments DateStartPeriod=Date start period DateEndPeriod=Date end period newLT1Payment=New tax 2 payment @@ -110,7 +110,7 @@ ShowVatPayment=Show VAT payment TotalToPay=Total to pay BalanceVisibilityDependsOnSortAndFilters=Balance is visible in this list only if table is sorted ascending on %s and filtered for 1 bank account CustomerAccountancyCode=Customer accounting code -SupplierAccountancyCode=Supplier accounting code +SupplierAccountancyCode=Vendor accounting code CustomerAccountancyCodeShort=Cust. account. code SupplierAccountancyCodeShort=Sup. account. code AccountNumber=Account number @@ -171,6 +171,7 @@ LT1ReportByCustomersES=Report by third party RE LT2ReportByCustomersES=Report by third party IRPF VATReport=Sale tax report VATReportByPeriods=Sale tax report by period +VATReportByRates=Sale tax report by rates VATReportByThirdParties=Sale tax report by third parties VATReportByCustomers=Sale tax report by customer VATReportByCustomersInInputOutputMode=Report by the customer VAT collected and paid @@ -224,7 +225,7 @@ ACCOUNTING_VAT_BUY_ACCOUNT=Accounting account by default for VAT on purchases (u ACCOUNTING_VAT_PAY_ACCOUNT=Accounting account by default for paying VAT ACCOUNTING_ACCOUNT_CUSTOMER=Accounting account used for customer third parties ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated customer accouting account on third party is not defined. -ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for supplier third parties +ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for vendor third parties ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accouting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated supplier accouting account on third party is not defined. CloneTax=Clone a social/fiscal tax ConfirmCloneTax=Confirm the clone of a social/fiscal tax payment diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index 588044f18df..2352e704bde 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -39,8 +39,8 @@ ShowECMSection=Show directory DeleteSection=Remove directory ConfirmDeleteSection=Can you confirm you want to delete the directory %s? ECMDirectoryForFiles=Relative directory for files -CannotRemoveDirectoryContainsFilesOrDirs=Removed not possible because it contains some files or sub-directories -CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files +CannotRemoveDirectoryContainsFilesOrDirs=Removal not possible because it contains some files or sub-directories +CannotRemoveDirectoryContainsFiles=Removal not possible because it contains some files ECMFileManager=File manager ECMSelectASection=Select a directory in the tree... DirNotSynchronizedSyncFirst=This directory seems to be created or modified outside ECM module. You must click on "Resync" button first to synchronize disk and database to get content of this directory. diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index efee041cbf4..4141df0c967 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -32,9 +32,9 @@ ErrorBarCodeRequired=Bar code required ErrorCustomerCodeAlreadyUsed=Customer code already used ErrorBarCodeAlreadyUsed=Bar code already used ErrorPrefixRequired=Prefix required -ErrorBadSupplierCodeSyntax=Bad syntax for supplier code -ErrorSupplierCodeRequired=Supplier code required -ErrorSupplierCodeAlreadyUsed=Supplier code already used +ErrorBadSupplierCodeSyntax=Bad syntax for endor code +ErrorSupplierCodeRequired=Vendor code required +ErrorSupplierCodeAlreadyUsed=Vendor code already used ErrorBadParameters=Bad parameters ErrorBadValueForParameter=Wrong value '%s' for parameter '%s' ErrorBadImageFormat=Image file has not a supported format (Your PHP does not support functions to convert images of this format) @@ -87,7 +87,7 @@ ErrorsOnXLines=Errors on %s source record(s) ErrorFileIsInfectedWithAVirus=The antivirus program was not able to validate the file (file might be infected by a virus) ErrorSpecialCharNotAllowedForField=Special characters are not allowed for field "%s" ErrorNumRefModel=A reference exists into database (%s) and is not compatible with this numbering rule. Remove record or renamed reference to activate this module. -ErrorQtyTooLowForThisSupplier=Quantity too low for this supplier or no price defined on this product for this supplier +ErrorQtyTooLowForThisSupplier=Quantity too low for this vendor or no price defined on this product for this supplier ErrorModuleSetupNotComplete=Setup of module looks to be uncomplete. Go on Home - Setup - Modules to complete. ErrorBadMask=Error on mask ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number @@ -177,7 +177,7 @@ ErrorBadDefinitionOfMenuArrayInModuleDescriptor=Bad Definition Of Menu Array In ErrorSavingChanges=An error has ocurred when saving the changes ErrorWarehouseRequiredIntoShipmentLine=Warehouse is required on the line to ship ErrorFileMustHaveFormat=File must have format %s -ErrorSupplierCountryIsNotDefined=Country for this supplier is not defined. Correct this first. +ErrorSupplierCountryIsNotDefined=Country for this vendor is not defined. Correct this first. ErrorsThirdpartyMerge=Failed to merge the two records. Request canceled. ErrorStockIsNotEnoughToAddProductOnOrder=Stock is not enough for product %s to add it into a new order. ErrorStockIsNotEnoughToAddProductOnInvoice=Stock is not enough for product %s to add it into a new invoice. diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 27a2edd1fda..fe96d7c0f97 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -146,7 +146,7 @@ NothingToDo=Nothing to do # upgrade MigrationFixData=Fix for denormalized data MigrationOrder=Data migration for customer's orders -MigrationSupplierOrder=Data migration for supplier's orders +MigrationSupplierOrder=Data migration for vendor's orders MigrationProposal=Data migration for commercial proposals MigrationInvoice=Data migration for customer's invoices MigrationContract=Data migration for contracts diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1d29afa1fa5..3a93cd836c6 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -231,7 +231,7 @@ Limit=Limit Limits=Limits Logout=Logout NoLogoutProcessWithAuthMode=No applicative disconnect feature with authentication mode %s -Connection=Connection +Connection=Login Setup=Setup Alert=Alert MenuWarnings=Alerts @@ -414,7 +414,7 @@ Favorite=Favorite ShortInfo=Info. Ref=Ref. ExternalRef=Ref. extern -RefSupplier=Ref. supplier +RefSupplier=Ref. vendor RefPayment=Ref. payment CommercialProposalsShort=Commercial proposals Comment=Comment @@ -619,9 +619,9 @@ BuildDoc=Build Doc Entity=Environment Entities=Entities CustomerPreview=Customer preview -SupplierPreview=Supplier preview +SupplierPreview=Vendor preview ShowCustomerPreview=Show customer preview -ShowSupplierPreview=Show supplier preview +ShowSupplierPreview=Show vendor preview RefCustomer=Ref. customer Currency=Currency InfoAdmin=Information for administrators @@ -679,7 +679,7 @@ Color=Color Documents=Linked files Documents2=Documents UploadDisabled=Upload disabled -MenuAccountancy=Accountancy +MenuAccountancy=Accounting MenuECM=Documents MenuAWStats=AWStats MenuMembers=Members @@ -915,11 +915,11 @@ SearchIntoProductsOrServices=Products or services SearchIntoProjects=Projects SearchIntoTasks=Tasks SearchIntoCustomerInvoices=Customer invoices -SearchIntoSupplierInvoices=Supplier invoices +SearchIntoSupplierInvoices=Vendor invoices SearchIntoCustomerOrders=Customer orders -SearchIntoSupplierOrders=Supplier orders +SearchIntoSupplierOrders=Vendor orders SearchIntoCustomerProposals=Customer proposals -SearchIntoSupplierProposals=Supplier proposals +SearchIntoSupplierProposals=Vendor proposals SearchIntoInterventions=Interventions SearchIntoContracts=Contracts SearchIntoCustomerShipments=Customer shipments diff --git a/htdocs/langs/en_US/margins.lang b/htdocs/langs/en_US/margins.lang index 9f590ef3718..b9d52dcfdc6 100644 --- a/htdocs/langs/en_US/margins.lang +++ b/htdocs/langs/en_US/margins.lang @@ -28,10 +28,10 @@ UseDiscountAsService=As a service UseDiscountOnTotal=On subtotal MARGIN_METHODE_FOR_DISCOUNT_DETAILS=Defines if a global discount is treated as a product, a service, or only on subtotal for margin calculation. MARGIN_TYPE=Buying/Cost price suggested by default for margin calculation -MargeType1=Margin on Best supplier price +MargeType1=Margin on Best vendor price MargeType2=Margin on Weighted Average Price (WAP) MargeType3=Margin on Cost Price -MarginTypeDesc=* Margin on best buying price = Selling price - Best supplier price defined on product card
* Margin on Weighted Average Price (WAP) = Selling price - Product Weighted Average Price (WAP) or best supplier price if WAP not yet defined
* Margin on Cost price = Selling price - Cost price defined on product card or WAP if cost price not defined, or best supplier price if WAP not yet defined +MarginTypeDesc=* Margin on best buying price = Selling price - Best vendor price defined on product card
* Margin on Weighted Average Price (WAP) = Selling price - Product Weighted Average Price (WAP) or best supplier price if WAP not yet defined
* Margin on Cost price = Selling price - Cost price defined on product card or WAP if cost price not defined, or best supplier price if WAP not yet defined CostPrice=Cost price UnitCharges=Unit charges Charges=Charges diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 8ab5b85b7e6..9942a081e57 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -1,6 +1,6 @@ # Dolibarr language file - Source file is en_US - orders OrdersArea=Customers orders area -SuppliersOrdersArea=Suppliers orders area +SuppliersOrdersArea=Purchase orders area OrderCard=Order card OrderId=Order Id Order=Order @@ -13,18 +13,18 @@ OrderToProcess=Order to process NewOrder=New order ToOrder=Make order MakeOrder=Make order -SupplierOrder=Supplier order -SuppliersOrders=Suppliers orders -SuppliersOrdersRunning=Current suppliers orders -CustomerOrder=Customer order -CustomersOrders=Customer orders +SupplierOrder=Purchase order +SuppliersOrders=Purchase orders +SuppliersOrdersRunning=Current purchase orders +CustomerOrder=Customer Order +CustomersOrders=Customer Orders CustomersOrdersRunning=Current customer orders CustomersOrdersAndOrdersLines=Customer orders and order lines OrdersDeliveredToBill=Customer orders delivered to bill OrdersToBill=Customer orders delivered OrdersInProcess=Customer orders in process OrdersToProcess=Customer orders to process -SuppliersOrdersToProcess=Supplier orders to process +SuppliersOrdersToProcess=Purchase orders to process StatusOrderCanceledShort=Canceled StatusOrderDraftShort=Draft StatusOrderValidatedShort=Validated @@ -75,15 +75,15 @@ ShowOrder=Show order OrdersOpened=Orders to process NoDraftOrders=No draft orders NoOrder=No order -NoSupplierOrder=No supplier order +NoSupplierOrder=No purchase order LastOrders=Latest %s customer orders LastCustomerOrders=Latest %s customer orders -LastSupplierOrders=Latest %s supplier orders +LastSupplierOrders=Latest %s purchase orders LastModifiedOrders=Latest %s modified orders AllOrders=All orders NbOfOrders=Number of orders OrdersStatistics=Order's statistics -OrdersStatisticsSuppliers=Supplier order's statistics +OrdersStatisticsSuppliers=Purchase order statistics NumberOfOrdersByMonth=Number of orders by month AmountOfOrdersByMonthHT=Amount of orders by month (net of tax) ListOfOrders=List of orders @@ -97,12 +97,12 @@ ConfirmMakeOrder=Are you sure you want to confirm you made this order on %s%s? DispatchSupplierOrder=Receiving supplier order %s FirstApprovalAlreadyDone=First approval already done SecondApprovalAlreadyDone=Second approval already done -SupplierOrderReceivedInDolibarr=Supplier order %s received %s -SupplierOrderSubmitedInDolibarr=Supplier order %s submited -SupplierOrderClassifiedBilled=Supplier order %s set billed +SupplierOrderReceivedInDolibarr=Purchase Order %s received %s +SupplierOrderSubmitedInDolibarr=Purchase Order %s submited +SupplierOrderClassifiedBilled=Vendor order %s set billed OtherOrders=Other orders ##### Types de contacts ##### TypeContact_commande_internal_SALESREPFOLL=Representative following-up customer order @@ -125,11 +125,11 @@ TypeContact_commande_internal_SHIPPING=Representative following-up shipping TypeContact_commande_external_BILLING=Customer invoice contact TypeContact_commande_external_SHIPPING=Customer shipping contact TypeContact_commande_external_CUSTOMER=Customer contact following-up order -TypeContact_order_supplier_internal_SALESREPFOLL=Representative following-up supplier order +TypeContact_order_supplier_internal_SALESREPFOLL=Representative following-up vendor order TypeContact_order_supplier_internal_SHIPPING=Representative following-up shipping -TypeContact_order_supplier_external_BILLING=Supplier invoice contact -TypeContact_order_supplier_external_SHIPPING=Supplier shipping contact -TypeContact_order_supplier_external_CUSTOMER=Supplier contact following-up order +TypeContact_order_supplier_external_BILLING=Vendor invoice contact +TypeContact_order_supplier_external_SHIPPING=Vendor shipping contact +TypeContact_order_supplier_external_CUSTOMER=Vendor contact following-up order Error_COMMANDE_SUPPLIER_ADDON_NotDefined=Constant COMMANDE_SUPPLIER_ADDON not defined Error_COMMANDE_ADDON_NotDefined=Constant COMMANDE_ADDON not defined Error_OrderNotChecked=No orders to invoice selected diff --git a/htdocs/langs/en_US/supplier_proposal.lang b/htdocs/langs/en_US/supplier_proposal.lang index d5b51978920..ef2e7242e31 100644 --- a/htdocs/langs/en_US/supplier_proposal.lang +++ b/htdocs/langs/en_US/supplier_proposal.lang @@ -1,22 +1,22 @@ # Dolibarr language file - Source file is en_US - supplier_proposal -SupplierProposal=Supplier commercial proposals -supplier_proposalDESC=Manage price requests to suppliers +SupplierProposal=Vendor commercial proposals +supplier_proposalDESC=Manage price requests to vendors SupplierProposalNew=New price request CommRequest=Price request CommRequests=Price requests SearchRequest=Find a request DraftRequests=Draft requests -SupplierProposalsDraft=Draft supplier proposals +SupplierProposalsDraft=Draft vendor proposals LastModifiedRequests=Latest %s modified price requests RequestsOpened=Open price requests -SupplierProposalArea=Supplier proposals area -SupplierProposalShort=Supplier proposal -SupplierProposals=Supplier proposals -SupplierProposalsShort=Supplier proposals +SupplierProposalArea=Vendor proposals area +SupplierProposalShort=Vendor proposal +SupplierProposals=Vendor proposals +SupplierProposalsShort=Vendor proposals NewAskPrice=New price request ShowSupplierProposal=Show price request AddSupplierProposal=Create a price request -SupplierProposalRefFourn=Supplier ref +SupplierProposalRefFourn=Vendor ref SupplierProposalDate=Delivery date SupplierProposalRefFournNotice=Before closing to "Accepted", think to grasp suppliers references. ConfirmValidateAsk=Are you sure you want to validate this price request under name %s? @@ -47,9 +47,9 @@ CommercialAsk=Price request DefaultModelSupplierProposalCreate=Default model creation DefaultModelSupplierProposalToBill=Default template when closing a price request (accepted) DefaultModelSupplierProposalClosed=Default template when closing a price request (refused) -ListOfSupplierProposals=List of supplier proposal requests -ListSupplierProposalsAssociatedProject=List of supplier proposals associated with project -SupplierProposalsToClose=Supplier proposals to close -SupplierProposalsToProcess=Supplier proposals to process +ListOfSupplierProposals=List of vendor proposal requests +ListSupplierProposalsAssociatedProject=List of vendor proposals associated with project +SupplierProposalsToClose=Vendor proposals to close +SupplierProposalsToProcess=Vendor proposals to process LastSupplierProposals=Latest %s price requests AllPriceRequests=All requests diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index f9e383e09af..d0cf540d3eb 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -1,11 +1,11 @@ # Dolibarr language file - Source file is en_US - suppliers -Suppliers=Suppliers -SuppliersInvoice=Suppliers invoice -ShowSupplierInvoice=Show Supplier Invoice -NewSupplier=New supplier +Suppliers=Vendors +SuppliersInvoice=Vendor invoice +ShowSupplierInvoice=Show Vendor Invoice +NewSupplier=New vendor History=History -ListOfSuppliers=List of suppliers -ShowSupplier=Show supplier +ListOfSuppliers=List of vendors +ShowSupplier=Show vendor OrderDate=Order date BuyingPriceMin=Best buying price BuyingPriceMinShort=Best buying price @@ -14,34 +14,34 @@ TotalSellingPriceMinShort=Total of subproducts selling prices SomeSubProductHaveNoPrices=Some sub-products have no price defined AddSupplierPrice=Add buying price ChangeSupplierPrice=Change buying price -SupplierPrices=Supplier prices +SupplierPrices=Vendor prices ReferenceSupplierIsAlreadyAssociatedWithAProduct=This reference supplier is already associated with a reference: %s -NoRecordedSuppliers=No suppliers recorded -SupplierPayment=Supplier payment -SuppliersArea=Suppliers area -RefSupplierShort=Ref. supplier +NoRecordedSuppliers=No vendor recorded +SupplierPayment=Vendor payment +SuppliersArea=Vendor area +RefSupplierShort=Ref. vendor Availability=Availability -ExportDataset_fournisseur_1=Supplier invoices list and invoice lines -ExportDataset_fournisseur_2=Supplier invoices and payments -ExportDataset_fournisseur_3=Supplier orders and order lines +ExportDataset_fournisseur_1=Vendor invoices list and invoice lines +ExportDataset_fournisseur_2=Vendor invoices and payments +ExportDataset_fournisseur_3=Purchase orders and order lines ApproveThisOrder=Approve this order ConfirmApproveThisOrder=Are you sure you want to approve order %s? DenyingThisOrder=Deny this order ConfirmDenyingThisOrder=Are you sure you want to deny this order %s? ConfirmCancelThisOrder=Are you sure you want to cancel this order %s? -AddSupplierOrder=Create supplier order -AddSupplierInvoice=Create supplier invoice -ListOfSupplierProductForSupplier=List of products and prices for supplier %s -SentToSuppliers=Sent to suppliers -ListOfSupplierOrders=List of supplier orders -MenuOrdersSupplierToBill=Supplier orders to invoice +AddSupplierOrder=Create Purchase Order +AddSupplierInvoice=Create vendor invoice +ListOfSupplierProductForSupplier=List of products and prices for vendor %s +SentToSuppliers=Sent to vendors +ListOfSupplierOrders=List of purchase orders +MenuOrdersSupplierToBill=Purchase orders to invoice NbDaysToDelivery=Delivery delay in days DescNbDaysToDelivery=The biggest deliver delay of the products from this order -SupplierReputation=Supplier reputation +SupplierReputation=Vendor reputation DoNotOrderThisProductToThisSupplier=Do not order NotTheGoodQualitySupplier=Wrong quality ReputationForThisProduct=Reputation BuyerName=Buyer name AllProductServicePrices=All product / service prices AllProductReferencesOfSupplier=All product / service references of supplier -BuyingPriceNumShort=Supplier prices +BuyingPriceNumShort=Vendor prices diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index eba04cc44d1..c8724c5f5b2 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -14,7 +14,7 @@ descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source custome descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid (and if amount of the invoice is same than total amount of linked orders) descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source customer order to shipped when a shipment is validated (and if quantity shipped by all shipments is the same as in the order to update) # Autoclassify supplier order -descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source supplier proposal(s) to billed when supplier invoice is validated (and if amount of the invoice is same than total amount of linked proposals) -descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source supplier order(s) to billed when supplier invoice is validated (and if amount of the invoice is same than total amount of linked orders) +descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source vendor proposal(s) to billed when supplier invoice is validated (and if amount of the invoice is same than total amount of linked proposals) +descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source vendor order(s) to billed when supplier invoice is validated (and if amount of the invoice is same than total amount of linked orders) AutomaticCreation=Automatic creation AutomaticClassification=Automatic classification \ No newline at end of file From 94d6e178f72e22af3267cf06ecd5dd6c6a6443b9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Apr 2018 16:06:46 +0200 Subject: [PATCH 476/609] Work on vat report code rewrite --- htdocs/compta/localtax/index.php | 307 ++++++++++++++++++++++------ htdocs/compta/tva/index.php | 246 +++++++++++++++++++--- htdocs/compta/tva/quadri_detail.php | 2 +- htdocs/core/lib/tax.lib.php | 53 ++--- htdocs/langs/en_US/admin.lang | 4 +- 5 files changed, 485 insertions(+), 127 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 2364290403b..36e6abf5fb7 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -45,13 +45,12 @@ if (empty($year)) } $date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); -// Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -150,11 +149,12 @@ if($localTaxType==1) { $CalcLT= $conf->global->MAIN_INFO_LOCALTAX_CALC2; } -$description = ''; +$fsearch.=' '; +$description = $fsearch; // Show report header $name = $langs->trans("ReportByMonth"); -$description = $langs->trans($LT); +$description .= $langs->trans($LT); $calcmode = $langs->trans("LTReportBuildWithOptionDefinedInModule").' '; $calcmode.= '('.$langs->trans("TaxModuleSetupToModifyRulesLT",DOL_URL_ROOT.'/admin/company.php').')
'; @@ -174,6 +174,7 @@ llxHeader('', $name); report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); + print '
'; print '
'; @@ -208,16 +209,141 @@ $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; $mcursor=0; while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { - $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) $y++; if ($m > 12) $m -= 12; $mcursor++; - $coll_listsell = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + // Get array with details of each line + $x_coll = tax_by_rate(($localTaxType==1?'localtax1':'localtax2'), $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $x_paye = tax_by_rate(($localTaxType==1?'localtax1':'localtax2'), $db, $y, 0, 0, 0, $modetax, 'buy', $m); + + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach(array_keys($x_coll) as $my_coll_rate) + { + $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; + $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; + $x_both[$my_coll_rate]['coll']['localtax1'] = $x_coll[$my_coll_rate]['localtax1']; + $x_both[$my_coll_rate]['coll']['localtax2'] = $x_coll[$my_coll_rate]['localtax2']; + $x_both[$my_coll_rate]['paye']['totalht'] = 0; + $x_both[$my_coll_rate]['paye']['vat'] = 0; + $x_both[$my_coll_rate]['paye']['localtax1'] = 0; + $x_both[$my_coll_rate]['paye']['localtax2'] = 0; + $x_both[$my_coll_rate]['coll']['links'] = ''; + $x_both[$my_coll_rate]['coll']['detail'] = array(); + foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; + //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; + //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; + //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); + $x_both[$my_coll_rate]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_rate]['facid'][$id], + 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], + 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], + 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], + 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], + 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], + + 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], + 'localtax1' =>$x_coll[$my_coll_rate]['localtax1_list'][$id], + 'localtax2' =>$x_coll[$my_coll_rate]['localtax2_list'][$id], + //'link' =>$invoice_customer->getNomUrl(1,'',12) + ); + } + } + + // tva paid + foreach (array_keys($x_paye) as $my_paye_rate) { + $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; + $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; + $x_both[$my_paye_rate]['paye']['localtax1'] = $x_paye[$my_paye_rate]['localtax1']; + $x_both[$my_paye_rate]['paye']['localtax2'] = $x_paye[$my_paye_rate]['localtax2']; + if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) { + $x_both[$my_paye_rate]['coll']['totalht'] = 0; + $x_both[$my_paye_rate]['coll']['vat'] = 0; + $x_both[$my_paye_rate]['coll']['localtax1'] = 0; + $x_both[$my_paye_rate]['coll']['localtax2'] = 0; + } + $x_both[$my_paye_rate]['paye']['links'] = ''; + $x_both[$my_paye_rate]['paye']['detail'] = array(); + + foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') + { + //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; + + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + //'link' =>$expensereport->getNomUrl(1) + ); + } + else + { + //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; + //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], + 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + 'localtax1' =>$x_paye[$my_paye_rate]['localtax1_list'][$id], + 'localtax2' =>$x_paye[$my_paye_rate]['localtax2_list'][$id], + //'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye $action = "tva"; - $object = array(&$coll_listsell, &$coll_listbuy); + $object = array(&$x_coll, &$x_paye, &$x_both); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; @@ -227,13 +353,13 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (! is_array($coll_listbuy) && $coll_listbuy == -1) + if (! is_array($x_coll) && $coll_listbuy == -1) { $langs->load("errors"); print '
'; break; } - if (! is_array($coll_listbuy) && $coll_listbuy == -2) + if (! is_array($x_paye) && $coll_listbuy == -2) { print ''; break; @@ -241,76 +367,121 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu print ''; - print ''; + print ''; - if ($CalcLT==0) { - $x_coll = 0; - foreach($coll_listsell as $vatrate=>$val) { - $x_coll+=$val[$localTaxType==1?'localtax1':'localtax2']; - } - $subtotalcoll = $subtotalcoll + $x_coll; - print ""; + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) + { + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - $x_paye = 0; - foreach($coll_listbuy as $vatrate=>$val) { - $x_paye+=$val[$localTaxType==1?'localtax1':'localtax2']; - } - $subtotalpaye = $subtotalpaye + $x_paye; - print ""; - } elseif($CalcLT==1) { - $x_paye = 0; - foreach($coll_listbuy as $vatrate=>$val) { - $x_paye+=$val[$localTaxType==1?'localtax1':'localtax2']; + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['localtax'.$localTaxType]*$ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; } - $subtotalpaye = $subtotalpaye + $x_paye; - print ""; - } elseif($CalcLT==2) { - $x_coll = 0; - foreach($coll_listsell as $vatrate=>$val) { - $x_coll+=$val[$localTaxType==1?'localtax1':'localtax2']; + } + print ""; + + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) + { + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; + + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['localtax'.$localTaxType]*$ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; } - $subtotalcoll = $subtotalcoll + $x_coll; - print ""; - } + print ""; - if($CalcLT==0) { - $diff= $x_coll - $x_paye; - } elseif($CalcLT==1) { - $diff= $x_paye; - } elseif($CalcLT==2) { - $diff= $x_coll; - } + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; + $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; - $subtotal = $subtotal + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print "\n"; + print "\n"; print "\n"; print "\n"; - $i++; + $i++; $m++; if ($i > 2) { - print ''; - print ''; - if($CalcLT==0) { - print ''; - print ''; - print ''; - } elseif($CalcLT==1) { - print ''; - print ''; - } elseif($CalcLT==2) { - print ''; - print ''; - } - print ''; - $i = 0; - $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i = 0; + $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; } } -print ''; +print ''; print "\n"; print ''; @@ -319,12 +490,14 @@ print '
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$langs->trans("Rate").': '.vatrate($rate).'%
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").'".price($x_coll)."".price($x_paye)."".price($x_paye)."".price(price2num($x_coll_sum,'MT'))."".price($x_coll)."".price(price2num($x_paye_sum,'MT'))."".price($diff)."".price(price2num($diff,'MT'))." 
'.$langs->trans("SubTotal").':'.price($subtotalcoll).''.price($subtotalpaye).''.price($subtotal).''.price($subtotalpaye).''.price($subtotal).''.price($subtotalcoll).''.price($subtotal).' 
'.$langs->trans("SubTotal").':'.price(price2num($subtotalcoll,'MT')).''.price(price2num($subtotalpaye,'MT')).''.price(price2num($subtotal,'MT')).' 
'.$langs->trans("TotalToPay").':'.price($total).'
'.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).' 
'; print '
'; -print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); + /* * Payed */ +print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); + $sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; $sql.= " WHERE f.entity = ".$conf->entity; @@ -336,10 +509,10 @@ $sql.= " ORDER BY dm ASC"; pt($db, $sql,$langs->trans("Year")." $y"); + print '
'; print '
'; - llxFooter(); $db->close(); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index d22d252f39c..c1a61fea540 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -45,13 +45,12 @@ if (empty($year)) } $date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); -// Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q"); + $q=GETPOST("q","int"); if (empty($q)) { - if (GETPOST("month")) { $date_start=dol_get_first_day($year_start,GETPOST("month"),false); $date_end=dol_get_last_day($year_start,GETPOST("month"),false); } + if (GETPOST("month","int")) { $date_start=dol_get_first_day($year_start,GETPOST("month","int"),false); $date_end=dol_get_last_day($year_start,GETPOST("month","int"),false); } else { $date_start=dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START,false); @@ -190,21 +189,128 @@ $m = $tmp['mon']; $tmp=dol_getdate($date_end); $yend = $tmp['year']; $mend = $tmp['mon']; - +//var_dump($m); $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; $mcursor=0; while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { - $m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); + //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) $y++; if ($m > 12) $m -= 12; $mcursor++; - $coll_listsell = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); - $coll_listbuy = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + $x_coll = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'sell', $m); + $x_paye = tax_by_rate('vat', $db, $y, 0, 0, 0, $modetax, 'buy', $m); + + $x_both = array(); + //now, from these two arrays, get another array with one rate per line + foreach(array_keys($x_coll) as $my_coll_rate) + { + $x_both[$my_coll_rate]['coll']['totalht'] = $x_coll[$my_coll_rate]['totalht']; + $x_both[$my_coll_rate]['coll']['vat'] = $x_coll[$my_coll_rate]['vat']; + $x_both[$my_coll_rate]['paye']['totalht'] = 0; + $x_both[$my_coll_rate]['paye']['vat'] = 0; + $x_both[$my_coll_rate]['coll']['links'] = ''; + $x_both[$my_coll_rate]['coll']['detail'] = array(); + foreach($x_coll[$my_coll_rate]['facid'] as $id=>$dummy) { + //$invoice_customer->id=$x_coll[$my_coll_rate]['facid'][$id]; + //$invoice_customer->ref=$x_coll[$my_coll_rate]['facnum'][$id]; + //$invoice_customer->type=$x_coll[$my_coll_rate]['type'][$id]; + //$company_static->fetch($x_coll[$my_coll_rate]['company_id'][$id]); + $x_both[$my_coll_rate]['coll']['detail'][] = array( + 'id' =>$x_coll[$my_coll_rate]['facid'][$id], + 'descr' =>$x_coll[$my_coll_rate]['descr'][$id], + 'pid' =>$x_coll[$my_coll_rate]['pid'][$id], + 'pref' =>$x_coll[$my_coll_rate]['pref'][$id], + 'ptype' =>$x_coll[$my_coll_rate]['ptype'][$id], + 'payment_id'=>$x_coll[$my_coll_rate]['payment_id'][$id], + 'payment_amount'=>$x_coll[$my_coll_rate]['payment_amount'][$id], + 'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id], + 'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id], + 'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id], + 'datef' =>$x_coll[$my_coll_rate]['datef'][$id], + 'datep' =>$x_coll[$my_coll_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id], + 'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id], + 'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id], + 'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id], + //'link' =>$invoice_customer->getNomUrl(1,'',12) + ); + } + } + + // tva paid + foreach (array_keys($x_paye) as $my_paye_rate) { + $x_both[$my_paye_rate]['paye']['totalht'] = $x_paye[$my_paye_rate]['totalht']; + $x_both[$my_paye_rate]['paye']['vat'] = $x_paye[$my_paye_rate]['vat']; + if (!isset($x_both[$my_paye_rate]['coll']['totalht'])) { + $x_both[$my_paye_rate]['coll']['totalht'] = 0; + $x_both[$my_paye_rate]['coll']['vat'] = 0; + } + $x_both[$my_paye_rate]['paye']['links'] = ''; + $x_both[$my_paye_rate]['paye']['detail'] = array(); + + foreach ($x_paye[$my_paye_rate]['facid'] as $id=>$dummy) + { + // ExpenseReport + if ($x_paye[$my_paye_rate]['ptype'][$id] == 'ExpenseReportPayment') + { + //$expensereport->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$expensereport->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$expensereport->type=$x_paye[$my_paye_rate]['type'][$id]; + + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id' =>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount' =>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc' =>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc' =>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'ddate_start' =>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + //'link' =>$expensereport->getNomUrl(1) + ); + } + else + { + //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; + //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; + //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; + //$company_static->fetch($x_paye[$my_paye_rate]['company_id'][$id]); + $x_both[$my_paye_rate]['paye']['detail'][] = array( + 'id' =>$x_paye[$my_paye_rate]['facid'][$id], + 'descr' =>$x_paye[$my_paye_rate]['descr'][$id], + 'pid' =>$x_paye[$my_paye_rate]['pid'][$id], + 'pref' =>$x_paye[$my_paye_rate]['pref'][$id], + 'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id], + 'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id], + 'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id], + 'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]), + 'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]), + 'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id], + 'datef' =>$x_paye[$my_paye_rate]['datef'][$id], + 'datep' =>$x_paye[$my_paye_rate]['datep'][$id], + //'company_link'=>$company_static->getNomUrl(1,'',20), + 'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id], + 'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id], + 'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]), + 'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id], + //'link' =>$invoice_supplier->getNomUrl(1,'',12) + ); + } + } + } + //now we have an array (x_both) indexed by rates for coll and paye $action = "tva"; - $object = array(&$coll_listsell, &$coll_listbuy); + $object = array(&$x_coll, &$x_paye, &$x_both); $parameters["mode"] = $modetax; $parameters["year"] = $y; $parameters["month"] = $m; @@ -214,13 +320,13 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu $hookmanager->initHooks(array('externalbalance')); $reshook=$hookmanager->executeHooks('addVatLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (! is_array($coll_listbuy) && $coll_listbuy == -1) + if (! is_array($x_coll) && $coll_listbuy == -1) { $langs->load("errors"); print ''.$langs->trans("ErrorNoAccountancyModuleLoaded").''; break; } - if (! is_array($coll_listbuy) && $coll_listbuy == -2) + if (! is_array($x_paye) && $coll_listbuy == -2) { print ''.$langs->trans("FeatureNotYetAvailable").''; break; @@ -228,46 +334,121 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu print ''; - print ''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''; + print ''.dol_print_date(dol_mktime(0,0,0,$m,1,$y),"%b %Y").''; - $x_coll = 0; - foreach($coll_listsell as $vatrate=>$val) + $x_coll_sum = 0; + foreach (array_keys($x_coll) as $rate) { - $x_coll+=$val['vat']; - } - $subtotalcoll = $subtotalcoll + $x_coll; - print "".price($x_coll).""; + $subtot_coll_total_ht = 0; + $subtot_coll_vat = 0; - $x_paye = 0; - foreach($coll_listbuy as $vatrate=>$val) + foreach ($x_both[$rate]['coll']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + $subtot_coll_total_ht += $temp_ht; + $subtot_coll_vat += $temp_vat; + $x_coll_sum += $temp_vat; + } + } + print "".price(price2num($x_coll_sum,'MT')).""; + + $x_paye_sum = 0; + foreach (array_keys($x_paye) as $rate) { - $x_paye+=$val['vat']; - } - $subtotalpaye = $subtotalpaye + $x_paye; - print "".price($x_paye).""; + $subtot_paye_total_ht = 0; + $subtot_paye_vat = 0; - $diff = $x_coll - $x_paye; + foreach ($x_both[$rate]['paye']['detail'] as $index => $fields) + { + // Payment + $ratiopaymentinvoice=1; + if ($modetax != 1) + { + // Define type + // We MUST use dtype (type in line). We can use something else, only if dtype is really unknown. + $type=(isset($fields['dtype'])?$fields['dtype']:$fields['ptype']); + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (!empty($fields['ddate_start'])) { + $type=1; + } + if (!empty($fields['ddate_end'])) { + $type=1; + } + + if (($type == 0 && $conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') + || ($type == 1 && $conf->global->TAX_MODE_SELL_SERVICE == 'invoice')) + { + //print $langs->trans("NA"); + } else { + if (isset($fields['payment_amount']) && price2num($fields['ftotal_ttc'])) { + $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); + } + } + } + //var_dump('type='.$type.' '.$fields['totalht'].' '.$ratiopaymentinvoice); + $temp_ht=$fields['totalht']*$ratiopaymentinvoice; + $temp_vat=$fields['vat']*$ratiopaymentinvoice; + $subtot_paye_total_ht += $temp_ht; + $subtot_paye_vat += $temp_vat; + $x_paye_sum += $temp_vat; + } + } + print "".price(price2num($x_paye_sum,'MT')).""; + + $subtotalcoll = $subtotalcoll + $x_coll_sum; + $subtotalpaye = $subtotalpaye + $x_paye_sum; + + $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; - $subtotal = $subtotal + $diff; + $subtotal = price2num($subtotal + $diff, 'MT'); - print "".price($diff)."\n"; + print "".price(price2num($diff,'MT'))."\n"; print " \n"; print "\n"; - $i++; + $i++; $m++; if ($i > 2) { print ''; print ''.$langs->trans("SubTotal").':'; - print ''.price($subtotalcoll).''; - print ''.price($subtotalpaye).''; - print ''.price($subtotal).''; + print ''.price(price2num($subtotalcoll,'MT')).''; + print ''.price(price2num($subtotalpaye,'MT')).''; + print ''.price(price2num($subtotal,'MT')).''; print ' '; $i = 0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; } } -print ''.$langs->trans("TotalToPay").':'.price($total).''; +print ''.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).''; print " \n"; print ''; @@ -277,12 +458,13 @@ print ''; print '
'; -print load_fiche_titre($langs->trans("VATPaid"), '', ''); /* * Payed */ +print load_fiche_titre($langs->trans("VATPaid"), '', ''); + $sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 28b2878998f..0866bafad0c 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -127,7 +127,7 @@ $fsearch.=' '; // Show report header -$name=$langs->trans("VATReportByPeriods"); +$name=$langs->trans("VATReportByRates"); $calcmode=''; if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 216b2c7ea33..e432b741929 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -699,18 +699,19 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $oldrowid=''; while($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + // Code to avoid warnings when array entry not defined + if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; + if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; + if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; + if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { $oldrowid=$assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; + $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; } $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; @@ -730,7 +731,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; $list[$assoc['rate']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2']; + $list[$assoc['rate']]['localtax2_list'][] = $assoc['total_localtax2']; $list[$assoc['rate']]['pid'][] = $assoc['pid']; $list[$assoc['rate']]['pref'][] = $assoc['pref']; @@ -849,18 +850,19 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $oldrowid=''; while($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + // Code to avoid warnings when array entry not defined + if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; + if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; + if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; + if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { $oldrowid=$assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; + $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; } $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; @@ -951,18 +953,19 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $oldrowid=''; while($assoc = $db->fetch_array($resql)) { - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; - if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; - if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; + // Code to avoid warnings when array entry not defined + if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['totalht']=0; + if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['vat']=0; + if (! isset($list[$assoc['rate']]['localtax1'])) $list[$assoc['rate']]['localtax1']=0; + if (! isset($list[$assoc['rate']]['localtax2'])) $list[$assoc['rate']]['localtax2']=0; if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid { $oldrowid=$assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; + $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + $list[$assoc['rate']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['rate']]['localtax2'] += $assoc['total_localtax2']; } $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0b192e96429..9b4079281b9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -548,8 +548,8 @@ Module400Name=Projects/Opportunities/Leads Module400Desc=Management of projects, opportunities/leads and/or tasks. You can also assign any element (invoice, order, proposal, intervention, ...) to a project and get a transversal view from the project view. Module410Name=Webcalendar Module410Desc=Webcalendar integration -Module500Name=Special expenses -Module500Desc=Management of special expenses (taxes, social or fiscal taxes, dividends) +Module500Name=Taxes and Special expenses +Module500Desc=Management of special expenses (sale taxes, social or fiscal taxes, dividends, ...) Module510Name=Payment of employee wages Module510Desc=Record and follow payment of your employee wages Module520Name=Loan From e8fd5ea5cdc7dcc6f1b12fbfe6dc44a4f46d20a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Apr 2018 17:18:38 +0200 Subject: [PATCH 477/609] Better translation --- htdocs/compta/localtax/index.php | 8 ++++---- htdocs/compta/sociales/card.php | 24 ++++++++++++------------ htdocs/compta/tva/card.php | 8 ++++---- htdocs/compta/tva/index.php | 11 ++++++----- htdocs/compta/tva/list.php | 8 ++++---- htdocs/langs/en_US/compta.lang | 1 + 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 36e6abf5fb7..04fa4438a96 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -96,10 +96,10 @@ function pt ($db, $sql, $date) $i = 0; $total = 0; print ''; + print ''; print ''; print ''; - print ''."\n"; print "\n"; while ($i < $num) { @@ -109,12 +109,12 @@ function pt ($db, $sql, $date) print '\n"; $total = $total + $obj->mm; - print '\n"; + print '\n"; print "\n"; $i++; } - print '"; + print '"; print "
'.$date.''.$langs->trans("Amount").' 
'.$obj->dm."'.price($obj->mm)." '.price($obj->mm)."
'.$langs->trans("Total")." :".price($total)." 
'.$langs->trans("Total")." :".price($total)."
"; $db->free($result); @@ -507,7 +507,7 @@ $sql.= " AND localtaxtype=".$localTaxType; $sql.= " GROUP BY dm"; $sql.= " ORDER BY dm ASC"; -pt($db, $sql,$langs->trans("Year")." $y"); +pt($db, $sql,$langs->trans("Month")); print '
'; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index cdcabc5617b..d7bdd9c77e6 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -327,13 +327,23 @@ if ($action == 'create') // Date end period print ''; print ''; - print $langs->trans("PeriodEndDate"); + print $form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")); print ''; print ''; print $form->select_date(! empty($dateperiod)?$dateperiod:'-1', 'period', 0, 0, 0, 'charge', 1); print ''; print ''; + // Date due + print ''; + print ''; + print $langs->trans("DateDue"); + print ''; + print ''; + print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); + print ''; + print "\n"; + // Amount print ''; print ''; @@ -370,16 +380,6 @@ if ($action == 'create') print ''; } - // Date due - print ''; - print ''; - print $langs->trans("DateDue"); - print ''; - print ''; - print $form->select_date(! empty($dateech)?$dateech:'-1', 'ech', 0, 0, 0, 'charge', 1); - print ''; - print "\n"; - print ''; dol_fiche_end(); @@ -496,7 +496,7 @@ if ($id > 0) print ""; // Period end date - print "".$langs->trans("PeriodEndDate").""; + print "".$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).""; print ""; if ($action == 'edit') { diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 2411858a924..76d2609a78d 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -248,7 +248,7 @@ if ($action == 'create') print $form->select_date($datep,"datep",'','','','add',1,1); print ''; - print ''.$langs->trans("DateValue").''; + print ''.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->select_date($datev,"datev",'','','','add',1,1); print ''; @@ -261,7 +261,7 @@ if ($action == 'create') print ''.$langs->trans("Label").''; // Amount - print ''.$langs->trans("Amount").''; + print ''.$langs->trans("Amount").''; if (! empty($conf->banque->enabled)) { @@ -325,9 +325,9 @@ if ($id) print ''; - print $form->editfieldkey("DateValue", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); + print $form->editfieldkey($form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")), 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); print ''; - print $form->editfieldval("DateValue", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); + print $form->editfieldval("PeriodEndDate", 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); //print dol_print_date($object->datev,'day'); print ''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index c1a61fea540..cafb965e354 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -96,10 +96,10 @@ function pt ($db, $sql, $date) $i = 0; $total = 0; print ''; + print ''; print ''; print ''; - print ''."\n"; print "\n"; while ($i < $num) { @@ -109,12 +109,12 @@ function pt ($db, $sql, $date) print '\n"; $total = $total + $obj->mm; - print '\n"; + print '"; + print '"; print "
'.$date.''.$langs->trans("Amount").' 
'.$obj->dm."'.price($obj->mm)." '.price($obj->mm)."\n"; $i++; } - print '
'.$langs->trans("Total")." :".price($total)." 
'.$langs->trans("Total")." :".price($total)."
"; $db->free($result); @@ -470,9 +470,10 @@ $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.datep >= '".$db->idate($date_start)."'"; $sql.= " AND f.datep <= '".$db->idate($date_end)."'"; -$sql.= " GROUP BY dm ORDER BY dm ASC"; +$sql.= " GROUP BY dm"; +$sql.= " ORDER BY dm ASC"; -pt($db, $sql,$langs->trans("Year")." $y"); +pt($db, $sql, $langs->trans("Month")); print '
'; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 99efc63f2d5..9a881daccc9 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -170,11 +170,11 @@ if ($result) print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; @@ -199,7 +199,7 @@ if ($result) print ''; print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"t.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"t.label","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre("DateValue",$_SERVER["PHP_SELF"],"t.datev","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("PeriodEndDate",$_SERVER["PHP_SELF"],"t.datev","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"t.datep","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("Account",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 1e457cedcd2..fcae17f10b2 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -244,3 +244,4 @@ FiscalPeriod=Accounting period ListSocialContributionAssociatedProject=List of social contributions associated with the project DeleteFromCat=Remove from accounting group AccountingAffectation=Accounting assignement +LastDayTaxIsRelatedTo=Last day of period the tax is related to \ No newline at end of file From 2241418b33b9f06801e45231d1fa3889a2a81c92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Apr 2018 18:43:29 +0200 Subject: [PATCH 478/609] Fix look and feel v7 --- htdocs/compta/localtax/card.php | 116 ++++++++++-------- .../compta/localtax/class/localtax.class.php | 31 ++++- htdocs/compta/tva/card.php | 7 +- htdocs/compta/tva/class/tva.class.php | 8 +- 4 files changed, 100 insertions(+), 62 deletions(-) diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index ad409145478..438427fa491 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; $langs->load("compta"); $langs->load("banks"); @@ -38,11 +39,11 @@ if (empty($refund)) $refund=0; $lttype=GETPOST('localTaxType', 'int'); // Security check -$socid = isset($_GET["socid"])?$_GET["socid"]:''; +$socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); -$localtax = new Localtax($db); +$object = new Localtax($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('localtaxvatcard','globalcard')); @@ -52,8 +53,8 @@ $hookmanager->initHooks(array('localtaxvatcard','globalcard')); * Actions */ -//add payment of localtax -if($_POST["cancel"] == $langs->trans("Cancel")){ +if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id) +{ header("Location: list.php?localTaxType=".$lttype); exit; } @@ -66,15 +67,15 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) $datev=dol_mktime(12,0,0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]); $datep=dol_mktime(12,0,0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]); - $localtax->accountid=GETPOST("accountid"); - $localtax->paymenttype=GETPOST("paiementtype"); - $localtax->datev=$datev; - $localtax->datep=$datep; - $localtax->amount=price2num(GETPOST("amount")); - $localtax->label=GETPOST("label"); - $localtax->ltt=$lttype; + $object->accountid=GETPOST("accountid"); + $object->paymenttype=GETPOST("paiementtype"); + $object->datev=$datev; + $object->datep=$datep; + $object->amount=price2num(GETPOST("amount")); + $object->label=GETPOST("label"); + $object->ltt=$lttype; - $ret=$localtax->addPayment($user); + $ret=$object->addPayment($user); if ($ret > 0) { $db->commit(); @@ -84,7 +85,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) else { $db->rollback(); - setEventMessages($localtax->error, $localtax->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $_GET["action"]="create"; } } @@ -92,39 +93,39 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) //delete payment of localtax if ($action == 'delete') { - $result=$localtax->fetch($id); + $result=$object->fetch($id); - if ($localtax->rappro == 0) + if ($object->rappro == 0) { $db->begin(); - $ret=$localtax->delete($user); + $ret=$object->delete($user); if ($ret > 0) { - if ($localtax->fk_bank) + if ($object->fk_bank) { $accountline=new AccountLine($db); - $result=$accountline->fetch($localtax->fk_bank); + $result=$accountline->fetch($object->fk_bank); if ($result > 0) $result=$accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing) } if ($result >= 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$localtax->ltt); + header("Location: ".DOL_URL_ROOT.'/compta/localtax/list.php?localTaxType='.$object->ltt); exit; } else { - $localtax->error=$accountline->error; + $object->error=$accountline->error; $db->rollback(); - setEventMessages($localtax->error, $localtax->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { $db->rollback(); - setEventMessages($localtax->error, $localtax->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else @@ -136,17 +137,12 @@ if ($action == 'delete') /* -* View -*/ - -llxHeader(); - -$form = new Form($db); + * View + */ if ($id) { - $vatpayment = new Localtax($db); - $result = $vatpayment->fetch($id); + $result = $object->fetch($id); if ($result <= 0) { dol_print_error($db); @@ -154,6 +150,13 @@ if ($id) } } +$form = new Form($db); + +$title=$langs->trans("LT".$object->ltt) . " - " . $langs->trans("Card"); +$help_url=''; +llxHeader("",$title,$helpurl); + + if ($action == 'create') { @@ -173,7 +176,7 @@ if ($action == 'create') print $form->select_date($datep,"datep",'','','','add',1,1); print ''; - print ''; @@ -218,47 +221,48 @@ if ($action == 'create') } -/* ************************************************************************** */ -/* */ -/* Barre d'action */ -/* */ -/* ************************************************************************** */ - +// View mode if ($id) { $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$vatpayment->id; + $head[$h][0] = DOL_URL_ROOT.'/compta/localtax/card.php?id='.$object->id; $head[$h][1] = $langs->trans('Card'); $head[$h][2] = 'card'; $h++; - dol_fiche_head($head, 'card', $langs->trans("VATPayment"), 0, 'payment'); + dol_fiche_head($head, 'card', $langs->transcountry("LT".$object->ltt, $mysoc->country_code), -1, 'payment'); + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); + + print '
'; + print '
'; print '
'; - print ''; + print ''; $syear = $year; $formother->select_year($syear?$syear:-1,'year',1, 20, 5); print '
'.$langs->trans("DateValue").''; + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->select_date($datev,"datev",'','','','add',1,1); print '
'; print ""; - print ''; print ""; print ''; - print ''; - print ''; + print ''; if (! empty($conf->banque->enabled)) { - if ($vatpayment->fk_account > 0) + if ($object->fk_account > 0) { $bankline=new AccountLine($db); - $bankline->fetch($vatpayment->fk_bank); + $bankline->fetch($object->fk_bank); print ''; print ''; @@ -271,22 +275,28 @@ if ($id) // Other attributes $parameters=array(); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$vatpayment,$action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'.$langs->trans("Ref").''; - print $vatpayment->ref; + print ''.$langs->trans("Ref").''; + print $object->ref; print '
'.$langs->trans("DatePayment").''; - print dol_print_date($vatpayment->datep,'day'); + print dol_print_date($object->datep,'day'); print '
'.$langs->trans("DateValue").''; - print dol_print_date($vatpayment->datev,'day'); + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print dol_print_date($object->datev,'day'); print '
'.$langs->trans("Amount").''.price($vatpayment->amount).'
'.$langs->trans("Amount").''.price($object->amount).'
'.$langs->trans('BankTransactionLine').'
'; - dol_fiche_end(); + print '
'; + + dol_fiche_end(); /* - * Boutons d'actions - */ + * Action buttons + */ print "
\n"; - if ($vatpayment->rappro == 0) - print ''.$langs->trans("Delete").''; + if ($object->rappro == 0) + { + print ''.$langs->trans("Delete").''; + } else + { print ''.$langs->trans("Delete").''; + } print "
"; } diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 79a88d11c4d..a75de537724 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -29,7 +29,11 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class Localtax extends CommonObject { - var $ltt; + public $element='localtax'; //!< Id that identify managed objects + public $table_element='localtax'; //!< Name of table without prefix where object is stored + public $picto='payment'; + + var $ltt; var $tms; var $datep; var $datev; @@ -607,4 +611,29 @@ class Localtax extends CommonObject return $result; } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } + + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + function LibStatut($status,$mode=0) + { + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + + return ''; + } + } diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 76d2609a78d..abd7baa12f9 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -172,7 +172,8 @@ if ($action == 'delete') } else { - setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors'); + $mesg='Error try do delete a line linked to a conciliated bank transaction'; + setEventMessages($mesg, null, 'errors'); } } @@ -180,11 +181,13 @@ if ($action == 'delete') /* * View */ + +$form = new Form($db); + $title=$langs->trans("VAT") . " - " . $langs->trans("Card"); $help_url=''; llxHeader("",$title,$helpurl); -$form = new Form($db); if ($id) { diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 80242103c51..af330910cdf 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -33,8 +33,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class Tva extends CommonObject { - //public $element='tva'; //!< Id that identify managed objects - //public $table_element='tva'; //!< Name of table without prefix where object is stored + public $element='tva'; //!< Id that identify managed objects + public $table_element='tva'; //!< Name of table without prefix where object is stored public $picto='payment'; var $tms; @@ -48,8 +48,6 @@ class Tva extends CommonObject var $fk_user_creat; var $fk_user_modif; - - /** * Constructor * @@ -58,8 +56,6 @@ class Tva extends CommonObject function __construct($db) { $this->db = $db; - $this->element = 'tva'; - $this->table_element = 'tva'; } From e72c2e6a11961719e0f47e60a02d2b3ac1d223ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Apr 2018 19:54:41 +0200 Subject: [PATCH 479/609] Enhance sorting of field for lists on field with several sort criterias --- htdocs/compta/bank/class/account.class.php | 5 ++-- .../salaries/class/paymentsalary.class.php | 6 +++- htdocs/compta/salaries/index.php | 11 +++---- htdocs/compta/salaries/stats/index.php | 9 +++--- htdocs/core/db/DoliDB.class.php | 4 +-- htdocs/core/js/lib_foot.js.php | 19 +++++++----- htdocs/core/lib/functions.lib.php | 29 ++++++++++++++----- 7 files changed, 52 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index c773ef242ad..d1fec4a5a6d 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -395,9 +395,10 @@ class Account extends CommonObject * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. + * @param int $datevalue Date value * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='') + function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='', $datev=null) { // Deprecatîon warning if (is_numeric($oper)) { @@ -447,7 +448,7 @@ class Account extends CommonObject $this->db->begin(); - $datev = $date; + if (is_null($datev) || empty($datev)) $datev = $date; $accline = new AccountLine($this->db); $accline->datec = $now; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index 71cfe997fe0..3a3f34b85b4 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -388,7 +388,11 @@ class PaymentSalary extends CommonObject -abs($this->amount), $this->num_payment, '', - $user + $user, + '', + '', + '', + $this->datev ); // Update fk_bank into llx_paiement. diff --git a/htdocs/compta/salaries/index.php b/htdocs/compta/salaries/index.php index b5cdbb11a82..a88ec8683a9 100644 --- a/htdocs/compta/salaries/index.php +++ b/htdocs/compta/salaries/index.php @@ -28,10 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; -$langs->load("compta"); -$langs->load("salaries"); -$langs->load("bills"); -$langs->load("hrm"); +$langs->loadLangs(array("compta","salaries","bills","hrm")); // Security check $socid = GETPOST("socid","int"); @@ -52,8 +49,8 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="s.datep"; -if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) $sortfield="s.datep,s.rowid"; +if (! $sortorder) $sortorder="DESC,DESC"; $optioncss = GETPOST('optioncss','alpha'); $filtre=$_GET["filtre"]; @@ -208,7 +205,7 @@ if ($result) print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"s.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Employee",$_SERVER["PHP_SELF"],"u.rowid","",$param,"",$sortfield,$sortorder); print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"s.label","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep","",$param,'align="center"',$sortfield,$sortorder); + print_liste_field_titre("DatePayment",$_SERVER["PHP_SELF"],"s.datep,s.rowid","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre("PaymentMode",$_SERVER["PHP_SELF"],"type","",$param,'align="left"',$sortfield,$sortorder); if (! empty($conf->banque->enabled)) print_liste_field_titre("BankAccount",$_SERVER["PHP_SELF"],"ba.label","",$param,"",$sortfield,$sortorder); print_liste_field_titre("PayedByThisPayment",$_SERVER["PHP_SELF"],"s.amount","",$param,'align="right"',$sortfield,$sortorder); diff --git a/htdocs/compta/salaries/stats/index.php b/htdocs/compta/salaries/stats/index.php index 0ba0c29ea6f..dbaeab2b252 100644 --- a/htdocs/compta/salaries/stats/index.php +++ b/htdocs/compta/salaries/stats/index.php @@ -59,6 +59,7 @@ $year = GETPOST('year')>0?GETPOST('year'):$nowyear; $startyear=$year-1; $endyear=$year; + /* * View */ @@ -231,11 +232,11 @@ print ''; print '

'; print ''; -print ''; +print ''; print ''; -print ''; -print ''; -print ''; +print ''; +print ''; +print ''; print ''; $oldyear=0; diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index c349d35a16d..ecc27bf88dc 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -221,8 +221,8 @@ abstract class DoliDB implements Database /** * Define sort criteria of request * - * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda, t2.fieldb' - * @param string $sortorder Sort order, separated by comma. Example: 'ASC, DESC'; + * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb' + * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; * @return string String to provide syntax of a sort sql string */ function order($sortfield=null,$sortorder=null) diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 14e2c3f3dec..f93fa57923f 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -141,15 +141,18 @@ print ' /* Set handler to add page_y param on output (click on href links or submit button) */ jQuery(".reposition").click(function() { var page_y = $(document).scrollTop(); - if (this.href) + if (page_y > 0) { - this.href=this.href+\'&page_y=\'+page_y; - console.log("We click on tag with .reposition class. this.ref is now "+this.href); - } - else - { - console.log("We click on tag with .reposition class but element is not an html tag, so we try to update form field page_y with value "+page_y); - jQuery("input[type=hidden][name=page_y]").val(page_y); + if (this.href) + { + this.href=this.href+\'&page_y=\'+page_y; + console.log("We click on tag with .reposition class. this.ref is now "+this.href); + } + else + { + console.log("We click on tag with .reposition class but element is not an html tag, so we try to update form field page_y with value "+page_y); + jQuery("input[type=hidden][name=page_y]").val(page_y); + } } }); });'."\n"; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 347dd641552..2094cd10c5c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3964,7 +3964,7 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $morepar * @param string $name Translation key of field * @param int $thead 0=To use with standard table format, 1=To use inside , 2=To use with
* @param string $file Url used when we click on sort picto - * @param string $field Field to use for new sorting. Empty if this field is not sortable. + * @param string $field Field to use for new sorting. Empty if this field is not sortable. Example "t.abc" or "t.abc,t.def" * @param string $begin ("" by defaut) * @param string $moreparam Add more parameters on sort url links ("" by default) * @param string $moreattrib Add more attributes on th ("" by defaut, example: 'align="center"'). To add more css class, use param $prefix. @@ -4005,16 +4005,31 @@ function getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $m $options=preg_replace('/&+/i','&',$options); if (! preg_match('/^&/',$options)) $options='&'.$options; - if ($field1 != $sortfield1) // We are on another field + $sortordertouseinlink=''; + if ($field1 != $sortfield1) // We are on another field than current sorted field { - if (preg_match('/^DESC/', $sortorder)) $out.= ''; - else $out.= ''; + if (preg_match('/^DESC/i', $sortorder)) + { + $sortordertouseinlink.=str_repeat('desc,', count(explode(',',$field))); + } + else // We reverse the var $sortordertouseinlink + { + $sortordertouseinlink.=str_repeat('asc,', count(explode(',',$field))); + } } - else // We are of first sorting criteria + else // We are on field that is the first current sorting criteria { - if (preg_match('/^ASC/', $sortorder)) $out.= ''; - else $out.= ''; + if (preg_match('/^ASC/i', $sortorder)) // We reverse the var $sortordertouseinlink + { + $sortordertouseinlink.=str_repeat('desc,', count(explode(',',$field))); + } + else + { + $sortordertouseinlink.=str_repeat('asc,', count(explode(',',$field))); + } } + $sortordertouseinlink=preg_replace('/,$/', '', $sortordertouseinlink); + $out.= ''; } if ($tooltip) $out.=$form->textwithpicto($langs->trans($name), $langs->trans($tooltip)); From 1a9476bff5806e79df54150206fe14aa35f584e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 Apr 2018 20:17:39 +0200 Subject: [PATCH 480/609] Fix edition of label of a vat payment. --- htdocs/compta/tva/card.php | 22 ++++++++++++++++++---- htdocs/compta/tva/document.php | 21 +++------------------ htdocs/compta/tva/info.php | 23 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index abd7baa12f9..240a4624d44 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -59,10 +59,18 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && ! $id) exit; } +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib','alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + if ($action == 'setdatev' && $user->rights->tax->charges->creer) { $object->fetch($id); - $object->datev=dol_mktime(12,0,0,$_POST['datevmonth'],$_POST['datevday'],$_POST['datevyear']); + $object->datev=dol_mktime(12,0,0,GETPOST('datevmonth','int'),GETPOST('datevday','int'),GETPOST('datevyear','int')); $result=$object->update($user); if ($result < 0) dol_print_error($db,$object->error); @@ -309,6 +317,13 @@ if ($id) dol_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment'); + $morehtmlref='
'; + // Label of social contribution + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); + // Project + $morehtmlref.='
'; + $linkback = '
'.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); @@ -319,14 +334,13 @@ if ($id) print '
'.$langs->trans("Year").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'; // Label - print ''; + //print ''; print ""; - print ''; - print ''; } diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index 77525a0b0d1..ae71f02753b 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -65,7 +65,7 @@ class modDav extends DolibarrModules // Module description, used if translation string 'ModuledavDesc' not found (MyModue is name of module). $this->description = "davDescription"; // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "davDescription (Long)"; + $this->descriptionlong = "davDescription"; // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' $this->version = 'experimental'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9b4079281b9..c88af3fc1b1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -473,6 +473,9 @@ AttachMainDocByDefault=Set this to 1 if you want to attach main document to emai FilesAttachedToEmail=Attach file SendEmailsReminders=Send agenda reminders by emails davDescription=Add a component to be a DAV server +DAVSetup=Setup of module DAV +DAV_ALLOW_PUBLIC_DIR=Enable the public directory (WebDav directory with no login required) +DAV_ALLOW_PUBLIC_DIRTooltip=The WebDav public directory is a WebDAV directory everybody can access to (in read and write mode), with no need to have/use an existing login/password account. # Modules Module0Name=Users & groups Module0Desc=Users / Employees and Groups management From 82a8513aeda45f6d86e1caee968b8c3201058066 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 19:52:14 +0200 Subject: [PATCH 484/609] Standardize code --- .../admin/assets_extrafields.php | 4 +- .../admin/assets_type_extrafields.php | 4 +- htdocs/{assets => asset}/admin/setup.php | 0 htdocs/{assets => asset}/card.php | 52 +++++++++---------- .../{assets => asset}/class/asset.class.php | 32 ++++++------ .../class/asset_type.class.php | 6 +-- htdocs/{assets => asset}/document.php | 26 +++++----- htdocs/{assets => asset}/info.php | 12 ++--- htdocs/{assets => asset}/list.php | 40 +++++++------- htdocs/{assets => asset}/note.php | 28 +++++----- htdocs/{assets => asset}/type.php | 38 +++++++------- htdocs/comm/propal/list.php | 23 ++++---- htdocs/commande/list.php | 12 ++--- htdocs/compta/paiement/list.php | 12 ++--- htdocs/compta/tva/list.php | 2 +- htdocs/contrat/list.php | 6 +-- htdocs/core/class/html.formother.class.php | 4 +- .../lib/{assets.lib.php => asset.lib.php} | 22 ++++---- htdocs/core/menus/standard/eldy.lib.php | 18 +++---- ...modAssets.class.php => modAsset.class.php} | 50 +++++++++--------- htdocs/fourn/commande/list.php | 25 ++++----- htdocs/fourn/facture/list.php | 12 ++--- htdocs/fourn/facture/paiement.php | 4 +- .../install/mysql/migration/7.0.0-8.0.0.sql | 2 + htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/orders.lang | 4 +- htdocs/langs/en_US/workflow.lang | 4 +- htdocs/supplier_proposal/list.php | 16 +++--- htdocs/theme/eldy/style.css.php | 2 +- 29 files changed, 229 insertions(+), 233 deletions(-) rename htdocs/{assets => asset}/admin/assets_extrafields.php (97%) rename htdocs/{assets => asset}/admin/assets_type_extrafields.php (97%) rename htdocs/{assets => asset}/admin/setup.php (100%) rename htdocs/{assets => asset}/card.php (85%) rename htdocs/{assets => asset}/class/asset.class.php (95%) rename htdocs/{assets => asset}/class/asset_type.class.php (97%) rename htdocs/{assets => asset}/document.php (83%) rename htdocs/{assets => asset}/info.php (88%) rename htdocs/{assets => asset}/list.php (94%) rename htdocs/{assets => asset}/note.php (82%) rename htdocs/{assets => asset}/type.php (96%) rename htdocs/core/lib/{assets.lib.php => asset.lib.php} (83%) rename htdocs/core/modules/{modAssets.class.php => modAsset.class.php} (88%) diff --git a/htdocs/assets/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php similarity index 97% rename from htdocs/assets/admin/assets_extrafields.php rename to htdocs/asset/admin/assets_extrafields.php index 426da1c239f..52c1f042836 100644 --- a/htdocs/assets/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/assets/admin/assets_extrafields.php - * \ingroup assets + * \file htdocs/asset/admin/asset_extrafields.php + * \ingroup asset * \brief Page to setup extra fields of assets */ diff --git a/htdocs/assets/admin/assets_type_extrafields.php b/htdocs/asset/admin/assets_type_extrafields.php similarity index 97% rename from htdocs/assets/admin/assets_type_extrafields.php rename to htdocs/asset/admin/assets_type_extrafields.php index 62878c9d8b5..261c7de99b7 100644 --- a/htdocs/assets/admin/assets_type_extrafields.php +++ b/htdocs/asset/admin/assets_type_extrafields.php @@ -18,8 +18,8 @@ /** /** - * \file htdocs/assets/admin/assets_type_extrafields.php - * \ingroup assets + * \file htdocs/asset/admin/assets_type_extrafields.php + * \ingroup asset * \brief Page to setup extra fields type of assets */ require '../../main.inc.php'; diff --git a/htdocs/assets/admin/setup.php b/htdocs/asset/admin/setup.php similarity index 100% rename from htdocs/assets/admin/setup.php rename to htdocs/asset/admin/setup.php diff --git a/htdocs/assets/card.php b/htdocs/asset/card.php similarity index 85% rename from htdocs/assets/card.php rename to htdocs/asset/card.php index 4424ca0cf93..a76bf3d069e 100644 --- a/htdocs/assets/card.php +++ b/htdocs/asset/card.php @@ -18,18 +18,18 @@ /** * \file card.php - * \ingroup assets - * \brief Page to create/edit/view assets + * \ingroup asset + * \brief Page to create/edit/view asset */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); // Load traductions files requiredby by page -$langs->loadLangs(array("assets")); +$langs->loadLangs(array("asset")); // Get parameters $id = GETPOST('id', 'int'); @@ -39,12 +39,12 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetscard')); // Note that conf->hooks_modules contains array +$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Initialize array of search criterias @@ -60,7 +60,7 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'assets', $id); +//$result = restrictedArea($user, 'asset', $id); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); @@ -84,9 +84,9 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->assets->create; - $permissiontodelete = $user->rights->assets->delete; - $backurlforlist = dol_buildpath('/assets/list.php',1); + $permissiontoadd = $user->rights->asset->create; + $permissiontodelete = $user->rights->asset->delete; + $backurlforlist = dol_buildpath('/asset/list.php',1); // Actions cancel, add, update or delete include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -97,7 +97,7 @@ if (empty($reshook)) // Actions to send emails $trigger_name='MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; - $trackid='assets'.$object->id; + $trackid='asset'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; } @@ -241,13 +241,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; /* // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->assets->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->asset->creer, 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); */ @@ -289,7 +289,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Send print '' . $langs->trans('SendMail') . ''."\n"; - if ($user->rights->assets->write) + if ($user->rights->asset->write) { print ''.$langs->trans("Modify").''."\n"; } @@ -298,7 +298,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Modify').''."\n"; } - if ($user->rights->assets->delete) + if ($user->rights->asset->delete) { print ''.$langs->trans('Delete').''."\n"; } @@ -324,15 +324,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Documents /*$objref = dol_sanitizeFileName($object->ref); $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->assets->dir_output . '/' . $objref; + $filedir = $conf->asset->dir_output . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->assets->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->assets->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('assets', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + $genallowed = $user->rights->asset->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->asset->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('asset', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('assets')); + $linktoelem = $form->showLinkToObjectBlock($object, null, array('asset')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); @@ -340,14 +340,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $MAXEVENT = 10; - $morehtmlright = ''; + $morehtmlright = ''; $morehtmlright.= $langs->trans("SeeAll"); $morehtmlright.= ''; // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'assets', $socid, 1, '', $MAXEVENT, '', $morehtmlright); + $somethingshown = $formactions->showactions($object, 'asset', $socid, 1, '', $MAXEVENT, '', $morehtmlright); print '
'; } diff --git a/htdocs/assets/class/asset.class.php b/htdocs/asset/class/asset.class.php similarity index 95% rename from htdocs/assets/class/asset.class.php rename to htdocs/asset/class/asset.class.php index efacac10822..86da8ae5379 100644 --- a/htdocs/assets/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -17,9 +17,9 @@ */ /** - * \file assets/class/assets.class.php - * \ingroup assets - * \brief This file is a CRUD class file for assets (Create/Read/Update/Delete) + * \file asset/class/asset.class.php + * \ingroup asset + * \brief This file is a CRUD class file for asset (Create/Read/Update/Delete) */ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; @@ -27,30 +27,30 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** - * Class for Assets + * Class for Asset */ -class Assets extends CommonObject +class Asset extends CommonObject { /** * @var string ID to identify managed object */ - public $element = 'assets'; + public $element = 'asset'; /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'assets'; + public $table_element = 'asset'; /** - * @var int Does assets support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int Does module support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; /** - * @var int Does assets support extrafields ? 0=No, 1=Yes + * @var int Does asset support extrafields ? 0=No, 1=Yes */ public $isextrafieldmanaged = 1; /** - * @var string String with name of icon for assets. Must be the part after the 'object_' into object_assets.png + * @var string String with name of icon for asset. Must be the part after the 'object_' into object_asset.png */ - public $picto = 'assets'; + public $picto = 'asset'; /** @@ -111,21 +111,21 @@ class Assets extends CommonObject /** * @var int Name of subtable line */ - //public $table_element_line = 'assetsdet'; + //public $table_element_line = 'assetdet'; /** * @var int Field with ID of parent key if this field has a parent */ - //public $fk_element = 'fk_assets'; + //public $fk_element = 'fk_asset'; /** * @var int Name of subtable class that manage subtable lines */ - //public $class_element_line = 'Assetsline'; + //public $class_element_line = 'Assetline'; /** * @var array Array of child tables (child tables to delete before deleting a record) */ - //protected $childtables=array('assetsdet'); + //protected $childtables=array('assetdet'); /** - * @var AssetsLine[] Array of subtable lines + * @var AssetLine[] Array of subtable lines */ //public $lines = array(); diff --git a/htdocs/assets/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php similarity index 97% rename from htdocs/assets/class/asset_type.class.php rename to htdocs/asset/class/asset_type.class.php index d4d12916e9a..9fbcca64d8b 100644 --- a/htdocs/assets/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -16,8 +16,8 @@ */ /** - * \file htdocs/assets/class/asset_type.class.php - * \ingroup assets + * \file htdocs/asset/class/asset_type.class.php + * \ingroup asset * \brief File of class to manage asset types */ @@ -375,7 +375,7 @@ class AssetType extends CommonObject $result=''; $label=$langs->trans("ShowTypeCard",$this->label); - $linkstart = ''; + $linkstart = ''; $linkend=''; $result .= $linkstart; diff --git a/htdocs/assets/document.php b/htdocs/asset/document.php similarity index 83% rename from htdocs/assets/document.php rename to htdocs/asset/document.php index 490fb8f36a4..fbd2fe6cdb8 100644 --- a/htdocs/assets/document.php +++ b/htdocs/asset/document.php @@ -18,13 +18,13 @@ /** * \file document.php - * \ingroup assets + * \ingroup asset * \brief Tab for documents linked to Assets */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; @@ -42,7 +42,7 @@ $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'assets', $id); +//$result = restrictedArea($user, 'asset', $id); // Get parameters $sortfield = GETPOST("sortfield",'alpha'); @@ -56,12 +56,12 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetsdocument')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array('assetdocument')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -110,7 +110,7 @@ if ($object->id) // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -131,15 +131,15 @@ if ($object->id) dol_fiche_end(); - $modulepart = 'assets'; - //$permission = $user->rights->assets->create; + $modulepart = 'asset'; + //$permission = $user->rights->asset->create; $permission = 1; - //$permtoedit = $user->rights->assets->create; + //$permtoedit = $user->rights->asset->create; $permtoedit = 1; $param = '&id=' . $object->id; - //$relativepathwithnofile='assets/' . dol_sanitizeFileName($object->id).'/'; - $relativepathwithnofile='assets/' . dol_sanitizeFileName($object->ref).'/'; + //$relativepathwithnofile='asset/' . dol_sanitizeFileName($object->id).'/'; + $relativepathwithnofile='asset/' . dol_sanitizeFileName($object->ref).'/'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } diff --git a/htdocs/assets/info.php b/htdocs/asset/info.php similarity index 88% rename from htdocs/assets/info.php rename to htdocs/asset/info.php index 9017a9e6845..c953a09c83b 100644 --- a/htdocs/assets/info.php +++ b/htdocs/asset/info.php @@ -17,16 +17,16 @@ /** * \file info.php - * \ingroup assets + * \ingroup asset * \brief Page to show an asset information */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; -$langs->loadLangs(array("assets")); +$langs->loadLangs(array("asset")); $id = GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -34,9 +34,9 @@ $action=GETPOST('action','alpha'); // Security check if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'assets', $id, ''); +$result = restrictedArea($user, 'asset', $id, ''); -$object = new Assets($db); +$object = new Asset($db); $object->fetch($id); /* diff --git a/htdocs/assets/list.php b/htdocs/asset/list.php similarity index 94% rename from htdocs/assets/list.php rename to htdocs/asset/list.php index 2b68a1b6782..d9860dc32a3 100644 --- a/htdocs/assets/list.php +++ b/htdocs/asset/list.php @@ -19,8 +19,8 @@ /** * \file list.php - * \ingroup assets - * \brief List page for assets + * \ingroup asset + * \brief List page for asset */ // Load Dolibarr environment @@ -28,7 +28,7 @@ require '../main.inc.php'; require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load traductions files requiredby by page $langs->loadLangs(array("assets")); @@ -56,12 +56,12 @@ $pageprev = $page - 1; $pagenext = $page + 1; // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetslist')); // Note that conf->hooks_modules contains array +$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Default sort order (if not yet defined by previous GETPOST) @@ -75,7 +75,7 @@ if ($user->societe_id > 0) //$socid = $user->societe_id; accessforbidden(); } -//$result = restrictedArea($user, 'assets', $id,''); +//$result = restrictedArea($user, 'asset', $id,''); // Initialize array of search criterias $search_all=trim(GETPOST("search_all",'alpha')); @@ -147,11 +147,11 @@ if (empty($reshook)) } // Mass actions - $objectclass='Assets'; - $objectlabel='Assets'; - $permtoread = $user->rights->assets->read; - $permtodelete = $user->rights->assets->delete; - $uploaddir = $conf->assets->dir_output; + $objectclass='Asset'; + $objectlabel='Asset'; + $permtoread = $user->rights->asset->read; + $permtodelete = $user->rights->asset->delete; + $uploaddir = $conf->asset->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -167,7 +167,7 @@ $form=new Form($db); $now=dol_now(); -//$help_url="EN:Module_Assets|FR:Module_Assets_FR|ES:Módulo_Assets"; +//$help_url="EN:Module_Asset|FR:Module_Asset_FR|ES:Módulo_Asset"; $help_url=''; $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets")); @@ -291,7 +291,7 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->assets->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if ($user->rights->asset->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); @@ -309,8 +309,8 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort // Add code for pre mass action (confirmation or email presend form) $topicmail="SendAssetsRef"; -$modelmail="assets"; -$objecttmp=new Assets($db); +$modelmail="asset"; +$objecttmp=new Asset($db); $trackid='xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; @@ -515,10 +515,10 @@ if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nb $urlsource.=str_replace('&','&',$param); $filedir=$diroutputmassaction; - $genallowed=$user->rights->assets->read; - $delallowed=$user->rights->assets->create; + $genallowed=$user->rights->asset->read; + $delallowed=$user->rights->asset->create; - print $formfile->showdocuments('massfilesarea_assets','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + print $formfile->showdocuments('massfilesarea_asset','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); } else { diff --git a/htdocs/assets/note.php b/htdocs/asset/note.php similarity index 82% rename from htdocs/assets/note.php rename to htdocs/asset/note.php index b0db48e2abe..9ed9053dc5c 100644 --- a/htdocs/assets/note.php +++ b/htdocs/asset/note.php @@ -18,16 +18,16 @@ /** * \file note.php - * \ingroup assets - * \brief Card with notes on Assets + * \ingroup asset + * \brief Card with notes on Asset */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/assets.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; // Load traductions files requiredby by page -$langs->loadLangs(array("assets","companies")); +$langs->loadLangs(array("asset","companies")); // Get parameters $id = GETPOST('id', 'int'); @@ -37,24 +37,24 @@ $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new Assets($db); +$object=new Asset($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('assetsnote')); // Note that conf->hooks_modules contains array +$diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('assets'); +$extralabels = $extrafields->fetch_name_optionals_label('asset'); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); //if ($user->societe_id > 0) $socid = $user->societe_id; -//$result = restrictedArea($user, 'assets', $id); +//$result = restrictedArea($user, 'asset', $id); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -if ($id > 0 || ! empty($ref)) $upload_dir = $conf->assets->multidir_output[$object->entity] . "/" . $object->id; +if ($id > 0 || ! empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; $permissionnote=1; -//$permissionnote=$user->rights->assets->creer; // Used by the include of actions_setnotes.inc.php +//$permissionnote=$user->rights->asset->creer; // Used by the include of actions_setnotes.inc.php /* @@ -84,7 +84,7 @@ if ($id > 0 || ! empty($ref)) // Object card // ------------------------------------------------------------ - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; /* @@ -98,7 +98,7 @@ if ($id > 0 || ! empty($ref)) { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->assets->creer) + if ($user->rights->asset->creer) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; diff --git a/htdocs/assets/type.php b/htdocs/asset/type.php similarity index 96% rename from htdocs/assets/type.php rename to htdocs/asset/type.php index c1a6d849c01..d26175d168f 100644 --- a/htdocs/assets/type.php +++ b/htdocs/asset/type.php @@ -16,15 +16,15 @@ */ /** - * \file htdocs/assets/type.php - * \ingroup assets + * \file htdocs/asset/type.php + * \ingroup asset * \brief Asset's type setup */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/assets.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/asset.class.php'; -require_once DOL_DOCUMENT_ROOT.'/assets/class/asset_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php'; +require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("assets"); @@ -51,7 +51,7 @@ $label=GETPOST("label","alpha"); $comment=GETPOST("comment"); // Security check -$result=restrictedArea($user,'assets',$rowid,'asset_type'); +$result=restrictedArea($user,'asset',$rowid,'asset_type'); $object = new AssetType($db); @@ -86,7 +86,7 @@ if ($cancel) { } } -if ($action == 'add' && $user->rights->assets->write) +if ($action == 'add' && $user->rights->asset->write) { $object->label = trim($label); $object->accountancy_code_asset = trim($accountancy_code_asset); @@ -135,7 +135,7 @@ if ($action == 'add' && $user->rights->assets->write) } } -if ($action == 'update' && $user->rights->assets->write) +if ($action == 'update' && $user->rights->asset->write) { $object->fetch($rowid); @@ -166,7 +166,7 @@ if ($action == 'update' && $user->rights->assets->write) exit; } -if ($action == 'confirm_delete' && $user->rights->assets->write) +if ($action == 'confirm_delete' && $user->rights->asset->write) { $object->fetch($rowid); $res=$object->delete(); @@ -255,7 +255,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') print '
'; print ''; print ''; - if ($user->rights->adherent->configurer) + if ($user->rights->asset->configurer) print ''; else print ''; @@ -281,7 +281,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') /* ************************************************************************** */ if ($action == 'create') { - $object = new AdherentType($db); + $object = new AssetType($db); print load_fiche_titre($langs->trans("NewMemberType")); @@ -344,7 +344,7 @@ if ($rowid > 0) { if ($action != 'edit') { - $object = new AdherentType($db); + $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); @@ -360,7 +360,7 @@ if ($rowid > 0) dol_fiche_head($head, 'card', $langs->trans("MemberType"), -1, 'group'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'rowid', $linkback); @@ -398,7 +398,7 @@ if ($rowid > 0) print '
'; // Edit - if ($user->rights->adherent->configurer) + if ($user->rights->asset->configurer) { print ''; } @@ -407,7 +407,7 @@ if ($rowid > 0) print ''; // Delete - if ($user->rights->adherent->configurer) + if ($user->rights->asset->configurer) { print ''; } @@ -575,7 +575,7 @@ if ($rowid > 0) $datefin=$db->jdate($objp->datefin); - $adh=new Adherent($db); + $adh=new Asset($db); $adh->lastname=$objp->lastname; $adh->firstname=$objp->firstname; @@ -643,12 +643,12 @@ if ($rowid > 0) // Actions print '
'; } if (! empty($arrayfields['p.ref_client']['checked'])) { print ''; } if (! empty($arrayfields['pr.ref']['checked'])) { print ''; } if (! empty($arrayfields['s.nom']['checked'])) { print ''; } if (! empty($arrayfields['s.town']['checked'])) print ''; @@ -529,15 +529,16 @@ if ($resql) { print ''; } // Date if (! empty($arrayfields['p.date']['checked'])) { - print ''; @@ -551,28 +552,28 @@ if ($resql) { // Amount print ''; } if (! empty($arrayfields['p.total_vat']['checked'])) { // Amount print ''; } if (! empty($arrayfields['p.total_ttc']['checked'])) { // Amount print ''; } if (! empty($arrayfields['u.login']['checked'])) { // Author print ''; } // Extra fields diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 5e3f9bade62..872d6f02bfa 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -612,17 +612,17 @@ if ($resql) // Date order if (! empty($arrayfields['c.date_commande']['checked'])) { - print ''; } if (! empty($arrayfields['c.date_delivery']['checked'])) { - print ''; } diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index f001d84a27d..017593316a7 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -235,21 +235,21 @@ if ($resql) // Lines for filters fields print ''; print ''; print ''; print ''; print ''; print ''; if (! empty($conf->banque->enabled)) { @@ -258,7 +258,7 @@ if ($resql) print ''; } print ''; print ''; print ''; print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index b3ee34731cc..61d62896cf1 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -519,11 +519,11 @@ if (! empty($arrayfields['c.date_contrat']['checked'])) // Date contract print ''; } // Extra fields diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 3f07066bf2e..fcc2ddf049c 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -867,7 +867,7 @@ class FormOther * @param string $morecss More CSS * @return string */ - function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='') + function select_year($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='valignmiddle widthauto') { print $this->selectyear($selected,$htmlname,$useempty,$min_year,$max_year,$offset,$invert,$option,$morecss); } @@ -886,7 +886,7 @@ class FormOther * @param string $morecss More css * @return string */ - function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='') + function selectyear($selected='',$htmlname='yearid',$useempty=0, $min_year=10, $max_year=5, $offset=0, $invert=0, $option='', $morecss='valignmiddle widthauto') { $out=''; diff --git a/htdocs/core/lib/assets.lib.php b/htdocs/core/lib/asset.lib.php similarity index 83% rename from htdocs/core/lib/assets.lib.php rename to htdocs/core/lib/asset.lib.php index cc9ea922854..460d368f2c4 100644 --- a/htdocs/core/lib/assets.lib.php +++ b/htdocs/core/lib/asset.lib.php @@ -17,7 +17,7 @@ /** * \file core/lib/assets.lib.php - * \ingroup assets + * \ingroup asset * \brief Library files with common functions for Assets */ @@ -35,7 +35,7 @@ function AssetsAdminPrepareHead() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/assets/admin/setup.php'; + $head[$h][0] = DOL_URL_ROOT . '/asset/admin/setup.php'; $head[$h][1] = $langs->trans("Settings"); $head[$h][2] = 'settings'; $h++; @@ -43,19 +43,19 @@ function AssetsAdminPrepareHead() // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( - // 'entity:+tabname:Title:@assets:/assets/mypage.php?id=__ID__' + // 'entity:+tabname:Title:@assets:/asset/mypage.php?id=__ID__' //); // to add new tab //$this->tabs = array( - // 'entity:-tabname:Title:@assets:/assets/mypage.php?id=__ID__' + // 'entity:-tabname:Title:@assets:/asset/mypage.php?id=__ID__' //); // to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets_admin'); - $head[$h][0] = DOL_URL_ROOT . '/assets/admin/assets_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/assets/admin/assets_type_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT . '/asset/admin/assets_type_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFieldsAssetsType"); $head[$h][2] = 'attributes_type'; $h++; @@ -74,7 +74,7 @@ function AssetsPrepareHead() $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT . '/assets/card.php'; + $head[$h][0] = DOL_URL_ROOT . '/asset/card.php'; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -94,7 +94,7 @@ function AssetsPrepareHead() $upload_dir = $conf->assets->dir_output . '/' . get_exdir($filename,2,0,1,$object,'assets'). '/'. dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); - $head[$h][0] = DOL_URL_ROOT.'/assets/document.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/asset/document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; $head[$h][2] = 'documents'; @@ -103,18 +103,18 @@ function AssetsPrepareHead() $nbNote = 0; if(!empty($object->note_private)) $nbNote++; if(!empty($object->note_public)) $nbNote++; - $head[$h][0] = DOL_URL_ROOT.'/assets/note.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/asset/note.php?id='.$object->id; $head[$h][1] = $langs->trans("Notes"); if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/assets/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT . '/asset/info.php?id=' . $object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; - complete_head_from_modules($conf, $langs, $object, $head, $h, 'assets', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'asset', 'remove'); return $head; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 71901d2fcef..5463e737282 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -188,10 +188,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode $menuqualified=0; if (! empty($conf->comptabilite->enabled)) $menuqualified++; if (! empty($conf->accounting->enabled)) $menuqualified++; - if (! empty($conf->assets->enabled)) $menuqualified++; + if (! empty($conf->asset->enabled)) $menuqualified++; $tmpentry=array( 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->assets->read)), + 'perms'=>(! empty($user->rights->compta->resultat->lire) || ! empty($user->rights->accounting->mouvements->lire) || ! empty($user->rights->asset->read)), 'module'=>'comptabilite|accounting'); $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) @@ -1138,15 +1138,15 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Assets - if (! empty($conf->assets->enabled)) + if (! empty($conf->asset->enabled)) { $langs->load("assets"); - $newmenu->add("/assets/list.php?leftmenu=assets&mainmenu=accountancy",$langs->trans("MenuAssets"), 0, $user->rights->assets->read, '', $mainmenu, 'assets'); - $newmenu->add("/assets/card.php?leftmenu=assets&action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->assets->write); - $newmenu->add("/assets/type.php?leftmenu=assets",$langs->trans("MenuTypeAssets"), 1, $user->rights->assets->read, '', $mainmenu, 'assets_type'); - $newmenu->add("/assets/type.php?leftmenu=assets_type&action=create",$langs->trans("MenuNewTypeAssets"), 1, $user->rights->assets->write); - $newmenu->add("/assets/type.php?leftmenu=assets_type",$langs->trans("MenuListTypeAssets"), 1, $user->rights->assets->read); - $newmenu->add("/assets/list.php?leftmenu=assets",$langs->trans("MenuListAssets"), 1, $user->rights->assets->read); + $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy",$langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset'); + $newmenu->add("/asset/card.php?leftmenu=asset&action=create",$langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); + $newmenu->add("/asset/type.php?leftmenu=asset",$langs->trans("MenuTypeAssets"), 1, $user->rights->asset->read, '', $mainmenu, 'asset_type'); + $newmenu->add("/asset/type.php?leftmenu=asset_type&action=create",$langs->trans("MenuNewTypeAssets"), 1, $user->rights->asset->write); + $newmenu->add("/asset/type.php?leftmenu=asset_type",$langs->trans("MenuListTypeAssets"), 1, $user->rights->asset->read); + $newmenu->add("/asset/list.php?leftmenu=asset",$langs->trans("MenuListAssets"), 1, $user->rights->asset->read); } } diff --git a/htdocs/core/modules/modAssets.class.php b/htdocs/core/modules/modAsset.class.php similarity index 88% rename from htdocs/core/modules/modAssets.class.php rename to htdocs/core/modules/modAsset.class.php index 84aed4669a2..6b7985a0e23 100644 --- a/htdocs/core/modules/modAssets.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -17,11 +17,11 @@ */ /** - * \defgroup assets Module Assets - * \brief Assets module descriptor. + * \defgroup asset Module Assets + * \brief Asset module descriptor. * - * \file htdocs/core/modules/modAssets.class.php - * \ingroup assets + * \file htdocs/core/modules/modAsset.class.php + * \ingroup asset * \brief Description and activation file for module Assets */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; @@ -33,7 +33,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; /** * Description and activation class for module FixedAssets */ -class modAssets extends DolibarrModules +class modAsset extends DolibarrModules { // @codingStandardsIgnoreEnd /** @@ -51,7 +51,7 @@ class modAssets extends DolibarrModules // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). $this->numero = 51000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'assets'; + $this->rights_class = 'asset'; // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' // It is used to group modules by family in module setup page @@ -78,17 +78,17 @@ class modAssets extends DolibarrModules $this->picto='generic'; // Defined all module parts (triggers, login, substitutions, menus, css, etc...) - // for default path (eg: /assets/core/xxxxx) (0=disable, 1=enable) - // for specific path of parts (eg: /assets/core/modules/barcode) - // for specific css file (eg: /assets/css/assets.css.php) + // for default path (eg: /asset/core/xxxxx) (0=disable, 1=enable) + // for specific path of parts (eg: /asset/core/modules/barcode) + // for specific css file (eg: /asset/css/assets.css.php) $this->module_parts = array(); // Data directories to create when module is enabled. - // Example: this->dirs = array("/assets/temp","/assets/subdir"); + // Example: this->dirs = array("/asset/temp","/asset/subdir"); $this->dirs = array(); // Config pages. Put here list of php page, stored into assets/admin directory, to use to setup module. - $this->config_page_url = array("setup.php@assets"); + $this->config_page_url = array("setup.php@asset"); // Dependencies $this->hidden = false; // A condition to hide module @@ -109,14 +109,14 @@ class modAssets extends DolibarrModules // 1=>array('ASSETS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) // ); $this->const = array( - 1=>array('ASSETS_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + 1=>array('ASSET_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) ); - if (! isset($conf->assets) || ! isset($conf->assets->enabled)) + if (! isset($conf->asset) || ! isset($conf->asset->enabled)) { - $conf->assets=new stdClass(); - $conf->assets->enabled=0; + $conf->asset=new stdClass(); + $conf->asset->enabled=0; } @@ -170,16 +170,16 @@ class modAssets extends DolibarrModules // Boxes/Widgets // Add here list of php file(s) stored in assets/core/boxes that contains class to show a widget. $this->boxes = array( - //0=>array('file'=>'assetswidget1.php@assets','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'assetswidget2.php@assets','note'=>'Widget provided by Assets'), - //2=>array('file'=>'assetswidget3.php@assets','note'=>'Widget provided by Assets') + //0=>array('file'=>'assetswidget1.php@asset','note'=>'Widget provided by Assets','enabledbydefaulton'=>'Home'), + //1=>array('file'=>'assetswidget2.php@asset','note'=>'Widget provided by Assets'), + //2=>array('file'=>'assetswidget3.php@asset','note'=>'Widget provided by Assets') ); // Cronjobs (List of cron jobs entries to add when module is enabled) // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week $this->cronjobs = array( - 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/assets/class/assets.class.php', 'objectname'=>'Assets', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) + 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/asset/class/asset.class.php', 'objectname'=>'Asset', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true) ); // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>true), // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>true) @@ -193,22 +193,22 @@ class modAssets extends DolibarrModules $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Read assets'; // Permission label $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Create/Update assets'; // Permission label $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) $r++; $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) $this->rights[$r][1] = 'Delete assets'; // Permission label $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->assets->level1->level2) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->asset->level1->level2) // Main menu entries diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index c72c31b3a99..1ea820e09ad 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -24,10 +24,9 @@ /** * \file htdocs/fourn/commande/list.php * \ingroup fournisseur - * \brief List of suppliers orders + * \brief List of vendor orders */ - require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -40,13 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->load("orders"); -$langs->load("sendings"); -$langs->load('deliveries'); -$langs->load('companies'); -$langs->load('compta'); -$langs->load('bills'); -$langs->load('projects'); +$langs->loadLangs(array("orders","sendings",'deliveries','companies','compta','bills','projects','suppliers')); $action=GETPOST('action','aZ09'); $massaction=GETPOST('massaction','alpha'); @@ -825,19 +818,19 @@ if ($resql) // Date order if (! empty($arrayfields['cf.date_commande']['checked'])) { - print ''; } // Date delivery if (! empty($arrayfields['cf.date_delivery']['checked'])) { - print ''; } if (! empty($arrayfields['cf.total_ht']['checked'])) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 95bbfe48e19..90240cf8688 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -643,18 +643,18 @@ if ($resql) // Date invoice if (! empty($arrayfields['f.datef']['checked'])) { - print ''; } // Date due if (! empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index a47b76e4af8..74593cb8675 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -851,8 +851,8 @@ if (empty($action)) print ''; print ''; print ''; print ''; } if (! empty($arrayfields['s.nom']['checked'])) { print ''; } if (! empty($arrayfields['s.town']['checked'])) print ''; @@ -514,7 +514,7 @@ if ($resql) { print ''; } if (! empty($arrayfields['sp.total_vat']['checked'])) { // Amount print ''; } if (! empty($arrayfields['sp.total_ttc']['checked'])) { // Amount print ''; } if (! empty($arrayfields['u.login']['checked'])) { // Author print ''; } // Extra fields diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 578ec142ad5..6683e966a97 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1011,7 +1011,7 @@ select.selectarrowonleft option { select { padding-top: 4px; - padding-bottom: 5px; + padding-bottom: 4px; } input, input[type=text], input[type=password], select, textarea { min-width: 20px; From 98ff3868a9f49c4e41d91ab4c9a045a99f0676ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 20:11:17 +0200 Subject: [PATCH 485/609] Fix translation --- htdocs/langs/en_US/other.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 2afabe43b06..04b38e531ef 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -218,7 +218,7 @@ FileIsTooBig=Files is too big PleaseBePatient=Please be patient... NewPassword=New password ResetPassword=Reset password -RequestToResetPasswordReceived=A request to change your Dolibarr password has been received +RequestToResetPasswordReceived=A request to change your password has been received NewKeyIs=This is your new keys to login NewKeyWillBe=Your new key to login to software will be ClickHereToGoTo=Click here to go to %s From 9a345e99ef8cca1300474a90ff2175c5e7e27fd1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 20:14:57 +0200 Subject: [PATCH 486/609] Fix syntax error --- htdocs/fourn/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index aff48655daf..8ea1f249b7e 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1104,7 +1104,7 @@ if (empty($reshook)) if ($result > 0) { $ref_supplier = $productsupplier->ref_supplier; - $product_fourn_price_id = $productsupplier->product_fourn_price_id + $product_fourn_price_id = $productsupplier->product_fourn_price_id; } } else From 2fc2c44de419192b89dedb09fd17bd6db430ff20 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 20:18:50 +0200 Subject: [PATCH 487/609] Fix phpcs --- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/lib/tax.lib.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index d1fec4a5a6d..7228214e51c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -395,7 +395,7 @@ class Account extends CommonObject * @param string $emetteur Name of cheque writer * @param string $banque Bank of cheque writer * @param string $accountancycode When we record a free bank entry, we must provide accounting account if accountancy module is on. - * @param int $datevalue Date value + * @param int $datev Date value * @return int Rowid of added entry, <0 if KO */ function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur='',$banque='', $accountancycode='', $datev=null) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0c3ddab9e2d..046097eec86 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6659,7 +6659,7 @@ abstract class CommonObject } $queryarray[$field] = serialize($this->{$field}); } else { - $queryarray[$field] = NULL; + $queryarray[$field] = null; } } else if($this->isInt($info)) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index e432b741929..0d46503c51b 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -88,7 +88,7 @@ function tax_prepare_head(ChargeSociales $object) * @param int $q Quarter * @return array Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error */ -function tax_by_thirdparty($type='vat', $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0) +function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m=0, $q=0) { global $conf; From efcc3f40fa82d913de826edaca465ee7946dbff8 Mon Sep 17 00:00:00 2001 From: Julien BARRET Date: Sun, 29 Apr 2018 23:22:46 +0200 Subject: [PATCH 488/609] Fix link "refresh" on turnover report --- htdocs/compta/stats/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index eb26015615c..ea2d6fa9c03 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -84,6 +84,12 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end $userid=GETPOST('userid','int'); $socid = GETPOST('socid','int'); +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; + // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') $modecompta = $conf->global->ACCOUNTING_MODE; if (! empty($conf->accounting->enabled)) $modecompta='BOOKKEEPING'; From b099d834a0145dc8ea53791a7bef2e74c2b9d0bd Mon Sep 17 00:00:00 2001 From: Julien BARRET Date: Sun, 29 Apr 2018 23:26:44 +0200 Subject: [PATCH 489/609] Fix bug : when click on refresh button, next and previous button are broken. Eg. in year 2018, next button point to year 4032! --- htdocs/compta/resultat/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index e8b00fc869b..c4131dc365b 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -90,7 +90,7 @@ $tmps=dol_getdate($date_start); $year_start = $tmps['year']; $tmpe=dol_getdate($date_end); $year_end = $tmpe['year']; -$nbofyear = ($year_end - $start_year) + 1; +$nbofyear = ($year_end - $year_start) + 1; //var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); From bb2ef46ef459733de33b46f42810b32227f94d04 Mon Sep 17 00:00:00 2001 From: Julien BARRET Date: Mon, 30 Apr 2018 00:24:47 +0200 Subject: [PATCH 490/609] Reactivate next and previous link --- htdocs/compta/stats/cabyprodserv.php | 17 +++++++++++++---- htdocs/compta/stats/cabyuser.php | 14 ++++++++++---- htdocs/compta/stats/casoc.php | 15 +++++++++++---- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index f367f8ee436..fb651977d7c 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -111,6 +111,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end // TODO We define q } +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; + $commonparams=array(); $commonparams['modecompta']=$modecompta; $commonparams['sortorder'] = $sortorder; @@ -154,10 +161,11 @@ $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByProductsAndServices") if ($modecompta=="CREANCES-DETTES") { $calcmode=$langs->trans("CalcModeDebt"); - $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - + $periodlink="".img_previous()." ".img_next().""; + $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description.= $langs->trans("DepositsAreNotIncluded"); @@ -168,10 +176,11 @@ if ($modecompta=="CREANCES-DETTES") { $builddate=dol_now(); } else { $calcmode=$langs->trans("CalcModeEngagement"); - $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - + $periodlink="".img_previous()." ".img_next().""; + $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 1fa48738e66..a21c34e0c2f 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -99,6 +99,12 @@ else { // TODO We define q } +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; $commonparams=array(); $commonparams['modecompta']=$modecompta; @@ -139,9 +145,9 @@ $form=new Form($db); if ($modecompta=="CREANCES-DETTES") { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode=$langs->trans("CalcModeDebt"); - $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink="".img_previous()." ".img_next().""; + $periodlink="".img_previous()." ".img_next().""; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -150,9 +156,9 @@ if ($modecompta=="CREANCES-DETTES") { } else { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode=$langs->trans("CalcModeEngagement"); - $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink="".img_previous()." ".img_next().""; + $periodlink="".img_previous()." ".img_next().""; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index b7b37d0837c..9a88a1c4574 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -120,6 +120,13 @@ else // TODO We define q } +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; +$nbofyear = ($year_end - $year_start) + 1; + $commonparams=array(); $commonparams['modecompta']=$modecompta; $commonparams['sortorder'] = $sortorder; @@ -167,9 +174,9 @@ if ($modecompta=="CREANCES-DETTES") { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); $calcmode=$langs->trans("CalcModeDebt"); - $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink=''.img_previous().' '.img_next().''; + $periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -178,9 +185,9 @@ if ($modecompta=="CREANCES-DETTES") } else { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); $calcmode=$langs->trans("CalcModeEngagement"); - $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - //$periodlink=''.img_previous().' '.img_next().''; + $periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); From 6a76242611bc68036a69934fc86de8f797fe289a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 08:59:07 +0200 Subject: [PATCH 491/609] Fix record with date_creation empty --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 2 ++ htdocs/install/mysql/migration/repair.sql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index c2d7d3dd321..70cbaeb7e04 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -435,6 +435,8 @@ UPDATE llx_accounting_account set account_parent = 0 WHERE account_parent = '' O -- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_parent SET DEFAULT 0; ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_parent (account_parent); +UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS NULL; + ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 0724dba9667..9493ef6c7c9 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -438,6 +438,8 @@ update llx_facture_fourn_det set product_type = 0 where product_type = 1 AND fk_ update llx_facture_fourn_det set product_type = 1 where product_type = 0 AND fk_product > 0 AND fk_product IN (SELECT rowid FROM llx_product WHERE fk_product_type = 1); +UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS NULL; + -- UPDATE llx_contratdet set label = NULL WHERE label IS NOT NULL; -- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL; From 55f982e504772f3a666592334a04fe5ae80147d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 09:28:24 +0200 Subject: [PATCH 492/609] Removed deprecated FPDI option and reorganise PDF setup page --- htdocs/admin/pdf.php | 93 +++++++++++-------- htdocs/core/lib/pdf.lib.php | 1 - .../commande/doc/pdf_einstein.modules.php | 10 +- .../contract/doc/pdf_strato.modules.php | 2 +- .../expedition/doc/pdf_merou.modules.php | 2 +- .../expedition/doc/pdf_rouget.modules.php | 2 +- .../doc/pdf_standard.modules.php | 2 +- .../modules/facture/doc/pdf_crabe.modules.php | 2 +- .../fichinter/doc/pdf_soleil.modules.php | 2 +- .../livraison/doc/pdf_typhon.modules.php | 2 +- .../product/doc/pdf_standard.modules.php | 2 +- .../project/doc/pdf_baleine.modules.php | 2 +- .../project/doc/pdf_beluga.modules.php | 2 +- .../project/doc/pdf_timespent.modules.php | 2 +- .../modules/propale/doc/pdf_azur.modules.php | 2 +- .../pdf/pdf_canelle.modules.php | 2 +- .../pdf/pdf_muscadet.modules.php | 2 +- .../doc/pdf_standard.modules.php | 2 +- .../doc/pdf_aurore.modules.php | 2 +- htdocs/langs/en_US/admin.lang | 3 +- 20 files changed, 76 insertions(+), 63 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 8484539528d..e0c2d776d7a 100644 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -133,7 +133,7 @@ if ($action == 'edit') // Edit // Misc options - print load_fiche_titre($langs->trans("DictionaryPaperFormat"),'','').'
'; + print load_fiche_titre($langs->trans("DictionaryPaperFormat"),'',''); print '
'; print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("DatePayment").''; + print ''.$langs->trans("DatePayment").''; print dol_print_date($object->datep,'day'); print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")), 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); print ''; diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 9ffc2202b8a..04d65dfadf5 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -84,7 +84,7 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; if ($action == 'setlib' && $user->rights->tax->charges->creer) { $object->fetch($id); - $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + $result = $object->setValueFrom('label', GETPOST('lib','alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -111,23 +111,8 @@ if ($object->id) $morehtmlref='
'; // Label of social contribution - $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' : '; - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } - } + $morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); $morehtmlref.='
'; $linkback = '' . $langs->trans("BackToList") . ''; diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index 6a3955403e7..24208aedf2a 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -37,10 +37,27 @@ $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'tax', '', '', 'charges'); +$object = new Tva($db); + + + +/* + * Actions + */ + +if ($action == 'setlib' && $user->rights->tax->charges->creer) +{ + $object->fetch($id); + $result = $object->setValueFrom('label', GETPOST('lib','alpha'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + /* * View */ + $title=$langs->trans("VAT") . " - " . $langs->trans("Info"); $help_url=''; llxHeader("",$title,$helpurl); @@ -53,6 +70,12 @@ $head = vat_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("VATPayment"), -1, 'payment'); +$morehtmlref='
'; +// Label of social contribution +$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1); +$morehtmlref.='
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); From aafab12f4b4775cebe001ba40a1a0e1a7db0fd6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 18:06:31 +0200 Subject: [PATCH 481/609] Debug API for ticket module --- .../facture/class/api_invoices.class.php | 3 +- htdocs/core/lib/functions2.lib.php | 3 + htdocs/product/class/api_products.class.php | 6 +- ...etsups.class.php => api_tickets.class.php} | 109 ++++++++++++++---- htdocs/ticketsup/class/ticketsup.class.php | 13 ++- 5 files changed, 101 insertions(+), 33 deletions(-) rename htdocs/ticketsup/class/{api_ticketsups.class.php => api_tickets.class.php} (89%) diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 35f7e966104..8547be8cb2c 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1072,8 +1072,9 @@ class Invoices extends DolibarrApi /** * Add a payment to pay partially or completely one or several invoices. * Warning: Take care that all invoices are owned by the same customer. + * Example of value for parameter arrayofamounts: {"1": "99.99", "2": "10"} * - * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice. Example {"1": "99.99", "2": "10"} + * @param string $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice * @param string $datepaye {@from body} Payment date {@type timestamp} * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index dc223f58ec3..0b8d42f3a9e 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2268,6 +2268,9 @@ function getModuleDirForApiClass($module) elseif ($module == 'ficheinter' || $module == 'interventions') { $moduledirforclass = 'fichinter'; } + elseif ($module == 'tickets') { + $moduledirforclass = 'ticketsup'; + } return $moduledirforclass; } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 083aeb80e34..8d4c435b18e 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -59,16 +59,16 @@ class Products extends DolibarrApi * * @param int $id ID of product * @param int $includestockdata Load also information about stock (slower) - * @return array|mixed data without useless information + * @return array|mixed Data without useless information * - * @throws RestException * @throws 401 + * @throws 403 * @throws 404 */ function get($id, $includestockdata=0) { if(! DolibarrApiAccess::$user->rights->produit->lire) { - throw new RestException(401); + throw new RestException(403); } $result = $this->product->fetch($id); diff --git a/htdocs/ticketsup/class/api_ticketsups.class.php b/htdocs/ticketsup/class/api_tickets.class.php similarity index 89% rename from htdocs/ticketsup/class/api_ticketsups.class.php rename to htdocs/ticketsup/class/api_tickets.class.php index 98af42fd262..e2e2776dcfc 100644 --- a/htdocs/ticketsup/class/api_ticketsups.class.php +++ b/htdocs/ticketsup/class/api_tickets.class.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/ticketsup.lib.php'; * * */ -class Ticketsups extends DolibarrApi +class Tickets extends DolibarrApi { /** * @var array $FIELDS Mandatory fields, checked when create and update object @@ -53,36 +53,93 @@ class Ticketsups extends DolibarrApi /** * Constructor - * - * @url GET ticketsup/ - * */ public function __construct() { - global $db; - $this->db = $db; + global $db; + $this->db = $db; $this->ticketsup = new Ticketsup($this->db); } /** - * Get properties of a ticketsup object - * - * Return an array with ticketsup informations - * - * @param int $id ID of ticketsup - * @param string $track_id Tracking ID of ticket - * @param string $ref Reference for ticket - * @return array|mixed data without useless information - * - * @url GET track_id/{track_id} - * @url GET ref/{ref} - * @url GET {id} - * @throws RestException - */ - public function get($id = 0, $track_id = '', $ref = '') + * Get properties of a Ticket object. + * + * Return an array with ticket informations + * + * @param int $id ID of ticketsup + * @return array|mixed Data without useless information + * + * @throws 401 + * @throws 403 + * @throws 404 + */ + function get($id) + { + return $this->getCommon($id, '', ''); + } + + /** + * Get properties of a Ticket object from track id + * + * Return an array with ticket informations + * + * @param string $track_id Tracking ID of ticket + * @return array|mixed Data without useless information + * + * @url GET track_id/{track_id} + * + * @throws 401 + * @throws 403 + * @throws 404 + */ + public function getByTrackId($track_id) + { + return $this->getCommon(0, $track_id, ''); + } + + /** + * Get properties of a Ticket object from ref + * + * Return an array with ticket informations + * + * @param string $ref Reference for ticket + * @return array|mixed Data without useless information + * + * @url GET ref/{ref} + * + * @throws 401 + * @throws 403 + * @throws 404 + */ + public function getByRef($ref) + { + try { + return $this->getCommon(0, '', $ref); + } + catch(Exception $e) + { + throw $e; + } + } + + /** + * Get properties of a Ticket object + * + * Return an array with ticket informations + * + * @param int $id ID of ticketsup + * @param string $track_id Tracking ID of ticket + * @param string $ref Reference for ticket + * @return array|mixed Data without useless information + * + * @throws 401 + * @throws 403 + * @throws 404 + */ + public function getCommon($id = 0, $track_id = '', $ref = '') { if (! DolibarrApiAccess::$user->rights->ticketsup->read) { - throw new RestException(401); + throw new RestException(403); } // Check parameters @@ -474,9 +531,9 @@ class Ticketsups extends DolibarrApi function _cleanObjectDatas($object) { - // Remove $db object property for object - unset($object->db); + $object = parent::_cleanObjectDatas($object); + // Other attributes to clean $attr2clean = array( "contact", "contact_id", @@ -515,7 +572,9 @@ class Ticketsups extends DolibarrApi "firstname", "civility_id", "cache_msgs_ticket", - "cache_logs_ticket" + "cache_logs_ticket", + "statuts_short", + "statuts" ); foreach ($attr2clean as $toclean) { unset($object->$toclean); diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index a8b8e7f5479..b416819b4b6 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -489,7 +489,8 @@ class Ticketsup extends CommonObject dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql)) { + if ($this->db->num_rows($resql)) + { $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; @@ -529,10 +530,14 @@ class Ticketsup extends CommonObject $this->tms = $this->db->jdate($obj->tms); $this->fetch_optionals(); - } - $this->db->free($resql); - return 1; + $this->db->free($resql); + return 1; + } + else + { + return 0; + } } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); From 8b4ef1313af9e63b2d34de642398676fa14db95a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 18:24:24 +0200 Subject: [PATCH 482/609] FIX API for tickets --- htdocs/api/class/api_setup.class.php | 4 +- ...pi_dictionaryticketsupcategories.class.php | 98 ---------- ...pi_dictionaryticketsupseverities.class.php | 98 ---------- .../api_dictionaryticketsuptypes.class.php | 100 ---------- htdocs/ticketsup/class/api_tickets.class.php | 184 ++++++++++++++++++ 5 files changed, 186 insertions(+), 298 deletions(-) delete mode 100644 htdocs/ticketsup/class/api_dictionaryticketsupcategories.class.php delete mode 100644 htdocs/ticketsup/class/api_dictionaryticketsupseverities.class.php delete mode 100644 htdocs/ticketsup/class/api_dictionaryticketsuptypes.class.php diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 19bf6688638..ef2b4c8bb6d 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -385,7 +385,7 @@ class Setup extends DolibarrApi * @param string $sortorder Sort order * @param string $type Type of element ('adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...) * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'SO-%')" - * @return List of events types + * @return List of extra fields * * @url GET extrafields * @@ -584,7 +584,7 @@ class Setup extends DolibarrApi * Do a test of integrity for files and setup. * * @param string $target Can be 'local' or 'default' or Url of the signatures file to use for the test. Must be reachable by the tested Dolibarr. - * @return Result of file and setup integrity check + * @return Result of file and setup integrity check * * @url GET checkintegrity * diff --git a/htdocs/ticketsup/class/api_dictionaryticketsupcategories.class.php b/htdocs/ticketsup/class/api_dictionaryticketsupcategories.class.php deleted file mode 100644 index d33f96db881..00000000000 --- a/htdocs/ticketsup/class/api_dictionaryticketsupcategories.class.php +++ /dev/null @@ -1,98 +0,0 @@ - - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; - -/** - * API class for ticketsup types - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryTicketsupCategories extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of ticketsup types. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types - * - * @throws RestException - */ - function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT rowid, code, pos, label, use_default, description"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ticketsup_category as t"; - $sql.= " WHERE t.active = 1"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(503, 'Error when retrieving list of ticketsup categories : '.$this->db->lasterror()); - } - - return $list; - } - - -} diff --git a/htdocs/ticketsup/class/api_dictionaryticketsupseverities.class.php b/htdocs/ticketsup/class/api_dictionaryticketsupseverities.class.php deleted file mode 100644 index 892563ad426..00000000000 --- a/htdocs/ticketsup/class/api_dictionaryticketsupseverities.class.php +++ /dev/null @@ -1,98 +0,0 @@ - - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; - -/** - * API class for ticketsup severities - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryTicketsupSeverities extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of ticketsup types. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types - * - * @throws RestException - */ - function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT rowid, code, pos, label, use_default, color, description"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ticketsup_severity as t"; - $sql.= " WHERE t.active = 1"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(503, 'Error when retrieving list of ticketsup severities : '.$this->db->lasterror()); - } - - return $list; - } - - -} diff --git a/htdocs/ticketsup/class/api_dictionaryticketsuptypes.class.php b/htdocs/ticketsup/class/api_dictionaryticketsuptypes.class.php deleted file mode 100644 index 90b8d4f6bbc..00000000000 --- a/htdocs/ticketsup/class/api_dictionaryticketsuptypes.class.php +++ /dev/null @@ -1,100 +0,0 @@ - - * Copyright (C) 2016 Laurent Destailleur - * - * 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 . - */ - -use Luracast\Restler\RestException; - -require_once DOL_DOCUMENT_ROOT.'/main.inc.php'; - -/** - * API class for ticketsup types - * - * @access protected - * @class DolibarrApiAccess {@requires user,external} - */ -class DictionaryTicketsupTypes extends DolibarrApi -{ - /** - * Constructor - */ - function __construct() - { - global $db; - $this->db = $db; - } - - /** - * Get the list of ticketsup types. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number (starting from zero) - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" - * @return List of events types - * - * @throws RestException - */ - function index($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') - { - $list = array(); - - $sql = "SELECT rowid, code, pos, label, use_default, description"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ticketsup_type as t"; - $sql.= " WHERE t.active = 1"; - if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; - if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } - - - $sql.= $this->db->order($sortfield, $sortorder); - - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; - - $sql .= $this->db->plimit($limit, $offset); - } - - $result = $this->db->query($sql); - - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(503, 'Error when retrieving list of ticketsup types : '.$this->db->lasterror()); - } - - return $list; - } - - -} diff --git a/htdocs/ticketsup/class/api_tickets.class.php b/htdocs/ticketsup/class/api_tickets.class.php index e2e2776dcfc..d0cd018648c 100644 --- a/htdocs/ticketsup/class/api_tickets.class.php +++ b/htdocs/ticketsup/class/api_tickets.class.php @@ -478,6 +478,190 @@ class Tickets extends DolibarrApi ); } + + /** + * Get the list of tickets categories. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of events types + * + * @url GET setup/dictionary/categories + * + * @throws RestException + */ + function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid, code, pos, label, use_default, description"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ticketsup_category as t"; + $sql.= " WHERE t.active = 1"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of ticketsup categories : '.$this->db->lasterror()); + } + + return $list; + } + + /** + * Get the list of tickets severity. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of events types + * + * @url GET setup/dictionary/severities + * + * @throws RestException + */ + function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid, code, pos, label, use_default, color, description"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ticketsup_severity as t"; + $sql.= " WHERE t.active = 1"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of ticketsup severities : '.$this->db->lasterror()); + } + + return $list; + } + + /** + * Get the list of tickets types. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return List of events types + * + * @url GET setup/dictionary/types + * + * @throws RestException + */ + function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid, code, pos, label, use_default, description"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ticketsup_type as t"; + $sql.= " WHERE t.active = 1"; + if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; + if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql.= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of ticketsup types : '.$this->db->lasterror()); + } + + return $list; + } + + + + + /** * Validate fields before create or update object * From e168240ab0febd5607e3052a741a6ec94b3f9997 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 Apr 2018 18:32:15 +0200 Subject: [PATCH 483/609] Debug module DAV --- htdocs/admin/dav.php | 2 +- htdocs/core/modules/modDav.class.php | 2 +- htdocs/langs/en_US/admin.lang | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index f757663b6d5..091c9ff66bf 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -76,7 +76,7 @@ if ($action == 'edit') foreach($arrayofparameters as $key => $val) { print '
'; - print $form->textwithpicto($langs->trans($key),$langs->trans($key.'Tooltip')); + print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); print '
'.dol_escape_htmltag($objp->label).''.yn($objp->subscription).''.yn($objp->vote).'rowid.'">'.img_edit().' '; - if ($user->rights->adherent->creer) + if ($user->rights->asset->creer) { print ''.img_edit().''; } print ' '; - if ($user->rights->adherent->supprimer) + if ($user->rights->asset->supprimer) { print ''.img_picto($langs->trans("Resiliate"),'disable.png').''; } @@ -682,7 +682,7 @@ if ($rowid > 0) if ($action == 'edit') { - $object = new AdherentType($db); + $object = new AssetType($db); $object->fetch($rowid); $object->fetch_optionals(); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 78aa5a0d9cb..84710999183 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -487,25 +487,25 @@ if ($resql) if (! empty($arrayfields['p.ref']['checked'])) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); + print ajax_combobox('search_type_thirdparty'); print ''; + print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; //print ' '.$langs->trans('Year').': '; $formother->select_year($search_year,'search_year',1, 20, 5); print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_orderyear?$search_orderyear:-1,'search_orderyear',1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_deliveryyear?$search_deliveryyear:-1,'search_deliveryyear',1, 20, 5); print '
'; - print ''; + print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; - print ''; + print ''; print ''; $form->select_types_paiements($search_paymenttype,'search_paymenttype','',2,1,1); print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; $searchpicto=$form->showFilterAndCheckAddButtons(0); diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 9a881daccc9..48356972e69 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -174,7 +174,7 @@ if ($result) print ''; - print ''; + print ''; $syear = $year; $formother->select_year($syear?$syear:-1,'year',1, 20, 5); print ''; //print $langs->trans('Month').': '; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; //print ' '.$langs->trans('Year').': '; $syear = $year; - print $formother->selectyear($syear,'year',1, 20, 5, 0, 0, '', 'widthauto'); + print $formother->selectyear($syear,'year',1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_orderyear?$search_orderyear:-1,'search_orderyear',1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; - $formother->select_year($search_deliveryyear?$search_deliveryyear:-1,'search_deliveryyear',1, 20, 5); + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + $formother->select_year($search_deliveryyear?$search_deliveryyear:-1, 'search_deliveryyear', 1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($year_lim?$year_lim:-1,'year_lim',1, 20, 5); print '
'.$langs->trans("Late"); print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($year?$year:-1,'year',1, 20, 5); print ''; diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 954469df861..c2d7d3dd321 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -437,3 +437,5 @@ ALTER TABLE llx_accounting_account ADD INDEX idx_accounting_account_account_pare ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); +UPDATE llx_rights_def set module = 'asset' where module = 'assets'; + diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 3a93cd836c6..46bf3c93a2c 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -917,7 +917,7 @@ SearchIntoTasks=Tasks SearchIntoCustomerInvoices=Customer invoices SearchIntoSupplierInvoices=Vendor invoices SearchIntoCustomerOrders=Customer orders -SearchIntoSupplierOrders=Vendor orders +SearchIntoSupplierOrders=Purchase orders SearchIntoCustomerProposals=Customer proposals SearchIntoSupplierProposals=Vendor proposals SearchIntoInterventions=Interventions diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 9942a081e57..06191d9f7b7 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -117,7 +117,7 @@ FirstApprovalAlreadyDone=First approval already done SecondApprovalAlreadyDone=Second approval already done SupplierOrderReceivedInDolibarr=Purchase Order %s received %s SupplierOrderSubmitedInDolibarr=Purchase Order %s submited -SupplierOrderClassifiedBilled=Vendor order %s set billed +SupplierOrderClassifiedBilled=Purchase Order %s set billed OtherOrders=Other orders ##### Types de contacts ##### TypeContact_commande_internal_SALESREPFOLL=Representative following-up customer order @@ -125,7 +125,7 @@ TypeContact_commande_internal_SHIPPING=Representative following-up shipping TypeContact_commande_external_BILLING=Customer invoice contact TypeContact_commande_external_SHIPPING=Customer shipping contact TypeContact_commande_external_CUSTOMER=Customer contact following-up order -TypeContact_order_supplier_internal_SALESREPFOLL=Representative following-up vendor order +TypeContact_order_supplier_internal_SALESREPFOLL=Representative following-up purchase order TypeContact_order_supplier_internal_SHIPPING=Representative following-up shipping TypeContact_order_supplier_external_BILLING=Vendor invoice contact TypeContact_order_supplier_external_SHIPPING=Vendor shipping contact diff --git a/htdocs/langs/en_US/workflow.lang b/htdocs/langs/en_US/workflow.lang index c8724c5f5b2..ed19a531c07 100644 --- a/htdocs/langs/en_US/workflow.lang +++ b/htdocs/langs/en_US/workflow.lang @@ -14,7 +14,7 @@ descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER=Classify linked source custome descWORKFLOW_INVOICE_CLASSIFY_BILLED_ORDER=Classify linked source customer order(s) to billed when customer invoice is set to paid (and if amount of the invoice is same than total amount of linked orders) descWORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING=Classify linked source customer order to shipped when a shipment is validated (and if quantity shipped by all shipments is the same as in the order to update) # Autoclassify supplier order -descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source vendor proposal(s) to billed when supplier invoice is validated (and if amount of the invoice is same than total amount of linked proposals) -descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source vendor order(s) to billed when supplier invoice is validated (and if amount of the invoice is same than total amount of linked orders) +descWORKFLOW_ORDER_CLASSIFY_BILLED_SUPPLIER_PROPOSAL=Classify linked source vendor proposal(s) to billed when vendor invoice is validated (and if amount of the invoice is same than total amount of linked proposals) +descWORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER=Classify linked source purchase order(s) to billed when vendor invoice is validated (and if amount of the invoice is same than total amount of linked orders) AutomaticCreation=Automatic creation AutomaticClassification=Automatic classification \ No newline at end of file diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 6cc5b54f050..aa5c7e70ab3 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -477,13 +477,13 @@ if ($resql) if (! empty($arrayfields['sp.ref']['checked'])) { print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; //print $langs->trans('Month').': '; - print ''; + print ''; //print ' '.$langs->trans('Year').': '; $syearvalid = $yearvalid; $formother->select_year($syearvalid,'yearvalid',1, 20, 5); @@ -525,7 +525,7 @@ if ($resql) { print ''; //print $langs->trans('Month').': '; - print ''; + print ''; //print ' '.$langs->trans('Year').': '; $syear = $year; $formother->select_year($syear,'year',1, 20, 5); @@ -536,28 +536,28 @@ if ($resql) { // Amount print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print '
'; @@ -168,7 +168,7 @@ if ($action == 'edit') // Edit // Addresses - print load_fiche_titre($langs->trans("PDFAddressForging"),'','').'
'; + print load_fiche_titre($langs->trans("PDFAddressForging"),'',''); print '
'; print '
'; @@ -255,14 +255,15 @@ if ($action == 'edit') // Edit print '
'; print '
'; + print '
'; + // Localtaxes + $locales =''; + $text=''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { - $locales =''; - $text=''; - if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1",$mysoc->country_code); @@ -279,31 +280,39 @@ if ($action == 'edit') // Edit $text.= $form->selectyesno('MAIN_PDF_MAIN_HIDE_THIRD_TAX', (!empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX)) ? $conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX : 0, 1); $text.= ''; } - - print load_fiche_titre($langs->trans("PDFLocaltax",$locales),'',''); - - print ''; - print ''; - print $text; - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print '
'; - } + $title = $langs->trans("PDFRulesForSalesTax"); + if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) + { + $title.=' - '.$langs->trans("PDFLocaltax",$locales); + } + + print load_fiche_titre($title,'',''); + + print ''; + print ''; + + // Hide any information on Sale tax / VAT + + print ''; + + // Locataxes + print $text; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; + print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1); + print '
'; + print '
'; + + // Other - print load_fiche_titre($langs->trans("Other"),'','').'
'; + print load_fiche_titre($langs->trans("Other"),'',''); print '
'; print ''; print ''; - // Hide any PDF informations - - print ''; - //Desc print ''; } - print load_fiche_titre($langs->trans("PDFLocaltax",$locales),'',''); - - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; - print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1); - print '
'.$langs->trans("HideDescOnPDF").''; @@ -491,11 +500,10 @@ else // Show print '
'; // Localtaxes + $locales =''; + $text=''; if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) { - $locales =''; - $text=''; - if ($mysoc->useLocalTax(1)) { $locales = $langs->transcountry("LT1",$mysoc->country_code); @@ -513,16 +521,27 @@ else // Show $text.= '
'; - print ''; - print $text; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print '
'; - } + // Sales TAX / VAT information + $title=$langs->trans("PDFRulesForSalesTax",$locales); + if ($mysoc->useLocalTax(1) || $mysoc->useLocalTax(2)) $title.=' - '.$langs->trans("PDFLocaltax",$locales); + + print load_fiche_titre($title,'',''); + + print ''; + print ''; + + print ''; + + print $text; + + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("HideAnyVATInformationOnPDF").''; + print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1); + print '
'; + print '
'; + + // Other print load_fiche_titre($langs->trans("Other"),'',''); @@ -558,12 +577,6 @@ else // Show print ""; print ''; - // Hide any PDF informations - - print ''.$langs->trans("HideAnyVATInformationOnPDF").''; - print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1); - print ''; - //Desc print ''.$langs->trans("HideDescOnPDF").''; @@ -601,7 +614,7 @@ else // Show */ print '
'; - print load_fiche_titre($langs->trans("Library")); + print load_fiche_titre($langs->trans("Library"), '', ''); print '
'; print ''."\n"; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e238dc7054e..e2c01f90f47 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -124,7 +124,6 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') // We need to instantiate tcpdi object (instead of tcpdf) to use merging features. But we can disable it (this will break all merge features). if (empty($conf->global->MAIN_DISABLE_TCPDI)) require_once TCPDI_PATH.'tcpdi.php'; - else if (empty($conf->global->MAIN_DISABLE_FPDI)) require_once FPDI_PATH.'fpdi.php'; //$arrayformat=pdf_getFormat(); //$format=array($arrayformat['width'],$arrayformat['height']); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 738a49fe81e..06f129299e4 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -97,7 +97,7 @@ class pdf_einstein extends ModelePDFCommandes public function __construct($db) { global $conf,$langs,$mysoc; - + // Translations $langs->loadLangs(array("main", "bills", "products")); @@ -189,7 +189,7 @@ class pdf_einstein extends ModelePDFCommandes if (! is_object($outputlangs)) $outputlangs=$langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; - + // Translations $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); @@ -252,7 +252,7 @@ class pdf_einstein extends ModelePDFCommandes } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); @@ -1209,7 +1209,7 @@ class pdf_einstein extends ModelePDFCommandes function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle") { global $conf,$langs,$hookmanager; - + // Translations $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies")); @@ -1308,7 +1308,7 @@ class pdf_einstein extends ModelePDFCommandes { $top_shift = $pdf->getY() - $current_y; } - + if ($showaddress) { // Sender properties diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 62501d4881e..aed6a7f8205 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -183,7 +183,7 @@ class pdf_strato extends ModelePDFContract } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 1609ef8283f..9a496cb5589 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -165,7 +165,7 @@ class pdf_merou extends ModelePdfExpedition } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 1b7c1edcd7b..683a5e13124 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -228,7 +228,7 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 32fe36044b3..3244bb25340 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -226,7 +226,7 @@ class pdf_standard extends ModeleExpenseReport } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 0e11be1a8fa..2afdd21c82f 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -301,7 +301,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 26cdc3f5dfc..aa7ed05070b 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -173,7 +173,7 @@ class pdf_soleil extends ModelePDFFicheinter } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index 6c37a706064..6b0bb759a19 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -197,7 +197,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index a4b65bbe38a..032f75f0d65 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -203,7 +203,7 @@ class pdf_standard extends ModelePDFProduct } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 4b6273388ad..baa38e8ad2d 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -161,7 +161,7 @@ class pdf_baleine extends ModelePDFProjects } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 959cc152a0f..4f1d9179aa1 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -179,7 +179,7 @@ class pdf_beluga extends ModelePDFProjects } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 6843e9c5a33..c7f23df52e3 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -160,7 +160,7 @@ class pdf_timespent extends ModelePDFProjects } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 2a790822ea4..51de90f3c7c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -283,7 +283,7 @@ class pdf_azur extends ModelePDFPropales } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index d18f9e5bfff..6eb9f136a27 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -219,7 +219,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); 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 0e560393c4b..6947d67fb16 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -269,7 +269,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 8c9ed049841..f9567a32a5c 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -226,7 +226,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 52fbeac21d5..227a4258918 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -299,7 +299,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c88af3fc1b1..6ac7d14f529 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -374,7 +374,8 @@ NoSmsEngine=No SMS sender manager available. SMS sender manager are not installe PDF=PDF PDFDesc=You can set each global options related to the PDF generation PDFAddressForging=Rules to forge address boxes -HideAnyVATInformationOnPDF=Hide all information related to VAT on generated PDF +HideAnyVATInformationOnPDF=Hide all information related to Sales tax / VAT on generated PDF +PDFRulesForSalesTax=Rules for Sales Tax / VAT PDFLocaltax=Rules for %s HideLocalTaxOnPDF=Hide %s rate into pdf column tax sale HideDescOnPDF=Hide products description on generated PDF From 19c12f31031ee876e1ac07716a55788efb5c9c21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 09:31:09 +0200 Subject: [PATCH 493/609] Translation --- htdocs/langs/en_US/admin.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6ac7d14f529..07b661d35e9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -485,7 +485,7 @@ Module1Desc=Companies and contact management (customers, prospects...) Module2Name=Commercial Module2Desc=Commercial management Module10Name=Accounting -Module10Desc=Simple accounting reports (journals, turnover) based onto database content. No dispatching. +Module10Desc=Simple accounting reports (journals, turnover) based onto database content. Does not use any ledger table. Module20Name=Proposals Module20Desc=Commercial proposal management Module22Name=Mass E-mailings @@ -619,7 +619,7 @@ Module50100Desc=Point of sales module (POS). Module50200Name=Paypal Module50200Desc=Module to offer an online payment page accepting payments using PayPal (credit card or PayPal credit). This can be used to allow your customers to make free payments or for a payment on a particular Dolibarr object (invoice, order, ...) Module50400Name=Accounting (advanced) -Module50400Desc=Accounting management (double entries, support general and auxiliary ledgers) +Module50400Desc=Accounting management (double entries, support general and auxiliary ledgers). Export the ledger in several other accounting software format. Module54000Name=PrintIPP Module54000Desc=Direct print (without opening the documents) using Cups IPP interface (Printer must be visible from server, and CUPS must be installe on server). Module55000Name=Poll, Survey or Vote From 4c12369a261e4e078237b56536aa87f7d1913dca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 10:33:36 +0200 Subject: [PATCH 494/609] Debug module ticket --- .../core/class/html.formticketsup.class.php | 6 +- htdocs/core/js/lib_foot.js.php | 7 +- htdocs/langs/en_US/ticketsup.lang | 1 - htdocs/ticketsup/card.php | 140 +++++++++--------- .../class/actions_ticketsup.class.php | 37 +---- htdocs/ticketsup/class/ticketsup.class.php | 4 +- 6 files changed, 87 insertions(+), 108 deletions(-) diff --git a/htdocs/core/class/html.formticketsup.class.php b/htdocs/core/class/html.formticketsup.class.php index b076a0923eb..82ce12b8a03 100644 --- a/htdocs/core/class/html.formticketsup.class.php +++ b/htdocs/core/class/html.formticketsup.class.php @@ -443,7 +443,7 @@ class FormTicketsup $ticketstat->loadCacheTypesTickets(); - print ''; if ($empty) { print ''; } @@ -543,7 +543,7 @@ class FormTicketsup $ticketstat->loadCacheCategoriesTickets(); - print ''; if ($empty) { print ''; } @@ -612,7 +612,7 @@ class FormTicketsup print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ajax_combobox('select'.$htmlname,'',0,0,'off'); + print ajax_combobox('select'.$htmlname); } /** diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index f93fa57923f..cc08af7431f 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -135,8 +135,11 @@ print ' /* If page_y set, we set scollbar with it */ page_y=getParameterByName(\'page_y\', 0); /* search in GET parameter */ if (page_y == 0) page_y = jQuery("#page_y").text(); /* search in POST parameter that is filed at bottom of page */ - console.log("page_y found is "+page_y); - if (page_y > 0) $(\'html, body\').scrollTop(page_y); + if (page_y > 0) + { + console.log("page_y found is "+page_y); + $(\'html, body\').scrollTop(page_y); + } /* Set handler to add page_y param on output (click on href links or submit button) */ jQuery(".reposition").click(function() { diff --git a/htdocs/langs/en_US/ticketsup.lang b/htdocs/langs/en_US/ticketsup.lang index d81cd799203..84cc786ef6d 100644 --- a/htdocs/langs/en_US/ticketsup.lang +++ b/htdocs/langs/en_US/ticketsup.lang @@ -171,7 +171,6 @@ TicketChangeType=Change type TicketChangeCategory=Change category TicketChangeSeverity=Change severity TicketAddMessage=Add a message -TicketEditProperties=Edit properties AddMessage=Add a message MessageSuccessfullyAdded=Ticket added TicketMessageSuccessfullyAdded=Message successfully added diff --git a/htdocs/ticketsup/card.php b/htdocs/ticketsup/card.php index b85d53763bf..4b186867302 100644 --- a/htdocs/ticketsup/card.php +++ b/htdocs/ticketsup/card.php @@ -45,11 +45,11 @@ if (!empty($conf->contrat->enabled)) { $langs->loadLangs(array("companies","other","ticketsup")); // Get parameters -$id = GETPOST('id', 'int'); -$track_id = GETPOST('track_id', 'alpha', 3); -$ref = GETPOST('ref', 'alpha'); +$id = GETPOST('id', 'int'); +$track_id = GETPOST('track_id', 'alpha', 3); +$ref = GETPOST('ref', 'alpha'); $projectid = GETPOST('projectid', 'int'); -$action = GETPOST('action', 'alpha', 3); +$action = GETPOST('action', 'alpha', 3); // Initialize technical object to manage hooks of ticketsup. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('ticketsupcard','globalcard')); @@ -63,7 +63,7 @@ if (!$action) { $action = 'view'; } //Select mail models is same action as add_message -if (GETPOST('modelselected')) { +if (GETPOST('modelselected','alpha')) { $action = 'add_message'; } @@ -121,6 +121,25 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) } } +if ($action == "change_property" && GETPOST('btn_update_ticket_prop','alpha') && $user->rights->ticketsup->write) +{ + $object->fetch(GETPOST('id','int'), '', GETPOST('track_id','alpha')); + + $object->type_code = GETPOST('update_value_type','az09'); + $object->category_code = GETPOST('update_value_category','az09'); + $object->severity_code = GETPOST('update_value_severity','az09'); + + $ret = $object->update($user); + if ($ret > 0) { + $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); + $ret = $object->createTicketLog($user, $log_action); + if ($ret > 0) { + setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); + } + } + $action = 'view'; +} + $permissiondellink = $user->rights->ticketsup->write; include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once @@ -471,92 +490,82 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti * Classification and actions on ticket * ***************************************************/ - /* - * Ticket properties - */ + + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; print ''; - print ''; + print ''; print ''; - if (GETPOST('set') == 'properties' && $user->rights->ticketsup->write) { - /* - * Form to change ticket properties - */ - $j = 0; - $ticketprop[$j] = array( - 'dict' => 'type', - 'list_function' => 'selectTypesTickets', - 'label' => 'TicketChangeType', - ); - $j++; - $ticketprop[$j] = array( - 'dict' => 'category', - 'list_function' => 'selectCategoriesTickets', - 'label' => 'TicketChangeCategory', - ); - $j++; - $ticketprop[$j] = array( - 'dict' => 'severity', - 'list_function' => 'selectSeveritiesTickets', - 'label' => 'TicketChangeSeverity', - ); - foreach ($ticketprop as $property) { - print ''; - print ''; - print ''; - } + if (GETPOST('set','alpha') == 'properties' && $user->rights->ticketsup->write) { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; } else { // Type - print ''; // Category print ''; // Severity print ''; } print '
'; + print ''; print $langs->trans('Properties'); print ''; + if (GETPOST('set','alpha') == 'properties' && $user->rights->ticketsup->write) { + print ''; + } + else { + // Button to edit Properties + if ($object->fk_statut < 5 && $user->rights->ticketsup->write) { + print '' . img_edit($langs->trans('Modify')) . ''; + } + } + print '
'; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - print ' '; - print ''; - print $formticket->{$property['list_function']}($object->type_code, 'update_value', '', 0); - print ''; - print ' '; - print '
'; - print ''; - - print '
'; + print $langs->trans('TicketChangeType'); + print ''; + print $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2); + print '
'; + print $langs->trans('TicketChangeCategory'); + print ''; + print $formticket->selectCategoriesTickets($object->category_code, 'update_value_category', '', 2); + print '
'; + print $langs->trans('TicketChangeSeverity'); + print ''; + print $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); + print '
' . $langs->trans("Type") . ''; - print $object->type_label; + print '
' . $langs->trans("Type") . ''; + print $langs->getLabelFromKey($db, $object->type_code, 'c_ticketsup_type', 'code', 'label'); /*if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ - print '
' . $langs->trans("Category") . ''; - print $object->category_label; + print $langs->getLabelFromKey($db, $object->category_code, 'c_ticketsup_category', 'code', 'label'); /*if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ - print '
' . $langs->trans("TicketSeverity") . ''; - print $object->severity_label; + print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticketsup_severity', 'code', 'label'); /*if ($user->admin && !$noadmininfo) { print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); }*/ - print '
'; // End table actions - print '
'; + + print ''; + print '
'; // Display navbar with links to change ticket status print ''; @@ -718,11 +727,6 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti print ''; } - // Button to edit Properties - if ($object->fk_statut < 5 && $user->rights->ticketsup->write) { - print ''; - } - // Button to link to a contract if ($user->rights->ticketsup->write && $object->fk_statut < 5 && $user->rights->contrat->creer) { print ''; diff --git a/htdocs/ticketsup/class/actions_ticketsup.class.php b/htdocs/ticketsup/class/actions_ticketsup.class.php index f53426c6a13..a3fda3ac543 100644 --- a/htdocs/ticketsup/class/actions_ticketsup.class.php +++ b/htdocs/ticketsup/class/actions_ticketsup.class.php @@ -383,31 +383,6 @@ class ActionsTicketsup $action = 'view'; } - if ($action == "change_property" && GETPOST('btn_update_ticket_prop') && $user->rights->ticketsup->write) { - $this->fetch('', '', GETPOST('track_id','alpha')); - - $fieldtomodify = GETPOST('property') . '_code'; - $fieldtomodify_label = GETPOST('property') . '_label'; - - $oldvalue_code = $object->$fieldtomodify; - $newvalue_code = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code'); - - $oldvalue_label = $object->$fieldtomodify_label; - $newvalue_label = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label'); - - $object->$fieldtomodify = $newvalue_code; - - $ret = $object->update($user); - if ($ret > 0) { - $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); - $ret = $object->createTicketLog($user, $log_action); - if ($ret > 0) { - setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); - } - } - $action = 'view'; - } - if ($action == "new_message" && GETPOST('btn_add_message') && $user->rights->ticketsup->read) { $ret = $this->newMessage($user, $action); if ($ret) { @@ -1152,16 +1127,16 @@ class ActionsTicketsup print '
'; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; - print ''; print ''; - - print ''; - print ''; + print ''; // Default language if (! empty($conf->global->MAIN_MULTILANGS)) From 32ace6a8cfdfe0771ab5682dd654a803c7675c4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 14:39:12 +0200 Subject: [PATCH 496/609] NEW Add hook setContentSecurityPolicy --- htdocs/comm/action/list.php | 3 ++ htdocs/core/class/hookmanager.class.php | 5 ++- htdocs/main.inc.php | 42 +++++++++++++++---- .../modulebuilder/template/myobject_card.php | 3 +- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 7 files changed, 46 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 36630b93092..cca1f59bf8e 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -25,12 +25,15 @@ * \brief Page to list actions */ +if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->loadLangs(array("users","companies","agenda","commercial")); diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index f3ca56c2e8f..5c1f1358784 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -120,7 +120,7 @@ class HookManager * @param array $parameters Array of parameters * @param Object $object Object to use hooks on * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. * $this->error or this->errors are also defined by class called by this function if error. @@ -184,7 +184,8 @@ class HookManager 'printObjectSubLine', 'sendMail', 'sendMailAfter', - 'showLinkToObjectBlock' + 'showLinkToObjectBlock', + 'setContentSecurityPolicy' ) )) $hooktype='addreplace'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 862b0701e33..f76bb90ef8f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1077,20 +1077,48 @@ if (! function_exists("llxHeader")) */ function top_httphead($contenttype='text/html', $forcenocache=0) { - global $conf; + global $db, $conf, $hookmanager; if ($contenttype == 'text/html' ) header("Content-Type: text/html; charset=".$conf->file->character_set_client); else header("Content-Type: ".$contenttype); // Security options header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) - if (! empty($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY)) + header("X-XSS-Protection: 1"); // Enable XSS protection of some browsers (note: use of Content-Security-Policy is more efficient) + if (! defined('FORCECSP')) { - // For example, to restrict script, object, frames or img to some domains - // script-src https://api.google.com https://anotherhost.com; object-src https://youtube.com; child-src https://youtube.com; img-src: https://static.example.com - // For example, to restrict everything to one domain, except object, ... - // default-src https://cdn.example.net; object-src 'none' - header("Content-Security-Policy: ".$conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY); + //if (! isset($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY)) + //{ + // // A default security policy that keep usage of js external component like ckeditor, stripe, google, working + // $contentsecuritypolicy = "font-src *; img-src *; style-src * 'unsafe-inline' 'unsafe-eval'; default-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; script-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' *.stripe.com; connect-src 'self';"; + //} + //else $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY; + $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY; + + if (! is_object($hookmanager)) $hookmanager = new HookManager($db); + $hookmanager->initHooks("main"); + + $parameters=array('contentsecuritypolicy'=>$contentsecuritypolicy); + $result=$hookmanager->executeHooks('setContentSecurityPolicy',$parameters); // Note that $action and $object may have been modified by some hooks + if ($result > 0) $contentsecuritypolicy = $hookmanager->resPrint; // Replace CSP + else $contentsecuritypolicy .= $hookmanager->resPrint; // Concat CSP + + if (! empty($contentsecuritypolicy)) + { + // For example, to restrict 'script', 'object', 'frames' or 'img' to some domains: + // script-src https://api.google.com https://anotherhost.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: https://static.example.com + // For example, to restrict everything to one domain, except 'object', ...: + // default-src https://cdn.example.net; object-src 'none' + // For example, to restrict everything to itself except img that can be on other servers: + // default-src 'self'; img-src *; + // Pre-existing site that uses too much inline code to fix but wants to ensure resources are loaded only over https and disable plugins: + // default-src http: https: 'unsafe-eval' 'unsafe-inline'; object-src 'none' + header("Content-Security-Policy: ".$contentsecuritypolicy); + } + } + elseif (constant('FORCECSP')) + { + header("Content-Security-Policy: ".constant('FORCECSP')); } if ($forcenocache) { diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 9a7fda388d2..5b2a1213c0f 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -38,7 +38,8 @@ //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message +//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies // Load Dolibarr environment diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index cbac5339384..8d4cf6439a4 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -38,7 +38,7 @@ //if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged +//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message // Load Dolibarr environment $res=0; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 6683e966a97..8eb6f0b98c8 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -3509,7 +3509,7 @@ div.titre { padding-bottom: 5px; } -#dolpaymenttable { min-width: 300px; font-size: 16px; } /* Width must have min to make stripe input area visible */ +#dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 0cafac9a6c2..2188a5bff9c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -3462,7 +3462,7 @@ div.titre { dol_optimize_smallscreen)?'':'margin-top: 4px;'); ?> } -#dolpaymenttable { min-width: 300px; font-size: 16px; } /* Width must have min to make stripe input area visible */ +#dolpaymenttable { min-width: 320px; font-size: 16px; } /* Width must have min to make stripe input area visible. Lower than 320 makes input area crazy for credit card that need zip code */ #tablepublicpayment { border: 1px solid #CCCCCC !important; width: 100%; padding: 20px; } #tablepublicpayment .CTableRow1 { background-color: #F0F0F0 !important; } #tablepublicpayment tr.liste_total { border-bottom: 1px solid #CCCCCC !important; } From 56be581a98984973e567ae5cccb66d71fb0653cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 15:31:05 +0200 Subject: [PATCH 497/609] Remove deprecated header --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f76bb90ef8f..72a7327a1a1 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1084,7 +1084,7 @@ function top_httphead($contenttype='text/html', $forcenocache=0) // Security options header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) - header("X-XSS-Protection: 1"); // Enable XSS protection of some browsers (note: use of Content-Security-Policy is more efficient) + //header("X-XSS-Protection: 1"); // XSS protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated. if (! defined('FORCECSP')) { //if (! isset($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY)) From ab85fa87219dd4db9982906c72cf0da85c28bfe1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 17:45:34 +0200 Subject: [PATCH 498/609] Backport EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS to solve blocking situation. --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index f70982fd429..63abda22fed 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -216,7 +216,7 @@ if (empty($reshook)) if ($ret < 0) $error++; } - if ($object->periode_existe($fuser,$object->date_debut,$object->date_fin)) + if (empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS) && $object->periode_existe($fuser,$object->date_debut,$object->date_fin)) { $error++; setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors'); From 1bf56e58b39ff0c16bc14ed2aadf337ef0781d98 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 18:17:22 +0200 Subject: [PATCH 499/609] Work on vat report --- htdocs/compta/localtax/index.php | 52 +++++++++++++++++++++--------- htdocs/compta/tva/index.php | 55 ++++++++++++++++++++++---------- htdocs/langs/en_US/compta.lang | 4 ++- 3 files changed, 79 insertions(+), 32 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 04fa4438a96..08c4197ef2a 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -81,10 +81,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); /** * print function * - * @param DoliDB $db Database handler - * @param string $sql SQL Request - * @param string $date Date - * @return void + * @param DoliDB $db Database handler + * @param string $sql SQL Request + * @param string $date Date + * @return void */ function pt ($db, $sql, $date) { @@ -98,8 +98,9 @@ function pt ($db, $sql, $date) print '
'; - print '' . $langs->trans("InitialMessage") . ' '; + print '
'; + print $langs->trans("InitialMessage"); + print ''; if ($user->rights->ticketsup->manage) { - print '' . img_edit($langs->trans('Modify')) . ' ' . $langs->trans('Modify') . ''; + print '' . img_edit($langs->trans('Modify')) . ''; } print '
'; + print ''; if (!empty($user->rights->ticketsup->manage) && $action == 'edit_message_init') { // MESSAGE $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; @@ -1470,7 +1445,7 @@ class ActionsTicketsup global $langs; print '
'; - print '
'; + print '
'; print '
'; print '
'; print '' . $langs->trans('TicketChangeStatus') . ''; diff --git a/htdocs/ticketsup/class/ticketsup.class.php b/htdocs/ticketsup/class/ticketsup.class.php index b416819b4b6..61e5f5dd04a 100644 --- a/htdocs/ticketsup/class/ticketsup.class.php +++ b/htdocs/ticketsup/class/ticketsup.class.php @@ -181,7 +181,7 @@ class Ticketsup extends CommonObject 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>1, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"), 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), - 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>""), + 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'), 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"), 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-2, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1), @@ -815,12 +815,10 @@ class Ticketsup extends CommonObject $sql .= " datec=" . (dol_strlen($this->datec) != 0 ? "'" . $this->db->idate($this->datec) . "'" : 'null') . ","; $sql .= " date_read=" . (dol_strlen($this->date_read) != 0 ? "'" . $this->db->idate($this->date_read) . "'" : 'null') . ","; $sql .= " date_close=" . (dol_strlen($this->date_close) != 0 ? "'" . $this->db->idate($this->date_close) . "'" : 'null') . ""; - $sql .= " WHERE rowid=" . $this->id; $this->db->begin(); - dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { $error++; From e79c907ae080d8065b6a58920bc957f489a7e6e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 11:01:33 +0200 Subject: [PATCH 495/609] Fix edit of capital --- htdocs/societe/card.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index e235f6f431c..40e3083e125 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -60,7 +60,7 @@ $mesg=''; $error=0; $errors=array(); $action = (GETPOST('action','aZ09') ? GETPOST('action','aZ09') : 'view'); $cancel = GETPOST('cancel','alpha'); $backtopage = GETPOST('backtopage','alpha'); -$confirm = GETPOST('confirm'); +$confirm = GETPOST('confirm','alpha'); $socid = GETPOST('socid','int')?GETPOST('socid','int'):GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; @@ -181,12 +181,12 @@ if (empty($reshook)) // Merge categories $static_cat = new Categorie($db); - + $custcats_ori = $static_cat->containing($soc_origin->id, 'customer', 'id'); $custcats = $static_cat->containing($object->id, 'customer', 'id'); $custcats = array_merge($custcats,$custcats_ori); $object->setCategories($custcats, 'customer'); - + $suppcats_ori = $static_cat->containing($soc_origin->id, 'supplier', 'id'); $suppcats = $static_cat->containing($object->id, 'supplier', 'id'); $suppcats = array_merge($suppcats,$suppcats_ori); @@ -1885,7 +1885,9 @@ else // Capital print '
'.fieldLabel('Capital','capital').' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Currency".$conf->currency).'
'; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print "\n"; while ($i < $num) { @@ -107,14 +108,26 @@ function pt ($db, $sql, $date) print ''; print '\n"; - $total = $total + $obj->mm; - print '\n"; + $amountclaimed = 0; + $amountpaid = 0; + if ($obj->mode == 'claimed') $amountclaimed = $obj->mm; + if ($obj->mode == 'paid') $amountpaid = $obj->mm; + + $totalclaimed = $totalclaimed + $amountclaimed; + $totalpaid = $totalpaid + $amountpaied; + + print '\n"; + print '\n"; print "\n"; $i++; } - print '"; + print ''; + print ''; + print ''; + print ''; + print ""; print "
'.$date.''.$langs->trans("Amount").''.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$obj->dm."'.price($obj->mm)."'.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total")." :".price($total)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; $db->free($result); @@ -498,20 +511,29 @@ print '
'; print load_fiche_titre($langs->transcountry($LTPaid,$mysoc->country_code), '', ''); -$sql = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm"; +$sql=''; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datev >= '".$db->idate($date_start)."'"; -$sql.= " AND f.datev <= '".$db->idate($date_end)."'"; +$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')"; $sql.= " AND localtaxtype=".$localTaxType; $sql.= " GROUP BY dm"; + +$sql.= " UNION "; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode"; +$sql.= " FROM ".MAIN_DB_PREFIX."localtax as f"; +$sql.= " WHERE f.entity = ".$conf->entity; +$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; +$sql.= " AND localtaxtype=".$localTaxType; +$sql.= " GROUP BY dm"; + $sql.= " ORDER BY dm ASC"; -pt($db, $sql,$langs->trans("Month")); +pt($db, $sql, $langs->trans("Month")); -print '
'; - print '
'; llxFooter(); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index cafb965e354..425dae6853c 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -81,10 +81,10 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); /** * print function * - * @param DoliDB $db Database handler - * @param string $sql SQL Request - * @param string $date Date - * @return void + * @param DoliDB $db Database handler + * @param string $sql SQL Request + * @param string $date Date + * @return void */ function pt ($db, $sql, $date) { @@ -98,8 +98,9 @@ function pt ($db, $sql, $date) print ''; print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print "\n"; while ($i < $num) { @@ -107,14 +108,26 @@ function pt ($db, $sql, $date) print ''; print '\n"; - $total = $total + $obj->mm; - print '\n"; + print '\n"; print "\n"; $i++; } - print '"; + print ''; + print ''; + print ''; + print ''; + print ""; print "
'.$date.''.$langs->trans("Amount").''.$date.''.$langs->trans("ClaimedForThisPeriod").''.$langs->trans("PaidDuringThisPeriod").'
'.$obj->dm."'.price($obj->mm)."mode == 'claimed') $amountclaimed = $obj->mm; + if ($obj->mode == 'paid') $amountpaid = $obj->mm; + + $totalclaimed = $totalclaimed + $amountclaimed; + $totalpaid = $totalpaid + $amountpaied; + + print ''.price($amountclaimed)."'.price($amountpaid)."
'.$langs->trans("Total")." :".price($total)."
'.$langs->trans("Total").''.price($totalclaimed).''.price($totalpaid).'
"; $db->free($result); @@ -465,23 +478,33 @@ print '
'; print load_fiche_titre($langs->trans("VATPaid"), '', ''); -$sql = "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm"; +$sql=''; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; $sql.= " WHERE f.entity = ".$conf->entity; -$sql.= " AND f.datep >= '".$db->idate($date_start)."'"; -$sql.= " AND f.datep <= '".$db->idate($date_end)."'"; +$sql.= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')"; $sql.= " GROUP BY dm"; + +$sql.= " UNION "; + +$sql.= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode"; +$sql.= " FROM ".MAIN_DB_PREFIX."tva as f"; +$sql.= " WHERE f.entity = ".$conf->entity; +$sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; +$sql.= " GROUP BY dm"; + $sql.= " ORDER BY dm ASC"; +//print $sql; pt($db, $sql, $langs->trans("Month")); -print '
'; - - if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { - /* + print '
'; + + /* * Recap */ diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index fcae17f10b2..ee768598ba0 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -244,4 +244,6 @@ FiscalPeriod=Accounting period ListSocialContributionAssociatedProject=List of social contributions associated with the project DeleteFromCat=Remove from accounting group AccountingAffectation=Accounting assignement -LastDayTaxIsRelatedTo=Last day of period the tax is related to \ No newline at end of file +LastDayTaxIsRelatedTo=Last day of period the tax is related to +ClaimedForThisPeriod=Claimed for the period +PaidDuringThisPeriod=Paid during this period \ No newline at end of file From c9cca57b0ff6f733b4531729049bee6613acfb00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 20:02:16 +0200 Subject: [PATCH 500/609] NEW monthly VAT report show "Claimed for the period" + "Paid during this period" --- htdocs/compta/localtax/index.php | 65 ++++++++++++++++++++++++++------ htdocs/compta/localtax/list.php | 12 +++--- htdocs/compta/tva/index.php | 62 ++++++++++++++++++++++++------ htdocs/compta/tva/list.php | 4 +- 4 files changed, 113 insertions(+), 30 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 08c4197ef2a..4e825469b14 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -103,26 +103,66 @@ function pt ($db, $sql, $date) print ''.$langs->trans("PaidDuringThisPeriod").''; print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; while ($i < $num) { $obj = $db->fetch_object($result); - print ''; - print ''.$obj->dm."\n"; + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print ''.$obj->dm."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - if ($obj->mode == 'claimed') $amountclaimed = $obj->mm; - if ($obj->mode == 'paid') $amountpaid = $obj->mm; + $amountclaimed = 0; + $amountpaid = 0; + } - $totalclaimed = $totalclaimed + $amountclaimed; - $totalpaid = $totalpaid + $amountpaied; + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaied; + } - print ''.price($amountclaimed)."\n"; - print ''.price($amountpaid)."\n"; - print "\n"; + if ($obj->mode == 'paid') + { + print ''; + print ''.$obj->dm."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + } + else + { + $previousmode = $obj->mode; + } $i++; } + + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print ''.$obj->dm."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; + print "\n"; + + $amountclaimed = 0; + $amountpaid = 0; + } + print ''; print ''.$langs->trans("Total").''; print ''.price($totalclaimed).''; @@ -529,7 +569,8 @@ $sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->id $sql.= " AND localtaxtype=".$localTaxType; $sql.= " GROUP BY dm"; -$sql.= " ORDER BY dm ASC"; +$sql.= " ORDER BY dm ASC, mode ASC"; +//print $sql; pt($db, $sql, $langs->trans("Month")); diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index 6a6d7e3a93b..6668e3d61db 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -51,10 +51,10 @@ if ($user->rights->tax->charges->creer) print load_fiche_titre($langs->transcountry($ltt==2?"LT2Payments":"LT1Payments",$mysoc->country_code), $newcardbutton); -$sql = "SELECT rowid, amount, label, f.datev as dm"; +$sql = "SELECT rowid, amount, label, f.datev, f.datep"; $sql.= " FROM ".MAIN_DB_PREFIX."localtax as f "; $sql.= " WHERE f.entity = ".$conf->entity." AND localtaxtype=".$db->escape($ltt); -$sql.= " ORDER BY dm DESC"; +$sql.= " ORDER BY datev DESC"; $result = $db->query($sql); if ($result) @@ -67,6 +67,7 @@ if ($result) print ''; print ''.$langs->trans("Ref").''; print "".$langs->trans("Label").""; + print "".$langs->trans("PeriodEndDate").""; print ''.$langs->trans("DatePayment").''; print "".$langs->trans("PayedByThisPayment").""; print "\n"; @@ -81,7 +82,8 @@ if ($result) $localtax_static->ref=$obj->rowid; print "".$localtax_static->getNomUrl(1)."\n"; print "".dol_trunc($obj->label,40)."\n"; - print ''.dol_print_date($db->jdate($obj->dm),'day')."\n"; + print ''.dol_print_date($db->jdate($obj->datev),'day')."\n"; + print ''.dol_print_date($db->jdate($obj->datep),'day')."\n"; $total = $total + $obj->amount; print "".price($obj->amount).""; @@ -89,8 +91,8 @@ if ($result) $i++; } - print ''.$langs->trans("Total").''; - print "".price($total).""; + print ''.$langs->trans("Total").''; + print ''.price($total).''; print ""; $db->free($result); diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 425dae6853c..673e697da43 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -103,26 +103,66 @@ function pt ($db, $sql, $date) print ''.$langs->trans("PaidDuringThisPeriod").''; print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; while ($i < $num) { $obj = $db->fetch_object($result); - print ''; - print ''.$obj->dm."\n"; + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print ''.$obj->dm."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; + print "\n"; - $amountclaimed = 0; - $amountpaid = 0; - if ($obj->mode == 'claimed') $amountclaimed = $obj->mm; - if ($obj->mode == 'paid') $amountpaid = $obj->mm; + $amountclaimed = 0; + $amountpaid = 0; + } - $totalclaimed = $totalclaimed + $amountclaimed; - $totalpaid = $totalpaid + $amountpaied; + if ($obj->mode == 'claimed') + { + $amountclaimed = $obj->mm; + $totalclaimed = $totalclaimed + $amountclaimed; + } + if ($obj->mode == 'paid') + { + $amountpaid = $obj->mm; + $totalpaid = $totalpaid + $amountpaied; + } - print ''.price($amountclaimed)."\n"; - print ''.price($amountpaid)."\n"; - print "\n"; + if ($obj->mode == 'paid') + { + print ''; + print ''.$obj->dm."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; + print "\n"; + $amountclaimed = 0; + $amountpaid = 0; + $previousmode = ''; + } + else + { + $previousmode = $obj->mode; + } $i++; } + + if ($obj->mode == 'claimed' && ! empty($previousmode)) + { + print ''; + print ''.$obj->dm."\n"; + print ''.price($amountclaimed)."\n"; + print ''.price($amountpaid)."\n"; + print "\n"; + + $amountclaimed = 0; + $amountpaid = 0; + } + print ''; print ''.$langs->trans("Total").''; print ''.price($totalclaimed).''; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 48356972e69..efe436a3704 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -173,7 +173,7 @@ if ($result) print ''; print ''; print ''; - print ''; + print ''; print ''; $syear = $year; $formother->select_year($syear?$syear:-1,'year',1, 20, 5); @@ -266,7 +266,7 @@ if ($result) $colspan=5; if (! empty($conf->banque->enabled)) $colspan++; print ''.$langs->trans("Total").''; - print "".price($total).""; + print ''.price($total).''; print " "; print ""; From 9eea58e4c5594af4c8e0ce439c892dd7a902d5ac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 Apr 2018 20:19:28 +0200 Subject: [PATCH 501/609] Translation --- htdocs/compta/tva/index.php | 14 +++++++------- htdocs/langs/en_US/compta.lang | 4 +++- htdocs/langs/en_US/main.lang | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 673e697da43..3597ad27c92 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -150,7 +150,7 @@ function pt ($db, $sql, $date) $i++; } - + if ($obj->mode == 'claimed' && ! empty($previousmode)) { print ''; @@ -158,11 +158,11 @@ function pt ($db, $sql, $date) print ''.price($amountclaimed)."\n"; print ''.price($amountpaid)."\n"; print "\n"; - + $amountclaimed = 0; $amountpaid = 0; } - + print ''; print ''.$langs->trans("Total").''; print ''.price($totalclaimed).''; @@ -543,12 +543,12 @@ pt($db, $sql, $langs->trans("Month")); if (! empty($conf->global->MAIN_FEATURES_LEVEL)) { print '
'; - + /* * Recap */ - print load_fiche_titre($langs->trans("VATRecap"), '', ''); // need to add translation + print load_fiche_titre($langs->trans("VATBalance"), '', ''); // need to add translation $sql1 = "SELECT SUM(amount) as mm, date_format(f.datev,'%Y') as dm"; $sql1 .= " FROM " . MAIN_DB_PREFIX . "tva as f"; @@ -563,7 +563,7 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) print ''; print ""; - print ''; // need to add translation + print ''; print ''; print "\n"; @@ -574,7 +574,7 @@ if (! empty($conf->global->MAIN_FEATURES_LEVEL)) $restopay = $total - $obj->mm; print ""; - print ''; // need to add translation + print ''; print ''; print "\n"; diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index ee768598ba0..9c1574c77ef 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -34,7 +34,8 @@ AmountHTVATRealPaid=Net paid VATToPay=Tax sales VATReceived=Tax received VATToCollect=Tax purchases -VATSummary=Tax Balance +VATSummary=Tax monthly +VATBalance=Tax Balance VATPaid=Tax paid LT1Summary=Tax 2 summary LT2Summary=Tax 3 summary @@ -245,5 +246,6 @@ ListSocialContributionAssociatedProject=List of social contributions associated DeleteFromCat=Remove from accounting group AccountingAffectation=Accounting assignement LastDayTaxIsRelatedTo=Last day of period the tax is related to +VATDue=Sale tax claimed ClaimedForThisPeriod=Claimed for the period PaidDuringThisPeriod=Paid during this period \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 46bf3c93a2c..418042f1da9 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -402,6 +402,7 @@ DefaultTaxRate=Default tax rate Average=Average Sum=Sum Delta=Delta +RemainToPay=Remain to pay Module=Module/Application Modules=Modules/Applications Option=Option From b21059ac25e29d37b6724290e2d5c737b6b0cb2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 00:50:47 +0200 Subject: [PATCH 502/609] Translation --- htdocs/langs/en_US/admin.lang | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 07b661d35e9..9be2b2d4de1 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1039,9 +1039,9 @@ Delays_MAIN_DELAY_MEMBERS=Tolerance delay (in days) before alert on delayed memb Delays_MAIN_DELAY_CHEQUES_TO_DEPOSIT=Tolerance delay (in days) before alert for cheques deposit to do Delays_MAIN_DELAY_EXPENSEREPORTS=Tolerance delay (in days) before alert for expense reports to approve SetupDescription1=The setup area is for initial setup parameters before starting to use Dolibarr. -SetupDescription2=The two mandatory setup steps are the first two in the setup menu on the left: %s setup page and %s setup page : -SetupDescription3=Parameters in menu %s -> %s are required because defined data are used on Dolibarr screens and to customize the default behavior of the software (for country-related features for example). -SetupDescription4=Parameters in menu %s -> %s are required because Dolibarr ERP/CRM is a collection of several modules/applications, all more or less independent. New features will be added to menus for every module you will activate. +SetupDescription2=The two mandatory setup steps are the following steps (the two first entries in the left setup menu): +SetupDescription3=Settings in menu %s -> %s. This step is required because it defines data used on Dolibarr screens to customize the default behavior of the software (for country-related features for example). +SetupDescription4=Settings in menu %s -> %s. This step is required because Dolibarr ERP/CRM is a collection of several modules/applications, all more or less independent. New features are added to menus for every module you activate. SetupDescription5=Other menu entries manage optional parameters. LogEvents=Security audit events Audit=Audit From b9e6f6eab84debb8158b17a75f565422c20f4ff1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 10:35:12 +0200 Subject: [PATCH 503/609] Fix link to navigate in year only if filter is for a full year --- htdocs/compta/stats/cabyprodserv.php | 9 +++------ htdocs/compta/stats/cabyuser.php | 8 ++++---- htdocs/compta/stats/casoc.php | 7 +++---- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index fb651977d7c..1c170eae96d 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -163,9 +163,6 @@ if ($modecompta=="CREANCES-DETTES") { $calcmode=$langs->trans("CalcModeDebt"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink="".img_previous()." ".img_next().""; - $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $description.= $langs->trans("DepositsAreNotIncluded"); @@ -178,14 +175,14 @@ if ($modecompta=="CREANCES-DETTES") { $calcmode=$langs->trans("CalcModeEngagement"); $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink="".img_previous()." ".img_next().""; - $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); } +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode); diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index a21c34e0c2f..1d386df6c6f 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -146,8 +146,6 @@ if ($modecompta=="CREANCES-DETTES") { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode=$langs->trans("CalcModeDebt"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink="".img_previous()." ".img_next().""; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -157,13 +155,15 @@ if ($modecompta=="CREANCES-DETTES") { $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByUserAuthorOfInvoice"); $calcmode=$langs->trans("CalcModeEngagement"); $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink="".img_previous()." ".img_next().""; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; + $moreparam=array(); if (! empty($modecompta)) $moreparam['modecompta']=$modecompta; diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 9a88a1c4574..ed36d677df9 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -175,8 +175,6 @@ if ($modecompta=="CREANCES-DETTES") $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); $calcmode=$langs->trans("CalcModeDebt"); $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -186,13 +184,14 @@ if ($modecompta=="CREANCES-DETTES") $name=$langs->trans("SalesTurnover").', '.$langs->trans("ByThirdParties"); $calcmode=$langs->trans("CalcModeEngagement"); $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; - $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=''.img_previous().' '.img_next().''; $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); } +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; report_header($name,$namelink,$period,$periodlink,$description,$builddate,$exportlink,$tableparams,$calcmode); From 3374c50e2d0b68a06da00cedf719d8c67c6b3262 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 10:42:09 +0200 Subject: [PATCH 504/609] CSS --- htdocs/adherents/stats/index.php | 2 +- htdocs/comm/propal/stats/index.php | 2 +- htdocs/commande/stats/index.php | 2 +- htdocs/compta/deplacement/stats/index.php | 2 +- htdocs/compta/facture/stats/index.php | 2 +- htdocs/compta/salaries/stats/index.php | 2 +- htdocs/don/stats/index.php | 4 ++-- htdocs/expedition/stats/index.php | 10 +++++----- htdocs/expensereport/stats/index.php | 2 +- htdocs/fichinter/stats/index.php | 2 +- htdocs/projet/stats/index.php | 6 +++--- htdocs/projet/tasks/stats/index.php | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index 4126fc6e68c..083d81d6db6 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -213,7 +213,7 @@ print '
'; // Show graphs -print '
' . $langs->trans("VATDue") . '' . $langs->trans("VATDue") . '' . price(price2num($total, 'MT')) . '
' . $langs->trans("VATRestopay") . '' . $langs->trans("RemainToPay") . '' . price(price2num($restopay, 'MT')) . '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 273862f68bf..50ec740ea4a 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -329,7 +329,7 @@ print '
'; // Show graphs -print '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index b1baf7332a1..27d177cfbd3 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -354,7 +354,7 @@ print '
'; // Show graphs -print '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 36bc107d672..d503d5e4c07 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -294,7 +294,7 @@ print '
'; // Show graphs -print '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index d85255fbf4e..2f2692055e9 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -331,7 +331,7 @@ print '
'; // Show graphs -print '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/compta/salaries/stats/index.php b/htdocs/compta/salaries/stats/index.php index dbaeab2b252..dabe988909f 100644 --- a/htdocs/compta/salaries/stats/index.php +++ b/htdocs/compta/salaries/stats/index.php @@ -270,7 +270,7 @@ print '
'; // Show graphs -print '
'; +print ''; print ''; - + print ''; /*print ''; print '';*/ @@ -300,7 +300,7 @@ print '
'; // Show graphs -print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index b8cd532d35a..cb574da939a 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -277,7 +277,7 @@ foreach ($data as $val) $oldyear--; print '
'.$oldyear.'000
'; +print ''; print ''; - + print ''; /*print ''; print '';*/ print ''; } - + print ''; print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/expedition/stats/index.php b/htdocs/expedition/stats/index.php index 53837c76fd1..9d7d77cf290 100644 --- a/htdocs/expedition/stats/index.php +++ b/htdocs/expedition/stats/index.php @@ -275,17 +275,17 @@ foreach ($data as $val) while (! empty($year) && $oldyear > $year+1) { // If we have empty year $oldyear--; - - + + print '
'.$oldyear.'000
'; if ($year) print ''.$year.''; @@ -305,7 +305,7 @@ print '
'; // Show graphs -print '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/expensereport/stats/index.php b/htdocs/expensereport/stats/index.php index d0e3a1164bc..819f0d4d351 100644 --- a/htdocs/expensereport/stats/index.php +++ b/htdocs/expensereport/stats/index.php @@ -288,7 +288,7 @@ print '
'; // Show graphs -print '
'; +print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/fichinter/stats/index.php b/htdocs/fichinter/stats/index.php index 7f45be6a624..b00b1391003 100644 --- a/htdocs/fichinter/stats/index.php +++ b/htdocs/fichinter/stats/index.php @@ -325,7 +325,7 @@ print '
'; // Show graphs -print '
'; +print ''; print ''; if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) @@ -334,7 +334,7 @@ foreach ($data_all_year as $val) print ''; print ''; } - + print ''; print ''; print ''; @@ -352,7 +352,7 @@ print '
'; if ($mesg) { print $mesg; } else { print $px1->show(); diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index 67504974759..5f6c526d1d5 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -322,7 +322,7 @@ foreach ($data_all_year as $val) while ($year && $oldyear > $year+1) { // If we have empty year $oldyear--; - + print '
0?'&userid='.$userid:'').'">'.$oldyear.'0
0?'&userid='.$userid:'').'">'.$year.''.$val['nb'].'
'; print '
'; -$stringtoshow.= '
'; +$stringtoshow.= '
'; if ($mesg) { print $mesg; } else { $stringtoshow.= $px1->show(); diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index b03d01a8006..d030f858f4e 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -199,7 +199,7 @@ print '
'; print '
'; -$stringtoshow.= ''; print ''; print ""; @@ -1134,16 +1122,11 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') } elseif (in_array($fieldlist[$field], array('content'))) { - if ($tabname == MAIN_DB_PREFIX.'c_email_templates') - { - print ''; print ''; print ''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''; if ($inputalsopricewithtax) print ''; @@ -3716,7 +3716,7 @@ abstract class CommonObject print ''; // Multicurrency - if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''; if ($outputalsopricetotalwithtax) print ''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index fdef8a03ed8..61818d4deb9 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -111,7 +111,7 @@ if ($nolinesbefore) { - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> @@ -345,7 +345,7 @@ else { "> - multicurrency->enabled)) { $colspan++;?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { $colspan++;?> @@ -462,7 +462,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index a6f5fef5310..d3dc9807c5a 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -53,7 +53,7 @@ $colspan = 3; // Col total ht + col edit + col delete if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc if (in_array($object->element,array('propal','supplier_proposal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button if (empty($user->rights->margins->creer)) $colspan++; -if (!empty($conf->multicurrency->enabled)) $colspan+=2; +if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2; ?> @@ -148,7 +148,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled)) { + if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index f48b0b917a1..b36159f9340 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -195,7 +195,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; - multicurrency->enabled)) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> @@ -261,7 +261,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; - multicurrency->enabled)) { ?> + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { ?> From 73c3529831ce3b4eabc38afaece66d3f5f12784d Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Wed, 2 May 2018 14:36:55 +0200 Subject: [PATCH 521/609] NEW : Display price HT on all commercial area boards --- htdocs/comm/index.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 48d989d0cdc..eab813653d6 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -349,7 +349,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'customer',16); print ''; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } $i++; $total += $obj->total_ttc; } @@ -432,7 +437,12 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande $companystatic->canvas=$obj->canvas; print $companystatic->getNomUrl(1,'supplier',16); print ''; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } $i++; $total += $obj->total_ttc; } @@ -744,7 +754,12 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''."\n"; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } print ''."\n"; print ''."\n"; $i++; @@ -843,7 +858,12 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print ''; print ''."\n"; - print ''; + if(! empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT)) { + print ''; + } + else { + print ''; + } print ''."\n"; print ''."\n"; $i++; From a20ec7ba1eea98d87297cbe0b6b4699fb3eb584e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 2 May 2018 14:37:35 +0200 Subject: [PATCH 522/609] NEW cancel orders on massaction --- htdocs/commande/list.php | 3 +++ htdocs/core/actions_massactions.inc.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 872d6f02bfa..ee2fa05656d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -208,6 +208,7 @@ if (empty($reshook)) $uploaddir = $conf->commande->dir_output; $trigger_name='ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + } @@ -419,6 +420,8 @@ if ($resql) $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), + 'cancelorders'=>$langs->trans("Cancel"), + ); if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4894212fa07..6303d78d6ef 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -736,6 +736,20 @@ if ($massaction == 'confirm_createbills') } } +if ($massaction == 'cancelorders') +{ + $orders = GETPOST('toselect', 'array'); + foreach ($orders as $id_order) + { + + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) + continue; + $cmd->cancel(); + } +} + + if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { if (empty($diroutputmassaction)) From 21b387a4c45d9ff57f943aafed328ab562b40626 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 2 May 2018 15:01:32 +0200 Subject: [PATCH 523/609] NEW thirdparty categ filter on lists --- htdocs/comm/propal/list.php | 20 ++++++++++++++++++++ htdocs/commande/list.php | 17 +++++++++++++++++ htdocs/compta/facture/list.php | 19 +++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 84710999183..d5d155ce0bf 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -76,6 +76,7 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_day=GETPOST("search_day","int"); $search_month=GETPOST("search_month","int"); $search_year=GETPOST("search_year","int"); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $viewstatut=GETPOST('viewstatut','alpha'); $optioncss = GETPOST('optioncss','alpha'); @@ -205,6 +206,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $object_statut=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; + } if ($object_statut != '') $viewstatut=$object_statut; @@ -248,6 +251,8 @@ $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; $sql.= ' u.login'; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -258,6 +263,8 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ + $sql.= ', '.MAIN_DB_PREFIX.'propal as p'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal_extrafields as ef on (p.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'propaldet as pd ON p.rowid=pd.fk_propal'; @@ -294,6 +301,9 @@ if ($search_montant_ttc != '') $sql.= natural_search("p.total", $search_montant_ if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; + if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$db->escape($search_product_category); if ($socid > 0) $sql.= ' AND s.rowid = '.$socid; if ($viewstatut != '' && $viewstatut != '-1') @@ -386,6 +396,8 @@ if ($resql) if ($search_zip) $param.='&search_zip='.urlencode($search_zip); if ($socid > 0) $param.='&socid='.urlencode($socid); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -464,6 +476,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 872d6f02bfa..b5e6e0de523 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -73,6 +73,7 @@ $socid=GETPOST('socid','int'); $search_user=GETPOST('search_user','int'); $search_sale=GETPOST('search_sale','int'); $search_total_ht=GETPOST('search_total_ht','alpha'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $optioncss = GETPOST('optioncss','alpha'); $billed = GETPOST('billed','int'); $viewstatut=GETPOST('viewstatut'); @@ -193,6 +194,7 @@ if (empty($reshook)) $billed=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; } if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) @@ -237,6 +239,8 @@ $sql.= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_clie $sql.= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql.= ' c.date_creation as date_creation, c.tms as date_update,'; $sql.= " p.rowid as project_id, p.ref as project_ref"; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -247,6 +251,7 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ $sql.= ', '.MAIN_DB_PREFIX.'commande as c'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; @@ -327,6 +332,8 @@ if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$sear if ($search_user > 0) $sql.= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; if ($search_total_ht != '') $sql.= natural_search('c.total_ht', $search_total_ht, 1); if ($search_project_ref != '') $sql.= natural_search("p.ref",$search_project_ref); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -412,6 +419,8 @@ if ($resql) if ($show_files) $param.='&show_files=' .urlencode($show_files); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); if ($billed != '') $param.='&billed='.urlencode($billed); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -538,6 +547,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 61383941c10..29a98c0541b 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -96,6 +96,7 @@ $search_year = GETPOST('search_year','int'); $search_day_lim = GETPOST('search_day_lim','int'); $search_month_lim = GETPOST('search_month_lim','int'); $search_year_lim = GETPOST('search_year_lim','int'); +$search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $option = GETPOST('search_option'); if ($option == 'late') { @@ -228,6 +229,8 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter','a $search_month_lim=''; $toselect=''; $search_array_options=array(); + $search_categ_cus=0; + } if (empty($reshook)) @@ -369,6 +372,8 @@ $sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed'; +if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; + // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); // Add fields from hooks @@ -379,6 +384,8 @@ $sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (! empty($search_categ_cus)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ + $sql.= ', '.MAIN_DB_PREFIX.'facture as f'; if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_extrafields as ef on (f.rowid = ef.fk_object)"; if (! $sall) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid'; @@ -435,6 +442,8 @@ if ($search_montant_vat != '') $sql.= natural_search('f.tva', $search_montant_va if ($search_montant_localtax1 != '') $sql.= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql.= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_categ_cus > 0) $sql.= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql.= " AND cc.fk_categorie IS NULL"; if ($search_status != '' && $search_status >= 0) { if ($search_status == '0') $sql.=" AND f.fk_statut = 0"; // draft @@ -566,6 +575,8 @@ if ($resql) if ($show_files) $param.='&show_files='.urlencode($show_files); if ($option) $param.="&search_option=".urlencode($option); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + if ($search_categ_cus > 0) $param.='&search_categ_cus='.urlencode($search_categ_cus); + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -657,6 +668,14 @@ if ($resql) $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, 'maxwidth300', 1); $moreforfilter.=''; } + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('CustomersProspectsCategoriesShort').': '; + $moreforfilter.=$formother->select_categories('customer',$search_categ_cus,'search_categ_cus',1); + $moreforfilter.='
'; + } $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; From 942e2f40bf6afe5e16d6dfd9543ad50aa963a626 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 2 May 2018 17:07:27 +0200 Subject: [PATCH 524/609] addline manage rank on its own if not provided --- htdocs/fourn/class/fournisseur.facture.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c1337452d8a..34609a8fa33 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1383,6 +1383,11 @@ class FactureFournisseur extends CommonInvoice if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; + if ($rang < 0) { + $rangmax = $this->line_max(); + $rang = $rangmax + 1; + } + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); // Clean vat code From 739317a794eedeab00bea35ae2895b223351879e Mon Sep 17 00:00:00 2001 From: bafbes Date: Wed, 2 May 2018 08:10:58 +0100 Subject: [PATCH 525/609] New : option to show database name in upper help menu --- htdocs/main.inc.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 72a7327a1a1..eaea0dc420c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1581,6 +1581,10 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if ($helpbaseurl && $helppage) { $text=''; + if(!empty($conf->global->MAIN_SHOWDATABASENAMEINHELPPAGESLINK)) { + $langs->load('admin'); + $appli .= '
' . $langs->trans("Database") . ': ' . $db->database_name; + } $title=$appli.'
'; $title.=$langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage'); if ($mode == 'wiki') $title.=' - '.$langs->trans("PageWiki").' "'.dol_escape_htmltag(strtr($helppage,'_',' ')).'"'; From d0fafc812e18d165ecc413c60514ab51871e9480 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:04:59 +0200 Subject: [PATCH 526/609] Fix include of strip class only when required --- .../triggers/interface_80_modStripe_Stripe.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index b6428c51b28..cef63a474e6 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -28,8 +28,9 @@ * - Le nom de la propriete name doit etre Mytrigger */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -dol_include_once('/stripe/class/stripe.class.php'); $path=dirname(__FILE__).'/'; + + /** * Class of triggers for stripe module */ @@ -47,8 +48,8 @@ class InterfaceStripe $this->db = $db; $this->name = preg_replace('/^Interface/i', '', get_class($this)); - $this->family = 'Stripeconnect'; - $this->description = "Triggers of the module Stripeconnect"; + $this->family = 'stripe'; + $this->description = "Triggers of the module Stripe"; $this->version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' or version $this->picto = 'stripe@stripe'; } @@ -120,7 +121,10 @@ class InterfaceStripe $langs->load('other'); $ok = 0; + + include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); + if (empty($conf->stripe->enabled)) return 0; $service = 'StripeTest'; From dfe6e4bfc1484e0f8dafe277ba9d2dfeafa508f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:08:59 +0200 Subject: [PATCH 527/609] Doxygen --- htdocs/admin/modulehelp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index b90fa10e211..8d44421186d 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/admin/modules.php + * \file htdocs/admin/modulehelp.php * \brief Page to activate/disable all modules */ From 24518803fc948fc0fe26aee1adfe77c498e6f2a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:15:16 +0200 Subject: [PATCH 528/609] Clean code --- htdocs/admin/notification.php | 4 ---- .../interface_50_modBlockedlog_ActionsBlockedLog.class.php | 2 +- .../core/triggers/interface_50_modLdap_Ldapsynchro.class.php | 5 +++-- .../interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 5 +++-- htdocs/core/triggers/interface_80_modStripe_Stripe.class.php | 3 +-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 5f57ac99efc..f71bc87fc2d 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -128,8 +128,6 @@ print '
'; print ''; print ''; -$var=true; - print '
'; +$stringtoshow.= ''; // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; if ($inputalsopricewithtax) print ''; @@ -3409,7 +3409,7 @@ abstract class CommonObject print ''; // Multicurrency - if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; if ($outputalsopricetotalwithtax) print ''; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 1deef2e2412..f14af2b838f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -65,7 +65,7 @@ if ($nolinesbefore) { - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> + multicurrency->enabled)) { $colspan++;?> @@ -266,7 +266,7 @@ else { "> - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { $colspan++;?> + multicurrency->enabled)) { $colspan++;?> @@ -402,7 +402,7 @@ if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $da } } - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; if (! empty($usemargins)) { diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 80d8c617c44..d982516bd67 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -122,7 +122,7 @@ $coldisplay=-1; // We remove first td if ($this->situation_counter > 1) print ' readonly'; print '>'; - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { + if (!empty($conf->multicurrency->enabled)) { $colspan++; print ''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 984af537ea9..0a20c2679a1 100755 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -138,7 +138,7 @@ if (empty($usemargins)) $usemargins=0; - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled)) { ?> @@ -204,7 +204,7 @@ if (empty($usemargins)) $usemargins=0; - multicurrency->enabled) && $object->multicurrency_code != $conf->currency) { ?> + multicurrency->enabled)) { ?> From b5d720651968b2ad26418f2a1713e2d34792a464 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 1 May 2018 12:02:33 +0200 Subject: [PATCH 507/609] fix 6.0 accountancy multientity --- htdocs/accountancy/admin/account.php | 45 ++++++++++--------- htdocs/accountancy/admin/journals_list.php | 4 +- .../core/class/html.formaccounting.class.php | 1 + 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 905fd8b97ef..9b1b6746861 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -94,9 +94,9 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { if (! empty($cancel)) $action = ''; - + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers { $search_account = ""; @@ -106,13 +106,13 @@ if (empty($reshook)) $search_pcgsubtype = ""; $search_array_options=array(); } - + if (GETPOST('change_chart')) { $chartofaccounts = GETPOST('chartofaccounts', 'int'); - + if (! empty($chartofaccounts)) { - + if (! dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { $error ++; } @@ -120,12 +120,12 @@ if (empty($reshook)) $error ++; } } - + if ($action == 'disable') { if ($accounting->fetch($id)) { $result = $accounting->account_desactivate($id); } - + $action = 'update'; if ($result < 0) { setEventMessages($accounting->error, $accounting->errors, 'errors'); @@ -165,6 +165,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_vers if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)"; else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)"; $sql .= " WHERE asy.rowid = " . $pcgver; +$sql .= " AND aa.entity = " . $conf->entity; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); @@ -179,7 +180,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); -} +} $sql .= $db->plimit($limit + 1, $offset); @@ -209,11 +210,11 @@ if ($resql) print ''; print ''; print ''; - + $htmlbuttonadd = '' . $langs->trans("Addanaccount") . ''; - + print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $htmlbuttonadd); - + // Box to select active chart of account print $langs->trans("Selectchartofaccounts") . " : "; print '"; print ''; - print '
'; + print '
'; print '
'; - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print '
'; if ($mesg) { print $mesg; } else { $stringtoshow.= $px1->show(); From f50a6149d56b11ec35fbbb2d9bfba6eb222ea9ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 11:09:03 +0200 Subject: [PATCH 505/609] Look and feel v8 (menu statistics at end) --- htdocs/core/menus/init_menu_auguria.sql | 5 +- htdocs/core/menus/standard/eldy.lib.php | 4 + htdocs/core/modules/modProduct.class.php | 8 +- htdocs/core/modules/modService.class.php | 8 +- htdocs/core/modules/modVariants.class.php | 18 ----- htdocs/install/upgrade2.php | 90 ++++++++++------------- 6 files changed, 55 insertions(+), 78 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index a1ea9088dc7..76973a1571c 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -101,7 +101,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2806__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 7, __ENTITY__); + +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->variants->enabled', __HANDLER__, 'left', 2807__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/variants/list.php', 'VariantAttributes', 1, 'products', '$user->rights->produit->lire', '', 2, 7, __ENTITY__); + +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 8, __ENTITY__); -- Product - Services insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2901__+MAX_llx_menu__, 'products', '', 2900__+MAX_llx_menu__, '/product/card.php?leftmenu=service&action=create&type=1', 'NewService', 1, 'products', '$user->rights->service->creer', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 5463e737282..0ad54a6b372 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1231,6 +1231,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/product/reassortlot.php?type=0", $langs->trans("StocksByLotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire); $newmenu->add("/product/stock/productlot_list.php", $langs->trans("LotSerial"), 1, $user->rights->produit->lire && $user->rights->stock->lire); } + if (! empty($conf->variants->enabled)) + { + $newmenu->add("/variants/list.php", $langs->trans("VariantAttributes"), 1, $user->rights->produit->lire); + } if (! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled) || ! empty($conf->supplier_proposal->enabled)) { $newmenu->add("/product/stats/card.php?id=all&leftmenu=stats&type=0", $langs->trans("Statistics"), 1, $user->rights->produit->lire && $user->rights->propale->lire); diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index f90323cda0e..bfbc28d8321 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -103,28 +103,28 @@ class modProduct extends DolibarrModules $r=0; $this->rights[$r][0] = 31; // id de la permission - $this->rights[$r][1] = 'Lire les produits'; // libelle de la permission + $this->rights[$r][1] = 'Read products'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 32; // id de la permission - $this->rights[$r][1] = 'Creer/modifier les produits'; // libelle de la permission + $this->rights[$r][1] = 'Create/modify products'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; $r++; $this->rights[$r][0] = 34; // id de la permission - $this->rights[$r][1] = 'Supprimer les produits'; // libelle de la permission + $this->rights[$r][1] = 'Delete products'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; $r++; $this->rights[$r][0] = 38; // Must be same permission than in service module - $this->rights[$r][1] = 'Exporter les produits'; + $this->rights[$r][1] = 'Export products'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 20261e98ca6..dc7b6512d51 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -85,28 +85,28 @@ class modService extends DolibarrModules $r=0; $this->rights[$r][0] = 531; // id de la permission - $this->rights[$r][1] = 'Lire les services'; // libelle de la permission + $this->rights[$r][1] = 'Read services'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 532; // id de la permission - $this->rights[$r][1] = 'Creer/modifier les services'; // libelle de la permission + $this->rights[$r][1] = 'Create/modify services'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; $r++; $this->rights[$r][0] = 534; // id de la permission - $this->rights[$r][1] = 'Supprimer les services'; // libelle de la permission + $this->rights[$r][1] = 'Delete les services'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; $r++; $this->rights[$r][0] = 538; // Must be same permission than in product module - $this->rights[$r][1] = 'Exporter les services'; + $this->rights[$r][1] = 'Export services'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; diff --git a/htdocs/core/modules/modVariants.class.php b/htdocs/core/modules/modVariants.class.php index 4160e0e0639..c56f5c0e49a 100644 --- a/htdocs/core/modules/modVariants.class.php +++ b/htdocs/core/modules/modVariants.class.php @@ -110,24 +110,6 @@ class modVariants extends DolibarrModules // Permissions $this->rights = array(); // Permission array used by this module - - // Main menu entries - $this->menu = array( - array( - 'fk_menu' => 'fk_mainmenu=products,fk_leftmenu=product', - 'type' => 'left', - 'titre' => 'VariantAttributes', - 'mainmenu' => 'products', - 'leftmenu' => 'product', - 'url' => '/variants/list.php', - 'langs' => 'products', - 'position' => 100, - 'enabled' => '$conf->product->enabled', - 'perms' => 1, - 'target' => '', - 'user' => 0 - ) - ); // List of menus to add } } diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 92ce07b2559..1a40d2eb9c5 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -405,11 +405,12 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 } } - // Code executed only if migrate is LAST ONE. Must always be done. + // Code executed only if migration is LAST ONE. Must always be done. if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3) { // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) $listofmodule=array( + 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', 'MAIN_MODULE_AGENDA'=>'newboxdefonly', 'MAIN_MODULE_BARCODE'=>'newboxdefonly', 'MAIN_MODULE_CRON'=>'newboxdefonly', @@ -422,17 +423,14 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', + 'MAIN_MODULE_PRINTING'=>'newboxdefonly', 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_SALARIES'=>'newboxdefonly', 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', - 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_PRINTING'=>'newboxdefonly', - 'MAIN_MODULE_SALARIES'=>'newboxdefonly', - - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + 'MAIN_MODULE_VARIANTS'=>'newboxdefonly', + 'MAIN_MODULE_WEBSITE'=>'newboxdefonly', ); migrate_reload_modules($db,$langs,$conf,$listofmodule); @@ -4524,7 +4522,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_API') + elseif ($moduletoreload == 'MAIN_MODULE_API') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; @@ -4534,7 +4532,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_BARCODE') + elseif ($moduletoreload == 'MAIN_MODULE_BARCODE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; @@ -4544,7 +4542,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_CRON') + elseif ($moduletoreload == 'MAIN_MODULE_CRON') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; @@ -4554,7 +4552,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SOCIETE') + elseif ($moduletoreload == 'MAIN_MODULE_SOCIETE') { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; @@ -4564,7 +4562,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 + elseif ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; @@ -4574,7 +4572,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 + elseif ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; @@ -4584,7 +4582,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 + elseif ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; @@ -4594,7 +4592,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 + elseif ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; @@ -4604,7 +4602,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 + elseif ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; @@ -4614,7 +4612,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 + elseif ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; @@ -4624,7 +4622,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; @@ -4634,7 +4632,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; @@ -4644,7 +4642,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 + elseif ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; @@ -4654,7 +4652,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; @@ -4664,7 +4662,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 + elseif ($moduletoreload == 'MAIN_MODULE_SUPPLIERPROPOSAL') // Module after 3.5 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Supplier Proposal module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSupplierProposal.class.php'; @@ -4674,7 +4672,7 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 + elseif ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 { dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; @@ -4684,34 +4682,24 @@ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) $mod->init($reloadmode); } } - if ($moduletoreload == 'MAIN_MODULE_SALARIES') // Permission has changed into 6.0 + else { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Salaries module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSalaries.class.php'; - if ($res) { - $mod=new modSalaries($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); + $tmp = preg_match('/MAIN_MODULE_([a-zA-Z0-9]+)/', $moduletoreload, $reg); + if (! empty($reg[1])) + { + $moduletoreloadshort = ucfirst(strtolower($reg[1])); + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate module ".$moduletoreloadshort); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/mod'.$moduletoreloadshort.'.class.php'; + if ($res) { + $classname = 'mod'.$moduletoreloadshort; + $mod=new $classname($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } } - } - if ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modUser.class.php'; - if ($res) { - $mod=new modUser($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_WEBSITE') // Module added in 7.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Website module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modWebsite.class.php'; - if ($res) { - $mod=new modWebsite($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); + else + { + print "Error, can't find module name"; } } From d975dd507bc64b760d53840224a532b98a77a089 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 11:17:47 +0200 Subject: [PATCH 506/609] Revert "No display object line curreny if not necessary" --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c1cd3cb6bd..4d44a4b6fec 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3370,7 +3370,7 @@ abstract class CommonObject print ''.$langs->trans('PriceUHT').''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''.$langs->trans('PriceUTTC').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''.$langs->trans('TotalTTCShort').' trans('VAT'); ?> trans('PriceUHT'); ?>trans('PriceUHTCurrency'); ?> "> subprice); ?>multicurrency_subprice); ?> trans('Option'); ?> total_ht); ?>multicurrency_total_ht); ?>
'."\n"; @@ -259,7 +260,7 @@ if ($resql) print $searchpicto; print ''; print ''; - + print ''; if (! empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"],"aa.account_number","",$param,'',$sortfield,$sortorder); if (! empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"],"aa.label","",$param,'',$sortfield,$sortorder); @@ -274,14 +275,14 @@ if ($resql) $accountparent = new AccountingAccount($db); $i=0; - while ($i < min($num, $limit)) + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $accountstatic->id = $obj->rowid; $accountstatic->label = $obj->label; $accountstatic->account_number = $obj->account_number; - + print ''; // Account number @@ -310,7 +311,7 @@ if ($resql) $accountparent->id = $obj->rowid2; $accountparent->label = $obj->label2; $accountparent->account_number = $obj->account_number2; - + print "\n"; @@ -371,11 +372,11 @@ if ($resql) } print '' . "\n"; if (! $i) $totalarray['nbfield']++; - + print "\n"; $i++; } - + print "
"; print $accountparent->getNomUrl(1); print "
"; print ""; print ''; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index a3912aebc89..a4718d556f2 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -86,7 +86,7 @@ $tablib[35]= "DictionaryAccountancyJournal"; // Requests to extract data $tabsql=array(); -$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a"; +$tabsql[35]= "SELECT a.rowid as rowid, a.code as code, a.label, a.nature, a.active FROM ".MAIN_DB_PREFIX."accounting_journal as a WHERE a.entity=".$conf->entity; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -102,7 +102,7 @@ $tabfieldvalue[35]= "code,label,nature"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); -$tabfieldinsert[35]= "code,label,nature"; +$tabfieldinsert[35]= "code,label,nature,entity"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index e3e6e9a4f20..3ae53f44fff 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -273,6 +273,7 @@ class FormAccounting extends Form $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity=".$conf->entity; $sql .= " ORDER BY aa.account_number"; dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); From c84f44a508d2a1a5b60c5468fe18c3340b506a19 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 1 May 2018 12:30:22 +0200 Subject: [PATCH 508/609] fix accountanty in multientity --- .../class/accountancycategory.class.php | 16 ++++++++++++---- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 13 +++++++++++-- .../mysql/tables/llx_accounting_journal.key.sql | 2 +- .../tables/llx_c_accounting_category.key.sql | 2 +- .../mysql/tables/llx_c_accounting_category.sql | 1 + 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 0a538f0a6ae..27254ef31d1 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -360,9 +360,11 @@ class AccountancyCategory // extends CommonObject * @return int <0 if KO, 0 if not found, >0 if OK */ public function display($id) { + global $conf; $sql = "SELECT t.rowid, t.account_number, t.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = " . $id; + $sql .= " AND t.entity = " . $conf->entity; $this->lines_display = array(); @@ -400,13 +402,14 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.numero_compte NOT IN ("; $sql .= " SELECT t.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as t"; - $sql .= " WHERE t.fk_accounting_category = " . $id . ")"; + $sql .= " WHERE t.fk_accounting_category = " . $id . " AND t.entity = " . $conf->entity.")"; $sql .= " AND t.numero_compte IN ("; $sql .= " SELECT DISTINCT aa.account_number"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; - $sql .= " AND aa.active = 1)"; + $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = = " . $conf->entity . ")"; $sql .= " GROUP BY t.numero_compte, t.label_operation, t.doc_ref"; $sql .= " ORDER BY t.numero_compte"; @@ -448,6 +451,7 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label"; @@ -492,6 +496,7 @@ class AccountancyCategory // extends CommonObject $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " AND aa.active = 1"; + $sql .= " AND aa.entity = " . $conf->entity; $this->db->begin(); @@ -581,7 +586,7 @@ class AccountancyCategory // extends CommonObject */ public function getCatsCpts() { - global $mysoc; + global $mysoc,$conf; $sql = ""; @@ -595,8 +600,10 @@ class AccountancyCategory // extends CommonObject $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = " . $conf->entity; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = " . $conf->entity; $sql .= " ORDER BY cat.position ASC"; $resql = $this->db->query($sql); @@ -685,7 +692,7 @@ class AccountancyCategory // extends CommonObject */ public function getCats($categorytype=-1) { - global $db, $langs, $user, $mysoc; + global $db, $langs, $user, $mysoc, $conf; if (empty($mysoc->country_id)) { dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); @@ -695,6 +702,7 @@ class AccountancyCategory // extends CommonObject $sql = "SELECT c.rowid, c.code, c.label, c.formula, c.position, c.category_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_accounting_category as c"; $sql .= " WHERE c.active = 1 "; + $sql .= " AND c.entity = " . $conf->entity; if ($categorytype >= 0) $sql.=" AND c.category_type = 1"; $sql .= " AND (c.fk_country = ".$mysoc->country_id." OR c.fk_country = 0)"; $sql .= " ORDER BY c.position ASC"; diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 70cbaeb7e04..9fa2849b757 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -9,8 +9,8 @@ -- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; -- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); -- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To drop an index: -- VMYSQL4.0 DROP INDEX nomindex on llx_table --- To drop an index: -- VPGSQL8.0 DROP INDEX nomindex +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex -- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y -- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y -- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; @@ -441,3 +441,12 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; + +ALTER TABLE llx_c_accounting_category ADD COLUMN entity integer NOT NULL DEFAULT 1 AFTER rowid; +-- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category +-- VPGSQL8.2 DROP INDEX uk_c_accounting_category +ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); +-- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal +-- VPGSQL8.2 DROP INDEX uk_accounting_journal_code +ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); + diff --git a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql index e5083aa83d7..701c39e06a2 100644 --- a/htdocs/install/mysql/tables/llx_accounting_journal.key.sql +++ b/htdocs/install/mysql/tables/llx_accounting_journal.key.sql @@ -17,4 +17,4 @@ -- =========================================================================== -ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code); +ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql index 6b2d520a156..be927f6e761 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.key.sql @@ -17,5 +17,5 @@ -- Table with category for accounting account -- =================================================================== -ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code); +ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); diff --git a/htdocs/install/mysql/tables/llx_c_accounting_category.sql b/htdocs/install/mysql/tables/llx_c_accounting_category.sql index 253ff6aef46..9df9a9d6ab0 100644 --- a/htdocs/install/mysql/tables/llx_c_accounting_category.sql +++ b/htdocs/install/mysql/tables/llx_c_accounting_category.sql @@ -22,6 +22,7 @@ CREATE TABLE llx_c_accounting_category ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, + entity integer NOT NULL DEFAULT 1, code varchar(16) NOT NULL, label varchar(255) NOT NULL, range_account varchar(255) NOT NULL, -- Comment From 8be8249f859d4bf16188fe9e5be7feee71b69c6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 12:40:42 +0200 Subject: [PATCH 509/609] Clean code, fix warnings --- htdocs/core/modules/DolibarrModules.class.php | 14 ++++--------- htdocs/core/modules/modDav.class.php | 14 +------------ .../core/modules/modMultiCurrency.class.php | 15 ------------- htdocs/core/modules/modResource.class.php | 21 +------------------ htdocs/core/modules/modTicketsup.class.php | 14 ------------- 5 files changed, 6 insertions(+), 72 deletions(-) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 7fb9f76119b..70e22bace45 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -158,14 +158,7 @@ class DolibarrModules // Can not be abstract, because we need to insta * // Set this to relative path of js file if module must load a js on all pages * 'js' => '/mymodule/js/mymodule.js', * // Set here all hooks context managed by module - * 'hooks' => array('hookcontext1','hookcontext2'), - * // Set here all workflow context managed by module - * 'workflow' => array( - * 'WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2' = >array( - * 'enabled' => '! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', - * 'picto'=>'yourpicto@mymodule' - * ) - * ) + * 'hooks' => array('hookcontext1','hookcontext2') * ) */ public $module_parts = array(); @@ -2083,7 +2076,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($value)) { // Can defined other parameters - if (is_array($value['data']) && ! empty($value['data'])) + // Example when $key='hooks', then $value is an array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>X) + if (isset($value['data']) && is_array($value['data'])) { $newvalue = json_encode($value['data']); if (isset($value['entity'])) $entity = $value['entity']; @@ -2093,7 +2087,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $newvalue = $value['data']; if (isset($value['entity'])) $entity = $value['entity']; } - else + else // when hook is declared with syntax 'hook'=>array('hookcontext1','hookcontext2',...) { $newvalue = json_encode($value); } diff --git a/htdocs/core/modules/modDav.class.php b/htdocs/core/modules/modDav.class.php index ae71f02753b..77c3f8feef7 100644 --- a/htdocs/core/modules/modDav.class.php +++ b/htdocs/core/modules/modDav.class.php @@ -80,19 +80,7 @@ class modDav extends DolibarrModules // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /dav/core/modules/barcode) // for specific css file (eg: /dav/css/dav.css.php) - $this->module_parts = array( - 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array(), // Set this to relative path of css file if module has its own css file - 'js' => array(), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array() // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - ); + $this->module_parts = array(); // Data directories to create when module is enabled. // Example: this->dirs = array("/dav/temp","/dav/subdir"); diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 7908f203c69..7c87ef35a53 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -74,21 +74,6 @@ class modMultiCurrency extends DolibarrModules // for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /multicurrency/core/modules/barcode) // for specific css file (eg: /multicurrency/css/multicurrency.css.php) - //$this->module_parts = array( - // 'triggers' => 0, // Set this to 1 if module has its own trigger directory (core/triggers) - // 'login' => 0, // Set this to 1 if module has its own login method directory (core/login) - // 'substitutions' => 0, // Set this to 1 if module has its own substitution function file (core/substitutions) - // 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - // 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - // 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - // 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - // 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - // 'css' => array('/multicurrency/css/multicurrency.css.php'), // Set this to relative path of css file if module has its own css file - // 'js' => array('/multicurrency/js/multicurrency.js'), // Set this to relative path of js file if module must load a js on all pages - // 'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module - // 'dir' => array('output' => 'othermodulename'), // To force the default directories names - // 'workflow' => array('WORKFLOW_MODULE1_YOURACTIONTYPE_MODULE2'=>array('enabled'=>'! empty($conf->module1->enabled) && ! empty($conf->module2->enabled)', 'picto'=>'yourpicto@multicurrency')) // Set here all workflow context managed by module - // ); $this->module_parts = array(); // Data directories to create when module is enabled. diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 0cf19ec31e2..15b414947ef 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -79,26 +79,7 @@ class modResource extends DolibarrModules // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable) // for specific path of parts (eg: /resource/core/modules/barcode) // for specific css file (eg: /resource/css/resource.css.php) - $this->module_parts = array( - // Set this to 1 if module has its own trigger directory - //'triggers' => 1, - // Set this to 1 if module has its own login method directory - //'login' => 0, - // Set this to 1 if module has its own substitution function file - //'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory - //'menus' => 0, - // Set this to 1 if module has its own barcode directory - //'barcode' => 0, - // Set this to 1 if module has its own models directory - //'models' => 0, - // Set this to relative path of css if module has its own css file - //'css' => '/resource/css/resource.css.php', - // Set here all hooks context managed by module - // 'hooks' => array('actioncard','actioncommdao','resource_card','element_resource') - // Set here all workflow context managed by module - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) - ); + $this->module_parts = array(); // Data directories to create when module is enabled. // Example: this->dirs = array("/resource/temp"); diff --git a/htdocs/core/modules/modTicketsup.class.php b/htdocs/core/modules/modTicketsup.class.php index 3dcd3a3423f..594835dad4a 100644 --- a/htdocs/core/modules/modTicketsup.class.php +++ b/htdocs/core/modules/modTicketsup.class.php @@ -82,22 +82,8 @@ class modTicketsup extends DolibarrModules $this->module_parts = array( // Set this to 1 if module has its own trigger directory 'triggers' => 1, - // Set this to 1 if module has its own login method directory - //'login' => 0, - // Set this to 1 if module has its own substitution function file - //'substitutions' => 0, - // Set this to 1 if module has its own menus handler directory - //'menus' => 0, - // Set this to 1 if module has its own barcode directory - //'barcode' => 0, // Set this to 1 if module has its own models directory 'models' => 1, - // Set this to relative path of css if module has its own css file - //'css' => '', - // Set here all hooks context managed by module - 'hooks' => array('admin') - // Set here all workflow context managed by module - //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE')) ); // Data directories to create when module is enabled. From 3340598cf8256a74dd9dad0b01646e8ffa4da838 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 14:15:11 +0200 Subject: [PATCH 510/609] FIX Projet is not prefilled when created from overwiew page --- htdocs/commande/card.php | 14 ++++++-------- htdocs/compta/bank/various_payment/card.php | 2 +- htdocs/supplier_proposal/card.php | 11 +++++------ 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 0844facca69..9f55311444b 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -28,9 +28,9 @@ */ /** - * \file htdocs/commande/card.php + * \file htdocs/commande/card.php * \ingroup commande - * \brief Page to show customer order + * \brief Page to show customer order */ require '../main.inc.php'; @@ -76,6 +76,7 @@ $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $lineid = GETPOST('lineid', 'int'); +$projectid = GETPOST('projectid', 'int'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility @@ -228,7 +229,7 @@ if (empty($reshook)) // Link to a project else if ($action == 'classin' && $user->rights->commande->creer) { - $object->setProject(GETPOST('projectid')); + $object->setProject(GETPOST('projectid','int')); } // Add order @@ -259,8 +260,8 @@ if (empty($reshook)) $object->note_private = GETPOST('note_private','none'); $object->note_public = GETPOST('note_public','none'); $object->source = GETPOST('source_id'); - $object->fk_project = GETPOST('projectid'); - $object->ref_client = GETPOST('ref_client'); + $object->fk_project = GETPOST('projectid','int'); + $object->ref_client = GETPOST('ref_client','alpha'); $object->modelpdf = GETPOST('model'); $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); @@ -1389,7 +1390,6 @@ if ($action == 'create' && $user->rights->commande->creer) if ($socid > 0) $res = $soc->fetch($socid); - $projectid = 0; $remise_absolue = 0; $currency_code = $conf->currency; @@ -1486,7 +1486,6 @@ if ($action == 'create' && $user->rights->commande->creer) $remise_percent = $soc->remise_percent; $remise_absolue = 0; $dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:''; - $projectid = 0; if (!empty($conf->multicurrency->enabled) && !empty($soc->multicurrency_code)) $currency_code = $soc->multicurrency_code; @@ -1494,7 +1493,6 @@ if ($action == 'create' && $user->rights->commande->creer) $note_public = $object->getDefaultCreateValueFor('note_public'); } - print '
'; print ''; print ''; diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index b6649250e64..2828963d889 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -349,7 +349,7 @@ if ($action == 'create') print '
'; print ''; print '   '; - print ''; + print ''; print '
'; print '
'; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a5488959016..8c2bfb8090a 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -67,6 +67,7 @@ $action = GETPOST('action', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); +$projectid = GETPOST('projectid', 'int'); $lineid = GETPOST('lineid', 'int'); $contactid = GETPOST('contactid','int'); @@ -265,7 +266,7 @@ if (empty($reshook)) $object->remise_percent = GETPOST('remise_percent'); $object->remise_absolue = GETPOST('remise_absolue'); $object->socid = GETPOST('socid'); - $object->fk_project = GETPOST('projectid'); + $object->fk_project = GETPOST('projectid','int'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note','none'); @@ -283,7 +284,7 @@ if (empty($reshook)) $object->cond_reglement_id = GETPOST('cond_reglement_id'); $object->mode_reglement_id = GETPOST('mode_reglement_id'); $object->fk_account = GETPOST('fk_account', 'int'); - $object->fk_project = GETPOST('projectid'); + $object->fk_project = GETPOST('projectid','int'); $object->modelpdf = GETPOST('model'); $object->author = $user->id; // deprecated $object->note = GETPOST('note','none'); @@ -890,7 +891,7 @@ if (empty($reshook)) // Set project else if ($action == 'classin' && $user->rights->supplier_proposal->creer) { - $object->setProject($_POST['projectid']); + $object->setProject(GETPOST('projectid'),'int'); } // Delai de livraison @@ -1103,9 +1104,7 @@ if ($action == 'create') $formproject = new FormProjets($db); - $projectid = 0; - if ($origin == 'project') - $projectid = ($originid ? $originid : 0); + if ($origin == 'project') $projectid = ($originid ? $originid : 0); print '
' . $langs->trans("Project") . ''; From c3b5664fb51f3573cb8bbb0bd0ab2f47242609e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 16:24:40 +0200 Subject: [PATCH 511/609] Fix sort order of email templates --- htdocs/admin/mails_templates.php | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d282acd3447..4e731021199 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -169,10 +169,6 @@ if ($conf->adherent->enabled) $elementList['member']=$langs->trans('Mai if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject'); $elementList['user']=$langs->trans('MailToUser'); -sort($elementList); -// Add all and none after the sort -$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; -$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; $parameters=array('elementList'=>$elementList); $reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks @@ -182,6 +178,12 @@ if ($reshook == 0) { } } +// Add all and none after the sort +$elementList['all'] ='-- '.$langs->trans("All").' -- ('.$langs->trans('VisibleEverywhere').')'; +$elementList['none']='-- '.$langs->trans("None").' -- ('.$langs->trans('VisibleNowhere').')'; + +asort($elementList); + $id = 25; @@ -211,7 +213,7 @@ if (empty($reshook)) } // Actions add or modify an entry into a dictionary - if (GETPOST('actionadd') || GETPOST('actionmodify')) + if (GETPOST('actionadd','alpha') || GETPOST('actionmodify','alpha')) { $listfield=explode(',', str_replace(' ', '',$tabfield[$id])); $listfieldinsert=explode(',',$tabfieldinsert[$id]); @@ -227,7 +229,7 @@ if (empty($reshook)) if ($value == 'content') continue; if ($value == 'content_lines') continue; - if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; + if (GETPOST('actionmodify','alpha') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { @@ -269,8 +271,8 @@ if (empty($reshook)) if ($value == 'fk_user' && ! ($_POST[$keycode] > 0)) $_POST[$keycode]=''; if ($value == 'private' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='0'; if ($value == 'position' && ! is_numeric($_POST[$keycode])) $_POST[$keycode]='1'; - if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work - elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="null"; + if ($_POST[$keycode] == '' && $keycode != 'langcode') $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } @@ -316,12 +318,16 @@ if (empty($reshook)) if ($field == 'entity') $_POST[$keycode] = $conf->entity; if ($i) $sql.=","; $sql.= $field."="; - if ($_POST[$keycode] == '' || ($keycode == 'langcode' && empty($_POST[$keycode]))) $sql.="null"; // For vat, we want/accept code = '' + +// print $keycode.' - '.$_POST[$keycode].'
'; + if ($_POST[$keycode] == '' || ($keycode != 'langcode' && $keycode != 'private' && empty($_POST[$keycode]))) $sql.="null"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($_POST[$keycode] == '0' && $keycode == 'langcode') $sql.="''"; // lang must be '' if not defined so the unique key that include lang will work + elseif ($keycode == 'private') $sql.=((int) $_POST[$keycode]); // private must be 0 or 1 else $sql.="'".$db->escape($_POST[$keycode])."'"; $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - +//print $sql;exit; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); From 14fd740b04a08e115a1972604d0cb3f8ac3fe7e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 16:25:06 +0200 Subject: [PATCH 512/609] Fix lang must be '' and not empty in email_template --- htdocs/accountancy/admin/accountmodel.php | 23 +++---------------- .../install/mysql/migration/7.0.0-8.0.0.sql | 1 + 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index db9725ce9f6..f8a31b239bb 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -617,25 +617,13 @@ if ($id) $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error=$hookmanager->error; $errors=$hookmanager->errors; - if ($id == 3) unset($fieldlist[2]); - if (empty($reshook)) { - if ($tabname[$id] == MAIN_DB_PREFIX.'c_email_templates' && $action == 'edit') - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'hide'); - } - else - { - fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); - } + fieldListAccountModel($fieldlist,$obj,$tabname[$id],'add'); } print '
'; - if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit') - { - print ''; - } + print ''; print '
'; // To create an artificial CR for the current tr we are on - } - else print ''; + print ''; if ($context != 'hide') { //print ''; $okforextended=true; - if ($tabname == MAIN_DB_PREFIX.'c_email_templates' && empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $okforextended=false; $doleditor = new DolEditor($fieldlist[$field], (! empty($obj->{$fieldlist[$field]})?$obj->{$fieldlist[$field]}:''), '', 140, 'dolibarr_mailings', 'In', 0, false, $okforextended, ROWS_5, '90%'); print $doleditor->Create(1); } diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 70cbaeb7e04..287c3bb6aaa 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -441,3 +441,4 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; +update llx_c_email_templates set lang = '' where lang IS NULL; From cb76d2ce0f8d3c4dcd43ecd0b7b217080312db3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 18:58:19 +0200 Subject: [PATCH 513/609] Better logging --- htdocs/core/class/menubase.class.php | 3 ++ htdocs/core/modules/DolibarrModules.class.php | 28 +++++++++++-------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index a96f62e8cbc..c123356f9ab 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -124,6 +124,9 @@ class Menubase else dol_print_error($this->db); } + // TODO + // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql + // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu("; $sql.= "menu_handler,"; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 70e22bace45..a5211b11b5e 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -953,7 +953,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$entity.")"; - dol_syslog(get_class($this)."::_active", LOG_DEBUG); + dol_syslog(get_class($this)."::_active delect activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -965,7 +965,7 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", 0, ".$entity; $sql.= ", '".$this->db->escape($note)."')"; - dol_syslog(get_class($this)."::_active", LOG_DEBUG); + dol_syslog(get_class($this)."::_active insert activation constant", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1133,6 +1133,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($this->boxes)) { + dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); + $pos_name = InfoBox::getListOfPagesForBoxes(); foreach ($this->boxes as $key => $value) @@ -1150,7 +1152,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= " AND entity = ".$conf->entity; if ($note) $sql.=" AND note ='".$this->db->escape($note)."'"; - dol_syslog(get_class($this)."::insert_boxes", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1304,6 +1305,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (is_array($this->cronjobs)) { + dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); + foreach ($this->cronjobs as $key => $value) { $entity = isset($this->cronjobs[$key]['entity'])?$this->cronjobs[$key]['entity']:$conf->entity; @@ -1332,7 +1335,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $now=dol_now(); - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $result=$this->db->query($sql); if ($result) { @@ -1369,7 +1371,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= "'".$this->db->escape($test)."'"; $sql.= ")"; - dol_syslog(get_class($this)."::insert_cronjobs", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $err++; @@ -1466,6 +1467,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (! empty($this->tabs)) { + dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); + $i=0; foreach ($this->tabs as $key => $value) { @@ -1499,7 +1502,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", ".$entity; $sql.= ")"; - dol_syslog(get_class($this)."::insert_tabs", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { @@ -1532,6 +1534,8 @@ class DolibarrModules // Can not be abstract, because we need to insta if (empty($this->const)) return 0; + dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); + foreach ($this->const as $key => $value) { $name = $this->const[$key][0]; @@ -1567,8 +1571,6 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ",".$entity; $sql.= ")"; - - dol_syslog(get_class($this)."::insert_const", LOG_DEBUG); if (! $this->db->query($sql) ) { $err++; @@ -1638,13 +1640,14 @@ class DolibarrModules // Can not be abstract, because we need to insta $err=0; $entity=(! empty($force_entity) ? $force_entity : $conf->entity); + dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); + // Test if module is activated $sql_del = "SELECT ".$this->db->decrypt('value')." as value"; $sql_del.= " FROM ".MAIN_DB_PREFIX."const"; $sql_del.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql_del.= " AND entity IN (0,".$entity.")"; - dol_syslog(get_class($this)."::insert_permissions", LOG_DEBUG); $resql=$this->db->query($sql_del); if ($resql) @@ -1802,6 +1805,8 @@ class DolibarrModules // Can not be abstract, because we need to insta require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php'; + dol_syslog(get_class($this)."::insert_menus", LOG_DEBUG); + $err=0; $this->db->begin(); @@ -2110,7 +2115,8 @@ class DolibarrModules // Can not be abstract, because we need to insta $sql.= ", ".$entity; $sql.= ")"; - dol_syslog(get_class($this)."::insert_const_".$key."", LOG_DEBUG); + dol_syslog(get_class($this)."::insert_module_parts for key=".$this->const_name."_".strtoupper($key), LOG_DEBUG); + $resql=$this->db->query($sql,1); if (! $resql) { @@ -2121,7 +2127,7 @@ class DolibarrModules // Can not be abstract, because we need to insta } else { - dol_syslog(get_class($this)."::insert_const_".$key." Record already exists.", LOG_WARNING); + dol_syslog(get_class($this)."::insert_module_parts for ".$this->const_name."_".strtoupper($key)." Record already exists.", LOG_WARNING); } } } From 5e14b165c93c1429e0bf30c988f901ad018382d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 19:51:53 +0200 Subject: [PATCH 514/609] NEW Show last result code of cron jobs in error in red --- htdocs/cron/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 81e9d57c03b..61b31d37131 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -508,7 +508,10 @@ if ($num > 0) print ''; - if ($obj->lastresult != '') {print dol_trunc($obj->lastresult);} + if ($obj->lastresult != '') { + if (empty($obj->lastresult)) print $obj->lastresult; + else print ''.dol_trunc($obj->lastresult).''; + } print ''; From dc9892f803a08e96156c6bea1ee86f183859aca9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:17:03 +0200 Subject: [PATCH 515/609] Fix bad log --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 2094cd10c5c..2e345a48276 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6181,7 +6181,7 @@ function complete_substitutions_array(&$substitutionarray, $outputlangs, $object { $module=$reg[1]; - dol_syslog("Library functions_".$substitfile['name']." found into ".$dir); + dol_syslog("Library ".$substitfile['name']." found into ".$dir); // Include the user's functions file require_once $dir.$substitfile['name']; // Call the user's function, and only if it is defined From 124abd39b6355b8aea21bae426172ede290e31e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:31:57 +0200 Subject: [PATCH 516/609] Code comment --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 28c6f86769f..c275dd6cda3 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -105,7 +105,7 @@ function dol_decode($chain, $key='1') * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO then md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @getRandomPassword */ From 2f2d17926ddf917d860cac85f5ac5dc2e7b6393d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 1 May 2018 20:52:25 +0200 Subject: [PATCH 517/609] Sort list --- htdocs/admin/security.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9627164f534..38cd2d12c1b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -127,7 +127,7 @@ if ($action == 'activate_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_set_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED", "1"); header("Location: security.php"); @@ -135,7 +135,7 @@ if ($action == 'activate_encryptdbpassconf') } else { - setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); + setEventMessages($langs->trans('InstrucToEncodePass',dol_encode($dolibarr_main_db_pass)), null, 'warnings'); } } else if ($action == 'disable_encryptdbpassconf') @@ -144,7 +144,7 @@ else if ($action == 'disable_encryptdbpassconf') if ($result > 0) { sleep(3); // Don't know why but we need to wait file is completely saved before making the reload. Even with flush and clearstatcache, we need to wait. - + // database value not required //dolibarr_del_const($db, "MAIN_DATABASE_PWD_CONFIG_ENCRYPTED",$conf->entity); header("Location: security.php"); @@ -233,6 +233,7 @@ if (is_resource($handle)) } closedir($handle); } +asort($arrayhandler); print ''; print ''; @@ -299,42 +300,42 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso"){ print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print ''; print '"; print ''; print ''; - + print '
'.$langs->trans("PasswordPatternDesc").'
' . $langs->trans("MinLength")."
' . $langs->trans("NbMajMin")."
' . $langs->trans("NbNumMin")."
' . $langs->trans("NbSpeMin")."
' . $langs->trans("NbIteConsecutive")."
' . $langs->trans("NoAmbiCaracAutoGeneration")." '.($tabConf[5] ? $langs->trans("Activated") : $langs->trans("Disabled")).'
'; print '
'; From 42dee75ba3dc3a5ed83987f880c4c3b0e306755e Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 1 May 2018 23:32:35 +0100 Subject: [PATCH 518/609] Add: Overload styles files from a current folder of module & theme My goal is to overload css files only for the current module and without changing the source code of the module but just by adding a folder style in the module folder. Then just place the css files to overload in this folder they will be automatically added in the head. The same method is applied to the current theme. To test, for example, place a custom.css file in the societe/style/custom.css folder and check the head of a company module page. --- htdocs/main.inc.php | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f1d6487d5de..19e74d1ddc2 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1206,6 +1206,54 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; + //Overload css files to the current theme + // Check if the /theme/nameoftheme/style folder exists and Add the contains css files to head + if (file_exists(dirname(dol_buildpath($conf->css, 0))."/style")) + { + //browse the css dir and add the contains css files + if ($handle = opendir(dirname(dol_buildpath($conf->css, 0))."/style")) + { + while (false !== ($entry = readdir($handle))) + { + list($filename, $extension) = explode(".", $entry); + if ($entry !== '.' && $entry !== '..' && $extension == 'css') + { + print ''."\n"; + } + } + closedir($handle); + } + } + + //Overload css files to the current module + // Check if the /module/style folder exists and Add the contains css files to head + $cur_modulepart = explode("/",$_SERVER["PHP_SELF"]); + if(is_array($cur_modulepart) && count($cur_modulepart)>0) + { + foreach($conf->modules as $module) + { + if(in_array($module, $cur_modulepart)) + { + if (file_exists(getcwd().DIRECTORY_SEPARATOR."style")) + { + //browse the style dir and add the contains css files + if ($handle = opendir(getcwd().DIRECTORY_SEPARATOR."style")) + { + while (false !== ($entry = readdir($handle))) + { + list($filename, $extension) = explode(".", $entry); + if ($entry !== '.' && $entry !== '..' && $extension == 'css') + { + print ''."\n"; + } + } + closedir($handle); + } + } + } + } + } + // CSS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['css'])) { From 886ad9d4b644b295bbc673b98ec437d84f5945f5 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 May 2018 08:45:18 +0200 Subject: [PATCH 519/609] check eldy message --- htdocs/accountancy/admin/account.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 9b1b6746861..1c845716e6b 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -160,12 +160,11 @@ $pcgver = $conf->global->CHARTOFACCOUNTS; $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = " . $conf->entity; // Dirty hack wainting that foreign key account_parent is an integer to be compared correctly with rowid -if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER)"; -else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED)"; +if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS INTEGER) AND a2.entity = " . $conf->entity; +else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = CAST(aa.account_parent AS UNSIGNED) AND a2.entity = " . $conf->entity; $sql .= " WHERE asy.rowid = " . $pcgver; -$sql .= " AND aa.entity = " . $conf->entity; if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); From 12440e6a7e62087adb32a07b17abf9f64ac9f018 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Wed, 2 May 2018 11:30:35 +0200 Subject: [PATCH 520/609] Do not display multicurrency cols if currency of object is same as main currency --- htdocs/core/class/commonobject.class.php | 4 ++-- htdocs/core/tpl/objectline_create.tpl.php | 6 +++--- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++-- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 046097eec86..4c236324373 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3677,7 +3677,7 @@ abstract class CommonObject print '
'.$langs->trans('PriceUHT').''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''.$langs->trans('PriceUHTCurrency', $this->multicurrency_code).''.$langs->trans('PriceUTTC').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''.$langs->trans('TotalHTShortCurrency', $this->multicurrency_code).''.$langs->trans('TotalTTCShort').' trans('VAT'); ?> trans('PriceUHT'); ?>trans('PriceUHTCurrency'); ?> "> subprice); ?>multicurrency_subprice); ?> trans('Option'); ?> total_ht); ?>multicurrency_total_ht); ?> '.price($obj->total_ttc).'
'.price($obj->total_ht).'
'.price($obj->total_ttc).'
'.price($obj->total_ttc).'
'.price($obj->total_ht).'
'.price($obj->total_ttc).'
'; print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.price($obj->total_ht).''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut,3).'
'; print dol_print_date($db->jdate($obj->dp),'day').''.price($obj->total_ttc).''.price($obj->total_ht).''.price($obj->total_ttc).''.$orderstatic->LibStatut($obj->fk_statut,$obj->billed,3).'
'; print ''; print ''; @@ -168,7 +166,6 @@ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); print ''; print '\n"; $notificationtrigger=new InterfaceNotification($db); $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents(); -$var=true; foreach($listofnotifiedevents as $notifiedevent) { diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php index 6666cdec47b..2750834bac6 100644 --- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php +++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php @@ -23,7 +23,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; /** @@ -56,6 +55,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; $b=new BlockedLog($this->db); // Tracked events diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 8cfece7dc89..7677c1743a8 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -24,8 +24,6 @@ */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; -require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; /** @@ -60,6 +58,9 @@ class InterfaceLdapsynchro extends DolibarrTriggers return 0; } + require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"; + require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; + $result=0; // Users diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index ecf57316c89..44a6645a6d7 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -22,8 +22,6 @@ * \brief File to manage triggers Mailman and Spip */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; -require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; /** @@ -51,6 +49,9 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers { if (empty($conf->mailmanspip->enabled)) return 0; // Module not active, we do nothing + require_once DOL_DOCUMENT_ROOT."/mailmanspip/class/mailmanspip.class.php"; + require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php"; + if ($action == 'CATEGORY_LINK') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index cef63a474e6..7d4680be3f9 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -28,7 +28,6 @@ * - Le nom de la propriete name doit etre Mytrigger */ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php'; -$path=dirname(__FILE__).'/'; /** @@ -122,7 +121,7 @@ class InterfaceStripe $ok = 0; - include_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; + require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php'; $stripe = new Stripe($db); if (empty($conf->stripe->enabled)) return 0; From 3657857d2160ba759f0f2429aa5e119d122b3026 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 May 2018 19:29:18 +0200 Subject: [PATCH 529/609] fix project and task visibility same as list --- htdocs/projet/activity/perday.php | 3 ++- htdocs/projet/activity/perweek.php | 3 ++- htdocs/projet/class/project.class.php | 19 ++++++++------ htdocs/projet/class/task.class.php | 38 ++++++++++++++------------- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 36b55ea79ff..b4329ac9237 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -49,7 +49,8 @@ $projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; // Security check $socid=0; -if ($user->societe_id > 0) $socid=$user->societe_id; +// For external user, no check is done on company because readability is managed by public status of project and assignement. +//if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 438d71cbdba..591f8b3ab6f 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -50,7 +50,8 @@ $projectid=isset($_GET["id"])?$_GET["id"]:$_POST["projectid"]; // Security check $socid=0; -if ($user->societe_id > 0) $socid=$user->societe_id; +// For external user, no check is done on company because readability is managed by public status of project and assignement. +// if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); $now=dol_now(); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index ea304eaabe0..551bdcb9d5f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1662,23 +1662,26 @@ class Project extends CommonObject { global $conf, $langs; - $mine=0; $socid=$user->societe_id; - - $projectsListId = $this->getProjectsAuthorizedForUser($user,$mine?$mine:($user->rights->projet->all->lire?2:0),1,$socid); + // For external user, no check is done on company because readability is managed by public status of project and assignement. + //$socid=$user->societe_id; + if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1,$socid); + $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql.= ")"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + // For external user, no check is done on company permission because readability is managed by public status of project and assignement. + //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql.= " WHERE p.fk_statut = 1"; $sql.= " AND p.entity IN (".getEntity('project', 0).')'; - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - + // For external user, no check is done on company permission because readability is managed by public status of project and assignement. + //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + + //print $sql; $resql=$this->db->query($sql); if ($resql) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 1c8b1466483..6beafe71a25 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -1701,29 +1701,31 @@ class Task extends CommonObject { global $conf, $langs; - $mine=0; $socid=$user->societe_id; - + // For external user, no check is done on company because readability is managed by public status of project and assignement. + //$socid=$user->societe_id; + $projectstatic = new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid); - + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1,$socid); + // List of tasks (does not care about permissions. Filtering will be done later) $sql = "SELECT p.rowid as projectid, p.fk_statut as projectstatus,"; $sql.= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; $sql.= " t.dateo as date_start, t.datee as datee"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; - $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; - $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; - $sql.= " AND p.fk_statut = 1"; - $sql.= " AND t.fk_projet = p.rowid"; - $sql.= " AND t.progress < 100"; // tasks to do - if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; - // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser - //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; - //print $sql; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; + $sql.= ", ".MAIN_DB_PREFIX."projet_task as t"; + $sql.= " WHERE p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND p.fk_statut = 1"; + $sql.= " AND t.fk_projet = p.rowid"; + if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; + // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser + // if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND ((s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id.") OR (s.rowid IS NULL))"; + + //print $sql; $resql=$this->db->query($sql); if ($resql) { From 46e94af5949c233dc165b20af77048d0f9852482 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 2 May 2018 19:46:04 +0200 Subject: [PATCH 530/609] fix taskid --- htdocs/projet/tasks/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 3d239921c60..c3f1da54a16 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -756,7 +756,7 @@ while ($i < min($num,$limit)) $showlineingray=0;$showproject=1; print ''; print ''; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/livraison/doc/"); @@ -452,7 +448,6 @@ print ''; print ''; print ''; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -460,7 +455,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 7abb16a0729..3aa3b3364c0 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -27,8 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; -$langs->load("admin"); -$langs->load("mails"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "mails")); if (!$user->admin) accessforbidden(); @@ -105,29 +105,24 @@ print ''; print ''; print ''; -$var=true; - print '
'.$langs->trans("Parameter").'
'; -$var=true; $i=0; foreach($listofnotifiedevents as $notifiedevent) { @@ -212,7 +209,6 @@ print "
'; if ($showlineingray) print ''; - else print ''; + else print ''; if ($obj->duration_effective) print convertSecondToTime($obj->duration_effective,$timespentoutputformat); else print '--:--'; if ($showlineingray) print ''; From 9e18c95a3f9547bdfa400fcf0be11df8cb0391e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 May 2018 19:54:07 +0200 Subject: [PATCH 531/609] Fix migration script --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index cf99009100e..3ca87e97053 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -442,11 +442,11 @@ ALTER TABLE llx_extrafields MODIFY COLUMN list VARCHAR(128); UPDATE llx_rights_def set module = 'asset' where module = 'assets'; ALTER TABLE llx_c_accounting_category ADD COLUMN entity integer NOT NULL DEFAULT 1 AFTER rowid; --- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category --- VPGSQL8.2 DROP INDEX uk_c_accounting_category +-- VMYSQL4.1 DROP INDEX uk_c_accounting_category on llx_c_accounting_category; +-- VPGSQL8.2 DROP INDEX uk_c_accounting_category; ALTER TABLE llx_c_accounting_category ADD UNIQUE INDEX uk_c_accounting_category(code,entity); --- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal --- VPGSQL8.2 DROP INDEX uk_accounting_journal_code +-- VMYSQL4.1 DROP INDEX uk_accounting_journal_code on llx_accounting_journal; +-- VPGSQL8.2 DROP INDEX uk_accounting_journal_code; ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code (code,entity); UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; From db76fd7895233bb13e1996fd8b800cf1048d9dd5 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 2 May 2018 22:33:23 +0200 Subject: [PATCH 532/609] Fix delete all product variants of a parent product User object missing --- htdocs/product/class/product.class.php | 2 +- htdocs/variants/class/ProductCombination.class.php | 9 +++++---- htdocs/variants/generator.php | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e36d5970e8f..e989b0eb206 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1116,7 +1116,7 @@ class Product extends CommonObject //If it is a parent product, then we remove the association with child products $prodcomb = new ProductCombination($this->db); - if ($prodcomb->deleteByFkProductParent($id) < 0) { + if ($prodcomb->deleteByFkProductParent($user, $id) < 0) { $error++; $this->errors[] = 'Error deleting combinations'; } diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 4f647aa2cb3..92bba2f70f8 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -275,10 +275,11 @@ class ProductCombination /** * Deletes all product combinations of a parent product * - * @param int $fk_product_parent Rowid of parent product + * @param User $user Object user + * @param int $fk_product_parent Rowid of parent product * @return int <0 KO >0 OK */ - public function deleteByFkProductParent($fk_product_parent) + public function deleteByFkProductParent($user, $fk_product_parent) { $this->db->begin(); @@ -289,11 +290,11 @@ class ProductCombination $res = $prodstatic->fetch($prodcomb->fk_product_child); if ($res > 0) { - $res = $prodcomb->delete(); + $res = $prodcomb->delete($user); } if ($res > 0 && !$prodstatic->isObjectUsed($prodstatic->id)) { - $res = $prodstatic->delete(); + $res = $prodstatic->delete($user); } if ($res < 0) { diff --git a/htdocs/variants/generator.php b/htdocs/variants/generator.php index d4162899874..4daa2d8f45a 100644 --- a/htdocs/variants/generator.php +++ b/htdocs/variants/generator.php @@ -95,7 +95,7 @@ if ($_POST) { $delete_prev_comb_res = 1; if (!$donotremove) { - $delete_prev_comb_res = $combination->deleteByFkProductParent($id); + $delete_prev_comb_res = $combination->deleteByFkProductParent($user, $id); } //Current combinations will be deleted From bca8d0844e97765139ad0babfcd7f033d4e06f03 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Thu, 3 May 2018 00:38:38 +0100 Subject: [PATCH 533/609] Prepare the adding pdf models to the stock module --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 3ca87e97053..51b83612983 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -451,3 +451,7 @@ ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code ( UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; +-- Warehouse +ALTER TABLE `llx_entrepot` ADD `model_pdf` VARCHAR(255) AFTER `fk_user_author`; +ALTER TABLE `llx_stock_mouvement` ADD `model_pdf` VARCHAR(255) AFTER `origintype`; + From 2cf1aa967c5a327f4968a07b5620ad999c19ad98 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Thu, 3 May 2018 01:01:05 +0100 Subject: [PATCH 534/609] Add warehouse models pdf --- htdocs/core/modules/modStock.class.php | 83 +- .../doc/doc_generic_stock_odt.modules.php | 503 +++++++ .../stock/doc/pdf_standard.modules.php | 1158 ++++++++++++++++ .../stock/doc/pdf_stdmouvement.modules.php | 1159 +++++++++++++++++ .../modules/stock/modules_stock.class.php | 90 ++ htdocs/core/modules/stock/modules_stock.php | 52 + 6 files changed, 3041 insertions(+), 4 deletions(-) create mode 100644 htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php create mode 100644 htdocs/core/modules/stock/doc/pdf_standard.modules.php create mode 100644 htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php create mode 100644 htdocs/core/modules/stock/modules_stock.class.php create mode 100644 htdocs/core/modules/stock/modules_stock.php diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ca518ed8851..55c0bfe6410 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -60,7 +60,7 @@ class modStock extends DolibarrModules $this->picto='stock'; // Data directories to create when module is enabled - $this->dirs = array(); + $this->dirs = array("/stock/temp"); $this->config_page_url = array("stock.php"); @@ -70,9 +70,38 @@ class modStock extends DolibarrModules $this->langfiles = array("stocks"); // Constants - $this->const = array( - 0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1) - ); + $this->const = array(); + $r=0; + + $this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1); + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "Standard"; + $this->const[$r][3] = 'Name of PDF model of stock'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "StdMouvement"; + $this->const[$r][3] = 'Name of PDF model of stock mouvement'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; // Boxes $this->boxes = array(); @@ -266,4 +295,50 @@ class modStock extends DolibarrModules ); } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + global $conf,$langs; + + // Permissions + $this->remove($options); + + //ODT template + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/stock'; + $dest=$dirodt.'/template_stock.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + $sql = array(); + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")", + ); + + return $this->_init($sql,$options); + } } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php new file mode 100644 index 00000000000..0cadf3362d4 --- /dev/null +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -0,0 +1,503 @@ + + * Copyright (C) 2012 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 +* 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 . +* or see http://www.gnu.org/ +*/ + +/** + * \file htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php + * \ingroup societe + * \brief File of class to build ODT documents for stocks/services + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/stock/class/stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class doc_generic_stock_odt extends ModelePDFStock +{ + var $emetteur; // Objet societe qui emet + + var $phpmin = array(5,2,0); // Minimum version of PHP required by module + var $version = 'dolibarr'; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "ODT templates"; + $this->description = $langs->trans("DocumentModelOdt"); + $this->scandir = 'STOCK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + + // Dimension page pour format A4 + $this->type = 'odt'; + $this->page_largeur = 0; + $this->page_hauteur = 0; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=0; + $this->marge_droite=0; + $this->marge_haute=0; + $this->marge_basse=0; + + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva STOCK_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + } + + + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + function info($langs) + { + global $conf,$langs; + + $langs->load("companies"); + $langs->load("errors"); + + $form = new Form($this->db); + + $texte = $this->description.".
\n"; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) + { + $texte.= ''; + $texte.= ''; + $texte.= ''; + } + $texte.= ''; + + // List of directories area + $texte.= ''; + + $texte.= ''; + $texte.= ''; + + $texte.= '
'; + $texttitle=$langs->trans("ListOfDirectories"); + $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->STOCK_ADDON_PDF_ODT_PATH))); + $listoffiles=array(); + foreach($listofdir as $key=>$tmpdir) + { + $tmpdir=trim($tmpdir); + $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir); + if (! $tmpdir) { + unset($listofdir[$key]); continue; + } + if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); + else + { + $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); + } + } + $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + // Add list of substitution keys + $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + + $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1); + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + $texte.= ''; + $texte.= '
'; + + // Scan directories + if (count($listofdir)) + { + $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + + /*if ($conf->global->MAIN_STOCK_CHOOSE_ODT_DOCUMENT > 0) + { + // Model for creation + $liste=ModelePDFStock::liste_modeles($this->db); + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '"; + + $texte.= ''; + $texte.= ''; + $texte.= '"; + $texte.= ''; + + $texte.= ''; + $texte.= '"; + $texte.= '
'.$langs->trans("DefaultModelPropalCreate").''; + $texte.= $form->selectarray('value2',$liste,$conf->global->STOCK_ADDON_PDF_ODT_DEFAULT); + $texte.= "
'.$langs->trans("DefaultModelPropalToBill").''; + $texte.= $form->selectarray('value3',$liste,$conf->global->STOCK_ADDON_PDF_ODT_TOBILL); + $texte.= "
'.$langs->trans("DefaultModelPropalClosed").''; + $texte.= $form->selectarray('value4',$liste,$conf->global->STOCK_ADDON_PDF_ODT_CLOSED); + $texte.= "
'; + }*/ + } + + $texte.= '
'; + $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte.= '
'; + $texte.= ''; + + return $texte; + } + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Stock $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $stock,$langs,$conf,$mysoc,$hookmanager,$user; + + if (empty($srctemplatepath)) + { + dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING); + return -1; + } + + // Add odtgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('odtgeneration')); + global $action; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $sav_charset_output=$outputlangs->charset_output; + $outputlangs->charset_output='UTF-8'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + if ($conf->produit->dir_output) + { + // If $object is id instead of object + if (! is_object($object)) + { + $id = $object; + $object = new Stock($this->db); + $result=$object->fetch($id); + if ($result < 0) + { + dol_print_error($this->db,$object->error); + return -1; + } + } + $stockFournisseur = new StockFournisseur($this->db); + $supplierprices = $stockFournisseur->list_stock_fournisseur_price($object->id); + $object->supplierprices = $supplierprices; + + $dir = $conf->produit->dir_output; + $objectref = dol_sanitizeFileName($object->ref); + if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; + $file = $dir . "/" . $objectref . ".odt"; + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + //print "srctemplatepath=".$srctemplatepath; // Src filename + $newfile=basename($srctemplatepath); + $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile); + $newfiletmp=preg_replace('/template_/i','',$newfiletmp); + $newfiletmp=preg_replace('/modele_/i','',$newfiletmp); + + $newfiletmp=$objectref.'_'.$newfiletmp; + + // Get extension (ods or odt) + $newfileformat=substr($newfile, strrpos($newfile, '.')+1); + if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format=$conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format='%Y%m%d%H%M%S'; + $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; + } + else + { + $filename=$newfiletmp.'.'.$newfileformat; + } + $file=$dir.'/'.$filename; + //print "newdir=".$dir; + //print "newfile=".$newfile; + //print "file=".$file; + //print "conf->produit->dir_temp=".$conf->produit->dir_temp; + + dol_mkdir($conf->produit->dir_temp); + + + // If CUSTOMER contact defined on stock, we use it + $usecontact=false; + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); + if (count($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + + // Recipient name + if (! empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { + $socobject=$object->thirdparty; + } + // Make substitution + $substitutionarray=array( + '__FROM_NAME__' => $this->emetteur->name, + '__FROM_EMAIL__' => $this->emetteur->email, + '__TOTAL_TTC__' => $object->total_ttc, + '__TOTAL_HT__' => $object->total_ht, + '__TOTAL_VAT__' => $object->total_vat + ); + complete_substitutions_array($substitutionarray, $langs, $object); + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + // Line of free text + $newfreetext=''; + $paramfreetext='stock_FREE_TEXT'; + if (! empty($conf->global->$paramfreetext)) + { + $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); + } + + // Open and load template + require_once ODTPHP_PATH.'odf.php'; + try { + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->produit->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' + ) + ); + } + catch(Exception $e) + { + $this->error=$e->getMessage(); + return -1; + } + // After construction $odfHandler->contentXml contains content and + // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by + // [!-- BEGIN lines --]*[!-- END lines --] + //print html_entity_decode($odfHandler->__toString()); + //print exit; + + $object->fetch_optionals(); + + // Make substitutions into odt of freetext + try { + $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + + // Define substitution array + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + //$array_objet=$this->get_substitutionarray_object($object,$outputlangs); + $array_user=$this->get_substitutionarray_user($user,$outputlangs); + $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); + $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs); + $array_other=$this->get_substitutionarray_other($outputlangs); + // retrieve contact information for use in stock as contact_xxx tags + $array_thirdparty_contact = array(); + if ($usecontact) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); + + $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_other,$array_thirdparty_contact); + complete_substitutions_array($tmparray, $outputlangs, $object); + + // Call the ODTSubstitution hook + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); + $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + foreach($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/',$key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + } + catch(OdfException $e) + { + } + } + // Replace tags of lines + try + { + $listlines = $odfHandler->setSegment('supplierprices'); + if(!empty($object->supplierprices)){ + foreach ($object->supplierprices as $supplierprice) + { + $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); + complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); + // Call the ODTSubstitutionLine hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice); + $reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + foreach($array_lines as $key => $val) + { + try + { + $listlines->setVars($key, $val, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + catch(SegmentException $e) + { + } + } + $listlines->merge(); + } + } + $odfHandler->mergeSegment($listlines); + } + catch(OdfException $e) + { + $this->error=$e->getMessage(); + dol_syslog($this->error, LOG_WARNING); + return -1; + } + + // Replace labels translated + $tmparray=$outputlangs->get_translations_for_substitutions(); + foreach($tmparray as $key=>$value) + { + try { + $odfHandler->setVars($key, $value, true, 'UTF-8'); + } + catch(OdfException $e) + { + } + } + + // Call the beforeODTSave hook + $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + // Write new file + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { + try { + $odfHandler->exportAsAttachedPDF($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + return -1; + } + } + else { + try { + $odfHandler->saveToDisk($file); + }catch (Exception $e){ + $this->error=$e->getMessage(); + return -1; + } + } + + $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $odfHandler=null; // Destroy object + + $this->result = array('fullpath'=>$file); + + return 1; // Success + } + else + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + return -1; + } + +} + diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php new file mode 100644 index 00000000000..5825bd693f5 --- /dev/null +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -0,0 +1,1158 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/stock/doc/pdf_standard.modules.php + * \ingroup societe + * \brief File of class to build PDF documents for stocks/services + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class pdf_standard extends ModelePDFStock +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.3 = array(5, 3) + */ + public $phpmin = array(5, 2); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + public $page_largeur; + public $page_hauteur; + public $format; + public $marge_gauche; + public $marge_droite; + public $marge_haute; + public $marge_basse; + + public $emetteur; // Objet societe qui emet + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "standard"; + $this->description = $langs->trans("DocumentModelStandardPDF"); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo + $this->option_codestockservice = 0; // Affiche code stock-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_freetext = 0; // Support add of a personalised text + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Define position of columns + $this->wref = 15; + $this->posxdesc=$this->marge_gauche+1; + $this->posxlabel=$this->posxdesc+$this->wref; + $this->posxtva=80; + $this->posxqty=95; + $this->posxup=115; + $this->posxunit=135; + $this->posxdiscount=155; + $this->postotalht=175; + + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpicture-=20; + $this->posxtva-=20; + $this->posxup-=20; + $this->posxqty-=20; + $this->posxunit-=20; + $this->posxdiscount-=20; + $this->postotalht-=20; + } + $this->tva=array(); + $this->localtax1=array(); + $this->localtax2=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; + } + + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Stock $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $user,$langs,$conf,$mysoc,$db,$hookmanager; + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("stocks"); + $outputlangs->load("orders"); + $outputlangs->load("deliveries"); + + $nblignes = count($object->lines); + + if ($conf->stock->dir_output) + { + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->stock->dir_output; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->stock->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + + $stockFournisseur = new ProductFournisseur($this->db); + $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id); + $object->supplierprices = $supplierprices; + + $productstatic=new Product($db); + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + // Create pdf instance + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf->SetAutoPageBreak(1,0); + + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Stock")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle)); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 42; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_height = 130; + $tab_height_newpage = 150; + + /* ************************************************************************** */ + /* */ + /* Affichage de la liste des produits de l'entrepot */ + /* */ + /* ************************************************************************** */ + + $nexY+=5; + $nexY = $pdf->GetY(); + $nexY+=10; + + $totalunit=0; + $totalvalue=$totalvaluesell=0; + + $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc, p.entity,"; + $sql.= " ps.reel as value"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; + $sql.= " WHERE ps.fk_product = p.rowid"; + $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) + $sql.= " AND ps.fk_entrepot = ".$object->id; + $sql.= $db->order($sortfield,$sortorder); + + //dol_syslog('List products', LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $nblignes = $num; + for ($i = 0 ; $i < $nblignes ; $i++) + { + $objp = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->produit = $objtp->label; + } + } + + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of product line + $curX = $this->posxdesc-1; + + $showpricebeforepagebreak=1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + $productstatic->id=$objp->rowid; + $productstatic->ref = $objp->ref; + $productstatic->label = $objp->produit; + $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; + + // Ref. + $pdf->SetXY($this->posxdesc, $curY); + $pdf->MultiCell($this->wref, 3, $productstatic->ref, 0, 'L'); + + // Label + $pdf->SetXY($this->posxlabel+0.8, $curY); + $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 3, $objp->produit, 0, 'L'); + + // Quantity + $valtoshow=price2num($objp->value, 'MS'); + $towrite = (empty($valtoshow)?'0':$valtoshow); + + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R'); + + $totalunit+=$objp->value; + + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, price(price2num($objp->ppmp,'MU'), 0, $outputlangs), 0, 'R'); + + // Total PMP + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($objp->ppmp*$objp->value,'MT'), 0, $outputlangs), 0, 'R'); + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); + + // Price sell min + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + $pricemin=$objp->price; + $pdf->SetXY($this->posxdiscount, $curY); + $pdf->MultiCell($this->postotalht-$this->posxdiscount, 3, price(price2num($pricemin,'MU'), 0, $outputlangs), 0, 'R', 0); + + // Total sell min + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($pricemin*$objp->value,'MT'), 0, $outputlangs), 0, 'R', 0); + } + $totalvaluesell+=price2num($pricemin*$objp->value,'MT'); + + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + + $db->free($resql); + + /** + * footer table + */ + $nexY = $pdf->GetY(); + $nexY+=2; + $curY = $nexY; + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1); + $pdf->SetLineStyle(array('dash'=>0)); + + $pdf->SetFont('','B',$default_font_size-1); + $pdf->SetTextColor(0,0,120); + + // Ref. + $pdf->SetXY($this->posxdesc, $curY); + $pdf->MultiCell($this->wref, 3, $langs->trans("Total"), 0, 'L'); + + // Quantity + $valtoshow=price2num($totalunit, 'MS'); + $towrite = empty($valtoshow)?'0':$valtoshow; + + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $towrite, 0, 'R'); + + // Total PMP + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, price(price2num($totalvalue,'MT'), 0, $outputlangs), 0, 'R'); + + // Price sell min + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + // Total sell min + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, price(price2num($totalvaluesell,'MT'), 0, $outputlangs), 0, 'R', 0); + } + } + else + { + dol_print_error($db); + } + + if ($notetoshow) + { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + + $tab_top = 88; + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + + // Loop on each lines + /* + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of stock line + $curX = $this->posxdesc-1; + + $showpricebeforepagebreak=1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + // VAT Rate + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) + { + $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxtva, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); + } + + // Unit price before discount + $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); + + // Quantity + $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->posxqty, $curY); + // Enough for 6 chars + if($conf->global->PRODUCT_USE_UNITS) + { + $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); + } + else + { + $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); + } + + // Unit + if($conf->global->PRODUCT_USE_UNITS) + { + $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L'); + } + + // Discount on line + $pdf->SetXY($this->posxdiscount, $curY); + if ($object->lines[$i]->remise_percent) + { + $pdf->SetXY($this->posxdiscount-2, $curY); + $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); + $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); + } + + // Total HT line + $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); + + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; + else $tvaligne=$object->lines[$i]->total_tva; + + $localtax1ligne=$object->lines[$i]->total_localtax1; + $localtax2ligne=$object->lines[$i]->total_localtax2; + $localtax1_rate=$object->lines[$i]->localtax1_tx; + $localtax2_rate=$object->lines[$i]->localtax2_tx; + $localtax1_type=$object->lines[$i]->localtax1_type; + $localtax2_type=$object->lines[$i]->localtax2_type; + + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; + + $vatrate=(string) $object->lines[$i]->tva_tx; + + // 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,$object->thirdparty,$mysoc); + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; + } + + // retrieve global local tax + if ($localtax1_type && $localtax1ligne != 0) + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; + if ($localtax2_type && $localtax2ligne != 0) + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; + + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; + $this->tva[$vatrate] += $tvaligne; + + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + */ + $tab_top = $tab_top_newpage+21; + + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + + // Affiche zone infos + //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Pied de page + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $this->result = array('fullpath'=>$file); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR"); + return 0; + } + } + + + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom=0; + if ($hidetop) $hidetop=-1; + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + + if (empty($hidetop)) + { + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + + $pdf->SetDrawColor(128,128,128); + $pdf->SetFont('','B', $default_font_size - 3); + + // Output Rect + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->SetDrawColor(220,26,26); + $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top); + $pdf->SetLineStyle(array('dash'=>0)); + $pdf->SetDrawColor(128,128,128); + $pdf->SetTextColor(0,0,120); + + if (empty($hidetop)) + { + //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->MultiCell($this->wref,3, $outputlangs->transnoentities("Ref"),'','L'); + } + + //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxlabel-3, $tab_top+1); + $pdf->MultiCell($this->posxqty-$this->posxlabel+3,2, $outputlangs->transnoentities("Label"),'','C'); + } + + //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxqty-1, $tab_top+1); + $pdf->MultiCell($this->posxup-$this->posxqty-1,2, $outputlangs->transnoentities("Units"),'','C'); + } + + //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxup-1, $tab_top+1); + $pdf->MultiCell($this->posxunit-$this->posxup-1,2, $outputlangs->transnoentities("AverageUnitPricePMPShort"),'','C'); + } + + //$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxunit - 1, $tab_top + 1); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', + 'C'); + } + + //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdiscount-1, $tab_top+1); + $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("SellPriceMin"),'','C'); + } + + //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->postotalht-1, $tab_top+1); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("EstimatedStockValueSellShort"),'','C'); + } + + $pdf->SetDrawColor(220,26,26); + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); + $pdf->SetLineStyle(array('dash'=>0)); + + } + + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @param string $titlekey Translation key to show as title of document + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") + { + global $conf,$langs,$db,$hookmanager; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); + $outputlangs->load("orders"); + $outputlangs->load("stocks"); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + if ($object->type == 1) $titlekey='ServiceSheet'; + else $titlekey='StockSheet'; + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + // Show Draft Watermark + if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + } + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posy=$this->marge_haute; + $posx=$this->page_largeur-$this->marge_droite-100; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size -2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else + { + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + } + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("Warehouse"); + $pdf->MultiCell(100, 3, $title, '', 'R'); + + $pdf->SetFont('','B',$default_font_size); + + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R'); + + $posy+=5; + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $pdf->MultiCell(150, 3, $object->lieu, '', 'R'); + + + // Parent entrepot + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $e = new Entrepot($db); + if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) + { + $pdf->MultiCell(150, 3, $e->libelle, '', 'R'); + } + else + { + $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R'); + } + + // Description + $nexY = $pdf->GetY(); + $nexY+=5; + $pdf->SetXY($posx,$posy); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); + $nexY = $pdf->GetY(); + + $calcproductsunique=$object->nb_different_products(); + $calcproducts=$object->nb_products(); + + // Total nb of different products + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1); + $nexY = $pdf->GetY(); + + // Nb of products + $valtoshow=price2num($calcproducts['nb'], 'MS'); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow)?'0':$valtoshow), 0, 1); + $nexY = $pdf->GetY(); + + // Value + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); + $nexY = $pdf->GetY(); + + + // Last movement + $sql = "SELECT max(m.datem) as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate=$db->jdate($obj->datem); + } + else + { + dol_print_error($db); + } + + if ($lastmovementdate) + { + $toWrite = dol_print_date($lastmovementdate,'dayhour').' '; + } + else + { + $toWrite = $outputlangs->transnoentities("None"); + } + + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("LastMovement").' : '.$toWrite, 0, 1); + $nexY = $pdf->GetY(); + + + /*if ($object->ref_client) + { + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + }*/ + + /*$posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); + */ + + // Get contact + /* + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) + { + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $usertmp=new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + } + }*/ + + $posy+=2; + + // Show list of linked objects + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + + if ($showaddress) + { + /* + // Sender properties + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); + + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + */ + } + + $pdf->SetTextColor(0,0,0); + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } + +} + diff --git a/htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php new file mode 100644 index 00000000000..16d979d60ee --- /dev/null +++ b/htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php @@ -0,0 +1,1159 @@ + + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/stock/doc/pdf_standard.modules.php + * \ingroup societe + * \brief File of class to build PDF documents for stocks/services + */ + +require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; + + +/** + * Class to build documents using ODF templates generator + */ +class pdf_stdmouvement extends ModelePDFMouvement +{ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array() Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.3 = array(5, 3) + */ + public $phpmin = array(5, 2); + + /** + * Dolibarr version of the loaded document + * @public string + */ + public $version = 'dolibarr'; + + public $page_largeur; + public $page_hauteur; + public $format; + public $marge_gauche; + public $marge_droite; + public $marge_haute; + public $marge_basse; + + public $emetteur; // Objet societe qui emet + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("companies"); + + $this->db = $db; + $this->name = "stdmouvement"; + $this->description = $langs->trans("DocumentModelStandardPDF"); + + // Dimension page pour format A4 + $this->type = 'pdf'; + $formatarray=pdf_getFormat(); + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; + $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; + $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; + $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + + $this->option_logo = 1; // Affiche logo + $this->option_codestockservice = 0; // Affiche code stock-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_freetext = 0; // Support add of a personalised text + + // Recupere emetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined + + // Define position of columns + $this->wref = 15; + $this->posxidref = $this->marge_gauche; + $this->posxdatemouv = $this->marge_gauche+8;; + $this->posxdesc=37; + $this->posxlabel=50; + $this->posxtva=80; + $this->posxqty=105; + $this->posxup=119; + $this->posxunit=136; + $this->posxdiscount=167; + $this->postotalht=180; + + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; + $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpicture-=20; + $this->posxtva-=20; + $this->posxup-=20; + $this->posxqty-=20; + $this->posxunit-=20; + $this->posxdiscount-=20; + $this->postotalht-=20; + } + $this->tva=array(); + $this->localtax1=array(); + $this->localtax2=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; + } + + + /** + * Function to build a document on disk using the generic odt module. + * + * @param Stock $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return int 1 if OK, <=0 if KO + */ + function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) + { + global $user,$langs,$conf,$mysoc,$db,$hookmanager; + + if (! is_object($outputlangs)) $outputlangs=$langs; + // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO + if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("stocks"); + $outputlangs->load("orders"); + $outputlangs->load("deliveries"); + + /** + * TODO: get from object + */ + + $id=GETPOST('id','int'); + $ref = GETPOST('ref','alpha'); + $msid=GETPOST('msid','int'); + $product_id=GETPOST("product_id"); + $action=GETPOST('action','aZ09'); + $cancel=GETPOST('cancel','alpha'); + $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; + + $idproduct = GETPOST('idproduct','int'); + $year = GETPOST("year"); + $month = GETPOST("month"); + $search_ref = GETPOST('search_ref', 'alpha'); + $search_movement = GETPOST("search_movement"); + $search_product_ref = trim(GETPOST("search_product_ref")); + $search_product = trim(GETPOST("search_product")); + $search_warehouse = trim(GETPOST("search_warehouse")); + $search_inventorycode = trim(GETPOST("search_inventorycode")); + $search_user = trim(GETPOST("search_user")); + $search_batch = trim(GETPOST("search_batch")); + $search_qty = trim(GETPOST("search_qty")); + $search_type_mouvement=GETPOST('search_type_mouvement','int'); + + $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; + $page = GETPOST("page",'int'); + $sortfield = GETPOST("sortfield",'alpha'); + $sortorder = GETPOST("sortorder",'alpha'); + if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 + $offset = $limit * $page; + if (! $sortfield) $sortfield="m.datem"; + if (! $sortorder) $sortorder="DESC"; + + $pdluoid=GETPOST('pdluoid','int'); + + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + $hookmanager->initHooks(array('movementlist')); + $extrafields = new ExtraFields($db); + + // fetch optionals attributes and labels + $extralabels = $extrafields->fetch_name_optionals_label('movement'); + $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); + + $productlot=new ProductLot($db); + $productstatic=new Product($db); + $warehousestatic=new Entrepot($db); + $movement=new MouvementStock($db); + $userstatic=new User($db); + + $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; + $sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; + $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; + $sql.= " m.batch, m.price,"; + $sql.= " m.type_mouvement,"; + $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; + $sql.= " u.login, u.photo, u.lastname, u.firstname"; + // Add fields from extrafields + foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); + // Add fields from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; + $sql.= " ".MAIN_DB_PREFIX."product as p,"; + $sql.= " ".MAIN_DB_PREFIX."stock_mouvement as m"; + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."movement_extrafields as ef on (m.rowid = ef.fk_object)"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product"; + $sql.= " WHERE m.fk_product = p.rowid"; + if ($msid > 0) $sql .= " AND m.rowid = ".$msid; + $sql.= " AND m.fk_entrepot = e.rowid"; + $sql.= " AND e.entity IN (".getEntity('stock').")"; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= " AND p.fk_product_type = 0"; + if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; + if ($month > 0) + { + if ($year > 0) + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + else + $sql.= " AND date_format(m.datem, '%m') = '$month'"; + } + else if ($year > 0) + { + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + } + if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; + if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); + if (! empty($search_movement)) $sql.= natural_search('m.label', $search_movement); + if (! empty($search_inventorycode)) $sql.= natural_search('m.inventorycode', $search_inventorycode); + if (! empty($search_product_ref)) $sql.= natural_search('p.ref', $search_product_ref); + if (! empty($search_product)) $sql.= natural_search('p.label', $search_product); + if ($search_warehouse > 0) $sql.= " AND e.rowid = '".$db->escape($search_warehouse)."'"; + if (! empty($search_user)) $sql.= natural_search('u.login', $search_user); + if (! empty($search_batch)) $sql.= natural_search('m.batch', $search_batch); + if ($search_qty != '') $sql.= natural_search('m.value', $search_qty, 1); + if ($search_type_mouvement > 0) $sql.= " AND m.type_mouvement = '".$db->escape($search_type_mouvement)."'"; + // Add where from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + $sql.= $db->order($sortfield,$sortorder); + + $nbtotalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } + } + + if(empty($search_inventorycode)) $sql.= $db->plimit($limit+1, $offset); + + + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + + /* + * END TODO + **/ + + //$nblignes = count($object->lines); + + if ($conf->stock->dir_output) + { + + if ($resql) + { + $product = new Product($db); + $object = new Entrepot($db); + + if ($idproduct > 0) + { + $product->fetch($idproduct); + } + if ($id > 0 || $ref) + { + $result = $object->fetch($id, $ref); + if ($result < 0) + { + dol_print_error($db); + } + } + + $num = $db->num_rows($resql); + + $arrayofselected=is_array($toselect)?$toselect:array(); + + $i = 0; + $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + if ($msid) $texte = $langs->trans('StockMovementForId', $msid); + else + { + $texte = $langs->trans("ListOfStockMovements"); + if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; + } + } + + // Definition of $dir and $file + if ($object->specimen) + { + $dir = $conf->stock->dir_output . "/mouvement"; + $file = $dir . "/SPECIMEN.pdf"; + } + else + { + $objectref = dol_sanitizeFileName($object->ref); + if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; + if($search_type_mouvement) $objectref.="_".$search_type_mouvement; + $dir = $conf->stock->dir_output . "/mouvement/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; + } + + $stockFournisseur = new ProductFournisseur($this->db); + $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id); + $object->supplierprices = $supplierprices; + + $productstatic=new Product($db); + + if (! file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + return -1; + } + } + + if (file_exists($dir)) + { + // Add pdfgeneration hook + if (! is_object($hookmanager)) + { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager=new HookManager($this->db); + } + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + + // Create pdf instance + $pdf=pdf_getInstance($this->format); + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance + $pdf->SetAutoPageBreak(1,0); + + $heightforinfotot = 40; // Height reserved to output the info and total part + $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } + + $pdf->Open(); + $pagenb=0; + $pdf->SetDrawColor(128,128,128); + + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); + $pdf->SetSubject($outputlangs->transnoentities("Stock")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->libelle)); + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + + + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + $this->_pagehead($pdf, $object, 1, $outputlangs); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0,0,0); + + $tab_top = 42; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_height = 130; + $tab_height_newpage = 150; + + /* ************************************************************************** */ + /* */ + /* Affichage de la liste des produits du MouvementStock */ + /* */ + /* ************************************************************************** */ + + $nexY+=5; + $nexY = $pdf->GetY(); + $nexY+=10; + + $totalunit=0; + $totalvalue=$totalvaluesell=0; + + //dol_syslog('List products', LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $nblignes = $num; + for ($i = 0 ; $i < $nblignes ; $i++) + { + $objp = $db->fetch_object($resql); + + // Multilangs + if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + { + $sql = "SELECT label"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql.= " WHERE fk_product=".$objp->rowid; + $sql.= " AND lang='". $langs->getDefaultLang() ."'"; + $sql.= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) + { + $objtp = $db->fetch_object($result); + if ($objtp->label != '') $objp->produit = $objtp->label; + } + } + + $curY = $nexY; + $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0,0,0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore=$pdf->getPage(); + + // Description of product line + $curX = $this->posxdesc-1; + + $showpricebeforepagebreak=1; + + $pdf->startTransaction(); + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter=$pdf->getPage(); + + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + + $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut + + // $objp = $db->fetch_object($resql); + + $userstatic->id=$objp->fk_user_author; + $userstatic->login=$objp->login; + $userstatic->lastname=$objp->lastname; + $userstatic->firstname=$objp->firstname; + $userstatic->photo=$objp->photo; + + $productstatic->id=$objp->rowid; + $productstatic->ref=$objp->product_ref; + $productstatic->label=$objp->produit; + $productstatic->type=$objp->type; + $productstatic->entity=$objp->entity; + $productstatic->status_batch=$objp->tobatch; + + $productlot->id = $objp->lotid; + $productlot->batch= $objp->batch; + $productlot->eatby= $objp->eatby; + $productlot->sellby= $objp->sellby; + + $warehousestatic->id=$objp->entrepot_id; + $warehousestatic->libelle=$objp->stock; + $warehousestatic->lieu=$objp->lieu; + + $arrayofuniqueproduct[$objp->rowid]=$objp->produit; + if(!empty($objp->fk_origin)) { + $origin = $movement->get_origin($objp->fk_origin, $objp->origintype); + } else { + $origin = ''; + } + + // Id movement. + $pdf->SetXY($this->posxidref, $curY); + $pdf->MultiCell($this->posxdesc-$this->posxidref-0.8, 3, $objp->mid, 0, 'L'); + + // Date. + $pdf->SetXY($this->posxdatemouv, $curY); + $pdf->MultiCell($this->posxdesc-$this->posxdatemouv-0.8, 6, dol_print_date($db->jdate($objp->datem),'dayhour'), 0, 'L'); + + // Ref. + $pdf->SetXY($this->posxdesc, $curY); + $pdf->MultiCell($this->posxlabel-$this->posxdesc-0.8, 3, $productstatic->ref, 0, 'L'); + + // Label + $pdf->SetXY($this->posxlabel+0.8, $curY); + $pdf->MultiCell($this->posxqty-$this->posxlabel-0.8, 6, $productstatic->label, 0, 'L'); + + // Lot/serie + $pdf->SetXY($this->posxqty, $curY); + $pdf->MultiCell($this->posxup-$this->posxqty-0.8, 3, $productlot->batch, 0, 'R'); + + // Inv. code + $pdf->SetXY($this->posxup, $curY); + $pdf->MultiCell($this->posxunit-$this->posxup-0.8, 3, $objp->inventorycode, 0, 'R'); + + // Label mouvement + $pdf->SetXY($this->posxunit, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 3, $objp->label, 0, 'R'); + $totalvalue+=price2num($objp->ppmp*$objp->value,'MT'); + + // Origin + $pricemin=$objp->price; + $pdf->SetXY($this->posxdiscount, $curY); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8, 3, $origin, 0, 'R', 0); + + // Qty + $valtoshow=price2num($objp->qty, 'MS'); + $towrite = (empty($valtoshow)?'0':$valtoshow); + $totalunit+=$objp->qty; + + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $objp->qty, 0, 'R', 0); + + $totalvaluesell+=price2num($pricemin*$objp->value,'MT'); + + $nexY+=3.5; // Passe espace entre les lignes + // Add line + if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) + { + $pdf->setPage($pageposafter); + $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + //$pdf->SetDrawColor(190,190,200); + $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); + $pdf->SetLineStyle(array('dash'=>0)); + } + + $nexY+=2; // Passe espace entre les lignes + + // Detect if some page were added automatically and output _tableau for past pages + while ($pagenb < $pageposafter) + { + $pdf->setPage($pagenb); + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + $pagenb++; + $pdf->setPage($pagenb); + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); + } + $this->_pagefoot($pdf,$object,$outputlangs,1); + // New page + $pdf->AddPage(); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + $pagenb++; + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + } + + $db->free($resql); + + /** + * footer table + */ + $nexY = $pdf->GetY(); + $nexY+=5; + $curY = $nexY; + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $curY-1, $this->page_largeur-$this->marge_droite, $curY-1); + $pdf->SetLineStyle(array('dash'=>0)); + + $pdf->SetFont('','B',$default_font_size-1); + $pdf->SetTextColor(0,0,120); + + // Total + $pdf->SetXY($this->posxidref, $curY); + $pdf->MultiCell($this->posxdesc-$this->posxidref, 3, $langs->trans("Total"), 0, 'L'); + + // Total Qty + $pdf->SetXY($this->postotalht, $curY); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0); + + } + else + { + dol_print_error($db); + } + + if ($notetoshow) + { + $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); + + $tab_top = 88; + + $pdf->SetFont('','', $default_font_size - 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + + $tab_top = $tab_top_newpage+21; + + // Show square + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + } + + $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + + // Affiche zone infos + //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + + // Pied de page + $this->_pagefoot($pdf,$object,$outputlangs); + if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); + + $pdf->Close(); + + $pdf->Output($file,'F'); + + // Add pdfgeneration hook + $hookmanager->initHooks(array('pdfgeneration')); + $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + global $action; + $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + + if (! empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); + + $this->result = array('fullpath'=>$file); + + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","PRODUCT_OUTPUTDIR"); + return 0; + } + } + + + /** + * Show table for lines + * + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') + { + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom=0; + if ($hidetop) $hidetop=-1; + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + + if (empty($hidetop)) + { + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); + } + + $pdf->SetDrawColor(128,128,128); + $pdf->SetFont('','B', $default_font_size - 3); + + // Output Rect + //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param + + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->SetDrawColor(220,26,26); + $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite, $tab_top); + $pdf->SetLineStyle(array('dash'=>0)); + $pdf->SetDrawColor(128,128,128); + $pdf->SetTextColor(0,0,120); + + //Ref mouv + if (empty($hidetop)) + { + //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param + $pdf->SetXY($this->posxidref, $tab_top+1); + $pdf->MultiCell($this->posxdatemouv-$this->posxdatemouv-0.8,3, $outputlangs->transnoentities("Ref"),'','L'); + } + + //Date mouv + //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdatemouv, $tab_top+1); + $pdf->MultiCell($this->posxdesc-$this->posxdatemouv,2, $outputlangs->transnoentities("Date"),'','C'); + } + + //Ref Product + //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->MultiCell($this->posxlabel-$this->posxdesc,2, $outputlangs->transnoentities("Ref. Product"),'','C'); + } + + //Label Product + //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxlabel-1, $tab_top+1); + $pdf->MultiCell($this->posxqty-$this->posxlabel,2, $outputlangs->transnoentities("Label"),'','C'); + } + + //Lot/serie Product + //$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxqty, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '','C'); + } + + //Code Inv + //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxup-1, $tab_top+1); + $pdf->MultiCell($this->posxunit-$this->posxup,2, $outputlangs->transnoentities("Inventory Code"),'','C'); + } + + //Label mouvement + //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxunit, $tab_top+1); + $pdf->MultiCell($this->posxdiscount-$this->posxunit,2, $outputlangs->transnoentities("Label Mouvement"),'','C'); + } + + //Origin + //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxdiscount+2, $tab_top+1); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-0.8,2, $outputlangs->transnoentities("Origin"),'','C'); + } + + //Qty + //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->postotalht+2, $tab_top+1); + $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht,2, $outputlangs->transnoentities("Qty"),'','C'); + } + + $pdf->SetDrawColor(220,26,26); + $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); + $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); + $pdf->SetLineStyle(array('dash'=>0)); + + } + + /** + * Show top header of page. + * + * @param TCPDF $pdf Object PDF + * @param Object $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @param string $titlekey Translation key to show as title of document + * @return void + */ + function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") + { + global $conf,$langs,$db,$hookmanager; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); + $outputlangs->load("orders"); + $outputlangs->load("stocks"); + $default_font_size = pdf_getPDFFontSize($outputlangs); + + if ($object->type == 1) $titlekey='ServiceSheet'; + else $titlekey='StockSheet'; + + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); + + // Show Draft Watermark + if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); + } + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('','B', $default_font_size + 3); + + $posy=$this->marge_haute; + $posx=$this->page_largeur-$this->marge_droite-100; + + $pdf->SetXY($this->marge_gauche,$posy); + + // Logo + $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height=pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('','B', $default_font_size -2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else + { + $text=$this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + } + + $pdf->SetFont('','B', $default_font_size + 3); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("Warehouse"); + $pdf->MultiCell(100, 3, $title, '', 'R'); + + $pdf->SetFont('','B',$default_font_size); + + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->libelle), '', 'R'); + + $posy+=5; + $pdf->SetFont('','', $default_font_size - 1); + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $pdf->MultiCell(150, 3, $object->lieu, '', 'R'); + + + // Parent MouvementStock + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R'); + + $posy+=4; + $pdf->SetXY($posx-50,$posy); + $e = new MouvementStock($db); + if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) + { + $pdf->MultiCell(150, 3, $e->libelle, '', 'R'); + } + else + { + $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R'); + } + + // Description + $nexY = $pdf->GetY(); + $nexY+=5; + $pdf->SetXY($posx,$posy); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("Description").' : '.nl2br($object->description), 0, 1); + $nexY = $pdf->GetY(); + + $calcproductsunique=$object->nb_different_products(); + $calcproducts=$object->nb_products(); + + // Total nb of different products + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfDifferentProducts").' : '.(empty($calcproductsunique['nb'])?'0':$calcproductsunique['nb']), 0, 1); + $nexY = $pdf->GetY(); + + // Nb of products + $valtoshow=price2num($calcproducts['nb'], 'MS'); + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("NumberOfProducts").' : '.(empty($valtoshow)?'0':$valtoshow), 0, 1); + $nexY = $pdf->GetY(); + + // Value + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("EstimatedStockValueShort").' : '. price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1); + $nexY = $pdf->GetY(); + + + // Last movement + $sql = "SELECT max(m.datem) as datem"; + $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; + $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; + $resqlbis = $db->query($sql); + if ($resqlbis) + { + $obj = $db->fetch_object($resqlbis); + $lastmovementdate=$db->jdate($obj->datem); + } + else + { + dol_print_error($db); + } + + if ($lastmovementdate) + { + $toWrite = dol_print_date($lastmovementdate,'dayhour').' '; + } + else + { + $toWrite = $outputlangs->transnoentities("None"); + } + + $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, ''.$outputlangs->transnoentities("LastMovement").' : '.$toWrite, 0, 1); + $nexY = $pdf->GetY(); + + + /*if ($object->ref_client) + { + $posy+=5; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); + }*/ + + /*$posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); + */ + + // Get contact + /* + if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) + { + $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); + if (count($arrayidcontact) > 0) + { + $usertmp=new User($this->db); + $usertmp->fetch($arrayidcontact[0]); + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); + } + }*/ + + $posy+=2; + + // Show list of linked objects + //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + + if ($showaddress) + { + /* + // Sender properties + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); + + // Show sender + $posy=42; + $posx=$this->marge_gauche; + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $hautcadre=40; + + // Show sender frame + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetXY($posx,$posy-5); + $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); + $pdf->SetXY($posx,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0,0,60); + + // Show sender name + $pdf->SetXY($posx+2,$posy+3); + $pdf->SetFont('','B', $default_font_size); + $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy=$pdf->getY(); + + // Show sender information + $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); + */ + } + + $pdf->SetTextColor(0,0,0); + } + + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); + } + +} + diff --git a/htdocs/core/modules/stock/modules_stock.class.php b/htdocs/core/modules/stock/modules_stock.class.php new file mode 100644 index 00000000000..9af3aa11501 --- /dev/null +++ b/htdocs/core/modules/stock/modules_stock.class.php @@ -0,0 +1,90 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * + * 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 . + * or see http://www.gnu.org/ + */ + + +/** + * \class ModeleStock + * \brief Parent class for warehouse generators + */ + +/** + * \file htdocs/core/modules/stock/modules_stock.php + * \ingroup stock + * \brief File with parent class for generating warehouse to PDF and File of class to manage warehouse mouvement + */ + + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +/** + * Parent class to manage warehouse document templates + */ +abstract class ModelePDFStock extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='stock'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + return $liste; + } +} + + +/** + * Parent class to manage warehouse mouvement document templates + */ +abstract class ModelePDFMouvement extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='mouvementcom'; + $liste=array(); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + return $liste; + } +} \ No newline at end of file diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php new file mode 100644 index 00000000000..f1c72601b97 --- /dev/null +++ b/htdocs/core/modules/stock/modules_stock.php @@ -0,0 +1,52 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2016 Charlie Benke + * + * 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 . + * or see http://www.gnu.org/ + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + +/** + * \class ModeleStock + * \brief Parent class for stock models of doc generators + */ +abstract class ModeleStock extends CommonDocGenerator +{ + var $error=''; + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='stock'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} From bc7b05537f6f41f1707a0c00f027ec768d4aaf9b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 3 May 2018 09:26:48 +0200 Subject: [PATCH 535/609] NEW: hidden conf to assign category to thirparty neither customer nor prospect nor supplier --- htdocs/societe/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 204eff383d5..afec096a500 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1321,7 +1321,7 @@ else $langs->load('categories'); // Customer - if ($object->prospect || $object->client) { + if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, @@ -1879,7 +1879,7 @@ else if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client) { + if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); @@ -2269,7 +2269,7 @@ else if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client) { + if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { print '
' . $langs->trans("CustomersCategoriesShort") . ''; print $form->showCategories($object->id, 'customer', 1); From f70df3490feb344fe59dfbb6afafac0e2c06299e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Thu, 3 May 2018 10:53:24 +0200 Subject: [PATCH 536/609] FIX add db commit --- htdocs/core/actions_massactions.inc.php | 40 +++++++++++++++++++++++-- htdocs/langs/fr_FR/errors.lang | 1 + 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 6303d78d6ef..c2c3467e55c 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -736,8 +736,14 @@ if ($massaction == 'confirm_createbills') } } -if ($massaction == 'cancelorders') +if (!$error && $massaction == 'cancelorders') { + + $db->begin(); + + $nbok = 0; + + $orders = GETPOST('toselect', 'array'); foreach ($orders as $id_order) { @@ -745,7 +751,37 @@ if ($massaction == 'cancelorders') $cmd = new Commande($db); if ($cmd->fetch($id_order) <= 0) continue; - $cmd->cancel(); + + if ($cmd->statut != Commande::STATUS_VALIDATED) + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); + $error++; + break; + } + else + $result = $cmd->cancel(); + + if ($result < 0) + { + setEventMessages($cmd->error, $cmd->errors, 'errors'); + $error++; + break; + } + else + $nbok++; + } + if (!$error) + { + if ($nbok > 1) + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + else + setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); + $db->commit(); + } + else + { + $db->rollback(); } } diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index c6fe1334436..c3c3f55deb4 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -208,6 +208,7 @@ ErrorFileNotFoundWithSharedLink=Fichier non trouvé. Peut que la clé de partage ErrorProductBarCodeAlreadyExists=Le code-barre du produit %s existe déjà sur une autre référence de produit ErrorNoteAlsoThatSubProductCantBeFollowedByLot=Notez également que l'utilisation d'un produit virtuel pour augmenter ou réduire automatiquement les sous-produits n'est pas possible lorsqu'au moins un sous-produit (ou sous-produit de sous-produits) a besoin d'un numéro de série/lot. ErrorDescRequiredForFreeProductLines=La description est obligatoire pour les lignes avec un produit non prédéfini +ErrorObjectMustHaveStatusValidToBeCanceled=L'objet %s doit être au statut 'Validé' pour être annulé # Warnings WarningPasswordSetWithNoAccount=Un mot de passe a été fixé pour cet adhérent. Cependant, aucun compte d'utilisateur n'a été créé. Donc, ce mot de passe est stocké, mais ne peut être utilisé pour accéder à Dolibarr. Il peut être utilisé par un module/interface externe, mais si vous n'avez pas besoin de définir ni login ni mot de passe pour un adhérent, vous pouvez désactiver l'option «Gérer un login pour chaque adhérent" depuis la configuration du module Adhérents. Si vous avez besoin de gérer un login, mais pas de mot de passe, vous pouvez laisser ce champ vide pour éviter cet avertissement. Remarque: L'email peut également être utilisé comme login si l'adhérent est lié à un utilisateur. From 6245f25deb85cc0ef6cdb92e89ff64fb72e54d79 Mon Sep 17 00:00:00 2001 From: atm-arnaud Date: Thu, 3 May 2018 11:45:41 +0200 Subject: [PATCH 537/609] FIX label in getnomurl projectlist --- htdocs/projet/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 6eaf231a5cb..dc3ab9a58ac 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -668,6 +668,7 @@ while ($i < min($num,$limit)) $object->datee = $db->jdate($obj->date_end); $object->statut = $obj->fk_statut; $object->opp_status = $obj->fk_opp_status; + $object->title = $obj->title; $userAccess = $object->restrictedProjectArea($user); // why this ? if ($userAccess >= 0) From 08cf034e2f35db1ce6cc5e40e6e25606f6948426 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 3 May 2018 13:39:44 +0200 Subject: [PATCH 538/609] FIX to allow IRPF not null even if main VAT is null. From https://www.javierrguez.com/problema-facturas-irpf-sin-iva-dolibarr/ --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a22a9675ff6..78010725086 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4261,7 +4261,8 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller if ($local == 2) { - if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; + //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; + if (! $mysoc->localtax2_assuj) return 0; // If main vat is 0, IRPF may be different than 0. if ($thirdparty_seller->id == $mysoc->id) { if (! $thirdparty_buyer->localtax2_assuj) return 0; From f3a70a40d7b12cd921edddcf45f03c09c71fbd00 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Thu, 3 May 2018 21:27:52 +0200 Subject: [PATCH 539/609] clean and update code --- htdocs/admin/expedition.php | 8 +++---- htdocs/admin/livraison.php | 14 ++++------- htdocs/admin/mailing.php | 9 ++----- htdocs/admin/mailman.php | 10 +++----- htdocs/admin/mails.php | 40 ++++---------------------------- htdocs/admin/mails_emailing.php | 12 ---------- htdocs/admin/mails_templates.php | 6 +---- 7 files changed, 17 insertions(+), 82 deletions(-) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 442a85c9c6a..311398a78e1 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -6,7 +6,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * 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 @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); if (! $user->admin) accessforbidden(); diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 4c18069b415..0af26a0a2b7 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -6,8 +6,8 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2011-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand - * Copyright (C) 2015 Claudio Aschieri + * Copyright (C) 2011-2018 Philippe Grand + * Copyright (C) 2015 Claudio Aschieri * * 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 @@ -34,10 +34,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "sendings", "deliveries", "other")); if (!$user->admin) accessforbidden(); @@ -216,7 +214,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -337,7 +334,6 @@ print "
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print ''; print ''; print ''; print "\n"; - print ''; - print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $langs->trans("MailingEMailFrom").''; print ''; if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingEMailError").''; print ''; if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail")); print '
'; print $langs->trans("MailingDelay").''; print ''; diff --git a/htdocs/admin/mailman.php b/htdocs/admin/mailman.php index 89416a72e36..bb53349d1b7 100644 --- a/htdocs/admin/mailman.php +++ b/htdocs/admin/mailman.php @@ -32,9 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/mailmanspip.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("admin"); -$langs->load("members"); -$langs->load("mailmanspip"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "members", "mailmanspip")); if (! $user->admin) accessforbidden(); @@ -49,7 +48,7 @@ $testunsubscribeemail = GETPOST("testunsubscribeemail"); * Actions */ -// Action mise a jour ou ajout d'une constante +// Action updated or added a constant if ($action == 'update' || $action == 'add') { foreach($_POST['constname'] as $key => $val) @@ -156,9 +155,6 @@ print load_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'title_setup' $head = mailmanspip_admin_prepare_head(); - -$var=true; - if (! empty($conf->global->ADHERENT_USE_MAILMAN)) { print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index f85853f5b97..f4c5a2531ff 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -27,12 +27,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -$langs->load("companies"); -$langs->load("products"); -$langs->load("admin"); -$langs->load("mails"); -$langs->load("other"); -$langs->load("errors"); +// Load traductions files requiredby by page +$langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors")); $action=GETPOST('action','alpha'); @@ -260,13 +256,11 @@ if ($action == 'edit') clearstatcache(); - $var=true; print ''; print ''; // Disable - print ''; @@ -283,11 +277,9 @@ if ($action == 'edit') print ''; // Separator - print ''; // Method - print ''; // Port - print ''; // From - print ''; print ''; @@ -497,22 +486,19 @@ if ($action == 'edit') } else dol_print_error($db);*/ - print ''; // Separator - print ''; // From - print ''; print ''; // Autocopy to - print ''; print ''; @@ -535,15 +521,11 @@ else print $langs->trans("EMailsDesc")."
\n"; print "
\n"; - - - $var=true; - + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''; print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); print '
 
'.$langs->trans("MAIN_MAIL_SENDMODE").''; // SuperAdministrator access only @@ -338,7 +330,6 @@ if ($action == 'edit') print '
'; if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { @@ -411,7 +402,6 @@ if ($action == 'edit') } // TLS - print '
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { @@ -469,7 +459,6 @@ if ($action == 'edit') print '
 
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; + print '
'.$langs->trans('MAIN_MAIL_DEFAULT_FROMTYPE').''; print $form->selectarray('MAIN_MAIL_DEFAULT_FROMTYPE', $liste, $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE, 0); print '
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").'
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'
'; print ''; // Disable - print ''; // Force e-mail recipient @@ -555,11 +537,9 @@ else print ''; // Separator - print ''; // Method - print ''; // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -578,7 +557,6 @@ else } // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE) && $conf->global->MAIN_MAIL_SENDMODE == 'mail')) { print ''; @@ -589,21 +567,18 @@ else } // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { print ''; } // TLS - print ''; // STARTTLS - print ''; // From - print ''; print ''; // Separator - print ''; // Errors To - print ''; print ''; // Autocopy to - print ''; print ''; + $html .= ''; $html .= ''; $html .= ''; } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 90cf8bad1b4..2fa0ee44178 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -1010,7 +1010,7 @@ class Don extends CommonObject $object=$this; $classname = $modele; - $obj = new $classname($db); + $obj = new $classname($this->db); // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. @@ -1028,7 +1028,7 @@ class Don extends CommonObject { $outputlangs->charset_output=$sav_charset_output; dol_syslog("Erreur dans don_create"); - dol_print_error($db,$obj->error); + dol_print_error($this->db,$obj->error); return 0; } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b7ee4ee7232..de09e800ede 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -573,9 +573,9 @@ class CommandeFournisseur extends CommonOrder */ function LibStatut($statut,$mode=0,$billed=0) { - if (empty($this->statuts) || empty($statutshort)) + if (empty($this->statuts) || empty($this->statutshort)) { - global $langs; + global $conf, $langs; $langs->load('orders'); $this->statuts[0] = 'StatusOrderDraft'; @@ -591,19 +591,17 @@ class CommandeFournisseur extends CommonOrder $this->statuts[9] = 'StatusOrderRefused'; // List of language codes for status - $statutshort[0] = 'StatusOrderDraftShort'; - $statutshort[1] = 'StatusOrderValidatedShort'; - $statutshort[2] = 'StatusOrderApprovedShort'; - $statutshort[3] = 'StatusOrderOnProcessShort'; - $statutshort[4] = 'StatusOrderReceivedPartiallyShort'; - $statutshort[5] = 'StatusOrderReceivedAllShort'; - $statutshort[6] = 'StatusOrderCanceledShort'; - $statutshort[7] = 'StatusOrderCanceledShort'; - $statutshort[9] = 'StatusOrderRefusedShort'; + $this->statutshort[0] = 'StatusOrderDraftShort'; + $this->statutshort[1] = 'StatusOrderValidatedShort'; + $this->statutshort[2] = 'StatusOrderApprovedShort'; + $this->statutshort[3] = 'StatusOrderOnProcessShort'; + $this->statutshort[4] = 'StatusOrderReceivedPartiallyShort'; + $this->statutshort[5] = 'StatusOrderReceivedAllShort'; + $this->statutshort[6] = 'StatusOrderCanceledShort'; + $this->statutshort[7] = 'StatusOrderCanceledShort'; + $this->statutshort[9] = 'StatusOrderRefusedShort'; } - $langs->load('orders'); - $billedtext=''; //if ($statut==5 && $this->billed == 1) $statut = 8; if ($billed == 1) $billedtext=$langs->trans("Billed"); @@ -614,7 +612,7 @@ class CommandeFournisseur extends CommonOrder } if ($mode == 1) { - return $langs->trans($statutshort[$statut]); + return $langs->trans($this->statutshort[$statut]); } if ($mode == 2) { @@ -644,14 +642,14 @@ class CommandeFournisseur extends CommonOrder } if ($mode == 5) { - if ($statut==0) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); - if ($statut==1) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1'); - if ($statut==2) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); - if ($statut==3) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); - if ($statut==4) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); - if ($statut==5) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); - if ($statut==6 || $statut==7) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); - if ($statut==9) return ''.$langs->trans($statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); + if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut0'); + if ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut1'); + if ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); + if ($statut==3) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); + if ($statut==4) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut3'); + if ($statut==5) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut6'); + if ($statut==6 || $statut==7) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); + if ($statut==9) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5'); } } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d4b1c14b522..6b4c45eafad 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1493,9 +1493,10 @@ class FactureFournisseur extends CommonInvoice */ public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='') { - dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); + global $langs, $mysoc, $conf; + + dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; - global $mysoc, $conf; // Clean parameters if (empty($remise_percent)) $remise_percent=0; @@ -1514,7 +1515,7 @@ class FactureFournisseur extends CommonInvoice if (! empty($conf->global->SUPPLIER_INVOICE_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." qty=".$qty." ref_supplier=".$ref_supplier); $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9815d664ae3..a1d6f722994 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -352,7 +352,7 @@ class MyObject extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode=0) + function LibStatut($status, $mode=0) { if (empty($this->labelstatus)) { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index a39fba04b81..31a89ab332e 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -403,7 +403,7 @@ class SupplierProposal extends CommonObject if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) { // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier); + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); $prod = new Product($this->db, $fk_product); if ($prod->fetch($fk_product) > 0) { diff --git a/htdocs/ticketsup/class/api_tickets.class.php b/htdocs/ticketsup/class/api_tickets.class.php index d0cd018648c..79fd497ba4f 100644 --- a/htdocs/ticketsup/class/api_tickets.class.php +++ b/htdocs/ticketsup/class/api_tickets.class.php @@ -20,13 +20,12 @@ require 'ticketsup.class.php'; require_once DOL_DOCUMENT_ROOT . '/core/lib/ticketsup.lib.php'; + /** * API class for ticketsup object * * @access protected * @class DolibarrApiAccess {@requires user,external} - * - * */ class Tickets extends DolibarrApi { @@ -311,18 +310,14 @@ class Tickets extends DolibarrApi $sql.= $db->order($sortfield, $sortorder); - $nbtotalofrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } - } + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $this->db->plimit($limit, $offset); + } $result = $db->query($sql); if ($result) {
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'
'.$langs->trans("MAIN_MAIL_ENABLED_USER_DEST_SELECT").''.yn($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT).'
 
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -567,7 +547,6 @@ else print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -617,7 +592,6 @@ else print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))) { @@ -634,7 +608,6 @@ else if ($conf->global->MAIN_MAIL_SENDMODE == 'swiftmailer') { // DKIM - print '
'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; if (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))) { @@ -664,11 +637,9 @@ else } // Separator - print '
 
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_EMAIL_FROM; if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); @@ -723,18 +694,15 @@ else print '
 
'.$langs->trans("MAIN_MAIL_ERRORS_TO").''.$conf->global->MAIN_MAIL_ERRORS_TO; if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print '
'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 1202e9817d3..1cb92ae8377 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -228,7 +228,6 @@ if ($action == 'edit') clearstatcache(); - $var=true; print ''; print ''; @@ -341,7 +340,6 @@ if ($action == 'edit') // PW if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { - $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING)?$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING:''); print ''; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 8eb6f0b98c8..a8798901a21 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -822,6 +822,9 @@ select.flat.selectlimit { .fa-trash, .fa-crop, .fa-pencil { font-size: 1.4em; } +.fa-15 { + font-size: 1.5em; +} /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /*.table-responsive { From b5f222f45aca791b65de2264c314fad190318dae Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Fri, 4 May 2018 14:14:04 +0200 Subject: [PATCH 542/609] Clean and update code --- htdocs/admin/menus.php | 7 ------- htdocs/admin/payment.php | 9 ++------- htdocs/admin/prelevement.php | 1 - htdocs/admin/propal.php | 13 ++++--------- htdocs/admin/proxy.php | 15 ++++++--------- 5 files changed, 12 insertions(+), 33 deletions(-) diff --git a/htdocs/admin/menus.php b/htdocs/admin/menus.php index 7ffaa9a110a..a5f2fb2a2ff 100644 --- a/htdocs/admin/menus.php +++ b/htdocs/admin/menus.php @@ -163,8 +163,6 @@ if ($action == 'edit') clearstatcache(); // Gestionnaires de menu - $var=true; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''; // SuperAdministrator access only @@ -405,14 +403,10 @@ else print $langs->trans("EMailsDesc")."
\n"; print "
\n"; - - $var=true; - print ''; print ''; // Method - print ''; @@ -433,7 +426,6 @@ else } // Port - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) { print ''; @@ -444,21 +436,18 @@ else } // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { print ''; } // SMTPS PW - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { print ''; } // TLS - print ''; // STARTTLS - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; if (empty($text)) $text=$langs->trans("Undefined").img_warning(); @@ -422,7 +416,6 @@ else if (! empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { // Host server - if ($linuxlike && (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING == 'mail')) { print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_EMAILING.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW_EMAILING).'
'.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { @@ -472,7 +461,6 @@ else print '
'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 4e731021199..60db9fae8c4 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2017 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -447,7 +447,6 @@ $fieldlist=explode(',',$tabfield[$id]); // Form to add a new line $alabelisused=0; -$var=false; print ''; print ''; @@ -591,9 +590,7 @@ $colspan=count($fieldlist)+1; print '
'; print ''; - print ''; - print '
'; @@ -611,7 +608,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; $paramwithsearch = $param; From 1f775c907dfd22f73ca75f54a561e08a206a177f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 11:01:22 +0200 Subject: [PATCH 540/609] Fix translation of % column in gantt view --- dev/dolibarr_changes.txt | 8 ++++++++ htdocs/includes/jsgantt/jsgantt.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 9e6ab3a8ddc..cdbc2e2bb40 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -90,6 +90,14 @@ var vTmpNode=this.newNode(vTmpCell, 'div', null, ''); vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']); vTmpNode.setAttribute('href',vTaskList[i].getLink()); +* Replace '% Comp.' to have a smaller text column header +'comp':'% Comp.' +with +'comp':'%' + + + + JCROP: ------ diff --git a/htdocs/includes/jsgantt/jsgantt.js b/htdocs/includes/jsgantt/jsgantt.js index 7a26eecb9fc..04921b92405 100644 --- a/htdocs/includes/jsgantt/jsgantt.js +++ b/htdocs/includes/jsgantt/jsgantt.js @@ -331,7 +331,7 @@ JSGantt.GanttChart=function(pDiv, pFormat) var vLangs={'en': {'format':'Format','hour':'Hour','day':'Day','week':'Week','month':'Month','quarter':'Quarter','hours':'Hours','days':'Days', 'weeks':'Weeks','months':'Months','quarters':'Quarters','hr':'Hr','dy':'Day','wk':'Wk','mth':'Mth','qtr':'Qtr','hrs':'Hrs', - 'dys':'Days','wks':'Wks','mths':'Mths','qtrs':'Qtrs','resource':'Resource','duration':'Duration','comp':'% Comp.', + 'dys':'Days','wks':'Wks','mths':'Mths','qtrs':'Qtrs','resource':'Resource','duration':'Duration','comp':'%', 'completion':'Completion','startdate':'Start Date','enddate':'End Date','moreinfo':'More Information','notes':'Notes', 'january':'January','february':'February','march':'March','april':'April','maylong':'May','june':'June','july':'July', 'august':'August','september':'September','october':'October','november':'November','december':'December','jan':'Jan', From 5cff4c152b28441ddfd04329804b12cde4dddcef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 11:25:21 +0200 Subject: [PATCH 541/609] Add tab "time spent" in project view. Can swith gantt/list. --- htdocs/core/lib/project.lib.php | 8 +++--- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/ganttview.php | 42 ++++++++++++-------------------- htdocs/projet/tasks.php | 5 ++-- htdocs/projet/tasks/time.php | 11 +++++---- htdocs/theme/eldy/style.css.php | 3 +++ 6 files changed, 32 insertions(+), 38 deletions(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 06d0b7aa6d3..6a8ef760a04 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -104,10 +104,10 @@ function project_prepare_head($object) $head[$h][2] = 'tasks'; $h++; - $head[$h][0] = DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id; - $head[$h][1] = $langs->trans("Gantt"); - if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; - $head[$h][2] = 'gantt'; + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id; + $head[$h][1] = $langs->trans("TimeSpent"); + //if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).''; + $head[$h][2] = 'timespent'; $h++; } diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 85937ad827a..6dfb11e2284 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -77,6 +77,7 @@ Time=Time ListOfTasks=List of tasks GoToListOfTimeConsumed=Go to list of time consumed GoToListOfTasks=Go to list of tasks +GoToGanttView=Go to Gantt view GanttView=Gantt View ListProposalsAssociatedProject=List of the commercial proposals associated with the project ListOrdersAssociatedProject=List of customer orders associated with the project diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 0c1e86c8ab5..248eb1a63b3 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -80,7 +80,8 @@ if (! empty($conf->use_javascript_ajax)) ); } -$title=$langs->trans("Project").' - '.$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); +//$title=$langs->trans("Gantt").($object->ref?' - '.$object->ref.' '.$object->name:''); +$title=$langs->trans("Gantt"); if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=($object->ref?$object->ref.' '.$object->name.' - ':'').$langs->trans("Gantt"); $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$title,$help_url,'',0,0,$arrayofjs,$arrayofcss); @@ -93,7 +94,7 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) //$userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $tab='gantt'; + $tab='tasks'; $head=project_prepare_head($object); dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($object->public?'projectpub':'project')); @@ -187,43 +188,32 @@ if (($id > 0 && is_numeric($id)) || ! empty($ref)) print '
'; dol_fiche_end(); + + print '
'; } - -/* - * Buttons actions - */ - -if ($id > 0 && is_numeric($id)) +// Link to create task +if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - - print '
'; - - if ($user->rights->projet->all->creer || $user->rights->projet->creer) + if ($object->public || $userWrite > 0) { - if ($object->public || $userWrite > 0) - { - print ''.$langs->trans('AddTask').''; - } - else - { - print ''.$langs->trans('AddTask').''; - } + $linktocreatetask = ''.$langs->trans('AddTask').''; } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } - - print '
'; - - print '
'; } else { - print_fiche_titre($langs->trans("GanttView")); + $linktocreatetask = ''.$langs->trans('AddTask').''; } +$linktolist=''.$langs->trans("GoToListOfTasks").' '; + +//print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); +print load_fiche_titre($title, $linktolist.'   '.$linktocreatetask, 'title_generic.png'); + // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 67dd84a1572..22fe740a63b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -31,8 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -$langs->load("users"); -$langs->load("projects"); +$langs->loadLangs(array("users", "projects")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -489,7 +488,7 @@ else if ($id > 0 || ! empty($ref)) print ''; $title=$langs->trans("ListOfTasks"); - $linktotasks=''.$langs->trans("GoToListOfTimeConsumed").''; + $linktotasks=''.$langs->trans("GoToGanttView").' '; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'title_generic.png'); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 0f2ec5f9fcd..86a2027b3b7 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -320,7 +320,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($withproject) { // Tabs for project - $tab='tasks'; + if (empty($id)) $tab='timespent'; + else $tab='tasks'; $head=project_prepare_head($projectstatic); dol_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public?'projectpub':'project')); @@ -695,9 +696,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''."\n"; $title=$langs->trans("ListTaskTimeUserProject"); - $linktotasks=''.$langs->trans("GoToListOfTasks").''; + //$linktotasks=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime, 'title_generic.png'); + print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); } $i = 0; @@ -868,8 +869,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['t.task_date']['checked'])) { print '
'; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; - print ''; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; $formother->select_year($search_year,'search_year',1, 20, 5); print '
'; print ''; print ''; // Menu top - print ''; print ''; // Menu smartphone - print ''; print '"; print "\n"; - $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'sell'); + $coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end, $modetax, 'sell'); $action = "tvaclient"; $object = &$coll_list; @@ -248,7 +248,7 @@ if($calc ==0 || $calc == 1){ $company_static=new Societe($db); - $coll_list = tax_by_thirdparty($db,0,$date_start,$date_end,$modetax,'buy'); + $coll_list = tax_by_thirdparty('localtax'.$local, $db, 0, $date_start, $date_end,$modetax, 'buy'); $parameters["direction"] = 'buy'; $parameters["type"] = 'localtax'.$local; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index e6cdf738b96..0eb40cd4d56 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -107,8 +107,12 @@ function pt ($db, $sql, $date) $amountpaid = 0; $previousmonth = ''; $previousmode = ''; + $mode = ''; + while ($i < $num) { $obj = $db->fetch_object($result); + $mode = $obj->mode; + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; if ($obj->mode == 'claimed' && ! empty($previousmode)) { @@ -154,7 +158,7 @@ function pt ($db, $sql, $date) $i++; } - if ($obj->mode == 'claimed' && ! empty($previousmode)) + if ($mode == 'claimed' && ! empty($previousmode)) { print ''; print '\n"; @@ -173,6 +177,7 @@ function pt ($db, $sql, $date) print ""; print "
'.$langs->trans("Menu").''; @@ -176,7 +174,6 @@ if ($action == 'edit') print '
'.$langs->trans("DefaultMenuManager").''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled'); @@ -187,7 +184,6 @@ if ($action == 'edit') print '
'.$langs->trans("DefaultMenuSmartphoneManager").''; $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled'); @@ -202,8 +198,6 @@ if ($action == 'edit') else { // Gestionnaires de menu - $var=true; - print ''; print ''; print ''; print "\n"; // Allow payments on different thirdparties bills but same parent company -$var=! $var; print '\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index c533ea94795..7ee44a93b52 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -33,10 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('propal'); + +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "errors", "propal")); if (! $user->admin) accessforbidden(); @@ -266,8 +265,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (substr($file, 0, 12) == 'mod_propale_' && substr($file, dol_strlen($file)-3, 3) == 'php') @@ -386,7 +383,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -531,7 +527,6 @@ print ''; print ''; /* -$var=! $var; print ''; print ''; print ''; @@ -631,7 +626,7 @@ print "\n"; print " \n"; print " \n"; print "\n"; -print "\n \n \n\n"; +print "\n \n \n\n"; print "
'.$langs->trans("Menu").''; @@ -267,7 +261,6 @@ if ($action == 'edit') print ''; - if ($action != 'edit') { print '
'; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 339b4fef566..4fe15379629 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -26,10 +26,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load('other'); -$langs->load('bills'); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin", "other", "errors", "bills")); if (! $user->admin) accessforbidden(); @@ -131,8 +129,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -249,7 +245,6 @@ print '
 
'; print $langs->trans("PaymentOnDifferentThirdBills"); print ''; diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 21f34f2a770..203b4ed9bc5 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -274,7 +274,6 @@ print "
".$langs->trans("Name")."".$langs->trans("Value")."
".$langs->trans("PathDirectory")."".$conf->propal->multidir_output[$conf->entity]."
".$langs->trans("PathDirectory")."".$conf->propal->multidir_output[$conf->entity]."
\n
"; diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index ee22f377200..a9028635991 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -26,10 +26,8 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -$langs->load("users"); -$langs->load("admin"); -$langs->load("other"); - +// Load traductions files requiredby by page +$langs->loadLangs(array("other", "users", "admin")); if (!$user->admin) accessforbidden(); @@ -124,7 +122,6 @@ if ($conf->use_javascript_ajax) // Timeout -$var=true; print ''; @@ -163,7 +160,7 @@ print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; + print ''; + } + // Date delivery + if (! empty($arrayfields['p.date_livraison']['checked'])) + { + print ''; + } + // Availability + if (! empty($arrayfields['ava.rowid']['checked'])) + { + print ''; } if (! empty($arrayfields['p.total_ht']['checked'])) { @@ -644,6 +714,8 @@ if ($resql) if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'],$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.date']['checked'])) print_liste_field_titre($arrayfields['p.date']['label'],$_SERVER["PHP_SELF"],'p.datep','',$param, 'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.fin_validite']['checked'])) print_liste_field_titre($arrayfields['p.fin_validite']['label'],$_SERVER["PHP_SELF"],'dfv','',$param, 'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['p.date_livraison']['checked'])) print_liste_field_titre($arrayfields['p.date_livraison']['label'],$_SERVER["PHP_SELF"],'ddelivery','',$param, 'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['ava.rowid']['checked'])) print_liste_field_titre($arrayfields['ava.rowid']['label'],$_SERVER["PHP_SELF"],'availability','',$param, '',$sortfield,$sortorder); if (! empty($arrayfields['p.total_ht']['checked'])) print_liste_field_titre($arrayfields['p.total_ht']['label'],$_SERVER["PHP_SELF"],'p.total_ht','',$param, 'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.total_vat']['checked'])) print_liste_field_titre($arrayfields['p.total_vat']['label'],$_SERVER["PHP_SELF"],'p.tva','',$param, 'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'],$_SERVER["PHP_SELF"],'p.total','',$param, 'align="right"',$sortfield,$sortorder); @@ -809,6 +881,28 @@ if ($resql) } if (! $i) $totalarray['nbfield']++; } + // Date delivery + if (! empty($arrayfields['p.date_livraison']['checked'])) + { + if ($obj->ddelivery) + { + print ''; + } + else + { + print ''; + } + if (! $i) $totalarray['nbfield']++; + } + // Availability + if (! empty($arrayfields['ava.rowid']['checked'])) + { + print ''; + if (! $i) $totalarray['nbfield']++; + } // Amount HT if (! empty($arrayfields['p.total_ht']['checked'])) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c02ada175fd..fa606639bcc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2018 Ferran Marcet * * 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 @@ -2903,7 +2904,7 @@ class Form dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG); - print ''; if ($addempty) print ''; foreach($this->cache_availability as $id => $arrayavailability) { From ea4c48047a80e19ddc458cdf24795cd09c21b27c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:30:27 +0200 Subject: [PATCH 581/609] All new hooks must be addreplace hooks --- htdocs/core/lib/security.lib.php | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 15047b2f2d7..b599fac3cfb 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -111,21 +111,23 @@ function dol_hash($chain,$type=0) */ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null) { - global $db, $conf; + global $db, $conf; + global $hookmanager; //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename,$feature2,$dbt_socfield,$dbt_select"); //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; - // If we use canvas, we try to use function that overlod restrictarea if provided with canvas - if (is_object($objcanvas)) - { - if (method_exists($objcanvas->control,'restrictedArea')) return $objcanvas->control->restrictedArea($user,$features,$objectid,$dbtablename,$feature2,$dbt_keyfield,$dbt_select); - } - if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; + // Get more permissions checks from hooks + $hookmanager->initHooks(array('permissions')); + $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); + $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); + if (isset($hookmanager->resArray['result']) && empty($hookmanager->resArray['result']) return false; + if ($reshook > 0) return true; + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); @@ -206,7 +208,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Check write permission from module $createok=1; $nbko=0; - if (GETPOST("action") == 'create') + if (GETPOST("action","apha") == 'create') { foreach ($featuresarray as $feature) { @@ -261,7 +263,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Check create user permission $createuserok=1; - if (GETPOST("action") == 'confirm_create_user' && GETPOST("confirm") == 'yes') + if (GETPOST("action","alpha") == 'confirm_create_user' && GETPOST("confirm","alpha") == 'yes') { if (! $user->rights->user->user->creer) $createuserok=0; @@ -271,7 +273,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Check delete permission from module $deleteok=1; $nbko=0; - if ((GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == 'yes') || GETPOST("action") == 'delete') + if ((GETPOST("action","alpha") == 'confirm_delete' && GETPOST("confirm","alpha") == 'yes') || GETPOST("action","alpha") == 'delete') { foreach ($featuresarray as $feature) { @@ -335,13 +337,6 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu accessforbidden(); } - // get more permissions checks from hooks - global $hookmanager; - $hookmanager->initHooks(array('permissions')); - $parameters=array('features'=>$features,'objectid'=>preg_replace("/'/", '', $objectid),'idtype'=>$dbt_select); - $reshook=$hookmanager->executeHooks('restricted',$parameters); - if ($reshook < 0) accessforbidden(); - return 1; } From 0891766a3e631068e17363be7d8a5b532dc5b226 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:31:27 +0200 Subject: [PATCH 582/609] Update security.lib.php --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b599fac3cfb..86226587416 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -333,8 +333,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // is linked to a company allowed to $user. if (! empty($objectid) && $objectid > 0) { - if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) - accessforbidden(); + $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) + return $ok ? 1 : accessforbidden(); } return 1; From 7be804dcf552f62639bd29ff494e08ad70c8381c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:32:08 +0200 Subject: [PATCH 583/609] Update security.lib.php --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 86226587416..14c9be76abe 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -333,8 +333,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // is linked to a company allowed to $user. if (! empty($objectid) && $objectid > 0) { - $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) - return $ok ? 1 : accessforbidden(); + $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); + return $ok ? 1 : accessforbidden(); } return 1; From bc9eaaab8407f2b640b04fb43d6a383111ce4ff8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:34:20 +0200 Subject: [PATCH 584/609] Update security.lib.php --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 14c9be76abe..ceebdd63681 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -125,8 +125,8 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu $hookmanager->initHooks(array('permissions')); $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); - if (isset($hookmanager->resArray['result']) && empty($hookmanager->resArray['result']) return false; - if ($reshook > 0) return true; + if (! empty($hookmanager->resArray['result']) return true; + if ($reshook > 0) return false; // Features/modules to check $featuresarray = array($features); From 9077f18dd683c43896096353bfd16575b34186c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:37:22 +0200 Subject: [PATCH 585/609] Update security.lib.php --- htdocs/core/lib/security.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 5101772ac66..f89bba09a76 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -189,7 +189,6 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; // Get more permissions checks from hooks - $hookmanager->initHooks(array('permissions')); $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); if (! empty($hookmanager->resArray['result']) return true; From 56b80d81dd94f23dcf7c4267de44e819725b453a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:39:29 +0200 Subject: [PATCH 586/609] Declare hook as addreplace hook --- htdocs/core/class/hookmanager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 5c1f1358784..cd33f1d8d02 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -182,6 +182,7 @@ class HookManager 'printTabsHead', 'printObjectLine', 'printObjectSubLine', + 'restrictedArea', 'sendMail', 'sendMailAfter', 'showLinkToObjectBlock', From 4efc9f95cd03be3234da33bba149796feb9d1b93 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:48:18 +0200 Subject: [PATCH 587/609] FIX #8775 (try better fix) --- htdocs/compta/ajaxpayment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index 01fe12e50f4..5e83b3032c1 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -61,7 +61,7 @@ foreach ($remains as $key => $value) } // Treatment -$result = $amountPayment != '' ? ($amountPayment - array_sum($amounts)) : ($amountPayment + array_sum($amounts)); // Remaining amountPayment +$result = ($amountPayment != '') ? ($amountPayment - array_sum($amounts)) : array_sum($amounts); // Remaining amountPayment $toJsonArray = array(); $totalRemaining = price2num(array_sum($remains)); $toJsonArray['label'] = $amountPayment == '' ? '' : $langs->transnoentities('RemainingAmountPayment'); From f476e3e304e30acb079c2ee426a2f84f0be09d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 11:56:49 +0200 Subject: [PATCH 588/609] Update translate.class.php --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index ec3ed00a313..55b853f5c8e 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -576,7 +576,7 @@ class Translate // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } - dol_syslog(__METHOD__."missing translation ".$newstr." in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + dol_syslog(__METHOD__."missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); return $newstr; } From c094a6c43ed41c0af0027cd27399a9eaf683f065 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 12:29:58 +0200 Subject: [PATCH 589/609] Reorder permissions --- htdocs/core/lib/security.lib.php | 4 +- htdocs/core/modules/modFournisseur.class.php | 45 ++++++++------------ 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index f89bba09a76..45a96f9a527 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -191,9 +191,9 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // Get more permissions checks from hooks $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); - if (! empty($hookmanager->resArray['result']) return true; + if (! empty($hookmanager->resArray['result'])) return true; if ($reshook > 0) return false; - + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 69e749a4c92..cfac00e14c1 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -165,14 +165,6 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'approuver'; - /*$r++; - $this->rights[$r][0] = 1191; - $this->rights[$r][1] = 'Approuver une commande fournisseur (si supérieur hiérarchique)'; - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'approve_ifsupervisor_advance';*/ - $r++; $this->rights[$r][0] = 1186; $this->rights[$r][1] = 'Commander une commande fournisseur'; @@ -205,6 +197,24 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'supprimer'; + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) + { + $r++; + $this->rights[$r][0] = 1190; + $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190"); + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande'; + $this->rights[$r][5] = 'approve2'; + } + + $r++; + $this->rights[$r][0] = 1191; + $this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs'; + $this->rights[$r][2] = 'r'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'commande'; + $this->rights[$r][5] = 'export'; $r++; $this->rights[$r][0] = 1231; @@ -254,25 +264,6 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'facture'; $this->rights[$r][5] = 'export'; - $r++; - $this->rights[$r][0] = 1237; - $this->rights[$r][1] = 'Exporter les commande fournisseurs, attributs'; - $this->rights[$r][2] = 'r'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'export'; - - if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) - { - $r++; - $this->rights[$r][0] = 1190; - $this->rights[$r][1] = 'Approve supplier order (second level)'; // $langs->trans("Permission1190"); - $this->rights[$r][2] = 'w'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'commande'; - $this->rights[$r][5] = 'approve2'; - } - // Menus //------- From 63b9384ef6ea3e0ad2af852ee301a1a2b21baa40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 12:34:23 +0200 Subject: [PATCH 590/609] No transmormation of data objectid before calling trigger --- htdocs/core/lib/security.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 45a96f9a527..502f962dede 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -186,15 +186,15 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; - if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; - // Get more permissions checks from hooks $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); $reshook=$hookmanager->executeHooks('restrictedArea',$parameters); if (! empty($hookmanager->resArray['result'])) return true; if ($reshook > 0) return false; - // Features/modules to check + if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; + + // Features/modules to check $featuresarray = array($features); if (preg_match('/&/', $features)) $featuresarray = explode("&", $features); else if (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); From 70a185a9e640af08895074e7fa0f8966e93f9310 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 13:11:52 +0200 Subject: [PATCH 591/609] Update main.inc.php --- htdocs/main.inc.php | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index bd803febe5f..cd728711244 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1253,35 +1253,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs } } - //Overload css files to the current module - // Check if the /module/style folder exists and add the contains css files to head - $cur_modulepart = explode("/",$_SERVER["PHP_SELF"]); - if(is_array($cur_modulepart) && count($cur_modulepart)>0) - { - foreach($conf->modules as $module) - { - if(in_array($module, $cur_modulepart)) - { - if (file_exists(getcwd().DIRECTORY_SEPARATOR."style")) - { - //browse the style dir and add the contains css files - if ($handle = opendir(getcwd().DIRECTORY_SEPARATOR."style")) - { - while (false !== ($entry = readdir($handle))) - { - list($filename, $extension) = explode(".", $entry); - if ($entry !== '.' && $entry !== '..' && $extension == 'css') - { - print ''."\n"; - } - } - closedir($handle); - } - } - } - } - } - // CSS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['css'])) { From a6966fe295b5849e8682b774158d71c32afce57d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 13:12:24 +0200 Subject: [PATCH 592/609] Update main.inc.php --- htdocs/main.inc.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index cd728711244..eaea0dc420c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1234,25 +1234,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; - //Overload css files to the current theme - // Check if the /theme/nameoftheme/style folder exists and add the contains css files to head - if (file_exists(dirname(dol_buildpath($conf->css, 0))."/style")) - { - //browse the style dir and add the contains css files - if ($handle = opendir(dirname(dol_buildpath($conf->css, 0))."/style")) - { - while (false !== ($entry = readdir($handle))) - { - list($filename, $extension) = explode(".", $entry); - if ($entry !== '.' && $entry !== '..' && $extension == 'css') - { - print ''."\n"; - } - } - closedir($handle); - } - } - // CSS forced by modules (relative url starting with /) if (! empty($conf->modules_parts['css'])) { From 0c35bc52842eb3e88ebdc8e55cdc90591c3708d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 14:15:52 +0200 Subject: [PATCH 593/609] Standardize code --- htdocs/core/modules/dons/modules_don.php | 111 ----------------------- htdocs/don/card.php | 13 ++- htdocs/don/class/don.class.php | 108 ++++++++++++++++++++++ htdocs/expedition/card.php | 41 +-------- htdocs/livraison/card.php | 15 ++- 5 files changed, 135 insertions(+), 153 deletions(-) diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index 14045f20d11..4949cce94e1 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -139,114 +139,3 @@ abstract class ModeleNumRefDons } } - -/** - * Cree un don sur disque en fonction du modele de DON_ADDON_PDF - * - * @param DoliDB $db Databse handler - * @param int $id Id donation - * @param string $message Message - * @param string $modele Force le modele a utiliser ('' par defaut) - * @param Translate $outputlangs Object langs - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref - * @return int 0 if KO, 1 if OK - */ -function don_create($db, $id, $message, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) -{ - global $conf, $langs; - $langs->load("bills"); - - $eror=0; - - // Increase limit for PDF build - $err=error_reporting(); - error_reporting(0); - @set_time_limit(120); - error_reporting($err); - - $srctemplatepath=''; - - // Set template to use - if (! dol_strlen($modele)) - { - if (! empty($conf->global->DON_ADDON_MODEL)) - { - $modele = $conf->global->DON_ADDON_MODEL; - } - else - { - print $langs->trans("Error")." ".$langs->trans("Error_DON_ADDON_MODEL_NotDefined"); - return 0; - } - } - - // If selected modele is a filename template (then $modele="modelname:filename") - $tmp=explode(':',$modele,2); - if (! empty($tmp[1])) - { - $modele=$tmp[0]; - $srctemplatepath=$tmp[1]; - } - - // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array('/'); - if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); - foreach($dirmodels as $reldir) - { - foreach(array('html','doc','pdf') as $prefix) - { - $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; - - // On verifie l'emplacement du modele - $file=dol_buildpath($reldir."core/modules/dons/".$file,0); - if (file_exists($file)) - { - $filefound=1; - $classname=$prefix.'_'.$modele; - break; - } - } - if ($filefound) break; - } - - // Charge le modele - if ($filefound) - { - require_once $file; - - $object=new Don($db); - $object->fetch($id); - - $classname = $modele; - $obj = new $classname($db); - - // We save charset_output to restore it because write_file can change it if needed for - // output format that does not support UTF8. - $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) - { - $outputlangs->charset_output=$sav_charset_output; - - // we delete preview files - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - dol_delete_preview($object); - return 1; - } - else - { - $outputlangs->charset_output=$sav_charset_output; - dol_syslog("Erreur dans don_create"); - dol_print_error($db,$obj->error); - return 0; - } - } - else - { - print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); - return 0; - } -} - diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 375b49bd4d1..46f223d3857 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -242,8 +242,15 @@ else if ($action == 'classin' && $user->rights->don->creer) $object->fetch($id); $object->setProject($projectid); } + +// Actions to build doc +$upload_dir = $conf->don->dir_output; +$permissioncreate = $user->rights->don->creer; +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + // Remove file in doc form -if ($action == 'remove_file') +/*if ($action == 'remove_file') { $object = new Don($db, 0, $_GET['id']); if ($object->fetch($id)) @@ -261,11 +268,12 @@ if ($action == 'remove_file') $action=''; } } +*/ /* * Build doc */ - +/* if ($action == 'builddoc') { $object = new Don($db); @@ -291,6 +299,7 @@ if ($action == 'builddoc') exit; } } +*/ /* diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 78e3a57f436..90cf8bad1b4 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -931,4 +931,112 @@ class Don extends CommonObject } } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force template to use ('' to not force) + * @param Translate $outputlangs objet lang a utiliser pour traduction + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$langs; + + $langs->load("bills"); + + if (! dol_strlen($modele)) { + + $modele = 'html_cerfafr'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->DON_ADDON_MODEL)) { + $modele = $conf->global->DON_ADDON_MODEL; + } + } + + $modelpath = "core/modules/dons/"; + + // TODO Restore use of commonGenerateDocument instead of dedicated code here + //return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + + // Increase limit for PDF build + $err=error_reporting(); + error_reporting(0); + @set_time_limit(120); + error_reporting($err); + + $srctemplatepath=''; + + // If selected modele is a filename template (then $modele="modelname:filename") + $tmp=explode(':',$modele,2); + if (! empty($tmp[1])) + { + $modele=$tmp[0]; + $srctemplatepath=$tmp[1]; + } + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array('/'); + if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + foreach(array('html','doc','pdf') as $prefix) + { + $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; + + // On verifie l'emplacement du modele + $file=dol_buildpath($reldir."core/modules/dons/".$file,0); + if (file_exists($file)) + { + $filefound=1; + $classname=$prefix.'_'.$modele; + break; + } + } + if ($filefound) break; + } + + // Charge le modele + if ($filefound) + { + require_once $file; + + $object=$this; + + $classname = $modele; + $obj = new $classname($db); + + // We save charset_output to restore it because write_file can change it if needed for + // output format that does not support UTF8. + $sav_charset_output=$outputlangs->charset_output; + if ($obj->write_file($object,$outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) + { + $outputlangs->charset_output=$sav_charset_output; + + // we delete preview files + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_delete_preview($object); + return 1; + } + else + { + $outputlangs->charset_output=$sav_charset_output; + dol_syslog("Erreur dans don_create"); + dol_print_error($db,$obj->error); + return 0; + } + } + else + { + print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file); + return 0; + } + } + } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 078d77c47c9..ddf819ad692 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -123,6 +123,11 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + // Actions to build doc + $upload_dir = $conf->expedition->dir_output.'/sending'; + $permissioncreate = $user->rights->expedition->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + // Reopen if ($action == 'reopen' && $user->rights->expedition->creer) { @@ -533,42 +538,6 @@ if (empty($reshook)) $action=""; } - // Build document - else if ($action == 'builddoc') // En get ou en post - { - // Save last template used to generate document - if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha')); - - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->thirdparty->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - $action=''; - } - } - - // Delete file in doc form - elseif ($action == 'remove_file') - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $upload_dir = $conf->expedition->dir_output . "/sending"; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - elseif ($action == 'classifybilled') { $object->fetch($id); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index b6b25424e65..caee19a2c34 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -45,11 +45,8 @@ if (! empty($conf->projet->enabled)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } +$langs->loadLangs(array("sendings","bills",'deliveries','orders')); -$langs->load("sendings"); -$langs->load("bills"); -$langs->load('deliveries'); -$langs->load('orders'); if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); $action=GETPOST('action', 'alpha'); @@ -77,9 +74,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('deliverycard','globalcard')); + /* * Actions */ + $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -245,9 +244,16 @@ if ($action == 'update_extras_line') } +// Actions to build doc +$upload_dir = $conf->expedition->dir_output.'/receipt'; +$permissioncreate = $user->rights->expedition->creer; +include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + + /* * Build document */ +/* if ($action == 'builddoc') // En get ou en post { // Save last template used to generate document @@ -283,6 +289,7 @@ elseif ($action == 'remove_file') if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } +*/ /* From 7f704231fecbeccc520606cd014ad4e88202c073 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 14:20:05 +0200 Subject: [PATCH 594/609] Fix migration script --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 2e5395cb714..a57e02455cc 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -470,6 +470,6 @@ ALTER TABLE llx_accounting_journal ADD UNIQUE INDEX uk_accounting_journal_code ( UPDATE llx_c_email_templates SET lang = '' WHERE lang IS NULL; -- Warehouse -ALTER TABLE `llx_entrepot` ADD `model_pdf` VARCHAR(255) AFTER `fk_user_author`; -ALTER TABLE `llx_stock_mouvement` ADD `model_pdf` VARCHAR(255) AFTER `origintype`; +ALTER TABLE llx_entrepot ADD COLUMN model_pdf VARCHAR(255) AFTER fk_user_author; +ALTER TABLE llx_stock_mouvement ADD COLUMN model_pdf VARCHAR(255) AFTER origintype; From 9315d9c423ee9b4ffbbee194ffbf399f5886f132 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 May 2018 18:56:21 +0200 Subject: [PATCH 595/609] NEW Introduce permission "approve" for "leave request" like for "expense report" --- htdocs/core/modules/modHoliday.class.php | 19 +++++++---- htdocs/expensereport/card.php | 2 ++ htdocs/holiday/card.php | 28 +++++++++++++--- htdocs/holiday/class/holiday.class.php | 42 ++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 3fd056b525e..e60be690ce4 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -108,42 +108,49 @@ class modHoliday extends DolibarrModules $r=0; $this->rights[$r][0] = 20001; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read your own holidays'; // Permission label + $this->rights[$r][1] = 'Read your own leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20002; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify your own holidays'; // Permission label + $this->rights[$r][1] = 'Create/modify your own leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20003; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete holidays'; // Permission label + $this->rights[$r][1] = 'Delete leave requests'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; + $this->rights[$r][0] = 20007; + $this->rights[$r][1] = 'Approve leave requests'; + $this->rights[$r][2] = 'w'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'approve'; + $r++; + $this->rights[$r][0] = 20004; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read holidays for everybody'; // Permission label + $this->rights[$r][1] = 'Read leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'read_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20005; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/modify holidays for everybody'; // Permission label + $this->rights[$r][1] = 'Create/modify leave requests for everybody'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'write_all'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $r++; $this->rights[$r][0] = 20006; // Permission id (must not be already used) - $this->rights[$r][1] = 'Setup holidays of users (setup and update balance)'; // Permission label + $this->rights[$r][1] = 'Setup leave requests of users (setup and update balance)'; // Permission label $this->rights[$r][3] = 0; // Permission by default for new user (0/1) $this->rights[$r][4] = 'define_holiday'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index a2d67d627c0..d17ae2eb095 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1346,6 +1346,7 @@ if ($action == 'create') print ''; print '
'; + // User for expense report print ''; print ''; print ''; print ''; + // Approver print ''; print ''; print '\n"; - // Array Data - $var=true; - if (count($name)) { foreach($name as $key=>$value) { print ''; // Product + print "\n"; + print $linkname; + print "\n"; // Quantity print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; - print ''; + print ''; print ''; $db->free($result); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index ed36d677df9..5c1e8cc4db7 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -90,8 +90,8 @@ $date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GE // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q=GETPOST("q","int")?GETPOST("q","int"):0; + if (empty($q)) { // We define date_start and date_end $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index ea2d6fa9c03..bb5cb25e30d 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -565,7 +565,7 @@ print ''; $i++; } - print ""; + print ""; } $db->free($resql); } @@ -614,7 +614,7 @@ print ''; $i++; } - print ""; + print ""; } $db->free($resql); } @@ -622,7 +622,7 @@ print ''; { dol_print_error($db); } - print ""; + print ""; } print "
'.$langs->trans("MAIN_PROXY_HOST").''; print ''; @@ -172,7 +169,7 @@ print '
'.$langs->trans("MAIN_PROXY_PORT").''; print ''; @@ -181,7 +178,7 @@ print '
'.$langs->trans("MAIN_PROXY_USER").''; print ''; @@ -190,7 +187,7 @@ print '
'.$langs->trans("MAIN_PROXY_PASS").''; print ''; From d766cb66b8814588abce4393a20f6b7b56263a8c Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 16:14:41 +0100 Subject: [PATCH 543/609] Overload styles files from a current folder of module & theme --- htdocs/main.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e20451e2415..bd803febe5f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1235,10 +1235,10 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs if (! empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) print ''."\n".''."\n"; //Overload css files to the current theme - // Check if the /theme/nameoftheme/style folder exists and Add the contains css files to head + // Check if the /theme/nameoftheme/style folder exists and add the contains css files to head if (file_exists(dirname(dol_buildpath($conf->css, 0))."/style")) { - //browse the css dir and add the contains css files + //browse the style dir and add the contains css files if ($handle = opendir(dirname(dol_buildpath($conf->css, 0))."/style")) { while (false !== ($entry = readdir($handle))) @@ -1254,7 +1254,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs } //Overload css files to the current module - // Check if the /module/style folder exists and Add the contains css files to head + // Check if the /module/style folder exists and add the contains css files to head $cur_modulepart = explode("/",$_SERVER["PHP_SELF"]); if(is_array($cur_modulepart) && count($cur_modulepart)>0) { From 8e2844b29547a0dd232177c2e299446ff5dac2e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 17:55:29 +0200 Subject: [PATCH 544/609] css --- htdocs/projet/ganttview.php | 2 +- htdocs/projet/tasks.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 248eb1a63b3..2f43701c73d 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -209,7 +209,7 @@ else $linktocreatetask = ''.$langs->trans('AddTask').''; } -$linktolist=''.$langs->trans("GoToListOfTasks").' '; +$linktolist=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title, $linktolist.'   '.$linktocreatetask, 'title_generic.png'); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 22fe740a63b..69c62416e9b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -488,7 +488,7 @@ else if ($id > 0 || ! empty($ref)) print ''; $title=$langs->trans("ListOfTasks"); - $linktotasks=''.$langs->trans("GoToGanttView").' '; + $linktotasks=''.$langs->trans("GoToGanttView").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'title_generic.png'); From 06bad22b31136e8c938aee6ac37bfda8b37f8f31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 18:12:18 +0200 Subject: [PATCH 545/609] FIX function not found --- htdocs/product/class/product.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2f36fd59035..f2c59f95925 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3514,6 +3514,7 @@ class Product extends CommonObject } if (! empty($conf->accounting->enabled) && $this->status_buy) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label.= '
' . $langs->trans('ProductAccountancyBuyCode') . ': '. length_accountg($this->accountancy_code_buy); } if (! empty($this->entity)) From 634e58b7c97a3d48ac8559eb801fa95b1b81ce60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 May 2018 18:12:18 +0200 Subject: [PATCH 546/609] Look and feel v8 --- htdocs/admin/agenda_reminder.php | 6 +----- htdocs/product/class/product.class.php | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index fac49dcfcde..76b69073f25 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -29,9 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("other"); -$langs->load("agenda"); +$langs->loadLangs(array("admin","other","agenda")); $action = GETPOST('action','alpha'); $value = GETPOST('value','alpha'); @@ -173,8 +171,6 @@ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup'); -print "
\n"; - diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2f36fd59035..f2c59f95925 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3514,6 +3514,7 @@ class Product extends CommonObject } if (! empty($conf->accounting->enabled) && $this->status_buy) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label.= '
' . $langs->trans('ProductAccountancyBuyCode') . ': '. length_accountg($this->accountancy_code_buy); } if (! empty($this->entity)) From e34bd1a2228443faa0f45884669b37e87b237c73 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 18:08:04 +0100 Subject: [PATCH 547/609] Update llx_entrepot add model_pdf --- htdocs/install/mysql/tables/llx_entrepot.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index cfb17c55766..4c6f0480d5a 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -34,6 +34,7 @@ create table llx_entrepot fk_pays integer DEFAULT 0, statut tinyint DEFAULT 1, -- 1 open, 0 close fk_user_author integer, - import_key varchar(14), + model_pdf varchar(255), + import_key varchar(14), fk_parent integer DEFAULT 0 )ENGINE=innodb; From 468f970d32a41150ffd03117f1dc89b6650fe3b7 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 18:10:55 +0100 Subject: [PATCH 548/609] Update llx_stock_mouvement Add model_pdf --- htdocs/install/mysql/tables/llx_stock_mouvement.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_stock_mouvement.sql b/htdocs/install/mysql/tables/llx_stock_mouvement.sql index 3ac42c0c852..1e78e7a9820 100644 --- a/htdocs/install/mysql/tables/llx_stock_mouvement.sql +++ b/htdocs/install/mysql/tables/llx_stock_mouvement.sql @@ -34,5 +34,6 @@ create table llx_stock_mouvement label varchar(255), -- Comment on movement inventorycode varchar(128), -- Code used to group different movement line into one operation (may be an inventory, a mass picking) fk_origin integer, - origintype varchar(32) + origintype varchar(32), + model_pdf varchar(255) )ENGINE=innodb; From 1b2dbedd154b6e1849985294b3fba8f31aefc9d6 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 4 May 2018 22:06:44 +0100 Subject: [PATCH 549/609] Add models pdf to warehouse module - Warehouse report - Mouvement report From f6ca1eb6248e022288a32d25a1c0fa9c53cda556 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:24:46 +0200 Subject: [PATCH 550/609] Fix permission name --- htdocs/core/menus/standard/eldy.lib.php | 24 ++++++++++++------------ htdocs/core/modules/modStock.class.php | 10 +++++----- htdocs/product/inventory/card.php | 6 +++--- htdocs/product/inventory/list.php | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e930a0ab8b9..171c2a52f8d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1257,18 +1257,18 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->stock->enabled)) { $langs->load("stocks"); - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) - { - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); - } - else - { - $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->advance_inventory->read, '', $mainmenu, 'stock'); - $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->advance_inventory->write); - $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->advance_inventory->read); - } + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) + { + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->lire, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->creer); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->lire); + } + else + { + $newmenu->add("/product/inventory/list.php?leftmenu=stock", $langs->trans("Inventory"), 0, $user->rights->stock->inventory_advance->read, '', $mainmenu, 'stock'); + $newmenu->add("/product/inventory/card.php?action=create", $langs->trans("NewInventory"), 1, $user->rights->stock->inventory_advance->write); + $newmenu->add("/product/inventory/list.php", $langs->trans("List"), 1, $user->rights->stock->inventory_advance->read); + } } } diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index c23a02eeac1..daeb948fe4a 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -122,31 +122,31 @@ class modStock extends DolibarrModules $this->rights[5][0] = 1011; $this->rights[5][1] = 'inventoryReadPermission'; // Permission label $this->rights[5][3] = 0; // Permission by default for new user (0/1) - $this->rights[5][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[6][0] = 1012; $this->rights[6][1] = 'inventoryCreatePermission'; // Permission label $this->rights[6][3] = 0; // Permission by default for new user (0/1) - $this->rights[6][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[6][5] = 'create'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[7][0] = 1013; $this->rights[7][1] = 'inventoryWritePermission'; // Permission label $this->rights[7][3] = 0; // Permission by default for new user (0/1) - $this->rights[7][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[7][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[7][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[8][0] = 1014; $this->rights[8][1] = 'inventoryValidatePermission'; // Permission label $this->rights[8][3] = 0; // Permission by default for new user (0/1) - $this->rights[8][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[9][0] = 1015; $this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label $this->rights[9][3] = 0; // Permission by default for new user (0/1) - $this->rights[9][4] = 'advance_inventory'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) + $this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) $this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) } diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 30bb3312576..aaba9e8cdfe 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -42,7 +42,7 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $result = restrictedArea($user, 'stock', $id, '', 'advance_inventory'); + $result = restrictedArea($user, 'stock', $id, '', 'inventory_advance'); } // Initialize technical objects @@ -82,8 +82,8 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $permissiontoadd = $user->rights->stock->advance_inventory->create; - $permissiontodelete = $user->rights->stock->advance_inventory->write; + $permissiontoadd = $user->rights->stock->inventory_advance->create; + $permissiontodelete = $user->rights->stock->inventory_advance->write; } diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index f3089099efe..79f0835e991 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -78,7 +78,7 @@ if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) } else { - $result = restrictedArea($user, 'stock', $objectid, '', 'advance_inventory'); + $result = restrictedArea($user, 'stock', $objectid, '', 'inventory_advance'); } // Initialize array of search criterias From a9c7f905121083354b7b04d4a300c9be87a40c4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:36:20 +0200 Subject: [PATCH 551/609] Missing hook after deprecated trigger --- htdocs/user/logout.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/user/logout.php b/htdocs/user/logout.php index 5958c71f295..ceeaf35fddf 100644 --- a/htdocs/user/logout.php +++ b/htdocs/user/logout.php @@ -48,6 +48,13 @@ $result=$interface->run_triggers('USER_LOGOUT',$user,$user,$langs,$conf); if ($result < 0) { $error++; } // Fin appel triggers +// Hooks on logout +$action=''; +$hookmanager->initHooks(array('logout')); +$parameters=array(); +$reshook=$hookmanager->executeHooks('afterLogout',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { $error++; } + // Define url to go after disconnect $urlfrom=empty($_SESSION["urlfrom"])?'':$_SESSION["urlfrom"]; From bdf4c0704b52c306cf75972573eb8ae3a514ef83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:40:45 +0200 Subject: [PATCH 552/609] Removed depreaceted not used method Categorie::get_nb_categories() --- ChangeLog | 2 +- htdocs/categories/class/categorie.class.php | 24 --------------------- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 19ab1e0f49b..b800098144b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,7 +21,7 @@ Following changes may create regressions for some external modules, but were nec * Removed method fetch_prods() and get_each_prod() not used, keep only get_arbo_each_prod() that is better. * The hook contaxt commcard has been renamed thirdpartycomm * The hook contaxt thirdpartycard has been renamed thirdpartycontact - +* Remove method Categorie:get_nb_categories() that was not used. ***** ChangeLog for 7.0.1 compared to 7.0.0 ***** FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5fa8d267830..0f28a8d1cde 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1207,30 +1207,6 @@ class Categorie extends CommonObject } } - /** - * Returns total number of categories - * - * @return int Number of categories - * @deprecated function not used ? - */ - function get_nb_categories() - { - $sql = "SELECT count(rowid)"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; - $sql.= " WHERE entity IN (".getEntity('category').")"; - $res = $this->db->query($sql); - if ($res) - { - $res = $this->db->fetch_array($res); - return $res[0]; - } - else - { - dol_print_error($this->db); - return -1; - } - } - /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * From 363eaf0d72196120bb9af4ff96f97cccbb71a6c6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 13:44:49 +0200 Subject: [PATCH 553/609] FIX Parameters to triggers must be set into $this->context array. --- htdocs/categories/class/categorie.class.php | 6 ++---- ...interface_50_modMailmanspip_Mailmanspipsynchro.class.php | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 0f28a8d1cde..044f3e68c0f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -761,11 +761,9 @@ class Categorie extends CommonObject dol_syslog(get_class($this).'::del_type', LOG_DEBUG); if ($this->db->query($sql)) { - // Save object we want to unlink category off into category instance to provide information to trigger - $this->unlinkoff=$obj; - // Call trigger - $result=$this->call_trigger('CATEGORY_UNLINK',$user); + $this->context=array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result=$this->call_trigger('CATEGORY_UNLINK',$user); if ($result < 0) { $error++; } // End call triggers diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index 44a6645a6d7..c5f704fdcb1 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -75,10 +75,10 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); // We remove subscription if we change category (lessw category may means less mailing-list to subscribe) - if (is_object($object->unlinkoff) && method_exists($object->unlinkoff, 'del_to_abo') && $object->unlinkoff->del_to_abo() < 0) + if (is_object($object->context['unlinkoff']) && method_exists($object->context['unlinkoff'], 'del_to_abo') && $object->context['unlinkoff']->del_to_abo() < 0) { - $this->error=$object->unlinkoff->error; - $this->errors=$object->unlinkoff->errors; + $this->error=$object->context['unlinkoff']->error; + $this->errors=$object->context['unlinkoff']->errors; $return=-1; } else From 17b8de2cdd420a33629c2ee8848e5397a8bcce6d Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Sat, 5 May 2018 12:52:38 +0100 Subject: [PATCH 554/609] New : Option INVOICE_CAN_REMOVE_DRAFT_ONLY to delete draft invoices with precedence over INVOICE_CAN_ALWAYS_BE_REMOVED --- htdocs/compta/facture/list.php | 34 ++++++++++++------------- htdocs/core/actions_massactions.inc.php | 28 +++++++------------- htdocs/core/tpl/massactions_pre.tpl.php | 5 ++++ htdocs/langs/en_US/main.lang | 4 ++- htdocs/langs/fr_FR/main.lang | 2 ++ 5 files changed, 35 insertions(+), 38 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 29a98c0541b..c90ab660c31 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -585,24 +585,22 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); - if ($conf->prelevement->enabled) - { - $langs->load("withdrawals"); - $arrayofmassactions['withdrawrequest']=$langs->trans("MakeWithdrawRequest"); - } - if ($user->rights->facture->supprimer) - { - //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - { - // mass deletion never possible on invoices on such situation - } - else - { - $arrayofmassactions['predelete']=$langs->trans("Delete"); - } - } - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); + if ($conf->prelevement->enabled) { + $langs->load("withdrawals"); + $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); + } + if ($user->rights->facture->supprimer) { + //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) + if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); + + } + elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { + // mass deletion never possible on invoices on such situation + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index c2c3467e55c..1952bb0c224 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1079,26 +1079,16 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == $result=$objecttmp->fetch($toselectid); if ($result > 0) { - // Refuse deletion for some status ? - /* - if ($objectclass == 'Facture' && $objecttmp->status == Facture::STATUS_DRAFT) - { - $langs->load("errors"); - $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; - continue; - }*/ + if ($objectclass != 'Facture' || empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) || (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) && $objecttmp->statut == Facture::STATUS_DRAFT) ) { + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + else $result = $objecttmp->delete($user); - if (in_array($objecttmp->element, array('societe','member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); - - if ($result <= 0) - { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } - else $nbok++; + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; + } } else { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 48989b2daec..d46e27e28af 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -27,6 +27,11 @@ // $trackid='ord'.$object->id; +if ($massaction == 'predeletedraft') +{ + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDraftDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); +} + if ($massaction == 'predelete') { print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 418042f1da9..60369b80ea5 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -941,4 +941,6 @@ Local=Local Remote=Remote LocalAndRemote=Local and Remote KeyboardShortcut=Keyboard shortcut -AssignedTo=Assigned to \ No newline at end of file +AssignedTo=Assigned to +Deletedraft=Delete draft +ConfirmMassDraftDeletion=Draft Bulk delete confirmation diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index e8681e72e62..6fba224525e 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -941,3 +941,5 @@ Remote=Distant LocalAndRemote=Local et distant KeyboardShortcut=Raccourci clavier AssignedTo=Assigné à +Deletedraft=Supprimer brouillon +ConfirmMassDraftDeletion=Confirmation de suppression brouillons en masse From aba2ef7ad290b239dc87324625c611874bebc0c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 14:22:18 +0200 Subject: [PATCH 555/609] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 26 ++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 1952bb0c224..e1d862b6098 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1079,16 +1079,24 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == $result=$objecttmp->fetch($toselectid); if ($result > 0) { - if ($objectclass != 'Facture' || empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) || (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY) && $objecttmp->statut == Facture::STATUS_DRAFT) ) { - if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); + // Refuse deletion for some objects/status + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT)) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; + continue; + } + + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); + else $result = $objecttmp->delete($user); + + if ($result <= 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + break; + } else $nbok++; - if ($result <= 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - $error++; - break; - } else $nbok++; - } } else { From 8baa529719d2352ed98ffadd896b311a665e0a5f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 14:22:52 +0200 Subject: [PATCH 556/609] Update actions_massactions.inc.php --- htdocs/core/actions_massactions.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e1d862b6098..4d2b6145990 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1091,12 +1091,13 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); - if ($result <= 0) { + if ($result <= 0) + { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; - } else $nbok++; - + } + else $nbok++; } else { From 97f161b2763767ae376760f2e4922a8e65c85150 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 14:25:44 +0200 Subject: [PATCH 557/609] Update list.php --- htdocs/compta/facture/list.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c90ab660c31..b6bde6605ad 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -585,22 +585,19 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); - if ($conf->prelevement->enabled) { - $langs->load("withdrawals"); - $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); - } - if ($user->rights->facture->supprimer) { - //if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) - if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { - $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); - - } - elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { - // mass deletion never possible on invoices on such situation - $arrayofmassactions['predelete'] = $langs->trans("Delete"); - } - } - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if ($conf->prelevement->enabled) { + $langs->load("withdrawals"); + $arrayofmassactions['withdrawrequest'] = $langs->trans("MakeWithdrawRequest"); + } + if ($user->rights->facture->supprimer) { + if (!empty($conf->global->INVOICE_CAN_REMOVE_DRAFT_ONLY)) { + $arrayofmassactions['predeletedraft'] = $langs->trans("Deletedraft"); + } + elseif (!empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED)) { // mass deletion never possible on invoices on such situation + $arrayofmassactions['predelete'] = $langs->trans("Delete"); + } + } + if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; From a8ecce9e6d1d8e550833f69c285ebb9ce0f7bc54 Mon Sep 17 00:00:00 2001 From: altatof Date: Sat, 5 May 2018 14:31:17 +0200 Subject: [PATCH 558/609] add hook for more permissions control --- htdocs/core/lib/security.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 4cfc077f0be..15047b2f2d7 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -331,10 +331,17 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu // is linked to a company allowed to $user. if (! empty($objectid) && $objectid > 0) { - $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); - return $ok ? 1 : accessforbidden(); + if (!checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select)) + accessforbidden(); } + // get more permissions checks from hooks + global $hookmanager; + $hookmanager->initHooks(array('permissions')); + $parameters=array('features'=>$features,'objectid'=>preg_replace("/'/", '', $objectid),'idtype'=>$dbt_select); + $reshook=$hookmanager->executeHooks('restricted',$parameters); + if ($reshook < 0) accessforbidden(); + return 1; } From c2696996791a72e05db356035512902a4143bbd4 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sat, 5 May 2018 13:33:34 +0100 Subject: [PATCH 559/609] Add model_pdf to warehouse module --- htdocs/core/modules/modStock.class.php | 83 ++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ca518ed8851..2cb53a52da4 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -60,7 +60,7 @@ class modStock extends DolibarrModules $this->picto='stock'; // Data directories to create when module is enabled - $this->dirs = array(); + $this->dirs = array("/stock/temp"); $this->config_page_url = array("stock.php"); @@ -70,9 +70,38 @@ class modStock extends DolibarrModules $this->langfiles = array("stocks"); // Constants - $this->const = array( - 0=>array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1) - ); + $this->const = array(); + $r=0; + + $this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1); + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "Standard"; + $this->const[$r][3] = 'Name of PDF model of stock'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "StdMouvement"; + $this->const[$r][3] = 'Name of PDF model of stock mouvement'; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "STOCK_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + + $r++; + $this->const[$r][0] = "MOUVEMENT_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/stocks/mouvements"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; // Boxes $this->boxes = array(); @@ -266,4 +295,50 @@ class modStock extends DolibarrModules ); } + + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + function init($options='') + { + global $conf,$langs; + + // Permissions + $this->remove($options); + + //ODT template + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/stock/template_stock.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/stock'; + $dest=$dirodt.'/template_stock.odt'; + + if (file_exists($src) && ! file_exists($dest)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + dol_mkdir($dirodt); + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + } + + $sql = array(); + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'stock' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','stock',".$conf->entity.")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[2][2])."' AND type = 'mouvement' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[2][2])."','mouvement',".$conf->entity.")", + ); + + return $this->_init($sql,$options); + } } From fb81088a4b8b9de12faa7923176c2ba23e3a6e2c Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sat, 5 May 2018 13:44:11 +0100 Subject: [PATCH 560/609] Add models warehouse and movement --- htdocs/core/modules/stock/modules_stock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/stock/modules_stock.class.php b/htdocs/core/modules/stock/modules_stock.class.php index 9af3aa11501..283ae75b6a3 100644 --- a/htdocs/core/modules/stock/modules_stock.class.php +++ b/htdocs/core/modules/stock/modules_stock.class.php @@ -81,7 +81,7 @@ abstract class ModelePDFMouvement extends CommonDocGenerator { global $conf; - $type='mouvementcom'; + $type='mouvement'; $liste=array(); include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $liste=getListOfModels($db,$type,$maxfilenamelength); From c34bfc229b9b90088c0cb183a897f3573aee24fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 19:39:58 +0200 Subject: [PATCH 561/609] Fix syntax error --- htdocs/core/actions_massactions.inc.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4d2b6145990..371dd75a8e2 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1080,18 +1080,18 @@ if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == if ($result > 0) { // Refuse deletion for some objects/status - if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT)) - { - $langs->load("errors"); - $nbignored++; - $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; - continue; - } - + if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) + { + $langs->load("errors"); + $nbignored++; + $resaction.='
'.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction',$objecttmp->ref).'

'; + continue; + } + if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); else $result = $objecttmp->delete($user); - if ($result <= 0) + if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; From b958311819231c32d329e96a9d90bf869d49187b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 20:25:06 +0200 Subject: [PATCH 562/609] Prepare 6.0.7 --- ChangeLog | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dcc363d03a9..405aaa9ed9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,22 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 6.0.6 compared to 6.0.6 ***** +***** ChangeLog for 6.0.7 compared to 6.0.6 ***** +FIX: #8023 +FIX: #8259 can't update contact birthday with REST API +FIX: #8478 !empty instead of count to avoid warning +FIX: #8488 +FIX: actioncomm export: type filtering not working +FIX: addline on invoice supplier manage rank on its own if not provided +FIX: issue #8037 +FIX: label in getnomurl projectlist +FIX: payment term doc-specific label was not used +FIX: payment term doc-specific label was not used (issue #8414) +FIX: project category is type 6 not 5 !! +FIX: some localtaxes errors +FIX: weird password autocompletion in Google Chrome (issue #8479) + +***** ChangeLog for 6.0.6 compared to 6.0.5 ***** FIX: #7974 Contract - Invalid reference on the document FIX: #8139 FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php From d4d4f8cc832785b416cf38952272ee32b15c383f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 20:29:06 +0200 Subject: [PATCH 563/609] Prepare 7.0.2 --- ChangeLog | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3ecdc4d0c54..0a2157316b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,96 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 7.0.2 compared to 7.0.1 ***** +FIX: #8023 +FIX: #8259 can't update contact birthday with REST API +FIX: #8359 +FIX: #8389 +FIX: #8478 !empty instead of count to avoid warning +FIX: #8488 +FIX: #8559 Bug to generate cheque receipt +FIX: #8571 +FIX: #8574 +FIX: #8580 +FIX: #8650 +FIX: actioncomm export: type filtering not working +FIX: Add a test to avoid to reset binding by error. +FIX: addline on invoice supplier manage rank on its own if not provided +FIX: Add warning when expense report line not into range +FIX: avoid Error: Call to undefined method mysqli::get_charset() +FIX: avoid focus problem when select2 is in a modal dialog window +FIX: Binding pages must start on fiscal month not calendar month +FIX: button "Classify bill" on supplier order was not visible +FIX: Button receive products not visible +FIX: can bypass the CSRF protection with url with domain inside +FIX: Can't edit option PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY +FIX: commonobject: don't require notnull field if default set +FIX: CommonObject: don't require 'notnull' field if 'default' set +FIX: cron script disabled if module disabled +FIX: CVE-2018-10092 +FIX: CVE-2018-10094 +FIX: CVE-2018-10095 +FIX: CVE-2018-9019 +FIX: CWE-89 +FIX: Data on income/expense report was always 0 +FIX: default addupdatedelete actions: uniformize add/update value checks +FIX: default currency not set on supplier order creation from commercial menu #8459 +FIX: delete all product variants of a parent product +FIX: Detail per account not visible when total < 0 +FIX: DOL_AUTOSET_COOKIE was not correctly setting value of cookie +FIX: don't print empty date in CommonObject::showOutputField +FIX: dont print empty date in CommonObject::showOutputField +FIX: Draft invoice must be excluded from report +FIX: environment shown on cron card +FIX: Error in ContractLigne not return to Contract +FIX: extrafields price and double were lost during a failed post. +FIX: File name not visible in email preview +FIX: filter/sorting on extrafield on contact list from contact tab +FIX: Initial month on report income/expense per predefined group +FIX: issue #8037 +FIX: Issue #8455 +FIX: issue #8470 +FIX: label in getnomurl projectlist +FIX: limit access of email template page to internal users +FIX: look and feel v7 "back to" for bookkeeping record +FIX: Max nb of generation of recurring invoice should not show warning +FIX: missing english name for object +FIX: Missing include +FIX: missing User object with API REST +FIX: modulebuilder: could not create html fields +FIX: modulebuilder: handle 'price' fieldtype +FIX: multiple creation of same event +FIX: Name of user not visible on journalizing expense report payments +FIX: Not approved holidays must not be visible into timesheet +FIX: Only approved expense report must be journalized +FIX: payment term doc-specific label was not used +FIX: payment term doc-specific label was not used (issue #8414) +FIX: project category is type 6 not 5 +FIX: Projet is not prefilled when created from overwiew page +FIX: Related contact printed in societe agenda +FIX: Removed error when no error on accounting setup page +FIX: remove var_dump +FIX: sanitize setup params +FIX: selectForFormsList: entity checked even is object not multi-entity managed +FIX: service creation, right is tested regarding the product type +FIX: some localtaxes errors +FIX: Some report have data when several chart of accounts exists +FIX: sql error using no category +FIX: SQL Injection CWE-89 +FIX: Support or multicompany for sheduled jobs +FIX: Test on mandatory status when closing proposal failed +FIX: to allow IRPF not null even if main VAT is null. +FIX: update wrong datetime extrafield +FIX: Use priority to define order of sheduled jobs +FIX: various modulebuilder-related issues +FIX: view of balance before field +FIX: weird password autocompletion in Goocle Chrome (issue #8479) +FIX: weird password autocompletion in Google Chrome (issue #8479) +FIX: When clearing filter, we must not save tmp criterias in session +FIX: With x extrafields, request for multicompany label was done x times +FIX: several XSS +FIX: zip not filtered + ***** ChangeLog for 7.0.1 compared to 7.0.0 ***** FIX: #8139 User search does not work if MAIN_USE_OLD_SEARCH_FORM, missing list.php FIX: #8200 From f76df85aec7a18ce137e8f1ef6d9e8629cc93194 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 21:53:02 +0200 Subject: [PATCH 564/609] compatibility with ubuntu 14.04 --- build/makepack-dolibarr.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 7da6d180dcb..62e1b8b6c34 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -849,6 +849,8 @@ if ($nboftargetok) { unlink("$NEWDESTI/${FILENAMEDEB}.changes"); print "Remove target ${FILENAMEDEB}.debian.tar.gz...\n"; unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.gz"); + print "Remove target ${FILENAMEDEB}.debian.tar.xz...\n"; + unlink("$NEWDESTI/${FILENAMEDEB}.debian.tar.xz"); print "Remove target ${FILENAMEDEBNATIVE}.orig.tar.gz...\n"; unlink("$NEWDESTI/${FILENAMEDEBNATIVE}.orig.tar.gz"); @@ -1024,7 +1026,8 @@ if ($nboftargetok) { $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.orig.tar.gz "$NEWDESTI/"`; - $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/"`; + $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/" 2>/dev/null`; + $ret=`mv $BUILDROOT/*.debian.tar.xz "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.changes "$NEWDESTI/"`; next; } From 19008531bba77484b3fbbe1fefdc5eaf81efffbe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 21:56:34 +0200 Subject: [PATCH 565/609] Fix packager --- build/makepack-dolibarr.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 62e1b8b6c34..31338e44649 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -466,10 +466,12 @@ if ($nboftargetok) { $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.dsc`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.tar.gz`; + $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr_*.tar.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.deb`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.rpm`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar.gz`; + $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tar.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.tgz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.xz`; $ret=`rm -f $BUILDROOT/$PROJECT/build/dolibarr-*.zip`; @@ -1026,7 +1028,6 @@ if ($nboftargetok) { $ret=`mv $BUILDROOT/*_all.deb "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.dsc "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.orig.tar.gz "$NEWDESTI/"`; - $ret=`mv $BUILDROOT/*.debian.tar.gz "$NEWDESTI/" 2>/dev/null`; $ret=`mv $BUILDROOT/*.debian.tar.xz "$NEWDESTI/"`; $ret=`mv $BUILDROOT/*.changes "$NEWDESTI/"`; next; @@ -1171,7 +1172,7 @@ if ($nboftargetok) { "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'Dolibarr installer for Debian-Ubuntu (DoliDeb)', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'none', # none means it won't be published on SF - "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'none', # none means it won't be published on SF + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.xz"=>'none', # none means it won't be published on SF "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'none', # none means it won't be published on SF "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'Dolibarr installer for Windows (DoliWamp)', "$DESTI/standard/$FILENAMETGZ.tgz"=>'Dolibarr ERP-CRM', @@ -1184,8 +1185,7 @@ if ($nboftargetok) { "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_all.deb"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}_amd64.changes"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.dsc"=>'package_debian-ubuntu', - "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.gz"=>'package_debian-ubuntu', - "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', + "$DESTI/package_debian-ubuntu/${FILENAMEDEB}.debian.tar.xz"=>'package_debian-ubuntu', "$DESTI/package_debian-ubuntu/${FILENAMEDEBSHORT}.orig.tar.gz"=>'package_debian-ubuntu', "$DESTI/package_windows/$FILENAMEEXEDOLIWAMP.exe"=>'package_windows', "$DESTI/standard/$FILENAMETGZ.tgz"=>'standard', From f15da0b980f8c3ed6862d45a654f0ba8ccbe8acf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 22:15:19 +0200 Subject: [PATCH 566/609] Fix chart of account initial data for syscohada --- .../install/mysql/migration/6.0.0-7.0.0.sql | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index efb47ede029..cf0a8c8cc49 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -577,21 +577,21 @@ ALTER TABLE llx_c_email_senderprofile ADD UNIQUE INDEX uk_c_email_senderprofile( -- Add new chart of account entries INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 67,'PC-MIPYME', 'The PYME accountancy Chile plan', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 7,'ENG-BASE', 'England plan', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); -INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA-BJ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA-BF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA-CM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA-CF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA-KM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA-CG', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA-CI', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA-GA', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA-GQ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA-ML', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA-NE', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA-CD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA-SN', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA-TD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA-TG', 'Plan comptable Ouest-Africain', 1); -- Update old chart of account entries From 7511ba52ae301ca0cfdc1845b6c131a625a13673 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 22:20:33 +0200 Subject: [PATCH 567/609] NEW Suggest link to pay online for customer orders --- htdocs/commande/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d399c83131c..57b98d1a29a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2613,9 +2613,8 @@ if ($action == 'create' && $user->rights->commande->creer) $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); // Show online payment link - //$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); - $useonlinepayment = $conf->global->ORDER_SHOW_ONLINE_PAYMENT_ON_ORDER; - + $useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled)); + if (! empty($conf->global->ORDER_HIDE_ONLINE_PAYMENT_ON_ORDER)) $useonlinepayment = 0; if ($object->statut != Commande::STATUS_DRAFT && $useonlinepayment) { print '
'; From fd53788d2f657064efad986eb2778b0b1a52715c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 22:54:22 +0200 Subject: [PATCH 568/609] Add param autostable into generate_filelist_xml.php --- build/generate_filelist_xml.php | 37 +++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 5f54c95d7e0..86afcd286f9 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -45,7 +45,7 @@ $includeconstants=array(); if (empty($argv[1])) { - print "Usage: ".$script_file." release=auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + print "Usage: ".$script_file." release=autostable|auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n"; exit -1; } @@ -68,29 +68,44 @@ while ($i < $argc) $i++; } +$savrelease = $release; + // If release is auto, we take current version $tmpver=explode('-', $release, 2); -if ($tmpver[0] == 'auto') +if ($tmpver[0] == 'auto' || $tmpver[0] == 'autostable') { $release=DOL_VERSION; - if ($tmpver[1]) $release.='-'.$tmpver[1]; + if ($tmpver[1] && $tmpver[0] == 'auto') $release.='-'.$tmpver[1]; } if (empty($includecustom)) { - $tmpver=explode('-', $release, 2); - if (DOL_VERSION != $tmpver[0]) - { - print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpver[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; - exit -1; - } + $tmpverbis=explode('-', $release, 2); + if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') + { + if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') + { + print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; + print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + exit -1; + } + } + else + { + $tmpverter=explode('-', DOL_VERSION, 2); + if ($tmpverter[0] != $tmpverbis[0]) + { + print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; + print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + exit -1; + } + } } else { if (! preg_match('/'.preg_quote(DOL_VERSION,'/').'-/',$release)) { - print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parmater (ex: '.DOL_VERSION.'-mydistrib).'."\n"; + print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n"; print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; exit -1; } From 8e729c2021f885274e7be81cf32e73897baa907b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 23:12:31 +0200 Subject: [PATCH 569/609] Add param autostable into generate_filelist_xml.php --- build/generate_filelist_xml.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 86afcd286f9..93ee76e3359 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -45,7 +45,7 @@ $includeconstants=array(); if (empty($argv[1])) { - print "Usage: ".$script_file." release=autostable|auto|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n"; exit -1; } @@ -68,6 +68,13 @@ while ($i < $argc) $i++; } +if (empty($release)) +{ + print "Error: Missing release paramater\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; + exit -1; +} + $savrelease = $release; // If release is auto, we take current version @@ -86,7 +93,7 @@ if (empty($includecustom)) if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') { print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } @@ -96,7 +103,7 @@ if (empty($includecustom)) if ($tmpverter[0] != $tmpverbis[0]) { print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } @@ -106,7 +113,7 @@ else if (! preg_match('/'.preg_quote(DOL_VERSION,'/').'-/',$release)) { print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n"; - print "Usage: ".$script_file." release=x.y.z[-...] [includecustom=1]\n"; + print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n"; exit -1; } } From a84217868923b1c38e774483bf4bacb800431145 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 May 2018 23:20:53 +0200 Subject: [PATCH 570/609] Fix migration missing steps --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 3ca87e97053..055a38a36b7 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -59,6 +59,24 @@ INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUE INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 10, 'PCT', 'The Tunisia plan', 1); INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 12, 'PCG', 'The Moroccan chart of accounts', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 67,'PC-MIPYME', 'The PYME accountancy Chile plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 7,'ENG-BASE', 'England plan', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 49,'SYSCOHADA-BJ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 60,'SYSCOHADA-BF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 24,'SYSCOHADA-CM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 65,'SYSCOHADA-CF', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 71,'SYSCOHADA-KM', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 72,'SYSCOHADA-CG', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 21,'SYSCOHADA-CI', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 16,'SYSCOHADA-GA', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 87,'SYSCOHADA-GQ', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (147,'SYSCOHADA-ML', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES (168,'SYSCOHADA-NE', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 73,'SYSCOHADA-CD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 22,'SYSCOHADA-SN', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 66,'SYSCOHADA-TD', 'Plan comptable Ouest-Africain', 1); +INSERT INTO llx_accounting_system (fk_country, pcg_version, label, active) VALUES ( 15,'SYSCOHADA-TG', 'Plan comptable Ouest-Africain', 1); + -- For 8.0 -- delete old permission no more used From a2c93e56aef79e40ec0d35ccc3987442bba7178c Mon Sep 17 00:00:00 2001 From: delcroix Patrick Date: Sun, 6 May 2018 13:36:37 +0200 Subject: [PATCH 571/609] fixAdd properly the project models Previous code was adding only the Task model (project model where actually push during the installation) and only one of the two model available. --- htdocs/core/modules/modProjet.class.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index ab837803349..d38fc743de1 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -352,15 +352,14 @@ class modProjet extends DolibarrModules } } - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'project' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','project',".$conf->entity.")", - ); - - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")" - ); + $sql = array(); + $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[3][2])."' AND type = 'task' AND entity = ".$conf->entity; + $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[3][2])."','task',".$conf->entity.")"; + $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'beluga' AND type = 'project' AND entity = ".$conf->entity; + $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")"; + $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity; + $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")"; + return $this->_init($sql,$options); } From 5ac2b515174d2b5825e686db777c85947fc4da66 Mon Sep 17 00:00:00 2001 From: delcroix Patrick Date: Sun, 6 May 2018 17:29:30 +0200 Subject: [PATCH 572/609] new: log message for missing traduction It's often difficult to find out the missing translation --- htdocs/core/class/translate.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 0df169a3c3e..ec3ed00a313 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -576,6 +576,7 @@ class Translate // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } + dol_syslog(__METHOD__."missing translation ".$newstr." in ".$_SERVER["PHP_SELF"], LOG_DEBUG); return $newstr; } From c90d0e6cb35a6b4dd084708a4f727fd2d1a28591 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sun, 6 May 2018 17:30:54 +0100 Subject: [PATCH 573/609] Add pdf warehouse to warehouse module From e733ea29791c2c26c7ea96400399a4e6502a3780 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Sun, 6 May 2018 17:54:59 +0100 Subject: [PATCH 574/609] Revert "Add models pdf to warehouse module" From de8bd3f8868aa3b72f4d4e00b29b46bdea455c20 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 7 May 2018 08:31:40 +0100 Subject: [PATCH 575/609] New : Translate accountancy journal menu entries --- htdocs/core/menus/standard/eldy.lib.php | 3 ++- htdocs/install/mysql/data/llx_accounting_abc.sql | 14 +++++++------- htdocs/langs/en_US/accountancy.lang | 5 ++++- htdocs/langs/fr_FR/accountancy.lang | 4 +++- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3d05ac3ceb3..4d3951f7b5e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1069,7 +1069,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($nature) { - $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, dol_trunc($objp->label,25), 2, $user->rights->accounting->comptarapport->lire); + $langs->load('accountancy'); + $newmenu->add('/accountancy/journal/'.$nature.'journal.php?mainmenu=accountancy&leftmenu=accountancy_journal&id_journal='.$objp->rowid, $langs->trans($objp->label), 2, $user->rights->accounting->comptarapport->lire); } $i++; } diff --git a/htdocs/install/mysql/data/llx_accounting_abc.sql b/htdocs/install/mysql/data/llx_accounting_abc.sql index 6345768e6a8..e80de82b6ad 100644 --- a/htdocs/install/mysql/data/llx_accounting_abc.sql +++ b/htdocs/install/mysql/data/llx_accounting_abc.sql @@ -29,13 +29,13 @@ -- -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'Sale Journal', 2, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'Purchase Journal', 3, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'Bank Journal', 4, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'Other Journal', 1, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'Has new Journal', 9, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'Expense Report Journal', 5, 1, 1); -INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'Inventory Journal' , 8, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('VT', 'ACCOUNTING_SELL_JOURNAL', 2, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AC', 'ACCOUNTING_PURCHASE_JOURNAL', 3, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('BQ', 'FinanceJournal', 4, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('OD', 'ACCOUNTING_MISCELLANEOUS_JOURNAL', 1, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('AN', 'ACCOUNTING_HAS_NEW_JOURNAL', 9, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('ER', 'ExpenseReportsJournal', 5, 1, 1); +INSERT INTO llx_accounting_journal (code, label, nature, active, entity) VALUES ('INV', 'InventoryJournal' , 8, 1, 1); -- Description of chart of account FR PCG99-ABREGE diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index f3acb7ac39c..a7b7e345682 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -137,6 +137,7 @@ ACCOUNTING_PURCHASE_JOURNAL=Purchase journal ACCOUNTING_MISCELLANEOUS_JOURNAL=Miscellaneous journal ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal ACCOUNTING_SOCIAL_JOURNAL=Social journal +ACCOUNTING_HAS_NEW_JOURNAL=Has new Journal ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transfer ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait @@ -294,4 +295,6 @@ Binded=Lines bound ToBind=Lines to bind UseMenuToSetBindindManualy=Autodection not possible, use menu %s to make the binding manually -WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. +WarningReportNotReliable=Warning, this report is not based on the Ledger, so does not contains transaction modified manualy in the Ledger. If your journalization is up to date, the bookkeeping view is more accurate. +ExpenseReportJournal=Expense Report Journal +InventoryJournal=Inventory Journal diff --git a/htdocs/langs/fr_FR/accountancy.lang b/htdocs/langs/fr_FR/accountancy.lang index 0bb7e235410..2ff8dc59dd9 100644 --- a/htdocs/langs/fr_FR/accountancy.lang +++ b/htdocs/langs/fr_FR/accountancy.lang @@ -133,9 +133,10 @@ BANK_DISABLE_DIRECT_INPUT=Désactiver la saisie directe de transactions en banqu ACCOUNTING_SELL_JOURNAL=Journal des ventes ACCOUNTING_PURCHASE_JOURNAL=Journal des achats -ACCOUNTING_MISCELLANEOUS_JOURNAL=Journal des opérations diverses +ACCOUNTING_MISCELLANEOUS_JOURNAL=Journal des ops. diverses ACCOUNTING_EXPENSEREPORT_JOURNAL=Journal des notes de frais ACCOUNTING_SOCIAL_JOURNAL=Journal de paie +ACCOUNTING_HAS_NEW_JOURNAL=Journal d'ouverture ACCOUNTING_ACCOUNT_TRANSFER_CASH=Compte comptable de tranfert ACCOUNTING_ACCOUNT_SUSPENSE=Compte comptable d'attente @@ -294,3 +295,4 @@ ToBind=Lignes à lier UseMenuToSetBindindManualy=L'autodection n'est pas possible, utilisez le menu %s pour effectuer la liaison manuellement WarningReportNotReliable=Attention : ce rapport n'est pas basé sur le grand livre et ne contient donc pas les écritures manuelles qui lui ont été ajoutées. Si votre journalisation est à jour, la vue depuis le grand livre sera plus précise. +InventoryJournal=Journal d'inventaire From fd9b6365a76883b487870225d36df6a90c06e038 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Mon, 7 May 2018 09:19:45 +0100 Subject: [PATCH 576/609] New : Translate list element in journal selection --- htdocs/core/class/html.formaccounting.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index 18cf165e641..17e437f5223 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -64,7 +64,7 @@ class FormAccounting extends Form */ function select_journal($selectid, $htmlname = 'journal', $nature=0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss='maxwidth300 maxwidthonsmartphone', $usecache='', $disabledajaxcombo=0) { - global $conf; + global $conf,$langs; $out = ''; @@ -93,9 +93,10 @@ class FormAccounting extends Form } $selected = 0; + $langs->load('accountancy'); while ($obj = $this->db->fetch_object($resql)) { - $label = $obj->code . ' - ' . $obj->label; + $label = $obj->code . ' - ' . $langs->trans($obj->label); $select_value_in = $obj->rowid; $select_value_out = $obj->rowid; From 5bc9799bf1d48e232cd8b11d430b974264b88331 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 7 May 2018 16:30:22 +0200 Subject: [PATCH 577/609] FIX : Drag and drop lines with extrafields --- htdocs/core/tpl/ajaxrow.tpl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 070eefc0ff0..4ae64ea82ed 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -55,6 +55,7 @@ $(document).ready(function(){ var reloadpage = ""; console.log("tableDND onDrop"); console.log(decodeURI($("#").tableDnDSerialize())); + $('# tr[data-element=extrafield]').attr('id', ''); // Set extrafields id to empty value in order to ignore them in tableDnDSerialize function var roworder = cleanSerialize(decodeURI($("#").tableDnDSerialize())); var table_element_line = ""; var fk_element = ""; From fb9ace010fdb0e07ef0c8cd75f31f7fa4224ec05 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 7 May 2018 17:16:20 +0200 Subject: [PATCH 578/609] FIX : Missing translations --- htdocs/langs/en_US/categories.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 8b38b2f1f42..c0c8d4c0cef 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -85,3 +85,4 @@ CategorieRecursivHelp=If activated, product will also linked to parent category AddProductServiceIntoCategory=Add the following product/service ShowCategory=Show tag/category ByDefaultInList=By default in list +ChooseCategory=Choose category From 415b7425fdbaadf26e24428f508526f395182931 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 8 May 2018 09:45:10 +0200 Subject: [PATCH 579/609] NEW add pdf function to check if pdf file is protected/encrypted --- htdocs/core/lib/pdf.lib.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index e2c01f90f47..b0cda2ecd6a 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -169,6 +169,25 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') return $pdf; } +/** + * Return if pdf file is protected/encrypted + * + * @param TCPDF $pdf PDF initialized object + * @param string $pathoffile Path of file + * @return boolean True or false + */ +function pdf_getEncryption(&$pdf, $pathoffile) +{ + $isencrypted = false; + + $pdfparser = $pdf->_getPdfParser($pathoffile); + $data = $pdfparser->getParsedData(); + if (isset($data[0]['trailer'][1]['/Encrypt'])) { + $isencrypted = true; + } + + return $isencrypted; +} /** * Return font name to use for PDF generation From 70527e64c51be73c1e621b33682cc76c6df5e1b2 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 8 May 2018 18:15:02 +0200 Subject: [PATCH 580/609] New: Add Date delivery and Availability on Propals List --- htdocs/comm/propal/list.php | 102 +++++++++++++++++++++++++- htdocs/core/class/html.form.class.php | 3 +- 2 files changed, 100 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index d5d155ce0bf..ced465dfdb7 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2012 Christophe Battarel * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * Copyright (C) 2017 Charlene Benke * Copyright (C) 2018 Nicolas ZABOURI * @@ -44,7 +44,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; -$langs->loadLangs(array('companies','propal','compta','bills','orders','products')); +$langs->loadLangs(array('companies','propal','compta','bills','orders','products','deliveries')); $socid=GETPOST('socid','int'); @@ -76,6 +76,13 @@ $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); $search_day=GETPOST("search_day","int"); $search_month=GETPOST("search_month","int"); $search_year=GETPOST("search_year","int"); +$search_dayfin=GETPOST("search_dayfin","int"); +$search_monthfin=GETPOST("search_monthfin","int"); +$search_yearfin=GETPOST("search_yearfin","int"); +$search_daydelivery=GETPOST("search_daydelivery","int"); +$search_monthdelivery=GETPOST("search_monthdelivery","int"); +$search_yeardelivery=GETPOST("search_yeardelivery","int"); +$search_availability=GETPOST('search_availability','int'); $search_categ_cus=trim(GETPOST("search_categ_cus",'int')); $viewstatut=GETPOST('viewstatut','alpha'); @@ -145,6 +152,8 @@ $arrayfields=array( 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), 'p.date'=>array('label'=>$langs->trans("Date"), 'checked'=>1), 'p.fin_validite'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1), + 'p.date_livraison'=>array('label'=>$langs->trans("DeliveryDate"), 'checked'=>0), + 'ava.rowid'=>array('label'=>$langs->trans("AvailabilityPeriod"), 'checked'=>0), 'p.total_ht'=>array('label'=>$langs->trans("AmountHT"), 'checked'=>1), 'p.total_vat'=>array('label'=>$langs->trans("AmountVAT"), 'checked'=>0), 'p.total_ttc'=>array('label'=>$langs->trans("AmountTTC"), 'checked'=>0), @@ -202,6 +211,13 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $search_year=''; $search_month=''; $search_day=''; + $search_yearfin=''; + $search_monthfin=''; + $search_dayfin=''; + $search_yeardelivery=''; + $search_monthdelivery=''; + $search_daydelivery=''; + $search_availability=''; $viewstatut=''; $object_statut=''; $toselect=''; @@ -245,8 +261,9 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql.= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, '; $sql.= " typent.code as typent_code,"; +$sql.= " ava.rowid as availability,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; -$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,'; +$sql.= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; $sql.= ' p.datec as date_creation, p.tms as date_update,'; $sql.= " pr.rowid as project_id, pr.ref as project_ref,"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= " sc.fk_soc, sc.fk_user,"; @@ -271,6 +288,7 @@ if ($sall || $search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.' if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale if ($search_sale > 0 || (! $user->rights->societe->client->voir && ! $socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if ($search_user > 0) @@ -292,6 +310,7 @@ if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$db->escape($search if ($search_ref) $sql .= natural_search('p.ref', $search_ref); if ($search_refcustomer) $sql .= natural_search('p.ref_client', $search_refcustomer); if ($search_refproject) $sql .= natural_search('pr.ref', $search_refprojet); +if ($search_availability) $sql .= " AND p.fk_availability IN (".$db->escape($search_availability).')'; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_login) $sql .= natural_search("u.login", $search_login); @@ -323,6 +342,32 @@ else if ($search_year > 0) { $sql.= " AND p.datep BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } +if ($search_monthfin > 0) +{ + if ($search_yearfin > 0 && empty($search_dayfin)) + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,$search_monthfin,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,$search_monthfin,false))."'"; + else if ($search_yearfin > 0 && ! empty($search_dayfin)) + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthfin, $search_dayfin, $search_yearfin))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthfin, $search_dayfin, $search_yearfin))."'"; + else + $sql.= " AND date_format(p.fin_validite, '%m') = '".$db->escape($search_monthfin)."'"; +} +else if ($search_yearfin > 0) +{ + $sql.= " AND p.fin_validite BETWEEN '".$db->idate(dol_get_first_day($search_yearfin,1,false))."' AND '".$db->idate(dol_get_last_day($search_yearfin,12,false))."'"; +} +if ($search_monthdelivery > 0) +{ + if ($search_yeardelivery > 0 && empty($search_daydelivery)) + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,$search_monthdelivery,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,$search_monthdelivery,false))."'"; + else if ($search_yeardelivery > 0 && ! empty($search_daydelivery)) + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_monthdelivery, $search_daydelivery, $search_yeardelivery))."'"; + else + $sql.= " AND date_format(p.date_livraison, '%m') = '".$db->escape($search_monthdelivery)."'"; +} +else if ($search_yeardelivery > 0) +{ + $sql.= " AND p.date_livraison BETWEEN '".$db->idate(dol_get_first_day($search_yeardelivery,1,false))."' AND '".$db->idate(dol_get_last_day($search_yeardelivery,12,false))."'"; +} if ($search_sale > 0) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$db->escape($search_sale); if ($search_user > 0) { @@ -566,7 +611,32 @@ if ($resql) // Date end if (! empty($arrayfields['p.fin_validite']['checked'])) { - print '
 '; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $formother->select_year($search_yearfin,'search_yearfin',1, 20, 5); + print ''; + //print $langs->trans('Month').': '; + if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + print ''; + //print ' '.$langs->trans('Year').': '; + $formother->select_year($search_yeardelivery,'search_yeardelivery',1, 20, 5); + print ''; + print $form->selectAvailabilityDelay($search_availability, 'search_availability', '', 1); + print ajax_combobox('search_availability'); + print ''.dol_print_date($db->jdate($obj->ddelivery),'day'); + print ' '; + $form->form_availability('', $obj->availability, 'none', 1); + print '
'.$langs->trans("User").''; @@ -1358,6 +1359,7 @@ if ($action == 'create') print '
'.$langs->trans("VALIDATOR").''; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index e5b35b5a434..18039a1d47e 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -38,7 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php'; // Get parameters -$myparam = GETPOST("myparam"); $action=GETPOST('action', 'alpha'); $id=GETPOST('id', 'int'); $fuserid = (GETPOST('fuserid','int')?GETPOST('fuserid','int'):$user->id); @@ -864,7 +863,7 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print ''; print ''; - // User + // User for leave request print ''; print ''; print ''; print ''; - // Approved by + // Approver print ''; print ''; print ''; print ''; @@ -1181,7 +1193,13 @@ else print ''; print ''; print ''; print ''; } diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index f0b36f910d9..03b2491ab59 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1569,6 +1569,48 @@ class Holiday extends CommonObject } } + + /** + * Return list of people with permission to validate leave requests. + * Search for permission "approve leave requests" + * + * @return array Array of user ids + */ + function fetch_users_approver_holiday() + { + $users_validator=array(); + + $sql = "SELECT DISTINCT ur.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."user_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql.= " WHERE ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + $sql.= "UNION"; + $sql.= " SELECT DISTINCT ugu.fk_user"; + $sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd"; + $sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'holiday' AND rd.perms = 'approve'"; // Permission 'Approve'; + //print $sql; + + dol_syslog(get_class($this)."::fetch_users_approver_holiday sql=".$sql); + $result = $this->db->query($sql); + if($result) + { + $num_lignes = $this->db->num_rows($result); $i = 0; + while ($i < $num_lignes) + { + $objp = $this->db->fetch_object($result); + array_push($users_validator,$objp->fk_user); + $i++; + } + return $users_validator; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch_users_approver_holiday Error ".$this->error, LOG_ERR); + return -1; + } + } + + /** * Compte le nombre d'utilisateur actifs dans Dolibarr * From 94ccb44673c6485c7695ef11caf8817a903a73d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 11:02:44 +0200 Subject: [PATCH 596/609] Fix bad url wor external subscription page --- htdocs/adherents/admin/website.php | 8 +++++++- htdocs/admin/agenda_xcal.php | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 0a560c402fd..b35df5f0083 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -241,7 +241,13 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC)) } else { $entity_qr=''; } - print ''.DOL_MAIN_URL_ROOT.'/public/members/new.php'.$entity_qr.''; + + // Define $urlwithroot + $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); + $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file + //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current + + print ''.$urlwithroot.'/public/members/new.php'.$entity_qr.''; } diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index ac19eb24c03..ab0effc2c45 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -32,9 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (!$user->admin) accessforbidden(); -$langs->load("admin"); -$langs->load("other"); -$langs->load("agenda"); +$langs->loadLangs(array("admin","other","agenda")); $def = array(); $actionsave=GETPOST('save','alpha'); From 63ed5dcccce62c78100b9a566bad25772b8e2c10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 11:23:40 +0200 Subject: [PATCH 597/609] Fix securekey for new online payment form --- htdocs/comm/mailing/card.php | 2 +- htdocs/public/members/new.php | 37 ++++++++++++++------------- htdocs/public/members/public_card.php | 5 ++-- htdocs/public/members/public_list.php | 5 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 5ded0c16b5e..bb68f85ea16 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -244,7 +244,7 @@ if (empty($reshook)) $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__']=dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'contractline' . $obj->source_id, 2); } } - /* For backward compatibility */ + /* For backward compatibility, deprecated */ if (! empty($conf->paypal->enabled) && ! empty($conf->global->PAYPAL_SECURITY_TOKEN)) { $substitutionarray['__SECUREKEYPAYPAL__']=dol_hash($conf->global->PAYPAL_SECURITY_TOKEN, 2); diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index b6d87ce9ac2..b92e84b8352 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -35,8 +35,9 @@ * MEMBER_NEWFORM_FORCECOUNTRYCODE Force country */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -356,7 +357,7 @@ if ($action == 'add') if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'all') { $urlback=DOL_MAIN_URL_ROOT.'/public/payment/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { @@ -373,51 +374,51 @@ if ($action == 'add') else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paybox') { $urlback=DOL_MAIN_URL_ROOT.'/public/paybox/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->PAYBOX_SECURITY_TOKEN)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->PAYBOX_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYBOX_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { - $urlback.='&securekey='.urlencode($conf->global->PAYBOX_SECURITY_TOKEN); + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } } else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'paypal') { $urlback=DOL_MAIN_URL_ROOT.'/public/paypal/newpayment.php?from=membernewform&source=membersubscription&ref='.urlencode($adh->ref); - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYPAL_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { - $urlback.='&securekey='.urlencode($conf->global->PAYPAL_SECURITY_TOKEN); + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } } else if ($conf->global->MEMBER_NEWFORM_PAYONLINE == 'stripe') { $urlback=DOL_MAIN_URL_ROOT.'/public/stripe/newpayment.php?from=membernewform&source=membersubscription&ref='.$adh->ref; - if (price2num(GETPOST('amount'))) $urlback.='&amount='.price2num(GETPOST('amount')); + if (price2num(GETPOST('amount','alpha'))) $urlback.='&amount='.price2num(GETPOST('amount','alpha')); if (GETPOST('email')) $urlback.='&email='.urlencode(GETPOST('email')); - if (! empty($conf->global->STRIPE_SECURITY_TOKEN)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - if (! empty($conf->global->STRIPE_SECURITY_TOKEN_UNIQUE)) + if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - $urlback.='&securekey='.urlencode(dol_hash($conf->global->STRIPE_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); + $urlback.='&securekey='.urlencode(dol_hash($conf->global->PAYMENT_SECURITY_TOKEN . 'membersubscription' . $adh->ref, 2)); } else { - $urlback.='&securekey='.urlencode($conf->global->STRIPE_SECURITY_TOKEN); + $urlback.='&securekey='.urlencode($conf->global->PAYMENT_SECURITY_TOKEN); } } } diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index f3027eb0149..5dee0eb49a3 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -24,8 +24,9 @@ * \brief File to show a public card of a member */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/members/public_list.php b/htdocs/public/members/public_list.php index b3438e8be02..1f9a4406028 100644 --- a/htdocs/public/members/public_list.php +++ b/htdocs/public/members/public_list.php @@ -24,8 +24,9 @@ * \brief File sample to list members */ -define("NOLOGIN",1); // This means this output page does not require to be logged. -define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOLOGIN')) define("NOLOGIN",1); // This means this output page does not require to be logged. +if (! defined('NOCSRFCHECK')) define("NOCSRFCHECK",1); // We accept to go on this page from external web site. +if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php From b84baece3c980e5a0008f24c851eb715b38ff476 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 11:32:00 +0200 Subject: [PATCH 598/609] Code comment --- htdocs/modulebuilder/template/myobject_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 5b2a1213c0f..48a039e4edf 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -31,11 +31,11 @@ //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. +//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message From 53b5733fb4a515f97ded7c7d5267856e2290cc83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 12 May 2018 13:40:53 +0200 Subject: [PATCH 599/609] Fix test --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/public/test/test_forms.php | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fa606639bcc..9cba6ed839e 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4775,7 +4775,7 @@ class Form * - local date in user area, if set_time is '' (so if set_time is '', output may differs when done from two different location) * - Empty (fields empty), if set_time is -1 (in this case, parameter empty must also have value 1) * - * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date (emptydate must be 0). + * @param timestamp $set_time Pre-selected date (must be a local PHP server timestamp), -1 to keep date not preselected, '' to use current date with 00:00 hour (Parameter 'empty' must be 0 or 2). * @param string $prefix Prefix for fields name * @param int $h 1 or 2=Show also hours (2=hours on a new line), -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show hour always empty * @param int $m 1=Show also minutes, -1 has same effect but hour and minutes are prefilled with 23:59 if date is empty, 3 show minutes always empty @@ -4813,7 +4813,7 @@ class Form } // Analysis of the pre-selection date - if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) + if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/',$set_time,$reg)) // deprecated usage { // Date format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' $syear = (! empty($reg[1])?$reg[1]:''); diff --git a/htdocs/public/test/test_forms.php b/htdocs/public/test/test_forms.php index a53f812611a..0250bb2c39f 100644 --- a/htdocs/public/test/test_forms.php +++ b/htdocs/public/test/test_forms.php @@ -28,11 +28,16 @@ This page is a sample of page using Dolibarr HTML widget methods. It is designed $form=new Form($db); // Test1: form->select_date using tzuser date -print "Test 1: We must have here current hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; +print "Test 1a: We must have here current date and hour for user (must match hour on browser). Note: Check your are logged so user TZ and DST are known."; $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; print " (dol_tz=".$offsettz." dol_dst=".$dol_dst.")
\n"; -$form->select_date('', 'test1', 1, 1, 0); +$form->select_date(dol_now(), 'test1a', 1, 1, 0); + +print '

'."\n"; + +print "Test 1b: We must have here current date with hours to 00:00.
"; +$form->select_date('', 'test1b', 1, 1, 0); print '

'."\n"; From 302d9399e2475fe270a122210b6f5cc7bab529bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 12:42:16 +0200 Subject: [PATCH 600/609] Fix search when using special char --- htdocs/core/class/html.form.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9cba6ed839e..642fe099593 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5542,7 +5542,7 @@ class Form /** - * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. + * Return a HTML select string, built from an array of key+value, but content returned into select come from an Ajax call of an URL. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area @@ -5557,7 +5557,7 @@ class Form * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string - * @see ajax_combobox in ajax.lib.php + * @see selectArrayFilter, ajax_combobox in ajax.lib.php */ static function selectArrayAjax($htmlname, $url, $id='', $moreparam='', $moreparamtourl='', $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { @@ -5618,7 +5618,7 @@ class Form /* Code to execute a GET when we select a value */ $(".'.$htmlname.'").change(function() { var selected = $(".'.$htmlname.'").val(); - console.log("We select "+selected) + console.log("We select in selectArrayAjax the entry "+selected) $(".'.$htmlname.'").val(""); /* reset visible combo value */ $.each( saveRemoteData, function( key, value ) { if (key == selected) @@ -5644,7 +5644,7 @@ class Form } /** - * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. + * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area @@ -5659,7 +5659,7 @@ class Form * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 if caller request to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) * @return string HTML select string - * @see ajax_combobox in ajax.lib.php + * @see selectArrayAjax, ajax_combobox in ajax.lib.php */ static function selectArrayFilter($htmlname, $array, $id='', $moreparam='', $disableFiltering=0, $disabled=0, $minimumInputLength=1, $morecss='', $callurlonselect=0, $placeholder='', $acceptdelayedhtml=0) { @@ -5708,8 +5708,9 @@ class Form var urlBase = data.url; var separ = urlBase.indexOf("?") >= 0 ? "&" : "?"; - - saveRemoteData[data.id].url = urlBase + separ + "sall=" + params.term;'; + /* console.log("params.term="+params.term); */ + /* console.log("params.term encoded="+encodeURIComponent(params.term)); */ + saveRemoteData[data.id].url = urlBase + separ + "sall=" + encodeURIComponent(params.term);'; } if(! $disableFiltering) { From c76e866f41bc605ddc7009379f4cd8f5864d541e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 14:06:57 +0200 Subject: [PATCH 601/609] CSS --- htdocs/core/tpl/admin_extrafields_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index ecdda360309..1b0a5303bec 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -91,7 +91,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel if (! empty($conf->multicompany->enabled)) { print '
'; } - print '\n"; print ""; } From a2d485c14fcb4510458d05ffe9cb0795d1604454 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 14:27:40 +0200 Subject: [PATCH 602/609] Fix management of enabled property extrafields --- htdocs/core/class/extrafields.class.php | 24 ++++++++++++++++++------ htdocs/core/tpl/extrafields_view.tpl.php | 6 +++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 153efd5b8c9..62fd4335315 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -39,38 +39,50 @@ class ExtraFields var $db; // type of element (for what object is the extrafield) + // @deprecated var $attribute_elementtype; - // Array with type of the extra field + // @deprecated var $attribute_type; // Array with label of extra field + // @deprecated var $attribute_label; // Array with size of extra field + // @deprecated var $attribute_size; // array with list of possible values for some types of extra fields + // @deprecated var $attribute_choice; // Array to store compute formula for computed fields + // @deprecated var $attribute_computed; // Array to store default value + // @deprecated var $attribute_default; // Array to store if attribute is unique or not + // @deprecated var $attribute_unique; // Array to store if attribute is required or not + // @deprecated var $attribute_required; // Array to store parameters of attribute (used in select type) + // @deprecated var $attribute_param; // Array to store position of attribute + // @deprecated var $attribute_pos; // Array to store if attribute is editable regardless of the document status + // @deprecated var $attribute_alwayseditable; // Array to store permission to check + // @deprecated var $attribute_perms; // Array to store language file to translate label of values + // @deprecated var $attribute_langfile; // Array to store if field is visible by default on list + // @deprecated var $attribute_list; - // Array to store if extra field is hidden - var $attribute_hidden; // warning, do not rely on this. If your module need a hidden data, it must use its own table. // New array to store extrafields definition var $attributes; @@ -126,7 +138,6 @@ class ExtraFields $this->attribute_perms = array(); $this->attribute_langfile = array(); $this->attribute_list = array(); - $this->attribute_hidden = array(); } /** @@ -758,7 +769,7 @@ class ExtraFields // We should not have several time this log. If we have, there is some optimization to do by calling a simple $object->fetch_optionals() that include cache management. dol_syslog("fetch_name_optionals_label elementtype=".$elementtype); - $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity"; + $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired,param,pos,alwayseditable,perms,langs,list,fielddefault,fieldcomputed,entity,enabled"; $sql.= " FROM ".MAIN_DB_PREFIX."extrafields"; $sql.= " WHERE entity IN (0,".$conf->entity.")"; if ($elementtype) $sql.= " AND elementtype = '".$elementtype."'"; // Filed with object->table_element @@ -812,6 +823,7 @@ class ExtraFields $this->attributes[$tab->elementtype]['list'][$tab->name]=$tab->list; $this->attributes[$tab->elementtype]['entityid'][$tab->name]=$tab->entity; $this->attributes[$tab->elementtype]['entitylabel'][$tab->name]=(empty($labelmulticompany[$tab->entity])?'Entity'.$tab->entity:$labelmulticompany[$tab->entity]); + $this->attributes[$tab->elementtype]['enabled'][$tab->name]=$tab->enabled; $this->attributes[$tab->elementtype]['loaded']=1; } @@ -884,7 +896,7 @@ class ExtraFields $param=$this->attribute_param[$key]; $langfile=$this->attribute_langfile[$key]; $list=$this->attribute_list[$key]; - $hidden=$this->attribute_hidden[$key]; + $hidden=(empty($list) ? 1 : 0); // If empty, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) } if ($computed) diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 0e3d742e986..06396cf4fb7 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -45,13 +45,17 @@ $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -//var_dump($extrafields->attributes); +//var_dump($extrafields->attributes[$object->table_element]); if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { // Discard if extrafield is a hidden field on form $enabled = 1; + if ($enabled && isset($extrafields->attributes[$object->table_element]['enabled'][$key])) + { + $enabled = dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1); + } if ($enabled && isset($extrafields->attributes[$object->table_element]['list'][$key])) { $enabled = dol_eval($extrafields->attributes[$object->table_element]['list'][$key], 1); From 0c40dfa3f9b3795450a2a069d016d54edc1a72d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 May 2018 14:30:48 +0200 Subject: [PATCH 603/609] Translation --- htdocs/langs/en_US/products.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index a8f9f815cb6..abf262ec9ba 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -156,7 +156,7 @@ BuyingPrices=Buying prices CustomerPrices=Customer prices SuppliersPrices=Supplier prices SuppliersPricesOfProductsOrServices=Supplier prices (of products or services) -CustomCode=Customs/Commodity/HS code +CustomCode=Customs / Commodity / HS code CountryOrigin=Origin country Nature=Nature ShortLabel=Short label From f342c5c6b3231383f45bdca117ed179afaa74df1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 11:36:39 +0200 Subject: [PATCH 604/609] Page title first --- htdocs/website/index.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index f141c6cf417..3a92029e205 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -542,10 +542,10 @@ if ($action == 'addcontainer') } else { + $objectpage->title = GETPOST('WEBSITE_TITLE','alpha'); $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER','alpha'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME','alpha'); $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT','alpha'); - $objectpage->title = GETPOST('WEBSITE_TITLE','alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION','alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS','alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG','aZ09'); @@ -958,10 +958,10 @@ if ($action == 'updatemeta') { $objectpage->old_object = clone $objectpage; + $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); $objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha'); $objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); $objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha'); - $objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha'); $objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha'); $objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha'); $objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09'); @@ -2026,14 +2026,22 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pagelang=$objectpage->lang; $pagehtmlheader=$objectpage->htmlheader; } + if (GETPOST('WEBSITE_TITLE','alpha')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); if (GETPOST('WEBSITE_PAGENAME','alpha')) $pageurl=GETPOST('WEBSITE_PAGENAME','alpha'); if (GETPOST('WEBSITE_ALIASALT','alpha')) $pagealiasalt=GETPOST('WEBSITE_ALIASALT','alpha'); - if (GETPOST('WEBSITE_TITLE','alpha')) $pagetitle=GETPOST('WEBSITE_TITLE','alpha'); if (GETPOST('WEBSITE_DESCRIPTION','alpha')) $pagedescription=GETPOST('WEBSITE_DESCRIPTION','alpha'); if (GETPOST('WEBSITE_KEYWORDS','alpha')) $pagekeywords=GETPOST('WEBSITE_KEYWORDS','alpha'); if (GETPOST('WEBSITE_LANG','aZ09')) $pagelang=GETPOST('WEBSITE_LANG','aZ09'); if (GETPOST('htmlheader','none')) $pagehtmlheader=GETPOST('htmlheader','none'); + // Title + print ''; + + // Alias print ''; } - print ''; - print ''; + // GDPR contact + + print ''; + // Capital print ''; + // GDPR Contact + + print ''; + // Capital print ''; - print '\n"; + print '\n"; print '\n"; print '\n"; print "\n"; @@ -129,7 +130,7 @@ function pt ($db, $sql, $date) if ($obj->mode == 'paid') { $amountpaid = $obj->mm; - $totalpaid = $totalpaid + $amountpaied; + $totalpaid = $totalpaid + $amountpaid; } if ($obj->mode == 'paid') @@ -142,10 +143,12 @@ function pt ($db, $sql, $date) $amountclaimed = 0; $amountpaid = 0; $previousmode = ''; + $previousmonth = ''; } else { $previousmode = $obj->mode; + $previousmonth = $obj->dm; } $i++; @@ -154,7 +157,7 @@ function pt ($db, $sql, $date) if ($obj->mode == 'claimed' && ! empty($previousmode)) { print ''; - print '\n"; + print '\n"; print '\n"; print '\n"; print "\n"; @@ -534,7 +537,7 @@ $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; $sql.= " GROUP BY dm"; -$sql.= " ORDER BY dm ASC"; +$sql.= " ORDER BY dm ASC, mode ASC"; //print $sql; pt($db, $sql, $langs->trans("Month")); From 3e27d7dd2a3888811080d71179c971fc16f213af Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 17:51:19 +0200 Subject: [PATCH 607/609] Report of turnover by vat rate / product type / country --- htdocs/compta/stats/byratecountry.php | 361 ++++++++++++++++++++++++ htdocs/compta/stats/cabyprodserv.php | 49 ++-- htdocs/compta/stats/casoc.php | 4 +- htdocs/compta/stats/index.php | 6 +- htdocs/core/menus/standard/eldy.lib.php | 3 +- htdocs/langs/en_US/accountancy.lang | 1 + htdocs/langs/en_US/compta.lang | 10 +- htdocs/langs/en_US/main.lang | 2 +- 8 files changed, 401 insertions(+), 35 deletions(-) create mode 100644 htdocs/compta/stats/byratecountry.php diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php new file mode 100644 index 00000000000..b2186633413 --- /dev/null +++ b/htdocs/compta/stats/byratecountry.php @@ -0,0 +1,361 @@ + + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2006-2007, 2015 Yannick Warnier + * Copyright (C) 2014 Ferran Marcet + * + * 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/tva/quadri_detail.php + * \ingroup tax + * \brief VAT by rate + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php'; + +$langs->loadLangs(array("other","compta","banks","bills","companies","product","trips","admin","accountancy")); + +$modecompta = GETPOST('modecompta','alpha'); + +// Date range +$year=GETPOST("year",'int'); +$month=GETPOST("month",'int'); +if (empty($year)) +{ + $year_current = strftime("%Y",dol_now()); + $month_current = strftime("%m",dol_now()); + $year_start = $year_current; +} else { + $year_current = $year; + $month_current = strftime("%m",dol_now()); + $year_start = $year; +} +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); +// Quarter +if (empty($date_start) || empty($date_end)) // We define date_start and date_end +{ + $q=GETPOST("q","int"); + if (empty($q)) + { + // We define date_start and date_end + $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); + $year_end=$year_start; + $month_end=$month_start; + if (! GETPOST("month")) // If month not forced + { + if (! GETPOST('year') && $month_start > $month_current) + { + $year_start--; + $year_end--; + } + $month_end=$month_start-1; + if ($month_end < 1) $month_end=12; + else $year_end++; + } + $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); + } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } +} + +// $date_start and $date_end are defined. We force $year_start and $nbofyear +$tmps=dol_getdate($date_start); +$year_start = $tmps['year']; +$tmpe=dol_getdate($date_end); +$year_end = $tmpe['year']; + +$tmp_date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; +if ($tmp_date_end < $date_end || $date_end < $date_start) $date_end = $tmp_date_end; + +$min = price2num(GETPOST("min","alpha")); +if (empty($min)) $min = 0; + +// Define modetax (0 or 1) +// 0=normal, 1=option vat for services is on debit, 2=option on payments for products +$modetax = $conf->global->TAX_MODE; +if (GETPOSTISSET("modetax")) $modetax=GETPOST("modetax",'int'); +if (empty($modetax)) $modetax=0; + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'tax', '', '', 'charges'); + + + +/* + * View + */ + +$form=new Form($db); +$company_static=new Societe($db); +$invoice_customer=new Facture($db); +$invoice_supplier=new FactureFournisseur($db); +$expensereport=new ExpenseReport($db); +$product_static=new Product($db); +$payment_static=new Paiement($db); +$paymentfourn_static=new PaiementFourn($db); +$paymentexpensereport_static=new PaymentExpenseReport($db); + +$morequerystring=''; +$listofparams=array('date_startmonth','date_startyear','date_startday','date_endmonth','date_endyear','date_endday'); +foreach ($listofparams as $param) +{ + if (GETPOST($param)!='') $morequerystring.=($morequerystring?'&':'').$param.'='.GETPOST($param); +} + +llxHeader('',$langs->trans("TurnoverReport"),'','',0,0,'','',$morequerystring); + + +//print load_fiche_titre($langs->trans("VAT"),""); + +//$fsearch.='
'; +$fsearch.=' '; +$fsearch.=' '; +//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; +//$fsearch.=' '; + + +// Show report header +$name=$langs->trans("xxx"); +$calcmode=''; +if ($modetax == 0) $calcmode=$langs->trans('OptionVATDefault'); +if ($modetax == 1) $calcmode=$langs->trans('OptionVATDebitOption'); +if ($modetax == 2) $calcmode=$langs->trans('OptionPaymentForProductAndServices'); +$calcmode.='
('.$langs->trans("TaxModuleSetupToModifyRules",DOL_URL_ROOT.'/admin/taxes.php').')'; +// Set period +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +$prevyear=$year_start; $prevquarter=$q; +if ($prevquarter > 1) { + $prevquarter--; +} else { + $prevquarter=4; $prevyear--; +} +$nextyear=$year_start; $nextquarter=$q; +if ($nextquarter < 4) { + $nextquarter++; +} else { + $nextquarter=1; $nextyear++; +} +$description.=$fsearch; +$builddate=dol_now(); + +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'invoice') $description.=$langs->trans("RulesVATDueProducts"); +if ($conf->global->TAX_MODE_SELL_PRODUCT == 'payment') $description.=$langs->trans("RulesVATInProducts"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'invoice') $description.='
'.$langs->trans("RulesVATDueServices"); +if ($conf->global->TAX_MODE_SELL_SERVICE == 'payment') $description.='
'.$langs->trans("RulesVATInServices"); +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.='
'.$langs->trans("DepositsAreNotIncluded"); +} +if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description.='
'.$langs->trans("ThisIsAnEstimatedValue"); + +// Customers invoices +$elementcust=$langs->trans("CustomersInvoices"); +$productcust=$langs->trans("ProductOrService"); +$amountcust=$langs->trans("AmountHT"); + +// Suppliers invoices +$elementsup=$langs->trans("SuppliersInvoices"); +$productsup=$productcust; +$amountsup=$amountcust; +$namesup=$namecust; + + + + +// Show report header +$name=$langs->trans("SalesTurnover").', '.$langs->trans("ByVatRate"); + +if ($modecompta=="CREANCES-DETTES") { + $calcmode=$langs->trans("CalcModeDebt"); + $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; + + $description=$langs->trans("RulesCADue"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $description.= $langs->trans("DepositsAreNotIncluded"); + } else { + $description.= $langs->trans("DepositsAreIncluded"); + } + + $builddate=dol_now(); +} else { + $calcmode=$langs->trans("CalcModeEngagement"); + $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; + + $description=$langs->trans("RulesCAIn"); + $description.= $langs->trans("DepositsAreIncluded"); + + $builddate=dol_now(); +} +$period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); +if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink=''.img_previous().' '.img_next().''; +else $periodlink = ''; + +$description.=' '; + +report_header($name,'',$period,$periodlink,$description,$builddate,$exportlink,array(),$calcmode); + +if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') +{ + print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); +} + + +if ($modecompta == 'CREANCES-DETTES') +{ + +print '
'.$langs->trans("User").''; @@ -932,11 +931,24 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create print '
'.$langs->trans("ReviewedByCP").''; - print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent + + $object = new Holiday($db); + $include_users = $object->fetch_users_approver_holiday(); + if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + else + { + $defaultselectuser=$user->fk_user; // Will work only if supervisor has permission to approve so is inside include_users + if (! empty($conf->global->HOLIDAY_DEFAULT_VALIDATOR)) $defaultselectuser=$conf->global->HOLIDAY_DEFAULT_VALIDATOR; // Can force default approver + if (GETPOST('valideur', 'int') > 0) $defaultselectuser=GETPOST('valideur', 'int'); + $s=$form->select_dolusers($defaultselectuser, "valideur", 1, "", 0, $include_users); + print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } + + //print $form->select_dolusers((GETPOST('valideur','int')>0?GETPOST('valideur','int'):$user->fk_user), "valideur", 1, ($user->admin ? '' : array($user->id)), 0, '', 0, 0, 0, 0, '', 0, '', '', 1); // By default, hierarchical parent print '
'.$langs->trans('ReviewedByCP').''; - print $form->select_dolusers($object->fk_validator, "valideur", 1, ($user->admin ? '' : array($user->id))); // By default, hierarchical parent + $include_users = $object->fetch_users_approver_holiday(); + if (empty($include_users)) print img_warning().' '.$langs->trans("NobodyHasPermissionToValidateHolidays"); + else + { + $s=$form->select_dolusers($object->fk_validator, "valideur", 1, ($user->admin ? '' : array($user->id)), 0, $include_users); + print $form->textwithpicto($s, $langs->trans("AnyOtherInThisListCanValidate")); + } print '
'.($extrafields->attributes[$elementtype]['entityid'][$key]==0?$langs->trans("All"):$extrafields->attributes[$elementtype]['entitylabel'][$key]).''.img_edit().''; + print ''.img_edit().''; print "  ".img_delete()."
'; + print $langs->trans('WEBSITE_TITLE'); + print ''; + print ''; + print '
'; print $langs->trans('WEBSITE_PAGENAME'); print ''; @@ -2055,12 +2063,6 @@ if ($action == 'editmeta' || $action == 'createcontainer') print '
'; - print $langs->trans('WEBSITE_TITLE'); - print ''; - print ''; - print '
'; print $langs->trans('WEBSITE_DESCRIPTION'); print ''; From d52305cef86e61da2391d8aa13e618231fc8d076 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 11:50:42 +0200 Subject: [PATCH 605/609] NEW Add entry for the GDPR contact --- htdocs/admin/company.php | 15 ++++++++++++++- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 59fa9eeae2f..dfa4b043978 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004-2018 Laurent Destailleur * Copyright (C) 2005-2017 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2011-2017 Philippe Grand @@ -157,6 +157,7 @@ if ( ($action == 'update' && ! GETPOST("cancel",'alpha')) } dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MANAGERS", GETPOST("MAIN_INFO_SOCIETE_MANAGERS",'nohtml'),'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_INFO_GDPR", GETPOST("MAIN_INFO_GDPR",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_CAPITAL", GETPOST("capital",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE", GETPOST("forme_juridique_code",'nohtml'),'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_INFO_SIREN", GETPOST("siren",'nohtml'),'chaine',0,'',$conf->entity); @@ -424,6 +425,13 @@ if ($action == 'edit' || $action == 'updateedit') print '
'; print '
'; + print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc")); + print ''; + print '
'; @@ -815,6 +823,11 @@ else print '
'.$langs->trans("ManagingDirectors").''; print $conf->global->MAIN_INFO_SOCIETE_MANAGERS . '
'.$langs->trans("GDPRContact").''; + print $conf->global->MAIN_INFO_GDPR . '
'.$langs->trans("Capital").''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 9be2b2d4de1..563b63ef7b9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1793,6 +1793,8 @@ EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous fie SeveralLangugeVariatFound=Several language variants found COMPANY_AQUARIUM_REMOVE_SPECIAL=Remove special characters COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN_REGEX) +GDPRContact=GDPR contact +GDPRContactDesc=If you store data about European companies/citizen, you can store here the contact who is responsible for the General Data Protection Regulation ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From 7099068f055f0955feb53f2c54b571dc9e819bae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 May 2018 14:47:04 +0200 Subject: [PATCH 606/609] Fix calculation of vat paid --- htdocs/compta/tva/index.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 3597ad27c92..e6cdf738b96 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -105,14 +105,15 @@ function pt ($db, $sql, $date) $amountclaimed = 0; $amountpaid = 0; + $previousmonth = ''; $previousmode = ''; while ($i < $num) { $obj = $db->fetch_object($result); - + //print $obj->dm.' '.$obj->mode.' '.$previousmonth.' '.$previousmode; if ($obj->mode == 'claimed' && ! empty($previousmode)) { print '
'.$obj->dm."'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'.$obj->dm."'.$previousmonth."'.price($amountclaimed)."'.price($amountpaid)."
'; +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql = "SELECT fd.tva_tx AS vatrate,"; +$sql .= " fd.product_type AS product_type,"; +$sql .= " cc.label AS country,"; +for($i = 1; $i <= 12; $i ++) { + $sql .= " SUM(" . $db->ifsql('MONTH(f.datef)=' . $i, 'fd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql .= " SUM(fd.total_ht) as total"; +$sql .= " FROM " . MAIN_DB_PREFIX . "facturedet as fd"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture as f ON f.rowid = fd.fk_facture"; +$sql .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = f.fk_soc"; +$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; +$sql .= " WHERE f.datef >= '" . $db->idate($date_start) . "'"; +$sql .= " AND f.datef <= '" . $db->idate($date_end) . "'"; +$sql.= " AND f.fk_statut in (1,2)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND f.type IN (0,1,2,5)"; +} else { + $sql.= " AND f.type IN (0,1,2,3,5)"; +} +$sql .= " AND f.entity IN (" . getEntity("facture", 0) . ")"; +$sql .= " GROUP BY fd.tva_tx,fd.product_type, cc.label "; + +dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) { + $num = $db->num_rows($resql); + + while ( $row = $db->fetch_row($resql)) { + print ''; + if ($row[1] == 0) { + print ''; + } else { + print ''; + } + print ''; + + for($i = 3; $i <= 14; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql); +} else { + print $db->lasterror(); // Show last sql error +} +print ''; +print ''; +print ''; +for($i = 1; $i <= 12; $i ++) { + print ''; +} +print ''; + +$sql2 = "SELECT ffd.tva_tx AS vatrate,"; +$sql2 .= " ffd.product_type AS product_type,"; +$sql2 .= " cc.label AS country,"; +for($i = 1; $i <= 12; $i ++) { + $sql2 .= " SUM(" . $db->ifsql('MONTH(ff.datef)=' . $i, 'ffd.total_ht', '0') . ") AS month" . str_pad($i, 2, '0', STR_PAD_LEFT) . ","; +} +$sql2 .= " SUM(ffd.total_ht) as total"; +$sql2 .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as ffd"; +$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn"; +$sql2 .= " INNER JOIN " . MAIN_DB_PREFIX . "societe as soc ON soc.rowid = ff.fk_soc"; +$sql2 .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as cc ON cc.rowid = soc.fk_pays"; +$sql2 .= " WHERE ff.datef >= '" . $db->idate($date_start) . "'"; +$sql2 .= " AND ff.datef <= '" . $db->idate($date_end) . "'"; +$sql.= " AND ff.fk_statut in (1,2)"; +if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { + $sql.= " AND ff.type IN (0,1,2,5)"; +} else { + $sql.= " AND ff.type IN (0,1,2,3,5)"; +} +$sql2 .= " AND ff.entity IN (" . getEntity("facture_fourn", 0) . ")"; +$sql2 .= " GROUP BY ffd.tva_tx, ffd.product_type, cc.label"; + +//print $sql2; +dol_syslog("htdocs/compta/tva/index.php sql=" . $sql, LOG_DEBUG); +$resql2 = $db->query($sql2); +if ($resql2) { + $num = $db->num_rows($resql2); + + while ( $row = $db->fetch_row($resql2)) { + print ''; + if ($row[1] == 0) { + print ''; + } else { + print ''; + } + print ''; + for($i = 3; $i <= 14; $i ++) { + print ''; + } + print ''; + print ''; + } + $db->free($resql2); +} else { + print $db->lasterror(); // Show last sql error +} +print "
' . $langs->trans("TurnoverbyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' .$row[2] . '' . price($row[$i]) . '' . price($row[15]) . '
' . $langs->trans("PurchasebyVatrate") . '' . $langs->trans("ProductOrService") . '' . $langs->trans("Country") . '' . $langs->trans('MonthShort' . str_pad($i, 2, '0', STR_PAD_LEFT)) . '' . $langs->trans("TotalHT") . '
' . vatrate($row[0]) . ''. $langs->trans("Product") . ''. $langs->trans("Service") . '' . $row[2] . '' . price($row[$i]) . '' . price($row[15]) . '
\n"; + +} else { + // $modecompta != 'CREANCES-DETTES' + // "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an + // invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ? + // Because there is no way to know this, this report is not relevant. + print '
'.$langs->trans("TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant") . '
'; +} + + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index 1c170eae96d..e4d1f16cb8b 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -29,9 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -$langs->load("products"); -$langs->load("categories"); -$langs->load("errors"); +$langs->loadLangs(array("products","categories","errors",'accountancy')); // Security pack (data & check) $socid = GETPOST('socid','int'); @@ -78,13 +76,13 @@ if (empty($year)) $month_current = strftime("%m",dol_now()); $year_start = $year; } -$date_start=dol_mktime(0,0,0,$_REQUEST["date_startmonth"],$_REQUEST["date_startday"],$_REQUEST["date_startyear"]); -$date_end=dol_mktime(23,59,59,$_REQUEST["date_endmonth"],$_REQUEST["date_endday"],$_REQUEST["date_endyear"]); +$date_start=dol_mktime(0,0,0,GETPOST("date_startmonth"),GETPOST("date_startday"),GETPOST("date_startyear")); +$date_end=dol_mktime(23,59,59,GETPOST("date_endmonth"),GETPOST("date_endday"),GETPOST("date_endyear")); // Quarter if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q=GETPOST("q")?GETPOST("q"):0; - if ($q==0) + $q=GETPOST("q","int"); + if (empty($q)) { // We define date_start and date_end $month_start=GETPOST("month")?GETPOST("month"):($conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START):1); @@ -103,10 +101,13 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } $date_start=dol_get_first_day($year_start,$month_start,false); $date_end=dol_get_last_day($year_end,$month_end,false); } - if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } - if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } - if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } - if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + else + { + if ($q==1) { $date_start=dol_get_first_day($year_start,1,false); $date_end=dol_get_last_day($year_start,3,false); } + if ($q==2) { $date_start=dol_get_first_day($year_start,4,false); $date_end=dol_get_last_day($year_start,6,false); } + if ($q==3) { $date_start=dol_get_first_day($year_start,7,false); $date_end=dol_get_last_day($year_start,9,false); } + if ($q==4) { $date_start=dol_get_first_day($year_start,10,false); $date_end=dol_get_last_day($year_start,12,false); } + } } else { // TODO We define q } @@ -188,7 +189,7 @@ report_header($name,$namelink,$period,$periodlink,$description,$builddate,$expor if (! empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') { - print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); + print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1); } @@ -205,17 +206,17 @@ if ($modecompta == 'CREANCES-DETTES') $sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,"; $sql.= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,"; $sql.= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l, ".MAIN_DB_PREFIX."product as p"; + $sql.= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."facturedet as l"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; if ($selected_cat === -2) // Without any category { - $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; } else if ($selected_cat) // Into a specific category { $sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp"; } - $sql.= " WHERE l.fk_product = p.rowid"; - $sql.= " AND l.fk_facture = f.rowid"; + $sql.= " WHERE l.fk_facture = f.rowid"; $sql.= " AND f.fk_statut in (1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { $sql.= " AND f.type IN (0,1,2,5)"; @@ -363,23 +364,21 @@ if ($modecompta == 'CREANCES-DETTES') ); print "
"; $fullname=$name[$key]; - if ($key >= 0) { + if ($key > 0) { $linkname=''.img_object($langs->trans("ShowProduct"),$type[$key]==0?'product':'service').' '.$fullname.''; } else { $linkname=$langs->trans("PaymentsNotLinkedToProduct"); } - - print "".$linkname."'; @@ -423,11 +422,11 @@ if ($modecompta == 'CREANCES-DETTES') // Total print '
'.$langs->trans("Total").''.price($qtytotal).' '.$qtytotal.'100%'.price($catotal_ht).''.price($catotal).' 100%
Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es
Facture a encaisser : ".price($total_ttc_Rac)."<-- bug ici car n'exclut pas le deja r?gl? des factures partiellement r?gl?es
Signe et non facture:".price($total_pr)."<-- bug ici, ca devrait exclure le deja facture
Signe et non facture:".price($total_pr)."<-- bug ici, ca devrait exclure le deja facture
Total CA previsionnel : ".price($total_CA)."<-- bug ici car bug sur les 2 precedents
Total CA previsionnel : ".price($total_CA)."<-- bug ici car bug sur les 2 precedents
"; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4d3951f7b5e..6a77e4661d5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -699,7 +699,6 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } //if ($usemenuhider || empty($leftmenu) || $leftmenu=="cat") $newmenu->add("/categories/list.php", $langs->trans("List"), 1, $user->rights->categorie->lire); } - } /* @@ -1103,6 +1102,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=accountancy_report",$langs->trans("ByCompanies"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=accountancy_report",$langs->trans("ByUsers"),3,$user->rights->accounting->comptarapport->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=accountancy_report", $langs->trans("ByProductsAndServices"),3,$user->rights->accounting->comptarapport->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/',$leftmenu)) $newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report", $langs->trans("ByVatRate"),3,$user->rights->accounting->comptarapport->lire); } // Accountancy (simple) @@ -1131,6 +1131,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/casoc.php?leftmenu=report",$langs->trans("ByCompanies"),2,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cabyuser.php?leftmenu=report",$langs->trans("ByUsers"),2,$user->rights->compta->resultat->lire); if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/cabyprodserv.php?leftmenu=report", $langs->trans("ByProductsAndServices"),2,$user->rights->compta->resultat->lire); + if ($usemenuhider || empty($leftmenu) || preg_match('/report/',$leftmenu)) $newmenu->add("/compta/stats/byratecountry.php?leftmenu=report", $langs->trans("ByVatRate"),2,$user->rights->compta->resultat->lire); // Journaux //if ($leftmenu=="ca") $newmenu->add("/compta/journaux/index.php?leftmenu=ca",$langs->trans("Journaux"),1,$user->rights->compta->resultat->lire||$user->rights->accounting->comptarapport->lire); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index a7b7e345682..7207110ce42 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -192,6 +192,7 @@ ListAccounts=List of the accounting accounts UnknownAccountForThirdparty=Unknown third party account. We will use %s UnknownAccountForThirdpartyBlocking=Unknown third party account. Blocking error UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third party account and waiting account not defined. Blocking error +PaymentsNotLinkedToProduct=Payment not linked to any product / service Pcgtype=Group of account Pcgsubtype=Subgroup of account diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 9c1574c77ef..db9b4d481e8 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -210,7 +210,7 @@ Pcg_version=Chart of accounts models Pcg_type=Pcg type Pcg_subtype=Pcg subtype InvoiceLinesToDispatch=Invoice lines to dispatch -ByProductsAndServices=By products and services +ByProductsAndServices=By product and service RefExt=External ref ToCreateAPredefinedInvoice=To create a template invoice, create a standard invoice, then, without validating it, click onto button "%s". LinkedOrder=Link to order @@ -218,7 +218,8 @@ Mode1=Method 1 Mode2=Method 2 CalculationRuleDesc=To calculate total VAT, there is two methods:
Method 1 is rounding vat on each line, then summing them.
Method 2 is summing all vat on each line, then rounding result.
Final result may differs from few cents. Default mode is mode %s. CalculationRuleDescSupplier=According to supplier, choose appropriate method to apply same calculation rule and get same result expected by your supplier. -TurnoverPerProductInCommitmentAccountingNotRelevant=Turnover report per product, when using a cash accountancy mode is not relevant. This report is only available when using engagement accountancy mode (see setup of accountancy module). +TurnoverPerProductInCommitmentAccountingNotRelevant=Turnover report per product, when using a cash accounting mode is not relevant. This report is only available when using commitment accounting mode (see setup of accountancy module). +TurnoverPerSaleTaxRateInCommitmentAccountingNotRelevant=Turnover report per sale tax rate, when using a cash accounting mode is not relevant. This report is only available when using commitment accounting mode (see setup of accountancy module). CalculationMode=Calculation mode AccountancyJournal=Accounting code journal ACCOUNTING_VAT_SOLD_ACCOUNT=Accounting account by default for VAT on sales (used if not defined on VAT dictionary setup) @@ -248,4 +249,7 @@ AccountingAffectation=Accounting assignement LastDayTaxIsRelatedTo=Last day of period the tax is related to VATDue=Sale tax claimed ClaimedForThisPeriod=Claimed for the period -PaidDuringThisPeriod=Paid during this period \ No newline at end of file +PaidDuringThisPeriod=Paid during this period +ByVatRate=By sale tax rate +TurnoverbyVatrate=Turnover by sale tax rate +PurchasebyVatrate=Purchase by sale tax rate \ No newline at end of file diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 60369b80ea5..77e9c04b10a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -494,7 +494,7 @@ Received=Received Paid=Paid Topic=Subject ByCompanies=By third parties -ByUsers=By users +ByUsers=By user Links=Links Link=Link Rejects=Rejects From ad32b3098acdd45c1d8b574f758efb838a955516 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 10:31:44 +0200 Subject: [PATCH 608/609] Too verbose log --- htdocs/core/class/translate.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 55b853f5c8e..3602ae427bd 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -542,7 +542,7 @@ class Translate */ private function getTradFromKey($key) { - global $db; + global $conf, $db; if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly. @@ -576,7 +576,9 @@ class Translate // TODO OrderSourceX must be replaced with content of table llx_c_input_reason or llx_c_input_method //$newstr=$this->getLabelFromKey($db,$reg[1],'c_ordersource','code','label'); } - dol_syslog(__METHOD__."missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) dol_syslog(__METHOD__." missing translation for key '".$newstr."' in ".$_SERVER["PHP_SELF"], LOG_DEBUG); + return $newstr; } From ef395fc36bbd74a451a7e79c3af5947a3f190b3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 May 2018 15:23:52 +0200 Subject: [PATCH 609/609] Fix scrutinizer bugs --- htdocs/asset/class/asset.class.php | 2 +- htdocs/categories/class/categorie.class.php | 1 + htdocs/comm/propal/class/propal.class.php | 22 +++++----- .../facture/class/api_invoices.class.php | 2 +- .../facture/class/facture-rec.class.php | 10 +++-- htdocs/compta/localtax/clients.php | 4 +- htdocs/compta/tva/index.php | 7 +++- htdocs/core/lib/security.lib.php | 2 + htdocs/core/lib/tax.lib.php | 2 +- .../modules/printing/printgcp.modules.php | 2 +- htdocs/don/class/don.class.php | 4 +- .../class/fournisseur.commande.class.php | 42 +++++++++---------- .../fourn/class/fournisseur.facture.class.php | 7 ++-- .../template/class/myobject.class.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/ticketsup/class/api_tickets.class.php | 21 ++++------ 16 files changed, 69 insertions(+), 63 deletions(-) diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 86da8ae5379..812c4956187 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -214,7 +214,7 @@ class Asset extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + //if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); return $result; } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 044f3e68c0f..70b2108dd4c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -895,6 +895,7 @@ class Categorie extends CommonObject $sql.= $this->db->order($sortfield, $sortorder); + $offset = 0; $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index b6e9d1411c5..f324161a4e7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3081,21 +3081,23 @@ class Propal extends CommonObject */ function LibStatut($statut,$mode=1) { + global $conf; + // Init/load array of translation of status if (empty($this->labelstatut) || empty($this->labelstatut_short)) { global $langs; $langs->load("propal"); - $this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft")); - $this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated")); - $this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned")); - $this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned")); - $this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled")); - $this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort")); - $this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened")); - $this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort")); - $this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort")); - $this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort")); + $this->labelstatut[0]=$langs->trans("PropalStatusDraft"); + $this->labelstatut[1]=$langs->trans("PropalStatusValidated"); + $this->labelstatut[2]=$langs->trans("PropalStatusSigned"); + $this->labelstatut[3]=$langs->trans("PropalStatusNotSigned"); + $this->labelstatut[4]=$langs->trans("PropalStatusBilled"); + $this->labelstatut_short[0]=$langs->trans("PropalStatusDraftShort"); + $this->labelstatut_short[1]=$langs->trans("Opened"); + $this->labelstatut_short[2]=$langs->trans("PropalStatusSignedShort"); + $this->labelstatut_short[3]=$langs->trans("PropalStatusNotSignedShort"); + $this->labelstatut_short[4]=$langs->trans("PropalStatusBilledShort"); } $statuttrans=''; diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 8547be8cb2c..2c744b8bda3 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1074,7 +1074,7 @@ class Invoices extends DolibarrApi * Warning: Take care that all invoices are owned by the same customer. * Example of value for parameter arrayofamounts: {"1": "99.99", "2": "10"} * - * @param string $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice + * @param array $arrayofamounts {@from body} Array with id of invoices with amount to pay for each invoice * @param string $datepaye {@from body} Payment date {@type timestamp} * @param int $paiementid {@from body} Payment mode Id {@min 1} * @param string $closepaidinvoices {@from body} Close paid invoices {@choice yes,no} diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index e52658d38e8..40205ff0a97 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -979,6 +979,8 @@ class FactureRec extends CommonInvoice { global $conf, $langs, $db, $user; + $error=0; + $langs->load("bills"); $nb_create=0; @@ -1010,11 +1012,13 @@ class FactureRec extends CommonInvoice while ($i < $num) // Loop on each template invoice. If $num = 0, test is false at first pass. { - $line = $db->fetch_object($resql); + $line = $db->fetch_object($resql); $db->begin(); - $facturerec = new FactureRec($db); + $invoiceidgenerated = 0; + + $facturerec = new FactureRec($db); $facturerec->fetch($line->rowid); if ($facturerec->id > 0) @@ -1024,8 +1028,6 @@ class FactureRec extends CommonInvoice dol_syslog("createRecurringInvoices Process invoice template id=".$facturerec->id.", ref=".$facturerec->ref.", entity=".$facturerec->entity); - $error=0; - $facture = new Facture($db); $facture->fac_rec = $facturerec->id; // We will create $facture from this recurring invoice $facture->fk_fac_rec_source = $facturerec->id; // We will create $facture from this recurring invoice diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 3c8a2a9aef6..dadb5ee5e5d 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -164,7 +164,7 @@ if($calc ==0 || $calc == 2) print "
".$vatcust."
'.$previousmonth."
"; + $db->free($result); } else { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 502f962dede..d157cafd5f8 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -38,6 +38,7 @@ function dol_encode($chain, $key='1') { if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { + $output_tab=array(); $strlength=dol_strlen($chain); for ($i=0; $i < $strlength; $i++) { @@ -75,6 +76,7 @@ function dol_decode($chain, $key='1') if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { + $output_tab=array(); $strlength=dol_strlen($chain); for ($i=0; $i < $strlength;$i++) { diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 0d46503c51b..57bb32ef1a3 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -580,7 +580,7 @@ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $dire $paymentfacturetable='paiement_facture'; $invoicefieldref='facnumber'; } - if ($direction == 'buy') + else { $invoicetable='facture_fourn'; $invoicedettable='facture_fourn_det'; diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index d2db656a6f2..c8c765e454d 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -482,7 +482,7 @@ class printing_printgcp extends PrintingDriver } else { - $html .= '
'.$langs->trans("None").'