From a45ffeecca5eba9e050b2c36207fc1c923897a26 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Mar 2016 18:21:57 +0100 Subject: [PATCH 001/123] Missing changelog --- ChangeLog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2144fe54620..dbc858dc1d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,18 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 3.5.8 compared to 3.5.7 ***** +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: bad calculation for stock value +FIX: bad stock valo +FIX: change order date on clone (as everywhere else) +FIX: CVE CVE-2015-8685 +FIX: The hours of date filter aren't correct +FIX: #3442 Remove useless syslog +FIX: #3448 Pass expected date format +FIX: #3471 3.5 Rounding issue when dispatching non-integer + ***** ChangeLog for 3.5.7 compared to 3.5.6 ***** Fix: Paypal link were broken due to SSL v3 closed. Fix: [ bug #1769 ] Error when installing to a PostgreSQL DB that contains numbers From 32d0f9a8d771685d962e405b9f0c76d9a586df19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Mar 2016 18:27:04 +0100 Subject: [PATCH 002/123] Prepare 3.6.7 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index d1784fb4863..3c1d1fdea0e 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.6'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.6.7'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From e669dac3980f7da1e11d20a4b16d7ab0484497f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Mar 2016 18:28:39 +0100 Subject: [PATCH 003/123] Prepare 3.6.7 --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index fe638ab3902..9a0da671af3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 3.6.7 compared to 3.6.6 ***** +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: CVE CVE-2015-8685 ***** ChangeLog for 3.6.6 compared to 3.6.5 ***** FIX: #3734 Do not show empty links of deleted source objects in stock movement list From 444fce0bd9ccecef83a3dbbb8ed2704efcbd264d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Mar 2016 18:34:05 +0100 Subject: [PATCH 004/123] Prepare 3.7.4 --- ChangeLog | 17 +++++++++++++++++ htdocs/filefunc.inc.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ce76d999605..b28b5a4be64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,23 @@ Upgrading to any other version or database system is abolutely required BEFORE t make a Dolibarr upgrade. +***** ChangeLog for 3.7.4 compared to 3.7.3 ***** +FIX: #3694 +FIX: #4239 +FIX: #4291 Correctly filter external calendar GETPOSTs +FIX: #4341 +FIX: #4414 Supplier invoices use FAC_FORCE_DATE_VALIDATION client invoices property +FIX: #4440 Wrong price is filled by Product::fetch into multiprices arrays +FIX: add missing global def for ttc column +FIX: Contrat card don't consider user permissions to show active/unactive service button +FIX: CVE CVE-2015-8685 +FIX: Email templates not compatible with Multicompany +Fix: for avoid division by 0 +FIX: ISSUE #4506 : make working the PROPAL_CLONE_ON_CREATE_PAGE hidden constant +FIX: $outputlangs is not defined (dolibarr 3.7, 3.8, 3.9) +FIX: sql injection even when code is on several lines +FIX: The third dashboard don't consider user permissions + ***** ChangeLog for 3.7.3 compared to 3.7.2 ***** FIX: #3734 Do not show empty links of deleted source objects in stock movement list FIX: #3890 Expected transactions bank account page, shows negative numbers diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index fc909577415..66b0582b17b 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -29,7 +29,7 @@ * \brief File that include conf.php file and commons lib like functions.lib.php */ -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.7.3'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.7.4'); if (! defined('EURO')) define('EURO',chr(128)); // Define syslog constants From df1c5697beff392030a693fe61abee9bb5d0a892 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Sat, 12 Mar 2016 19:07:56 +0100 Subject: [PATCH 005/123] [fix]: define to avoid issue with external pdf models --- htdocs/commande/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index d8ac0b6d63d..e2ac24caeca 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2016 Philippe Grand * Copyright (C) 2012-2013 Christophe Battarel * Copyright (C) 2012 Marcos García * Copyright (C) 2012 Cedric Salvador @@ -2446,6 +2446,7 @@ if ($action == 'create' && $user->rights->commande->creer) $ref = dol_sanitizeFileName($object->ref); include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($ref, '/').'[^\-]+'); $file = $fileparams['fullname']; // Define output language From 5d88c10e943d67eb3fce03be6f50edb77eec2846 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 13 Mar 2016 08:33:34 +0100 Subject: [PATCH 006/123] Missing language file --- htdocs/societe/consumption.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php index feaed5d9f7d..621a8988a04 100644 --- a/htdocs/societe/consumption.php +++ b/htdocs/societe/consumption.php @@ -5,9 +5,6 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Ferran Marcet * - * Version V1.1 Initial version of Philippe Berthet - * Version V2 Change to be compatible with 3.4 and enhanced to be more generic - * * 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 @@ -79,6 +76,7 @@ $langs->load("suppliers"); $langs->load("propal"); $langs->load("interventions"); $langs->load("contracts"); +$langs->load("products"); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('consumptionthirdparty')); From 08c5fd2e36af5b7b775cd7a73a35f914d58acee4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Mar 2016 14:38:30 +0100 Subject: [PATCH 007/123] FIX #4809 - Duplicate functions with different content --- htdocs/comm/propal/class/propal.class.php | 2 ++ htdocs/commande/class/commande.class.php | 12 +++++++----- htdocs/compta/facture/class/facture.class.php | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 0159e767ff3..bca97f09188 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2803,6 +2803,8 @@ class Propal extends CommonObject */ function getLinesArray() { + // For other object, here we call fetch_lines. But fetch_lines does not exists on proposal + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 3137cd9c7dc..85d5c5cebc4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1702,7 +1702,7 @@ class Commande extends CommonOrder $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (p.rowid = l.fk_product)'; $sql.= ' WHERE l.fk_commande = '.$this->id; if ($only_product) $sql .= ' AND p.fk_product_type = 0'; - $sql .= ' ORDER BY l.rang'; + $sql .= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG); $result = $this->db->query($sql); @@ -3233,12 +3233,14 @@ class Commande extends CommonOrder } /** - * Return an array of order lines - * - * @return array Lines of order + * Create an array of order lines + * + * @return int >0 if OK, <0 if KO */ function getLinesArray() { + return $this->fetch_lines(); + /* $lines = array(); $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.price, l.qty, l.tva_tx, '; @@ -3308,7 +3310,7 @@ class Commande extends CommonOrder { $this->error=$this->db->error(); return -1; - } + }*/ } /** diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 614c7d3f33a..d2fdf68172c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1097,7 +1097,7 @@ class Facture extends CommonInvoice $this->lines=array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.tva_tx, '; - $sql .= ' l.situation_percent, l.fk_prev_id,'; + $sql.= ' l.situation_percent, l.fk_prev_id,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; $sql.= ' l.date_start as date_start, l.date_end as date_end,'; @@ -1107,7 +1107,7 @@ class Facture extends CommonInvoice $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; - $sql.= ' ORDER BY l.rang'; + $sql.= ' ORDER BY l.rang, l.rowid'; dol_syslog(get_class($this).'::fetch_lines', LOG_DEBUG); $result = $this->db->query($sql); @@ -3474,6 +3474,8 @@ class Facture extends CommonInvoice */ function getLinesArray() { + return $this->fetch_lines(); + /* $sql = 'SELECT l.rowid, l.label as custom_label, l.description, l.fk_product, l.product_type, l.qty, l.tva_tx,'; $sql.= ' l.fk_remise_except, l.localtax1_tx, l.localtax2_tx,'; $sql .= ' l.situation_percent, l.fk_prev_id,'; @@ -3506,11 +3508,12 @@ class Facture extends CommonInvoice $this->lines[$i]->description = $obj->description; $this->lines[$i]->fk_product = $obj->fk_product; $this->lines[$i]->ref = $obj->product_ref; - $this->lines[$i]->entity = $obj->entity; // Product entity - $this->lines[$i]->product_label = $obj->product_label; + $this->lines[$i]->product_ref = $obj->product_ref; + $this->lines[$i]->product_label = $obj->product_label; $this->lines[$i]->product_desc = $obj->product_desc; $this->lines[$i]->fk_product_type = $obj->fk_product_type; $this->lines[$i]->product_type = $obj->product_type; + $this->lines[$i]->entity = $obj->entity; // Product entity $this->lines[$i]->qty = $obj->qty; $this->lines[$i]->subprice = $obj->subprice; $this->lines[$i]->fk_remise_except = $obj->fk_remise_except; @@ -3520,6 +3523,10 @@ class Facture extends CommonInvoice $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->localtax1_tx = $obj->localtax1_tx; + $this->lines[$i]->localtax2_tx = $obj->localtax2_tx; + $this->lines[$i]->localtax1_type = $obj->localtax1_type; + $this->lines[$i]->localtax2_type = $obj->localtax2_type; $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->situation_percent = $obj->situation_percent; $this->lines[$i]->fk_prev_id = $obj->fk_prev_id; @@ -3544,7 +3551,7 @@ class Facture extends CommonInvoice { $this->error=$this->db->error(); return -1; - } + }*/ } /** From 416766349122a1de59156d54dc912a4ea90896b7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 15 Mar 2016 06:53:17 +0100 Subject: [PATCH 008/123] Fix: 3.9 Problem of rowspan in edit mode --- htdocs/user/card.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dd424a9e0e6..9638e7070bf 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Ari Elbaz (elarifr) * @@ -1065,7 +1065,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ''.$langs->trans("AccountancyCode").''; print ''; @@ -1402,7 +1402,7 @@ else print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ''.$langs->trans("AccountancyCode").''; print ''.$object->accountancy_code.''; @@ -1749,13 +1749,14 @@ else dol_fiche_head($head, 'user', $title, 0, 'user'); - $rowspan=17; + $rowspan=22; if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; if (! empty($conf->skype->enabled)) $rowspan++; if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3; if (! empty($conf->agenda->enabled)) $rowspan++; + if (! empty($conf->accounting->enabled)) $rowspan++; print ''; @@ -2173,7 +2174,7 @@ else print "\n"; // Accountancy code - if ($conf->salaries->enabled) + if ($conf->accounting->enabled) { print ""; print ''; From 19d75772673da581e5e3beaad2bce074a8d9fede Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Tue, 15 Mar 2016 11:14:51 +0100 Subject: [PATCH 009/123] FIX Bad function name call on delete --- htdocs/projet/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index c6511e2a67d..58943ad3d30 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -352,7 +352,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result > 0) { - setEventMessagess($langs->trans("RecordDeleted"), null, 'mesgs'); + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); header("Location: index.php"); exit; } From 610249068d58a0fe67565518404d77ba85638fd5 Mon Sep 17 00:00:00 2001 From: Drosis Nikos Date: Tue, 15 Mar 2016 12:48:46 +0200 Subject: [PATCH 010/123] Fix syntax SQL error when ordering product list --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 6451f8bdde5..eb730bd63a4 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -423,7 +423,7 @@ else if (! empty($arrayfields['p.duration']['checked'])) print_liste_field_titre($arrayfields['p.duration']['label'], $_SERVER["PHP_SELF"],"p.duration","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['p.sellprice']['checked'])) print_liste_field_titre($arrayfields['p.sellprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.minbuyprice']['checked'])) print_liste_field_titre($arrayfields['p.minbuyprice']['label'], $_SERVER["PHP_SELF"],"","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desirestock","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['p.desiredstock']['checked'])) print_liste_field_titre($arrayfields['p.desiredstock']['label'], $_SERVER["PHP_SELF"],"p.desiredstock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.tobatch']['checked'])) print_liste_field_titre($arrayfields['p.tobatch']['label'], $_SERVER["PHP_SELF"],"p.tobatch","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['p.stock']['checked'])) print_liste_field_titre($arrayfields['p.stock']['label'], $_SERVER["PHP_SELF"],"p.stock","",$param,'align="right"',$sortfield,$sortorder); if (! empty($arrayfields['p.accountancy_code_sell']['checked'])) print_liste_field_titre($arrayfields['p.accountancy_code_sell']['label'], $_SERVER["PHP_SELF"],"p.accountancy_code_sell","",$param,'',$sortfield,$sortorder); From 1ded08abeffc754304c8beeb467d27b76e96432f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Mar 2016 21:02:45 +0100 Subject: [PATCH 011/123] FIX When using option Price per level, when adding a predefined product, the vat for customer was not correctly set. --- htdocs/comm/propal.php | 7 +++++-- htdocs/commande/card.php | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5406ba72a26..51057ec3af4 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -759,8 +759,11 @@ if (empty($reshook)) $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + } } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index e13381677c0..ebe2b58745d 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -657,10 +657,11 @@ if (empty($reshook)) $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; - if (isset($prod->multiprices_tva_tx[$object->client->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->client->price_level]; - if (isset($prod->multiprices_recuperableonly[$object->client->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->client->price_level]; - $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; - $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + { + if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level]; + if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; + } } elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { From ad942afbf1ea47f4af02bd29e0ce4007a7f251a8 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 16 Mar 2016 16:30:59 +0100 Subject: [PATCH 012/123] FIX: Not showing sellprice properly on product list --- htdocs/product/list.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 6451f8bdde5..b9a2fda5147 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -10,6 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Adolfo segura * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 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 @@ -79,6 +80,7 @@ if ($type === '0') { $contextpage='productlist'; if ($search_type=='') $search_t // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); +$form=new Form($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('product'); @@ -120,6 +122,15 @@ if (! empty($conf->barcode->enabled)) { $fieldstosearchall['p.barcode']='Gencod'; } +if (empty($conf->global->PRODUIT_MULTIPRICES)) +{ + $titlesellprice=$langs->trans("SellingPrice"); + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + $titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); + } +} + // Definition of fields for lists $arrayfields=array( 'p.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -176,7 +187,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP */ $htmlother=new FormOther($db); -$form=new Form($db); if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { @@ -402,16 +412,7 @@ else print ''; } - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - $titlesellprice=$langs->trans("SellingPrice"); - if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) - { - $titlesellprice=$form->textwithpicto($langs->trans("SellingPrice"), $langs->trans("DefaultPriceRealPriceMayDependOnCustomer")); - } - } - - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
'.$langs->trans("AccountancyCode").'
'; From a1bc5dcc310f10616e12ec31a3f8ce1622b5b650 Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 16 Mar 2016 16:35:07 +0100 Subject: [PATCH 013/123] FIX: Not showing sellprice properly on product list --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b9a2fda5147..68b4c67ad72 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -412,7 +412,7 @@ else print ''; } - $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print '
'; From d2d38f58bf7d320b29e0047f516c4ec9a2744b9d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2016 09:22:12 +0100 Subject: [PATCH 014/123] Fix: beware with merges in conflict !! --- htdocs/user/card.php | 390 +++++++++++++++---------------- htdocs/user/class/user.class.php | 36 +-- 2 files changed, 202 insertions(+), 224 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dd424a9e0e6..4c34542ce59 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -3,7 +3,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent @@ -203,7 +203,7 @@ if (empty($reshook)) { $object->ldap_sid = GETPOST("ldap_sid"); $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; $object->employee = GETPOST('employee'); - + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; @@ -249,15 +249,15 @@ if (empty($reshook)) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; - } + } else { $langs->load("errors"); $db->rollback(); - if (is_array($object->errors) && count($object->errors)) + if (is_array($object->errors) && count($object->errors)) { setEventMessages($object->error, $object->errors, 'errors'); - } + } $action = "create"; // Go back to create page } } @@ -283,8 +283,8 @@ if (empty($reshook)) { if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF'].'?id='.$id); exit; - } - else + } + else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -298,220 +298,198 @@ if (empty($reshook)) { { $error = 0; - if (!$_POST["lastname"]) { - setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; - } - if (!$_POST["login"]) { - setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); - $action = "edit"; // Go back to create page - $error ++; - } + if (!$_POST["lastname"]) { + setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); + $action = "edit"; // Go back to create page + $error ++; + } + if (!$_POST["login"]) { + setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); + $action = "edit"; // Go back to create page + $error ++; + } - if (!$error) { - $object->fetch($id); + if (!$error) { + $object->fetch($id); - $object->oldcopy = clone $object; + $object->oldcopy = clone $object; - if (!$error) { - $db->begin(); + if (!$error) { + $db->begin(); - $object->oldcopy = dol_clone($object); + $object->oldcopy = dol_clone($object); - $object->lastname = GETPOST("lastname", 'alpha'); - $object->firstname = GETPOST("firstname", 'alpha'); - $object->login = GETPOST("login", 'alpha'); - $object->gender = GETPOST("gender", 'alpha'); - $object->pass = GETPOST("password"); - $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; - $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin - $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->office_phone = GETPOST("office_phone", 'alpha'); - $object->office_fax = GETPOST("office_fax", 'alpha'); - $object->user_mobile = GETPOST("user_mobile"); - $object->skype = GETPOST("skype", 'alpha'); - $object->email = GETPOST("email", 'alpha'); - $object->job = GETPOST("job", 'alpha'); - $object->signature = GETPOST("signature"); - $object->accountancy_code = GETPOST("accountancy_code"); - $object->openid = GETPOST("openid"); - $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; - $object->employee = GETPOST('employee'); - - $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; - $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; - $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; - $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; - $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; + $object->lastname = GETPOST("lastname", 'alpha'); + $object->firstname = GETPOST("firstname", 'alpha'); + $object->login = GETPOST("login", 'alpha'); + $object->gender = GETPOST("gender", 'alpha'); + $object->pass = GETPOST("password"); + $object->api_key = (GETPOST("api_key", 'alpha')) ? GETPOST("api_key", 'alpha') : $object->api_key; + $object->admin = empty($user->admin) ? 0 : GETPOST("admin"); // A user can only be set admin by an admin + $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->office_phone = GETPOST("office_phone", 'alpha'); + $object->office_fax = GETPOST("office_fax", 'alpha'); + $object->user_mobile = GETPOST("user_mobile"); + $object->skype = GETPOST("skype", 'alpha'); + $object->email = GETPOST("email", 'alpha'); + $object->job = GETPOST("job", 'alpha'); + $object->signature = GETPOST("signature"); + $object->accountancy_code = GETPOST("accountancy_code"); + $object->openid = GETPOST("openid"); + $object->fk_user = GETPOST("fk_user") > 0 ? GETPOST("fk_user") : 0; + $object->employee = GETPOST('employee'); - if (! empty($conf->multicompany->enabled)) - { - if (! empty($_POST["superadmin"])) - { - $object->entity = 0; - } - else if ($conf->multicompany->transverse_mode) - { - $object->entity = 1; // all users in master entity - } - else - { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); - } - } - else - { - $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); - } + $object->thm = GETPOST("thm") != '' ? GETPOST("thm") : ''; + $object->tjm = GETPOST("tjm") != '' ? GETPOST("tjm") : ''; + $object->salary = GETPOST("salary") != '' ? GETPOST("salary") : ''; + $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; + $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; - // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) { - $error ++; - } + if (! empty($conf->multicompany->enabled)) + { + if (! empty($_POST["superadmin"])) + { + $object->entity = 0; + } + else if ($conf->multicompany->transverse_mode) + { + $object->entity = 1; // all users in master entity + } + else + { + $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + } + } + else + { + $object->entity = (! GETPOST('entity', 'int') ? 0 : GETPOST('entity', 'int')); + } - if (!empty($conf->multicompany->enabled)) { - if (!empty($_POST["superadmin"])) { - $object->entity = 0; - } else { - if ($conf->multicompany->transverse_mode) { - $object->entity = 1; // all users in master entity - } else { - $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); - } - } - } else { - $object->entity = (empty($_POST["entity"]) ? 0 : $_POST["entity"]); - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } - if (GETPOST('deletephoto')) { - $object->photo = ''; - } - if (!empty($_FILES['photo']['name'])) { - $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); - } + if (GETPOST('deletephoto')) { + $object->photo = ''; + } + if (!empty($_FILES['photo']['name'])) { + $object->photo = dol_sanitizeFileName($_FILES['photo']['name']); + } - if (!$error) { - $ret = $object->update($user); - if ($ret < 0) { - $error ++; - if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors'); - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } + if (!$error) { + $ret = $object->update($user); + if ($ret < 0) { + $error ++; + if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorLoginAlreadyExists", $object->login), null, 'errors'); + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - if (!$error && isset($_POST['contactid'])) { - $contactid = GETPOST('contactid'); + if (!$error && isset($_POST['contactid'])) { + $contactid = GETPOST('contactid', 'int'); - if ($contactid > 0) { - $contact = new Contact($db); - $contact->fetch($contactid); + if ($contactid > 0) { + $contact = new Contact($db); + $contact->fetch($contactid); - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET fk_socpeople=".$db->escape($contactid); - if ($contact->socid) { - $sql .= ", fk_soc=".$db->escape($contact->socid); - } - $sql .= " WHERE rowid=".$object->id; - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."user"; - $sql .= " SET fk_socpeople=NULL, fk_soc=NULL"; - $sql .= " WHERE rowid=".$object->id; - } - dol_syslog("fiche::update", LOG_DEBUG); - $resql = $db->query($sql); - if (!$resql) { - $error ++; - setEventMessages($db->lasterror(), null, 'errors'); - } - } + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET fk_socpeople=".$db->escape($contactid); + if (!empty($contact->socid)) { + $sql .= ", fk_soc=".$db->escape($contact->socid); + } + $sql .= " WHERE rowid=".$object->id; + } else { + $sql = "UPDATE ".MAIN_DB_PREFIX."user"; + $sql .= " SET fk_socpeople=NULL, fk_soc=NULL"; + $sql .= " WHERE rowid=".$object->id; + } + dol_syslog("usercard::update", LOG_DEBUG); + $resql = $db->query($sql); + if (!$resql) { + $error ++; + setEventMessages($db->lasterror(), null, 'errors'); + } + } - if (!$error && !count($object->errors)) { - if (GETPOST('deletephoto') && $object->photo) { - $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; - $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - } + if (!$error && !count($object->errors)) { + if (GETPOST('deletephoto') && $object->photo) { + $fileimg = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/'.$object->photo; + $dirthumbs = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user').'/logos/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } - if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { - $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); + if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name'])) { + $dir = $conf->user->dir_output.'/'.get_exdir($object->id, 2, 0, 1, $object, 'user'); - dol_mkdir($dir); + dol_mkdir($dir); - if (@is_dir($dir)) { - $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); - $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); + if (@is_dir($dir)) { + $newfile = $dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']); + $result = dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']); - if (!$result > 0) { - setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); - } else { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + if (!$result > 0) { + setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors'); + } else { + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); - } - } else { - $error ++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); - } - } - } + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality); + } + } else { + $error ++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); + } + } + } - if (!$error && !count($object->errors)) { - setEventMessages($langs->trans("UserModified"), null, 'mesgs'); - $db->commit(); + if (!$error && !count($object->errors)) { + setEventMessages($langs->trans("UserModified"), null, 'mesgs'); + $db->commit(); - $login = $_SESSION["dol_login"]; - if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login - { - $error++; - $langs->load("errors"); - setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); - } - } else { - $db->rollback(); - } - } - } else { - if ($caneditpassword) // Case we can edit only password - { - $object->fetch($id); + $login = $_SESSION["dol_login"]; + if ($login && $login == $object->oldcopy->login && $object->oldcopy->login != $object->login) // Current user has changed its login + { + $error++; + $langs->load("errors"); + setEventMessages($langs->transnoentitiesnoconv("ErrorFailedToCreateDir", $dir), $mesgs, 'errors'); + } + } else { + $db->rollback(); + } + } + } else { + if ($caneditpassword) // Case we can edit only password + { + $object->fetch($id); - $object->oldcopy = dol_clone($object); + $object->oldcopy = dol_clone($object); - $ret = $object->setPassword($user, $_POST["password"]); - if ($ret < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - } - } - - $object->oldcopy = clone $object; - - $ret=$object->setPassword($user,$_POST["password"]); - if ($ret < 0) - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $ret = $object->setPassword($user, $_POST["password"]); + if ($ret < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + } + } // Change password with a new generated one if ((($action == 'confirm_password' && $confirm == 'yes') @@ -526,16 +504,16 @@ if (empty($reshook)) { } else { // Succes if ($action == 'confirm_passwordsend' && $confirm == 'yes') { - if ($object->send_password($user, $newpassword) > 0) + if ($object->send_password($user, $newpassword) > 0) { setEventMessages($langs->trans("PasswordChangedAndSentTo", $object->email), null, 'mesgs'); - } - else + } + else { setEventMessages($object->error, $object->errors, 'errors'); } - } - else + } + else { setEventMessages($langs->trans("PasswordChangedTo", $newpassword), null, 'errors'); } @@ -589,8 +567,8 @@ if (empty($reshook)) { $ldap_sid = $attribute[$conf->global->LDAP_FIELD_SID]; } } - } - else + } + else { setEventMessages($ldap->error, $ldap->errors, 'errors'); } @@ -921,7 +899,7 @@ if (($action == 'create') || ($action == 'adduserldap')) print $formcompany->select_state($object->state_id,$object->country_code, 'state_id'); print ''; } - + // Tel print ''; print '\n"; //print "\n"; } From d4529d19c7bc760a9e5153ab3f632dd247a122ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 1 Apr 2016 17:32:58 +0200 Subject: [PATCH 070/123] Update facture.php ref_client in order ref_customer in shipping --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 5fab485e655..c13d8197801 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1906,7 +1906,7 @@ if ($action == 'create') $objectsrc->fetch_thirdparty(); $projectid = (! empty($projectid) ? $projectid : $objectsrc->fk_project); - $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); + $ref_client = (! empty($objectsrc->ref_client) ? $objectsrc->ref_client : (! empty($objectsrc->ref_customer) ? $objectsrc->ref_customer:'')); $ref_int = (! empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); // only if socid not filled else it's allready done upper From be8384389f04a9310f37e8edf35c167af7a16870 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 14:15:38 +0200 Subject: [PATCH 071/123] FIX Creation of thumb image for size "small" was not done. Conflicts: htdocs/core/lib/files.lib.php --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 25b5712d3f4..df0ae0d40ee 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1467,7 +1467,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example - $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheigthsmall, '_small', 50, "thumbs"); + $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); From 599b225489ceca826190f331a1070e8d85c0c9f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 14:15:38 +0200 Subject: [PATCH 072/123] FIX Creation of thumb image for size "small" was not done. Conflicts: htdocs/core/lib/files.lib.php --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 8fc5bea72b6..42615ec51f4 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1139,7 +1139,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example - $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheigthsmall, '_small', 50, "thumbs"); + $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); From c0b2d7405a676fcc9d6788f9732df0d6a6b87bd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 14:46:04 +0200 Subject: [PATCH 073/123] FIX Generated thumbs must always use the png format so using thumbs can work. --- htdocs/core/lib/files.lib.php | 4 ++-- htdocs/core/lib/images.lib.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index df0ae0d40ee..a1bdf274995 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1467,10 +1467,10 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example - $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + $imgThumbSmall = vignette($destpath, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs", IMAGETYPE_PNG); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example - $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + $imgThumbMini = vignette($destpath, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs", IMAGETYPE_PNG); } setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 20a58d7021c..2fe9065b21c 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -301,7 +301,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x=0, $s * @param string $extName Extension to differenciate thumb file name ('_small', '_mini') * @param int $quality Quality of compression (0=worst, 100=best) * @param string $outdir Directory where to store thumb - * @param int $targetformat New format of target (1,2,3,... or 0 to keep old format) + * @param int $targetformat New format of target (IMAGETYPE_GIF, IMAGETYPE_JPG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_WBMP ... or 0 to keep old format) * @return string Full path of thumb or '' if it fails */ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $quality=50, $outdir='thumbs', $targetformat=0) From 066c793de2336a37490c486253a27f1f996cd8b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Apr 2016 15:00:58 +0200 Subject: [PATCH 074/123] FIX image extension must be in lower case Conflicts: htdocs/core/lib/files.lib.php --- htdocs/core/class/html.formfile.class.php | 10 +++++++--- htdocs/core/lib/files.lib.php | 6 ++++++ htdocs/core/lib/images.lib.php | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1226d3b35ba..8c704aba52d 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -859,11 +859,15 @@ class FormFile { $fileinfo = pathinfo($file['name']); print ''; + print ''; print ''; + $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + print $form->select_company($object->socid, 'socid', '', 'SelectThirdParty', 1, 0, $events, 0); + print ''; + print ''; // Contact - print ''; + print ''; + print ''; + print ''; } // Project @@ -1108,10 +1113,10 @@ if ($id > 0) { $formproject=new FormProjets($db); - $langs->load("project"); + $langs->load("projects"); - print ''; @@ -1136,7 +1141,7 @@ if ($id > 0) print ''; @@ -1281,7 +1286,7 @@ if ($id > 0) // Third party - Contact if ($conf->societe->enabled) { - print ''; - } + 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); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ee4add6d4c5..d9fa371e443 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -322,7 +322,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0123d539f50..c925a587b33 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4841,7 +4841,7 @@ class Form /* var_dump($val); var_dump(array_key_exists('enabled', $val)); var_dump(!$val['enabled']);*/ - if (array_key_exists('enabled', $val) && ! $val['enabled']) + if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) { unset($array[$key]); // We don't want this field continue; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 8e4f1ac20aa..c78483bb93d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -260,7 +260,7 @@ else $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 9ae3513fa8a..f520e7ba1a6 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -106,7 +106,7 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('project'); +$extralabels = $extrafields->fetch_name_optionals_label('projet'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -218,16 +218,15 @@ $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."projet as p"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields as ef on (p.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_lead_status as cls on p.fk_opp_status = cls.rowid"; - // 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 .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; if ($search_user > 0) { $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; } - $sql.= " WHERE p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser @@ -274,6 +273,19 @@ if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_sale > 0) $sql.= " AND sc.fk_user = " .$search_sale; 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))"; if ($search_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_user; +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -481,10 +493,25 @@ if ($resql) { 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 ''; + } } - } - // Fields from hook + } + // 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; diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e140ee2f672..0f955484bfe 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -66,7 +66,7 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('project'); +$extralabels = $extrafields->fetch_name_optionals_label('projet_task'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // Security check @@ -226,6 +226,7 @@ $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid,"; $sql.= " ".MAIN_DB_PREFIX."projet_task as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_extrafields as ef on (t.rowid = ef.fk_object)"; if ($search_project_user > 0) { $sql.=", ".MAIN_DB_PREFIX."element_contact as ecp"; @@ -275,6 +276,19 @@ if ($search_projectstatus >= 0) $sql .= " AND p.fk_statut = ".$db->escape($searc if ($search_public!='') $sql .= " AND p.public = ".$db->escape($search_public); if ($search_project_user > 0) $sql.= " AND ecp.fk_c_type_contact IN (".join(',',array_keys($listofprojectcontacttype)).") AND ecp.element_id = p.rowid AND ecp.fk_socpeople = ".$search_project_user; if ($search_task_user > 0) $sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$search_task_user; +// Add where from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); + } +} // Add where from hooks $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook @@ -478,14 +492,29 @@ if ($resql) if (! empty($arrayfields['t.duration_effective']['checked'])) print ''; if (! empty($arrayfields['t.progress_calculated']['checked'])) print ''; if (! empty($arrayfields['t.progress']['checked'])) print ''; - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key => $val) + // 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'])) print ''; + 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 diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 48202706ff7..80e54742765 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -101,7 +101,7 @@ $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('thirdparty'); +$extralabels = $extrafields->fetch_name_optionals_label('societe'); $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); // List of fields to search into when doing a "search in all" @@ -170,7 +170,6 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } } - /* @@ -402,7 +401,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); @@ -593,35 +592,35 @@ if ($resql) { print ''; } // Barcode if (! empty($arrayfields['s.barcode']['checked'])) { print ''; } // Customer code if (! empty($arrayfields['s.code_client']['checked'])) { print ''; } // Supplier code if (! empty($arrayfields['s.code_fournisseur']['checked'])) { print ''; } // Account Customer code if (! empty($arrayfields['s.code_compta']['checked'])) { print ''; } // Account Supplier code @@ -635,14 +634,14 @@ if ($resql) if (! empty($arrayfields['s.town']['checked'])) { print ''; } // Zip if (! empty($arrayfields['s.zip']['checked'])) { print ''; } // Country @@ -663,42 +662,42 @@ if ($resql) { // IdProf1 print ''; } if (! empty($arrayfields['s.siret']['checked'])) { // IdProf2 print ''; } if (! empty($arrayfields['s.ape']['checked'])) { // IdProf3 print ''; } if (! empty($arrayfields['s.idprof4']['checked'])) { // IdProf4 print ''; } if (! empty($arrayfields['s.idprof5']['checked'])) { // IdProf5 print ''; } if (! empty($arrayfields['s.idprof6']['checked'])) { // IdProf6 print ''; } @@ -760,7 +759,18 @@ if ($resql) { if (! empty($arrayfields["ef.".$key]['checked'])) { - print ''; } } diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 8710dc87e04..bc2f9249dea 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -213,7 +213,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); @@ -368,7 +368,22 @@ if ($result) { 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 ''; + } } } // Fields from hook From d3794bb145d04ad954b197c5e6e5dbac959dd73e Mon Sep 17 00:00:00 2001 From: fmarcet Date: Tue, 5 Apr 2016 16:49:50 +0200 Subject: [PATCH 079/123] FIX: Not removing code into vatrate. --- htdocs/contrat/class/contrat.class.php | 4 ++-- htdocs/fourn/class/fournisseur.facture.class.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 37eaa1db04d..74ea611dc96 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2013 Christophe Battarel * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2015-2016 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 @@ -1514,7 +1514,7 @@ class Contrat extends CommonObject // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $localtaxes_type=getLocalTaxesFromRate($tvatx, 0, $this->societe, $mysoc); - $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. + $tvatx = preg_replace('/\s*\(.*\)/','',$tvatx); // Remove code into vatrate. $tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtax1tx, $localtax2tx, 0, $price_base_type, $info_bits, 1, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 64c988e74e1..8617748d369 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -9,6 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2015 Bahfir Abbes + * Copyright (C) 2015 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 @@ -1269,7 +1270,7 @@ class FactureFournisseur extends CommonInvoice // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $localtaxes_type=getLocalTaxesFromRate($vatrate,0,$mysoc, $this->thirdparty); - $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. + $vatrate = preg_replace('/\s*\(.*\)/','',$vatrate); // Remove code into vatrate. $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type); $total_ht = $tabprice[0]; From ed0ab05b93acc836f08c76871f6bb0682e1b1bd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2016 17:11:44 +0200 Subject: [PATCH 080/123] FIX Damn, where was the project ref ? --- htdocs/core/modules/modCommande.class.php | 7 ++++--- htdocs/core/modules/modFacture.class.php | 14 ++++++++------ htdocs/core/modules/modPropale.class.php | 7 ++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 8390e1f10a0..c993cb3eda3 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -178,10 +178,10 @@ class modCommande extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='CustomersOrdersAndOrdersLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("commande","commande","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.label'=>'Country','co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.label'=>'Country','co.code'=>"CountryCode",'s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",'c.date_commande'=>"OrderDate",'c.amount_ht'=>"Amount",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total_ttc'=>"TotalTTC",'c.facture'=>"Billed",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.label'=>'company','co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",'c.date_livraison'=>"order",'cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.label'=>'company','co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"order",'c.ref'=>"order",'c.ref_client'=>"order",'c.fk_soc'=>"order",'c.date_creation'=>"order",'c.date_commande'=>"order",'c.amount_ht'=>"order",'c.remise_percent'=>"order",'c.total_ht'=>"order",'c.total_ttc'=>"order",'c.facture'=>"order",'c.fk_statut'=>"order",'c.note'=>"order",'c.date_livraison'=>"order",'pj.ref'=>'project','cd.rowid'=>'order_line','cd.label'=>"order_line",'cd.description'=>"order_line",'cd.product_type'=>'order_line','cd.tva_tx'=>"order_line",'cd.qty'=>"order_line",'cd.total_ht'=>"order_line",'cd.total_tva'=>"order_line",'cd.total_ttc'=>"order_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('order_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $keyforselect='commande'; $keyforelement='order'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -193,6 +193,7 @@ class modCommande extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande as c'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_extrafields as extra ON c.rowid = extra.fk_object'; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index f5b4d3dac2e..5ab27f65671 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -180,10 +180,10 @@ class modFacture extends DolibarrModules $this->export_label[$r]='CustomersInvoicesAndInvoiceLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("facture","facture","export","other")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','fd.rowid'=>'LineId','fd.label'=>"Label",'fd.description'=>"LineDescription",'fd.subprice'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalVAT",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.special_code'=>'SpecialCode','fd.product_type'=>"TypeOfLineServiceOrProduct",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_sell'=>'ProductAccountancySellCode'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'LineId','fd.label'=>"Label",'fd.description'=>"LineDescription",'fd.subprice'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalVAT",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",'fd.date_end'=>"DateEnd",'fd.special_code'=>'SpecialCode','fd.product_type'=>"TypeOfLineServiceOrProduct",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel','p.accountancy_code_sell'=>'ProductAccountancySellCode'); //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.price'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','p.accountancy_code_sell'=>'Text'); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.label'=>"invoice_line",'fd.description'=>"invoice_line",'fd.subprice'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.special_code'=>'invoice_line','fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_sell'=>'product','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text", 'pj.ref'=>'Text', 'fd.description'=>"Text",'fd.subprice'=>"Numeric",'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text','p.accountancy_code_sell'=>'Text'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice", 'pj.ref'=>'project', 'fd.rowid'=>'invoice_line','fd.label'=>"invoice_line",'fd.description'=>"invoice_line",'fd.subprice'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.special_code'=>'invoice_line','fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_sell'=>'product','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user'); $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $keyforselect='facture'; $keyforelement='invoice'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -195,6 +195,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object'; @@ -210,10 +211,10 @@ class modFacture extends DolibarrModules $this->export_label[$r]='CustomersInvoicesAndPayments'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r]='bill'; $this->export_permission[$r]=array(array("facture","facture","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','p.rowid'=>'PaymentId','p.ref'=>'PaymentRef','p.amount'=>'AmountPayment','pf.amount'=>'AmountPaymentDistributedOnInvoice','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','pt.code'=>'PaymentMode','p.note'=>'PaymentNote','p.fk_bank'=>'IdTransaction','ba.ref'=>'AccountRef'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra','f.rowid'=>"InvoiceId",'f.facnumber'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",'f.datef'=>"DateInvoice",'f.date_lim_reglement'=>"DateDue",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus','f.note_private'=>"NotePrivate",'f.note_public'=>"NotePublic",'f.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','f.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'p.rowid'=>'PaymentId','p.ref'=>'PaymentRef','p.amount'=>'AmountPayment','pf.amount'=>'AmountPaymentDistributedOnInvoice','p.datep'=>'DatePayment','p.num_paiement'=>'PaymentNumber','pt.code'=>'PaymentMode','p.note'=>'PaymentNote','p.fk_bank'=>'IdTransaction','ba.ref'=>'AccountRef'); //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"List:facture:facnumber",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'pf.amount'=>'Numeric','p.datep'=>'Date','p.num_paiement'=>'Numeric','p.fk_bank'=>'Numeric'); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"Numeric",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'p.amount'=>'Numeric','pf.amount'=>'Numeric','p.rowid'=>'Numeric','p.ref'=>'Text','p.datep'=>'Date','p.num_paiement'=>'Numeric','p.fk_bank'=>'Numeric','p.note'=>'Text','pt.code'=>'Text','ba.ref'=>'Text'); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice",'p.rowid'=>'payment','p.ref'=>'payment','p.amount'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','pt.code'=>'payment','p.note'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user','p.fk_bank'=>'account','ba.ref'=>'account'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text','f.rowid'=>"Numeric",'f.facnumber'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text", 'pj.ref'=>'Text', 'p.amount'=>'Numeric','pf.amount'=>'Numeric','p.rowid'=>'Numeric','p.ref'=>'Text','p.datep'=>'Date','p.num_paiement'=>'Numeric','p.fk_bank'=>'Numeric','p.note'=>'Text','pt.code'=>'Text','ba.ref'=>'Text'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.facnumber'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.date_lim_reglement'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_private'=>"invoice",'f.note_public'=>"invoice", 'pj.ref'=>'project', 'p.rowid'=>'payment','p.ref'=>'payment','p.amount'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment','pt.code'=>'payment','p.note'=>'payment','f.fk_user_author'=>'user','uc.login'=>'user','f.fk_user_valid'=>'user','uv.login'=>'user','p.fk_bank'=>'account','ba.ref'=>'account'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $keyforselect='facture'; $keyforelement='invoice'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -221,6 +222,7 @@ class modFacture extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON f.fk_user_valid = uv.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'facture_extrafields as extra ON f.rowid = extra.fk_object'; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 65f5a4729b5..32ebb340e71 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -171,10 +171,10 @@ class modPropale extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='ProposalsAndProposalsLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("propale","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin','cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_client'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.datec'=>"DateCreation",'c.datep'=>"DatePropal",'c.fin_validite'=>"DateEndPropal",'c.remise_percent'=>"GlobalDiscount",'c.total_ht'=>"TotalHT",'c.total'=>"TotalTTC",'c.fk_statut'=>'Status','c.note_public'=>"Note",'c.date_livraison'=>'DeliveryDate','c.fk_user_author'=>'CreatedById','uc.login'=>'CreatedByLogin','c.fk_user_valid'=>'ValidatedById','uv.login'=>'ValidatedByLogin', 'pj.ref'=>'ProjectRef', 'cd.rowid'=>'LineId','cd.label'=>"Label",'cd.description'=>"LineDescription",'cd.product_type'=>'TypeOfLineServiceOrProduct','cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'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','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text'); - $this->export_TypeFields_array[$r]=array('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','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.ref'=>'Text','p.label'=>'Text'); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal",'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal",'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note_public'=>"propal",'c.date_livraison'=>"propal",'cd.rowid'=>'propal_line','cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line",'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); + $this->export_TypeFields_array[$r]=array('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','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date",'c.fin_validite'=>"Date",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",'c.total'=>"Numeric",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date', 'pj.ref'=>'Text', 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric",'cd.total_ttc'=>"Numeric",'p.ref'=>'Text','p.label'=>'Text'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.siret'=>'company','c.rowid'=>"propal",'c.ref'=>"propal",'c.ref_client'=>"propal",'c.fk_soc'=>"propal",'c.datec'=>"propal",'c.datep'=>"propal",'c.fin_validite'=>"propal",'c.remise_percent'=>"propal",'c.total_ht'=>"propal",'c.total'=>"propal",'c.fk_statut'=>"propal",'c.note_public'=>"propal",'c.date_livraison'=>"propal", 'pj.ref'=>'project', 'cd.rowid'=>'propal_line','cd.label'=>"propal_line",'cd.description'=>"propal_line",'cd.product_type'=>'propal_line','cd.tva_tx'=>"propal_line",'cd.qty'=>"propal_line",'cd.total_ht'=>"propal_line",'cd.total_tva'=>"propal_line",'cd.total_ttc'=>"propal_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('propal_line'=>'cd.rowid','product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $keyforselect='propal'; $keyforelement='propal'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; @@ -186,6 +186,7 @@ class modPropale extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s '; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'propal as c'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON c.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON c.fk_user_author = uc.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uv ON c.fk_user_valid = uv.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'propal_extrafields as extra ON c.rowid = extra.fk_object'; From f9d7c27bd2c1b4123cdb4feff1fddd7f61be65c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Apr 2016 17:17:40 +0200 Subject: [PATCH 081/123] FIX Export must use a left join to not loose lines --- htdocs/core/modules/modFicheinter.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 4578a3e60a9..c10b617887e 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -138,15 +138,18 @@ class modFicheinter extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='InterventionCardsAndInterventionLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("ficheinter","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation",'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote",'fd.rowid'=>'InterLineId','fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc"); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InterId",'f.ref'=>"InterRef",'f.datec'=>"InterDateCreation",'f.duree'=>"InterDuration",'f.fk_statut'=>'InterStatus','f.description'=>"InterNote", 'pj.ref'=>'ProjectRef', 'fd.rowid'=>'InterLineId','fd.date'=>"InterLineDate",'fd.duree'=>"InterLineDuration",'fd.description'=>"InterLineDesc"); //$this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric"); - $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean",'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric"); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention",'f.fk_statut'=>"intervention",'f.description'=>"intervention",'fd.rowid'=>"inter_line",'fd.date'=>"inter_line",'fd.duree'=>'inter_line','fd.description'=>'inter_line'); + $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','f.ref'=>"Text",'f.datec'=>"Date",'f.duree'=>"Duree",'f.fk_statut'=>'Statut','f.description'=>"Text",'f.datee'=>"Date",'f.dateo'=>"Date",'f.fulldayevent'=>"Boolean", 'pj.ref'=>'Text', 'fd.date'=>"Date",'fd.duree'=>"Duree",'fd.description'=>"Text",'fd.total_ht'=>"Numeric"); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company','f.rowid'=>"intervention",'f.ref'=>"intervention",'f.datec'=>"intervention",'f.duree'=>"intervention",'f.fk_statut'=>"intervention",'f.description'=>"intervention", 'pj.ref'=>'project', 'fd.rowid'=>"inter_line",'fd.date'=>"inter_line",'fd.duree'=>'inter_line','fd.description'=>'inter_line'); $this->export_dependencies_array[$r]=array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'fichinter as f, '.MAIN_DB_PREFIX.'fichinterdet as fd, '.MAIN_DB_PREFIX.'societe as s)'; - $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_fichinter'; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'fichinter as f'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'fichinterdet as fd ON f.rowid = fd.fk_fichinter,'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; + $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('intervention',1).')'; $r++; From 1f723cb8d0b15e922e36532cedf164ed5b6a655d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 7 Apr 2016 14:16:10 +0200 Subject: [PATCH 082/123] FIX : Template email must take care of positino column --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index a815875dc52..97a7434fd02 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -859,13 +859,13 @@ class FormMail extends Form { $ret=array(); - $sql = "SELECT rowid, label, topic, content, lang"; + $sql = "SELECT rowid, label, topic, content, lang, position"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; $sql.= " AND entity IN (".getEntity("c_email_templates").")"; $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - $sql.= $this->db->order("lang,label","ASC"); + $sql.= $this->db->order("position,lang,label","ASC"); //print $sql; $resql = $this->db->query($sql); From 9d6efde9357d5025745206730651797fb4615862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Thu, 7 Apr 2016 17:12:06 +0200 Subject: [PATCH 083/123] Prevent sentry logging error with 3.9 update Since we don't ship the required libraries anymore, if the module had been enabled before upgrade, the code was failing making Dolibarr totally unusable. Mitigated the issue by disabling sentry logging if the required libraries are unavailable. --- htdocs/core/modules/syslog/mod_syslog_sentry.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/syslog/mod_syslog_sentry.php b/htdocs/core/modules/syslog/mod_syslog_sentry.php index afea1a36375..a159a5edf2f 100644 --- a/htdocs/core/modules/syslog/mod_syslog_sentry.php +++ b/htdocs/core/modules/syslog/mod_syslog_sentry.php @@ -145,6 +145,10 @@ class mod_syslog_sentry extends LogHandler implements LogHandlerInterface */ public function export($content) { + if (! $this->isActive()) { + return; + } + global $conf; $dsn = $conf->global->SYSLOG_SENTRY_DSN; $client = new Raven_Client( From f7fb95cab8d88c975fdaf0439899743919823957 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Apr 2016 19:24:29 +0200 Subject: [PATCH 084/123] FIX Box disabled because bugged --- htdocs/core/boxes/box_task.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index d6a65884ffb..e7e8dafb22a 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -36,7 +36,8 @@ class box_task extends ModeleBoxes //var $depends = array("projet"); var $db; var $param; - + var $enabled = 0; // Disabled because bugged. + var $info_box_head = array(); var $info_box_contents = array(); From eb7bba956805d9b3e582e96fc688c056a1472050 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 15:41:01 +0200 Subject: [PATCH 085/123] Fix translation --- 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 e621d98641c..069ced7854e 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1494,7 +1494,7 @@ FCKeditorForProduct=WYSIWIG creation/edition of products/services description an FCKeditorForProductDetails=WYSIWIG creation/edition of products details lines for all entities (proposals, orders, invoices, etc...). Warning: Using this option for this case is seriously not recommended as it can create problems with special characters and page formating when building PDF files. FCKeditorForMailing= WYSIWIG creation/edition for mass eMailings (Tools->eMailing) FCKeditorForUserSignature=WYSIWIG creation/edition of user signature -FCKeditorForMail=WYSIWIG creation/edition for all mail (except Outils->eMailing) +FCKeditorForMail=WYSIWIG creation/edition for all mail (except Tools->eMailing) ##### OSCommerce 1 ##### OSCommerceErrorConnectOkButWrongDatabase=Connection succeeded but database doesn't look to be an OSCommerce database (Key %s not found in table %s). OSCommerceTestOk=Connection to server '%s' on database '%s' with user '%s' successfull. From 5753f217451b33a589feab210322e81f81cc9f56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 11:42:02 +0200 Subject: [PATCH 086/123] Missing translations --- htdocs/langs/en_US/agenda.lang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index cb7959a0901..d8747b74fe6 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -62,6 +62,9 @@ SupplierInvoiceSentByEMail=Supplier invoice %s sent by EMail ShippingSentByEMail=Shipment %s sent by EMail ShippingValidated= Shipment %s validated InterventionSentByEMail=Intervention %s sent by EMail +ProposalDeleted=Proposal deleted +OrderDeleted=Order deleted +InvoiceDeleted=Invoice deleted NewCompanyToDolibarr= Third party created DateActionPlannedStart= Planned start date DateActionPlannedEnd= Planned end date From 80caf58866d5de31f39d99d46d3b3155cea65134 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 19:16:40 +0200 Subject: [PATCH 087/123] FIX Default vat is not set correctly when an error occured and we use VAT identified by a code. --- htdocs/core/class/html.form.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c925a587b33..9a4fb17fa9c 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4013,11 +4013,18 @@ class Form $return=''; - // Define defaultnpr and defaultttx + // Define defaultnpr, defaultttx and defaultcode $defaultnpr=($info_bits & 0x01); $defaultnpr=(preg_match('/\*/',$selectedrate) ? 1 : $defaultnpr); $defaulttx=str_replace('*','',$selectedrate); - + $defaultcode=''; + if (preg_match('/\s*\((.*)\)/', $defaulttx, $reg)) + { + $defaultcode=$reg[1]; + $defaulttx=preg_replace('/\s*\(.*\)/','',$defaulttx); + } + //var_dump($defaulttx.'-'.$defaultnpr.'-'.$defaultcode); + // Check parameters if (is_object($societe_vendeuse) && ! $societe_vendeuse->country_code) { @@ -4113,9 +4120,13 @@ class Form $return.= $rate['nprtva'] ? '*': ''; if ($addcode && $rate['code']) $return.=' ('.$rate['code'].')'; $return.= '"'; - if ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) + if ($defaultcode) { - $return.= ' selected'; + if ($defaultcode == $rate['code']) $return.= ' selected'; + } + elseif ($rate['txtva'] == $defaulttx && $rate['nprtva'] == $defaultnpr) + { + $return.= ' selected'; } $return.= '>'.vatrate($rate['libtva']); //$return.=($rate['code']?' '.$rate['code']:''); From daa1aed3633ead45c650d16bfade6ca30075f21c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Apr 2016 19:31:18 +0200 Subject: [PATCH 088/123] Bad placeholder --- htdocs/societe/soc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 52f30317a3e..cb4f65abeed 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1885,7 +1885,7 @@ else 'name' => 'soc_origin', 'label' => $langs->trans('MergeOriginThirdparty'), 'type' => 'other', - 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 1, 0, 0, array(), 0, 'minwidth200') + 'value' => $form->select_company('', 'soc_origin', 's.rowid != '.$object->id, 'SelectThirdParty', 0, 0, array(), 0, 'minwidth200') ) ); From f90cffd74ab07245968688514f0e7fd63040a71f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 9 Apr 2016 15:42:53 +0200 Subject: [PATCH 089/123] Update nusoap.php re-establish user-agent --- htdocs/includes/nusoap/lib/nusoap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php index 403d74b13e9..6defe0e6004 100644 --- a/htdocs/includes/nusoap/lib/nusoap.php +++ b/htdocs/includes/nusoap/lib/nusoap.php @@ -2217,7 +2217,7 @@ class soap_transport_http extends nusoap_base { } $this->use_curl = $use_curl; preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev); - if (isset($rev[1])) $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')'); + $this->setHeader('User-Agent', $this->title.'/'.$this->version.(isset($rev[1])?' ('.$rev[1].')':'')); } /** From 9169adf4ceab98ad04a180653f205b4b928b7cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:34:55 +0200 Subject: [PATCH 090/123] FIX #4766 VAT not shown in supplier invoice popup Close #4766 --- htdocs/compta/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 5fb1d638a88..5c93c1e62db 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Marcos García * * 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 @@ -230,7 +231,7 @@ if (! empty($conf->facture->enabled) && $user->rights->facture->lire) */ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) { - $sql = "SELECT f.ref, f.rowid, f.total_ht, f.tva as total_tva, f.total_ttc, f.type"; + $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type"; $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; $sql.= ", s.code_fournisseur"; From b2f922291fefb66eb845ae7fce78ef536bcf60ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:38:58 +0200 Subject: [PATCH 091/123] FIX #4851 Project selector in supplier invoices shows the project label twice Close #4851 --- htdocs/core/class/html.formprojet.class.php | 2 +- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 2b7f76dedf9..4c094061ee4 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -180,7 +180,7 @@ class FormProjets continue; } - $labeltoshow=dol_trunc($obj->ref,18).' - '.$obj->title; + $labeltoshow=dol_trunc($obj->ref,18); //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')'; $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 890772326ea..42418184c4f 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1474,7 +1474,7 @@ class FactureFournisseur extends CommonInvoice if (! empty($this->total_ht)) $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_tva)) - $label.= '
' . $langs->trans('TVA') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); + $label.= '
' . $langs->trans('VAT') . ': ' . price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); From 1026484da1ec129a47cc84d4ec16e3d4863189df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:48:42 +0200 Subject: [PATCH 092/123] FIX #4748 Supplier invoice payment confirmation amount is not translated Close #4748 --- htdocs/fourn/facture/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 81fe1d6b345..d69c2df9a94 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -432,7 +432,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $preselectedchoice=$addwarning?'no':'yes'; print '
'; - $text=$langs->trans('ConfirmSupplierPayment',$totalpayment,$langs->trans("Currency".$conf->currency)); + $text=$langs->trans('ConfirmSupplierPayment', price($totalpayment),$langs->trans("Currency".$conf->currency)); if (GETPOST('closepaidinvoices')) { $text.='
'.$langs->trans("AllCompletelyPayedInvoiceWillBeClosed"); From 7cc1288bb2c4c9b86802f761664ff5903ff1b8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:54:13 +0200 Subject: [PATCH 093/123] FIX #4743 UI glitch in project summary page Close #4743 --- htdocs/projet/element.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 1be43fe94dd..c475dcbcae0 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -344,8 +344,7 @@ $langs->load("orders"); $langs->load("proposals"); $langs->load("margins"); -//print load_fiche_titre($langs->trans("Profit"),'','title_accountancy'); -print '
'.img_picto("", "title_accountancy").' '.$langs->trans("Profit").'

'; +print load_fiche_titre($langs->trans("Profit"), '', 'title_accountancy'); print '
'.$langs->trans("PhonePro").''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7307590016a..3470fb6b434 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -4,7 +4,7 @@ * Copyright (c) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2013-2014 Philippe Grand @@ -138,11 +138,11 @@ class User extends CommonObject // For cache usage $this->all_permissions_are_loaded = 0; - - // Force some default values + + // Force some default values $this->admin = 0; $this->employee = 1; - + $this->conf = new stdClass(); $this->rights = new stdClass(); $this->rights->user = new stdClass(); @@ -202,14 +202,14 @@ class User extends CommonObject } else { - $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database + $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database } } else // The fetch was forced on an entity { $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; } - + if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba { $sql.= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1"; @@ -239,7 +239,7 @@ class User extends CommonObject $this->ldap_sid = $obj->ldap_sid; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; - + $this->employee = $obj->employee; $this->login = $obj->login; @@ -298,8 +298,8 @@ class User extends CommonObject // Protection when module multicompany was set, admin was set to first entity and the module disabled, // then this admin user must be admin for all entities. - if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; - + if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; + // Retreive all extrafield for thirdparty // fetch optionals attributes and labels require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); @@ -1227,7 +1227,7 @@ class User extends CommonObject $this->error = $langs->trans("ErrorFieldRequired",$this->login); return -1; } - + $this->db->begin(); // Update datas @@ -1272,7 +1272,7 @@ class User extends CommonObject $nbrowsaffected+=$this->db->affected_rows($resql); // Update password - if ($this->pass) + if (!empty($this->pass)) { if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) { @@ -1893,7 +1893,7 @@ class User extends CommonObject global $menumanager; if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0; - + $result = ''; $companylink = ''; $link = ''; @@ -1947,11 +1947,11 @@ class User extends CommonObject $link.= 'global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $langs->load("users"); $label=$langs->trans("ShowUser"); - $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $link.=' alt="'.dol_escape_htmltag($label, 1).'"'; } $link.= ' title="'.dol_escape_htmltag($label, 1).'"'; $link.= ' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; @@ -1969,7 +1969,7 @@ class User extends CommonObject else $picto='
'.Form::showphoto('userphoto', $this, 0, 0, 0, 'loginphoto', 'mini', 0, 1).'
'; $result.=$picto; } - if (abs($withpictoimg) != 2) + if (abs($withpictoimg) != 2) { if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) $result.='
'; if ($mode == 'login') $result.=dol_trunc($this->login, $maxlen); @@ -2582,8 +2582,8 @@ class User extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - - + + /** * Charge indicateurs this->nb pour le tableau de bord * @@ -2618,6 +2618,6 @@ class User extends CommonObject return -1; } } - + } From d434cee3faf0443376abd430591299ecae5e7bd0 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Thu, 17 Mar 2016 09:40:05 +0100 Subject: [PATCH 015/123] [Qual] Typo --- ChangeLog | 6 +++--- htdocs/core/class/commonobjectline.class.php | 2 +- htdocs/core/modules/modIncoterm.class.php | 2 +- htdocs/product/class/product.class.php | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20c79c28ce7..7edc06afec0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1845,7 +1845,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac - Fix: [ bug #810 ] Cannot update ODT template path - Fix: [ bug #816 ] Sales journal does not reflect localtaxes - Fix: [ bug #817 ] Purchases journal does not reflect localtaxes -- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionnary +- Fix: [ bug #824 ] MAIN_DB_PREFIX not use into dictionary - Fix: [ bug #828 ] Error when code_region is not a number in llx_c_regions (with postgres) - Fix: [ bug #855 ] Holiday approval email in French - Fix: [ bug #856 ] (Holidays module) Mail error if destination user doesn't have an email @@ -1864,7 +1864,7 @@ backport commit 384e3812eb73a15adafb472cacfb93397a54459b to fix W3C/edit contrac - Fix: [ bug #736 ] Missing column in llx_c_chargesociales - Fix: Localtax2 for Spain must be based into buyer - Fix: [ bug #762 ] Bad profit calculation in Reporting -- Fix: bug dictionnary with wrong prefix table +- Fix: bug dictionary with wrong prefix table ***** ChangeLog for 3.3 compared to 3.2.* ***** For users: @@ -1952,7 +1952,7 @@ New experimental module: For developers: - New: Add webservice for thirdparty creation and list. - New: A module can overwrite templates parts. -- New: Can add a link on title field of added dictionnary. +- New: Can add a link on title field of added dictionary. - New: Uniformize code. - New: Add option WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER and WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER. diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 94c7b7bf860..84c49f6392d 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -51,7 +51,7 @@ abstract class CommonObjectLine extends CommonObject /** - * Returns the text label from units dictionnary + * Returns the text label from units dictionary * * @param string $type Label type (long or short) * @return string|int <0 if ko, label if ok diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index cae4f9ec28f..f7dba3a5e9d 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -91,7 +91,7 @@ class modIncoterm extends DolibarrModules 'tablib'=>array("Incoterms"), // Label of tables 'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields 'tabsqlsort'=>array("rowid ASC"), // Sort order - 'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionnary) + 'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary) 'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record) 'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert) 'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid') diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 66fe6edb19a..ec7a67aff83 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5,13 +5,13 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2007-2011 Jean Heimburger * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2012 Cedric Salvador + * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Cedric GROSS * Copyright (C) 2013-2015 Marcos García * Copyright (C) 2011-2014 Alexandre Spangaro * Copyright (C) 2014 Henry Florian - * Copyright (C) 2014 Philippe Grand - * Copyright (C) 2014 Ion agorria + * Copyright (C) 2014-2016 Philippe Grand + * Copyright (C) 2014 Ion agorria * Copyright (C) 2016 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -3927,7 +3927,7 @@ class Product extends CommonObject } /** - * Returns the text label from units dictionnary + * Returns the text label from units dictionary * * @param string $type Label type (long or short) * @return string|int <0 if ko, label if ok From 1683609d9a9befbd3429c2be4414015bfb7b8462 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Mar 2016 12:00:38 +0100 Subject: [PATCH 016/123] FIX Check of EAN13 barcode when mask was set to use 13 digits instead of 12 --- .../barcode/mod_barcode_product_standard.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 703db258e26..aeb7ea4cd8f 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -227,7 +227,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * Return if a code is used (by other element) * * @param DoliDB $db Handler acces base - * @param string $code Code a verifier + * @param string $code Code to check * @param Product $product Objet product * @return int 0 if available, <0 if KO */ @@ -277,12 +277,20 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode return ''; } + dol_syslog(get_class($this).'::verif_syntax codefortest='.$codefortest." typefortest=".$typefortest); + $newcodefortest=$codefortest; + + // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test if (in_array($typefortest,array('EAN13','ISBN'))) // We remove the CRC char not included into mask { - $newcodefortest=substr($newcodefortest,0,12); + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) + { + if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest,0,12); + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); + } } - + $result=check_value($mask,$newcodefortest); return $result; From aa7eb4935c5d4c60a115408d4ca64501e5968fcd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Mar 2016 12:18:47 +0100 Subject: [PATCH 017/123] FIX VAT rate can be negative. Example spain selling to morroco. --- htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php | 2 +- htdocs/core/modules/commande/doc/pdf_einstein.modules.php | 2 +- htdocs/core/modules/commande/doc/pdf_proforma.modules.php | 2 +- htdocs/core/modules/facture/doc/pdf_crabe.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php index 6729ea2a60c..acd3ddc1109 100644 --- a/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/askpricesupplier/doc/pdf_aurore.modules.php @@ -922,7 +922,7 @@ class pdf_aurore extends ModelePDFAskPriceSupplier // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index c29054cde54..849eeceac48 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -911,7 +911,7 @@ class pdf_einstein extends ModelePDFCommandes // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 7e5190dc5e6..50d62ee983f 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -818,7 +818,7 @@ class pdf_proforma extends ModelePDFCommandes // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 9716b6bd968..719449bcbd4 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1107,7 +1107,7 @@ class pdf_crabe extends ModelePDFFactures // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 818f6fdb560..f8e6874f3b2 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1073,7 +1073,7 @@ class pdf_azur extends ModelePDFPropales // VAT foreach($this->tva as $tvakey => $tvaval) { - if ($tvakey > 0) // On affiche pas taux 0 + if ($tvakey != 0) // On affiche pas taux 0 { $this->atleastoneratenotnull++; From ae16d6c45cef0f9b65806af6c2c979ae5dcf8d2a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2016 15:11:57 +0100 Subject: [PATCH 018/123] Fix: missing color update --- htdocs/user/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 4c34542ce59..8bf63b93467 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -349,6 +349,8 @@ if (empty($reshook)) { $object->salaryextra = GETPOST("salaryextra") != '' ? GETPOST("salaryextra") : ''; $object->weeklyhours = GETPOST("weeklyhours") != '' ? GETPOST("weeklyhours") : ''; + $object->color = GETPOST("color") != '' ? GETPOST("color") : ''; + if (! empty($conf->multicompany->enabled)) { if (! empty($_POST["superadmin"])) From a2bb57e33b4e1d544c1ec46e938402bb833110e4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2016 15:22:05 +0100 Subject: [PATCH 019/123] Fix: use clone instead dol_clone --- htdocs/user/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 8bf63b93467..58d87a68c8c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -481,7 +481,7 @@ if (empty($reshook)) { { $object->fetch($id); - $object->oldcopy = dol_clone($object); + $object->oldcopy = clone $object; $ret = $object->setPassword($user, $_POST["password"]); if ($ret < 0) From 2642b710ea56af94164a31d34bfb5e307fedf0a9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Mar 2016 15:56:03 +0100 Subject: [PATCH 020/123] Fix: missing model selected --- htdocs/commande/card.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ebe2b58745d..c16f3ca4466 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -644,7 +644,7 @@ if (empty($reshook)) $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) $tva_npr=0; - + $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; @@ -1397,7 +1397,7 @@ if ($action == 'create' && $user->rights->commande->creer) if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE)) { print '' . "\n"; } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 4d5ae4a3ba3..0314ce7b928 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2893,12 +2893,10 @@ table.valid { border-radius: 4px; } #tiptip_content { --moz-border-radius:0px; --webkit-border-radius: 0px; -border-radius: 0px; -background-color: rgb(255,255,255); -/* background-color: rgb(255,255,255); - background-color: rgba(255,255,255,0.95);*/ + -moz-border-radius:0px; + -webkit-border-radius: 0px; + border-radius: 0px; + background-color: rgb(255,255,255); line-height: 1.4em; min-width: 200px; } From 362bc106eb9439d015fca87ccd25f879c19f999b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 30 Mar 2016 11:38:39 +0200 Subject: [PATCH 057/123] FIX Multiprice generator didn't recalculate prices if only the price_base_type property changes --- htdocs/product/class/product.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ec7a67aff83..f8cb45a8b38 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013-2014 Cedric GROSS - * Copyright (C) 2013-2015 Marcos García + * Copyright (C) 2013-2016 Marcos García * Copyright (C) 2011-2014 Alexandre Spangaro * Copyright (C) 2014 Henry Florian * Copyright (C) 2014-2016 Philippe Grand @@ -4123,7 +4123,11 @@ class Product extends CommonObject $price_min = $price * (1 - ($rules[$i]->var_min_percent/100)); } - if ($price == $this->multiprices[$i] && ($price_min == $this->multiprices_min[$i])) { + //Little check to make sure the price is modified before triggering generation + $check_amount = $price == $this->multiprices[$i] && ($price_min == $this->multiprices_min[$i]); + $check_type = $baseprice == $this->multiprices_base_type[$i]; + + if ($check_amount && $check_type) { continue; } From 07e622a7f818f39e541df103fd37a471bee5c5ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Mar 2016 14:04:22 +0200 Subject: [PATCH 058/123] Introduce () to have code cleaner --- htdocs/product/class/product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f8cb45a8b38..28855e89855 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4124,8 +4124,8 @@ class Product extends CommonObject } //Little check to make sure the price is modified before triggering generation - $check_amount = $price == $this->multiprices[$i] && ($price_min == $this->multiprices_min[$i]); - $check_type = $baseprice == $this->multiprices_base_type[$i]; + $check_amount = (($price == $this->multiprices[$i]) && ($price_min == $this->multiprices_min[$i])); + $check_type = ($baseprice == $this->multiprices_base_type[$i]); if ($check_amount && $check_type) { continue; From fa10f9e030c454203d3d6d47b867f0c765b9960e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Mar 2016 14:07:07 +0200 Subject: [PATCH 059/123] FIX #4880 --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 3470fb6b434..85f340b1cb1 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -162,7 +162,7 @@ class User extends CommonObject */ function fetch($id='', $login='',$sid='',$loadpersonalconf=1, $entity=-1) { - global $langs, $conf, $user; + global $conf, $user; // Clean parameters $login=trim($login); @@ -256,7 +256,7 @@ class User extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; From 7146a8319bacaf3d8913b0aeeef55c833eb27e7f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Mar 2016 16:26:34 +0200 Subject: [PATCH 060/123] FIX Each time we edit a line, we loose the unit price. --- htdocs/core/tpl/objectline_edit.tpl.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 7c75e0ae49b..7723123bc0e 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -252,6 +252,10 @@ if (! empty($conf->margin->enabled)) jQuery("input[name='np_marginRate']:first").val(''); jQuery("input[name='np_markRate']:first").val(''); }); + jQuery("#qty").keyup(function() { + jQuery("input[name='np_marginRate']:first").val(''); + jQuery("input[name='np_markRate']:first").val(''); + }); jQuery("#remise_percent").keyup(function() { jQuery("input[name='np_marginRate']:first").val(''); jQuery("input[name='np_markRate']:first").val(''); @@ -300,7 +304,7 @@ if (! empty($conf->margin->enabled)) /* Add rules to reset price_ht from margin info */ global->DISPLAY_MARGIN_RATES)) + if (! empty($conf->global->DISPLAY_MARGIN_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD)) { ?> $('#savelinebutton').click(function (e) { @@ -312,7 +316,7 @@ if (! empty($conf->margin->enabled)) });*/ global->DISPLAY_MARK_RATES)) + if (! empty($conf->global->DISPLAY_MARK_RATES) && !empty($conf->global->MARGIN_RESET_HT_FROM_MARGIN_FIELD)) { ?> $('#savelinebutton').click(function (e) { From a47accb1c3f7bf91486fb8870201a0d6e0bc0f0c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Mar 2016 18:08:08 +0200 Subject: [PATCH 061/123] FIX PMP is deprecated at warehouse level --- htdocs/core/modules/modStock.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 67bebc0d6d7..81454a52222 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -189,13 +189,13 @@ class modStock extends DolibarrModules $this->import_icon[$r]=$this->picto; $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('ps'=>MAIN_DB_PREFIX.'product_stock'); - $this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*",'ps.pmp'=>"PMP" ); + $this->import_fields_array[$r]=array('ps.fk_product'=>"Product*",'ps.fk_entrepot'=>"Warehouse*",'ps.reel'=>"Stock*"); $this->import_convertvalue_array[$r]=array( 'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'), 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label') ); - $this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10",'ps.pmp'=>"25" + $this->import_examplevalues_array[$r]=array('ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" ); } From 5d4c959d2eadd3f1c18e44f4f14f355623b91efb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 31 Mar 2016 12:18:26 +0200 Subject: [PATCH 062/123] Add hook parameters on New search Box --- htdocs/core/ajax/selectsearchbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 6c91974b4a4..1bb2aa47003 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -113,7 +113,7 @@ if (! empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFO } -/* Do we really need this. We already have a select for users, and we should be able to filter into user list on employee flag +/* Do we really need this. We already have a select for users, and we should be able to filter into user list on employee flag if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLOYEE) && $user->rights->hrm->employee->read) { $langs->load("hrm"); @@ -122,7 +122,7 @@ if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLO */ // Execute hook addSearchEntry -$parameters=array(); +$parameters=array('search_boxvalue'=>$search_boxvalue); $reshook=$hookmanager->executeHooks('addSearchEntry',$parameters); if (empty($reshook)) { From f567a2a0ce3fb46c2e3b97ce451023c0938a233e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 31 Mar 2016 12:50:40 +0200 Subject: [PATCH 063/123] Search box hook --- htdocs/core/ajax/selectsearchbox.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 1bb2aa47003..a5f9edde28e 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -34,6 +34,8 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); $res=@include '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; +//global $hookmanager; +$hookmanager->initHooks(array('searchform')); $search_boxvalue=GETPOST('q'); @@ -120,7 +122,6 @@ if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLO $searchform.=printSearchForm(DOL_URL_ROOT.'/hrm/employee/list.php', DOL_URL_ROOT.'/hrm/employee/list.php', $langs->trans("Employees"), 'employee', 'search_all', 'M', 'searchleftemployee', img_object('','user')); } */ - // Execute hook addSearchEntry $parameters=array('search_boxvalue'=>$search_boxvalue); $reshook=$hookmanager->executeHooks('addSearchEntry',$parameters); @@ -131,13 +132,6 @@ if (empty($reshook)) else $arrayresult=$hookmanager->resArray; - - - - - - - print json_encode($arrayresult); if (is_object($db)) $db->close(); From 1419b0e385e1de0032fcc80c6f77a60556de2f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 31 Mar 2016 17:06:10 +0200 Subject: [PATCH 064/123] Update llx_establishment.sql --- htdocs/install/mysql/tables/llx_establishment.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_establishment.sql b/htdocs/install/mysql/tables/llx_establishment.sql index 8ddc71e1fba..fcf57ac28b6 100644 --- a/htdocs/install/mysql/tables/llx_establishment.sql +++ b/htdocs/install/mysql/tables/llx_establishment.sql @@ -19,7 +19,7 @@ -- Structure de la table llx_establishment -- -CREATE TABLE IF NOT EXISTS llx_establishment ( +CREATE TABLE llx_establishment ( rowid integer NOT NULL auto_increment PRIMARY KEY, entity integer NOT NULL DEFAULT 1, name varchar(50), From 125256c825f04c641658bad3436e19016f75fe6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 31 Mar 2016 17:11:17 +0200 Subject: [PATCH 065/123] Update llx_usergroup_extrafields.sql No need IF NOT EXISTS at install time --- htdocs/install/mysql/tables/llx_usergroup_extrafields.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_usergroup_extrafields.sql b/htdocs/install/mysql/tables/llx_usergroup_extrafields.sql index 0a89810dce5..eca555c4d78 100644 --- a/htdocs/install/mysql/tables/llx_usergroup_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_usergroup_extrafields.sql @@ -16,7 +16,7 @@ -- -- =================================================================== -CREATE TABLE IF NOT EXISTS llx_usergroup_extrafields ( +CREATE TABLE llx_usergroup_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, fk_object integer NOT NULL, From 90e74b346e7081eb998165f87afe662b12694bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 31 Mar 2016 17:13:38 +0200 Subject: [PATCH 066/123] Update llx_propal_merge_pdf_product.sql No need IF NOT EXISTS at install time --- htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql b/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql index 93af93c9190..7f29f4a4614 100644 --- a/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql +++ b/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql @@ -14,7 +14,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product ( +CREATE TABLE llx_propal_merge_pdf_product ( rowid integer NOT NULL auto_increment PRIMARY KEY, fk_product integer NOT NULL, file_name varchar(200) NOT NULL, From 2a19326a3f6c28b7e4261ae48d35b0bec8d1fc49 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Mar 2016 21:47:32 +0200 Subject: [PATCH 067/123] FIX Missing database escaping on supplier price insert/update --- htdocs/product/class/product.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 57fbcd01257..78ea0cb39c7 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2506,7 +2506,7 @@ class Product extends CommonObject $sql = "SELECT rowid, fk_product"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_soc = ".$id_fourn; - $sql.= " AND ref_fourn = '".$ref_fourn."'"; + $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; $sql.= " AND fk_product != ".$this->id; $sql.= " AND entity = ".$conf->entity; @@ -2528,7 +2528,7 @@ class Product extends CommonObject $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; $sql.= " WHERE fk_soc = ".$id_fourn; - if ($ref_fourn) $sql.= " AND ref_fourn = '".$ref_fourn."'"; + if ($ref_fourn) $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; else $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; $sql.= " AND quantity = '".$quantity."'"; $sql.= " AND fk_product = ".$this->id; @@ -2557,7 +2557,7 @@ class Product extends CommonObject $sql.= ", ".$conf->entity; $sql.= ", ".$this->id; $sql.= ", ".$id_fourn; - $sql.= ", '".$ref_fourn."'"; + $sql.= ", '".$this->db->escape($ref_fourn)."'"; $sql.= ", ".$quantity; $sql.= ", ".$user->id; $sql.= ", 0"; From feb35adbe1d5235d5bb8fa824d8e2fcfadd7a090 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Mar 2016 15:22:43 +0200 Subject: [PATCH 068/123] FIX Missing clean of criteria --- htdocs/societe/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 3aa18ed5018..48202706ff7 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -200,6 +200,7 @@ if (empty($reshook)) // Do we click on purge search criteria ? if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers { + $search_nom=''; $search_categ=''; $search_sale=''; $search_barcode=""; From be483bd7879d2331d86a9ed6f953f5394451c716 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Apr 2016 12:26:42 +0200 Subject: [PATCH 069/123] FIX Some records were lost into margin per product report --- htdocs/langs/en_US/products.lang | 1 + htdocs/margin/productMargins.php | 34 +++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 52eadb2e11c..9298bdc9669 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -175,6 +175,7 @@ PredefinedProductsAndServicesToSell=Predefined products/services to sell PredefinedProductsToPurchase=Predefined product to purchase PredefinedServicesToPurchase=Predefined services to purchase PredefinedProductsAndServicesToPurchase=Predefined products/services to puchase +NotPredefinedProducts=Not predefined products/services GenerateThumb=Generate thumb ProductCanvasAbility=Use special "canvas" addons ServiceNb=Service #%s diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index e8483c90a34..c74c38caef2 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -165,16 +165,15 @@ print ''; $sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref, p.entity as pentity,"; if ($id > 0) $sql.= " d.fk_product,"; if ($id > 0) $sql.= " f.rowid as facid, f.facnumber, f.total as total_ht, f.datef, f.paye, f.fk_statut as statut,"; -$sql.= " sum(d.total_ht) as selling_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; -$sql.= " sum(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; +$sql.= " SUM(d.total_ht) as selling_price,"; +$sql.= " SUM(".$db->ifsql('d.total_ht < 0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,"; +$sql.= " SUM(".$db->ifsql('d.total_ht < 0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."product as p"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = d.fk_product"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_soc = s.rowid"; -$sql.= " AND d.fk_product = p.rowid"; $sql.= " AND f.fk_statut > 0"; $sql.= " AND d.fk_facture = f.rowid"; if ($id > 0) @@ -186,8 +185,8 @@ if (!empty($enddate)) $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; -if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; -else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref"; +if ($id > 0) $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity, d.fk_product, f.rowid, f.facnumber, f.total, f.datef, f.paye, f.fk_statut"; +else $sql.= " GROUP BY p.label, p.rowid, p.fk_product_type, p.ref, p.entity"; $sql.=$db->order($sortfield,$sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); @@ -260,13 +259,20 @@ if ($result) } else { print '
'; - $product_static->type=$objp->fk_product_type; - $product_static->id=$objp->rowid; - $product_static->ref=$objp->ref; - $product_static->label=$objp->label; - $product_static->entity=$objp->pentity; - $text=$product_static->getNomUrl(1); - print $text.= ' - '.$objp->label; + if ($objp->rowid > 0) + { + $product_static->type=$objp->fk_product_type; + $product_static->id=$objp->rowid; + $product_static->ref=$objp->ref; + $product_static->label=$objp->label; + $product_static->entity=$objp->pentity; + $text=$product_static->getNomUrl(1); + print $text.= ' - '.$objp->label; + } + else + { + print $langs->trans("NotPredefinedProducts"); + } print "".$product_static->getNomUrl(1)."'; - $minifile=$fileinfo['filename'].'_mini.'.strtolower($fileinfo['extension']); // Thumbs are created with filename in lower case if (image_format_supported($file['name']) > 0) { - print ''; - print ''; + $minifile=getImageFileNameForSize($file['name'], '_mini', '.png'); // Thumbs are created with filename in lower case and with .png extension + //print $relativepath.'
'; + //print $file['path'].'/'.$minifile.'
'; + if (! dol_is_file($file['path'].'/'.$minifile)) $minifile=getImageFileNameForSize($file['name'], '_mini', '.'.$fileinfo['extension']); // For old thumbs + //print $file['path'].'/'.$minifile.'
'; + print '
'; + print ''; print ''; } else print ' '; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index a1bdf274995..4b1d3f3e491 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1451,6 +1451,12 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $destfile=preg_replace('/__file__/',$_FILES[$varfiles]['name'],$savingdocmask); } + // lowercase extension + $info = pathinfo($destpath); + $destpath = $info['dirname'].'/'.$info['filename'].'.'.strtolower($info['extension']); + $info = pathinfo($destfile); + $destfile = $info['filename'].'.'.strtolower($info['extension']); + $resupload = dol_move_uploaded_file($_FILES[$varfiles]['tmp_name'], $destpath, $allowoverwrite, 0, $_FILES[$varfiles]['error'], 0, $varfiles); if (is_numeric($resupload) && $resupload > 0) { diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 2fe9065b21c..669da7b751b 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -473,6 +473,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName='_small', $ } // Initialisation des variables selon l'extension de l'image + // $targetformat is 0 by default, in such case, we keep original extension switch($targetformat) { case IMAGETYPE_GIF: // 1 From 3aeb579486700e9a9f52e1bb95624744384549b5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2016 12:46:34 +0200 Subject: [PATCH 075/123] Fix bad link --- htdocs/core/search_page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/search_page.php b/htdocs/core/search_page.php index 8bb7e654b2f..ae1b29a5c48 100644 --- a/htdocs/core/search_page.php +++ b/htdocs/core/search_page.php @@ -111,7 +111,7 @@ else if (! empty($conf->user->enabled) && $user->rights->user->user->lire) { $langs->load("users"); - $searchform.=printSearchForm(DOL_URL_ROOT.'/user/list.php', DOL_URL_ROOT.'/user/list.php', $langs->trans("Users"), 'user', 'sall', 'M', 'searchleftuser', img_object('','user')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/user/index.php', DOL_URL_ROOT.'/user/index.php', $langs->trans("Users"), 'user', 'sall', 'M', 'searchleftuser', img_object('','user')); } } From cea48a8dd6a1f269501234428755c1fcb71ca5fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Apr 2016 19:04:03 +0200 Subject: [PATCH 076/123] FIX bad translation language loaded FIX When changing thirdparty on event card, the showempty option of contact was lost. FIX Bad placeholder shown on combo to select a thirdparty. --- htdocs/comm/action/card.php | 29 ++++++++++++-------- htdocs/core/ajax/contacts.php | 3 +- htdocs/core/class/html.formactions.class.php | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 19633aa13d7..62512562e9a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1090,17 +1090,22 @@ if ($id > 0) // Thirdparty - Contact if ($conf->societe->enabled) { - print '
'.$langs->trans("ActionOnCompany").'
'.$langs->trans("ActionOnCompany").''; + print '
'; $events=array(); - $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); - print $form->select_company($object->socid,'socid','',1,1,0,$events); - print '
'.$langs->trans("Contact").''; + print '
'.$langs->trans("Contact").''; + print '
'; $form->select_contacts($object->socid, $object->contactid, 'contactid', 1, '', '', 0, 'minwidth200'); - print '
'.$langs->trans("Project").''; - $numprojet=$formproject->select_projects($object->socid,$object->fk_project,'projectid'); + print '
'.$langs->trans("Project").''; + $numprojet=$formproject->select_projects($object->socid, $object->fk_project, 'projectid'); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; @@ -1120,7 +1125,7 @@ if ($id > 0) } // Priority - print '
'.$langs->trans("Priority").''; + print '
'.$langs->trans("Priority").''; print ''; print '
'.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note',$object->note,'',240,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,90); + $doleditor=new DolEditor('note',$object->note,'',200,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,90); $doleditor->Create(); print '
'.$langs->trans("ActionOnCompany").''.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None")); + print '
'.$langs->trans("ActionOnCompany").''.($object->thirdparty->id?$object->thirdparty->getNomUrl(1):$langs->trans("None")); if (is_object($object->thirdparty) && $object->thirdparty->id > 0 && $object->type_code == 'AC_TEL') { if ($object->thirdparty->fetch($object->thirdparty->id)) diff --git a/htdocs/core/ajax/contacts.php b/htdocs/core/ajax/contacts.php index c0cd9ecfd70..c3788a8baeb 100644 --- a/htdocs/core/ajax/contacts.php +++ b/htdocs/core/ajax/contacts.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2012 Regis Houssin + * 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 diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 0316fb461cf..9e61804af7a 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -136,7 +136,7 @@ class FormActions if (empty($onlyselect)) { print ' =0)?'':' disabled').'>'; - print '%'; + print '%'; } } else From fded7d3e9a37dff9f15b740be76aeffc75e56dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garc=C3=ADa?= Date: Sun, 3 Apr 2016 22:17:25 +0200 Subject: [PATCH 077/123] Corrected PHP documentation of calcul_price_total function --- htdocs/core/lib/price.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 21ad2c99d82..e8d4b103a30 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -49,7 +49,7 @@ * @param Societe $seller Thirdparty seller (we need $seller->country_id property). Provided only if seller is the supplier, otherwise $seller will be $mysoc. * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) - * @return result[ 0=total_ht, + * @return array [ 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) * 3=pu_ht, From 43165bab022798c2e06bda2e678db0cb7a72cfc7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Apr 2016 16:02:29 +0200 Subject: [PATCH 078/123] FIX Filter/search on extrafields on lists Conflicts: dev/skeletons/skeleton_list.php htdocs/projet/list.php htdocs/societe/list.php --- dev/skeletons/skeleton_list.php | 25 ++++++++++++--- htdocs/contact/list.php | 2 +- htdocs/core/class/html.form.class.php | 2 +- htdocs/product/list.php | 2 +- htdocs/projet/list.php | 39 ++++++++++++++++++++---- htdocs/projet/tasks/list.php | 43 +++++++++++++++++++++----- htdocs/societe/list.php | 44 ++++++++++++++++----------- htdocs/user/index.php | 19 ++++++++++-- 8 files changed, 136 insertions(+), 40 deletions(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 834e0b07e2f..cd2ed5405db 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -216,7 +216,7 @@ foreach ($search_array_options as $key => $val) $tmpkey=preg_replace('/search_options_/','',$key); $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; - if (in_array($typ, array('int'))) $mode=1; // Search on a numeric + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); @@ -322,10 +322,25 @@ if ($resql) // 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'])) print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $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'; + print ''; + } + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $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'; + print ''; + } + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $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'; + print ''; + } + print ''; if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; - 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 ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; - print ''; + print ''; print ''; + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $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'; + print ''; + } print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $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'; + print ''; + } + print '
'; print ''; From 3135cf720d8ccfc8ff09b821e664fd4be3a66edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 22:56:45 +0200 Subject: [PATCH 094/123] FIX #4737 Bank transacion type selector translation is cropped Close #4737 --- htdocs/compta/bank/search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 80befe3d433..d4f4b82a96b 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -210,7 +210,7 @@ if ($resql) print ''; print ''; print ''; print ''; print ''; print "\n"; From af473df2143a275a4d1704a2ac2dfaaefa5dfa48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:27:42 +0200 Subject: [PATCH 097/123] FIX #4742 Able to delete a supplier invoice with a registered payment Close #4742 --- htdocs/fourn/facture/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index c2b2c587736..7887e8cc6ed 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2270,7 +2270,11 @@ else // Delete if ($action != 'edit' && $user->rights->fournisseur->facture->supprimer) { - print ''.$langs->trans('Delete').''; + if ($object->getSommePaiement()) { + print ''; + } else { + print ''.$langs->trans('Delete').''; + } } print ''; print '
'; From 15d927375132469cd89c7fcf834be5ccc9886495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 10 Apr 2016 00:30:31 +0200 Subject: [PATCH 098/123] FIX #4747 Missing UI background when registering a supplier invoice payment Close #4747 --- htdocs/fourn/facture/paiement.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 758885cef58..dcaabd160f8 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -281,9 +281,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + dol_fiche_head(); + print '
  '; - $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1, 8); + $form->select_types_paiements(empty($type)?'':$type, 'type', '', 2, 0, 1); print ''; From b9de3d5852d59d0ca9ca0f73852ffdb431e29fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:03:00 +0200 Subject: [PATCH 095/123] FIX #4442 Missing translation in Banks menu Close #4442 --- htdocs/core/menus/standard/eldy.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 8d6882c26c2..b6a98b1c2d3 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -970,6 +970,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $langs->load("withdrawals"); $langs->load("banks"); $langs->load("bills"); + $langs->load('categories'); // Bank-Caisse if (! empty($conf->banque->enabled)) From 865f9defff1b2ca8b23684c59e44f03b94bd0d26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 9 Apr 2016 23:08:47 +0200 Subject: [PATCH 096/123] FIX #4424 Missing email of user popup in supplier orders area Close #4424 --- htdocs/fourn/commande/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index c877589851d..510ca2755be 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -245,7 +245,7 @@ if (! empty($conf->fournisseur->enabled)) /* * List of users allowed */ -$sql = "SELECT u.rowid, u.lastname, u.firstname"; +$sql = "SELECT u.rowid, u.lastname, u.firstname, u.email"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u,"; $sql.= " ".MAIN_DB_PREFIX."user_rights as ur"; $sql.= ", ".MAIN_DB_PREFIX."rights_def as rd"; @@ -278,6 +278,7 @@ if ($resql) $userstatic->id=$obj->rowid; $userstatic->lastname=$obj->lastname; $userstatic->firstname=$obj->firstname; + $userstatic->email=$obj->email; print $userstatic->getNomUrl(1); print '
'; - print ''; print '
'.$langs->trans('Payment').'
'.$langs->trans('Company').''; $supplierstatic->id=$obj->socid; $supplierstatic->name=$obj->name; @@ -311,6 +312,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print '
'; + dol_fiche_end(); $parameters=array('facid'=>$facid, 'ref'=>$ref, 'objcanvas'=>$objcanvas); $reshook=$hookmanager->executeHooks('paymentsupplierinvoices',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -337,7 +339,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { $i = 0; print '
'; - print $langs->trans('Invoices').'
'; if(!empty($conf->global->FAC_AUTO_FILLJS)){ //Add js for AutoFill From 7acbf1dd92112dfbdfdc6228ac4e8f0660531a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 10 Apr 2016 01:00:27 +0200 Subject: [PATCH 099/123] FIX #4874 SQL error when listing users Close #4874 --- htdocs/user/index.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 8710dc87e04..3d787762a8c 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Marcos García * * 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 @@ -201,7 +202,9 @@ if ($search_login != '') $sql.= natural_search("u.login", $search_login); if ($search_lastname != '') $sql.= natural_search("u.lastname", $search_lastname); if ($search_firstname != '') $sql.= natural_search("u.firstname", $search_firstname); if ($search_gender != '' && $search_gender != '-1') $sql.= " AND u.gender = '".$search_gender."'"; -if ($search_employee >= 0) $sql.= natural_search("u.employee", $search_employee); +if (is_numeric($search_employee) && $search_employee >= 0) { + $sql .= ' AND u.employee = '.(int) $search_employee; +} if ($search_accountancy_code != '') $sql.= natural_search("u.accountancy_code", $search_accountancy_code); if ($search_email != '') $sql.= natural_search("u.email", $search_email); if ($search_statut != '' && $search_statut >= 0) $sql.= " AND (u.statut=".$search_statut.")"; From b7275edfb8db5a92e19a901ac61b22a0bd107370 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:24:31 +0200 Subject: [PATCH 100/123] FIX #4989 --- htdocs/admin/dict.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index bc56f13cc66..a5a3139353a 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -232,7 +232,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -$tabfield[25]= "label,type_template,position,topic,content"; +$tabfield[25]= "label,type_template,private,position,topic,content"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newByMonth,country_id,country"; @@ -264,7 +264,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -$tabfieldvalue[25]= "label,type_template,position,topic,content"; +$tabfieldvalue[25]= "label,type_template,private,position,topic,content"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newByMonth,country"; @@ -585,7 +585,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $ok=0; setEventMessages($langs->transnoentities("ErrorFieldMustBeANumeric",$langs->transnoentities("Code")), null, 'errors'); } - + // Clean some parameters if (isset($_POST["localtax1"]) && empty($_POST["localtax1"])) $_POST["localtax1"]='0'; // If empty, we force to 0 if (isset($_POST["localtax2"]) && empty($_POST["localtax2"])) $_POST["localtax2"]='0'; // If empty, we force to 0 @@ -685,7 +685,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - + print $sql; dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); @@ -1330,7 +1330,7 @@ if ($id) if (in_array($obj->code, array('AC_OTH','AC_OTH_AUTO')) || in_array($obj->type, array('systemauto'))) { $canbedisabled=0; $canbedisabled = 0; } $canbemodified=$iserasable; if ($obj->code == 'RECEP') $canbemodified=1; - + $url = $_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(! empty($obj->rowid)?$obj->rowid:(! empty($obj->code)?$obj->code:'')).'&code='.(! empty($obj->code)?urlencode($obj->code):'').'&id='.$id.'&'; // Favorite From 23bb2eaf8a4e1be3fdf22db1d4b05324bf6287a3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:27:17 +0200 Subject: [PATCH 101/123] remove debug --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index a5a3139353a..5e9fc895f0b 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -685,7 +685,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) $i++; } $sql.= " WHERE ".$rowidcol." = '".$rowid."'"; - print $sql; + dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); From 8035742779d1b7f9c4afe90fb6b6fd44a3a9aa2e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 11 Apr 2016 14:52:22 +0200 Subject: [PATCH 102/123] FIX fetchAllEMailTemplate --- htdocs/core/class/html.formmail.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index bc185ef6d71..f8f6afcf1ff 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -334,7 +334,7 @@ class FormMail extends Form $out.= '   '; $out.= ''; } - + $out.= ''."\n"; @@ -894,7 +894,7 @@ class FormMail extends Form $line->id=$obj->rowid; $line->label=$obj->label; $line->topic=$obj->topic; - $line->content=$obj->lacontentbel; + $line->content=$obj->content; $line->lang=$obj->lang; $this->lines_model[]=$line; } From 791df0c9ea4e657c2d80c51d91b9c41886463551 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:27:34 +0200 Subject: [PATCH 103/123] FIX: correct display of minimum buying price --- htdocs/fourn/class/fournisseur.product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 344fa3ffa56..50613103848 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -540,7 +540,7 @@ class ProductFournisseur extends Product { global $langs; $langs->load("suppliers"); - $out=($showunitprice?price($this->fourn_unitprice).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_unitcharges - $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); return $out; } From 983b2c9a210c11a56f7af7376686afaef70ba8b6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:40:47 +0200 Subject: [PATCH 104/123] FIX: real min buying price --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 89760dc66ba..10d50acebe0 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -354,7 +354,7 @@ if ($id > 0 || ! empty($ref)) else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } } print ''; - $totalline=price2num($value['nb'] * $product_fourn->fourn_unitprice, 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges), 'MT'); $total+=$totalline; print ''; if (! empty($conf->stock->enabled)) print ''; // Real stock From 292373cf8401f190ccc7269838d0e0efdff5d0c6 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Mon, 11 Apr 2016 17:43:10 +0200 Subject: [PATCH 105/123] forgot new discount field --- htdocs/product/composition/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 10d50acebe0..6cb6424bdc4 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -354,7 +354,7 @@ if ($id > 0 || ! empty($ref)) else { print $langs->trans("NotDefined"); $notdefined++; $atleastonenotdefined++; } } print ''; - $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges), 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; if (! empty($conf->stock->enabled)) print ''; // Real stock From 25dcca301f38c986feef2beebc4b3800913da1a8 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 12 Apr 2016 09:47:35 +0200 Subject: [PATCH 106/123] Fix VAT amount on credit note was > 0 when manually entered --- 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 ae368b3870b..333f71806c6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2392,7 +2392,7 @@ class Facture extends CommonInvoice $this->line->date_start = $date_start; $this->line->date_end = $date_end; $this->line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = $total_tva; + $this->line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); $this->line->total_localtax1 = $total_localtax1; $this->line->total_localtax2 = $total_localtax2; $this->line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); From 872c99afe951b1ed23611681c0f68e73625dc5b3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 12 Apr 2016 11:35:39 +0200 Subject: [PATCH 107/123] FIX Hook resprint be printed --- htdocs/core/tpl/objectline_create.tpl.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 31ad9716155..71d34ac4cd4 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -32,7 +32,7 @@ $usemargins=0; -if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) +if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element,array('facture','propal','commande'))) { $usemargins=1; } @@ -193,11 +193,17 @@ else { { $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line','int')); $reshook=$hookmanager->executeHooks('formCreateProductOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } if (is_object($hookmanager) && ! empty($senderissupplier)) { $parameters=array('htmlname'=>'addproduct'); $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions',$parameters,$object,$action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } } @@ -476,7 +482,7 @@ jQuery(document).ready(function() { $("#select_type").change(function() { setforfree(); - if (jQuery('#select_type').val() >= 0) + if (jQuery('#select_type').val() >= 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); @@ -582,7 +588,7 @@ jQuery(document).ready(function() { /* To set focus */ - if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) { /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ jQuery('#dp_desc').focus(); From 2d3b2c08b57e3c156599ec90f1f7413a2cfcf1f2 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 10:56:03 +0200 Subject: [PATCH 108/123] FIX #3815 Call to undefined function local_by_date(). branch 3.7 --- htdocs/compta/localtax/quadri_detail.php | 36 +-- htdocs/core/lib/tax.lib.php | 366 ++++++++++++++++++++++- 2 files changed, 370 insertions(+), 32 deletions(-) diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 7396c625165..73cfdff0659 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -3,7 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier - * Copyright (C) 2014 Rosana Romero + * Copyright (C) 2014-2016 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 @@ -116,16 +116,11 @@ $product_static=new Product($db); $payment_static=new Paiement($db); $paymentfourn_static=new PaiementFourn($db); -//print_fiche_titre($langs->trans("VAT"),""); - -//$fsearch.='
'; $fsearch.=' '; $fsearch.=' '; -//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; -//$fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; -// Affiche en-tete du rapport + if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services { $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode"); @@ -138,14 +133,11 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice $nextyear=$year_start; $nextquarter=$q; if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } - //$periodlink=($prevyear?"".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"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); else $description.='
'.$langs->trans("DepositsAreIncluded"); $description.=$fsearch; $builddate=time(); - //$exportlink=$langs->trans("NotYetAvailable"); $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("ProductOrService"); @@ -170,14 +162,10 @@ if ($conf->global->$calc==2) // Invoice for goods, payment for services $nextyear=$year_start; $nextquarter=$q; if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } - //$periodlink=($prevyear?"".img_previous()." ".img_next()."":""); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); else $description.=' '.$langs->trans("DepositsAreIncluded"); - //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; $builddate=time(); - //$exportlink=$langs->trans("NotYetAvailable"); $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("ProductOrService"); @@ -203,15 +191,12 @@ if($local==1){ // VAT Received and paid - - $y = $year_current; $total = 0; $i=0; // Load arrays of datas $x_coll= local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell', $local); -//$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); $x_paye = local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy', $local); @@ -230,10 +215,10 @@ if (! is_array($x_coll) || ! is_array($x_paye)) 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_rate) { - //foreach($x_coll[$my_coll_rate][localtax1_list]){ $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; @@ -303,9 +288,6 @@ else } //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; @@ -313,9 +295,7 @@ else $span=3; if ($modetax == 0) $span+=2; - - //print '
'; - + if($conf->global->$calc ==0 || $conf->global->$calc == 2){ // Customers invoices print ''; @@ -345,8 +325,6 @@ else if($rate!=0){ print ""; - //print ''; - /**/ print ''; print ''."\n"; } @@ -400,9 +378,7 @@ else 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 ''; } @@ -413,7 +389,6 @@ else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); print '
'.($notdefined?'':price($totalline,'','',0,0,-1,$conf->currency)).''.$langs->trans("Stock").': '.$value['stock'].''.($notdefined?'':price($totalline,'','',0,0,-1,$conf->currency)).''.$langs->trans("Stock").': '.$value['stock'].'
'..')
'.$langs->trans("Rate").': '.vatrate($rate).'%'.$langs->trans("Rate").': '.vatrate($rate).'%
'; - //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id=$fields['payment_id']; @@ -491,7 +466,6 @@ else if($conf->global->$calc ==0 || $conf->global->$calc == 1){ echo ''; //print table headers for this quadri - expenses now - //imprime les en-tete de tables pour ce quadri - maintenant les d�penses print ''; print ''; print ''; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index de705111b9d..ae217004bbf 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2011 Regis Houssin - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -205,6 +205,370 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction } } +/** + * Gets LocalTaxes to collect for the given year (and given quarter or month) + * The function gets the LocalTaxes in split results, as the LocalTaxes declaration asks + * to report the amounts for different LocalTaxes rates as different lines. + * + * @param DoliDB $db Database handler object + * @param int $y Year + * @param int $q Quarter + * @param string $date_start Start date + * @param string $date_end End date + * @param int $modetax 0 or 1 (option on debit) + * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) + * @param int $local 1 for LocalTax1, 2 for LocalTax2 + * @param int $m Month + * @return array List of quarters with LocalTaxes + */ +function local_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $local, $m=0) +{ + global $conf; + + $list=array(); + + if ($direction == 'sell') + { + $invoicetable='facture'; + $invoicedettable='facturedet'; + $fk_facture='fk_facture'; + $fk_facture2='fk_facture'; + $fk_payment='fk_paiement'; + $total_tva='total_tva'; + $total_localtax1='total_localtax1'; + $total_localtax2='total_localtax2'; + $paymenttable='paiement'; + $paymentfacturetable='paiement_facture'; + $invoicefieldref='facnumber'; + $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; + } + if ($direction == 'buy') + { + $invoicetable='facture_fourn'; + $invoicedettable='facture_fourn_det'; + $fk_facture='fk_facture_fourn'; + $fk_facture2='fk_facturefourn'; + $fk_payment='fk_paiementfourn'; + $total_tva='tva'; + $total_localtax1='total_localtax1'; + $total_localtax2='total_localtax2'; + $paymenttable='paiementfourn'; + $paymentfacturetable='paiementfourn_facturefourn'; + $invoicefieldref='ref'; + $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; + } + + // BIENS + + // Define sql request + $sql=''; + if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services + { + if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) + { + $sql='TODO'; + } + if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) + { + // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx,"; + $sql.= " 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,"; + $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.$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)"; + else $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.rowid = d.".$fk_facture; + 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 service + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + } + } + else // Option vat on delivery for goods (payments) and payments for services + { + if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) + { + $sql='TODO'; + } + if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) + { + // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; + $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.$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)"; + else $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.rowid = d.".$fk_facture; + 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 service + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + } + } + + if (! $sql) return -1; + if ($sql == 'TODO') return -2; + if ($sql != 'TODO') + { + dol_syslog("Tax.lib.php::vat_by_date sql=".$sql); + + $resql = $db->query($sql); + if ($resql) + { + $lt=-1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; + if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) + { + $oldrowid=$assoc['rowid']; + $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; + } + + $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; + $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; + + $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; + $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; + $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; + $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; + $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; + + $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; + $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; + $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; + + $lt = $assoc['localtax_tx']; + } + } + else + { + dol_print_error($db); + return -3; + } + } + + + //SERVICES + + // Define sql request + $sql=''; + if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services + { + if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) + { + $sql='TODO'; + } + if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) + { + // Count on invoice date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; + $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.$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)"; + else $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.rowid = d.".$fk_facture; + 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.= " ORDER BY d.rowid, d.".$fk_facture; + } + } + else // Option on delivery for goods (payments) and payments for services + { + if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) + { + + $sql='TODO'; + } + if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) + { + // Count on payments date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; + $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.= " 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.$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)"; + else $sql.= " AND f.type IN (0,1,2,3)"; + $sql.= " AND f.rowid = d.".$fk_facture;; + $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.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + } + } + + if (! $sql) + { + dol_syslog("Tax.lib.php::vat_by_date 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::vat_by_date sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + $lt = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; + if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) + { + $oldrowid=$assoc['rowid']; + $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; + } + + $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; + $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; + + $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; + $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; + $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; + $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; + $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; + + $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; + $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; + $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; + + $lt = $assoc['localtax_tx']; + } + } + else + { + dol_print_error($db); + return -3; + } + } + + return $list; + + +} + /** * Gets VAT to collect for the given year (and given quarter or month) From 4446e6a36cf5df2de1e660944cae2bc8d710ea2b Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 12:47:21 +0200 Subject: [PATCH 109/123] FIX #3815 Call to undefined function local_by_date(). branch 3.8 --- htdocs/compta/localtax/quadri_detail.php | 42 +-- htdocs/core/lib/tax.lib.php | 335 +++++++++++++++++++++++ 2 files changed, 343 insertions(+), 34 deletions(-) diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 7396c625165..a4eaccba35b 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -3,7 +3,7 @@ * Copyright (C) 2004 Eric Seigne * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier - * Copyright (C) 2014 Rosana Romero + * Copyright (C) 2014-2016 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 @@ -116,16 +116,11 @@ $product_static=new Product($db); $payment_static=new Paiement($db); $paymentfourn_static=new PaiementFourn($db); -//print_fiche_titre($langs->trans("VAT"),""); - -//$fsearch.='
'; $fsearch.=' '; $fsearch.=' '; -//$fsearch.=' '.$langs->trans("SalesTurnoverMinimum").': '; -//$fsearch.=' '; $calc=$conf->global->MAIN_INFO_LOCALTAX_CALC.$local; -// Affiche en-tete du rapport + if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice for goods and services { $nom=$langs->trans($local==1?"LT1ReportByQuartersInDueDebtMode":"LT2ReportByQuartersInDueDebtMode"); @@ -138,14 +133,11 @@ if ($conf->global->$calc==0 || $conf->global->$calc==1) // Calculate on invoice $nextyear=$year_start; $nextquarter=$q; if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } - //$periodlink=($prevyear?"".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"); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); + + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.='
'.$langs->trans("DepositsAreNotIncluded"); else $description.='
'.$langs->trans("DepositsAreIncluded"); $description.=$fsearch; $builddate=time(); - //$exportlink=$langs->trans("NotYetAvailable"); $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("ProductOrService"); @@ -170,14 +162,10 @@ if ($conf->global->$calc==2) // Invoice for goods, payment for services $nextyear=$year_start; $nextquarter=$q; if ($nextquarter < 4) $nextquarter++; else { $nextquarter=1; $nextyear++; } - //$periodlink=($prevyear?"".img_previous()." ".img_next()."":""); - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); + if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.=' '.$langs->trans("DepositsAreNotIncluded"); else $description.=' '.$langs->trans("DepositsAreIncluded"); - //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; $builddate=time(); - //$exportlink=$langs->trans("NotYetAvailable"); $elementcust=$langs->trans("CustomersInvoices"); $productcust=$langs->trans("ProductOrService"); @@ -203,15 +191,12 @@ if($local==1){ // VAT Received and paid - - $y = $year_current; $total = 0; $i=0; // Load arrays of datas $x_coll= local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell', $local); -//$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); $x_paye = local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy', $local); @@ -230,10 +215,10 @@ if (! is_array($x_coll) || ! is_array($x_paye)) 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_rate) { - //foreach($x_coll[$my_coll_rate][localtax1_list]){ $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; @@ -303,9 +288,6 @@ else } //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; @@ -314,8 +296,6 @@ else $span=3; if ($modetax == 0) $span+=2; - //print '
'; - if($conf->global->$calc ==0 || $conf->global->$calc == 2){ // Customers invoices print ''; @@ -345,8 +325,6 @@ else if($rate!=0){ print ""; - //print ''; - /**/ print ''; print ''."\n"; } @@ -400,9 +378,7 @@ else 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 ''; } @@ -413,7 +389,6 @@ else { if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']); print ''; @@ -491,7 +466,6 @@ else if($conf->global->$calc ==0 || $conf->global->$calc == 1){ echo '
'.$elementsup.''.$productsup.'
'..')
'.$langs->trans("Rate").': '.vatrate($rate).'%'.$langs->trans("Rate").': '.vatrate($rate).'%
'; - //print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc']; if ($fields['payment_amount'] && $fields['ftotal_ttc']) { $payment_static->id=$fields['payment_id']; @@ -424,7 +399,7 @@ else print $langs->trans("NotUsedForGoods"); } else { - print $fields['payment_amount']; + print price($fields['payment_amount']); if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; } print '
'; //print table headers for this quadri - expenses now - //imprime les en-tete de tables pour ce quadri - maintenant les d�penses print ''; print ''; print ''; @@ -585,7 +559,7 @@ else } else { - print $fields['payment_amount']; + print price($fields['payment_amount']); if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; } print ''; diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 0a3c4942857..6054a32c692 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -178,6 +178,341 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction } } +/** + * Gets LocalTaxes to collect for the given year (and given quarter or month) + * The function gets the LocalTaxes in split results, as the LocalTaxes declaration asks + * to report the amounts for different LocalTaxes rates as different lines. + * + * @param DoliDB $db Database handler object + * @param int $y Year + * @param int $q Quarter + * @param string $date_start Start date + * @param string $date_end End date + * @param int $modetax 0 or 1 (option on debit) + * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) + * @param int $local 1 for LocalTax1, 2 for LocalTax2 + * @param int $m Month + * @return array List of quarters with LocalTaxes + */ +function local_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $local, $m=0) +{ + global $conf; + + $list=array(); + + if ($direction == 'sell') + { + $invoicetable='facture'; + $invoicedettable='facturedet'; + $fk_facture='fk_facture'; + $fk_facture2='fk_facture'; + $fk_payment='fk_paiement'; + $total_tva='total_tva'; + $total_localtax1='total_localtax1'; + $total_localtax2='total_localtax2'; + $paymenttable='paiement'; + $paymentfacturetable='paiement_facture'; + $invoicefieldref='facnumber'; + $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; + } + if ($direction == 'buy') + { + $invoicetable='facture_fourn'; + $invoicedettable='facture_fourn_det'; + $fk_facture='fk_facture_fourn'; + $fk_facture2='fk_facturefourn'; + $fk_payment='fk_paiementfourn'; + $total_tva='tva'; + $total_localtax1='total_localtax1'; + $total_localtax2='total_localtax2'; + $paymenttable='paiementfourn'; + $paymentfacturetable='paiementfourn_facturefourn'; + $invoicefieldref='ref'; + $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; + } + + // BIENS + + // Define sql request + $sql=''; + if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services + { + + // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx,"; + $sql.= " 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,"; + $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.$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; + 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 service + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + + } + else // Option on delivery for goods (payments) and payments for services + { + // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; + $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.$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; + 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 service + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + + } + + if (! $sql) return -1; + + dol_syslog("Tax.lib.php::vat_by_date sql=".$sql); + + $resql = $db->query($sql); + if ($resql) + { + $lt=-1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; + if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid + { + $oldrowid=$assoc['rowid']; + $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; + } + + $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; + $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; + + $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; + $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; + $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; + $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; + $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; + + $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; + $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; + $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; + + $lt = $assoc['localtax_tx']; + } + } + else + { + dol_print_error($db); + return -3; + } + + // CAS DES SERVICES + + // Define sql request + $sql=''; + if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services + { + + // Count on invoice date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; + $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.$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; + 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.= " ORDER BY d.rowid, d.".$fk_facture; + + } + else // Option vat on delivery for goods (payments) and payments for services + { + + // Count on payments date + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; + $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.= " 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.$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 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.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + + } + + if (! $sql) + { + dol_syslog("Tax.lib.php::local_by_date no accountancy module enabled".$sql,LOG_ERR); + return -1; + } + + dol_syslog("Tax.lib.php::local_by_date sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + $lt = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; + if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; + if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; + + if ($assoc['rowid'] != $oldrowid) + { + $oldrowid=$assoc['rowid']; + $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; + } + + $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; + $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; + + $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; + $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); + $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); + + $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; + $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; + $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; + $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; + + $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; + $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; + $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; + + $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; + $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; + $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; + + $lt = $assoc['localtax_tx']; + } + } + else + { + dol_print_error($db); + return -3; + } + + return $list; + + +} + /** * Gets VAT to collect for the given year (and given quarter or month) From c5ecc46a220b227b5fe46efba9fc76fda55773e1 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 15:42:58 +0200 Subject: [PATCH 110/123] FIX #3815 With higher quality --- htdocs/compta/localtax/quadri_detail.php | 11 +- htdocs/core/lib/tax.lib.php | 338 +---------------------- 2 files changed, 6 insertions(+), 343 deletions(-) diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index a4eaccba35b..175ff6cf98f 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -196,8 +196,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll= local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell', $local); -$x_paye = local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy', $local); +$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); echo '
'.$elementsup.''.$productsup.'
'; @@ -220,9 +220,9 @@ else 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']['localtax'.$local] = $x_coll[$my_coll_rate]['localtax'.$local]; $x_both[$my_coll_rate]['paye']['totalht'] = 0; - $x_both[$my_coll_rate]['paye']['vat'] = 0; + $x_both[$my_coll_rate]['paye']['localtax'.$local] = 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) @@ -637,6 +637,5 @@ else $i++; } -$db->close(); - llxFooter(); +$db->close(); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 6054a32c692..93b4b480dde 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2006-2007 Yannick Warnier * Copyright (C) 2011 Regis Houssin - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2016 Juanjo Menent * Copyright (C) 2012 Cédric Salvador * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García @@ -178,342 +178,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction } } -/** - * Gets LocalTaxes to collect for the given year (and given quarter or month) - * The function gets the LocalTaxes in split results, as the LocalTaxes declaration asks - * to report the amounts for different LocalTaxes rates as different lines. - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Quarter - * @param string $date_start Start date - * @param string $date_end End date - * @param int $modetax 0 or 1 (option on debit) - * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) - * @param int $local 1 for LocalTax1, 2 for LocalTax2 - * @param int $m Month - * @return array List of quarters with LocalTaxes - */ -function local_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $local, $m=0) -{ - global $conf; - - $list=array(); - - if ($direction == 'sell') - { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='facnumber'; - $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; - } - if ($direction == 'buy') - { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; - $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; - } - - // BIENS - - // Define sql request - $sql=''; - if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services - { - - // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx,"; - $sql.= " 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,"; - $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.$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; - 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 service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - - } - else // Option on delivery for goods (payments) and payments for services - { - // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; - $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.$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; - 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 service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - - } - - if (! $sql) return -1; - - dol_syslog("Tax.lib.php::vat_by_date sql=".$sql); - - $resql = $db->query($sql); - if ($resql) - { - $lt=-1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; - if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; - - if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { - $oldrowid=$assoc['rowid']; - $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; - } - - $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; - $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; - - $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; - $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); - - $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; - $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; - $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; - $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; - - $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; - - $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; - $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; - $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; - - $lt = $assoc['localtax_tx']; - } - } - else - { - dol_print_error($db); - return -3; - } - - // CAS DES SERVICES - - // Define sql request - $sql=''; - if ($modetax == 1) // Option vat on delivery for goods (payment) and debit invoice for services - { - - // Count on invoice date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; - $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.$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; - 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.= " ORDER BY d.rowid, d.".$fk_facture; - - } - else // Option vat on delivery for goods (payments) and payments for services - { - - // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; - $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.= " 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.$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 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.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; - - } - - if (! $sql) - { - dol_syslog("Tax.lib.php::local_by_date no accountancy module enabled".$sql,LOG_ERR); - return -1; - } - - dol_syslog("Tax.lib.php::local_by_date sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $lt = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; - if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; - - if ($assoc['rowid'] != $oldrowid) - { - $oldrowid=$assoc['rowid']; - $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; - } - - $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; - $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; - - $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; - $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); - - $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; - $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; - $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; - $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; - - $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; - - $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; - $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; - $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; - - $lt = $assoc['localtax_tx']; - } - } - else - { - dol_print_error($db); - return -3; - } - - return $list; - - -} - - /** * Gets VAT to collect for the given year (and given quarter or month) * The function gets the VAT in split results, as the VAT declaration asks From 9f4ccfab95760b425951c194241aeba71c9c27a1 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 15:54:51 +0200 Subject: [PATCH 111/123] FIX #3815 With higher quality --- htdocs/compta/localtax/quadri_detail.php | 15 +- htdocs/core/lib/tax.lib.php | 365 ----------------------- 2 files changed, 7 insertions(+), 373 deletions(-) diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index 73cfdff0659..b0a103ac514 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -196,8 +196,8 @@ $total = 0; $i=0; // Load arrays of datas -$x_coll= local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell', $local); -$x_paye = local_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy', $local); +$x_coll = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'sell'); +$x_paye = vat_by_date($db, 0, 0, $date_start, $date_end, $modetax, 'buy'); echo '
'; @@ -220,9 +220,9 @@ else 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']['localtax'.$local] = $x_coll[$my_coll_rate]['localtax'.$local]; $x_both[$my_coll_rate]['paye']['totalht'] = 0; - $x_both[$my_coll_rate]['paye']['vat'] = 0; + $x_both[$my_coll_rate]['paye']['localtax'.$local] = 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) @@ -399,7 +399,7 @@ else print $langs->trans("NotUsedForGoods"); } else { - print $fields['payment_amount']; + print price($fields['payment_amount']); if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; } print ''; @@ -559,7 +559,7 @@ else } else { - print $fields['payment_amount']; + print price($fields['payment_amount']); if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)'; } print ''; @@ -637,6 +637,5 @@ else $i++; } -$db->close(); - llxFooter(); +$db->close(); diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index ae217004bbf..b4ae09c6d7d 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -205,371 +205,6 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction } } -/** - * Gets LocalTaxes to collect for the given year (and given quarter or month) - * The function gets the LocalTaxes in split results, as the LocalTaxes declaration asks - * to report the amounts for different LocalTaxes rates as different lines. - * - * @param DoliDB $db Database handler object - * @param int $y Year - * @param int $q Quarter - * @param string $date_start Start date - * @param string $date_end End date - * @param int $modetax 0 or 1 (option on debit) - * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) - * @param int $local 1 for LocalTax1, 2 for LocalTax2 - * @param int $m Month - * @return array List of quarters with LocalTaxes - */ -function local_by_date($db, $y, $q, $date_start, $date_end, $modetax, $direction, $local, $m=0) -{ - global $conf; - - $list=array(); - - if ($direction == 'sell') - { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - $invoicefieldref='facnumber'; - $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; - } - if ($direction == 'buy') - { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $total_localtax1='total_localtax1'; - $total_localtax2='total_localtax2'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - $invoicefieldref='ref'; - $localtax_tx=$local==1?'localtax1_tx':'localtax2_tx'; - } - - // BIENS - - // Define sql request - $sql=''; - if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services - { - if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) - { - $sql='TODO'; - } - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) - { - // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx,"; - $sql.= " 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,"; - $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.$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)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - $sql.= " AND f.rowid = d.".$fk_facture; - 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 service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - } - } - else // Option vat on delivery for goods (payments) and payments for services - { - if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) - { - $sql='TODO'; - } - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) - { - // 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.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; - $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.$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)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - $sql.= " AND f.rowid = d.".$fk_facture; - 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 service - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - } - } - - if (! $sql) return -1; - if ($sql == 'TODO') return -2; - if ($sql != 'TODO') - { - dol_syslog("Tax.lib.php::vat_by_date sql=".$sql); - - $resql = $db->query($sql); - if ($resql) - { - $lt=-1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; - if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; - - if ($assoc['rowid'] != $oldrowid) - { - $oldrowid=$assoc['rowid']; - $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; - } - - $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; - $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; - - $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; - $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); - - $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; - $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; - $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; - $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; - - $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; - - $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; - $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; - $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; - - $lt = $assoc['localtax_tx']; - } - } - else - { - dol_print_error($db); - return -3; - } - } - - - //SERVICES - - // Define sql request - $sql=''; - if ($modetax == 1) // Option on delivery for goods (payment) and debit invoice for services - { - if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) - { - $sql='TODO'; - } - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) - { - // Count on invoice date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; - $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.$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)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - $sql.= " AND f.rowid = d.".$fk_facture; - 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.= " ORDER BY d.rowid, d.".$fk_facture; - } - } - else // Option on delivery for goods (payments) and payments for services - { - if (! empty($conf->global->MAIN_MODULE_ACCOUNTING)) - { - - $sql='TODO'; - } - if (! empty($conf->global->MAIN_MODULE_COMPTABILITE)) - { - // Count on payments date - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_tx as rate, d.".$localtax_tx." as localtax_tx, 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,"; - $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.= " 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.$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)"; - else $sql.= " AND f.type IN (0,1,2,3)"; - $sql.= " AND f.rowid = d.".$fk_facture;; - $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.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; - } - } - - if (! $sql) - { - dol_syslog("Tax.lib.php::vat_by_date 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::vat_by_date sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $lt = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['localtax_tx']]['totalht'])) $list[$assoc['localtax_tx']]['totalht']=0; - if (! isset($list[$assoc['localtax_tx']]['vat'])) $list[$assoc['localtax_tx']]['vat']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax1'])) $list[$assoc['localtax_tx']]['localtax1']=0; - if (! isset($list[$assoc['localtax_tx']]['localtax2'])) $list[$assoc['localtax_tx']]['localtax2']=0; - - if ($assoc['rowid'] != $oldrowid) - { - $oldrowid=$assoc['rowid']; - $list[$assoc['localtax_tx']]['totalht'] += $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat'] += $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1'] += $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2'] += $assoc['total_localtax2']; - } - - $list[$assoc['localtax_tx']]['localtax1_tx'] = $assoc['localtax1_tx']; - $list[$assoc['localtax_tx']]['localtax2_tx'] = $assoc['localtax2_tx']; - - $list[$assoc['localtax_tx']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['localtax_tx']]['dtype'][] = $assoc['dtype']; - $list[$assoc['localtax_tx']]['ddate_start'][] = $db->jdate($assoc['date_start']); - $list[$assoc['localtax_tx']]['ddate_end'][] = $db->jdate($assoc['date_end']); - - $list[$assoc['localtax_tx']]['facid'][] = $assoc['facid']; - $list[$assoc['localtax_tx']]['facnum'][] = $assoc['facnum']; - $list[$assoc['localtax_tx']]['type'][] = $assoc['type']; - $list[$assoc['localtax_tx']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['localtax_tx']]['descr'][] = $assoc['descr']; - - $list[$assoc['localtax_tx']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['localtax_tx']]['vat_list'][] = $assoc['total_vat']; - $list[$assoc['localtax_tx']]['localtax1_list'][] = $assoc['total_localtax1']; - $list[$assoc['localtax_tx']]['localtax2_list'][] = $assoc['total_localtax2']; - - $list[$assoc['localtax_tx']]['pid'][] = $assoc['pid']; - $list[$assoc['localtax_tx']]['pref'][] = $assoc['pref']; - $list[$assoc['localtax_tx']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['localtax_tx']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['localtax_tx']]['payment_amount'][] = $assoc['payment_amount']; - - $lt = $assoc['localtax_tx']; - } - } - else - { - dol_print_error($db); - return -3; - } - } - - return $list; - - -} - - /** * Gets VAT to collect for the given year (and given quarter or month) * The function gets the VAT in split results, as the VAT declaration asks From ecbf5996c1b315cd1f0b63f11972e2094f2317b1 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 15 Apr 2016 17:20:37 +0200 Subject: [PATCH 112/123] FIX #4961 --- htdocs/compta/prelevement/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index 9dd841e0add..58e7840a7ec 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2010 Laurent Destailleur - * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2010-2016 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 @@ -298,7 +298,7 @@ if ($id > 0) $num = $db->num_rows($result); $i = 0; - $urladd = "&id=".$prev_id; + $urladd = "&id=".$id; print_barre_liste("", $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num); print"\n\n"; From 09528cccaf7d2752efb9af20d7ba4814632f6ea5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 17 Apr 2016 19:14:48 +0200 Subject: [PATCH 113/123] Update printsheet.php --- htdocs/barcode/printsheet.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index bb3934625b6..81533de82ae 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -62,7 +62,7 @@ if (GETPOST('submitproduct') && GETPOST('submitproduct')) { $producttmp->fetch(GETPOST('productid')); $forbarcode=$producttmp->barcode; - $fk_barcode_type=$thirdpartytmp->barcode_type_code; + $fk_barcode_type=$producttmp->barcode_type; if (empty($fk_barcode_type) && ! empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE; From 3db34a723d1eaaee2553825e2680579f879535d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 18 Apr 2016 00:55:12 +0200 Subject: [PATCH 114/123] Update style.css.php --- htdocs/theme/eldy/style.css.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0314ce7b928..f474c4463d8 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -103,7 +103,7 @@ $useboldtitle=1; if (! isset($conf->global->THEME_ELDY_BACKBODY)) $conf->global->THEME_ELDY_BACKBODY=$colorbackbody; if (! isset($conf->global->THEME_ELDY_TOPMENU_BACK1)) $conf->global->THEME_ELDY_TOPMENU_BACK1='120,130,170'; if (! isset($conf->global->THEME_ELDY_BACKTITLE1)) $conf->global->THEME_ELDY_BACKTITLE1=$colorbacktitle1; -if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER=='238,246,252'; +if (! isset($conf->global->THEME_ELDY_USE_HOVER)) $conf->global->THEME_ELDY_USE_HOVER='238,246,252'; if (! isset($conf->global->THEME_ELDY_TEXTTITLENOTAB)) $conf->global->THEME_ELDY_TEXTTITLENOTAB=$colortexttitlenotab; if (! isset($conf->global->THEME_ELDY_TEXTLINK)) $conf->global->THEME_ELDY_TEXTLINK=$colortextlink; From 0a52abab5df8cca431a71f9f4cecf1f5bd06ad90 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 19 Apr 2016 13:38:32 +0200 Subject: [PATCH 115/123] Fix: broken multicompany transverse mode authentication feature --- htdocs/user/class/user.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 85f340b1cb1..1ee07e0a7af 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -207,7 +207,10 @@ class User extends CommonObject } else // The fetch was forced on an entity { - $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; + if (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode)) + $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database + else + $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; } if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba From 79f408feebde0f24599c9a9e9ff24acae73f199d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 20 Apr 2016 17:17:03 +0200 Subject: [PATCH 116/123] FIX : When cloning an order the order result from clone must be now --- htdocs/commande/class/commande.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f184e6f6358..af73be2330d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -985,6 +985,7 @@ class Commande extends CommonOrder $this->user_author_id = $user->id; $this->user_valid = ''; $this->date = dol_now(); + $this->date_commande = dol_now(); $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; @@ -1253,7 +1254,7 @@ class Commande extends CommonOrder $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -1386,7 +1387,7 @@ class Commande extends CommonOrder if (empty($tva_tx)) $tva_npr=0; $localtax1_tx=get_localtax($tva_tx,1,$this->client,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$this->client,$mysoc,$tva_npr); - + // multiprix if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) $price = $prod->multiprices[$this->client->price_level]; @@ -2481,7 +2482,7 @@ class Commande extends CommonOrder $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - + $tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2918,7 +2919,7 @@ class Commande extends CommonOrder function LibStatut($statut,$billed,$mode,$donotshowbilled=0) { global $langs, $conf; - + $billedtext = ''; if (empty($donotshowbilled)) $billedtext .= ($billed?' - '.$langs->trans("Billed"):''); From e1d55d280eab94778ffe3092f2c57a829a01d42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Apr 2016 22:29:27 +0200 Subject: [PATCH 117/123] Update printgcp.modules.php --- .../modules/printing/printgcp.modules.php | 84 +++++++++---------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 5177e108f40..610df641deb 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -65,52 +65,52 @@ class printing_printgcp extends PrintingDriver $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 - $this->db = $db; - $this->google_id = $conf->global->OAUTH_GOOGLE_ID; - $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; - // Token storage - $storage = new DoliStorage($this->db, $this->conf); - //$storage->clearToken('Google'); - // Setup the credentials for the requests - $credentials = new Credentials( - $this->google_id, - $this->google_secret, - $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' - ); - $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); - $serviceFactory = new \OAuth\ServiceFactory(); - $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); - $token_ok=true; - try { - $token = $storage->retrieveAccessToken('Google'); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $token_ok = false; - } - //var_dump($this->errors);exit; - - $expire = false; - // Is token expired or will token expire in the next 30 seconds - if ($token_ok) { - $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); - } - - // Token expired so we refresh it - if ($token_ok && $expire) { - try { - // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois - $refreshtoken = $token->getRefreshToken(); - $token = $apiService->refreshAccessToken($token); - $token->setRefreshToken($refreshtoken); - $storage->storeAccessToken('Google', $token); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } if (!$conf->oauth->enabled) { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'ModuleAuthNotActive', 'type'=>'info'); } else { + $this->db = $db; + $this->google_id = $conf->global->OAUTH_GOOGLE_ID; + $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; + // Token storage + $storage = new DoliStorage($this->db, $this->conf); + //$storage->clearToken('Google'); + // Setup the credentials for the requests + $credentials = new Credentials( + $this->google_id, + $this->google_secret, + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' + ); + $access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken'); + $serviceFactory = new \OAuth\ServiceFactory(); + $apiService = $serviceFactory->createService('Google', $credentials, $storage, array()); + $token_ok=true; + try { + $token = $storage->retrieveAccessToken('Google'); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $token_ok = false; + } + //var_dump($this->errors);exit; + + $expire = false; + // Is token expired or will token expire in the next 30 seconds + if ($token_ok) { + $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); + } + + // Token expired so we refresh it + if ($token_ok && $expire) { + try { + // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois + $refreshtoken = $token->getRefreshToken(); + $token = $apiService->refreshAccessToken($token); + $token->setRefreshToken($refreshtoken); + $storage->storeAccessToken('Google', $token); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info', 'renew'=>$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?state=userinfo_email,userinfo_profile,cloud_print&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'), 'delete'=>($storage->hasAccessToken('Google')?$urlwithroot.'/core/modules/oauth/google_oauthcallback.php?action=delete&backtourl='.urlencode(DOL_URL_ROOT.'/printing/admin/printing.php?mode=setup&driver=printgcp'):'')); From e3e2b8750624063ca92a8ae288e3548df93a5cdc Mon Sep 17 00:00:00 2001 From: Philippe-OpenDSI Date: Wed, 20 Apr 2016 13:59:13 +0200 Subject: [PATCH 118/123] Product supplier list display only one product Last parameter of select_produits_fournisseurs_list is $limit, not $socidif --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c17fdb65aea..05efcc24a0e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -183,7 +183,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) if (empty($mode) || $mode == 1) { $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); } $db->close(); From d043c9ce80be068239eb010877d5d4f3568f8d15 Mon Sep 17 00:00:00 2001 From: placid0w Date: Wed, 20 Apr 2016 15:43:14 -0300 Subject: [PATCH 119/123] Fix #5054 --- htdocs/webservices/server_productorservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 2e3314fff12..43facbb24fa 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -374,7 +374,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $product->load_stock(); $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos/"; + $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/"; $dir = $dir . '/'. $pdir; if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; From fd9fb505b97230bd3514c16e33c4d7d75cc2e9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 21 Apr 2016 07:53:22 +0200 Subject: [PATCH 120/123] Update printgcp.modules.php --- htdocs/core/modules/printing/printgcp.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index 610df641deb..3911c4d6be2 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -64,12 +64,12 @@ class printing_printgcp extends PrintingDriver $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 + $this->db = $db; if (!$conf->oauth->enabled) { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'ModuleAuthNotActive', 'type'=>'info'); } else { - $this->db = $db; $this->google_id = $conf->global->OAUTH_GOOGLE_ID; $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; // Token storage From 2fc876f60773cc8d49f51f2768bc6634a962d7ca Mon Sep 17 00:00:00 2001 From: Philippe-OpenDSI Date: Thu, 21 Apr 2016 08:41:45 +0200 Subject: [PATCH 121/123] FIX #5048 Product supplier list display only one produc Last parameter of select_produits_fournisseurs_list is $limit, not $socid --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c17fdb65aea..05efcc24a0e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -183,7 +183,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) if (empty($mode) || $mode == 1) { $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); } $db->close(); From 0ef1be93642d66a110d881ab78cd5852b2526a8c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Apr 2016 18:07:34 +0200 Subject: [PATCH 122/123] Prepare 3.9.1 --- ChangeLog | 65 +++++++++++++++++++++++++++++++++++++++++ htdocs/filefunc.inc.php | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 84d05ba8ea7..120c19ca5e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,71 @@ Upgrading to any other version or any other database system is abolutely require make a Dolibarr upgrade. +***** ChangeLog for 3.9.1 compared to 3.9.* ***** +FIX: #3815 Call to undefined function local_by_date(). +FIX: #3815 With higher quality +FIX: #4424 Missing email of user popup in supplier orders area +FIX: #4442 Missing translation in Banks menu +FIX: #4737 Bank transacion type selector translation is cropped +FIX: #4742 Able to delete a supplier invoice with a registered payment +FIX: #4743 UI glitch in project summary page +FIX: #4747 Missing UI background when registering a supplier invoice payment +FIX: #4748 Supplier invoice payment confirmation amount is not translated +FIX: #4766 VAT not shown in supplier invoice popup +FIX: #4784 +FIX: #4809 Duplicate functions with different content +FIX: #4812 +FIX: #4839 +FIX: #4851 Project selector in supplier invoices shows the project label twice +FIX: #4870 +FIX: #4874 SQL error when listing users +FIX: #4880 +FIX: #4961 +FIX: #4989 +FIX: A not enabled field for list must not into fields to add +FIX: Bad color of message password changed +FIX: Bad error and style message when changing its own login +FIX: Bad function name call on delete +FIX: Bad include and param for project numbering module call +FIX: bad translation language loaded FIX: When changing thirdparty on event card, the showempty option of contact was lost. FIX: Bad placeholder shown on combo to select a thirdparty. +FIX: Bad vat definition when using POS module +FIX: Box disabled because bugged +FIX: Can not select a commercial on the creation of a third +FIX: Check of EAN13 barcode when mask was set to use 13 digits instead of 12 +FIX: correct display of minimum buying price +FIX: Creation of thumb image for size "small" was not done. +FIX: Damn, where was the project ref ? +FIX: Default vat is not set correctly when an error occured and we use VAT identified by a code. +FIX: dont retrieve new buying price on margin display +FIX: Duplicate records into export +FIX: Each time we edit a line, we loose the unit price. +FIX: Email templates not compatible with Multicompany +FIX: Export must use a left join to not loose lines +FIX: fetchAllEMailTemplate +FIX: Filter/search on extrafields on lists +FIX: finished parameters not used +FIX: Generated thumbs must always use the png format so using thumbs can work. +FIX: Hook resprint be printed +FIX: image extension must be in lower case +FIX: Missing clean of criteria +FIX: Missing database escaping on supplier price insert/update +FIX: Missing function +FIX: Multiprice generator didn't recalculate prices if only the price_base_type property changes +FIX: Not removing code into vatrate. +FIX: Not showing sellprice properly on product list +FIX: Parsing of amount to pay vat +FIX: PHPCS +FIX: PMP is deprecated at warehouse level +FIX: real min buying price +FIX: Same term to create than other objects +FIX: Some records were lost into margin per product report +FIX: systematic rounding causes prices to be updated without reason +FIX: Template email must take care of positino column +FIX: VAT rate can be negative. Example spain selling to morroco. +FIX: When cloning an order the order result from clone must be now +FIX: When using option Price per level, when adding a predefined product, the vat for customer was not correctly set. + + ***** ChangeLog for 3.9.0 compared to 3.8.* ***** For users: NEW: A new and more modern look for "eldy" theme. diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index bf7357fb2e1..db8a5869914 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.0'); +if (! defined('DOL_VERSION')) define('DOL_VERSION','3.9.1'); if (! defined('EURO')) define('EURO',chr(128)); From 980f3d522fbfd01d4f67bce8a6cfcd7552f546da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Apr 2016 20:09:42 +0200 Subject: [PATCH 123/123] Prepare 3.9.1 --- ChangeLog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 120c19ca5e7..2ab1185a65c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,8 +13,7 @@ make a Dolibarr upgrade. ***** ChangeLog for 3.9.1 compared to 3.9.* ***** -FIX: #3815 Call to undefined function local_by_date(). -FIX: #3815 With higher quality +FIX: #3815 Call to undefined function local_by_date() FIX: #4424 Missing email of user popup in supplier orders area FIX: #4442 Missing translation in Banks menu FIX: #4737 Bank transacion type selector translation is cropped @@ -33,6 +32,7 @@ FIX: #4874 SQL error when listing users FIX: #4880 FIX: #4961 FIX: #4989 +FIX: If oauth has never been activated two tables are missing and printing is not working FIX: A not enabled field for list must not into fields to add FIX: Bad color of message password changed FIX: Bad error and style message when changing its own login