From bfadd39e8cda84dd477e8812829c177e71a19154 Mon Sep 17 00:00:00 2001 From: Abbes Bahfir Date: Fri, 19 Oct 2018 12:46:54 +0100 Subject: [PATCH 001/103] Fix: Grant right to child classes to use Category methods --- htdocs/categories/class/categorie.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index a9432234793..97bceaf082c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -65,7 +65,7 @@ class Categorie extends CommonObject * * @note This array should be remove in future, once previous constants are moved to the string value. Deprecated */ - private $MAP_ID = array( + protected $MAP_ID = array( 'product' => 0, 'supplier' => 1, 'customer' => 2, @@ -93,7 +93,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_CAT_FK = array( + protected $MAP_CAT_FK = array( 'product' => 'product', 'customer' => 'soc', 'supplier' => 'soc', @@ -109,7 +109,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_CAT_TABLE = array( + protected $MAP_CAT_TABLE = array( 'product' => 'product', 'customer' => 'societe', 'supplier' => 'fournisseur', @@ -125,7 +125,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_OBJ_CLASS = array( + protected $MAP_OBJ_CLASS = array( 'product' => 'Product', 'customer' => 'Societe', 'supplier' => 'Fournisseur', @@ -141,7 +141,7 @@ class Categorie extends CommonObject * * @note Move to const array when PHP 5.6 will be our minimum target */ - private $MAP_OBJ_TABLE = array( + protected $MAP_OBJ_TABLE = array( 'product' => 'product', 'customer' => 'societe', 'supplier' => 'societe', @@ -931,7 +931,7 @@ class Categorie extends CommonObject * * @return int <0 if KO, >0 if OK */ - private function load_motherof() + protected function load_motherof() { // phpcs:enable global $conf; From d8537a3c7696f83f6d17f79be50fbb3223ae84f8 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 27 Nov 2018 11:36:31 +0100 Subject: [PATCH 002/103] FIX Lines are not inserted correctly if VAT have code --- htdocs/comm/propal/class/propal.class.php | 21 +++++++------- htdocs/commande/class/commande.class.php | 29 ++++++++++--------- htdocs/contrat/class/contrat.class.php | 22 +++++++------- .../class/expensereport.class.php | 19 ++++++------ .../class/fournisseur.commande.class.php | 29 ++++++++++--------- 5 files changed, 62 insertions(+), 58 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 2b3ae7834e1..d30b430bc4b 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -424,6 +425,16 @@ class Propal extends CommonObject if (empty($rang)) $rang=0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; + $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu_ht=price2num($pu_ht); @@ -469,16 +480,6 @@ class Propal extends CommonObject // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); - - // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $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, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 739a6538612..6f795511a56 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García - * Copyright (C) 2016-2017 Ferran Marcet + * Copyright (C) 2016-2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1283,6 +1283,16 @@ class Commande extends CommonOrder if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line=0; if (empty($this->fk_multicurrency)) $this->fk_multicurrency=0; + $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu_ht=price2num($pu_ht); @@ -1326,20 +1336,11 @@ class Commande extends CommonOrder return self::STOCK_NOT_ENOUGH_FOR_ORDER; } } + // Calcul du total TTC et de la TVA pour la ligne a partir de - // qty, pu, remise_percent et txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); - - // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index a460f6aff51..a827647c354 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-2017 Ferran Marcet + * Copyright (C) 2015-2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1358,6 +1358,16 @@ class Contrat extends CommonObject { $this->db->begin(); + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + // Clean parameters $pu_ht=price2num($pu_ht); $pu_ttc=price2num($pu_ttc); @@ -1392,16 +1402,6 @@ class Contrat extends CommonObject // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); - - // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $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, 1,$mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index c6debbe60ff..966f7b1af84 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1,8 +1,8 @@ - * Copyright (C) 2015 Laurent Destailleur - * Copyright (C) 2015 Alexandre Spangaro - * Copyright (C) 2016 Ferran Marcet +/* Copyright (C) 2011 Dimitri Mouillard + * Copyright (C) 2015 Laurent Destailleur + * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016-2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1685,6 +1685,12 @@ class ExpenseReport extends CommonObject if (empty($date)) $date = ''; if (empty($fk_project)) $fk_project = 0; + if (preg_match('/\((.*)\)/', $vatrate, $reg)) + { + $vat_src_code = $reg[1]; + $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. + } + $qty = price2num($qty); $vatrate = price2num($vatrate); $up = price2num($up); @@ -1695,11 +1701,6 @@ class ExpenseReport extends CommonObject $this->line = new ExpenseReportLine($this->db); - if (preg_match('/\((.*)\)/', $vatrate, $reg)) - { - $vat_src_code = $reg[1]; - $vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate. - } $vatrate = preg_replace('/\*/','',$vatrate); $seller = ''; // seller is unknown diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1dc68b34bc2..ca7651d641f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1434,6 +1435,16 @@ class CommandeFournisseur extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($remise_percent)) $remise_percent=0; + $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc,$this->thirdparty); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu_ht=price2num($pu_ht); @@ -1526,20 +1537,10 @@ class CommandeFournisseur extends CommonOrder $product_type = $type; } - // Calcul du total TTC et de la TVA pour la ligne a partir de - // qty, pu, remise_percent et txtva - // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker - // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc,$this->thirdparty); - - // Clean vat code - $vat_src_code=''; - if (preg_match('/\((.*)\)/', $txtva, $reg)) - { - $vat_src_code = $reg[1]; - $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. - } + // Calcul du total TTC et de la TVA pour la ligne a partir de + // qty, pu, remise_percent et txtva + // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker + // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise); $total_ht = $tabprice[0]; From 6ab12b59119b4f665b91e4caaef535d815802f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 1 Dec 2018 00:26:51 +0100 Subject: [PATCH 003/103] Update llx_paiementfourn.sql --- htdocs/install/mysql/tables/llx_paiementfourn.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_paiementfourn.sql b/htdocs/install/mysql/tables/llx_paiementfourn.sql index 0e9b1885c97..511febcf1fa 100644 --- a/htdocs/install/mysql/tables/llx_paiementfourn.sql +++ b/htdocs/install/mysql/tables/llx_paiementfourn.sql @@ -28,6 +28,7 @@ create table llx_paiementfourn amount real DEFAULT 0, -- montant multicurrency_amount double(24,8) DEFAULT 0, -- multicurrency amount fk_user_author integer, -- auteur + fk_user_modif integer, fk_paiement integer NOT NULL, -- moyen de paiement num_paiement varchar(50), -- numero de paiement (cheque) note text, From 0270da7d8c8a6d95936ff5ca96b0906f13e27888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 1 Dec 2018 00:28:58 +0100 Subject: [PATCH 004/103] Update 5.0.0-6.0.0.sql --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql index 06d006230a0..740cba9d914 100644 --- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql +++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql @@ -317,6 +317,7 @@ ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN multicurrency_amount double ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255); +ALTER TABLE llx_paiementfourn ADD COLUMN fk_user_modif integer AFTER fk_user_author; insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); From 8c13c87429dc1d0df723fdd0ab57462d936845b8 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 1 Dec 2018 16:55:42 +0100 Subject: [PATCH 005/103] Fix path for user photo --- htdocs/core/class/html.form.class.php | 8 ++++---- htdocs/user/card.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4d91e8a358a..ef95b3679ef 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6860,10 +6860,10 @@ class Form $dir=$conf->user->dir_output; if (! empty($object->photo)) { - if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_mini'); - else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').getImageFileNameForSize($object->photo, '_small'); - else $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo; - $originalfile=get_exdir($id, 2, 0, 0, $object, 'user').$object->photo; + if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); + else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); + else $file=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; + $originalfile=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; } if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fd6234268b2..b4aed9f7844 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -449,14 +449,14 @@ if (empty($reshook)) { 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'; + $fileimg = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/logos/'.$object->photo; + $dirthumbs = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/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'); + $dir = $conf->user->dir_output.'/'.get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id; dol_mkdir($dir); From 5e2f3a53c9ab309d35f4a3179c30be7ef5abc374 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 1 Dec 2018 19:39:00 +0100 Subject: [PATCH 006/103] Fix expense report in ecm auto dir --- htdocs/core/ajax/ajaxdirpreview.php | 4 +++- htdocs/core/class/html.formfile.class.php | 8 +++++++- htdocs/ecm/index_auto.php | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 4d72b576429..04c16c75fe0 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -172,7 +172,7 @@ if ($type == 'directory') $sorting = (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC); // Right area. If module is defined here, we are in automatic ecm. - $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport'); + $automodules = array('company', 'invoice', 'invoice_supplier', 'propal', 'supplier_proposal', 'order', 'order_supplier', 'contract', 'product', 'tax', 'project', 'fichinter', 'user', 'expensereport', 'holiday'); // TODO change for multicompany sharing // Auto area for suppliers invoices @@ -203,6 +203,8 @@ if ($type == 'directory') else if ($module == 'user') $upload_dir = $conf->user->dir_output; // Auto area for expense report else if ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output; + // Auto area for holiday + else if ($module == 'holiday') $upload_dir = $conf->holiday->dir_output; // Automatic list if (in_array($module, $automodules)) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 9219d242151..09e70d4201a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1392,6 +1392,11 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; $object_instance=new ExpenseReport($this->db); } + else if ($modulepart == 'holiday') + { + include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; + $object_instance=new Holiday($this->db); + } foreach($filearray as $key => $file) { @@ -1421,7 +1426,8 @@ class FormFile if ($modulepart == 'project') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:'');} if ($modulepart == 'fichinter') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:'');} if ($modulepart == 'user') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:'');} - if ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:'');} + if ($modulepart == 'expensereport') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=(isset($reg[1])?$reg[1]:'');} + if ($modulepart == 'holiday') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $id=(isset($reg[1])?$reg[1]:'');} if (! $id && ! $ref) continue; $found=0; diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 19c607b1612..3ff4ce64887 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -331,6 +331,7 @@ if (! empty($conf->global->ECM_AUTO_TREE_ENABLED)) if (! empty($conf->projet->enabled)) { $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'project', 'test'=>$conf->projet->enabled, 'label'=>$langs->trans("Projects"), 'desc'=>$langs->trans("ECMDocsByProjects")); } if (! empty($conf->ficheinter->enabled)) { $langs->load("interventions"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'fichinter', 'test'=>$conf->ficheinter->enabled, 'label'=>$langs->trans("Interventions"), 'desc'=>$langs->trans("ECMDocsByInterventions")); } if (! empty($conf->expensereport->enabled)) { $langs->load("trips"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'expensereport', 'test'=>$conf->expensereport->enabled, 'label'=>$langs->trans("ExpenseReports"), 'desc'=>$langs->trans("ECMDocsByExpenseReports")); } + if (! empty($conf->holiday->enabled)) { $langs->load("holiday"); $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'holiday', 'test'=>$conf->holiday->enabled, 'label'=>$langs->trans("Holidays"), 'desc'=>$langs->trans("ECMDocsByHolidays")); } $rowspan++; $sectionauto[]=array('level'=>1, 'module'=>'user', 'test'=>1, 'label'=>$langs->trans("Users"), 'desc'=>$langs->trans("ECMDocsByUsers")); } From 72225f65247f3fbba5be98b3a3adcf9139d15d26 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 1 Dec 2018 23:57:15 +0100 Subject: [PATCH 007/103] Migration of user photo paths --- htdocs/install/upgrade2.php | 71 ++++++++++++++++++++++++++++++++- htdocs/langs/en_US/install.lang | 1 + 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 1011dcef9cb..08fa147fb0d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -446,7 +446,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 $beforeversionarray=explode('.','9.0.9'); if (versioncompare($versiontoarray,$afterversionarray) >= 0 && versioncompare($versiontoarray,$beforeversionarray) <= 0) { - //migrate_rename_directories($db,$langs,$conf,'/contracts','/contract'); + migrate_user_photospath(); } } @@ -4826,7 +4826,76 @@ function migrate_reload_menu($db,$langs,$conf,$versionto) } } +/** + * Migrate file from old path to new one for users + * + * @return void + */ +function migrate_user_photospath() +{ + global $conf, $db, $langs; + + print ''; + print ''.$langs->trans('MigrationUserPhotoPath')."
\n"; + + include_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $fuser = new User($db); + + $sql = "SELECT rowid as uid from ".MAIN_DB_PREFIX."user"; // Get list of all users + $resql = $db->query($sql); + if ($resql) + { + while ($obj = $db->fetch_object($resql)) + { + $fuser->fetch($obj->uid); + //echo '
'.$fuser->id.' -> '.$fuser->entity; + $entity = (!empty($fuser->entity)) ? $fuser->entity : 1; + $dir = $conf->user->multidir_output[$entity]; + $origin = $dir .'/'. get_exdir($fuser->id,2,0,0,$fuser,'user'); + $destin = $dir.'/'.$fuser->id; + + $error = 0; + + $origin_osencoded=dol_osencode($origin); + $destin_osencoded=dol_osencode($destin); + dol_mkdir($destin); + //echo '
'.$origin.' -> '.$destin; + if (dol_is_dir($origin)) + { + $handle=opendir($origin_osencoded); + if (is_resource($handle)) + { + while (($file = readdir($handle)) !== false) + { + if ($file != '.' && $file != '..' && is_dir($origin_osencoded.'/'.$file)) + { + $thumbs = opendir($origin_osencoded.'/'.$file); + if (is_resource($thumbs)) + { + dol_mkdir($destin.'/'.$file); + while (($thumb = readdir($thumbs)) !== false) + { + dol_move($origin.'/'.$file.'/'.$thumb, $destin.'/'.$file.'/'.$thumb); + } + // dol_delete_dir($origin.'/'.$file); + } + } + else + { + if (dol_is_file($origin.'/'.$file) ) + { + dol_move($origin.'/'.$file, $destin.'/'.$file); + } + } + } + } + } + } + } + + print ''; +} /* A faire egalement: Modif statut paye et fk_facture des factures payes completement diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index bcca348c861..c92d83988ff 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -200,6 +200,7 @@ MigrationRemiseEntity=Update entity field value of llx_societe_remise MigrationRemiseExceptEntity=Update entity field value of llx_societe_remise_except MigrationUserRightsEntity=Update entity field value of llx_user_rights MigrationUserGroupRightsEntity=Update entity field value of llx_usergroup_rights +MigrationUserPhotoPath=Migration of photo paths for users MigrationReloadModule=Reload module %s MigrationResetBlockedLog=Reset module BlockedLog for v7 algorithm ShowNotAvailableOptions=Show unavailable options From ad05b531e7f9603b885630364c6049c84ee63e9d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 2 Dec 2018 00:02:43 +0100 Subject: [PATCH 008/103] Fix display user photo with new path --- htdocs/core/class/html.form.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1394ad46f2b..8ba38b81edb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6861,10 +6861,10 @@ class Form $dir=$conf->user->dir_output; if (! empty($object->photo)) { - if ((string) $imagesize == 'mini') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); - else if ((string) $imagesize == 'small') $file=get_exdir($id, 2, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); - else $file=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; - $originalfile=get_exdir($id, 2, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; + if ((string) $imagesize == 'mini') $file=get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini'); + else if ((string) $imagesize == 'small') $file=get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small'); + else $file=get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; + $originalfile=get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo; } if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility $email=$object->email; From d2d623b0b6f6688291714087987f9121a74ac128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 2 Dec 2018 09:26:24 +0100 Subject: [PATCH 009/103] GETPOSTISSET has only one param --- htdocs/admin/mails_templates.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 945656962ea..a9068544e35 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -11,6 +11,7 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2015 Ferran Marcet * Copyright (C) 2016 Raphaël Doursenaud + * Copyright (C) 2018 Frédéric France * * 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 @@ -995,7 +996,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='') print ''; if (! empty($conf->global->MAIN_MULTILANGS)) { - $selectedlang = GETPOSTISSET('langcode','aZ09')?GETPOST('langcode','aZ09'):$langs->defaultlang; + $selectedlang = GETPOSTISSET('langcode')?GETPOST('langcode', 'aZ09'):$langs->defaultlang; if ($context == 'edit') $selectedlang = $obj->{$fieldlist[$field]}; print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); } From 8ec2bac36a06421971bffb7baa45aa6ec082fdd0 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 2 Dec 2018 10:02:05 +0100 Subject: [PATCH 010/103] FIX #3234 --- htdocs/admin/barcode.php | 64 ++++++++++++++------ htdocs/core/class/html.formbarcode.class.php | 26 +++++--- 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 313a852e384..75c82157ddf 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -70,18 +70,8 @@ else if ($action == 'update') $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity); $coder_id = GETPOST('GENBARCODE_BARCODETYPE_THIRDPARTY','alpha'); $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity); -} -else if ($action == 'updateengine') -{ - // TODO Update engines. - -} - -if ($action && $action != 'setcoder' && $action != 'setModuleOptions') -{ - if (! $res > 0) $error++; - - if (! $error) + + if ($res > 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -90,6 +80,42 @@ if ($action && $action != 'setcoder' && $action != 'setModuleOptions') setEventMessages($langs->trans("Error"), null, 'errors'); } } +else if ($action == 'updateengine') +{ + $sql = "SELECT rowid, coder"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; + $sql.= " WHERE entity = ".$conf->entity; + $sql.= " ORDER BY code"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + if (GETPOST('coder'.$obj->rowid, 'alpha')) + { + $coder = GETPOST('coder'.$obj->rowid,'alpha'); + $code_id = $obj->rowid; + + $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; + $sqlp.= " SET coder = '" . $coder."'"; + $sqlp.= " WHERE rowid = ". $code_id; + $sqlp.= " AND entity = ".$conf->entity; + + $upsql=$db->query($sqlp); + if (! $upsql) dol_print_error($db); + } + + $i++; + } + } + +} /* * View @@ -162,9 +188,12 @@ $var=true; print '
'; print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); -//print "
"; -//print ''; -//print ""; +if (empty($conf->use_javascript_ajax)) +{ + print ''; + print ''; + print ''; +} print ''; print ''; @@ -260,10 +289,9 @@ print "
\n"; if (empty($conf->use_javascript_ajax)) { - // TODO Implement code behind action updateengine - //print '
'; + print '
'; + print '
'; } -//print ''; print "
"; diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index e1ee7ae04ff..d155c8a1a0c 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -59,7 +59,7 @@ class FormBarCode $disable = ''; - if ($conf->use_javascript_ajax) + if (!empty($conf->use_javascript_ajax)) { print "\n".'