From 7f1adc6a6ab53fce7e3a5d7f910cd90109ffc27e Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Tue, 7 Nov 2017 09:46:39 +0100 Subject: [PATCH 001/125] FIX: Saving wrong localtax on order addline --- htdocs/commande/class/commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index c326efa7e49..0ea9302b221 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1360,8 +1360,8 @@ class Commande extends CommonOrder $this->line->vat_src_code=$vat_src_code; $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=$localtaxes_type[1]; - $this->line->localtax2_tx=$localtaxes_type[3]; + $this->line->localtax1_tx=$txlocaltax1; + $this->line->localtax2_tx=$txlocaltax2; $this->line->localtax1_type=$localtaxes_type[0]; $this->line->localtax2_type=$localtaxes_type[2]; $this->line->fk_product=$fk_product; From 4874d08062ed78dc66ea3bb6e24e5431b5644f05 Mon Sep 17 00:00:00 2001 From: De Coninck Laurent Date: Fri, 19 Jan 2018 08:59:04 +0100 Subject: [PATCH 002/125] fix the bill replacement with discounts #8028 --- htdocs/compta/facture/class/facture.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3c35a03f218..748f83f5a53 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -539,6 +539,15 @@ class Facture extends CommonInvoice } $newinvoiceline->fk_parent_line=$fk_parent_line; + + if($newinvoiceline->fk_remise_except){ + $discount = new DiscountAbsolute($this->db); + $discount->fetch($newinvoiceline->fk_remise_except); + + $discountId = $soc->set_remise_except($discount->amount_ht, $user, $discount->description, $discount->tva_tx); + $newinvoiceline->fk_remise_except = $discountId; + } + $result=$newinvoiceline->insert(); // Defined the new fk_parent_line From 53ac13c792dddc0cbd073ea25657900a323d6dc6 Mon Sep 17 00:00:00 2001 From: De Coninck Laurent Date: Tue, 23 Jan 2018 18:03:29 +0100 Subject: [PATCH 003/125] check on type replacement #8028 --- 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 748f83f5a53..72285e87808 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -540,7 +540,7 @@ class Facture extends CommonInvoice $newinvoiceline->fk_parent_line=$fk_parent_line; - if($newinvoiceline->fk_remise_except){ + if($this->type === Facture::TYPE_REPLACEMENT && $newinvoiceline->fk_remise_except){ $discount = new DiscountAbsolute($this->db); $discount->fetch($newinvoiceline->fk_remise_except); From 6fe69d4a606788e27939e21b74c856a3829f4666 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 15 Feb 2018 15:17:59 +0100 Subject: [PATCH 004/125] Wrong field in thirdparty getnomurl --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index afc33f110cf..9a43c5b3cfa 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1919,7 +1919,7 @@ class Societe extends CommonObject if (! empty($this->code_fournisseur) && $this->fournisseur) $label.= '
' . $langs->trans('SupplierCode') . ': '. $this->code_fournisseur; if (! empty($conf->accounting->enabled) && $this->client) - $label.= '
' . $langs->trans('CustomerAccountancyCode') . ': '. $this->code_compta_client; + $label.= '
' . $langs->trans('CustomerAccountancyCode') . ': '. $this->code_compta; if (! empty($conf->accounting->enabled) && $this->fournisseur) $label.= '
' . $langs->trans('SupplierAccountancyCode') . ': '. $this->code_compta_fournisseur; From bfd46f62ea8ccfee4420f4e63176a58b510eb9a5 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Thu, 15 Feb 2018 15:18:25 +0100 Subject: [PATCH 005/125] Fix : contact and user getnomurl needs all info to display tooltip correctly --- htdocs/core/tpl/contacts.tpl.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 27d57d3e48a..aa392489987 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -201,18 +201,12 @@ if ($permission) { if ($tab[$i]['source']=='internal') { - $userstatic->id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; - $userstatic->photo=$tab[$i]['photo']; - $userstatic->login=$tab[$i]['login']; + $userstatic->fetch($tab[$i]['id']); echo $userstatic->getNomUrl(-1); } if ($tab[$i]['source']=='external') { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; + $contactstatic->fetch($tab[$i]['id']); echo $contactstatic->getNomUrl(1); } ?> @@ -223,16 +217,10 @@ if ($permission) { id=$tab[$i]['id']; - $userstatic->lastname=$tab[$i]['lastname']; - $userstatic->firstname=$tab[$i]['firstname']; echo $userstatic->LibStatut($tab[$i]['statuscontact'],3); } if ($tab[$i]['source']=='external') { - $contactstatic->id=$tab[$i]['id']; - $contactstatic->lastname=$tab[$i]['lastname']; - $contactstatic->firstname=$tab[$i]['firstname']; echo $contactstatic->LibStatut($tab[$i]['statuscontact'],3); } ?> From 63987fa32e1682704dd269f065c1024e882afde5 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 15 Feb 2018 16:39:47 +0100 Subject: [PATCH 006/125] fix invoice extrafield transmition to credit --- htdocs/compta/facture/card.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8cf8f64ed09..86e21e1518b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -852,6 +852,12 @@ if (empty($reshook)) foreach($facture_source->lines as $line) { + // Extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + // load extrafields + $line->fetch_optionals(); + } + // Reset fk_parent_line for no child products and special product if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { $fk_parent_line = 0; From 49bad95d3128e7a3180f5d10ab232a2ae1a8fbe8 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 15 Feb 2018 17:04:27 +0100 Subject: [PATCH 007/125] fix method exist test --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 86e21e1518b..f31b0be6a38 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -853,7 +853,7 @@ if (empty($reshook)) foreach($facture_source->lines as $line) { // Extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($line, 'fetch_optionals')) { // load extrafields $line->fetch_optionals(); } From 235a5f9b7fea1b3b07c3df2c31fd6801e6170450 Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Fri, 16 Feb 2018 09:02:34 +0100 Subject: [PATCH 008/125] Fix : bad var name --- htdocs/core/lib/functions.lib.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 62bda6b57cb..a278ad9bfd6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2231,36 +2231,36 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep } elseif (strtoupper($countrycode) == "PT" ) {//Portugal - if (dol_strlen($object) == 13) + if (dol_strlen($newphone) == 13) {//ex: +351_ABC_DEF_GHI $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "SR" ) {//Suriname - if (dol_strlen($object) == 10) + if (dol_strlen($newphone) == 10) {//ex: +597_ABC_DEF $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,3); } - elseif (dol_strlen($object) == 11) + elseif (dol_strlen($newphone) == 11) {//ex: +597_ABC_DEFG $newphone= substr($newphone,0,4).$separ.substr($newphone,4,3).$separ.substr($newphone,7,4); } } elseif (strtoupper($countrycode) == "DE" ) {//Allemagne - if (dol_strlen($object) == 14) + if (dol_strlen($newphone) == 14) {//ex: +49_ABCD_EFGH_IJK $newphone= substr($newphone,0,3).$separ.substr($newphone,3,4).$separ.substr($newphone,7,4).$separ.substr($newphone,11,3); } - elseif (dol_strlen($object) == 13) + elseif (dol_strlen($newphone) == 13) {//ex: +49_ABC_DEFG_HIJ $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,4).$separ.substr($newphone,10,3); } } elseif (strtoupper($countrycode) == "ES") {//Espagne - if (dol_strlen($object) == 12) + if (dol_strlen($newphone) == 12) {//ex: +34_ABC_DEF_GHI $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,3); } @@ -2281,7 +2281,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep } elseif (strtoupper($countrycode) == "TR") {//Turquie - if (dol_strlen($object) == 13) + if (dol_strlen($newphone) == 13) {//ex : +90 ABC_DEF_GHIJ $newphone= substr($newphone,0,3).$separ.substr($newphone,3,3).$separ.substr($newphone,6,3).$separ.substr($newphone,9,4); } From 7c583227fb0fcdd8b2c70126b6997ba68c58279a Mon Sep 17 00:00:00 2001 From: sschwebel Date: Mon, 19 Feb 2018 10:58:05 +0100 Subject: [PATCH 009/125] FIX: #8139 --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2806f2d06a0..3328bf49e67 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1625,7 +1625,7 @@ function left_menu($menu_array_before, $helppagename='', $notused='', $menu_arra 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"), 'maxwidth100', 'sall', 'M', 'searchleftuser', img_object('','user')); + $searchform.=printSearchForm(DOL_URL_ROOT.'/user/index.php', DOL_URL_ROOT.'/user/index.php', $langs->trans("Users"), 'maxwidth100', 'sall', 'M', 'searchleftuser', img_object('','user')); } } From 2e1727e323a7552f61e910bedb34302ff8020797 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 19 Feb 2018 17:45:19 +0100 Subject: [PATCH 010/125] Fix: Barcode type --- htdocs/barcode/codeinit.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index ebe121301b7..537f9d30a3f 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -1,5 +1,6 @@ + * 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 @@ -143,7 +144,7 @@ if ($action == 'initbarcodeproducts') $nextvalue=$modBarCodeProduct->getNextValue($productstatic,''); //print 'Set value '.$nextvalue.' to product '.$productstatic->id." ".$productstatic->ref." ".$productstatic->type."
\n"; - $result=$productstatic->setValueFrom('barcode', $nextvalue, '', '', 'date', '', $user, 'PRODUCT_MODIFY'); + $result=$productstatic->setValueFrom('barcode', $nextvalue, '', '', 'text', '', $user, 'PRODUCT_MODIFY'); $nbtry++; if ($result > 0) $nbok++; From 671b4a399dbdd2dc47cb20a18ae324b489a86309 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Mon, 19 Feb 2018 17:47:24 +0100 Subject: [PATCH 011/125] Fix: Barcode type --- htdocs/commande/class/commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0ea9302b221..c326efa7e49 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1360,8 +1360,8 @@ class Commande extends CommonOrder $this->line->vat_src_code=$vat_src_code; $this->line->tva_tx=$txtva; - $this->line->localtax1_tx=$txlocaltax1; - $this->line->localtax2_tx=$txlocaltax2; + $this->line->localtax1_tx=$localtaxes_type[1]; + $this->line->localtax2_tx=$localtaxes_type[3]; $this->line->localtax1_type=$localtaxes_type[0]; $this->line->localtax2_type=$localtaxes_type[2]; $this->line->fk_product=$fk_product; From a0078baeb6d3dbb8879a864974f612959be745bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 18:07:59 +0100 Subject: [PATCH 012/125] Fix webpage --- htdocs/website/index.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 55119ef418d..5afea1d8bb3 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -287,13 +287,16 @@ if ($action == 'addcontainer') // and $urltograbdirrootwithoutslash is https://www.dolimed.com // Check pageurl is not already used - $tmpwebsitepage = new WebsitePage($db); - $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); - if ($result > 0) + if ($pageurl) { - setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); - $error++; - $action='createcontainer'; + $tmpwebsitepage = new WebsitePage($db); + $result = $tmpwebsitepage->fetch(0, $object->id, $pageurl); + if ($result > 0) + { + setEventMessages($langs->trans("AliasPageAlreadyExists", $pageurl), null, 'errors'); + $error++; + $action='createcontainer'; + } } if (! $error) @@ -2003,7 +2006,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print $langs->trans('WEBSITE_PAGENAME'); print ''; - print ''; + print ''; print ''; print ''; From 576fda9c4a465c67f649261ff54bc0a5b24228aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 18:17:42 +0100 Subject: [PATCH 013/125] Sort --- htdocs/website/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5afea1d8bb3..d2ee6f0c6c9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1454,7 +1454,7 @@ if (count($object->records) > 0) { print ''; // Close current websitebar to open a new one - $array=$objectpage->fetchAll($object->id); + $array=$objectpage->fetchAll($object->id, 'ASC,ASC', 'type_container,pageurl'); if (! is_array($array) && $array < 0) dol_print_error('', $objectpage->error, $objectpage->errors); $atleastonepage=(is_array($array) && count($array) > 0); From 1ee128ff13b478252b2c2f0a030af78fdb994e77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 19:47:42 +0100 Subject: [PATCH 014/125] NEW Add type of website container/page into dictionary --- htdocs/admin/dict.php | 36 +++++------ htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formwebsite.class.php | 63 +++++++++++++++++++ .../mysql/data/llx_c_type_container.sql | 37 +++++++++++ .../install/mysql/migration/7.0.0-8.0.0.sql | 16 +++++ .../mysql/tables/llx_c_type_container.key.sql | 21 +++++++ .../mysql/tables/llx_c_type_container.sql | 36 +++++++++++ htdocs/langs/en_US/admin.lang | 1 + htdocs/website/index.php | 5 +- 9 files changed, 193 insertions(+), 24 deletions(-) create mode 100644 htdocs/install/mysql/data/llx_c_type_container.sql create mode 100644 htdocs/install/mysql/tables/llx_c_type_container.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_type_container.sql diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 438c7cd5227..fbb0b5f38c5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -93,7 +93,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,25,0); // Name of SQL tables of dictionaries $tabname=array(); @@ -121,7 +121,7 @@ $tabname[21]= MAIN_DB_PREFIX."c_availability"; $tabname[22]= MAIN_DB_PREFIX."c_input_reason"; $tabname[23]= MAIN_DB_PREFIX."c_revenuestamp"; $tabname[24]= MAIN_DB_PREFIX."c_type_resource"; -//$tabname[25]= MAIN_DB_PREFIX."c_email_templates"; +$tabname[25]= MAIN_DB_PREFIX."c_type_container"; $tabname[26]= MAIN_DB_PREFIX."c_units"; $tabname[27]= MAIN_DB_PREFIX."c_stcomm"; $tabname[28]= MAIN_DB_PREFIX."c_holiday_types"; @@ -160,7 +160,7 @@ $tablib[21]= "DictionaryAvailability"; $tablib[22]= "DictionarySource"; $tablib[23]= "DictionaryRevenueStamp"; $tablib[24]= "DictionaryResourceType"; -//$tablib[25]= "DictionaryEMailTemplates"; +$tablib[25]= "DictionaryTypeOfContainer"; $tablib[26]= "DictionaryUnits"; $tablib[27]= "DictionaryProspectStatus"; $tablib[28]= "DictionaryHolidayTypes"; @@ -199,7 +199,7 @@ $tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason"; $tabsql[23]= "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as country, c.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid"; $tabsql[24]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource"; -//$tabsql[25]= "SELECT rowid as rowid, label, type_template, private, position, topic, content_lines, content, active FROM ".MAIN_DB_PREFIX."c_email_templates WHERE entity IN (".getEntity('email_template').")"; +$tabsql[25]= "SELECT rowid as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")"; $tabsql[26]= "SELECT rowid as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units"; $tabsql[27]= "SELECT id as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm"; $tabsql[28]= "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid"; @@ -237,8 +237,8 @@ $tabsqlsort[20]="code ASC, libelle ASC"; $tabsqlsort[21]="code ASC, label ASC"; $tabsqlsort[22]="code ASC, label ASC"; $tabsqlsort[23]="country ASC, taux ASC"; -$tabsqlsort[24]="code ASC,label ASC"; -//$tabsqlsort[25]="label ASC"; +$tabsqlsort[24]="code ASC, label ASC"; +$tabsqlsort[25]="t.module ASC, t.code ASC, t.label ASC"; $tabsqlsort[26]="code ASC"; $tabsqlsort[27]="code ASC"; $tabsqlsort[28]="country ASC, code ASC"; @@ -277,7 +277,7 @@ $tabfield[21]= "code,label"; $tabfield[22]= "code,label"; $tabfield[23]= "country_id,country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfield[24]= "code,label"; -//$tabfield[25]= "label,type_template,private,position,topic,content_lines,content"; +$tabfield[25]= "code,label"; $tabfield[26]= "code,label,short_label"; $tabfield[27]= "code,libelle"; $tabfield[28]= "code,label,affect,delay,newbymonth,country_id,country"; @@ -316,7 +316,7 @@ $tabfieldvalue[21]= "code,label"; $tabfieldvalue[22]= "code,label"; $tabfieldvalue[23]= "country,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldvalue[24]= "code,label"; -//$tabfieldvalue[25]= "label,type_template,private,position,topic,content_lines,content"; +$tabfieldvalue[25]= "code,label"; $tabfieldvalue[26]= "code,label,short_label"; $tabfieldvalue[27]= "code,libelle"; $tabfieldvalue[28]= "code,label,affect,delay,newbymonth,country"; @@ -355,7 +355,7 @@ $tabfieldinsert[21]= "code,label"; $tabfieldinsert[22]= "code,label"; $tabfieldinsert[23]= "fk_pays,taux,revenuestamp_type,accountancy_code_sell,accountancy_code_buy,note"; $tabfieldinsert[24]= "code,label"; -//$tabfieldinsert[25]= "label,type_template,private,position,topic,content_lines,content,entity"; +$tabfieldinsert[25]= "code,label"; $tabfieldinsert[26]= "code,label,short_label"; $tabfieldinsert[27]= "code,libelle"; $tabfieldinsert[28]= "code,label,affect,delay,newbymonth,fk_country"; @@ -396,7 +396,7 @@ $tabrowid[21]= "rowid"; $tabrowid[22]= "rowid"; $tabrowid[23]= ""; $tabrowid[24]= ""; -//$tabrowid[25]= ""; +$tabrowid[25]= ""; $tabrowid[26]= ""; $tabrowid[27]= "id"; $tabrowid[28]= ""; @@ -435,7 +435,7 @@ $tabcond[21]= ! empty($conf->propal->enabled); $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabled)); $tabcond[23]= true; $tabcond[24]= ! empty($conf->resource->enabled); -//$tabcond[25]= true; // && ! empty($conf->global->MAIN_EMAIL_EDIT_TEMPLATE_FROM_DIC); +$tabcond[25]= ! empty($conf->website->enabled); $tabcond[26]= ! empty($conf->product->enabled); $tabcond[27]= ! empty($conf->societe->enabled); $tabcond[28]= ! empty($conf->holiday->enabled); @@ -474,7 +474,7 @@ $tabhelp[21] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[22] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[23] = array('revenuestamp_type'=>'FixedOfPercent'); $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode")); -//$tabhelp[25] = array('topic'=>$langs->trans('SeeSubstitutionVars'),'content'=>$langs->trans('SeeSubstitutionVars'),'content_lines'=>$langs->trans('SeeSubstitutionVars'),'type_template'=>$langs->trans("TemplateForElement"),'private'=>$langs->trans("TemplateIsVisibleByOwnerOnly"), 'position'=>$langs->trans("PositionIntoComboList")); +$tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode')); $tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"),'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically")); @@ -513,7 +513,7 @@ $tabfieldcheck[21] = array(); $tabfieldcheck[22] = array(); $tabfieldcheck[23] = array(); $tabfieldcheck[24] = array(); -//$tabfieldcheck[25] = array(); +$tabfieldcheck[25] = array(); $tabfieldcheck[26] = array(); $tabfieldcheck[27] = array(); $tabfieldcheck[28] = array(); @@ -1072,8 +1072,7 @@ if ($id) if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); $class='width100'; } if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { - if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - else $valuetoshow=$langs->trans("Label"); + $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); } if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); @@ -1298,12 +1297,7 @@ if ($id) if ($fieldlist[$field]=='type') { $valuetoshow=$langs->trans("Type"); } if ($fieldlist[$field]=='code') { $valuetoshow=$langs->trans("Code"); } if ($fieldlist[$field]=='position') { $align='right'; } - if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') - { - //if ($id != 25) $valuetoshow=$form->textwithtooltip($langs->trans("Label"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); - //else $valuetoshow=$langs->trans("Label"); - $valuetoshow=$langs->trans("Label"); - } + if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label"); } if ($fieldlist[$field]=='libelle_facture') { //$valuetoshow=$form->textwithtooltip($langs->trans("LabelOnDocuments"), $langs->trans("LabelUsedByDefault"),2,1,img_help(1,'')); $valuetoshow=$langs->trans("LabelOnDocuments"); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index af9bd644caf..3339b2b054e 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1184,7 +1184,7 @@ class FormOther /** - * Return a HTML select list of bank accounts + * Return a HTML select list of a dictionary * * @param string $htmlname Name of select zone * @param string $dictionarytable Dictionary table diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 6981ecc343f..4f92b2e9449 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -95,4 +95,67 @@ class FormWebsite return $out; } + + /** + * Return a HTML select list of a dictionary + * + * @param string $htmlname Name of select zone + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function selectTypeOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='') + { + global $langs, $conf, $user; + + $langs->load("admin"); + + $sql = "SELECT rowid, code, label, entity"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; + $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; + $sql.= " ORDER BY label"; + + dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; + if ($num) + { + print '"; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + } + else + { + print $langs->trans("NoTypeOfPagePleaseEditDictionary"); + } + } + else { + dol_print_error($this->db); + } + } + } diff --git a/htdocs/install/mysql/data/llx_c_type_container.sql b/htdocs/install/mysql/data/llx_c_type_container.sql new file mode 100644 index 00000000000..1e915412a12 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_type_container.sql @@ -0,0 +1,37 @@ +-- Copyright (C) 2001-2004 Rodolphe Quiedeville +-- Copyright (C) 2003 Jean-Louis Bergamo +-- Copyright (C) 2004-2009 Laurent Destailleur +-- Copyright (C) 2004 Benoit Mortier +-- Copyright (C) 2004 Guillaume Delecourt +-- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2007 Patrick Raguin +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- + +-- +-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors +-- de l'install et tous les sigles '--' sont supprimés. +-- + +-- +-- Type of website page/container +-- + +insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); + diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 9bfe0bd2915..014f2d5eeff 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -35,3 +35,19 @@ ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; ALTER TABLE llx_societe ADD COLUMN order_min_amount double(24,8) DEFAULT NULL AFTER outstanding_limit; ALTER TABLE llx_societe ADD COLUMN supplier_order_min_amount double(24,8) DEFAULT NULL AFTER order_min_amount; + +create table llx_c_type_container +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + label varchar(64) NOT NULL, + module varchar(32) NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; + +ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); + + + + diff --git a/htdocs/install/mysql/tables/llx_c_type_container.key.sql b/htdocs/install/mysql/tables/llx_c_type_container.key.sql new file mode 100644 index 00000000000..7a81f352f63 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_container.key.sql @@ -0,0 +1,21 @@ +-- ======================================================================== +-- Copyright (C) 2018 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + + +ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); + diff --git a/htdocs/install/mysql/tables/llx_c_type_container.sql b/htdocs/install/mysql/tables/llx_c_type_container.sql new file mode 100644 index 00000000000..33be89a67f4 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_type_container.sql @@ -0,0 +1,36 @@ +-- ======================================================================== +-- Copyright (C) 2018 Laurent Destailleur +-- +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- Defini les types de contact d'un element sert de reference pour +-- la table llx_element_contact +-- +-- element est le nom de la table utilisant le type de contact. +-- i.e. contact, facture, projet, societe (sans le llx_ devant). +-- Libelle est un texte decrivant le type de contact. +-- active precise si cette valeur est 'active' ou 'archive'. +-- +-- ======================================================================== + +create table llx_c_type_container +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(32) NOT NULL, + entity integer DEFAULT 1 NOT NULL, -- multi company id + label varchar(64) NOT NULL, + module varchar(32) NULL, + active tinyint DEFAULT 1 NOT NULL +)ENGINE=innodb; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 537da9bdb0b..91a503ba6a6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -885,6 +885,7 @@ DictionaryRevenueStamp=Amount of revenue stamps DictionaryPaymentConditions=Payment terms DictionaryPaymentModes=Payment modes DictionaryTypeContact=Contact/Address types +DictionaryTypeOfContainer=Type of website pages/containers DictionaryEcotaxe=Ecotax (WEEE) DictionaryPaperFormat=Paper formats DictionaryFormatCards=Cards formats diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d2ee6f0c6c9..77edf7728c3 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; @@ -1245,6 +1246,7 @@ if (GETPOST('exportsite','alpha')) $form = new Form($db); $formadmin = new FormAdmin($db); $formwebsite = new FormWebsite($db); +$formother = new FormOther($db); $help_url=''; @@ -1999,8 +2001,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; print $langs->trans('WEBSITE_TYPE_CONTAINER'); print ''; - $arrayoftype=array('page'=>$langs->trans("Page"), 'banner'=>$langs->trans("Banner"), 'blogpost'=>$langs->trans("BlogPost"), 'other'=>$langs->trans("Other")); - print $form->selectarray('WEBSITE_TYPE_CONTAINER', $arrayoftype, $type_container); + print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER')?GETPOST('WEBSITE_TYPE_CONTAINER'):'page')); print ''; print ''; From 31d0679876fc3b1952b00922cd19d3b0c7f724f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 19:52:51 +0100 Subject: [PATCH 015/125] Add data --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 014f2d5eeff..a0ec8f58e37 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -48,6 +48,11 @@ create table llx_c_type_container ALTER TABLE llx_c_type_container ADD UNIQUE INDEX uk_c_type_container_id (code, entity); +insert into llx_c_type_container (code,label,module,active) values ('page', 'Page', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('banner', 'Banner', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('blogpost', 'BlogPost', 'system', 1); +insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); + From 3eef9fd57a300540b1eca48a275e4e88cade3906 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 21:31:03 +0100 Subject: [PATCH 016/125] Fix doc --- htdocs/langs/en_US/website.lang | 7 +++--- htdocs/website/index.php | 40 +++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index df799470b6d..035d0661c95 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -34,9 +34,10 @@ ViewPageInNewTab=View page in new tab SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs -SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on %s
then enter here the virtual hostname you have created, so the preview can be done also using this direct web server access, and not only using Dolibarr server. -PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s -PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. +SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on
%s
then enter here the virtual hostname you have created, so the preview can be done also using this dedicated web server access instead of only using Dolibarr server. +CheckVirtualHostPerms=Check also that virtual host has read access on files into
%s +PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s +PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined NoPageYet=No pages yet SyntaxHelp=Help on specific syntax tips diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 77edf7728c3..1b4bd000e38 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1413,29 +1413,37 @@ if (count($object->records) > 0) if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone') { - print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot), 1, 'preview'); + $urlext=$virtualurl; + $urlint=$urlwithroot.'/public/website/index.php?website='.$website; + + $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + print '
'; + print $form->textwithpicto('', $htmltext, 1, 'preview'); print ''; print '
'; print ''; //print ''; - $htmltext=$langs->trans("SetHereVirtualHost", $dataroot); + $htmltext =$langs->trans("SetHereVirtualHost", $dataroot); + $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print '
'; - $urlext=$virtualurl; - $urlint=$urlwithroot.'/public/website/index.php?website='.$website; if (empty($object->fk_default_home)) { + $htmltext = ''.$langs->trans("YouMustDefineTheHomePage").'
'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); + $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', ''.$langs->trans("YouMustDefineTheHomePage").'
'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print '
'; } else { + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); + $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print ''; } } @@ -1585,8 +1593,11 @@ if (count($object->records) > 0) $realpage=$urlwithroot.'/public/website/index.php?website='.$website.'&pageref='.$websitepage->pageurl; $pagealias = $websitepage->pageurl; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot), 1, 'preview'); + $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + + print '
'; + print $form->textwithpicto('', $htmltext, 1, 'preview'); print ''; // View page in new Tab print '
'; @@ -1597,8 +1608,11 @@ if (count($object->records) > 0) $urlext=$virtualurl.'/'.$pagealias.'.php'; $urlint=$urlwithroot.'/public/website/index.php?website='.$website; - print 'transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $urlext)).'">'; - print $form->textwithpicto('', $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''), 1, 'preview_ext'); + + $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $dataroot, $virtualurl?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); + + print ''; + print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print ''; //print ''; @@ -1884,7 +1898,9 @@ if ($action == 'createsite') print ''; print ''; - print $form->textwithpicto($langs->trans('Virtualhost'), $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref'), 1, 'help', '', 0, 2, 'tooltipvirtual'); + $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref'); + $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'tooltipvirtual'); print ''; print ''; print ''; From bfbe03d55d9f7e736bdb099f23e38944e14b93f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 21:57:30 +0100 Subject: [PATCH 017/125] Fix tooltip doc --- htdocs/langs/en_US/website.lang | 4 +++- htdocs/website/index.php | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 035d0661c95..6e67062b859 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -35,7 +35,9 @@ SetAsHomePage=Set as Home page RealURL=Real URL ViewWebsiteInProduction=View web site using home URLs SetHereVirtualHost=If you can create, on your web server (Apache, Nginx, ...), a dedicated Virtual Host with PHP enabled and a Root directory on
%s
then enter here the virtual hostname you have created, so the preview can be done also using this dedicated web server access instead of only using Dolibarr server. -CheckVirtualHostPerms=Check also that virtual host has read access on files into
%s +CheckVirtualHostPerms=Check also that virtual host has %s on files into
%s +ReadPerm=Read permission +WritePerm=Write permission PreviewSiteServedByWebServer=Preview %s in a new tab.

The %s will be served by an external web server (like Apache, Nginx, IIS). You must install and setup this server before to point to directory:
%s
URL served by external server:
%s PreviewSiteServedByDolibarr=Preview %s in a new tab.

The %s will be served by Dolibarr server so it does not need any extra web server (like Apache, Nginx, IIS) to be installed.
The inconvenient is that URL of pages are not user friendly and start with path of your Dolibarr.
URL served by Dolibarr:
%s

To use your own external web server to serve this web site, create a virtual host on your web server that point on directory
%s
then enter the name of this virtual server and click on the other preview button. VirtualHostUrlNotDefined=URL of the virtual host served by external web server not defined diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1b4bd000e38..84d2c19b9de 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1417,7 +1417,8 @@ if (count($object->records) > 0) $urlint=$urlwithroot.'/public/website/index.php?website='.$website; $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $urlint, $dataroot); - $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print ''; print $form->textwithpicto('', $htmltext, 1, 'preview'); print ''; @@ -1426,14 +1427,18 @@ if (count($object->records) > 0) print ''; //print ''; $htmltext =$langs->trans("SetHereVirtualHost", $dataroot); - $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print $form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helpvirtualhost'); print '
'; if (empty($object->fk_default_home)) { $htmltext = ''.$langs->trans("YouMustDefineTheHomePage").'
'.$langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); - $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print ''; @@ -1441,7 +1446,9 @@ if (count($object->records) > 0) else { $htmltext = $langs->trans("PreviewSiteServedByWebServer", $langs->transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext?$urlext:''.$langs->trans("VirtualHostUrlNotDefined").''); - $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print 'transnoentitiesnoconv("Site"), $langs->transnoentitiesnoconv("Site"), $dataroot, $urlext)).'">'; print $form->textwithpicto('', $htmltext, 1, 'preview_ext'); print ''; @@ -1594,7 +1601,8 @@ if (count($object->records) > 0) $pagealias = $websitepage->pageurl; $htmltext = $langs->trans("PreviewSiteServedByDolibarr", $langs->transnoentitiesnoconv("Page"), $langs->transnoentitiesnoconv("Page"), $realpage, $dataroot); - $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); print ''; print $form->textwithpicto('', $htmltext, 1, 'preview'); @@ -1899,7 +1907,10 @@ if ($action == 'createsite') print ''; $htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/websiteref'); - $htmltext.='

'.$langs->trans("CheckVirtualHostPerms", DOL_DOCUMENT_ROOT); + $htmltext.='
'; + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT); + $htmltext.='
'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), DOL_DATA_ROOT); + print $form->textwithpicto($langs->trans('Virtualhost'), $htmltext, 1, 'help', '', 0, 2, 'tooltipvirtual'); print ''; print ''; From 1f412bd1d487ad7e22041ed75a3b2778b7eb0b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 22:10:15 +0100 Subject: [PATCH 018/125] Fix infinite redirects --- htdocs/core/lib/website.lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index dbd3acd794a..c8e59c4e6af 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -184,7 +184,23 @@ function redirectToContainer($containeralias) unset($tmpwebsitepage); if ($result > 0) { - $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $_SERVER["REQUEST_URI"]); + $currenturi = $_SERVER["REQUEST_URI"]; + if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) + { + if ($regtmp[0] == $containeralias) + { + print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containeralias."' in web site '".$website->ref."'"; + exit; + } + else + { + $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $currenturi); + } + } + else + { + $newurl = $currenturi.'&pageref='.urlencode($containeralias); + } } } else // When page called from virtual host server @@ -199,7 +215,7 @@ function redirectToContainer($containeralias) } else { - print "Error, page contains a reditect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; + print "Error, page contains a redirect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; exit; } } From 1cb58a308c0de687982e71f16a9f789dba02150f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 22:25:12 +0100 Subject: [PATCH 019/125] Fix redirect --- htdocs/core/lib/website.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index c8e59c4e6af..b4475d5f907 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -205,7 +205,7 @@ function redirectToContainer($containeralias) } else // When page called from virtual host server { - $newurl = '/'.$containeralias; + $newurl = '/'.$containeralias.'.php'; } if ($newurl) From 5ada5c18f91a2a287019229da81d29594e6363bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 23:19:54 +0100 Subject: [PATCH 020/125] url in generator --- htdocs/core/lib/website.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index b4475d5f907..ac1016af7b8 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -515,7 +515,7 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; - $tplcontent.= ''."\n"; + $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; $tplcontent.= ''."\n"; From 9230c6757b7bdcc233aceecfc3c793ceaff925b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 23:31:35 +0100 Subject: [PATCH 021/125] Fix error when removing dir with some subdirs --- htdocs/ecm/dir_card.php | 27 ++++++++++++++++++--------- htdocs/langs/en_US/ecm.lang | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index e313787b01f..e2b031305d9 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -160,23 +160,28 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') { // Fetch was already done $result=$ecmdir->delete($user); + if ($result <= 0) + { + $langs->load('errors'); + setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors'); + } } else { - $resbool = dol_delete_dir($upload_dir); + $resbool = dol_delete_dir($upload_dir, 1); if ($resbool) $result = 1; - else $result = 0; + else + { + $langs->load('errors'); + setEventMessages($langs->trans("ErrorFailToDeleteDir", $upload_dir), null, 'errors'); + $result = 0; + } } if ($result > 0) { header("Location: ".$backtourl); exit; } - else - { - $langs->load('errors'); - setEventMessages($langs->trans($ecmdir->error,$ecmdir->label), null, 'errors'); - } } // Update dirname or description @@ -281,6 +286,7 @@ if ($module == 'ecm') llxHeader(); // Built the file List +$filearrayall=dol_dir_list($upload_dir,"all",0,'','',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $totalsize=0; foreach($filearray as $key => $file) @@ -469,7 +475,7 @@ if ($action != 'edit' && $action != 'delete') print '
'.$langs->trans('ECMAddSection').''; } - if (count($filearray) == 0) + if (count($filearrayall) == 0) { if ($permtoadd) { @@ -482,7 +488,10 @@ if ($action != 'edit' && $action != 'delete') } else { - print ''.$langs->trans('Delete').''; + if (count($filearray) > 0) + print ''.$langs->trans('Delete').''; + else + print ''.$langs->trans('Delete').''; } print ''; } diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index fe5600004ed..588044f18df 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -39,6 +39,7 @@ ShowECMSection=Show directory DeleteSection=Remove directory ConfirmDeleteSection=Can you confirm you want to delete the directory %s? ECMDirectoryForFiles=Relative directory for files +CannotRemoveDirectoryContainsFilesOrDirs=Removed not possible because it contains some files or sub-directories CannotRemoveDirectoryContainsFiles=Removed not possible because it contains some files ECMFileManager=File manager ECMSelectASection=Select a directory in the tree... From 5f51af505f698e4bb5a75d1e3fd4be1c2e9a4af8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 23:52:45 +0100 Subject: [PATCH 022/125] NEW Can delete dir content in media and ECM module recursively --- htdocs/core/class/html.form.class.php | 2 +- htdocs/ecm/class/ecmdirectory.class.php | 18 ++++++++++---- htdocs/ecm/dir_card.php | 33 +++++++++++++++++++------ htdocs/langs/en_US/other.lang | 2 ++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4e8f67d6552..ba0ea7a37c2 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3652,7 +3652,7 @@ class Form $more.=''; $more.=''.$input['label'].' '; $more.='0 if OK + * @param User $user User that delete + * @param string $mode 'all'=delete all, 'databaseonly'=only database entry, 'fileonly' (not implemented) + * @param int $deletedirrecursive 1=Agree to delete content recursiveley (otherwise an error will be returned when trying to delete) + * @return int <0 if KO, >0 if OK */ - function delete($user, $mode='all') + function delete($user, $mode='all', $deletedirrecursive=0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -368,7 +369,14 @@ class EcmDirectory // extends CommonObject if ($mode != 'databaseonly') { $file = $conf->ecm->dir_output . "/" . $relativepath; - $result=@dol_delete_dir($file); + if ($deletedirrecursive) + { + $result=@dol_delete_dir_recursive($file, 0, 0); + } + else + { + $result=@dol_delete_dir($file, 0); + } } if ($result || ! @is_dir(dol_osencode($file))) diff --git a/htdocs/ecm/dir_card.php b/htdocs/ecm/dir_card.php index e2b031305d9..14f0ee18e8c 100644 --- a/htdocs/ecm/dir_card.php +++ b/htdocs/ecm/dir_card.php @@ -156,10 +156,12 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') $backtourl = DOL_URL_ROOT."/ecm/index.php"; if ($module == 'medias') $backtourl = DOL_URL_ROOT."/website/index.php?file_manager=1"; + $deletedirrecursive = (GETPOST('deletedirrecursive','alpha') == 'on' ? 1 : 0); + if ($module == 'ecm') { // Fetch was already done - $result=$ecmdir->delete($user); + $result=$ecmdir->delete($user, 'all', $deletedirrecursive); if ($result <= 0) { $langs->load('errors'); @@ -168,7 +170,14 @@ if ($action == 'confirm_deletedir' && $confirm == 'yes') } else { - $resbool = dol_delete_dir($upload_dir, 1); + if ($deletedirrecursive) + { + $resbool = dol_delete_dir_recursive($upload_dir, 0, 1); + } + else + { + $resbool = dol_delete_dir($upload_dir, 1); + } if ($resbool) $result = 1; else { @@ -475,8 +484,8 @@ if ($action != 'edit' && $action != 'delete') print ''.$langs->trans('ECMAddSection').''; } - if (count($filearrayall) == 0) - { + //if (count($filearrayall) == 0) + //{ if ($permtoadd) { print ''.$langs->trans('Delete').''; @@ -485,14 +494,14 @@ if ($action != 'edit' && $action != 'delete') { print ''.$langs->trans('Delete').''; } - } + /*} else { if (count($filearray) > 0) print ''.$langs->trans('Delete').''; else print ''.$langs->trans('Delete').''; - } + }*/ print ''; } @@ -506,7 +515,17 @@ if ($action == 'delete') if ($action == 'delete_dir') { $relativepathwithoutslash=preg_replace('/[\/]$/','',$relativepath); - print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', '', 1, 1); + + //Form to close proposal (signed or not) + if (count($filearrayall) > 0) + { + $langs->load("other"); + $formquestion = array( + array('type' => 'checkbox', 'name' => 'deletedirrecursive', 'label' => $langs->trans("ContentOfDirectoryIsNotEmpty").'
'.$langs->trans("DeleteAlsoContentRecursively"),'value' => '0') // Field to complete private note (not replace) + ); + } + + print $form->formconfirm($_SERVER["PHP_SELF"].'?section='.GETPOST('section','alpha').($module?'&module='.$module:''), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$relativepathwithoutslash), 'confirm_deletedir', $formquestion, 1, 1); } diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 1585504479e..c4cb693716d 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -22,6 +22,8 @@ JumpToLogin=Disconnected. Go to login page... MessageForm=Message on online payment form MessageOK=Message on validated payment return page MessageKO=Message on canceled payment return page +ContentOfDirectoryIsNotEmpty=Content of this directory is not empty. +DeleteAlsoContentRecursively=Check to delete all content recursiveley YearOfInvoice=Year of invoice date PreviousYearOfInvoice=Previous year of invoice date From 6ef3b330e45b1370566889b1874e997f7033522d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 00:04:43 +0100 Subject: [PATCH 023/125] Fix output dir of grab --- htdocs/core/lib/website.lib.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index ac1016af7b8..b4c542edf9c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -289,11 +289,14 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $error=0; + dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); + $alreadygrabbed=array(); if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 + // Search X in "img...src=X" preg_match_all('/]*)>/i', $tmp, $regs); foreach ($regs[0] as $key => $val) @@ -388,16 +391,20 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } $linkwithoutdomain = $regs[2][$key]; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + + $dirforimages = '/'.$objectpage->pageurl; + if ($grabimagesinto == 'root') $dirforimages=''; + + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); From 0a00bdcb7319d929eb54e5d7aa5f81a4fe663147 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 05:45:42 +0100 Subject: [PATCH 024/125] FIX Search criteria on vat --- htdocs/accountancy/customer/lines.php | 43 ++++++++----------- htdocs/accountancy/expensereport/lines.php | 48 +++++++++------------ htdocs/accountancy/supplier/lines.php | 50 +++++++++------------- 3 files changed, 58 insertions(+), 83 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2d197de8c9f..c4c3d03ee97 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -113,7 +113,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; + $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); @@ -204,7 +204,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("fd.tva_tx", $search_vat); + $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -223,7 +223,7 @@ if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= natural_search("s.tva_intra", $search_tva_intra); + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -245,28 +245,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; - + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '
' . "\n"; print ''; @@ -370,7 +361,7 @@ if ($result) { print ''; print ''; - print '' . $objp->country .''; + print '' . $objp->country .''; print '' . $objp->tva_intra . ''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index df039bf4093..5c7347403d9 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -61,10 +61,10 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; +$offset = $limit * $page; if (! $sortfield) $sortfield = "erd.date, erd.rowid"; if (! $sortorder) { @@ -170,19 +170,19 @@ if (strlen(trim($search_expensereport))) { $sql .= " AND er.ref like '%" . $search_expensereport . "%'"; } if (strlen(trim($search_label))) { - $sql .= " AND f.label like '%" . $search_label . "%'"; + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= " AND er.comments like '%" . $search_desc . "%'"; + $sql .= natural_search("er.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= " AND erd.total_ht like '%" . $search_amount . "%'"; + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= " AND aa.account_number like '%" . $search_account . "%'"; + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; + $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -219,25 +219,18 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_expensereport) - $param .= "&search_expensereport=" . $search_expensereport; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_expensereport) $param .= "&search_expensereport=" . urlencode($search_expensereport); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '' . "\n"; print ''; @@ -297,7 +290,6 @@ if ($result) { $expensereport_static = new ExpenseReport($db); - $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label; @@ -347,7 +339,7 @@ if ($result) { print '
'; } else { - print $db->error(); + print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index b8b1ed9206d..af9d82e5056 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -65,8 +65,8 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) @@ -195,10 +195,10 @@ if (strlen(trim($search_amount))) { $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account, 1); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -214,10 +214,10 @@ else if ($search_year > 0) $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } if (strlen(trim($search_country))) { - $sql .= " AND (co.label like'" . $search_country . "%')"; + $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')"; + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy @@ -241,27 +241,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '
' . "\n"; print ''; @@ -277,7 +269,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 1); print '
'; $moreforfilter = ''; @@ -389,7 +381,7 @@ if ($result) { print '
'; } else { - print $db->error(); + print $db->lasterror(); } From eb0073c33015835bf6dffc5e43fa07feeb29e0ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 05:53:53 +0100 Subject: [PATCH 025/125] Fix upgrade missing steps --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 11 +++++++++++ htdocs/install/upgrade2.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 4ffe73ac6ea..6e9e480cdb0 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -684,3 +684,14 @@ ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL; ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); + +create table llx_facture_rec_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + + +ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d20357dd20c..560bf3d2593 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3977,7 +3977,7 @@ function migrate_reset_blocked_log($db,$langs,$conf) } else { - print ' - '.$langs->trans('AlreadyInV7'); + print ' - '.$langs->trans('AlreadyInV7').'
'; } } else From cb644665bd4199164e7e7bc8d2a0d698e00f89d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 00:04:43 +0100 Subject: [PATCH 026/125] Fix output dir of grab --- htdocs/core/lib/website.lib.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 8a7e14f8b0d..81031d5e49c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -230,11 +230,14 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify $error=0; + dol_syslog("Call getAllImages with grabimagesinto=".$grabimagesinto); + $alreadygrabbed=array(); if (preg_match('/\/$/', $urltograb)) $urltograb.='.'; $urltograb = dirname($urltograb); // So urltograb is now http://www.nltechno.com or http://www.nltechno.com/dir1 + // Search X in "img...src=X" preg_match_all('/]*)>/i', $tmp, $regs); foreach ($regs[0] as $key => $val) @@ -323,16 +326,20 @@ function getAllImages($object, $objectpage, $urltograb, &$tmp, &$action, $modify } $linkwithoutdomain = $regs[2][$key]; - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; + + $dirforimages = '/'.$objectpage->pageurl; + if ($grabimagesinto == 'root') $dirforimages=''; + + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $regs[2][$key])?'':'/').$regs[2][$key]; if (preg_match('/^http/', $regs[2][$key])) { $urltograbbis = $regs[2][$key]; $linkwithoutdomain = preg_replace('/^https?:\/\/[^\/]+\//i', '', $regs[2][$key]); - $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filetosave = $conf->medias->multidir_output[$conf->entity].'/image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; } - $filename = 'image/'.$object->ref.'/'.$objectpage->pageurl.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; + $filename = 'image/'.$object->ref.$dirforimages.(preg_match('/^\//', $linkwithoutdomain)?'':'/').$linkwithoutdomain; // Clean the aa/bb/../cc into aa/cc $filetosave = preg_replace('/\/[^\/]+\/\.\./', '', $filetosave); From aa1ede6f742c18510e4315aafcd3df97308b7857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 05:45:42 +0100 Subject: [PATCH 027/125] FIX Search criteria on vat --- htdocs/accountancy/customer/lines.php | 43 ++++++++----------- htdocs/accountancy/expensereport/lines.php | 48 +++++++++------------ htdocs/accountancy/supplier/lines.php | 50 +++++++++------------- 3 files changed, 58 insertions(+), 83 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 2d197de8c9f..c4c3d03ee97 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -113,7 +113,7 @@ if (is_array($changeaccount) && count($changeaccount) > 0) { $db->begin(); $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as l"; - $sql1 .= " SET l.fk_code_ventilation=" . $account_parent; + $sql1 .= " SET l.fk_code_ventilation=" . GETPOST('account_parent','int'); $sql1 .= ' WHERE l.rowid IN (' . implode(',', $changeaccount) . ')'; dol_syslog('accountancy/customer/lines.php::changeaccount sql= ' . $sql1); @@ -204,7 +204,7 @@ if (strlen(trim($search_account))) { $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("fd.tva_tx", $search_vat); + $sql .= natural_search("fd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -223,7 +223,7 @@ if (strlen(trim($search_country))) { $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= natural_search("s.tva_intra", $search_tva_intra); + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture', 0) . ")"; // We don't share object for accountancy $sql .= $db->order($sortfield, $sortorder); @@ -245,28 +245,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; - + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '
' . "\n"; print ''; @@ -370,7 +361,7 @@ if ($result) { print ''; print ''; - print '' . $objp->country .''; + print '' . $objp->country .''; print '' . $objp->tva_intra . ''; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index df039bf4093..5c7347403d9 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -61,10 +61,10 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; $pageprev = $page - 1; $pagenext = $page + 1; +$offset = $limit * $page; if (! $sortfield) $sortfield = "erd.date, erd.rowid"; if (! $sortorder) { @@ -170,19 +170,19 @@ if (strlen(trim($search_expensereport))) { $sql .= " AND er.ref like '%" . $search_expensereport . "%'"; } if (strlen(trim($search_label))) { - $sql .= " AND f.label like '%" . $search_label . "%'"; + $sql .= natural_search("f.label", $search_label); } if (strlen(trim($search_desc))) { - $sql .= " AND er.comments like '%" . $search_desc . "%'"; + $sql .= natural_search("er.comments", $search_desc); } if (strlen(trim($search_amount))) { - $sql .= " AND erd.total_ht like '%" . $search_amount . "%'"; + $sql .= natural_search("erd.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= " AND aa.account_number like '%" . $search_account . "%'"; + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= " AND (erd.tva_tx like '" . $search_vat . "%')"; + $sql .= natural_search("erd.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -219,25 +219,18 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_expensereport) - $param .= "&search_expensereport=" . $search_expensereport; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_expensereport) $param .= "&search_expensereport=" . urlencode($search_expensereport); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '' . "\n"; print ''; @@ -297,7 +290,6 @@ if ($result) { $expensereport_static = new ExpenseReport($db); - $var = True; while ( $i < min($num_lines, $limit) ) { $objp = $db->fetch_object($result); $codeCompta = length_accountg($objp->account_number) . ' - ' . $objp->label; @@ -347,7 +339,7 @@ if ($result) { print '
'; } else { - print $db->error(); + print $db->lasterror(); } diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index b8b1ed9206d..af9d82e5056 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -65,8 +65,8 @@ $limit = GETPOST('limit','int')?GETPOST('limit', 'int'):(empty($conf->global->AC $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOST('page', 'int'); -if ($page < 0) $page = 0; -$offset = $conf->liste_limit * $page; +if (empty($page) || $page < 0) $page = 0; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortfield) @@ -195,10 +195,10 @@ if (strlen(trim($search_amount))) { $sql .= natural_search("l.total_ht", $search_amount, 1); } if (strlen(trim($search_account))) { - $sql .= natural_search("aa.account_number", $search_account, 1); + $sql .= natural_search("aa.account_number", $search_account); } if (strlen(trim($search_vat))) { - $sql .= natural_search("l.tva_tx", $search_vat, 1); + $sql .= natural_search("l.tva_tx", price2num($search_vat), 1); } if ($search_month > 0) { @@ -214,10 +214,10 @@ else if ($search_year > 0) $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,1,false))."' AND '".$db->idate(dol_get_last_day($search_year,12,false))."'"; } if (strlen(trim($search_country))) { - $sql .= " AND (co.label like'" . $search_country . "%')"; + $sql .= natural_search("co.label", $search_country); } if (strlen(trim($search_tvaintra))) { - $sql .= " AND (s.tva_intra like'" . $search_tvaintra . "%')"; + $sql .= natural_search("s.tva_intra", $search_tvaintra); } $sql .= " AND f.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy @@ -241,27 +241,19 @@ if ($result) { $i = 0; $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_invoice) - $param .= "&search_invoice=" . $search_invoice; - if ($search_ref) - $param .= "&search_ref=" . $search_ref; - if ($search_label) - $param .= "&search_label=" . $search_label; - if ($search_desc) - $param .= "&search_desc=" . $search_desc; - if ($search_account) - $param .= "&search_account=" . $search_account; - if ($search_vat) - $param .= "&search_vat=" . $search_vat; - if ($search_day) $param.='&search_day='.urlencode($search_day); - if ($search_month) $param.='&search_month='.urlencode($search_month); - if ($search_year) $param.='&search_year='.urlencode($search_year); - if ($search_country) - $param .= "&search_country=" . $search_country; - if ($search_tvaintra) - $param .= "&search_tvaintra=" . $search_tvaintra; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($search_invoice) $param .= "&search_invoice=" . urlencode($search_invoice); + if ($search_ref) $param .= "&search_ref=" . urlencode($search_ref); + if ($search_label) $param .= "&search_label=" . urlencode($search_label); + if ($search_desc) $param .= "&search_desc=" . urlencode($search_desc); + if ($search_account) $param .= "&search_account=" . urlencode($search_account); + if ($search_vat) $param .= "&search_vat=" . urlencode($search_vat); + if ($search_day) $param .= '&search_day='.urlencode($search_day); + if ($search_month) $param .= '&search_month='.urlencode($search_month); + if ($search_year) $param .= '&search_year='.urlencode($search_year); + if ($search_country) $param .= "&search_country=" . urlencode($search_country); + if ($search_tvaintra) $param .= "&search_tvaintra=" . urlencode($search_tvaintra); print '
' . "\n"; print ''; @@ -277,7 +269,7 @@ if ($result) { print $langs->trans("DescVentilDoneSupplier") . '
'; print '
' . $langs->trans("ChangeAccount") . '
'; - print $formaccounting->select_account(GETPOST('account_parent'), 'account_parent', 1); + print $formaccounting->select_account($account_parent, 'account_parent', 1); print '
'; $moreforfilter = ''; @@ -389,7 +381,7 @@ if ($result) { print '
'; } else { - print $db->error(); + print $db->lasterror(); } From 87a3019e73636b5a03fea19614e249b762e36650 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 05:53:53 +0100 Subject: [PATCH 028/125] Fix upgrade missing steps --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 11 +++++++++++ htdocs/install/upgrade2.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 4ffe73ac6ea..6e9e480cdb0 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -684,3 +684,14 @@ ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL; ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); + +create table llx_facture_rec_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + + +ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (fk_object); diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index d20357dd20c..560bf3d2593 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -3977,7 +3977,7 @@ function migrate_reset_blocked_log($db,$langs,$conf) } else { - print ' - '.$langs->trans('AlreadyInV7'); + print ' - '.$langs->trans('AlreadyInV7').'
'; } } else From 16fca2ee353d8b7d11f270db2b32c880e01f2ce7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 10:05:11 +0100 Subject: [PATCH 029/125] Fix bad link --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 01ea8d93de3..19612349214 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3257,7 +3257,7 @@ else if ($id > 0 || ! empty($ref)) // Invoice content - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; // Ref customer From 17c210ca98481134b7d9ac3b45e35d26224c673d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 11:16:13 +0100 Subject: [PATCH 030/125] Normalize links href to Dolibarr internal naming --- htdocs/website/index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 84d2c19b9de..959529eb44e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -527,6 +527,11 @@ if ($action == 'addcontainer') getAllImages($object, $objectpage, $urltograb, $tmp, $action, 1, $grabimages, $grabimagesinto); + // Normalize links href to Dolibarr internal naming + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2.php"', $tmp); + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2-\3.php"', $tmp); + $tmp = preg_replace('/a href="\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)\/([^\/"]+)"/', 'a href="/\1-\2-\3-\4.php"', $tmp); + //print dol_escape_htmltag($tmp);exit; $objectpage->content = $tmp; From ea071b768057993855dcdcccfbd5bdef7a81d6d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 12:31:26 +0100 Subject: [PATCH 031/125] Fix can't delete holiday refused --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 39edb577aec..b2dca7ca41b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1246,7 +1246,7 @@ else { print ''.$langs->trans("Validate").''; } - if ($user->rights->holiday->delete && $object->statut == 1) // If draft + if ($user->rights->holiday->delete && ($object->statut == 1 || $object->statut == 4 || $object->statut == 5) // If draft or canceled or refused { print ''.$langs->trans("DeleteCP").''; } From 4056b87a74cd8b9cf387b7d9c4622a0e51c909fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 12:36:03 +0100 Subject: [PATCH 032/125] Fix syntax error --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 069b5657aa1..be61223d704 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1246,7 +1246,7 @@ else { print ''.$langs->trans("Validate").''; } - if ($user->rights->holiday->delete && ($object->statut == 1 || $object->statut == 4 || $object->statut == 5) // If draft or canceled or refused + if ($user->rights->holiday->delete && ($object->statut == 1 || $object->statut == 4 || $object->statut == 5)) // If draft or canceled or refused { print ''.$langs->trans("DeleteCP").''; } From 346a0becac95403b643149534ab654eede388031 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 13:20:24 +0100 Subject: [PATCH 033/125] Propagate context --- htdocs/contrat/class/contrat.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 190de79aa17..12e08984411 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -279,6 +279,8 @@ class Contrat extends CommonObject // Open lines not already open if ($contratline->statut != 4) { + $contratline->context = $this->context; + $result = $contratline->active_line($user, $date_start, -1); if ($result < 0) { From 67ee443b34403ed101056922680136d782ae429a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 14:53:19 +0100 Subject: [PATCH 034/125] Fix can set holiday remaining to 0 --- htdocs/holiday/define_holiday.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 66e490ae420..87cb1920394 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -116,7 +116,7 @@ if (empty($reshook)) $userValue = $_POST['nb_holiday_'.$val['rowid']]; $userValue = $userValue[$userID]; - if (!empty($userValue)) + if (!empty($userValue) || (string) $userValue == '0') { $userValue = price2num($userValue,5); } else { @@ -172,11 +172,14 @@ $userstatic=new User($db); llxHeader('', $langs->trans('CPTitreMenu')); +$typeleaves=$holiday->getTypes(1,1); + + print '
'; if ($optioncss != '') print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -210,10 +213,8 @@ if (is_numeric($listUsers) && $listUsers < 0) setEventMessages($holiday->error, $holiday->errors, 'errors'); } -$var=true; $i = 0; -$typeleaves=$holiday->getTypes(1,1); if (count($typeleaves) == 0) { @@ -234,8 +235,6 @@ else $userchilds=$user->getAllChildIds(); } - print ''; - $moreforfilter=''; print '
'; From 276f2dce77f87252cfbf0da47db34fd011c96f00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 14:55:23 +0100 Subject: [PATCH 035/125] FIX #8200 --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index afc33f110cf..9a43c5b3cfa 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1919,7 +1919,7 @@ class Societe extends CommonObject if (! empty($this->code_fournisseur) && $this->fournisseur) $label.= '
' . $langs->trans('SupplierCode') . ': '. $this->code_fournisseur; if (! empty($conf->accounting->enabled) && $this->client) - $label.= '
' . $langs->trans('CustomerAccountancyCode') . ': '. $this->code_compta_client; + $label.= '
' . $langs->trans('CustomerAccountancyCode') . ': '. $this->code_compta; if (! empty($conf->accounting->enabled) && $this->fournisseur) $label.= '
' . $langs->trans('SupplierAccountancyCode') . ': '. $this->code_compta_fournisseur; From 522caa4cf0c64399d66c8fbf88aebce7e695fda7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 15:26:40 +0100 Subject: [PATCH 036/125] Merge #7989 --- .../class/accountancycategory.class.php | 402 +++++++++++++++--- 1 file changed, 336 insertions(+), 66 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 3e661958931..effae05da0f 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -28,27 +28,356 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; /** * Class to manage categories of an accounting account */ -class AccountancyCategory +class AccountancyCategory // extends CommonObject { - private $db; - public $error; - public $errors = array (); - public $element = 'accounting_category'; - public $table_element = 'c_accounting_category'; + public $db; //!< To store db handler + public $error; //!< To return error code (or message) + public $errors=array(); //!< To return several error codes (or messages) + public $element='c_accounting_category'; //!< Id that identify managed objects + public $table_element='c_accounting_category'; //!< Name of table without prefix where object is stored + public $id; + public $code; + public $label; + public $range_account; + public $sens; + public $category_type; + public $formula; + public $position; + public $fk_country; + public $active; + public $lines_cptbk; public $lines_display; public $sdc; + /** * Constructor * * @param DoliDB $db Database handler */ - public function __construct($db) { + public function __construct($db) + { $this->db = $db; } + + var $id; + var $code; + var $label; + var $range_account; + var $sens; + var $category_type; + var $formula; + var $position; + var $fk_country; + var $active; + + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->code)) $this->code=trim($this->code); + if (isset($this->label)) $this->label=trim($this->label); + if (isset($this->range_account)) $this->range_account=trim($this->range_account); + if (isset($this->sens)) $this->sens=trim($this->sens); + if (isset($this->category_type)) $this->category_type=trim($this->category_type); + if (isset($this->formula)) $this->formula=trim($this->formula); + if (isset($this->position)) $this->position=trim($this->position); + if (isset($this->fk_country)) $this->fk_country=trim($this->fk_country); + if (isset($this->active)) $this->active=trim($this->active); + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category("; + $sql.= "rowid,"; + $sql.= "code,"; + $sql.= "label,"; + $sql.= "range_account,"; + $sql.= "sens,"; + $sql.= "category_type,"; + $sql.= "formula,"; + $sql.= "position,"; + $sql.= "fk_country,"; + $sql.= "active"; + $sql.= ") VALUES ("; + $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->rowid."'").","; + $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; + $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; + $sql.= " ".(! isset($this->range_account)?'NULL':"'".$this->db->escape($this->range_account)."'").","; + $sql.= " ".(! isset($this->sens)?'NULL':"'".$this->sens."'").","; + $sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->category_type."'").","; + $sql.= " ".(! isset($this->formula)?'NULL':"'".$this->db->escape($this->formula)."'").","; + $sql.= " ".(! isset($this->position)?'NULL':"'".$this->position."'").","; + $sql.= " ".(! isset($this->fk_country)?'NULL':"'".$this->fk_country."'").","; + $sql.= " ".(! isset($this->active)?'NULL':"'".$this->active."'").""; + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_accounting_category"); + + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $label Label + * @return int <0 if KO, >0 if OK + */ + function fetch($id,$code='',$label='') + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.code,"; + $sql.= " t.label,"; + $sql.= " t.range_account,"; + $sql.= " t.sens,"; + $sql.= " t.category_type,"; + $sql.= " t.formula,"; + $sql.= " t.position,"; + $sql.= " t.fk_country,"; + $sql.= " t.active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_accounting_category as t"; + if ($id) $sql.= " WHERE t.rowid = ".$id; + elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'"; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->code = $obj->code; + $this->label = $obj->label; + $this->range_account = $obj->range_account; + $this->sens = $obj->sens; + $this->category_type = $obj->category_type; + $this->formula = $obj->formula; + $this->position = $obj->position; + $this->fk_country = $obj->fk_country; + $this->active = $obj->active; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user=null, $notrigger=0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->code)) $this->code=trim($this->code); + if (isset($this->label)) $this->label=trim($this->label); + if (isset($this->range_account)) $this->range_account=trim($this->range_account); + if (isset($this->sens)) $this->sens=trim($this->sens); + if (isset($this->category_type)) $this->category_type=trim($this->category_type); + if (isset($this->formula)) $this->formula=trim($this->formula); + if (isset($this->position)) $this->position=trim($this->position); + if (isset($this->fk_country)) $this->fk_country=trim($this->fk_country); + if (isset($this->active)) $this->active=trim($this->active); + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_accounting_category SET"; + $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; + $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " range_account=".(isset($this->range_account)?"'".$this->db->escape($this->range_account)."'":"null").","; + $sql.= " sens=".(isset($this->sens)?$this->sens:"null").","; + $sql.= " category_type=".(isset($this->category_type)?$this->category_type:"null").","; + $sql.= " formula=".(isset($this->formula)?"'".$this->db->escape($this->formula)."'":"null").","; + $sql.= " position=".(isset($this->position)?$this->position:"null").","; + $sql.= " fk_country=".(isset($this->fk_country)?$this->fk_country:"null").","; + $sql.= " active=".(isset($this->active)?$this->active:"null").""; + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger=0) + { + global $conf, $langs; + $error=0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_accounting_category"; + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + /** * Function to select all accounting accounts from an accounting category * @@ -443,65 +772,6 @@ class AccountancyCategory } - // calcule - - /* I try to replace this with dol_eval() - - const PATTERN = '/(?:\-?\d+(?:\.?\d+)?[\+\-\*\/])+\-?\d+(?:\.?\d+)?/'; - - const PARENTHESIS_DEPTH = 10; - - public function calculate($input) - { - global $langs; - - if(strpos($input, '+') != null || strpos($input, '-') != null || strpos($input, '/') != null || strpos($input, '*') != null){ - // Remove white spaces and invalid math chars - $input = str_replace($langs->trans("ThousandSeparator"), '', $input); - $input = str_replace(',', '.', $input); - $input = preg_replace('[^0-9\.\+\-\*\/\(\)]', '', $input); - - // Calculate each of the parenthesis from the top - $i = 0; - while(strpos($input, '(') || strpos($input, ')')){ - $input = preg_replace_callback('/\(([^\(\)]+)\)/', 'self::callback', $input); - - $i++; - if($i > self::PARENTHESIS_DEPTH){ - break; - } - } - - // Calculate the result - if(preg_match(self::PATTERN, $input, $match)){ - return $this->compute($match[0]); - } - - return 0; - } - - return $input; - } - - private function compute($input){ - $compute = create_function('', 'return '.$input.';'); - - return 0 + $compute(); - } - - private function callback($input){ - if(is_numeric($input[1])){ - return $input[1]; - } - elseif(preg_match(self::PATTERN, $input[1], $match)){ - return $this->compute($match[0]); - } - - return 0; - } - */ - - /** * Get all accounting account of a group. * You must choose between first parameter (personalized group) or the second (free criteria filter) From 15ba0c3b49b6ba69461e4e7fb085109705392854 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 15:35:42 +0100 Subject: [PATCH 037/125] Close #7989 Merge manually in existing class --- .../class/accountancycategory.class.php | 25 ------------------- htdocs/core/modules/modAccounting.class.php | 21 ++++++++++++++++ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index effae05da0f..dae58bf1520 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -52,30 +52,6 @@ class AccountancyCategory // extends CommonObject public $sdc; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } - - - var $id; - var $code; - var $label; - var $range_account; - var $sens; - var $category_type; - var $formula; - var $position; - var $fk_country; - var $active; - - - /** * Constructor @@ -85,7 +61,6 @@ class AccountancyCategory // extends CommonObject function __construct($db) { $this->db = $db; - return 1; } diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 3f8a7c092b8..059118e2663 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2014 Ari Elbaz (elarifr) * Copyright (C) 2014 Florian Henry * Copyright (C) 2016-2017 Laurent Destailleur + * Copyright (C) 2017 Open-DSI * * 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 @@ -235,5 +236,25 @@ class modAccounting extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'accounting_account as aa, '.MAIN_DB_PREFIX.'accounting_system as ac'; $this->export_sql_end[$r] .=' WHERE ac.pcg_version = aa.fk_pcg_version AND aa.entity IN ('.getEntity('accounting').') '; + + // Imports + //-------- + $r=0; + + $r++; + $this->import_code[$r]=$this->rights_class.'_'.$r; + $this->import_label[$r]="Chartofaccounts"; // Translation key + $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('aa'=>MAIN_DB_PREFIX.'accounting_account'); + $this->import_tables_creator_array[$r]=array('aa'=>'fk_user_author'); // Fields to store import user id + $this->import_fields_array[$r]=array('aa.fk_pcg_version'=>"Chartofaccounts*",'aa.account_number'=>"AccountAccounting*",'aa.label'=>"Label*",'aa.account_parent'=>"Accountparent","aa.fk_accounting_category"=>"AccountingCategory","aa.pcg_type"=>"Pcgtype*",'aa.pcg_subtype'=>'Pcgsubtype*','aa.active'=>'Status*','aa.datec'=>"DateCreation"); + $this->import_regex_array[$r]=array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system','aa.account_number'=>'^\d{1,32}$','aa.label'=>'^.{1,255}$','aa.account_parent'=>'^\d{0,32}$','aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category','aa.pcg_type'=>'^.{1,20}$','aa.pcg_subtype'=>'^.{1,20}$','aa.active'=>'^0|1$','aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); + $this->import_convertvalue_array[$r]=array( + 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/accountancy/class/accountancycategory.class.php','class'=>'AccountingCategory','method'=>'fetch','dict'=>'DictionaryAccountancyCategory'), + 'aa.account_parent'=>array('rule'=>'zeroifnull'), + ); + $this->import_examplevalues_array[$r]=array('aa.fk_pcg_version'=>"PCG99-ABREGE",'aa.account_number'=>"707",'aa.label'=>"Product sales",'aa.account_parent'=>"1407","aa.fk_accounting_category"=>"SALES","aa.pcg_type"=>"PROD",'aa.pcg_subtype'=>'PRODUCT','aa.active'=>'1','aa.datec'=>"2017-04-28"); + } } From 48d250b201fa67df894ef7e0e269b759bf9db588 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 15:55:58 +0100 Subject: [PATCH 038/125] Help to understand --- htdocs/accountancy/admin/categories_list.php | 2 +- htdocs/langs/en_US/admin.lang | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 9833a1c01b1..0dcefdcc0ee 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -113,7 +113,7 @@ $tabcond[32]= ! empty($conf->accounting->enabled); // List of help for fields $tabhelp=array(); -$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode")); +$tabhelp[32] = array('code'=>$langs->trans("EnterAnyCode"), 'category_type'=>$langs->trans("SetToYesIfGroupIsComputationOfOtherGroups"), 'formula'=>$langs->trans("EnterCalculationRuleIfPreviousFieldIsYes")); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index efb9839ade2..29673edf51c 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1764,6 +1764,8 @@ MAIN_PDF_MARGIN_LEFT=Left margin on PDF MAIN_PDF_MARGIN_RIGHT=Right margin on PDF MAIN_PDF_MARGIN_TOP=Top margin on PDF MAIN_PDF_MARGIN_BOTTOM=Bottom margin on PDF +SetToYesIfGroupIsComputationOfOtherGroups=Set this to yes if this group is a computation of other groups +EnterCalculationRuleIfPreviousFieldIsYes=Enter calculcation rule if previous field was set to Yes (For example 'CODEGRP1+CODEGRP2') ##### Resource #### ResourceSetup=Configuration du module Resource UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). From 809ef1bd00d2a8f31a6eec49c228dce1ea7a289c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 18:09:38 +0100 Subject: [PATCH 039/125] FIX Trigger *_MODIFY must be called when editing a property event extra. Clean duplicate trigggers "*_CLONE" --- ChangeLog | 4 +++- htdocs/comm/card.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 5 ----- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 5 ----- htdocs/compta/facture/card.php | 2 +- htdocs/compta/facture/class/facture.class.php | 5 ----- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/contrat/class/contrat.class.php | 11 ----------- htdocs/expedition/card.php | 2 +- htdocs/expedition/shipment.php | 2 +- htdocs/expensereport/card.php | 2 +- htdocs/expensereport/class/expensereport.class.php | 5 ----- htdocs/fichinter/card.php | 2 +- htdocs/fichinter/class/fichinter.class.php | 5 ----- htdocs/fourn/card.php | 8 ++++---- htdocs/fourn/class/fournisseur.commande.class.php | 5 ----- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/livraison/card.php | 2 +- ...nterface_99_modMyModule_MyModuleTriggers.class.php | 11 ++++------- htdocs/product/stock/productlot_card.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 5 ----- 27 files changed, 27 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index fd18deeac14..5aff4d6d3ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,7 +12,9 @@ Following changes may create regressions for some external modules, but were nec 'doaction' into 'sendMail'. * Rename trigger CONTRACT_SERVICE_ACTIVATE into LINECONTRACT_ACTIVATE and CONTRACT_SERVICE_CLOSE into LINECONTRACT_CLOSE - +* Remove triggers *_CLONE. The trigger CREATE with context 'createfromclone' is already called so this is + a duplicated feature. Cloning is not a business event, the business event is CREATE, so no trigger required. + ***** ChangeLog for 7.0.0 compared to 6.0.5 ***** For users: diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 81443f04d62..506b0c6fa8d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -195,7 +195,7 @@ if (empty($reshook)) if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 54e3cf36c45..9c72170b880 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1234,7 +1234,7 @@ if (empty($reshook)) if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('PROPAL_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5efc1cf9db4..312d228b2d4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1289,11 +1289,6 @@ class Propal extends CommonObject $reshook=$hookmanager->executeHooks('createFrom',$parameters,$clonedObj,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$clonedObj->call_trigger('PROPAL_CLONE',$user); - if ($result < 0) { $error++; } - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6e1d411d55e..54c7db7d6ca 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1281,7 +1281,7 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by // some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('ORDER_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 65b704693fb..8f2f233fb10 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1073,11 +1073,6 @@ class Commande extends CommonOrder $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$this->call_trigger('ORDER_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 19612349214..ab7e0826553 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2119,7 +2119,7 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by // some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('BILL_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7edc3b65b41..184b9c80f3c 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -958,11 +958,6 @@ class Facture extends CommonInvoice $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$this->call_trigger('BILL_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index af81e797252..f869c01aa53 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -450,7 +450,7 @@ if (empty($reshook)) if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('BILLREC_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 6111be6c7ee..cdbcb46f815 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -881,7 +881,7 @@ if (empty($reshook)) if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('CONTRACT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 12e08984411..cf809adfc6c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2430,17 +2430,6 @@ class Contrat extends CommonObject } - if (! $notrigger && empty($error)) - { - // Call trigger - $clonedObj->old_copy=$this; - $result = $clonedObj->call_trigger('CONTRACT_CLONE', $user); - if ($result < 0) { - $error ++; - } - // End call triggers - } - unset($this->context['createfromclone']); // End diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 9f48d27ca00..8fc21e0653e 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -168,7 +168,7 @@ if (empty($reshook)) $parameters = array('id' => $object->id); $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index a358d349531..d172d1034ca 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -193,7 +193,7 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by // some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('SHIPMENT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 6d989e6efc0..59c8b719d4e 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -299,7 +299,7 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by // some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('FICHINTER_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b1523f3bbf9..5674192906c 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -341,11 +341,6 @@ class ExpenseReport extends CommonObject $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$this->call_trigger('EXPENSEREPORT_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 81e7fe9ac54..e7839f66da2 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -755,7 +755,7 @@ if (empty($reshook)) $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - $result=$object->insertExtraFields(); + $result=$object->insertExtraFields('INTERVENTION_MODIFY'); if ($result < 0) { $error++; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6ee279d2015..49db7cddc00 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -1107,11 +1107,6 @@ class Fichinter extends CommonObject $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$this->call_trigger('INTERVENTION_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 588c13ca849..6f06a6778fd 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -101,7 +101,7 @@ if (empty($reshook)) $result=$object->setPaymentMethods(GETPOST('mode_reglement_supplier_id','int')); if ($result < 0) dol_print_error($db,$object->error); } - + // update supplier order min amount if ($action == 'setsupplier_order_min_amount') { @@ -121,7 +121,7 @@ if (empty($reshook)) if ($ret < 0) $error++; if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) $error++; } if ($error) $action = 'edit_extras'; @@ -255,14 +255,14 @@ if ($object->id > 0) } print ""; print ''; - + print ''; print ''; print $form->editfieldkey("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer); print ''; $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OrderMinAmount",'supplier_order_min_amount',$object->supplier_order_min_amount,$object,$user->rights->societe->creer,$limit_field_type,($object->supplier_order_min_amount != '' ? price($object->supplier_order_min_amount) : '')); - + print ''; print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 38d0e42d36a..957794efd46 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1368,11 +1368,6 @@ class CommandeFournisseur extends CommonOrder $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$this->call_trigger('ORDER_SUPPLIER_CLONE',$user); - if ($result < 0) $error++; - // End call triggers } unset($this->context['createfromclone']); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 81ea1a0f951..da3f79d94d0 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -963,7 +963,7 @@ if (empty($reshook)) { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields(); + $result=$object->insertExtraFields('ORDER_SUPPLIER_MODIFY'); if ($result < 0) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 761d5d591e3..cfba614492e 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1274,7 +1274,7 @@ if (empty($reshook)) if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$object->insertExtraFields(); + $result=$object->insertExtraFields('BILL_SUPPLIER_MODIFY'); if ($result < 0) { diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index b0de98ae2eb..41091b36e08 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -206,7 +206,7 @@ if ($action == 'update_extras') $parameters = array('id' => $object->id); $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('DELIVERY_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php index e413c969119..f9984e8fb40 100644 --- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php +++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php @@ -151,13 +151,13 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers case 'STOCK_MOVEMENT': //MYECMDIR - case 'MYECMDIR_DELETE': case 'MYECMDIR_CREATE': case 'MYECMDIR_MODIFY': + case 'MYECMDIR_DELETE': // Customer orders case 'ORDER_CREATE': - case 'ORDER_CLONE': + case 'ORDER_MODIFY': case 'ORDER_VALIDATE': case 'ORDER_DELETE': case 'ORDER_CANCEL': @@ -170,7 +170,7 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Supplier orders case 'ORDER_SUPPLIER_CREATE': - case 'ORDER_SUPPLIER_CLONE': + case 'ORDER_SUPPLIER_MODIFY': case 'ORDER_SUPPLIER_VALIDATE': case 'ORDER_SUPPLIER_DELETE': case 'ORDER_SUPPLIER_APPROVE': @@ -184,7 +184,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Proposals case 'PROPAL_CREATE': - case 'PROPAL_CLONE': case 'PROPAL_MODIFY': case 'PROPAL_VALIDATE': case 'PROPAL_SENTBYMAIL': @@ -197,7 +196,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // SupplierProposal case 'SUPPLIER_PROPOSAL_CREATE': - case 'SUPPLIER_PROPOSAL_CLONE': case 'SUPPLIER_PROPOSAL_MODIFY': case 'SUPPLIER_PROPOSAL_VALIDATE': case 'SUPPLIER_PROPOSAL_SENTBYMAIL': @@ -210,8 +208,8 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Contracts case 'CONTRACT_CREATE': - case 'CONTRACT_ACTIVATE': case 'CONTRACT_MODIFY': + case 'CONTRACT_ACTIVATE': case 'CONTRACT_CANCEL': case 'CONTRACT_CLOSE': case 'CONTRACT_DELETE': @@ -221,7 +219,6 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers // Bills case 'BILL_CREATE': - case 'BILL_CLONE': case 'BILL_MODIFY': case 'BILL_VALIDATE': case 'BILL_UNVALIDATE': diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 3a8f4cbff4e..1d9a7420740 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -135,7 +135,7 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('insertExtraFields', $parameters, $object, $action); // Note that $action and $object may have been modified by // some hooks if (empty($reshook)) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('PRODUCT_LOT_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index dcacf89d643..b48c80a7a24 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -334,7 +334,7 @@ if (empty($reshook)) if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('COMPANY_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index a5488959016..440551bd925 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -934,7 +934,7 @@ if (empty($reshook)) if (! $error) { - $result = $object->insertExtraFields(); + $result = $object->insertExtraFields('SUPPLIER_PROPOSAL_MODIFY'); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e43404777b6..d71f9a02a1f 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1101,11 +1101,6 @@ class SupplierProposal extends CommonObject $reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) $error++; } - - // Call trigger - $result=$this->call_trigger('SUPPLIER_PROPOSAL_CLONE',$user); - if ($result < 0) { $error++; } - // End call triggers } // End From 71cbcce3a2bf4918c3495e55b5c52d5b1fa2a9dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 18:10:11 +0100 Subject: [PATCH 040/125] NEW Can select sample to use when creating a new page --- htdocs/core/class/html.formwebsite.class.php | 45 +++++++++++++++++++ htdocs/langs/en_US/website.lang | 5 ++- htdocs/website/index.php | 15 ++++++- ...te.html => page-sample-corporatehome.html} | 0 htdocs/website/page-sample-empty.html | 10 +++++ 5 files changed, 72 insertions(+), 3 deletions(-) rename htdocs/website/{pagetemplate.html => page-sample-corporatehome.html} (100%) create mode 100644 htdocs/website/page-sample-empty.html diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 4f92b2e9449..e7cd6d447a0 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -158,4 +158,49 @@ class FormWebsite } } + + /** + * Return a HTML select list of a dictionary + * + * @param string $htmlname Name of select zone + * @param string $selected Selected value + * @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param string $moreattrib More attributes on HTML select tag + * @return void + */ + function selectSampleOfContainer($htmlname, $selected='', $useempty=0, $moreattrib='') + { + global $langs, $conf, $user; + + $langs->load("admin"); + + $arrayofsamples=array('corporatehome'=>'CorporateHomePage', 'empty'=>'EmptyPage'); + + $out = ''; + + $out .= '"; + + return $out; + } + } diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 6e67062b859..a4c7d9e0211 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -4,6 +4,7 @@ WebsiteSetupDesc=Create here as much entry as number of different websites you n DeleteWebsite=Delete website ConfirmDeleteWebsite=Are you sure you want to delete this web site. All its pages and content will also be removed. WEBSITE_TYPE_CONTAINER=Type of page/container +WEBSITE_PAGE_EXAMPLE=Web page to use as example WEBSITE_PAGENAME=Page name/alias WEBSITE_CSS_URL=URL of external CSS file WEBSITE_CSS_INLINE=CSS file content (common to all pages) @@ -76,4 +77,6 @@ GrabImagesInto=Grab also images found into css and page. ImagesShouldBeSavedInto=Images should be saved into directory WebsiteRootOfImages=Root directory for website images SubdirOfPage=Sub-directory dedicated to page -AliasPageAlreadyExists=Alias page %s already exists \ No newline at end of file +AliasPageAlreadyExists=Alias page %s already exists +CorporateHomePage=Corporate Home page +EmptyPage=Empty page \ No newline at end of file diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 959529eb44e..084ef28c2d0 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -153,7 +153,7 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; -$htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault.=''."\n"; /* @@ -552,8 +552,13 @@ if ($action == 'addcontainer') $substitutionarray=array(); $substitutionarray['__WEBSITE_CREATE_BY__']=$user->getFullName($langs); + $sample = GETPOST('sample','alpha'); + if (empty($sample)) $sample='empty'; + + $pathtosample = DOL_DOCUMENT_ROOT.'/website/page-sample-'.$sample.'.html'; + // Init content with content into pagetemplate.html, blogposttempltate.html, ... - $objectpage->content = make_substitutions(@file_get_contents(DOL_DOCUMENT_ROOT.'/website/'.$objectpage->type_container.'template.html'), $substitutionarray); + $objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray); } if (! $error) @@ -2036,6 +2041,12 @@ if ($action == 'editmeta' || $action == 'createcontainer') print $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER')?GETPOST('WEBSITE_TYPE_CONTAINER'):'page')); print ''; + print ''; + print $langs->trans('WEBSITE_PAGE_EXAMPLE'); + print ''; + print $formwebsite->selectSampleOfContainer('sample', (GETPOST('sample')?GETPOST('sample'):'corporatehomepage')); + print ''; + print ''; print $langs->trans('WEBSITE_PAGENAME'); print ''; diff --git a/htdocs/website/pagetemplate.html b/htdocs/website/page-sample-corporatehome.html similarity index 100% rename from htdocs/website/pagetemplate.html rename to htdocs/website/page-sample-corporatehome.html diff --git a/htdocs/website/page-sample-empty.html b/htdocs/website/page-sample-empty.html new file mode 100644 index 00000000000..313c398a86e --- /dev/null +++ b/htdocs/website/page-sample-empty.html @@ -0,0 +1,10 @@ +
+

__[MAIN_INFO_SOCIETE_NOM]__


+__(MyContainerTitle)__ +
+
+
+
+
Created by: __WEBSITE_CREATE_BY__
+
+
From e465b0c40ebfd4eb71952491f6de147ba716baf6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 19:19:27 +0100 Subject: [PATCH 041/125] Fix extrafield date or datetime with bad timezone --- htdocs/core/class/commonobject.class.php | 18 ++++++++++++++++-- htdocs/core/class/extrafields.class.php | 4 ++-- htdocs/core/tpl/extrafields_view.tpl.php | 12 ++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 8def2194fb3..07993bb1d97 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4481,7 +4481,7 @@ abstract class CommonObject if (! is_array($optionsArray)) { // If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. - // TODO Use of existing extrafield is not yet ready (must mutualize code that use extrafields in form first) + // TODO Use of existing $extrafield is not yet ready (must mutualize code that use extrafields in form first) // global $extrafields; //if (! is_object($extrafields)) //{ @@ -4496,6 +4496,10 @@ abstract class CommonObject } $optionsArray = $extrafields->attributes[$this->table_element]['label']; } + else + { + dol_syslog("Warning: fetch_optionals was called with param $optionsArray defined when you should pass null now", LOG_WARNING); + } $table_element = $this->table_element; if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility @@ -4529,7 +4533,17 @@ abstract class CommonObject if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) { // we can add this attribute to object - $this->array_options["options_".$key]=$value; + if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) + { + //var_dump($extrafields->attributes[$this->table_element]['type'][$key]); + $this->array_options["options_".$key]=$this->db->jdate($value); + } + else + { + $this->array_options["options_".$key]=$value; + } + + //var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]); } } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a127ce706e9..ee165ac6808 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1404,12 +1404,12 @@ class ExtraFields if ($type == 'date') { $showsize=10; - $value=dol_print_date($value, 'day', 'tzuser'); + $value=dol_print_date($value, 'day'); } elseif ($type == 'datetime') { $showsize=19; - $value=dol_print_date($value, 'dayhour', 'tzuser'); + $value=dol_print_date($value, 'dayhour'); } elseif ($type == 'int') { diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 9d638426bc3..3559df44c9c 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -107,8 +107,16 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ print ''; // Convert date into timestamp format - if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) { - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options['options_' . $key]); + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) + { + $datenotinstring = $object->array_options['options_' . $key]; + // print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x'; + if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility + { + $datenotinstring = $db->jdate($datenotinstring); + } + //print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); + $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring; } //TODO Improve element and rights detection From 8b54a805935b2766f3d41d3c56803875e68428f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 19:20:03 +0100 Subject: [PATCH 042/125] Fix oldcopy not saved before calling trigger --- htdocs/contrat/card.php | 3 +++ htdocs/contrat/class/contrat.class.php | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index cdbcb46f815..0bbb509b7fa 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -94,6 +94,7 @@ $permissionnote=$user->rights->contrat->creer; // Used by the include of actions $permissiondellink=$user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php + /* * Actions */ @@ -875,6 +876,8 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index cf809adfc6c..537e37071bc 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -609,7 +609,7 @@ class Contrat extends CommonObject $this->mise_en_service = $this->db->jdate($result["datemise"]); $this->date_contrat = $this->db->jdate($result["datecontrat"]); - $this->date_creation = $this->db->jdate($result["datecontrat"]); + $this->date_creation = $this->db->jdate($result["datecontrat"]); $this->fin_validite = $this->db->jdate($result["fin_validite"]); $this->date_cloture = $this->db->jdate($result["date_cloture"]); @@ -634,16 +634,13 @@ class Contrat extends CommonObject $this->db->free($resql); - // Retreive all extrafield for thirdparty - // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + + $this->fetch_optionals($this->id, null); + /* * Lines - */ + */ $this->lines = array(); From 34135e0a133f3770d042b133e86d5b481c29b342 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 19:19:27 +0100 Subject: [PATCH 043/125] Fix extrafield date or datetime with bad timezone --- htdocs/core/class/commonobject.class.php | 18 ++++++++++++++++-- htdocs/core/class/extrafields.class.php | 4 ++-- htdocs/core/tpl/extrafields_view.tpl.php | 12 ++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60e491162f2..d89c110c2c9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4411,7 +4411,7 @@ abstract class CommonObject if (! is_array($optionsArray)) { // If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page. - // TODO Use of existing extrafield is not yet ready (must mutualize code that use extrafields in form first) + // TODO Use of existing $extrafield is not yet ready (must mutualize code that use extrafields in form first) // global $extrafields; //if (! is_object($extrafields)) //{ @@ -4426,6 +4426,10 @@ abstract class CommonObject } $optionsArray = $extrafields->attributes[$this->table_element]['label']; } + else + { + dol_syslog("Warning: fetch_optionals was called with param $optionsArray defined when you should pass null now", LOG_WARNING); + } $table_element = $this->table_element; if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility @@ -4459,7 +4463,17 @@ abstract class CommonObject if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) { // we can add this attribute to object - $this->array_options["options_".$key]=$value; + if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime'))) + { + //var_dump($extrafields->attributes[$this->table_element]['type'][$key]); + $this->array_options["options_".$key]=$this->db->jdate($value); + } + else + { + $this->array_options["options_".$key]=$value; + } + + //var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]); } } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 22b65d688fd..3d934baaf75 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1404,12 +1404,12 @@ class ExtraFields if ($type == 'date') { $showsize=10; - $value=dol_print_date($value, 'day', 'tzuser'); + $value=dol_print_date($value, 'day'); } elseif ($type == 'datetime') { $showsize=19; - $value=dol_print_date($value, 'dayhour', 'tzuser'); + $value=dol_print_date($value, 'dayhour'); } elseif ($type == 'int') { diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 9d638426bc3..3559df44c9c 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -107,8 +107,16 @@ if (empty($reshook) && ! empty($extrafields->attributes[$object->table_element][ print ''; // Convert date into timestamp format - if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) { - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $db->jdate($object->array_options['options_' . $key]); + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) + { + $datenotinstring = $object->array_options['options_' . $key]; + // print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x'; + if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility + { + $datenotinstring = $db->jdate($datenotinstring); + } + //print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); + $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring; } //TODO Improve element and rights detection From c4130730cb00cc75a08cc2a2eff4be533e62dd18 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Feb 2018 19:38:18 +0100 Subject: [PATCH 044/125] Clean code around fetch_optionals() --- htdocs/adherents/class/adherent.class.php | 7 +- htdocs/categories/class/categorie.class.php | 4 +- htdocs/comm/action/class/actioncomm.class.php | 3 + htdocs/comm/propal/class/propal.class.php | 7 +- htdocs/commande/class/commande.class.php | 7 +- htdocs/compta/bank/class/account.class.php | 7 +- .../facture/class/facture-rec.class.php | 7 +- htdocs/compta/facture/class/facture.class.php | 24 +++---- htdocs/contact/class/contact.class.php | 9 +-- htdocs/contrat/class/contrat.class.php | 4 +- htdocs/core/class/ctyperesource.class.php | 65 +++++++++---------- htdocs/don/class/don.class.php | 7 +- htdocs/ecm/class/ecmfiles.class.php | 8 +-- htdocs/expedition/class/expedition.class.php | 7 +- htdocs/fichinter/class/fichinter.class.php | 9 ++- .../class/fournisseur.commande.class.php | 7 +- .../fourn/class/fournisseur.facture.class.php | 5 +- htdocs/livraison/class/livraison.class.php | 8 +-- htdocs/product/class/product.class.php | 8 +-- .../stock/class/mouvementstock.class.php | 7 +- .../product/stock/class/productlot.class.php | 7 +- .../class/productstockentrepot.class.php | 65 +++++++++---------- htdocs/projet/class/project.class.php | 3 +- htdocs/projet/class/task.class.php | 5 +- htdocs/resource/class/dolresource.class.php | 8 +-- htdocs/societe/class/societe.class.php | 7 +- .../class/supplier_proposal.class.php | 14 ++-- htdocs/user/class/user.class.php | 7 +- htdocs/user/class/usergroup.class.php | 7 +- 29 files changed, 135 insertions(+), 198 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index bd0722ae63e..5691cd6687b 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -1156,12 +1156,9 @@ class Adherent extends CommonObject $this->model_pdf = $obj->model_pdf; - // Retreive all extrafield for thirdparty + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); // Load other properties $result=$this->fetch_subscriptions(); diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 46063c0f8c4..5b824d8c959 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -236,7 +236,9 @@ class Categorie extends CommonObject $this->type = $res['type']; $this->entity = $res['entity']; - $this->fetch_optionals($this->id,null); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); $this->db->free($resql); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 9e0a0d6321d..5f094856e1c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -465,7 +465,10 @@ class ActionComm extends CommonObject // Load source object $objFrom = clone $this; + // Retreive all extrafield + // fetch optionals attributes and labels $this->fetch_optionals(); + // $this->fetch_userassigned(); $this->fetchResources(); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 312d228b2d4..1380b02d339 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1434,12 +1434,9 @@ class Propal extends CommonObject $this->brouillon = 1; } - // Retreive all extrafield for invoice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); $this->db->free($resql); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 8f2f233fb10..f89bcf534a2 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1668,12 +1668,9 @@ class Commande extends CommonOrder if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - // Retrieve all extrafields for invoice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); $this->db->free($result); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 1dba4a5b221..719a48c3e3c 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -913,12 +913,9 @@ class Account extends CommonObject $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_update = $this->db->jdate($obj->date_update); - // Retreive all extrafield for thirdparty + // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); return 1; } diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 1636be2aace..84b61817a28 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -381,12 +381,9 @@ class FactureRec extends CommonInvoice if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - // Retreive all extrafield for thirdparty + // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); /* * Lines diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 184b9c80f3c..aba627dd8a2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -790,14 +790,17 @@ class Facture extends CommonInvoice // Charge facture source $facture=new Facture($this->db); - $this->fetch_optionals(); - if(!empty($this->array_options)){ - $facture->array_options = $this->array_options; - } + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); - foreach($this->lines as &$line){ + if(!empty($this->array_options)){ + $facture->array_options = $this->array_options; + } + + foreach($this->lines as &$line){ $line->fetch_optionals();//fetch extrafields - } + } $facture->fk_facture_source = $this->fk_facture_source; $facture->type = $this->type; @@ -1328,16 +1331,13 @@ class Facture extends CommonInvoice if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; - // Retrieve all extrafield for invoice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); /* * Lines - */ + */ $this->lines = array(); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index f616ca728b6..eca1174bb59 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -801,12 +801,9 @@ class Contact extends CommonObject } } - // Retreive all extrafield for contact - // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); return 1; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 537e37071bc..9d40001ad50 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -635,7 +635,9 @@ class Contrat extends CommonObject $this->db->free($resql); - $this->fetch_optionals($this->id, null); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); /* diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 1de616210e4..a5a6ea879ce 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -48,14 +48,14 @@ class Ctyperesource /** */ - + public $code; public $label; public $active; /** */ - + /** * Constructor @@ -82,7 +82,7 @@ class Ctyperesource $error = 0; // Clean parameters - + if (isset($this->code)) { $this->code = trim($this->code); } @@ -93,26 +93,26 @@ class Ctyperesource $this->active = trim($this->active); } - + // Check parameters // Put here code to add control on parameters values // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - + $sql.= 'code,'; $sql.= 'label'; $sql.= 'active'; - + $sql .= ') VALUES ('; - + $sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").','; $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").','; $sql .= ' '.(! isset($this->active)?'NULL':$this->active); - + $sql .= ')'; $this->db->begin(); @@ -165,18 +165,18 @@ class Ctyperesource $sql = 'SELECT'; $sql .= ' t.rowid,'; - + $sql .= " t.code,"; $sql .= " t.label,"; $sql .= " t.active"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if ($id) $sql.= " WHERE t.id = ".$id; elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; elseif ($label) $sql.= " WHERE t.label = '".$this->db->escape($label)."'"; - - + + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); @@ -184,25 +184,20 @@ class Ctyperesource $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->code = $obj->code; $this->label = $obj->label; $this->active = $obj->active; - + } - + // Retrieve all extrafields for invoice // fetch optionals attributes and labels - /* - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); - */ - + // $this->fetch_optionals(); + // $this->fetch_lines(); - + $this->db->free($resql); if ($numrows) { @@ -236,12 +231,12 @@ class Ctyperesource $sql = 'SELECT'; $sql .= ' t.rowid,'; - + $sql .= " t.code,"; $sql .= " t.label,"; $sql .= " t.active"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; // Manage filter @@ -251,7 +246,7 @@ class Ctyperesource $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; } } - + if (count($sqlwhere) > 0) { $sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere); } @@ -270,12 +265,12 @@ class Ctyperesource $line = new self($this->db); $line->id = $obj->rowid; - + $line->code = $obj->code; $line->label = $obj->label; $line->active = $obj->active; - + } $this->db->free($resql); @@ -303,7 +298,7 @@ class Ctyperesource dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->code)) { $this->code = trim($this->code); } @@ -319,12 +314,12 @@ class Ctyperesource // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - + $sql .= ' code = '.(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").','; $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").','; $sql .= ' active = '.(isset($this->active)?$this->active:"null"); - + $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -387,7 +382,7 @@ class Ctyperesource } // If you need to delete child tables to, you can insert them here - + if (!$error) { $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element; $sql .= ' WHERE rowid=' . $this->id; @@ -468,7 +463,7 @@ class Ctyperesource public function initAsSpecimen() { $this->id = 0; - + $this->code = ''; $this->label = ''; $this->active = ''; @@ -488,7 +483,7 @@ class CtyperesourceLine /** * @var mixed Sample line property 1 */ - + public $code; public $label; public $active; @@ -496,5 +491,5 @@ class CtyperesourceLine /** * @var mixed Sample line property 2 */ - + } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index df298831c22..01ae466f132 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -665,12 +665,9 @@ class Don extends CommonObject $this->modelpdf = $obj->model_pdf; $this->commentaire = $obj->note; // deprecated - // Retrieve all extrafield for thirdparty + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); } return 1; } diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index ae16ad85eaf..698960974d5 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -337,12 +337,8 @@ class EcmFiles //extends CommonObject // Retrieve all extrafields for invoice // fetch optionals attributes and labels - /* - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); - */ + // $this->fetch_optionals(); + // $this->fetch_lines(); $this->db->free($resql); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 85408c7e14a..b8eef6b5102 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -547,12 +547,9 @@ class Expedition extends CommonObject */ $result=$this->fetch_thirdparty(); - // Retrieve all extrafields for expedition + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); /* * Lines diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 49db7cddc00..2cbbd1be022 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -383,14 +383,13 @@ class Fichinter extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); /* * Lines - */ + */ $result=$this->fetch_lines(); if ($result < 0) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 957794efd46..1bbde68172e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -310,12 +310,9 @@ class CommandeFournisseur extends CommonOrder $this->db->free($resql); - // Retrieve all extrafields + // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); if ($this->statut == 0) $this->brouillon = 1; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 292466ea0d8..1f84e71df96 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -643,10 +643,7 @@ class FactureFournisseur extends CommonInvoice // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 837b0af77f5..d0d24d39144 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -301,13 +301,9 @@ class Livraison extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - - // Retrieve all extrafields for delivery + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); /* * Lignes diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 73d867e7141..123330004ed 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1951,13 +1951,9 @@ class Product extends CommonObject $this->db->free($resql); - - // Retreive all extrafield for current object + // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); // multilangs if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs(); diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 69be51f11e8..ab2b60f564a 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -576,12 +576,9 @@ class MouvementStock extends CommonObject $this->sellby = $this->db->jdate($obj->sellby); } - // Retrieve all extrafields for invoice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); // $this->fetch_lines(); diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index d7915512b2c..31c28eaa5b3 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -233,12 +233,9 @@ class Productlot extends CommonObject $this->fk_user_modif = $obj->fk_user_modif; $this->import_key = $obj->import_key; - // Retrieve all extrafields for invoice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); } $this->db->free($resql); diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 048be66461f..cbca4e5854d 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -51,7 +51,7 @@ class ProductStockEntrepot extends CommonObject /** */ - + public $tms = ''; public $fk_product; public $fk_entrepot; @@ -61,7 +61,7 @@ class ProductStockEntrepot extends CommonObject /** */ - + /** * Constructor @@ -88,7 +88,7 @@ class ProductStockEntrepot extends CommonObject $error = 0; // Clean parameters - + if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); @@ -100,23 +100,23 @@ class ProductStockEntrepot extends CommonObject // Insert request $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '('; - + $sql.= 'fk_product,'; $sql.= 'fk_entrepot,'; $sql.= 'seuil_stock_alerte,'; $sql.= 'desiredstock,'; $sql.= 'import_key'; - + $sql .= ') VALUES ('; - + $sql .= ' '.(! isset($this->fk_product)?'NULL':$this->fk_product).','; $sql .= ' '.(! isset($this->fk_entrepot)?'NULL':$this->fk_entrepot).','; $sql .= ' '.(! isset($this->seuil_stock_alerte)?'0':$this->seuil_stock_alerte).','; $sql .= ' '.(! isset($this->desiredstock)?'0':$this->desiredstock).','; $sql .= ' '.(! isset($this->import_key)?'NULL':"'".$this->db->escape($this->import_key)."'"); - + $sql .= ')'; $this->db->begin(); @@ -166,12 +166,12 @@ class ProductStockEntrepot extends CommonObject public function fetch($id, $fk_product, $fk_entrepot) { if(empty($id) && (empty($fk_product) || empty($fk_entrepot))) return -1; - + dol_syslog(__METHOD__, LOG_DEBUG); $sql = 'SELECT'; $sql .= ' t.rowid,'; - + $sql .= " t.tms,"; $sql .= " t.fk_product,"; $sql .= " t.fk_entrepot,"; @@ -179,11 +179,11 @@ class ProductStockEntrepot extends CommonObject $sql .= " t.desiredstock,"; $sql .= " t.import_key"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if(!empty($id)) $sql .= ' WHERE t.rowid = ' . $id; else $sql.= ' WHERE t.fk_product = '.$fk_product.' AND t.fk_entrepot = '.$fk_entrepot; - + $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); @@ -191,7 +191,7 @@ class ProductStockEntrepot extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->tms = $this->db->jdate($obj->tms); $this->fk_product = $obj->fk_product; $this->fk_entrepot = $obj->fk_entrepot; @@ -199,18 +199,15 @@ class ProductStockEntrepot extends CommonObject $this->desiredstock = $obj->desiredstock; $this->import_key = $obj->import_key; - + } - - // Retrieve all extrafields for invoice + + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); // $this->fetch_lines(); - + $this->db->free($resql); if ($numrows) { @@ -246,7 +243,7 @@ class ProductStockEntrepot extends CommonObject $sql = 'SELECT'; $sql .= ' t.rowid,'; - + $sql .= " t.tms,"; $sql .= " t.fk_product,"; $sql .= " t.fk_entrepot,"; @@ -254,11 +251,11 @@ class ProductStockEntrepot extends CommonObject $sql .= " t.desiredstock,"; $sql .= " t.import_key"; - + $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t'; - + $sql .= ' WHERE 1=1'; - + // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -267,19 +264,19 @@ class ProductStockEntrepot extends CommonObject } } if (count($sqlwhere) > 0) $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere); - + if(!empty($fk_product)) $sql .= ' AND fk_product = '.$fk_product; elseif(!empty($fk_entrepot)) $sql .= ' AND fk_entrepot = '.$fk_entrepot; // "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch - + if (!empty($sortfield)) $sql .= $this->db->order($sortfield,$sortorder); if (!empty($limit)) $sql .= ' ' . $this->db->plimit($limit, $offset); - + $lines = array(); $resql = $this->db->query($sql); if ($resql) { - + while ($obj = $this->db->fetch_object($resql)) { $lines[$obj->rowid] = array( 'id'=>$obj->rowid @@ -315,20 +312,20 @@ class ProductStockEntrepot extends CommonObject dol_syslog(__METHOD__, LOG_DEBUG); // Clean parameters - + if (isset($this->fk_product)) $this->fk_product = trim($this->fk_product); if (isset($this->fk_entrepot)) $this->fk_entrepot = trim($this->fk_entrepot); if (isset($this->seuil_stock_alerte)) $this->seuil_stock_alerte = trim($this->seuil_stock_alerte); if (isset($this->desiredstock)) $this->desiredstock = trim($this->desiredstock); if (isset($this->import_key)) $this->import_key = trim($this->import_key); - + // Check parameters // Put here code to add a control on parameters values // Update request $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET'; - + $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_product = '.(isset($this->fk_product)?$this->fk_product:"null").','; $sql .= ' fk_entrepot = '.(isset($this->fk_entrepot)?$this->fk_entrepot:"null").','; @@ -336,7 +333,7 @@ class ProductStockEntrepot extends CommonObject $sql .= ' desiredstock = '.(isset($this->desiredstock)?$this->desiredstock:"null").','; $sql .= ' import_key = '.(isset($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null"); - + $sql .= ' WHERE rowid=' . $this->id; $this->db->begin(); @@ -573,7 +570,7 @@ class ProductStockEntrepot extends CommonObject public function initAsSpecimen() { $this->id = 0; - + $this->tms = ''; $this->fk_product = ''; $this->fk_entrepot = ''; @@ -581,7 +578,7 @@ class ProductStockEntrepot extends CommonObject $this->desiredstock = ''; $this->import_key = ''; - + } } diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e24a444702c..8dbce2790fa 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -444,7 +444,8 @@ class Project extends CommonObject $this->db->free($resql); - // Retreive all extrafield for thirdparty + // Retreive all extrafield + // fetch optionals attributes and labels $this->fetch_optionals(); if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT)) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index e694b3c7bfd..eeacf27aaec 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -266,8 +266,9 @@ class Task extends CommonObject $this->task_parent_position = $obj->task_parent_position; } - // Retreive all extrafield data - $this->fetch_optionals(); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); } $this->db->free($resql); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index c880f9538c7..c7126c6d3bb 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -213,13 +213,9 @@ class Dolresource extends CommonObject $this->note_private = $obj->note_private; $this->type_label = $obj->type_label; - // Retreive all extrafield for thirdparty + // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); - + $this->fetch_optionals(); } $this->db->free($resql); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 652ffd8742e..3ca69fdb6fd 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -334,7 +334,7 @@ class Societe extends CommonObject */ var $price_level; var $outstanding_limit; - + /** * Min order amounts */ @@ -1315,8 +1315,9 @@ class Societe extends CommonObject $result = 1; - // Retreive all extrafield for thirdparty - $this->fetch_optionals(); + // Retreive all extrafield + // fetch optionals attributes and labels + $this->fetch_optionals(); } else { diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index d71f9a02a1f..c6ae3642bc9 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1215,12 +1215,9 @@ class SupplierProposal extends CommonObject $this->brouillon = 1; } - // Retreive all extrafield for invoice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); $this->db->free($resql); @@ -1311,12 +1308,9 @@ class SupplierProposal extends CommonObject return -1; } - // Retreive all extrafield for askprice + // Retreive all extrafield // fetch optionals attributes and labels - require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); return 1; } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6a2a1b774e7..3fcdf411a24 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -324,12 +324,9 @@ class User extends CommonObject // in such case, this admin user must be admin for ALL entities. if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) $this->entity = 0; - // Retreive all extrafield for thirdparty + // Retreive all extrafield // fetch optionals attributes and labels - require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); $this->db->free($result); } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 2e0cd0376c6..5104d813a05 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -116,12 +116,9 @@ class UserGroup extends CommonObject $this->members=$this->listUsersForGroup(); - // Retreive all extrafield for group + // Retreive all extrafield // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields=new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); - $this->fetch_optionals($this->id,$extralabels); + $this->fetch_optionals(); // Sav current LDAP Current DN From b276a8186e8bf0b9b2b556ea2268664c31d1df5a Mon Sep 17 00:00:00 2001 From: John Date: Wed, 21 Feb 2018 10:03:04 +0100 Subject: [PATCH 045/125] Fix sql entity for sub query --- htdocs/install/mysql/migration/5.0.0-6.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8b68929864f..f70b9e8e4c2 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 @@ -242,7 +242,7 @@ UPDATE llx_bank_account SET accountancy_journal = 'OD' WHERE accountancy_journal ALTER TABLE llx_bank_account ADD COLUMN fk_accountancy_journal integer; ALTER TABLE llx_bank_account ADD INDEX idx_fk_accountancy_journal (fk_accountancy_journal); -UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); +UPDATE llx_bank_account AS ba SET fk_accountancy_journal = (SELECT rowid FROM llx_accounting_journal AS aj WHERE ba.accountancy_journal = aj.code AND aj.entity = ba.entity) WHERE accountancy_journal NOT IN ('1', '2', '3', '4', '5', '6', '5', '8', '9', '10', '11', '12', '13', '14', '15'); ALTER TABLE llx_bank_account ADD CONSTRAINT fk_bank_account_accountancy_journal FOREIGN KEY (fk_accountancy_journal) REFERENCES llx_accounting_journal (rowid); --Update general ledger for FEC format & harmonization From 72c1357c9b822ab91b6ed5ad1a32992c8a21b0cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 11:02:45 +0100 Subject: [PATCH 046/125] NEW Section of files generated by mass action not visible if empty --- htdocs/admin/mails_senderprofile_list.php | 28 +++++++--------- htdocs/comm/propal/list.php | 25 ++++++--------- htdocs/commande/list.php | 25 ++++++--------- htdocs/compta/facture/list.php | 24 ++++++-------- htdocs/contrat/list.php | 26 ++++++--------- htdocs/core/class/html.formfile.class.php | 28 +++++++++------- htdocs/expensereport/list.php | 24 ++++++-------- htdocs/fichinter/list.php | 25 ++++++--------- htdocs/fourn/commande/list.php | 32 ++++++++----------- htdocs/fourn/facture/list.php | 24 ++++++-------- .../modulebuilder/template/myobject_list.php | 28 +++++++--------- htdocs/product/inventory/list.php | 28 +++++++--------- htdocs/product/stock/productlot_list.php | 24 ++++++-------- htdocs/societe/website.php | 28 +++++++--------- htdocs/supplier_proposal/list.php | 25 ++++++--------- 15 files changed, 163 insertions(+), 231 deletions(-) diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 763e648746d..69d1d8a8cea 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -507,25 +507,21 @@ print ''."\n"; if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); - $formfile = new FormFile($db); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->monmodule->read; - $delallowed=$user->rights->monmodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->monmodule->read; + $delallowed=$user->rights->monmodule->create; + + print $formfile->showdocuments('massfilesarea_monmodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } dol_fiche_end(); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index af67bd8107b..5de43a75b9d 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -892,25 +892,18 @@ if ($resql) print ''."\n"; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - /* - * Show list of available documents - */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->propal->lire; - $delallowed=$user->rights->propal->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->propal->lire; + $delallowed=$user->rights->propal->creer; + print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 13225c2c5d3..fe8461c3a41 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1101,25 +1101,18 @@ if ($resql) print ''."\n"; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - /* - * Show list of available documents - */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->commande->lire; - $delallowed=$user->rights->commande->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->commande->lire; + $delallowed=$user->rights->commande->creer; + print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fe26efd490e..5914f2f06e9 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1192,22 +1192,18 @@ if ($resql) print "\n"; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->facture->lire; + $delallowed=$user->rights->facture->creer; + + print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index cdafbd6c2fd..babc31f7702 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -775,24 +775,18 @@ if ($resql) print ''; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - /* - * Show list of available documents - */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->contrat->lire; - $delallowed=$user->rights->contrat->lire; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->contrat->lire; + $delallowed=$user->rights->contrat->lire; + + print $formfile->showdocuments('massfilesarea_contract','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index eded41be053..b139483b610 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -277,17 +277,18 @@ class FormFile * @param string $codelang Default language code to use on lang combo box if multilang is enabled * @param string $morepicto Add more HTML content into cell with picto * @param Object $object Object when method is called from an object card. + * @param int $hideifempty Hide section of generated files if there is no file * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$notused=0,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null) + function showdocuments($modulepart,$modulesubdir,$filedir,$urlsource,$genallowed,$delallowed=0,$modelselected='',$allowgenifempty=1,$forcenomultilang=0,$iconPDF=0,$notused=0,$noform=0,$param='',$title='',$buttonlabel='',$codelang='',$morepicto='',$object=null,$hideifempty=0) { // Deprecation warning - if (0 !== $iconPDF) { + if (! empty($iconPDF)) { dol_syslog(__METHOD__ . ": passing iconPDF parameter is deprecated", LOG_WARNING); } global $langs, $conf, $user, $hookmanager; - global $form, $bc; + global $form; if (! is_object($form)) $form=new Form($this->db); @@ -305,9 +306,17 @@ class FormFile } $hookmanager->initHooks(array('formfile')); - $forname='builddoc'; - $out=''; + // Get list of files + $file_list=null; + if (! empty($filedir)) + { + $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview.*.*\.png)$','date',SORT_DESC); + } + if ($hideifempty && empty($file_list)) return ''; + + $out=''; + $forname='builddoc'; $headershown=0; $showempty=0; $i=0; @@ -678,8 +687,6 @@ class FormFile // Get list of files if (! empty($filedir)) { - $file_list=dol_dir_list($filedir,'files',0,'','(\.meta|_preview.*.*\.png)$','date',SORT_DESC); - $link_list = array(); if (is_object($object)) { @@ -949,7 +956,6 @@ class FormFile function list_of_documents($filearray,$object,$modulepart,$param='',$forcedownload=0,$relativepath='',$permonobject=1,$useinecm=0,$textifempty='',$maxlength=0,$title='',$url='', $showrelpart=0, $permtoeditline=-1,$upload_dir='',$sortfield='',$sortorder='ASC', $disablemove=1, $addfilterfields=0) { global $user, $conf, $langs, $hookmanager; - global $bc,$bcdd; global $sortfield, $sortorder, $maxheightmini; global $dolibarr_main_url_root; @@ -1322,7 +1328,6 @@ class FormFile function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload=0, $relativepath='', $permtodelete=1, $useinecm=0, $textifempty='', $maxlength=0, $url='', $addfilterfields=0) { global $user, $conf, $langs, $form; - global $bc; global $sortfield, $sortorder; global $search_doc_ref; @@ -1543,7 +1548,7 @@ class FormFile if (count($filearray) == 0) { - print ''; + print ''; if (empty($textifempty)) print $langs->trans("NoFileFound"); else print $textifempty; print ''; @@ -1600,7 +1605,6 @@ class FormFile public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null, $param='') { global $user, $conf, $langs, $user; - global $bc; global $sortfield, $sortorder; $langs->load("link"); @@ -1712,7 +1716,7 @@ class FormFile } if ($nboflinks == 0) { - print ''; + print ''; print $langs->trans("NoLinkFound"); print ''; } diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index caae068461a..097a912b6c1 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -831,22 +831,18 @@ if ($resql) if (empty($id)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->expensereport->lire; - $delallowed=$user->rights->expensereport->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->expensereport->lire; + $delallowed=$user->rights->expensereport->creer; + + print $formfile->showdocuments('massfilesarea_expensereport','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } } else diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 49cb1837d35..e046209a354 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -563,25 +563,18 @@ if ($resql) print "\n"; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - /* - * Show list of available documents - */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->ficheinter->lire; - $delallowed=$user->rights->ficheinter->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->ficheinter->lire; + $delallowed=$user->rights->ficheinter->creer; + print $formfile->showdocuments('massfilesarea_interventions','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 0b45f2d63a0..f3deb4b12a3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1176,26 +1176,20 @@ if ($resql) print '
'; print "\n"; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - /* - * Show list of available documents - */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); - - $filedir=$diroutputmassaction; - $genallowed=$user->rights->fournisseur->commande->lire; - $delallowed=$user->rights->fournisseur->commande->creer; - - print $formfile->showdocuments('massfilesarea_supplier_order','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } - $db->free($resql); + + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); + + $filedir=$diroutputmassaction; + $genallowed=$user->rights->fournisseur->commande->lire; + $delallowed=$user->rights->fournisseur->commande->creer; + + print $formfile->showdocuments('massfilesarea_supplier_order','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 31d6ba2f183..1e056292517 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1098,22 +1098,18 @@ if ($resql) print "\n"; /* - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->facture->lire; + $delallowed=$user->rights->facture->creer; + + print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); */ } else diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 23a748a12dc..72715ec27f1 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -542,25 +542,21 @@ print ''."\n"; if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); - $formfile = new FormFile($db); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index cb67168b214..f9fef88edce 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -494,25 +494,21 @@ print ''."\n"; if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); - $formfile = new FormFile($db); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } // End of page diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 5934e8dff55..76d70c1ad10 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -537,22 +537,18 @@ if ($resql) print ''."\n"; /* - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; - $genallowed=$user->rights->facture->lire; - $delallowed=$user->rights->facture->creer; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->facture->lire; + $delallowed=$user->rights->facture->creer; + + print $formfile->showdocuments('massfilesarea_orders','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); */ } else diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index ef990a7e4f0..9e57176250a 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -525,25 +525,21 @@ print ''."\n"; if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); - $formfile = new FormFile($db); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->mymodule->read; - $delallowed=$user->rights->mymodule->create; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; + + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index abf9f9cfd2a..1a7d248f83f 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -858,26 +858,19 @@ if ($resql) print ''."\n"; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - /* - * Show list of available documents - */ - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + $hidegeneratedfilelistifempty=1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; - $filedir=$diroutputmassaction; + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - $genallowed=$user->rights->supplier_proposal->lire; - $delallowed=$user->rights->supplier_proposal->creer; + $filedir=$diroutputmassaction; - print $formfile->showdocuments('massfilesarea_supplier_proposal','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + $genallowed=$user->rights->supplier_proposal->lire; + $delallowed=$user->rights->supplier_proposal->creer; + print $formfile->showdocuments('massfilesarea_supplier_proposal','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty); } else { From aac59f3e2114436146e02452818114e3a98f4e33 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 11:09:17 +0100 Subject: [PATCH 047/125] Fix escaping --- .../class/accountancycategory.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index dae58bf1520..92d0f9e4499 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -92,7 +92,7 @@ class AccountancyCategory // extends CommonObject // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_accounting_category("; - $sql.= "rowid,"; + if ($this->rowid > 0) $sql.= "rowid,"; $sql.= "code,"; $sql.= "label,"; $sql.= "range_account,"; @@ -103,16 +103,16 @@ class AccountancyCategory // extends CommonObject $sql.= "fk_country,"; $sql.= "active"; $sql.= ") VALUES ("; - $sql.= " ".(! isset($this->rowid)?'NULL':"'".$this->rowid."'").","; + if ($this->rowid > 0) $sql.= " ".$this->rowid.","; $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; $sql.= " ".(! isset($this->range_account)?'NULL':"'".$this->db->escape($this->range_account)."'").","; - $sql.= " ".(! isset($this->sens)?'NULL':"'".$this->sens."'").","; - $sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->category_type."'").","; + $sql.= " ".(! isset($this->sens)?'NULL':"'".$this->db->escape($this->sens)."'").","; + $sql.= " ".(! isset($this->category_type)?'NULL':"'".$this->db->escape($this->category_type)."'").","; $sql.= " ".(! isset($this->formula)?'NULL':"'".$this->db->escape($this->formula)."'").","; - $sql.= " ".(! isset($this->position)?'NULL':"'".$this->position."'").","; - $sql.= " ".(! isset($this->fk_country)?'NULL':"'".$this->fk_country."'").","; - $sql.= " ".(! isset($this->active)?'NULL':"'".$this->active."'").""; + $sql.= " ".(! isset($this->position)?'NULL':$this->db->escape($this->position)).","; + $sql.= " ".(! isset($this->fk_country)?'NULL':$this->db->escape($this->fk_country)).","; + $sql.= " ".(! isset($this->active)?'NULL':$this->db->escape($this->active)); $sql.= ")"; $this->db->begin(); From 0ff148da1f0331fabe5d79b5e015ffbf67916491 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 11:22:27 +0100 Subject: [PATCH 048/125] Fix import of chart account --- htdocs/core/modules/modAccounting.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 059118e2663..9bad202251e 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -251,10 +251,10 @@ class modAccounting extends DolibarrModules $this->import_fields_array[$r]=array('aa.fk_pcg_version'=>"Chartofaccounts*",'aa.account_number'=>"AccountAccounting*",'aa.label'=>"Label*",'aa.account_parent'=>"Accountparent","aa.fk_accounting_category"=>"AccountingCategory","aa.pcg_type"=>"Pcgtype*",'aa.pcg_subtype'=>'Pcgsubtype*','aa.active'=>'Status*','aa.datec'=>"DateCreation"); $this->import_regex_array[$r]=array('aa.fk_pcg_version'=>'pcg_version@'.MAIN_DB_PREFIX.'accounting_system','aa.account_number'=>'^\d{1,32}$','aa.label'=>'^.{1,255}$','aa.account_parent'=>'^\d{0,32}$','aa.fk_accounting_category'=>'rowid@'.MAIN_DB_PREFIX.'c_accounting_category','aa.pcg_type'=>'^.{1,20}$','aa.pcg_subtype'=>'^.{1,20}$','aa.active'=>'^0|1$','aa.datec'=>'^\d{4}-\d{2}-\d{2}$'); $this->import_convertvalue_array[$r]=array( - 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/accountancy/class/accountancycategory.class.php','class'=>'AccountingCategory','method'=>'fetch','dict'=>'DictionaryAccountancyCategory'), + 'aa.fk_accounting_category'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/accountancy/class/accountancycategory.class.php','class'=>'AccountancyCategory','method'=>'fetch','dict'=>'DictionaryAccountancyCategory'), 'aa.account_parent'=>array('rule'=>'zeroifnull'), ); - $this->import_examplevalues_array[$r]=array('aa.fk_pcg_version'=>"PCG99-ABREGE",'aa.account_number'=>"707",'aa.label'=>"Product sales",'aa.account_parent'=>"1407","aa.fk_accounting_category"=>"SALES","aa.pcg_type"=>"PROD",'aa.pcg_subtype'=>'PRODUCT','aa.active'=>'1','aa.datec'=>"2017-04-28"); + $this->import_examplevalues_array[$r]=array('aa.fk_pcg_version'=>"PCG99-ABREGE",'aa.account_number'=>"707",'aa.label'=>"Product sales",'aa.account_parent'=>"1407","aa.fk_accounting_category"=>"","aa.pcg_type"=>"PROD",'aa.pcg_subtype'=>'PRODUCT','aa.active'=>'1','aa.datec'=>"2017-04-28"); } } From 423918b9ffd62b99cbe3b6de33d5e72eeba56186 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 11:41:52 +0100 Subject: [PATCH 049/125] Include notrigger --- htdocs/contrat/class/contrat.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 9d40001ad50..e7bae75c3ed 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -261,9 +261,10 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int|string $date_start Date start (now if empty) + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function activateAll($user, $date_start='') + function activateAll($user, $date_start='', $notrigger=0) { if (empty($date_start)) $date_start = dol_now(); @@ -294,7 +295,7 @@ class Contrat extends CommonObject if (! $error && $this->statut == 0) { - $result=$this->validate($user); + $result=$this->validate($user, '', $notrigger); if ($result < 0) $error++; } From b4446764f864c538b21233bd36e81c7e1a5c811d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 14:48:25 +0100 Subject: [PATCH 050/125] Clean code of deprecated usage --- htdocs/adherents/card.php | 4 +- htdocs/adherents/type.php | 4 +- htdocs/categories/viewcat.php | 11 +++-- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/document.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 4 +- .../facture/class/facture-rec.class.php | 2 +- htdocs/compta/facture/class/facture.class.php | 2 +- htdocs/contact/agenda.php | 3 +- htdocs/contact/card.php | 3 +- htdocs/contrat/card.php | 4 +- htdocs/contrat/class/contrat.class.php | 2 +- .../core/class/commondocgenerator.class.php | 10 ++-- htdocs/core/class/commonobject.class.php | 5 +- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/lib/functions.lib.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 14 +++--- .../task/doc/doc_generic_task_odt.modules.php | 4 +- htdocs/don/card.php | 4 +- htdocs/expedition/card.php | 10 ++-- htdocs/expedition/shipment.php | 2 +- htdocs/expensereport/card.php | 2 +- htdocs/fichinter/card.php | 4 +- htdocs/fourn/commande/card.php | 2 +- htdocs/hrm/establishment/card.php | 48 +++++++++---------- htdocs/livraison/card.php | 6 +-- .../modulebuilder/template/myobject_card.php | 2 +- .../class/price_parser.class.php | 2 +- htdocs/product/inventory/card.php | 2 +- htdocs/product/stock/productlot_card.php | 2 +- htdocs/projet/card.php | 2 +- htdocs/projet/tasks.php | 2 +- htdocs/projet/tasks/comment.php | 2 +- htdocs/projet/tasks/task.php | 2 +- htdocs/projet/tasks/time.php | 4 +- htdocs/public/members/public_card.php | 2 +- htdocs/resource/class/dolresource.class.php | 2 +- htdocs/societe/card.php | 4 +- htdocs/societe/contact.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 2 +- htdocs/user/card.php | 2 +- htdocs/webservices/server_actioncomm.php | 2 +- htdocs/webservices/server_contact.php | 2 +- .../webservices/server_productorservice.php | 4 +- htdocs/webservices/server_project.php | 2 +- htdocs/webservices/server_thirdparty.php | 2 +- htdocs/website/websiteaccount_card.php | 2 +- 51 files changed, 108 insertions(+), 106 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 73f207abe91..65f9c65e641 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1003,7 +1003,7 @@ else if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); if ($res < 0) { dol_print_error($db); exit; } @@ -1272,7 +1272,7 @@ else if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); if ($res < 0) { dol_print_error($db); exit; } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index cc9fd872062..142fdb300e2 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -361,7 +361,7 @@ if ($rowid > 0) { $object = new AdherentType($db); $object->fetch($rowid); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); /* * Confirmation suppression @@ -692,7 +692,7 @@ if ($rowid > 0) { $object = new AdherentType($db); $object->fetch($rowid); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $head = member_type_prepare_head($object); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 1f7b41df085..f6a0417bbda 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -53,11 +53,12 @@ $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); $result=$object->fetch($id, $label); -$object->fetch_optionals($id,$extralabels); -if ($result <= 0) -{ - dol_print_error($db,$object->error); - exit; +if ($result <= 0) { + dol_print_error($db,$object->error); exit; +} +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db,$object->error); exit; } $type=$object->type; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b89263bae01..2f59df43803 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -934,7 +934,7 @@ if ($id > 0) $result2=$object->fetch_projet(); $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); - $result5=$object->fetch_optionals($id,$extralabels); + $result5=$object->fetch_optionals(); if ($listUserAssignedUpdated || $donotclearsession) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 46efeb95a54..1bbe5ddc6fc 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -100,7 +100,7 @@ if ($object->id > 0) $result2=$object->fetch_thirdparty(); $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); - $result5=$object->fetch_optionals($id,$extralabels); + $result5=$object->fetch_optionals(); if ($result1 < 0 || $result2 < 0 || $result3 < 0 || $result4 < 0 || $result5 < 0) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 9c72170b880..380edc5a472 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -505,7 +505,7 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1380b02d339..2b714bbeff8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1210,7 +1210,7 @@ class Propal extends CommonObject // get extrafields so they will be clone foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); + $line->fetch_optionals(); // Load dest object $clonedObj = clone $this; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 54c7db7d6ca..21975439872 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1804,7 +1804,7 @@ if ($action == 'create' && $user->rights->commande->creer) $author = new User($db); $author->fetch($object->user_author_id); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = commande_prepare_head($object); dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f89bcf534a2..b7ba839b144 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1024,7 +1024,7 @@ class Commande extends CommonOrder // get lines so they will be clone foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); + $line->fetch_optionals(); // Load source object $objFrom = clone $this; @@ -1145,7 +1145,7 @@ class Commande extends CommonOrder $line->marque_tx = $marginInfos[2]; // get extrafields from original line - $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + $object->lines[$i]->fetch_optionals(); foreach($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 84b61817a28..7a08cc6c97e 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -501,7 +501,7 @@ class FactureRec extends CommonInvoice $line->price = $objp->price; $line->remise = $objp->remise; - $extralabelsline = $line->fetch_optionals($line->id,$extrafieldsline); + $extralabelsline = $line->fetch_optionals($line->id); // Multicurrency $line->fk_multicurrency = $objp->fk_multicurrency; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index aba627dd8a2..0c48a4336d4 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1031,7 +1031,7 @@ class Facture extends CommonInvoice $line->pa_ht = $marginInfos[0]; // get extrafields from original line - $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + $object->lines[$i]->fetch_optionals(); foreach($object->lines[$i]->array_options as $options_key => $value) $line->array_options[$options_key] = $value; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index c885f0869de..c513db1b49f 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -190,7 +190,8 @@ else $object = new Contact($db); $res=$object->fetch($id, $user); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); + if ($res < 0) { dol_print_error($db,$object->error); exit; } // Show tabs $head = contact_prepare_head($object); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 9c35714dcd5..7d024e6f096 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -468,7 +468,8 @@ else $object = new Contact($db); $res=$object->fetch($id, $user); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); + if ($res < 0) { dol_print_error($db,$object->error); exit; } // Show tabs $head = contact_prepare_head($object); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0bbb509b7fa..d74c677f018 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1709,7 +1709,7 @@ else if (is_array($extralabelslines) && count($extralabelslines)>0) { print ''; $line = new ContratLigne($db); - $line->fetch_optionals($objp->rowid,$extralabelslines); + $line->fetch_optionals($objp->rowid); print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); print ''; } @@ -1783,7 +1783,7 @@ else if (is_array($extralabelslines) && count($extralabelslines)>0) { print ''; $line = new ContratLigne($db); - $line->fetch_optionals($objp->rowid,$extralabelslines); + $line->fetch_optionals($objp->rowid); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$colspan)); print ''; } diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e7bae75c3ed..0b84b05b6fd 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -795,7 +795,7 @@ class Contrat extends CommonObject // Retreive all extrafield for contract // fetch optionals attributes and labels - $line->fetch_optionals($line->id,$extralabelsline); + $line->fetch_optionals(); $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index aeca3d5a102..c9c250ee1fa 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -203,7 +203,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('societe',true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { @@ -274,7 +274,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('socpeople', true); - $object->fetch_optionals($object->id, $extralabels); + $object->fetch_optionals(); foreach($extrafields->attribute_label as $key => $label) { @@ -457,7 +457,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); } @@ -524,7 +524,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $line->fetch_optionals($line->rowid,$extralabels); + $line->fetch_optionals(); $resarray = $this->fill_substitutionarray_with_extrafields($line,$resarray,$extrafields,$array_key=$array_key,$outputlangs); @@ -592,7 +592,7 @@ abstract class CommonDocGenerator require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('shipment',true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $array_shipment = $this->fill_substitutionarray_with_extrafields($object,$array_shipment,$extrafields,$array_key,$outputlangs); }*/ diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 07993bb1d97..f69e842ec81 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3670,8 +3670,7 @@ abstract class CommonObject foreach ($this->lines as $line) { //Line extrafield - $line->fetch_optionals($line->id,$extralabelslines); - + $line->fetch_optionals(); //if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line))) @@ -4498,7 +4497,7 @@ abstract class CommonObject } else { - dol_syslog("Warning: fetch_optionals was called with param $optionsArray defined when you should pass null now", LOG_WARNING); + dol_syslog("Warning: fetch_optionals was called with param optionsArray defined when you should pass null now", LOG_WARNING); } $table_element = $this->table_element; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 94ab828ee39..6e25c1ca730 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1185,7 +1185,7 @@ class FormMail extends Form $extralabels = $extrafields->fetch_name_optionals_label('product', true); $product = new Product($this->db); $product->fetch($line->fk_product, '', '', 1); - $product->fetch_optionals($product->id, $extralabels); + $product->fetch_optionals(); foreach ($extrafields->attribute_label as $key => $label) { $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0cc2fb0446f..ce95f2912c8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5806,7 +5806,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $extrafieldstmp = new ExtraFields($db); $extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); - $object->fetch_optionals($object->id, $extralabels); + $object->fetch_optionals(); foreach ($extrafieldstmp->attribute_label as $key => $label) { $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index be4f5898f85..35e8ace270e 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -136,10 +136,10 @@ class doc_generic_project_odt extends ModelePDFProjects require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); - + return $resarray; } @@ -198,18 +198,18 @@ class doc_generic_project_odt extends ModelePDFProjects if ($contact['source']=='external') { $ret[$pc.'isInternal'] = ''; // not internal - + $ct = new Contact($this->db); $ct->fetch($contact['id']); $ret[$pc.'phone_pro'] = $ct->phone_pro; $ret[$pc.'phone_perso'] = $ct->phone_perso; $ret[$pc.'phone_mobile'] = $ct->phone_mobile; - + // fetch external user extrafields require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); $extrafields=new ExtraFields($this->db); $extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true); - $extrafields_num = $ct->fetch_optionals($ct->id, $extralabels); + $extrafields_num = $ct->fetch_optionals(); //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG); foreach($ct->array_options as $efkey => $efval) { dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG); @@ -217,7 +217,7 @@ class doc_generic_project_odt extends ModelePDFProjects } } elseif ($contact['source']=='internal') { $ret[$pc.'isInternal'] = '1'; // this is an internal user - + $ct = new User($this->db); $ct->fetch($contact['id']); $ret[$pc.'phone_pro'] = $ct->office_phone; @@ -1067,7 +1067,7 @@ class doc_generic_project_odt extends ModelePDFProjects $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index 17e08dd4fd3..c846d7f6a23 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -139,7 +139,7 @@ class doc_generic_task_odt extends ModelePDFTask require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey,true); - $object->fetch_optionals($object->id,$extralabels); + $object->fetch_optionals(); $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs); } @@ -830,7 +830,7 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler=null; // Destroy object $this->result = array('fullpath'=>$file); - + return 1; // Success } else diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 01164c47508..3d0e9e9623a 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -411,7 +411,7 @@ if (! empty($id) && $action == 'edit') if ($result < 0) { dol_print_error($db,$object->error); exit; } - $result=$object->fetch_optionals($object->id,$extralabels); + $result=$object->fetch_optionals(); if ($result < 0) { dol_print_error($db); exit; } @@ -539,7 +539,7 @@ if (! empty($id) && $action != 'edit') if ($result < 0) { dol_print_error($db,$object->error); exit; } - $result=$object->fetch_optionals($object->id,$extralabels); + $result=$object->fetch_optionals(); if ($result < 0) { dol_print_error($db); exit; } diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8fc21e0653e..82d6c746640 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1068,7 +1068,7 @@ if ($action == 'create') // copy from order $orderExtrafields = new Extrafields($db); $orderExtrafieldLabels = $orderExtrafields->fetch_name_optionals_label($object->table_element); - if ($object->fetch_optionals($object->id, $orderExtrafieldLabels) > 0) { + if ($object->fetch_optionals() > 0) { $expe->array_options = array_merge($expe->array_options, $object->array_options); } print $object->showOptionals($extrafields, 'edit'); @@ -1605,9 +1605,9 @@ if ($action == 'create') $orderLineExtrafields = new Extrafields($db); $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); $srcLine = new OrderLine($db); - $srcLine->fetch_optionals($line->id,$orderLineExtrafieldLabels); // fetch extrafields also available in orderline + $srcLine->fetch_optionals($line->id); // fetch extrafields also available in orderline $line = new ExpeditionLigne($db); - $line->fetch_optionals($object->id,$extralabelslines); + $line->fetch_optionals($line->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); print ''; print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan),$indiceAsked); @@ -1661,7 +1661,7 @@ else if ($id || $ref) $soc = new Societe($db); $soc->fetch($object->socid); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head=shipping_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, 'sending'); @@ -2451,7 +2451,7 @@ else if ($id || $ref) if (is_array($extralabelslines) && count($extralabelslines)>0) { $colspan= empty($conf->productbatch->enabled) ? 5 : 6; $line = new ExpeditionLigne($db); - $line->fetch_optionals($lines[$i]->id,$extralabelslines); + $line->fetch_optionals($lines[$i]->id); print ''; if ($action == 'editline' && $lines[$i]->id == $line_id) { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index d172d1034ca..0141fc1dea5 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -247,7 +247,7 @@ if ($id > 0 || ! empty($ref)) $author = new User($db); $author->fetch($object->user_author_id); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = commande_prepare_head($object); dol_fiche_head($head, 'shipping', $langs->trans("CustomerOrder"), -1, 'order'); diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 59c8b719d4e..a71ba9762b6 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1434,7 +1434,7 @@ else { $result = $object->fetch($id, $ref); - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); if ($result > 0) { diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index e7839f66da2..3eddb02c28b 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1476,7 +1476,7 @@ else if ($id > 0 || ! empty($ref)) $extrafieldsline = new ExtraFields($db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element); - $line->fetch_optionals($line->rowid, $extralabelslines); + $line->fetch_optionals(); print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5)); @@ -1521,7 +1521,7 @@ else if ($id > 0 || ! empty($ref)) $extrafieldsline = new ExtraFields($db); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element); - $line->fetch_optionals($line->rowid, $extralabelslines); + $line->fetch_optionals(); print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5)); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index da3f79d94d0..15148cbcc2a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1642,7 +1642,7 @@ elseif (! empty($object->id)) $author = new User($db); $author->fetch($object->user_author_id); - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); $head = ordersupplier_prepare_head($object); diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php index 3a08ae197a2..6180393e1df 100644 --- a/htdocs/hrm/establishment/card.php +++ b/htdocs/hrm/establishment/card.php @@ -93,7 +93,7 @@ else if ($action == 'add') $object->fk_user_author = $user->id; $object->datec = dol_now(); - + $id = $object->create($user); @@ -123,7 +123,7 @@ else if ($action == 'add') else if ($action == 'update') { $error = 0; - + if (! $cancel) { $name = GETPOST('name', 'alpha'); @@ -132,7 +132,7 @@ else if ($action == 'update') $error ++; } - if (empty($error)) + if (empty($error)) { $object->name = GETPOST('name', 'alpha'); $object->address = GETPOST('address', 'alpha'); @@ -141,7 +141,7 @@ else if ($action == 'update') $object->country_id = GETPOST('country_id', 'int'); $object->fk_user_mod = $user->id; $object->status = GETPOST('status','int'); - + $result = $object->update($user); if ($result > 0) @@ -201,18 +201,18 @@ if ($action == 'create') print ''; print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array ( 'town', - 'selectcountry_id' + 'selectcountry_id' ), 6); print ''; print ''; - + // Town print ''; print ''.fieldLabel('Town','town',0).''; print ''; print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( 'zipcode', - 'selectcountry_id' + 'selectcountry_id' )); print ''; print ''; @@ -234,7 +234,7 @@ if ($action == 'create') print ''; print ''; - + dol_fiche_end(); print '
'; @@ -286,12 +286,12 @@ if (($id || $ref) && $action == 'edit') print ''.fieldLabel('Zip','zipcode',0).''; print $formcompany->select_ziptown($object->zip, 'zipcode', array ( 'town', - 'selectcountry_id' + 'selectcountry_id' ), 6) . ''; print ''.fieldLabel('Town','town',0).''; print $formcompany->select_ziptown($object->town, 'town', array ( 'zipcode', - 'selectcountry_id' + 'selectcountry_id' )) . ''; // Country @@ -300,7 +300,7 @@ if (($id || $ref) && $action == 'edit') print $form->select_country($object->fk_country,'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); print ''; - print ''; + print ''; // Status print ''.fieldLabel('Status','status',1).''; @@ -325,11 +325,11 @@ if (($id || $ref) && $action == 'edit') if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); - + $res = $object->fetch_optionals(); + $head = establishment_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("Establishment"), -1, 'building'); - + // Confirmation to delete if ($action == 'delete') { @@ -337,22 +337,22 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } - + // Object card // ------------------------------------------------------------ - + $linkback = '' . $langs->trans("BackToList") . ''; - + $morehtmlref='
'; $morehtmlref.='
'; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', $morehtmlref); - - + + print '
'; //print '
'; print '
'; - print ''."\n"; + print '
'."\n"; // Name print ''; @@ -393,9 +393,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; - + print '

'; - + dol_fiche_end(); /* @@ -407,6 +407,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$langs->trans('Delete').''; print '
'; } - + llxFooter(); $db->close(); diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 41091b36e08..b2218508ef6 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -571,7 +571,7 @@ else // copy from expedition $expeditionExtrafields = new Extrafields($db); $expeditionExtrafieldLabels = $expeditionExtrafields->fetch_name_optionals_label($expedition->table_element); - if ($expedition->fetch_optionals($object->origin_id, $expeditionExtrafieldLabels) > 0) { + if ($expedition->fetch_optionals($object->origin_id) > 0) { $object->array_options = array_merge($object->array_options, $expedition->array_options); } } @@ -674,12 +674,12 @@ else $colspan=2; $mode = ($object->statut == 0) ? 'edit' : 'view'; $line = new LivraisonLigne($db); - $line->fetch_optionals($object->lines[$i]->id,$extralabelslines); + $line->fetch_optionals($object->lines[$i]->id); if ($action = 'create_delivery') { $srcLine = new ExpeditionLigne($db); $expeditionLineExtrafields = new Extrafields($db); $expeditionLineExtrafieldLabels = $expeditionLineExtrafields->fetch_name_optionals_label($srcLine->table_element); - $srcLine->fetch_optionals($expedition->lines[$i]->id,$expeditionLineExtrafieldLabels); + $srcLine->fetch_optionals($expedition->lines[$i]->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); } print ''; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index bc1e9fc7d51..a82ec237006 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -228,7 +228,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = myobjectPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("MyObject"), -1, 'myobject@mymodule'); diff --git a/htdocs/product/dynamic_price/class/price_parser.class.php b/htdocs/product/dynamic_price/class/price_parser.class.php index c281816e99b..fc986a9e051 100644 --- a/htdocs/product/dynamic_price/class/price_parser.class.php +++ b/htdocs/product/dynamic_price/class/price_parser.class.php @@ -156,7 +156,7 @@ class PriceParser //Retrieve all extrafield for product and add it to values $extrafields = new ExtraFields($this->db); $extralabels = $extrafields->fetch_name_optionals_label('product', true); - $product->fetch_optionals($product->id, $extralabels); + $product->fetch_optionals(); foreach ($extrafields->attribute_label as $key=>$label) { $values["extrafield_".$key] = $product->array_options['options_'.$key]; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index e393721c47d..84db46c879f 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -194,7 +194,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = inventoryPrepareHead($object); dol_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'inventory'); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 1d9a7420740..8e639c90108 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -305,7 +305,7 @@ if ($action == 'create') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); //print load_fiche_titre($langs->trans("Batch")); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index ddfa1733f8c..71be9b5d4a3 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -660,7 +660,7 @@ elseif ($object->id > 0) * Show or edit */ - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); // To verify role of users $userAccess = $object->restrictedProjectArea($user,'read'); diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 47de9ce2b19..11367951976 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -207,7 +207,7 @@ if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); - $res=$object->fetch_optionals($object->id,$extralabels_projet); + $res=$object->fetch_optionals(); // To verify role of users diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index 49072299ac4..fb553a1b837 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -97,7 +97,7 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 479366ab586..3d1ccfb8fe1 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -207,7 +207,7 @@ if ($id > 0 || ! empty($ref)) { if ($object->fetch($id,$ref) > 0) { - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ce2e1c32889..49e917e4b61 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -288,13 +288,13 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { $result=$projectstatic->fetch($projectidforalltimes); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); + $res=$projectstatic->fetch_optionals(); } elseif ($object->fetch($id, $ref) >= 0) { $result=$projectstatic->fetch($object->fk_project); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); - $res=$projectstatic->fetch_optionals($object->id,$extralabels_projet); + $res=$projectstatic->fetch_optionals(); $object->project = clone $projectstatic; } diff --git a/htdocs/public/members/public_card.php b/htdocs/public/members/public_card.php index 8f28cd12827..f21a4d1a338 100644 --- a/htdocs/public/members/public_card.php +++ b/htdocs/public/members/public_card.php @@ -77,7 +77,7 @@ if ($id > 0) { $res=$object->fetch($id); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); print load_fiche_titre($langs->trans("MemberCard"), '', ''); diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index c7126c6d3bb..7db33a9bfae 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -566,7 +566,7 @@ class Dolresource extends CommonObject // Retreive all extrafield for thirdparty // fetch optionals attributes and labels - $line->fetch_optionals($line->id,$extralabels); + $line->fetch_optionals(); $this->lines[] = $line; } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index b48c80a7a24..362834b316d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1418,7 +1418,7 @@ else if ($socid) { - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } $head = societe_prepare_head($object); @@ -2011,7 +2011,7 @@ else * View */ - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + if (!empty($object->id)) $res=$object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index d57f61045c0..32575beb8c7 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -150,7 +150,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) else { - if (!empty($object->id)) $res=$object->fetch_optionals($object->id,$extralabels); + if (!empty($object->id)) $res=$object->fetch_optionals(); //if ($res < 0) { dol_print_error($db); exit; } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 440551bd925..c4f5c5c6ba9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -358,7 +358,7 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index c6ae3642bc9..91eff1b5a8a 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1042,7 +1042,7 @@ class SupplierProposal extends CommonObject // get extrafields so they will be clone foreach($this->lines as $line) - $line->fetch_optionals($line->rowid); + $line->fetch_optionals(); // Load source object $objFrom = clone $this; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ba327e7c9f1..aa169253fb3 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1176,7 +1176,7 @@ else { $object->fetch($id, '', '', 1); if ($res < 0) { dol_print_error($db,$object->error); exit; } - $res=$object->fetch_optionals($object->id,$extralabels); + $res=$object->fetch_optionals(); // Check if user has rights $object->getrights(); diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index 4f0081551ca..a00e014d88a 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -306,7 +306,7 @@ function getActionComm($authentication,$id) $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('actioncomm',true); //Get extrafield values - $actioncomm->fetch_optionals($actioncomm->id,$extralabels); + $actioncomm->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/webservices/server_contact.php b/htdocs/webservices/server_contact.php index fe4fcc3378f..6791864ba8b 100644 --- a/htdocs/webservices/server_contact.php +++ b/htdocs/webservices/server_contact.php @@ -311,7 +311,7 @@ function getContact($authentication,$id,$ref_ext) $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('socpeople',true); //Get extrafield values - $contact->fetch_optionals($contact->id,$extralabels); + $contact->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 00dcd2fe4fc..c4c4d40191e 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -425,7 +425,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('product',true); //Get extrafield values - $product->fetch_optionals($product->id,$extralabels); + $product->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { @@ -1096,7 +1096,7 @@ function getProductsForCategory($authentication,$id,$lang='') $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('product',true); //Get extrafield values - $obj->fetch_optionals($obj->id,$extralabels); + $obj->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index 9e10b0212ec..bc26de37601 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -377,7 +377,7 @@ function getProject($authentication,$id='',$ref='') $extralabels=$extrafields->fetch_name_optionals_label('societe',true); //Get extrafield values - $project->fetch_optionals($project->id,$extralabels); + $project->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { $project_result_fields=array_merge($project_result_fields,array('options_'.$key => $project->array_options['options_'.$key])); diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 8e358e21924..c2236368d18 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -357,7 +357,7 @@ function getThirdParty($authentication,$id='',$ref='',$ref_ext='') $extrafields=new ExtraFields($db); $extralabels=$extrafields->fetch_name_optionals_label('societe',true); //Get extrafield values - $thirdparty->fetch_optionals($thirdparty->id,$extralabels); + $thirdparty->fetch_optionals(); foreach($extrafields->attribute_label as $key=>$label) { diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 9918b0b3022..8daab76e38c 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -221,7 +221,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if ($object->fk_soc >0 && empty($socid)) $socid = $object->fk_soc; - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals(); $head = websiteaccountPrepareHead($object); dol_fiche_head($head, 'card', $langs->trans("WebsiteAccount"), -1, 'websiteaccount@website'); From 0c59d536ba7faa36486eb8fc13f86195e247222a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 21:59:11 +0100 Subject: [PATCH 051/125] More accurante message --- htdocs/cron/class/cronjob.class.php | 3 ++- htdocs/langs/en_US/cron.lang | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index a63982c5b12..74be91ec1ab 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -925,7 +925,8 @@ class Cronjob extends CommonObject $ret=dol_include_once($this->classesname); if ($ret===false || (! class_exists($this->objectname))) { - $this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname); + if ($ret===false) $this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname); + else $this->error=$langs->trans('CronCannotLoadObject',$this->classesname,$this->objectname); dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); $this->lastoutput = $this->error; $this->lastresult = -1; diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 7f3385bef12..8947fcc47ac 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -74,7 +74,8 @@ CronFrom=From CronType=Job type CronType_method=Call method of a PHP Class CronType_command=Shell command -CronCannotLoadClass=Cannot load class %s or object %s +CronCannotLoadClass=Cannot load class file %s (to use class %s) +CronCannotLoadObject=Class file %s was loaded, but object %s was not found into it UseMenuModuleToolsToAddCronJobs=Go into menu "Home - Admin tools - Scheduled jobs" to see and edit scheduled jobs. JobDisabled=Job disabled MakeLocalDatabaseDumpShort=Local database backup From f03fcef2d59337b5520eea358bea953c1a0cae74 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 22:41:02 +0100 Subject: [PATCH 052/125] Fix: missing the reposition --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d74c677f018..e27bbfb7655 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1895,7 +1895,7 @@ else } if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) { - print ''; + print ''; print img_picto($tmpactiontext, $tmpactionpicto); print ''; } From 0d0451e5c79d4710fa49f7dc5ae6ff7a9a0197ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 22:43:03 +0100 Subject: [PATCH 053/125] Code comment --- htdocs/core/modules/syslog/mod_syslog_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/syslog/mod_syslog_file.php b/htdocs/core/modules/syslog/mod_syslog_file.php index 92a70ab3f62..688f963f455 100644 --- a/htdocs/core/modules/syslog/mod_syslog_file.php +++ b/htdocs/core/modules/syslog/mod_syslog_file.php @@ -109,7 +109,7 @@ class mod_syslog_file extends LogHandler implements LogHandlerInterface if (empty($conf->global->SYSLOG_FILE)) $tmp=DOL_DATA_ROOT.'/dolibarr.log'; else $tmp=str_replace('DOL_DATA_ROOT', DOL_DATA_ROOT, $conf->global->SYSLOG_FILE); - if (! empty($conf->global->SYSLOG_FILE_ONEPERSESSION)) // file depend on session name that is same for all user, not per user value of the session id + if (! empty($conf->global->SYSLOG_FILE_ONEPERSESSION)) // file depend on session name (Note that session name is same for all users and is not a per user value) { $suffixinfilename = '_'.session_name(); } From 9114a28e88203c42e69fcf7171ccbb49fd137bef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Feb 2018 22:41:02 +0100 Subject: [PATCH 054/125] Fix: missing the reposition --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 08c43551509..7eedec6f824 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1868,7 +1868,7 @@ else } if (($tmpaction=='activateline' && $user->rights->contrat->activer) || ($tmpaction=='unactivateline' && $user->rights->contrat->desactiver)) { - print ''; + print ''; print img_picto($tmpactiontext, $tmpactionpicto); print ''; } From 1d6baf5f2bd69806314a82b9bdb449cad92fba36 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 22 Feb 2018 10:16:53 +0100 Subject: [PATCH 055/125] Fix: Not showing link to ad event if module is disabled --- htdocs/core/class/html.formactions.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 785ada1429c..31c33de889b 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2012 Regis Houssin - * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2010-2018 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 @@ -187,10 +187,12 @@ class FormActions $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); - $buttontoaddnewevent = ''; - $buttontoaddnewevent.= $langs->trans("AddEvent"); - $buttontoaddnewevent.= ''; - print load_fiche_titre($title, $buttontoaddnewevent, ''); + if ($conf->agenda->enabled) { + $buttontoaddnewevent = ''; + $buttontoaddnewevent.= $langs->trans("AddEvent"); + $buttontoaddnewevent.= ''; + } + print load_fiche_titre($title, $buttontoaddnewevent, ''); $page=0; $param=''; $sortfield='a.datep'; From 51cfb9795ed8c4290ed83b8dbeb8f7791f513658 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 11:26:41 +0100 Subject: [PATCH 056/125] Fix bad picto --- htdocs/core/class/commoninvoice.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 9d7ae9d0998..e0517ac864c 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -457,7 +457,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('Bill'.$prefix.'StatusDraft'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('StatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('Bill'.$prefix.'StatusNotPaid'); return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('Bill'.$prefix.'StatusStarted'); } @@ -475,7 +475,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1'); return img_picto($langs->trans('BillStatusStarted'),'statut3'); } @@ -493,7 +493,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return img_picto($langs->trans('BillStatusDraft'),'statut0').' '.$langs->trans('BillStatusDraft'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return img_picto($langs->trans('BillStatusCanceled'),'statut5').' '.$langs->trans('Bill'.$prefix.'StatusCanceled'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9').' '.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); if ($alreadypaid <= 0) return img_picto($langs->trans('BillStatusNotPaid'),'statut1').' '.$langs->trans('BillStatusNotPaid'); return img_picto($langs->trans('BillStatusStarted'),'statut3').' '.$langs->trans('BillStatusStarted'); } @@ -512,7 +512,7 @@ abstract class CommonInvoice extends CommonObject { if ($status == 0) return ''.$langs->trans('Bill'.$prefix.'StatusDraft').' '.img_picto($langs->trans('BillStatusDraft'),'statut0'); if (($status == 3 || $status == 2) && $alreadypaid <= 0) return ''.$langs->trans('Bill'.$prefix.'StatusCanceled').' '.img_picto($langs->trans('BillStatusCanceled'),'statut5'); - if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut7'); + if (($status == 3 || $status == 2) && $alreadypaid > 0) return ''.$langs->trans('Bill'.$prefix.'StatusClosedPaidPartially').' '.img_picto($langs->trans('BillStatusClosedPaidPartially'),'statut9'); if ($alreadypaid <= 0) { if ($type == self::TYPE_CREDIT_NOTE) return ''.$langs->trans('Bill'.$prefix.'StatusNotRefunded').' '.img_picto($langs->trans('StatusNotRefunded'),'statut1'); From 479c4b4d7795c877ea97a8d807df9da33cd7ba35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 12:15:11 +0100 Subject: [PATCH 057/125] Fix look and feel v7 --- htdocs/cron/card.php | 2 +- htdocs/cron/class/cronjob.class.php | 63 +++++++++++++++++++++++++++++ htdocs/cron/info.php | 2 +- htdocs/cron/list.php | 23 ++++++----- 4 files changed, 79 insertions(+), 11 deletions(-) diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index 8e540c799fe..8c97bc4e2c8 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -557,7 +557,7 @@ else dol_fiche_head($head, 'card', $langs->trans("CronTask"), -1, 'cron'); - $linkback = '' . $langs->trans("BackToList") . ''; + $linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; $morehtmlref.='
'; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index a63982c5b12..46ad08f849b 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -805,6 +805,69 @@ class Cronjob extends CommonObject $this->libname = ''; } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; + + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + + $result = ''; + $companylink = ''; + + $label = '' . $langs->trans("CronJob") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + + $url = DOL_URL_ROOT.'/cron/card.php?id='.$this->id; + + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } + + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowCronJob"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); + + $linkstart = ''; + $linkend=''; + + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + return $result; + } + + /** * Load object information * diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index d3365abb90b..18bfde73bde 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -50,7 +50,7 @@ $head = cron_prepare_head($object); dol_fiche_head($head, 'info', $langs->trans("CronTask"), -1, 'cron'); -$linkback = '' . $langs->trans("BackToList") . ''; +$linkback = '' . $langs->trans("BackToList") . ''; $morehtmlref='
'; $morehtmlref.='
'; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 3933a30a54b..ca21a40635a 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -38,6 +38,7 @@ if (!$user->rights->cron->read) accessforbidden(); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); $id=GETPOST('id','int'); +$contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'cronjoblist'; // To manage different context of search $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); @@ -50,9 +51,6 @@ $pagenext = $page + 1; if (! $sortfield) $sortfield='t.status'; if (! $sortorder) $sortorder='ASC'; -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$contextpage='cronjoblist'; - $status=GETPOST('status','int'); if ($status == '') $status=-2; @@ -151,6 +149,7 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex */ $form = new Form($db); +$cronjob = new Cronjob($db); $pagetitle=$langs->trans("CronList"); @@ -280,6 +279,9 @@ if (! empty($conf->global->CRON_WARNING_DELAY_HOURS)) $text.=$langs->trans("Warn print info_admin($text); print '
'; +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +//$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +//$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; print ''; @@ -340,19 +342,22 @@ if ($num > 0) if (empty($obj)) break; if (! verifCond($obj->test)) continue; // Discard line with test = false + $object->id = $obj->rowid; + $object->ref = $obj->rowid; + $object->label = $obj->label; + print ''; print ''; print ''; + print ''; } else { - print ''; + print ''; } } else diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index b6584f8d909..c34574791c1 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -42,14 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once '../lib/mymodule.lib.php'; // Translations -$langs->load("errors"); -$langs->load("admin"); -$langs->load("mymodule@mymodule"); +$langs->loadLangs(array("errors","admin","mymodule@mymodule")); // Access control -if (! $user->admin) { - accessforbidden(); -} +if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); @@ -73,7 +69,7 @@ $page_name = "MyModuleAbout"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 19908d33546..58a572a42ac 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -71,7 +71,7 @@ $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); From f7ecac8734e0edba02f5ea6935b842a1cd96679c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 11:40:20 +0100 Subject: [PATCH 069/125] Fix look and feel v7 --- htdocs/admin/modules.php | 8 ++++---- htdocs/modulebuilder/template/admin/about.php | 10 +++------- htdocs/modulebuilder/template/admin/setup.php | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ee17e647863..00c8d14219e 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -741,12 +741,12 @@ if ($mode == 'common') if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs)) { $urltouse=dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1); - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } else { $urltouse=$urlpage; - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } } } @@ -754,11 +754,11 @@ if ($mode == 'common') } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''; + print ''; } else { - print ''; + print ''; } } else diff --git a/htdocs/modulebuilder/template/admin/about.php b/htdocs/modulebuilder/template/admin/about.php index b6584f8d909..c34574791c1 100644 --- a/htdocs/modulebuilder/template/admin/about.php +++ b/htdocs/modulebuilder/template/admin/about.php @@ -42,14 +42,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once '../lib/mymodule.lib.php'; // Translations -$langs->load("errors"); -$langs->load("admin"); -$langs->load("mymodule@mymodule"); +$langs->loadLangs(array("errors","admin","mymodule@mymodule")); // Access control -if (! $user->admin) { - accessforbidden(); -} +if (! $user->admin) accessforbidden(); // Parameters $action = GETPOST('action', 'alpha'); @@ -73,7 +69,7 @@ $page_name = "MyModuleAbout"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 19908d33546..58a572a42ac 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -71,7 +71,7 @@ $page_name = "MyModuleSetup"; llxHeader('', $langs->trans($page_name)); // Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans($page_name), $linkback, 'object_mymodule@mymodule'); From 36cc1c6ca95feb4111cff39d09e45012d1807c64 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Fri, 23 Feb 2018 11:59:22 +0100 Subject: [PATCH 070/125] FIX: solve column mismatch in user card's usergroup list + code cleanup --- htdocs/user/card.php | 109 +++++++++++++++++++------------------------ 1 file changed, 49 insertions(+), 60 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 1885740b489..495ff14a062 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -75,6 +75,9 @@ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $canreadgroup=(! empty($user->admin) || $user->rights->user->group_advance->read); $caneditgroup=(! empty($user->admin) || $user->rights->user->group_advance->write); } +if(! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $caneditgroup = $conf->entity == 1 && ! empty($user->admin) && empty($user->entity); +} // Define value to know what current user can do on properties of edited user if ($id) { @@ -1791,41 +1794,21 @@ else print '
'; - print ''; - print img_picto('', 'object_cron').' '; - print $obj->rowid; - print ''; + print $object->getNomUrl(1); print ''; if (! empty($obj->label)) { - print ''.$langs->trans($obj->label).''; + $object->ref = $obj->label; + print $object->getNomUrl(0, '', 1); + $object->ref = $obj->rowid; } else { @@ -430,7 +435,7 @@ if ($num > 0) print ''; if ($user->rights->cron->create) { - print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."&backtourl=".urlencode($_SERVER["PHP_SELF"])."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; + print "rowid."&action=edit".($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'').$param."&backtourl=".urlencode($_SERVER["PHP_SELF"].($param?'?'.$param:''))."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')."  "; } if ($user->rights->cron->delete) { From 41c663f03f8a09bef1b3b76e5ad93b0acec1143f Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Thu, 22 Feb 2018 12:22:31 +0000 Subject: [PATCH 058/125] Fixed issue with elementarray null if num_rows = 0 --- htdocs/projet/class/project.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8dbce2790fa..c8096559c9c 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -584,10 +584,10 @@ class Project extends CommonObject $i++; } $this->db->free($result); - - /* Return array */ - return $elements; } + + /* Return array even if empty*/ + return $elements; } else { From a27ed541284b4849c002e4085b37a0750665f9dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 16:40:48 +0100 Subject: [PATCH 059/125] Fix sort order of email templates --- htdocs/core/class/html.formmail.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 6e25c1ca730..04f4aa020a3 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -999,7 +999,8 @@ class FormMail extends Form if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; - $sql.= $db->order("position,lang,label","ASC"); + if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' + else $sql.= $db->order("position,lang,label","ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined if ($id == -1) $sql.= $db->plimit(1); //print $sql; From 76543023a1d000fb92810b571362f8827b085052 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 17:05:24 +0100 Subject: [PATCH 060/125] Fix missing substitution key --- htdocs/core/lib/functions.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ce95f2912c8..b83257419b6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5703,6 +5703,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; + $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; if (is_object($object) && $object->element == 'shipping') { @@ -5766,11 +5767,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); } if (is_object($object->projet) && $object->projet->id > 0) From 420fe3a07abe63e553558c391ec2f70be76c63f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 17:05:45 +0100 Subject: [PATCH 061/125] Clean code --- 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 04f4aa020a3..922980f62dd 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -982,7 +982,7 @@ class FormMail extends Form * @param string $type_template Get message for type=$type_template, type='all' also included. * @param string $user Use template public or limited to this user * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with position = 0, or 0 for all + * @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position * @param int $active 1=Only active template, 0=Only disabled, -1=All * @return array array('topic'=>,'content'=>,..) */ @@ -1001,7 +1001,7 @@ class FormMail extends Form if ($id == -1) $sql.= " AND position=0"; if (is_object($outputlangs)) $sql.= $db->order("position,lang,label","ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' else $sql.= $db->order("position,lang,label","ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined - if ($id == -1) $sql.= $db->plimit(1); + $sql.= $db->plimit(1); //print $sql; $resql = $db->query($sql); From 3f9a9f20ce65525bfb903caf37f779a30fa3665f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Feb 2018 17:05:24 +0100 Subject: [PATCH 062/125] Fix missing substitution key --- htdocs/core/lib/functions.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8f2fb50b0dc..a3a12179a6e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5442,6 +5442,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__THIRDPARTY_ID__'] = '__THIRDPARTY_ID__'; $substitutionarray['__THIRDPARTY_NAME__'] = '__THIRDPARTY_NAME__'; + $substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__'; if (is_object($object) && $object->element == 'shipping') { @@ -5505,11 +5506,13 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); } if (is_object($object->projet) && $object->projet->id > 0) From 6793d826b704ad8e0468cbcf6ee5ef17d7f2c70f Mon Sep 17 00:00:00 2001 From: dolibarr95 <24292300+dolibarr95@users.noreply.github.com> Date: Fri, 23 Feb 2018 10:14:54 +0100 Subject: [PATCH 063/125] Dispatch if more than ordered If the constant SUPPLIER_ORDER_MORE_THAN_WISHED is set --- .../class/fournisseur.commande.class.php | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 1bbde68172e..01114cf22c5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2960,7 +2960,58 @@ class CommandeFournisseur extends CommonOrder } return 4; } - } + }elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) + {//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) + + $close=0; + + if( count($diff_array) > 0 ) + {//there are some difference between the two arrays + + //scan the array of results + foreach($diff_array as $key => $value) + {//if the quantity delivered is greater or equal to wish quantity + if($qtydelivered[$key] >= $qtywished[$key] ) + { + $close++; + } + + } + } + + + if($close == count($diff_array)) + {//all the products are received equal or more than the wished quantity + if ($closeopenorder) + { + $ret = $this->Livraison($user, $date_liv, 'tot', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 5; + } + else + { + //Diff => received partially + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + + } + else + {//all the products are not received + $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' + if ($ret<0) { + return -1; + } + return 4; + } + + } else { //Diff => received partially From d8f8e76bee485504c88c9775016f17dae6d00aa9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 10:39:39 +0100 Subject: [PATCH 064/125] Provide context to trigger --- htdocs/categories/class/categorie.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 5b824d8c959..05005b8b5bb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -715,11 +715,12 @@ class Categorie extends CommonObject } } - // Save object we want to link category to into category instance to provide information to trigger - $this->linkto=$obj; + // Call trigger - $result=$this->call_trigger('CATEGORY_LINK',$user); + $this->linkto=$obj; // Deprecated. Save object we want to link category to into category instance to provide information to trigger + $this->context=array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger + $result=$this->call_trigger('CATEGORY_LINK',$user); if ($result < 0) { $error++; } // End call triggers From 194f5a2cefc6ddebcff1cb149e142919dfe3ffb4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 11:03:48 +0100 Subject: [PATCH 065/125] Fix substitution key --- htdocs/core/lib/functions.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a3a12179a6e..0f10c40fddf 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5506,12 +5506,14 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); } From 829de06bf61021c9237689297975e0e391c1e1a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 11:23:04 +0100 Subject: [PATCH 066/125] Fix error management --- htdocs/societe/card.php | 39 +++++++++++++++++++++----- htdocs/societe/class/societe.class.php | 16 +++++++++-- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 362834b316d..c0775145828 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -511,6 +511,8 @@ if (empty($reshook)) { if ($action == 'add') { + $error = 0; + $db->begin(); if (empty($object->client)) $object->code_client=''; @@ -533,11 +535,21 @@ if (empty($reshook)) // Customer categories association $custcats = GETPOST('custcats', 'array'); - $object->setCategories($custcats, 'customer'); + $result = $object->setCategories($custcats, 'customer'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Supplier categories association $suppcats = GETPOST('suppcats', 'array'); - $object->setCategories($suppcats, 'supplier'); + $result = $object->setCategories($suppcats, 'supplier'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Logo/Photo save $dir = $conf->societe->multidir_output[$conf->entity]."/".$object->id."/logos/"; @@ -566,7 +578,7 @@ if (empty($reshook)) } } else - { + { switch($_FILES['photo']['error']) { case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini @@ -593,7 +605,7 @@ if (empty($reshook)) $error++; } - if ($result >= 0) + if ($result >= 0 && ! $error) { $db->commit(); @@ -622,6 +634,8 @@ if (empty($reshook)) if ($action == 'update') { + $error = 0; + if (GETPOST('cancel','alpha')) { if (! empty($backtopage)) @@ -647,16 +661,27 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); $error++; } + // Prevent thirdparty's emptying if a user hasn't rights $user->rights->categorie->lire (in such a case, post of 'custcats' is not defined) - if (!empty($user->rights->categorie->lire)) + if (! $error && !empty($user->rights->categorie->lire)) { // Customer categories association $categories = GETPOST( 'custcats', 'array' ); - $object->setCategories($categories, 'customer'); + $result = $object->setCategories($categories, 'customer'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } // Supplier categories association $categories = GETPOST('suppcats', 'array'); - $object->setCategories($categories, 'supplier'); + $result = $object->setCategories($categories, 'supplier'); + if ($result < 0) + { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } // Logo/Photo save diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3ca69fdb6fd..f67d1a1d9e7 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3767,6 +3767,8 @@ class Societe extends CommonObject $to_add = $categories; } + $error = 0; + // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { @@ -3774,12 +3776,20 @@ class Societe extends CommonObject } } foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, $type_text); + if ($c->fetch($add) > 0) + { + $result = $c->add_type($this, $type_text); + if ($result < 0) + { + $error++; + $this->error = $c->error; + $this->errors = $c->errors; + break; + } } } - return 1; + return $error ? -1 : 1; } From 82ae65b18d1f6d8d0a43f0f02daaf8090eca5d03 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 11:23:36 +0100 Subject: [PATCH 067/125] NEW Can get template of email from its label --- htdocs/categories/class/categorie.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 05005b8b5bb..ada86667f44 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -716,7 +716,7 @@ class Categorie extends CommonObject } - + // Call trigger $this->linkto=$obj; // Deprecated. Save object we want to link category to into category instance to provide information to trigger $this->context=array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 922980f62dd..67497b4881b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -984,9 +984,10 @@ class FormMail extends Form * @param Translate $outputlangs Output lang object * @param int $id Id of template to find, or -1 for first found with lower position, or 0 for first found whatever is position * @param int $active 1=Only active template, 0=Only disabled, -1=All + * @param string $label Label of template * @return array array('topic'=>,'content'=>,..) */ - public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1) + public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1, $label='') { $ret=array(); @@ -996,6 +997,7 @@ class FormMail extends Form $sql.= " AND entity IN (".getEntity('c_email_templates').")"; $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned if ($active >= 0) $sql.=" AND active = ".$active; + if ($label) $sql.=" AND label ='".$this->db->escape($label)."'"; if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; if ($id > 0) $sql.= " AND rowid=".$id; if ($id == -1) $sql.= " AND position=0"; From b3d968d4a164107734dee0a32e10ed37dcb866ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 11:40:20 +0100 Subject: [PATCH 068/125] Fix look and feel v7 --- htdocs/admin/modules.php | 8 ++++---- htdocs/modulebuilder/template/admin/about.php | 10 +++------- htdocs/modulebuilder/template/admin/setup.php | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ee17e647863..00c8d14219e 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -741,12 +741,12 @@ if ($mode == 'common') if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs)) { $urltouse=dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1); - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } else { $urltouse=$urlpage; - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; + print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''; } } } @@ -754,11 +754,11 @@ if ($mode == 'common') } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').''.img_picto($langs->trans("Setup"),"setup",'style="padding-right: 6px"').'
'."\n"; print ''."\n"; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print ''; - } print ''; - print "'."\n"; @@ -1849,40 +1832,46 @@ else print img_object($langs->trans("ShowGroup"),"group").' '.$group->name; } print ''; - if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print '\n"; + print ''."\n"; } } else { - print ''; + $colspan = 2; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $colspan ++; + if ($caneditgroup) $colspan ++; + } + + print ''; } print "
'.$langs->trans("Groups").''.$langs->trans("Entity").''; - if ($caneditgroup) - { - // Users/Groups management only in master entity if transverse mode - if (! empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) - { - // nothing - } - else - { - print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); - print '   '; - // Multicompany - if (! empty($conf->multicompany->enabled)) - { - if ($conf->entity == 1 && $conf->global->MULTICOMPANY_TRANSVERSE_MODE) - { - print ''.$langs->trans("Entity").'".$mc->select_entities($conf->entity); - } - else - { - print ''; - } - } - else - { - print ''; - } - print ''; - } + if ($caneditgroup) { + print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity); + } + + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + print '' . $langs->trans("Entity"); + + if ($caneditgroup) { + print '' . $mc->select_entities($conf->entity, 'entity'); + } + } + + if ($caneditgroup) { + print '   '; } print '
'; - if (! empty($group->usergroup_entity)) - { - $nb=0; - foreach($group->usergroup_entity as $group_entity) - { - $mc->getInfo($group_entity); - print ($nb > 0 ? ', ' : '').$mc->label; - print ''; - print img_delete($langs->trans("RemoveFromGroup")); - print ''; - $nb++; - } - } - } print ''; - if ($caneditgroup && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) - { - print ''; + if (! empty($conf->multicompany->enabled) && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + print ''; + + if (! empty($group->usergroup_entity)) { + $nb = 0; + foreach ($group->usergroup_entity as $group_entity) { + $mc->getInfo($group_entity); + print ($nb > 0 ? ', ' : '') . $mc->label; + + if ($conf->entity == 1 && ! empty($user->admin) && empty($user->entity)) { + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + print ''; + } + + $nb ++; + } + } + + if ($caneditgroup) { + print ''; + } + } elseif ($caneditgroup) { + print ''; print img_delete($langs->trans("RemoveFromGroup")); print ''; } - else - { - print " "; - } - print "
'.$langs->trans("None").'
' . $langs->trans("None") . '
"; From 8b479a05ade39a8952050ab7d86c11d50f55e8e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 12:34:25 +0100 Subject: [PATCH 071/125] Can add property in password extrafield (prepare to choose encrypt algo) --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 ++ htdocs/core/tpl/admin_extrafields_edit.tpl.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index fdf2f722932..3693883775a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -93,6 +93,7 @@ $langs->load("modulebuilder"); else if (type == 'int') { size.val('10').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } + else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} @@ -165,6 +166,7 @@ $langs->load("modulebuilder"); textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> + textwithpicto('', $langs->trans("ExtrafieldParamPassword"),1,0,'', 0, 2, 'helpvalue5')?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index e0b4927bf19..3a5922c216f 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -91,6 +91,7 @@ $langs->load("modulebuilder"); else if (type == 'int') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'text') { size.removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'varchar') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } + else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} @@ -166,7 +167,7 @@ if((($type == 'select') || ($type == 'checkbox') || ($type == 'radio')) && is_ar } } } -elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') ) +elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($type == 'password')) { $paramlist=array_keys($param['options']); $param_chain = $paramlist[0]; @@ -210,7 +211,7 @@ else trans("Size"); ?> - + trans("Value"); ?> @@ -224,6 +225,7 @@ else textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> + textwithpicto('', $langs->trans("ExtrafieldParamPassword"),1,0,'', 0, 2, 'helpvalue5')?> From cc618e886f75997a51700464c434b3e75508ac71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 13:19:33 +0100 Subject: [PATCH 072/125] Fix extrafield password must be >= than 64 for password_hash --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index ee165ac6808..db0e7f4284a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -234,7 +234,7 @@ class ExtraFields $lengthdb='11'; } elseif($type=='password') { $typedb='varchar'; - $lengthdb='50'; + $lengthdb='128'; } else { $typedb=$type; $lengthdb=$length; From 863cab362f3202de4e99fc22313ef494a939141f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 14:38:41 +0100 Subject: [PATCH 073/125] NEW Cat set the encryption algorithm for extrafields of type password --- htdocs/core/class/commonobject.class.php | 48 ++++++++++++++----- htdocs/core/lib/security.lib.php | 12 +++-- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 +- .../core/tpl/admin_extrafields_edit.tpl.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + htdocs/societe/card.php | 2 +- 6 files changed, 46 insertions(+), 21 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f69e842ec81..af940c91234 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4629,10 +4629,10 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - $attributeType = $extrafields->attribute_type[$attributeKey]; - $attributeLabel = $extrafields->attribute_label[$attributeKey]; - $attributeParam = $extrafields->attribute_param[$attributeKey]; - $attributeRequired = $extrafields->attribute_required[$attributeKey]; + $attributeType = $extrafields->attributes[$this->table_element]['type'][$attributeKey]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$attributeKey]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$attributeKey]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$attributeKey]; if ($attributeRequired) { @@ -4665,7 +4665,26 @@ abstract class CommonObject $this->array_options[$key] = null; } break;*/ - case 'price': + case 'password': + $algo=''; + if (is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) + { + // If there is an encryption choice, we use it to crypt data before insert + $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); + if ($algo != '') + { + $new_array_options[$key] = dol_hash($this->array_options[$key], $algo); + /*var_dump($algo); + var_dump($this->array_options[$key]); + var_dump($new_array_options[$key]);*/ + } + } + else // Common usage + { + $new_array_options[$key] = $this->array_options[$key]; + } + break; + case 'price': $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': @@ -4723,7 +4742,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; @@ -4731,8 +4750,8 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + // Add field of attribute + if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) { if ($new_array_options[$key] != '') { @@ -4781,7 +4800,7 @@ abstract class CommonObject * Update an exta field value for the current object. * Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * - * @param string $key Key of the extrafield + * @param string $key Key of the extrafield (without starting 'options_') * @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY) * @param User $userused Object user * @return int -1=error, O=did nothing, 1=OK @@ -4806,9 +4825,12 @@ abstract class CommonObject $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); $value=$this->array_options["options_".$key]; - $attributeType = $extrafields->attribute_type[$key]; - $attributeLabel = $extrafields->attribute_label[$key]; - $attributeParam = $extrafields->attribute_param[$key]; + + $attributeType = $extrafields->attributes[$this->table_element]['type'][$key]; + $attributeLabel = $extrafields->attributes[$this->table_element]['label'][$key]; + $attributeParam = $extrafields->attributes[$this->table_element]['param'][$key]; + $attributeRequired = $extrafields->attributes[$this->table_element]['required'][$key]; + switch ($attributeType) { case 'int': @@ -4838,7 +4860,7 @@ abstract class CommonObject $this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]); break; case 'link': - $param_list=array_keys($attributeParam ['options']); + $param_list=array_keys($attributeParam['options']); // 0 : ObjectName // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index dda89a7425d..a367579e1cd 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -70,11 +70,11 @@ function dol_decode($chain) /** * Returns a hash of a string. - * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function. - * If constant MAIN_SECURITY_SALT is defined, we use it as a salt. + * If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function (recommanded value is 'password_hash') + * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO then md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @getRandomPassword */ @@ -83,8 +83,10 @@ function dol_hash($chain, $type='0') global $conf; // No need to add salt for password_hash - if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) - return password_hash($chain, PASSWORD_DEFAULT); + if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) + { + return password_hash($chain, PASSWORD_DEFAULT); + } // Salt value if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 3693883775a..a48e8a5f31a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -166,7 +166,7 @@ $langs->load("modulebuilder"); textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> - textwithpicto('', $langs->trans("ExtrafieldParamPassword"),1,0,'', 0, 2, 'helpvalue5')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"),1,0,'', 0, 2, 'helpvalue5')?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 3a5922c216f..a919b545a36 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -225,7 +225,7 @@ else textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0,'', 0, 2, 'helpvalue2')?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0,'', 0, 2, 'helpvalue3')?> textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0,'', 0, 2, 'helpvalue4')?> - textwithpicto('', $langs->trans("ExtrafieldParamPassword"),1,0,'', 0, 2, 'helpvalue5')?> + textwithpicto('', $langs->trans("ExtrafieldParamHelpPassword"),1,0,'', 0, 2, 'helpvalue5')?> diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 02c44ebee88..d6bf4d01fe9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -411,6 +411,7 @@ ExtrafieldCheckBoxFromList=Checkboxes from table ExtrafieldLink=Link to an object ComputedFormula=Computed field ComputedFormulaDesc=You can enter here a formula using other properties of object or any PHP coding to get a dynamic computed value. You can use any PHP compatible formulas including the "?" condition operator, and following global object: $db, $conf, $langs, $mysoc, $user, $object.
WARNING: Only some properties of $object may be available. If you need a properties not loaded, just fetch yourself the object into your formula like in the second example.
Using a computed field means you can't enter yourself any value from interface. Also, if there is a syntax error, the formula may return nothing.

Example of formula:
$object->id < 10 ? round($object->id / 2, 2) : ($object->id + 2 * $user->id) * (int) substr($mysoc->zip, 1, 2)

Example to reload object
(($reloadedobj = new Societe($db)) && ($reloadedobj->fetch($obj->id ? $obj->id : ($obj->rowid ? $obj->rowid : $object->id)) > 0)) ? $reloadedobj->array_options['options_extrafieldkey'] * $reloadedobj->capital / 5 : '-1'

Other example of formula to force load of object and its parent object:
(($reloadedobj = new Task($db)) && ($reloadedobj->fetch($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetch($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : 'Parent project not found' +ExtrafieldParamHelpPassword=Keep this field empty means value will be stored without encryption (field must be only hidden with star on screen).
Set here value 'auto' to use the default encryption rule to save password into database (then value read will be the hash only, no way to retreive original value) ExtrafieldParamHelpselect=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
code3,value3
...

In order to have the list depending on another complementary attribute list :
1,value1|options_parent_list_code:parent_key
2,value2|options_parent_list_code:parent_key

In order to have the list depending on another list :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=List of values must be lines with format key,value (where key can't be '0')

for example :
1,value1
2,value2
3,value3
... diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index c0775145828..ed8e6c74c6e 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -329,7 +329,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) From 953001c7aba013f26f317e07d47a7b6a4fb252bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 15:16:49 +0100 Subject: [PATCH 074/125] Fix bad naming of column --- htdocs/expensereport/card.php | 13 ++++++++++--- htdocs/langs/en_US/main.lang | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 6d989e6efc0..6cebfb0fe2d 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1978,7 +1978,8 @@ else $i = 0;$total = 0; print ''; - print ''.$langs->trans('Piece').''; + print ''.$langs->trans('LineNb').''; + //print ''.$langs->trans('Piece').''; print ''.$langs->trans('Date').''; if (! empty($conf->projet->enabled)) print ''.$langs->trans('Project').''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''.$langs->trans('CarCategory').''; @@ -2001,15 +2002,21 @@ else foreach ($object->lines as &$line) { - $piece_comptable = $i + 1; + $numline = $i + 1; if ($action != 'editline' || $line->rowid != GETPOST('rowid')) { print ''; print ''; + print $numline; + print ''; + + /*print ''; print img_picto($langs->trans("Document"), "object_generic"); - print ' '.$piece_comptable.''; + print ' '.$piece_comptable.''; + print '';*/ + print ''.dol_print_date($db->jdate($line->date), 'day').''; if (! empty($conf->projet->enabled)) { diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index cde8a485e59..19c7967e43a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -854,6 +854,7 @@ FileNotShared=File not shared to exernal public Project=Project Projects=Projects Rights=Permissions +LineNb=Line nb # Week day Monday=Monday Tuesday=Tuesday From 93a817681327ddf9eaa70af71a78938e48130c76 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 15:28:24 +0100 Subject: [PATCH 075/125] Fix do not encrypt if empty --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index af940c91234..60d7f4a8c5e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4667,7 +4667,7 @@ abstract class CommonObject break;*/ case 'password': $algo=''; - if (is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) + if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])) { // If there is an encryption choice, we use it to crypt data before insert $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); From f002c84a766b11b552ff9cd5510b103a94e94251 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 15:33:00 +0100 Subject: [PATCH 076/125] Fix type of expense report output in PDF --- .../modules/expensereport/doc/pdf_standard.modules.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 15d48694277..c236c9ad017 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -328,7 +328,15 @@ class pdf_standard extends ModeleExpenseReport $nextColumnPosX = $this->posxprojet; } - $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, dol_trunc($outputlangs->transnoentities($object->lines[$i]->type_fees_code), 10), 0, 'C'); + $expensereporttypecode = $object->lines[$i]->type_fees_code; + $expensereporttypecodetoshow = $outputlangs->transnoentities($expensereporttypecode); + if ($expensereporttypecodetoshow == $expensereporttypecode) + { + $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); + } + $expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); // 10 is too much + + $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); // Project if (! empty($conf->projet->enabled)) From 812911bd44097e5defbc4d511643fa857b79c615 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 15:33:00 +0100 Subject: [PATCH 077/125] Fix type of expense report output in PDF --- .../modules/expensereport/doc/pdf_standard.modules.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 15d48694277..c236c9ad017 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -328,7 +328,15 @@ class pdf_standard extends ModeleExpenseReport $nextColumnPosX = $this->posxprojet; } - $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, dol_trunc($outputlangs->transnoentities($object->lines[$i]->type_fees_code), 10), 0, 'C'); + $expensereporttypecode = $object->lines[$i]->type_fees_code; + $expensereporttypecodetoshow = $outputlangs->transnoentities($expensereporttypecode); + if ($expensereporttypecodetoshow == $expensereporttypecode) + { + $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow); + } + $expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9); // 10 is too much + + $pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C'); // Project if (! empty($conf->projet->enabled)) From 787a13750939267bb1cda1ed308dd8b41e9adb1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 15:38:39 +0100 Subject: [PATCH 078/125] Add column for accounting doc --- htdocs/install/mysql/migration/7.0.0-8.0.0.sql | 1 + htdocs/install/mysql/tables/llx_expensereport_det.sql | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index a0ec8f58e37..6488a7dafde 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -54,5 +54,6 @@ insert into llx_c_type_container (code,label,module,active) values ('blogpost', insert into llx_c_type_container (code,label,module,active) values ('other', 'Other', 'system', 1); +ALTER TABLE llx_expensereport_det ADD COLUMN docnumber varchar(128) after fk_expensereport; diff --git a/htdocs/install/mysql/tables/llx_expensereport_det.sql b/htdocs/install/mysql/tables/llx_expensereport_det.sql index 5cc7b1b86f5..fc0bd6e697f 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_det.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_det.sql @@ -20,9 +20,10 @@ CREATE TABLE llx_expensereport_det ( rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY, fk_expensereport integer NOT NULL, - fk_c_type_fees integer NOT NULL, + docnumber varchar(128), -- To store a ref of a accounting doc (piece) + fk_c_type_fees integer NOT NULL, -- Type of expense fk_c_exp_tax_cat integer, - fk_projet integer, + fk_projet integer, -- Id of project comments text NOT NULL, product_type integer DEFAULT -1, qty real NOT NULL, From 0a79550f4320706d6d216717733da270932d8adb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 16:11:00 +0100 Subject: [PATCH 079/125] Fix oldcopy must be saved before update_extras --- htdocs/comm/card.php | 4 +++- htdocs/comm/propal/card.php | 4 +++- htdocs/commande/card.php | 4 +++- htdocs/compta/facture/card.php | 4 +++- htdocs/compta/facture/fiche-rec.php | 4 +++- htdocs/contrat/card.php | 2 +- htdocs/expedition/card.php | 6 ++++-- htdocs/expedition/shipment.php | 6 ++++-- htdocs/expensereport/card.php | 6 ++++-- htdocs/fichinter/card.php | 4 +++- htdocs/fourn/card.php | 4 +++- htdocs/fourn/commande/card.php | 4 +++- htdocs/fourn/facture/card.php | 4 +++- htdocs/livraison/card.php | 4 +++- htdocs/product/stock/productlot_card.php | 6 ++++-- htdocs/societe/card.php | 2 ++ htdocs/supplier_proposal/card.php | 4 +++- 17 files changed, 52 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 506b0c6fa8d..aab95264a57 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -189,9 +189,11 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($id); + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 380edc5a472..02c1b0e65bb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1228,9 +1228,11 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 21975439872..2cb899fcfe6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1268,9 +1268,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5681b0c339c..969f4d532cb 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2112,9 +2112,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index f869c01aa53..43d28c9abbd 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -444,9 +444,11 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index e27bbfb7655..3b7ab5ae49b 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -880,7 +880,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 82d6c746640..27b70e1b8cf 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -155,9 +155,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 0141fc1dea5..3b7a2d74818 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -180,9 +180,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index bb90442a110..dd5db880bc9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -286,9 +286,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 3eddb02c28b..9b623d21279 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -741,9 +741,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 6f06a6778fd..c6f0c8bb446 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -114,9 +114,11 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($id); + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 15148cbcc2a..f87b4c9bd25 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -945,9 +945,11 @@ if (empty($reshook)) if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index cfba614492e..cc6fb29fa5a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1255,9 +1255,11 @@ if (empty($reshook)) } if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from add form $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (!$error) diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index b2218508ef6..06c602df330 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -193,9 +193,11 @@ elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) // Update extrafields if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 8e639c90108..f269e260b25 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -122,9 +122,11 @@ if (empty($reshook)) if ($action == 'update_extras') { - // Fill array 'array_options' with data from update form + $object->oldcopy = dol_clone($object); + + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); if ($ret < 0) $error++; if (! $error) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ed8e6c74c6e..55c598fdd84 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -327,6 +327,8 @@ if (empty($reshook)) if ($action == 'update_extras') { $object->fetch($socid); + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute','none')); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index c4f5c5c6ba9..8d8e46a6ae9 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -927,9 +927,11 @@ if (empty($reshook)) } else if ($action == 'update_extras') { + $object->oldcopy = dol_clone($object); + // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) From f3e1e81219916363936e09e79da8a7c4f61dc286 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 16:11:25 +0100 Subject: [PATCH 080/125] Fix update of extrafield password that are crypted --- htdocs/core/class/commonobject.class.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 60d7f4a8c5e..990d158af56 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4673,10 +4673,26 @@ abstract class CommonObject $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); if ($algo != '') { - $new_array_options[$key] = dol_hash($this->array_options[$key], $algo); - /*var_dump($algo); - var_dump($this->array_options[$key]); - var_dump($new_array_options[$key]);*/ + if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value + { + //global $action; // $action may be 'create', 'update', 'update_extras'... + //var_dump($action); + //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); + if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same thaan submited new value, it means we don't change it, so we don't update. + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } + else + { + // var_dump($algo); + $newvalue = dol_hash($this->array_options[$key], $algo); + $new_array_options[$key] = $newvalue; + } + } + else + { + $new_array_options[$key] = $this->array_options[$key]; // Value is kept + } } } else // Common usage From 7cf7bf6e4591ac09e06cd16ef63d227895e48ac7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 16:26:23 +0100 Subject: [PATCH 081/125] Code comment --- htdocs/core/class/commonobject.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 990d158af56..f5e429bf54a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4673,12 +4673,13 @@ abstract class CommonObject $algo=reset(array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options'])); if ($algo != '') { + //global $action; // $action may be 'create', 'update', 'update_extras'... + //var_dump($action); + //var_dump($this->oldcopy);exit; if (is_object($this->oldcopy)) // If this->oldcopy is not defined, we can't know if we change attribute or not, so we must keep value { - //global $action; // $action may be 'create', 'update', 'update_extras'... - //var_dump($action); //var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]); - if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same thaan submited new value, it means we don't change it, so we don't update. + if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update. { $new_array_options[$key] = $this->array_options[$key]; // Value is kept } From d8bf553ea9d1e99c568c1a1b1df5d08afc7576d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Feb 2018 19:55:15 +0100 Subject: [PATCH 082/125] Add option THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD for logo indexing --- htdocs/core/class/commonobject.class.php | 2 + htdocs/core/lib/files.lib.php | 134 +++++++++++++++++++---- htdocs/societe/card.php | 17 ++- htdocs/societe/class/societe.class.php | 28 ++--- 4 files changed, 140 insertions(+), 41 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f5e429bf54a..55e3c380c31 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4116,6 +4116,7 @@ abstract class CommonObject * @param int $hideref 1 to hide product reference. 0 by default * @param null|array $moreparams Array to provide more information * @return int >0 if OK, <0 if KO + * @see addFileIntoDatabaseIndex */ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null) { @@ -4354,6 +4355,7 @@ abstract class CommonObject /** * Build thumb + * @TODO Move this into files.lib.php * * @param string $file Path file in UTF8 to original file to create thumbs from. * @return void diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 85d80f646d0..529f58dbbf1 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -950,7 +950,7 @@ function dolCheckVirus($src_file) * Note: * - This function can be used only into a HTML page context. Use dol_move if you are outside. * - Test on antivirus is always done (if antivirus set). - * - Database of files is NOT updated. + * - Database of files is NOT updated (this is done by dol_add_file_process() that calls this function). * * @param string $src_file Source full path filename ($_FILES['field']['tmp_name']) * @param string $dest_file Target full path filename ($_FILES['field']['name']) @@ -1554,28 +1554,10 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio // Update table of files if ($donotupdatesession) { - $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir); - - if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + $result = addFileIntoDatabaseIndex($upload_dir, basename($destfile), $TFile['name'][$i], 'uploaded', 0); + if ($result < 0) { - $filename = basename($destfile); - $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); - $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); - - include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); - $ecmfile->filepath = $rel_dir; - $ecmfile->filename = $filename; - $ecmfile->label = md5_file(dol_osencode($destfull)); // MD5 of file content - $ecmfile->fullpath_orig = $TFile['name'][$i]; - $ecmfile->gen_or_uploaded = 'uploaded'; - $ecmfile->description = ''; // indexed content - $ecmfile->keyword = ''; // keyword content - $result = $ecmfile->create($user); - if ($result < 0) - { - setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings'); - } + setEventMessages('FailedToAddFileIntoDatabaseIndex', '', 'warnings'); } } @@ -1679,6 +1661,114 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= } } + +/** + * Add a file into database index. + * Called by dol_add_file_process when uploading a file and on other cases. + * See also commonGenerateDocument that also add/update database index when a file is generated. + * + * @param string $dir Directory name (full real path without ending /) + * @param string $file File name + * @param string $fullpathorig Full path of origin for file (can be '') + * @param string $mode How file was created ('uploaded', 'generated', ...) + * @param int $setsharekey Set also the share key + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ +function addFileIntoDatabaseIndex($dir, $file, $fullpathorig='', $mode='uploaded', $setsharekey=0) +{ + global $db, $user; + + $result = 0; + + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + + if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir + { + $filename = basename($file); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; + $ecmfile=new EcmFiles($db); + $ecmfile->filepath = $rel_dir; + $ecmfile->filename = $filename; + $ecmfile->label = md5_file(dol_osencode($dir.'/'.$file)); // MD5 of file content + $ecmfile->fullpath_orig = $fullpathorig; + $ecmfile->gen_or_uploaded = $mode; + $ecmfile->description = ''; // indexed content + $ecmfile->keyword = ''; // keyword content + if ($setsharekey) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $ecmfile->share = getRandomPassword(true); + } + + $result = $ecmfile->create($user); + if ($result < 0) + { + dol_syslog($ecmfile->error); + } + } + + return $result; +} + + +/** + * Delete files into database index using search criterias. + * + * @param string $dir Directory name (full real path without ending /) + * @param string $file File name + * @param string $mode How file was created ('uploaded', 'generated', ...) + * @return int <0 if KO, 0 if nothing done, >0 if OK + */ +function deleteFilesIntoDatabaseIndex($dir, $file, $mode='uploaded') +{ + global $conf, $db, $user; + + $error = 0; + + if (empty($dir)) + { + dol_syslog("deleteFilesIntoDatabaseIndex: dir parameter can't be empty", LOG_ERR); + return -1; + } + + $db->begin(); + + $rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir); + + $filename = basename($file); + $rel_dir = preg_replace('/[\\/]$/', '', $rel_dir); + $rel_dir = preg_replace('/^[\\/]/', '', $rel_dir); + + if (! $error) + { + $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'ecm_files'; + $sql.= ' WHERE entity = '.$conf->entity; + $sql.= " AND filepath = '" . $db->escape($rel_dir) . "'"; + if ($file) $sql.= " AND filename = '" . $db->escape($file) . "'"; + if ($mode) $sql.= " AND gen_or_uploaded = '" . $db->escape($mode) . "'"; + + $resql = $db->query($sql); + if (!$resql) + { + $error++; + dol_syslog(__METHOD__ . ' ' . $db->lasterror(), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $db->rollback(); + return - 1 * $error; + } else { + $db->commit(); + return 1; + } +} + + /** * Convert an image file into another format. * This need Imagick php extension. diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 55c598fdd84..4e013581a25 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -713,13 +713,18 @@ if (empty($reshook)) } else { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality); + // Create thumbs + $object->addThumbs($newfile); - // 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); + // Index file in database + if (! empty($conf->global->THIRDPARTY_LOGO_ALLOW_EXTERNAL_DOWNLOAD)) + { + require_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; + // the dir dirname($newfile) is directory of logo, so we should have only one file at once into index, so we delete indexes for the dir + deleteFilesIntoDatabaseIndex(dirname($newfile), '', '', 'uploaded', 1); + // now we index the uploaded logo file + addFileIntoDatabaseIndex(dirname($newfile), basename($newfile), '', 'uploaded', 1); + } } } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index f67d1a1d9e7..f5c0f004794 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1121,10 +1121,11 @@ class Societe extends CommonObject * @param string $idprof4 Prof id 4 of third party (Warning, this can return several records) * @param string $idprof5 Prof id 5 of third party (Warning, this can return several records) * @param string $idprof6 Prof id 6 of third party (Warning, this can return several records) - * @param string $email Email (Warning, this can return several records) + * @param string $email Email of third party (Warning, this can return several records) + * @param string $ref_alias Name_alias of third party (Warning, this can return several records) * @return int >0 if OK, <0 if KO or if two records found for same ref or idprof, 0 if not found. */ - function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='') + function fetch($rowid, $ref='', $ref_ext='', $ref_int='', $idprof1='',$idprof2='',$idprof3='',$idprof4='',$idprof5='',$idprof6='', $email='', $ref_alias='') { global $langs; global $conf; @@ -1166,17 +1167,18 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; - if ($rowid) $sql .= ' AND s.rowid = '.$rowid; - if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; - if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; - if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; - if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; - if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; - if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; - if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; - if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; - if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; + if ($rowid) $sql .= ' AND s.rowid = '.$rowid; + if ($ref) $sql .= " AND s.nom = '".$this->db->escape($ref)."'"; + if ($ref_alias) $sql .= " AND s.nom_alias = '".$this->db->escape($nom_alias)."'"; + if ($ref_ext) $sql .= " AND s.ref_ext = '".$this->db->escape($ref_ext)."'"; + if ($ref_int) $sql .= " AND s.ref_int = '".$this->db->escape($ref_int)."'"; + if ($idprof1) $sql .= " AND s.siren = '".$this->db->escape($idprof1)."'"; + if ($idprof2) $sql .= " AND s.siret = '".$this->db->escape($idprof2)."'"; + if ($idprof3) $sql .= " AND s.ape = '".$this->db->escape($idprof3)."'"; + if ($idprof4) $sql .= " AND s.idprof4 = '".$this->db->escape($idprof4)."'"; + if ($idprof5) $sql .= " AND s.idprof5 = '".$this->db->escape($idprof5)."'"; + if ($idprof6) $sql .= " AND s.idprof6 = '".$this->db->escape($idprof6)."'"; + if ($email) $sql .= " AND s.email = '".$this->db->escape($email)."'"; $resql=$this->db->query($sql); if ($resql) From 4c06384197dc8d47b836c2b8daaa6abead75948b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 11:13:14 +0100 Subject: [PATCH 083/125] Fix: differentiate sharing of "member" and "member_type" --- htdocs/adherents/class/adherent_type.class.php | 3 ++- htdocs/adherents/class/api_memberstypes.class.php | 2 +- htdocs/adherents/index.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/core/boxes/box_members.php | 2 +- htdocs/core/modules/mailings/fraise.modules.php | 2 +- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/societe/societecontact.php | 3 ++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5e9cbb07ca5..c352f5dc944 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -35,6 +35,7 @@ class AdherentType extends CommonObject public $table_element = 'adherent_type'; public $element = 'adherent_type'; public $picto = 'group'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string @@ -307,7 +308,7 @@ class AdherentType extends CommonObject $sql = "SELECT rowid, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity IN (".getEntity('adherent').")"; + $sql.= " WHERE entity IN (".getEntity('member_type').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 26d3d115f75..f2dfba0367a 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; + $sql.= ' WHERE t.entity IN ('.getEntity('member_type').')'; // Add sql filters if ($sqlfilters) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index a04b1df5786..fd418756bd6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -65,7 +65,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " ON t.rowid = d.fk_adherent_type"; $sql.= " AND d.entity IN (".getEntity('adherent').")"; -$sql.= " WHERE t.entity IN (".getEntity('adherent').")"; +$sql.= " WHERE t.entity IN (".getEntity('member_type').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members by type", LOG_DEBUG); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index cc9fd872062..885e5a01251 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -216,7 +216,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); if ($result) diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 25fa257d098..e5819f0f14c 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -88,7 +88,7 @@ class box_members extends ModeleBoxes $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql.= " t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.entity = ".$conf->entity; + $sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql.= " AND a.fk_adherent_type = t.rowid"; $sql.= " ORDER BY a.tms DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index a1674d6ab08..f71b6b925f0 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -127,7 +127,7 @@ class mailing_fraise extends MailingTargets $s.=''; From e2e0f23d2990caf349676d82438a787a99e3f566 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Feb 2018 14:01:52 +0100 Subject: [PATCH 091/125] FIX Bad var for substitution of free text --- .../modules/contract/doc/doc_generic_contract_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index ff7abbca53a..98b644c8cce 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -317,7 +317,7 @@ class doc_generic_contract_odt extends ModelePDFContract // Line of free text $newfreetext=''; - $paramfreetext='contract_FREE_TEXT'; + $paramfreetext='CONTRACT_FREE_TEXT'; if (! empty($conf->global->$paramfreetext)) { $newfreetext=make_substitutions($conf->global->$paramfreetext,$tmparray); From 1ec5a5d0bf58cd6f21b4dfff89b825dd9598629b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Feb 2018 14:02:27 +0100 Subject: [PATCH 092/125] FIX Generic substitution of constant disabled for sensitive constant --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8476ab90b02..3f194d3531a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5947,7 +5947,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) if (dol_textishtml($text,1)) $msgishtml = 1; $keyfound = $reg[1]; - $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); } From 619e0d3792920887e42d2d748cd9310537df9a02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Feb 2018 14:01:52 +0100 Subject: [PATCH 093/125] FIX Bad var for substitution of free text --- .../modules/contract/doc/doc_generic_contract_odt.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 62eade74dfa..7e308964e29 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -324,7 +324,7 @@ class doc_generic_contract_odt extends ModelePDFContract // Line of free text $newfreetext=''; - $paramfreetext='contract_FREE_TEXT'; + $paramfreetext='CONTRACT_FREE_TEXT'; if (! empty($conf->global->$paramfreetext)) { $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray); From a5b1f114c2a88a3438a3ec3fb35697686f528ca2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Feb 2018 14:02:27 +0100 Subject: [PATCH 094/125] FIX Generic substitution of constant disabled for sensitive constant --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0f10c40fddf..715095f96ae 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5685,7 +5685,8 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null) if (dol_textishtml($text,1)) $msgishtml = 1; $keyfound = $reg[1]; - $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval=empty($conf->global->$keyfound)?'':$conf->global->$keyfound; $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml?dol_htmlentitiesbr($newval):$newval, $text); } From 3859b5a92662c6fe3de5f31e06d36c050dcd9d15 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 14:20:53 +0100 Subject: [PATCH 095/125] Fix: Parameter must be an array or an object that implements Countable --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b08993acf8a..fae976dec80 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -46,7 +46,7 @@ if (! empty($massaction) && count($toselect) < 1) $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (! $error && count($toselect) > $maxformassaction) +if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); $error++; From 3b5a3915c44be7f06b91fae595e4b17db299844c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Feb 2018 14:23:52 +0100 Subject: [PATCH 096/125] NEW Use common substitution rule for language to get translation in ODT --- htdocs/core/class/commondocgenerator.class.php | 8 ++++++++ htdocs/core/class/translate.class.php | 1 + 2 files changed, 9 insertions(+) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index dd296429d58..f6a410469de 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -316,6 +316,14 @@ abstract class CommonDocGenerator 'current_server_datehour_locale'=>dol_print_date($now,'dayhour','tzserver',$outputlangs), ); + + foreach($conf->global as $key => $val) + { + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) $newval = '*****forbidden*****'; + else $newval = $val; + $array_other['__['.$key.']__'] = $newval; + } + return $array_other; } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 14f017bef55..69fe031459d 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -1027,6 +1027,7 @@ class Translate foreach($this->tab_translate as $code => $label) { $substitutionarray['lang_'.$code] = $label; + $substitutionarray['__('.$code.')__'] = $label; } return $substitutionarray; From b2162492147f26443e051f84d477ae4d6526e6f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 15:01:29 +0100 Subject: [PATCH 097/125] Fix: missing hook parameters --- htdocs/adherents/list.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/product/list.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/user/index.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index a01cc379b3c..fc30d6f1ae2 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -574,7 +574,7 @@ if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titr include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index af67bd8107b..2903cee2a88 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -614,7 +614,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 13225c2c5d3..29590820b72 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -701,7 +701,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fe26efd490e..8d3f8971ef4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -862,7 +862,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 0b45f2d63a0..ef5f8816a94 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -914,7 +914,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'],$_SERVER["PHP_SELF"],"cf.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 31d6ba2f183..0876cfc7595 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -762,7 +762,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ebb2c0a421a..178432addbc 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -654,7 +654,7 @@ else // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index abf9f9cfd2a..74ee17affd5 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -599,7 +599,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'],$_SERVER["PHP_SELF"],"sp.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 6f9ac1f638a..b5edbafa89e 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -406,7 +406,7 @@ if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_t // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"u.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); From c604ce0a0676046c143bcbadf72e44e644819aa9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 Feb 2018 15:31:30 +0100 Subject: [PATCH 098/125] Fix date in odt --- htdocs/core/class/commondocgenerator.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f6a410469de..f5a16aa540b 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -353,6 +353,8 @@ abstract class CommonDocGenerator $sumcreditnote = $object->getSumCreditNotesUsed(); } + $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); + $resarray=array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, @@ -361,9 +363,9 @@ abstract class CommonDocGenerator $array_key.'_ref_supplier'=>(! empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), $array_key.'_source_invoice_ref'=>$invoice_source->ref, // Dates - $array_key.'_hour'=>dol_print_date($object->date,'hour'), - $array_key.'_date'=>dol_print_date($object->date,'day'), - $array_key.'_date_rfc'=>dol_print_date($object->date,'dayrfc'), + $array_key.'_hour'=>dol_print_date($date,'hour'), + $array_key.'_date'=>dol_print_date($date,'day'), + $array_key.'_date_rfc'=>dol_print_date($date,'dayrfc'), $array_key.'_date_limit'=>(! empty($object->date_lim_reglement)?dol_print_date($object->date_lim_reglement,'day'):''), $array_key.'_date_end'=>(! empty($object->fin_validite)?dol_print_date($object->fin_validite,'day'):''), $array_key.'_date_creation'=>dol_print_date($object->date_creation,'day'), From 703d976b3bd2929c6de2cf26a5a936be7417c7a2 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 16:21:16 +0100 Subject: [PATCH 099/125] Fix: missing object entity in fetch --- htdocs/comm/propal/class/propal.class.php | 3 ++- htdocs/commande/class/commande.class.php | 16 +++++++++------- htdocs/compta/facture/class/facture.class.php | 4 +++- .../fourn/class/fournisseur.commande.class.php | 4 +++- .../class/supplier_proposal.class.php | 3 ++- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 5efc1cf9db4..7663a05812f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1321,7 +1321,7 @@ class Propal extends CommonObject function fetch($rowid,$ref='') { - $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql.= ", p.datec"; $sql.= ", p.date_valid as datev"; @@ -1367,6 +1367,7 @@ class Propal extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 65b704693fb..feac3d74106 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1572,7 +1572,7 @@ class Commande extends CommonOrder // Check parameters if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; + $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; $sql.= ', c.fk_account'; $sql.= ', c.date_commande'; @@ -1602,12 +1602,14 @@ class Commande extends CommonOrder dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - $obj = $this->db->fetch_object($result); - if ($obj) - { - $this->id = $obj->rowid; + if ($result) + { + $obj = $this->db->fetch_object($result); + if ($obj) + { + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; $this->ref_client = $obj->ref_client; $this->ref_customer = $obj->ref_client; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 589a184030e..a87ebf0c9a9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1239,7 +1239,7 @@ class Facture extends CommonInvoice if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; - $sql = 'SELECT f.rowid,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; + $sql = 'SELECT f.rowid,f.entity,f.facnumber,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc,f.amount'; $sql.= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; $sql.= ', f.datef as df, f.date_pointoftax'; @@ -1276,6 +1276,8 @@ class Facture extends CommonInvoice $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->facnumber; $this->ref_client = $obj->ref_client; $this->ref_ext = $obj->ref_ext; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 38d0e42d36a..a42546fdb84 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -218,7 +218,7 @@ class CommandeFournisseur extends CommonOrder // Check parameters if (empty($id) && empty($ref)) return -1; - $sql = "SELECT c.rowid, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; + $sql = "SELECT c.rowid, c.entity, c.ref, ref_supplier, c.fk_soc, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_vat,"; $sql.= " c.localtax1, c.localtax2, "; $sql.= " c.date_creation, c.date_valid, c.date_approve, c.date_approve2,"; $sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_approve, c.fk_user_approve2,"; @@ -253,6 +253,8 @@ class CommandeFournisseur extends CommonOrder } $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->ref; $this->ref_supplier = $obj->ref_supplier; $this->socid = $obj->fk_soc; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index e43404777b6..621a229121c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1132,7 +1132,7 @@ class SupplierProposal extends CommonObject { global $conf; - $sql = "SELECT p.rowid, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; + $sql = "SELECT p.rowid, p.entity, p.ref, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql.= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; $sql.= ", p.datec"; $sql.= ", p.date_valid as datev"; @@ -1166,6 +1166,7 @@ class SupplierProposal extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->remise = $obj->remise; From 029ef534d04b80292a381b19a6a4a43ea1803d47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 10:55:02 +0100 Subject: [PATCH 100/125] Clean deprecated code (property "special" removed from mod descriptor) --- htdocs/admin/modulehelp.php | 7 +--- htdocs/admin/modules.php | 13 ++----- htdocs/contrat/class/contrat.class.php | 28 +++++++------ htdocs/core/lib/admin.lib.php | 2 - htdocs/core/modules/modAccounting.class.php | 1 - htdocs/core/modules/modAdherent.class.php | 1 - htdocs/core/modules/modAgenda.class.php | 1 - htdocs/core/modules/modApi.class.php | 4 +- htdocs/core/modules/modBanque.class.php | 5 +-- htdocs/core/modules/modBarcode.class.php | 1 - htdocs/core/modules/modBlockedLog.class.php | 2 - htdocs/core/modules/modBookmark.class.php | 5 +-- htdocs/core/modules/modCashDesk.class.php | 1 - htdocs/core/modules/modCategorie.class.php | 11 +++--- htdocs/core/modules/modClickToDial.class.php | 3 +- htdocs/core/modules/modCollab.class.php | 2 - htdocs/core/modules/modCommande.class.php | 9 ++--- htdocs/core/modules/modComptabilite.class.php | 7 ++-- htdocs/core/modules/modContrat.class.php | 23 ++++++----- htdocs/core/modules/modCron.class.php | 2 - htdocs/core/modules/modDeplacement.class.php | 11 +++--- .../modules/modDocumentGeneration.class.php | 1 - htdocs/core/modules/modDon.class.php | 1 - .../core/modules/modDynamicPrices.class.php | 2 - htdocs/core/modules/modECM.class.php | 2 - htdocs/core/modules/modExpedition.class.php | 5 +-- .../core/modules/modExpenseReport.class.php | 1 - htdocs/core/modules/modExport.class.php | 1 - htdocs/core/modules/modExternalRss.class.php | 1 - htdocs/core/modules/modExternalSite.class.php | 4 +- htdocs/core/modules/modFTP.class.php | 6 +-- htdocs/core/modules/modFacture.class.php | 1 - htdocs/core/modules/modFckeditor.class.php | 1 - htdocs/core/modules/modFicheinter.class.php | 7 ++-- htdocs/core/modules/modFournisseur.class.php | 1 - htdocs/core/modules/modGeoIPMaxmind.class.php | 4 +- htdocs/core/modules/modGravatar.class.php | 4 +- htdocs/core/modules/modHRM.class.php | 39 +++++++++---------- htdocs/core/modules/modHoliday.class.php | 2 - htdocs/core/modules/modImport.class.php | 1 - htdocs/core/modules/modIncoterm.class.php | 2 - htdocs/core/modules/modLabel.class.php | 1 - htdocs/core/modules/modLdap.class.php | 4 +- htdocs/core/modules/modLoan.class.php | 9 ++--- htdocs/core/modules/modMailing.class.php | 1 - htdocs/core/modules/modMailmanSpip.class.php | 3 +- htdocs/core/modules/modMargin.class.php | 2 - .../core/modules/modModuleBuilder.class.php | 2 - .../core/modules/modMultiCurrency.class.php | 2 - htdocs/core/modules/modNotification.class.php | 3 +- htdocs/core/modules/modOauth.class.php | 4 +- htdocs/core/modules/modOpenSurvey.class.php | 2 - htdocs/core/modules/modPaybox.class.php | 4 +- htdocs/core/modules/modPaypal.class.php | 4 +- htdocs/core/modules/modPrelevement.class.php | 13 +++---- htdocs/core/modules/modPrinting.class.php | 4 +- htdocs/core/modules/modProduct.class.php | 1 - htdocs/core/modules/modProductBatch.class.php | 9 ++--- htdocs/core/modules/modProjet.class.php | 1 - htdocs/core/modules/modPropale.class.php | 11 +++--- .../core/modules/modReceiptPrinter.class.php | 4 +- htdocs/core/modules/modResource.class.php | 3 -- htdocs/core/modules/modSalaries.class.php | 1 - htdocs/core/modules/modService.class.php | 1 - htdocs/core/modules/modSkype.class.php | 4 +- htdocs/core/modules/modSociete.class.php | 1 - htdocs/core/modules/modStock.class.php | 1 - htdocs/core/modules/modStripe.class.php | 4 +- .../modules/modSupplierProposal.class.php | 13 +++---- htdocs/core/modules/modSyslog.class.php | 2 - htdocs/core/modules/modTax.class.php | 17 ++++---- htdocs/core/modules/modUser.class.php | 1 - htdocs/core/modules/modVariants.class.php | 2 - htdocs/core/modules/modWebServices.class.php | 4 +- .../modules/modWebServicesClient.class.php | 4 +- htdocs/core/modules/modWebsite.class.php | 2 - htdocs/core/modules/modWorkflow.class.php | 2 - .../core/modules/modMyModule.class.php | 2 +- htdocs/public/demo/index.php | 2 - 79 files changed, 130 insertions(+), 245 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index bc48feb076f..dd90774a05b 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -163,8 +163,6 @@ foreach ($modulesdir as $dir) $modules[$i] = $objMod; $filename[$i]= $modName; - $special = $objMod->special; - // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { if (!is_array($familyinfo)) $familyinfo=array(); @@ -180,13 +178,11 @@ foreach ($modulesdir as $dir) $moduleposition = 800; } - if ($special == 1) $familykey='interface'; - $orders[$i] = $familyinfo[$familykey]['position']."_".$familykey."_".$moduleposition."_".$j; // Sort by family, then by module position then number $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] - $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown'; + $specialstring = 'unknown'; if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories else $categ[$specialstring]=1; @@ -240,7 +236,6 @@ foreach($orders as $tmpkey => $tmpvalue) $i++; } $value = $orders[$key]; -$special = $objMod->special; $tab=explode('_',$value); $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$tab[3]; diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 00c8d14219e..db8251d0562 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -358,8 +358,6 @@ foreach ($modulesdir as $dir) $filename[$i]= $modName; $modules[$modName] = $objMod; - $special = $objMod->special; - // Gives the possibility to the module, to provide his own family info and position of this family if (is_array($objMod->familyinfo) && !empty($objMod->familyinfo)) { $familyinfo = array_merge($familyinfo, $objMod->familyinfo); @@ -374,8 +372,6 @@ foreach ($modulesdir as $dir) $moduleposition = 800; } - if ($special == 1) $familykey='interface'; - // Add list of warnings to show into arrayofwarnings and arrayofwarningsext if (! empty($objMod->warnings_activation)) { @@ -390,7 +386,7 @@ foreach ($modulesdir as $dir) $dirmod[$i] = $dir; //print $i.'-'.$dirmod[$i].'
'; // Set categ[$i] - $specialstring = isset($specialtostring[$special])?$specialtostring[$special]:'unknown'; + $specialstring = 'unknown'; if ($objMod->version == 'development' || $objMod->version == 'experimental') $specialstring='expdev'; if (isset($categ[$specialstring])) $categ[$specialstring]++; // Array of all different modules categories else $categ[$specialstring]=1; @@ -531,12 +527,9 @@ if ($mode == 'common') $objMod = $modules[$modName]; $dirofmodule = $dirmod[$key]; - $special = $objMod->special; - - //print $objMod->name." - ".$key." - ".$objMod->special.' - '.$objMod->version."
"; + //print $objMod->name." - ".$key." - ".$objMod->version."
"; //if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev') - if (($special >= 4 && $mode != 'expdev') - || ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental')) continue; // Discard if not for current tab + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') continue; // Discard if not for current tab if (! $objMod->getName()) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0b84b05b6fd..0d5262ac66b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -316,9 +316,10 @@ class Contrat extends CommonObject * * @param User $user Object User making action * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function closeAll(User $user, $notrigger=0) + function closeAll(User $user, $notrigger=0, $comment='') { $this->db->begin(); @@ -337,7 +338,7 @@ class Contrat extends CommonObject $contratline->date_cloture=$now; $contratline->fk_user_cloture=$user->id; $contratline->statut='5'; - $result=$contratline->close_line($user, $now); + $result=$contratline->close_line($user, $now, $comment, $notrigger); if ($result < 0) { $error++; @@ -3140,9 +3141,10 @@ class ContratLigne extends CommonObjectLine * @param User $user Objet User who close contract * @param int $date_end Date end * @param string $comment A comment typed by user + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function close_line($user, $date_end, $comment = '') + function close_line($user, $date_end, $comment = '', $notrigger=0) { global $langs, $conf; @@ -3164,15 +3166,19 @@ class ContratLigne extends CommonObjectLine $sql .= " WHERE rowid = " . $this->id . " AND statut = 4"; $resql = $this->db->query($sql); - if ($resql) { - // Call trigger - $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); - if ($result < 0) { - $error++; - $this->db->rollback(); - return -1; + if ($resql) + { + if (! $notrigger) + { + // Call trigger + $result = $this->call_trigger('LINECONTRACT_CLOSE', $user); + if ($result < 0) { + $error++; + $this->db->rollback(); + return -1; + } + // End call triggers } - // End call triggers $this->db->commit(); return 1; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 65cc2965bea..7991b711660 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1290,8 +1290,6 @@ function complete_elementList_with_modules(&$elementList) $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories - else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; if (! empty($objMod->module_parts['contactelement'])) { diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 9bad202251e..ea7208cc5dd 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -54,7 +54,6 @@ class modAccounting extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); - $this->special = 0; $this->picto = 'accounting'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index aa098146dc7..afdbfcf5ada 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -56,7 +56,6 @@ class modAdherent extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='user'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 89085ea4d6c..01aa8896c35 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -59,7 +59,6 @@ class modAgenda extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='action'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 34c8e62a03f..3e27031fd6f 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -51,7 +51,7 @@ class modApi extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) @@ -60,8 +60,6 @@ class modApi extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index c9fde5f0087..d32a63b5a86 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -58,7 +58,6 @@ class modBanque extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='account'; // Data directories to create when module is enabled @@ -138,8 +137,8 @@ class modBanque extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index da8b51c8e8e..1f734af0871 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -51,7 +51,6 @@ class modBarcode extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; $this->picto='barcode'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index b18f8bebf62..07331bcbc3c 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -55,8 +55,6 @@ class modBlockedLog extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 2; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php index 8924be16ba4..191e12bc2eb 100644 --- a/htdocs/core/modules/modBookmark.class.php +++ b/htdocs/core/modules/modBookmark.class.php @@ -52,7 +52,6 @@ class modBookmark extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; $this->picto='bookmark'; // Data directories to create when module is enabled @@ -98,10 +97,10 @@ class modBookmark extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par d�faut $this->rights[$r][4] = 'supprimer'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } } diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index 33b44297628..4be7a937d1a 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -55,7 +55,6 @@ class modCashDesk extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = 'list'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index b56d405c354..153dd9ae58b 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -54,7 +54,6 @@ class modCategorie extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = 'category'; // Data directories to create when module is enabled @@ -107,12 +106,12 @@ class modCategorie extends DolibarrModules $this->rights[$r][4] = 'supprimer'; $r++; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; @@ -308,7 +307,7 @@ class modCategorie extends DolibarrModules 's.url'=>"company", 's.email'=>"company" ); // We define here only fields that use another picto - + // Add extra fields $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'"; $resql=$this->db->query($sql); @@ -346,7 +345,7 @@ class modCategorie extends DolibarrModules } } // End add axtra fields - + $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p'; $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid'; diff --git a/htdocs/core/modules/modClickToDial.class.php b/htdocs/core/modules/modClickToDial.class.php index c0983cc1a8b..4a5bcfc2f89 100644 --- a/htdocs/core/modules/modClickToDial.class.php +++ b/htdocs/core/modules/modClickToDial.class.php @@ -43,7 +43,7 @@ class modClickToDial extends DolibarrModules $this->db = $db; $this->numero = 58; - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Gestion du Click To Dial"; @@ -51,7 +51,6 @@ class modClickToDial extends DolibarrModules $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 1; $this->picto='phoning'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index 01a80d0b702..5349b000ac3 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -54,8 +54,6 @@ class modCollab extends DolibarrModules $this->version = 'development'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. $this->picto='globe'; diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index e80833ae7c4..aecfb8bd090 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -59,7 +59,6 @@ class modCommande extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='order'; // Data directories to create when module is enabled @@ -104,7 +103,7 @@ class modCommande extends DolibarrModules $this->const[$r][2] = "__(Draft)__"; $this->const[$r][3] = 'Watermark to show on draft orders'; $this->const[$r][4] = 0;*/ - + // Boxes $this->boxes = array( 0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'), @@ -177,12 +176,12 @@ class modCommande extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'export'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index c07318fb36b..41349d214fc 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -57,7 +57,6 @@ class modComptabilite extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='accounting'; // Config pages @@ -94,12 +93,12 @@ class modComptabilite extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'resultat'; $this->rights[$r][5] = 'lire'; - - + + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 1b17b773c77..ac722cd04ef 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -55,7 +55,6 @@ class modContrat extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='contract'; // Data directories to create when module is enabled @@ -71,28 +70,28 @@ class modContrat extends DolibarrModules // Constants $this->const = array(); $r=0; - + $this->const[$r][0] = "CONTRACT_ADDON"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "mod_contract_serpis"; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des contrats'; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "CONTRACT_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "strato"; $this->const[$r][3] = 'Name of PDF model of contract'; $this->const[$r][4] = 0; $r++; - + $this->const[$r][0] = "CONTRACT_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/contracts"; $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + // Boxes $this->boxes = array( 0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'), @@ -103,7 +102,7 @@ class modContrat extends DolibarrModules $this->rights = array(); $this->rights_class = 'contrat'; $r=0; - + $r++; $this->rights[$r][0] = 161; $this->rights[$r][1] = 'Lire les contrats'; @@ -146,12 +145,12 @@ class modContrat extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'export'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $langs->load("contracts"); @@ -223,7 +222,7 @@ class modContrat extends DolibarrModules $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/contracts/template_contract.odt'; $dirodt=DOL_DATA_ROOT.'/doctemplates/contracts'; $dest=$dirodt.'/template_contract.odt'; - + if (file_exists($src) && ! file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -236,12 +235,12 @@ class modContrat extends DolibarrModules return 0; } } - + $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[1][2])."' AND type = 'contract' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[1][2])."','contract',".$conf->entity.")" ); - + return $this->_init($sql,$options); } } diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 8afcc26c80f..b148149910f 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -54,8 +54,6 @@ class modCron extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 2; // Name of image file used for this module. $this->picto = 'technic'; diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index ec8d665b1e0..3baa7b74590 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -54,7 +54,6 @@ class modDeplacement extends DolibarrModules $this->version = 'dolibarr_deprecated'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = "trip"; // Data directories to create when module is enabled @@ -108,12 +107,12 @@ class modDeplacement extends DolibarrModules $this->rights[5][3] = 0; $this->rights[5][4] = 'export'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports $r=0; @@ -134,12 +133,12 @@ class modDeplacement extends DolibarrModules $this->export_sql_end[$r] .=' WHERE d.fk_user = u.rowid'; $this->export_sql_end[$r] .=' AND d.entity IN ('.getEntity('deplacement').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR d.fk_soc IS NULL)'; - + if (! empty($user)) // Not defined during migration process { $childids = $user->getAllChildIds(); $childids[]=$user->id; - + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',',$childids).')'; } } diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index ec40c8b6dc5..211fb38feca 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -53,7 +53,6 @@ class modDocumentGeneration extends DolibarrModules $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='email'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index 08564e241aa..dacfad736bf 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -52,7 +52,6 @@ class modDon extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; // Name of png file (without png) used for this module. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. $this->picto='bill'; diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 21aa3644e3e..c7bc152ff64 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -49,8 +49,6 @@ class modDynamicPrices extends DolibarrModules $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index b263b16e29e..5b85ada7f70 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -57,8 +57,6 @@ class modECM extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (XXX is id value) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 0; // Name of png file (without png) used for this module $this->picto='dir'; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 94c86e6e3b1..6fab26d68f6 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -58,7 +58,6 @@ class modExpedition extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = "sending"; // Data directories to create when module is enabled @@ -222,8 +221,8 @@ class modExpedition extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 4d84c0a6d05..9cc16969748 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -51,7 +51,6 @@ class modExpenseReport extends DolibarrModules $this->description = "Manage and claim expense reports (transportation, meal, ...)"; $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='trip'; // Data directories to create when module is enabled. diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index 4f754711ea1..b88438f5fe1 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -51,7 +51,6 @@ class modExport extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = 'technic'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index e3f4a538c4d..cf02888b9d2 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -52,7 +52,6 @@ class modExternalRss extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 1; $this->picto='rss'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 388bc340776..18bb0b000b2 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -49,7 +49,7 @@ class modExternalSite extends DolibarrModules // Family can be 'crm','financial','hr','projects','product','technic','other' // It is used to sort modules in module setup page - $this->family = "other"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) @@ -58,8 +58,6 @@ class modExternalSite extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (XXX is id value) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 1; // Name of png file (without png) used for this module $this->picto='bookmark'; // Call to inside lang's file diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php index 5e4785d4225..bdd745437e1 100644 --- a/htdocs/core/modules/modFTP.class.php +++ b/htdocs/core/modules/modFTP.class.php @@ -48,7 +48,7 @@ class modFTP extends DolibarrModules // Family can be 'crm','financial','hr','projects','product','ecm','technic','other' // It is used to sort modules in module setup page - $this->family = "other"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description used if translation string 'ModuleXXXDesc' not found (XXX is id value) @@ -57,8 +57,6 @@ class modFTP extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (XXX is id value) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of png file (without png) used for this module $this->picto='dir'; @@ -110,7 +108,7 @@ class modFTP extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'write'; - + // Menus //------- $this->menu[$r]=array('fk_menu'=>0, diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 04628560d74..9a23c0e5e9d 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -57,7 +57,6 @@ class modFacture extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = 'bill'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 54e1eadd735..812aa227ff6 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -52,7 +52,6 @@ class modFckeditor extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; // Name of png file (without png) used for this module. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. $this->picto='list'; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 0d9f73b76e4..0ba8f1bc42d 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -58,7 +58,6 @@ class modFicheinter extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = "intervention"; // Data directories to create when module is enabled @@ -147,12 +146,12 @@ class modFicheinter extends DolibarrModules $this->rights[$r][4] = 'ficheinter_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on $this->rights[$r][5] = 'unvalidate'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + //Exports //-------- $r=1; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 74c0070c92e..6034af489e5 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -59,7 +59,6 @@ class modFournisseur extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='company'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modGeoIPMaxmind.class.php b/htdocs/core/modules/modGeoIPMaxmind.class.php index eeb1b482198..88bc8b7e8b9 100644 --- a/htdocs/core/modules/modGeoIPMaxmind.class.php +++ b/htdocs/core/modules/modGeoIPMaxmind.class.php @@ -44,7 +44,7 @@ class modGeoIPMaxmind extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) @@ -53,8 +53,6 @@ class modGeoIPMaxmind extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png' diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index c8ef071cf7e..8f25ed2025a 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -48,7 +48,7 @@ class modGravatar extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) @@ -57,8 +57,6 @@ class modGravatar extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png' diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 3d1ea43f63c..033b6396fbe 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -31,41 +31,40 @@ class modHRM extends DolibarrModules * Constructor. * Define names, constants, directories, boxes, permissions * - * @param DoliDB $db + * @param DoliDB $db */ public function __construct($db) { global $langs, $conf; - + $this->db = $db; $this->numero = 4000; $this->rights_class = 'hrm'; - + $this->family = "hr"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace( '/^mod/i', '', get_class($this)); $this->description = "Management of employees carrier and feelings (department, employment contract)"; - + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; - + $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); - $this->special = 0; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' $this->picto='generic'; - + // define triggers $this->module_parts = array(); - + // Data directories to create when module is enabled $this->dirs = array(); - + // Config pages $this->config_page_url = array('admin_hrm.php@hrm'); - + // Dependencies $this->depends = array(); $this->requiredby = array(/*" @@ -76,14 +75,14 @@ class modHRM extends DolibarrModules $this->conflictwith = array(); $this->phpmin = array ( 5, - 3 + 3 ); // Minimum version of PHP required by module $this->need_dolibarr_version = array ( 3, - 9 + 9 ); // Minimum version of Dolibarr required by module $this->langfiles = array ( - "hrm" + "hrm" ); // Dictionnaries @@ -95,7 +94,7 @@ class modHRM extends DolibarrModules // Boxes $this->boxes = array (); - + // Permissions $this->rights = array(); // Permission array used by this module $r = 0; @@ -106,21 +105,21 @@ class modHRM extends DolibarrModules $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'read'; $r ++; - + $this->rights[$r][0] = 4002; $this->rights[$r][1] = 'Create employees'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'write'; $r ++; - + $this->rights[$r][0] = 4003; $this->rights[$r][1] = 'Delete employees'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'employee'; $this->rights[$r][5] = 'delete'; $r ++; - + $this->rights[$r][0] = 4004; $this->rights[$r][1] = 'Export employees'; $this->rights[$r][3] = 0; @@ -128,13 +127,13 @@ class modHRM extends DolibarrModules $this->rights[$r][5] = 'export'; $r ++; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } - + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index aef9eb9a7bb..3fd056b525e 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -62,8 +62,6 @@ class modHoliday extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index 18696ef4b11..01d66644dc7 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -51,7 +51,6 @@ class modImport extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto = 'technic'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 7b992fe0fde..7d4d1251f31 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -57,8 +57,6 @@ class modIncoterm extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; $this->picto='generic'; $this->module_parts = array(); diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index 4f7cb8cacbb..2d91fd121bb 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -51,7 +51,6 @@ class modLabel extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 2; $this->picto='label'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index 27174a7dda0..0f183bd6c76 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -42,15 +42,13 @@ class modLdap extends DolibarrModules $this->db = $db; $this->numero = 200; - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Synchronisation Ldap"; // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/images directory, use this->picto=DOL_URL_ROOT.'/module/images/file.png' diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 7e445a3dbce..51779f6ffc5 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -54,7 +54,6 @@ class modLoan extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='bill'; // Data directories to create when module is enabled @@ -118,7 +117,7 @@ class modLoan extends DolibarrModules $this->rights[$r][3] = 0; $this->rights[$r][4] = 'delete'; $this->rights[$r][5] = ''; - + $r++; $this->rights[$r][0] = 525; $this->rights[$r][1] = 'Access loan calculator'; @@ -135,12 +134,12 @@ class modLoan extends DolibarrModules $this->rights[$r][4] = 'export'; $this->rights[$r][5] = ''; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index 64966e2105c..46b31a08696 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -51,7 +51,6 @@ class modMailing extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='email'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 209dcba3d2b..9a019db7fea 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -43,7 +43,7 @@ class modMailmanSpip extends DolibarrModules $this->db = $db; $this->numero = 105; - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Mailman or Spip interface for member module"; @@ -52,7 +52,6 @@ class modMailmanSpip extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 1; $this->picto='technic'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 0a7f1a73a67..53fba120656 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -57,8 +57,6 @@ class modMargin extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 2; // Name of png file (without png) used for this module. // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. $this->picto='margin'; diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 606cdd7af22..2c7b917d6d2 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -51,8 +51,6 @@ class modModuleBuilder extends DolibarrModules $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 9d1be806de1..0dbfe3380cf 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -65,8 +65,6 @@ class modMultiCurrency extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index a4a56e1da0d..cc016d294b5 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -41,7 +41,7 @@ class modNotification extends DolibarrModules $this->db = $db; $this->numero = 600; - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "EMail notifications (push) on business Dolibarr events"; @@ -49,7 +49,6 @@ class modNotification extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 1; $this->picto='email'; // Data directories to create when module is enabled. diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 0dce715a9f4..8b045608a6d 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -46,7 +46,7 @@ class modOauth extends DolibarrModules $this->numero = 66000; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "interface"; $this->module_position = 510; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); @@ -55,8 +55,6 @@ class modOauth extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index ea10750ad7c..fcee9f585aa 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -61,8 +61,6 @@ class modOpenSurvey extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 6cbdd5e2127..164c9b0753a 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -48,7 +48,7 @@ class modPayBox extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "other"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) @@ -57,8 +57,6 @@ class modPayBox extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index 08f1c77e6d6..3ea0535bd4f 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -49,7 +49,7 @@ class modPaypal extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "other"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) @@ -58,8 +58,6 @@ class modPaypal extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index 542a02e7589..4d91c937d99 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -57,7 +57,6 @@ class modPrelevement extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; // Name of png file (without png) used for this module $this->picto='payment'; @@ -74,15 +73,15 @@ class modPrelevement extends DolibarrModules // Constants $this->const = array(); $r=0; - + $this->const[$r][0] = "BANK_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "sepamandate"; $this->const[$r][3] = 'Name of manager to generate SEPA mandate'; $this->const[$r][4] = 0; $r++; - - + + // Boxes $this->boxes = array(); @@ -129,11 +128,11 @@ class modPrelevement extends DolibarrModules $this->rights[2][4] = 'bons'; $this->rights[2][5] = 'configurer'; */ - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - + } @@ -155,7 +154,7 @@ class modPrelevement extends DolibarrModules $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", - ); + ); return $this->_init($sql,$options); } diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index 89bf6115dae..9924e1861b4 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -46,7 +46,7 @@ class modPrinting extends DolibarrModules $this->numero = 64000; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "interface"; $this->module_position = 520; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); @@ -54,8 +54,6 @@ class modPrinting extends DolibarrModules $this->description = "Enable Direct Printing System."; $this->version = 'dolibarr'; // 'development' or 'experimental' or 'dolibarr' or version $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 427b2cd72e0..b2a0a6faf4f 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -59,7 +59,6 @@ class modProduct extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='product'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index 9dbc8eb0212..91e8ddbae3c 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -47,7 +47,7 @@ class modProductBatch extends DolibarrModules $this->family = "products"; $this->module_position = 45; - + $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Batch number, eat-by and sell-by date management module"; @@ -56,7 +56,6 @@ class modProductBatch extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where dluo is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='stock'; @@ -95,12 +94,12 @@ class modProductBatch extends DolibarrModules $this->rights = array(); // Permission array used by this module $r=0; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports $r=0; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index edf5a1ab050..ab837803349 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -58,7 +58,6 @@ class modProjet extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->config_page_url = array("project.php@projet"); $this->picto='project'; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index a6b38f7d5ff..d4db0130492 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -58,7 +58,6 @@ class modPropale extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='propal'; // Data directories to create when module is enabled @@ -101,13 +100,13 @@ class modPropale extends DolibarrModules $this->const[$r][3] = ""; $this->const[$r][4] = 0; $r++; - + /*$this->const[$r][0] = "PROPALE_DRAFT_WATERMARK"; $this->const[$r][2] = "__(Draft)__"; $this->const[$r][3] = 'Watermark to show on draft proposals'; $this->const[$r][4] = 0; $r++;*/ - + // Boxes $this->boxes = array( 0=>array('file'=>'box_graph_propales_permonth.php','enabledbydefaulton'=>'Home'), @@ -170,12 +169,12 @@ class modPropale extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'export'; - + // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 50c93f07220..02e156a7abf 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -46,7 +46,7 @@ class modReceiptPrinter extends DolibarrModules $this->numero = 67000; // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "technic"; + $this->family = "interface"; $this->module_position = 530; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); @@ -55,8 +55,6 @@ class modReceiptPrinter extends DolibarrModules // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version $this->version = 'development'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 148dbece597..a13410ddcf1 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -69,9 +69,6 @@ class modResource extends DolibarrModules // Key used in llx_const table to save module status enabled/disabled // (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name); - // Where to store the module in setup page - // (0=common,1=interface,2=others,3=very specific) - $this->special = 2; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png // use this->picto='pictovalue' diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index aecb9eeb49f..1e648c1386a 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -60,7 +60,6 @@ class modSalaries extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='bill'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 7a9a3f4df3f..20261e98ca6 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -57,7 +57,6 @@ class modService extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='service'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modSkype.class.php b/htdocs/core/modules/modSkype.class.php index 4c7d862cf66..d84520318a3 100644 --- a/htdocs/core/modules/modSkype.class.php +++ b/htdocs/core/modules/modSkype.class.php @@ -44,7 +44,7 @@ class modSkype extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "crm"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable Skype links into contacts"; @@ -52,8 +52,6 @@ class modSkype extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. $this->picto='skype'; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index c41c2d391cc..52e865cbdbc 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -58,7 +58,6 @@ class modSociete extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->config_page_url = array("societe.php@societe"); // Name of image file used for this module. $this->picto='company'; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index c23a02eeac1..ccbf6f83f57 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -57,7 +57,6 @@ class modStock extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='stock'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index 7e6b15dee74..46af17cee55 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -48,7 +48,7 @@ class modStripe extends DolibarrModules // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // It is used to group modules in module setup page - $this->family = "other"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) @@ -57,8 +57,6 @@ class modStripe extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 1; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory, use this->picto=DOL_URL_ROOT.'/module/img/file.png' diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 8869f0cd343..34584ea3ffa 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -56,7 +56,6 @@ class modSupplierProposal extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='supplier_proposal'; $this->dirs = array(); @@ -177,7 +176,7 @@ class modSupplierProposal extends DolibarrModules 'position'=>302 ); $r++; - + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=supplier_proposalsubmenu', 'type'=>'left', @@ -233,8 +232,8 @@ class modSupplierProposal extends DolibarrModules return $this->_init($sql, $options); } - - + + /** * Function called when module is disabled. @@ -249,8 +248,8 @@ class modSupplierProposal extends DolibarrModules $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."rights_def WHERE module = 'askpricesupplier'" ); - + return $this->_remove($sql, $options); - } - + } + } \ No newline at end of file diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index 5f7ad0f387f..97c7b71ae21 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -57,8 +57,6 @@ class modSyslog extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 2; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index 8dfc7283b90..f3fa7d4e9db 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -58,7 +58,6 @@ class modTax extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='bill'; // Data directories to create when module is enabled @@ -119,10 +118,10 @@ class modTax extends DolibarrModules // Menus //------- - + $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Exports //-------- $r=0; @@ -140,7 +139,7 @@ class modTax extends DolibarrModules $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'paiementcharge as p ON p.fk_charge = c.rowid'; $this->export_sql_end[$r] .=' WHERE c.fk_type = cc.id'; $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('tax').')'; - + // Import social contributions $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; @@ -151,14 +150,14 @@ class modTax extends DolibarrModules $this->import_fields_array[$r]=array('t.libelle'=>"Label*",'t.fk_type'=>"Type", 't.amount'=>"Amount*",'t.date_ech'=>"DateDue*",'t.periode'=>"PeriodEndDate*" ); - + $this->import_convertvalue_array[$r]=array( 't.fk_type'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/sociales/class/cchargesociales.class.php','class'=>'Cchargesociales','method'=>'fetch','element'=>'Cchargesociales') ); $this->import_examplevalues_array[$r]=array('t.libelle'=>"Social/fiscal contribution",'t.fk_type'=>"TAXPRO (must be id or code found into dictionary)", 't.date_ech'=>"2016-01-01", 't.periode'=>"2016-01-01" ); - + // Import Taxes $r++; $this->import_code[$r]=$this->rights_class.'_'.$r; @@ -169,14 +168,14 @@ class modTax extends DolibarrModules $this->import_fields_array[$r]=array('t.datep'=>"DatePayment*",'t.datev'=>"DateValue*",'t.label'=>"Label*",'t.fk_typepayment'=>"PaymentMode*", 't.amount'=>"Amount*",'t.num_payment'=>'Numero' ); - + $this->import_convertvalue_array[$r]=array( 't.fk_typepayment'=>array('rule'=>'fetchidfromref','classfile'=>'/compta/paiement/class/cpaiement.class.php','class'=>'Cpaiement','method'=>'fetch','element'=>'Cpaiement') ); $this->import_examplevalues_array[$r]=array('t.label'=>"VAT Payment 1st quarter 2016",'t.fk_typepayment'=>"CHQ (must be id or code found into dictionary)", 't.datep'=>"2016-04-02", 't.datev'=>"2016-03-31", 't.amount'=>1000, 't.num_payment'=>'123456' ); - + } diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 95474ac8921..92323f853f6 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -55,7 +55,6 @@ class modUser extends DolibarrModules $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - $this->special = 0; $this->picto='group'; // Data directories to create when module is enabled diff --git a/htdocs/core/modules/modVariants.class.php b/htdocs/core/modules/modVariants.class.php index 358a35b4435..87a2e2ce491 100644 --- a/htdocs/core/modules/modVariants.class.php +++ b/htdocs/core/modules/modVariants.class.php @@ -62,8 +62,6 @@ class modVariants extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index ae979eb026e..8963f81813f 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -40,7 +40,7 @@ class modWebServices extends DolibarrModules $this->db = $db; $this->numero = 2600; - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the Dolibarr web services server"; @@ -48,8 +48,6 @@ class modWebServices extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index 2dd0ee871c5..9b6535143b3 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -40,7 +40,7 @@ class modWebServicesClient extends DolibarrModules $this->db = $db; $this->numero = 2660; - $this->family = "technic"; + $this->family = "interface"; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the web service client to call external supplier web services"; @@ -48,8 +48,6 @@ class modWebServicesClient extends DolibarrModules $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 1; // Name of image file used for this module. $this->picto='technic'; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index d62576c5063..fb6e91283db 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -54,8 +54,6 @@ class modWebsite extends DolibarrModules $this->version = 'experimental'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 0; // Name of image file used for this module. $this->picto='globe'; diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 5c348cdf77f..e721513073a 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -56,8 +56,6 @@ class modWorkflow extends DolibarrModules $this->version = 'dolibarr'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) - $this->special = 2; // Name of png file (without png) used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 1d8ba3dace6..eea2a85e656 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -53,7 +53,7 @@ class modMyModule extends DolibarrModules // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'mymodule'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','interface','other' + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' // It is used to group modules by family in module setup page $this->family = "other"; // Module position in the family on 2 digits ('01', '10', '20', ...) diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 61685ed8267..81450bd8a04 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -178,8 +178,6 @@ foreach ($modulesdir as $dir) $filename[$i]= $modName; $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module //print "x".$modName." ".$orders[$i]."\n
"; - if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories - else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; $j++; $i++; From dd204947b8fff0c09ccaf3c0b82cc551a061da2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 11:00:50 +0100 Subject: [PATCH 101/125] CSS --- htdocs/public/demo/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/demo/index.php b/htdocs/public/demo/index.php index 81450bd8a04..61919c54b1a 100644 --- a/htdocs/public/demo/index.php +++ b/htdocs/public/demo/index.php @@ -327,7 +327,7 @@ foreach ($demoprofiles as $profilearray) print '
'; } - print '
'."\n"; + print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -338,7 +338,7 @@ foreach ($demoprofiles as $profilearray) print ''."\n"; print ''."\n"; - print '
'."\n"; + print '
'."\n"; print '
'; From 2d252e85e6a1728f2edb456df781c9fab277acf4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 12:13:34 +0100 Subject: [PATCH 102/125] FIX Import process must stop after ending line nb to import --- htdocs/imports/import.php | 107 +++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 82ecad62417..abf3ec45c7c 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -225,7 +225,7 @@ if ($step == 3 && $datatoimport) $param='&datatoimport='.$datatoimport.'&format='.$format; if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline; if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb; - + $file = $conf->import->dir_temp . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $ret=dol_delete_file($file); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); @@ -429,9 +429,9 @@ if ($step == 2 && $datatoimport) print ''; print '

'; - + dol_fiche_end(); - + print ''; print ''; @@ -450,7 +450,7 @@ if ($step == 2 && $datatoimport) $liste=$objmodelimport->liste_modeles($db); foreach($liste as $key) { - + print ''; print ''.img_picto_common($key,$objmodelimport->getPictoForKey($key)).''; $text=$objmodelimport->getDriverDescForKey($key); @@ -495,7 +495,7 @@ if ($step == 3 && $datatoimport) print '
'; print '
'; - + print ''; // Module @@ -516,11 +516,11 @@ if ($step == 3 && $datatoimport) print '
'; print '
'; - + print '
'; - + print ''.$langs->trans("InformationOnSourceFile").''; - + print '
'; print '
'; print ''; @@ -537,15 +537,15 @@ if ($step == 3 && $datatoimport) print '
'; print '
'; - + dol_fiche_end(); print '
'; - + print ''; print ''; print ''; - + print ''; print ''; print ''; @@ -553,7 +553,7 @@ if ($step == 3 && $datatoimport) print ''; print ''; print ''; - + print ''; $filetoimport=''; @@ -613,7 +613,7 @@ if ($step == 3 && $datatoimport) $modulepart='import'; $urlsource=$_SERVER["PHP_SELF"].'?step='.$step.$param.'&filetoimport='.urlencode($filetoimport); $relativepath=$file; - + print ''; print ''; print '
'.img_mime($file).''; @@ -665,9 +665,9 @@ if ($step == 4 && $datatoimport) header("Location: ".$_SERVER["PHP_SELF"].'?step=3'.$param.'&filetoimport='.urlencode($relativepath)); exit; } - + } - + if (GETPOST('update')) { $array_match_file_to_database=array(); } @@ -772,9 +772,9 @@ if ($step == 4 && $datatoimport) print '
'; print '
'; - + print '
'; - + print ''.$langs->trans("InformationOnSourceFile").''; print '
'; print '
'; @@ -820,9 +820,9 @@ if ($step == 4 && $datatoimport) print ''; print '
'; - + dol_fiche_end(); - + print '
'."\n"; @@ -873,7 +873,7 @@ if ($step == 4 && $datatoimport) $lefti=1; foreach ($array_match_file_to_database as $key => $val) { - + show_elem($fieldssource,$key,$val,$var); // key is field number in source file //print '> '.$lefti.'-'.$key.'-'.$val; $listofkeys[$key]=1; @@ -890,7 +890,7 @@ if ($step == 4 && $datatoimport) $num=count($fieldssource); while ($lefti <= $num) { - + $newkey=getnewkey($fieldssource,$listofkeys); show_elem($fieldssource,$newkey,'',$var); // key start after field number in source file //print '> '.$lefti.'-'.$newkey; @@ -913,7 +913,7 @@ if ($step == 4 && $datatoimport) print ''; foreach($fieldstarget as $code=>$label) { - + print ''; $i++; @@ -1148,7 +1148,7 @@ if ($step == 4 && $datatoimport) $var=false; while ($i < $num) { - + $obj = $db->fetch_object($resql); print '
'; print $obj->label; @@ -1213,16 +1213,16 @@ if ($step == 5 && $datatoimport) if ($excludefirstline) $param.='&excludefirstline='.$excludefirstline; if ($endatlinenb) $param.='&endatlinenb='.$endatlinenb; if (!empty($updatekeys)) $param.='&updatekeys[]='.implode('&updatekeys[]=', $updatekeys); - + llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones'); $head = import_prepare_head($param,5); - + print ''; print ''; // step 5 print ''; // step 5 - + dol_fiche_head($head, 'step5', $langs->trans("NewImport"), -1); print '
'; @@ -1248,9 +1248,9 @@ if ($step == 5 && $datatoimport) print '
'; print '
'; - + print '
'; - + print ''.$langs->trans("InformationOnSourceFile").''; print '
'; print '
'; @@ -1274,7 +1274,7 @@ if ($step == 5 && $datatoimport) print htmlentities($enclosure); print ''; } - + // File to import print ''.$langs->trans("FileToImport").''; print ''; @@ -1351,16 +1351,16 @@ if ($step == 5 && $datatoimport) print_r($objimport->array_import_updatekeys); echo '';*/ print ''; - + print ''; print '
'; - + print '
'; print ''.$langs->trans("InformationOnTargetTables").''; print '
'; print '
'; - + print ''; //print ''; @@ -1426,7 +1426,7 @@ if ($step == 5 && $datatoimport) print '
'.$langs->trans("InformationOnTargetTables").'
'; print '
'; - + dol_fiche_end(); @@ -1475,10 +1475,11 @@ if ($step == 5 && $datatoimport) $sourcelinenb=0; $endoffile=0; // Loop on each input file record - while ($sourcelinenb < $nboflines && ! $endoffile) + while (($sourcelinenb < $nboflines) && ! $endoffile) { $sourcelinenb++; // Read line and stor it into $arrayrecord + //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb); $arrayrecord=$obj->import_read_record(); if ($arrayrecord === false) { @@ -1487,11 +1488,11 @@ if ($step == 5 && $datatoimport) continue; } if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; - + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; + // Run import $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); - + if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors; if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings; if (! count($obj->errors) && ! count($obj->warnings)) $nbok++; @@ -1505,7 +1506,7 @@ if ($step == 5 && $datatoimport) } $error=0; - + // Run the sql after import if defined //var_dump($objimport->array_import_run_sql_after[0]); if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) @@ -1515,14 +1516,14 @@ if ($step == 5 && $datatoimport) { $i++; $resqlafterimport=$db->query($sqlafterimport); - if (! $resqlafterimport) + if (! $resqlafterimport) { $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); $error++; } } } - + $db->rollback(); // We force rollback because this was just a simulation. // Show OK @@ -1613,7 +1614,7 @@ if ($step == 5 && $datatoimport) print ''.$langs->trans("RunImportFile").''; } print '
'; - + } print ''; @@ -1690,9 +1691,9 @@ if ($step == 6 && $datatoimport) print ''; print ''; - + print '
'; - + print ''.$langs->trans("InformationOnSourceFile").'
'; print ''; //print ''; @@ -1714,7 +1715,7 @@ if ($step == 6 && $datatoimport) print htmlentities($enclosure); print ''; } - + // File to import print ''; print ''; - + print '
'.$langs->trans("InformationOnSourceFile").'
'.$langs->trans("FileToImport").''; @@ -1745,7 +1746,7 @@ if ($step == 6 && $datatoimport) print ''; print ''; print '
'; print '
'; @@ -1848,11 +1849,11 @@ if ($step == 6 && $datatoimport) continue; } if ($excludefirstline && ($sourcelinenb < $excludefirstline)) continue; - if ($endatlinenb && ($sourcelinenb > $endatlinenb)) continue; + if ($endatlinenb && ($sourcelinenb > $endatlinenb)) break; // Run import $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport,count($fieldssource),$importid,$updatekeys); - + if (count($obj->errors)) $arrayoferrors[$sourcelinenb]=$obj->errors; if (count($obj->warnings)) $arrayofwarnings[$sourcelinenb]=$obj->warnings; if (! count($obj->errors) && ! count($obj->warnings)) $nbok++; @@ -1866,10 +1867,10 @@ if ($step == 6 && $datatoimport) } if (count($arrayoferrors) > 0) $db->rollback(); // We force rollback because this was errors. - else + else { $error=0; - + // Run the sql after import if defined //var_dump($objimport->array_import_run_sql_after[0]); if (! empty($objimport->array_import_run_sql_after[0]) && is_array($objimport->array_import_run_sql_after[0])) @@ -1879,18 +1880,18 @@ if ($step == 6 && $datatoimport) { $i++; $resqlafterimport=$db->query($sqlafterimport); - if (! $resqlafterimport) + if (! $resqlafterimport) { $arrayoferrors['none'][]=array('lib'=>$langs->trans("Error running final request: ".$sqlafterimport)); $error++; } } } - + if (! $error) $db->commit(); // We can commit if no errors. else $db->rollback(); } - + dol_fiche_end(); @@ -1930,7 +1931,7 @@ function show_elem($fieldssource,$pos,$key,$var,$nostyle='') global $langs,$bc; $height='24'; - + print "\n\n\n"; print '
'."\n"; From 7b448a2d18b0e2b78b614642cc979aa59842ad28 Mon Sep 17 00:00:00 2001 From: Rui Strecht Date: Thu, 22 Feb 2018 12:22:31 +0000 Subject: [PATCH 103/125] Fixed issue with elementarray null if num_rows = 0 --- htdocs/projet/class/project.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index e24a444702c..d9eeee14d89 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -583,10 +583,10 @@ class Project extends CommonObject $i++; } $this->db->free($result); - - /* Return array */ - return $elements; } + + /* Return array even if empty*/ + return $elements; } else { From 4581d6049cb17b641bbd29eedd98ee76e6e40d8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 12:52:39 +0100 Subject: [PATCH 104/125] Update societecontact.php --- htdocs/societe/societecontact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index bac674b4e2b..67a44d87ccf 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -223,7 +223,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_soc = ".$id; - $sql.= " AND fk_adherent_type = t.rowid"; + $sql.= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); $resql = $db->query($sql); From 0a571a0677a90560d2e175e03660a861beb0fb5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 12:58:17 +0100 Subject: [PATCH 105/125] Complete fix #8230 --- htdocs/modulebuilder/template/myobject_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index fa06a7e7d05..ed8e58e1c12 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -407,7 +407,7 @@ foreach($object->fields as $key => $val) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],'','','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; From 1f60d9ba81534d799349a87d8b37e0ba1b5d1899 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 13:14:55 +0100 Subject: [PATCH 106/125] Fix travis --- htdocs/core/modules/modHRM.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 033b6396fbe..a209fdccf2e 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -31,7 +31,7 @@ class modHRM extends DolibarrModules * Constructor. * Define names, constants, directories, boxes, permissions * - * @param DoliDB $db + * @param DoliDB $db Database handler */ public function __construct($db) { From 2cd5ed65a658dec9cc94d2bb900a944554db09a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 14:13:09 +0100 Subject: [PATCH 107/125] Clean deprecated (field unit_charge in supplier price) --- htdocs/core/class/html.formmargin.class.php | 4 +--- .../fourn/class/fournisseur.product.class.php | 24 ++++++------------- .../install/mysql/migration/7.0.0-8.0.0.sql | 2 ++ .../tables/llx_product_fournisseur_price.sql | 5 ++-- htdocs/product/composition/card.php | 2 +- htdocs/product/fournisseurs.php | 17 ------------- htdocs/product/list.php | 2 +- 7 files changed, 14 insertions(+), 42 deletions(-) diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 5f78fa0e283..cf1b7064a01 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -85,8 +85,6 @@ class FormMargin $product = new ProductFournisseur($db); if ($product->fetch_product_fournisseur_price($line->fk_fournprice)) $line->pa_ht = $product->fourn_unitprice * (1 - $product->fourn_remise_percent / 100); - if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == "2" && $product->fourn_unitcharges > 0) - $line->pa_ht += $product->fourn_unitcharges; } // si prix d'achat non renseigné et devrait l'être, alors prix achat = prix vente if ((!isset($line->pa_ht) || $line->pa_ht == 0) && $line->subprice > 0 && (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1)) { @@ -96,7 +94,7 @@ class FormMargin $pv = $line->qty * $line->subprice * (1 - $line->remise_percent / 100); $pa_ht = ($pv < 0 ? - $line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign $pa = $line->qty * $pa_ht; - + // calcul des marges if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 74da470c04c..c8c24afc942 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -64,10 +64,6 @@ class ProductFournisseur extends Product var $fourn_unitprice; var $fourn_tva_tx; var $fourn_tva_npr; - /** - * @deprecated - */ - var $fourn_unitcharges; // old version used a buggy system to calculate margin of a charge field on supplier price. Now margin is on pmp, best supplier price or cost price. var $fk_supplier_price_expression; var $supplier_reputation; // reputation of supplier @@ -215,7 +211,6 @@ class ProductFournisseur extends Product $error=0; $unitBuyPrice = price2num($buyprice/$qty,'MU'); - $unitCharges = price2num($charges/$qty,'MU'); $now=dol_now(); @@ -250,7 +245,6 @@ class ProductFournisseur extends Product $sql.= " remise_percent = ".$remise_percent.","; $sql.= " remise = ".$remise.","; $sql.= " unitprice = ".$unitBuyPrice.","; - $sql.= " unitcharges = ".$unitCharges.","; // deprecated $sql.= " fk_availability = ".$availability.","; $sql.= " entity = ".$conf->entity.","; $sql.= " tva_tx = ".price2num($tva_tx).","; @@ -306,7 +300,7 @@ class ProductFournisseur extends Product if ($resql) { // Add price for this quantity to supplier $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price("; - $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, unitcharges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; + $sql .= "datec, fk_product, fk_soc, ref_fourn, fk_user, price, quantity, remise_percent, remise, unitprice, tva_tx, charges, fk_availability, default_vat_code, info_bits, entity, delivery_time_days, supplier_reputation)"; $sql .= " values('" . $this->db->idate($now) . "',"; $sql .= " " . $this->id . ","; $sql .= " " . $fourn->id . ","; @@ -319,7 +313,6 @@ class ProductFournisseur extends Product $sql .= " " . $unitBuyPrice . ","; $sql .= " " . $tva_tx . ","; $sql .= " " . $charges . ","; - $sql .= " " . $unitCharges . ","; $sql .= " " . $availability . ","; $sql .= " ".($newdefaultvatcode?"'".$this->db->escape($newdefaultvatcode)."'":"null").","; $sql .= " " . $newnpr . ","; @@ -393,7 +386,7 @@ class ProductFournisseur extends Product { global $conf; $sql = "SELECT pfp.rowid, pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.default_vat_code, pfp.fk_availability,"; - $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.unitcharges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price + $sql.= " pfp.fk_soc, pfp.ref_fourn, pfp.fk_product, pfp.charges, pfp.fk_supplier_price_expression, pfp.delivery_time_days,"; // , pfp.recuperableonly as fourn_tva_npr"; FIXME this field not exist in llx_product_fournisseur_price $sql.= " pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.rowid = ".$rowid; @@ -418,7 +411,6 @@ class ProductFournisseur extends Product $this->fourn_remise_percent = $obj->remise_percent; $this->fourn_remise = $obj->remise; $this->fourn_unitprice = $obj->unitprice; - $this->fourn_unitcharges = $obj->unitcharges; // deprecated $this->fourn_tva_tx = $obj->tva_tx; // TODO // $this->fourn_tva_npr = $obj->fourn_tva_npr; // TODO this field not exist in llx_product_fournisseur_price. We should add it ? @@ -478,7 +470,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_pri_id, pfp.ref_fourn, pfp.fk_product as product_fourn_id, pfp.fk_supplier_price_expression,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.unitcharges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.remise_percent, pfp.remise, pfp.tva_tx, pfp.fk_availability, pfp.charges, pfp.info_bits, pfp.delivery_time_days, pfp.supplier_reputation"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; $sql.= " WHERE pfp.entity IN (".getEntity('productprice').")"; @@ -510,7 +502,6 @@ class ProductFournisseur extends Product $prodfourn->fourn_remise = $record["remise"]; $prodfourn->fourn_unitprice = $record["unitprice"]; $prodfourn->fourn_charges = $record["charges"]; // deprecated - $prodfourn->fourn_unitcharges = $record["unitcharges"]; // deprecated $prodfourn->fourn_tva_tx = $record["tva_tx"]; $prodfourn->fourn_id = $record["fourn_id"]; $prodfourn->fourn_name = $record["supplier_name"]; @@ -588,7 +579,7 @@ class ProductFournisseur extends Product $sql = "SELECT s.nom as supplier_name, s.rowid as fourn_id,"; $sql.= " pfp.rowid as product_fourn_price_id, pfp.ref_fourn,"; - $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges, pfp.unitcharges, "; + $sql.= " pfp.price, pfp.quantity, pfp.unitprice, pfp.tva_tx, pfp.charges,"; $sql.= " pfp.remise, pfp.remise_percent, pfp.fk_supplier_price_expression, pfp.delivery_time_days"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE s.entity IN (".getEntity('societe').")"; @@ -623,7 +614,7 @@ class ProductFournisseur extends Product { $fourn_price = $record["price"]; // discount calculated buy price - $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) + $record["unitcharges"] - $record["remise"]; + $fourn_unitprice = $record["unitprice"] * (1 - $record["remise_percent"] / 100) - $record["remise"]; if (!empty($conf->dynamicprices->enabled) && !empty($record["fk_supplier_price_expression"])) { $prod_supplier = new ProductFournisseur($this->db); $prod_supplier->product_fourn_price_id = $record["product_fourn_price_id"]; @@ -657,7 +648,6 @@ class ProductFournisseur extends Product $this->fourn_remise = $record["remise"]; $this->fourn_unitprice = $record["unitprice"]; $this->fourn_charges = $record["charges"]; // deprecated - $this->fourn_unitcharges = $record["unitcharges"]; // deprecated $this->fourn_tva_tx = $record["tva_tx"]; $this->fourn_id = $record["fourn_id"]; $this->fourn_name = $record["supplier_name"]; @@ -755,14 +745,14 @@ class ProductFournisseur extends Product $out .= ''.$langs->trans("Supplier").''; $out .= ''.$langs->trans("SupplierRef").''; foreach ($productFournList as $productFourn) { - $out.= ''.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) + $productFourn->fourn_unitcharges - $productFourn->fourn_remise):'').''; + $out.= ''.($showunitprice?price($productFourn->fourn_unitprice * (1 -$productFourn->fourn_remise_percent/100) - $productFourn->fourn_remise):'').''; $out.= ''.($showunitprice?$productFourn->fourn_qty:'').''; $out.= ''.$productFourn->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).''; $out.= ''.$productFourn->fourn_ref.''; } $out .= ''; } else { - $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, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); + $out=($showunitprice?price($this->fourn_unitprice * (1 - $this->fourn_remise_percent/100) + $this->fourn_remise).' '.$langs->trans("HT").'   (':'').($showsuptitle?$langs->trans("Supplier").': ':'').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->fourn_ref.($showunitprice?')':''); } return $out; } diff --git a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql index 6488a7dafde..79148c6887d 100644 --- a/htdocs/install/mysql/migration/7.0.0-8.0.0.sql +++ b/htdocs/install/mysql/migration/7.0.0-8.0.0.sql @@ -29,6 +29,8 @@ -- For 8.0 +ALTER TABLE llx_product_fournisseur_price DROP COLUMN unitcharges; + ALTER TABLE llx_societe ADD COLUMN fk_entrepot integer DEFAULT 0; ALTER TABLE llx_projet ADD COLUMN bill_time integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql index 1c86bfe04f8..14664225a9d 100755 --- a/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql +++ b/htdocs/install/mysql/tables/llx_product_fournisseur_price.sql @@ -29,13 +29,12 @@ create table llx_product_fournisseur_price fk_soc integer, ref_fourn varchar(30), fk_availability integer, - price double(24,8) DEFAULT 0, + price double(24,8) DEFAULT 0, -- price without tax for quantity quantity double, remise_percent double NOT NULL DEFAULT 0, remise double NOT NULL DEFAULT 0, - unitprice double(24,8) DEFAULT 0, + unitprice double(24,8) DEFAULT 0, -- unit price without tax charges double(24,8) DEFAULT 0, -- to store transport cost. Constant PRODUCT_CHARGES must be set to see it. - unitcharges double(24,8) DEFAULT 0, -- deprecated default_vat_code varchar(10), tva_tx double(6,3) NOT NULL, localtax1_tx double(6,3) DEFAULT 0, diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index a6cc3427243..79120aa1191 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -370,7 +370,7 @@ if ($id > 0 || ! empty($ref)) } print ''; - $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise), 'MT'); + $totalline=price2num($value['nb'] * ($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise), 'MT'); $total+=$totalline; print ''; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 5219291e8af..4f266611940 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -638,11 +638,6 @@ if ($id > 0 || $ref) print_liste_field_titre("DiscountQtyMin",$_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("NbDaysToDelivery",$_SERVER["PHP_SELF"],"pfp.delivery_time_days","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("ReputationForThisProduct",$_SERVER["PHP_SELF"],"pfp.supplier_reputation","",$param,'align="center"',$sortfield,$sortorder); - // Charges ???? - if ($conf->global->PRODUCT_CHARGES) - { - if (! empty($conf->margin->enabled)) print_liste_field_titre("UnitCharges"); - } print_liste_field_titre(''); print "\n"; @@ -708,18 +703,6 @@ if ($id > 0 || $ref) } print''; - // Charges ???? - /* - if ($conf->global->PRODUCT_CHARGES) - { - if (! empty($conf->margin->enabled)) - { - print ''; - print $productfourn->fourn_unitcharges?price($productfourn->fourn_unitcharges) : ($productfourn->fourn_qty?price($productfourn->fourn_charges/$productfourn->fourn_qty):" "); - print ''; - } - }*/ - if (is_object($hookmanager)) { $parameters=array('id_pfp'=>$productfourn->product_fourn_price_id,'id_fourn'=>$id_fourn,'prod_id'=>$object->id); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ebb2c0a421a..59b76ecab69 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -793,7 +793,7 @@ else if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } From 251136bebf0cf02b216daa69463384b0c05b7b0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 15:00:14 +0100 Subject: [PATCH 108/125] Fix PHPUnit --- htdocs/compta/facture/class/facture.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 589a184030e..ea06bd61dbd 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3846,6 +3846,7 @@ class Facture extends CommonInvoice // Initialize parameters $this->id=0; + $this->entity = 1; $this->ref = 'SPECIMEN'; $this->specimen=1; $this->socid = 1; From 0d125524456a9a7dd655975223f98653b4ad40e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 11:57:29 +0100 Subject: [PATCH 109/125] NEW Can enter time spent from the list of time spent of project --- htdocs/core/class/html.formprojet.class.php | 67 ++++++----- htdocs/projet/class/project.class.php | 6 +- htdocs/projet/tasks.php | 17 ++- htdocs/projet/tasks/time.php | 126 +++++++++++++++++--- 4 files changed, 156 insertions(+), 60 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index f1d407d3bba..9f03213a16d 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -292,7 +292,7 @@ class FormProjets } /** - * Output a combo list with projects qualified for a third party + * Output a combo list with tasks qualified for a third party * * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) * @param int $selected Id task preselected @@ -304,9 +304,11 @@ class FormProjets * @param int $forcefocus Force focus on field (works with javascript only) * @param int $disabled Disabled * @param string $morecss More css added to the select component + * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. + * @param string $showproject 'all' = Show project info, ''=Hide project info * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500') + function selectTasks($socid=-1, $selected='', $htmlname='taskid', $maxlength=24, $option_only=0, $show_empty='1', $discard_closed=0, $forcefocus=0, $disabled=0, $morecss='maxwidth500', $projectsListId='', $showproject='all') { global $user,$conf,$langs; @@ -317,11 +319,13 @@ class FormProjets $hideunselectables = false; if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; - $projectsListId = false; - if (empty($user->rights->projet->all->lire)) + if (empty($projectsListId)) { - $projectstatic=new Project($this->db); - $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + if (empty($user->rights->projet->all->lire)) + { + $projectstatic=new Project($this->db); + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + } } // Search all projects @@ -332,7 +336,7 @@ class FormProjets $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t'; $sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND t.fk_projet = p.rowid"; - if ($projectsListId !== false) $sql.= " AND p.rowid IN (".$projectsListId.")"; + if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; $sql.= " ORDER BY p.ref, t.ref ASC"; @@ -378,31 +382,38 @@ class FormProjets continue; } - $labeltoshow=dol_trunc($obj->ref,18); // Project ref - //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; - //else $labeltoshow.=' ('.$langs->trans("Private").')'; - $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); + $labeltoshow = ''; - if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; + if ($showproject == 'all') + { + $labeltoshow.=dol_trunc($obj->ref,18); // Project ref + //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; + //else $labeltoshow.=' ('.$langs->trans("Private").')'; + $labeltoshow.=' '.dol_trunc($obj->title,$maxlength); - $disabled=0; - if ($obj->fk_statut == 0) - { - $disabled=1; - $labeltoshow.=' - '.$langs->trans("Draft"); - } - else if ($obj->fk_statut == 2) - { - if ($discard_closed == 2) $disabled=1; - $labeltoshow.=' - '.$langs->trans("Closed"); - } - else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) - { - $disabled=1; - $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); + if ($obj->name) $labeltoshow.=' ('.$obj->name.')'; + + $disabled=0; + if ($obj->fk_statut == 0) + { + $disabled=1; + $labeltoshow.=' - '.$langs->trans("Draft"); + } + else if ($obj->fk_statut == 2) + { + if ($discard_closed == 2) $disabled=1; + $labeltoshow.=' - '.$langs->trans("Closed"); + } + else if ($socid > 0 && (! empty($obj->fk_soc) && $obj->fk_soc != $socid)) + { + $disabled=1; + $labeltoshow.=' - '.$langs->trans("LinkedToAnotherCompany"); + } + $labeltoshow.=' - '; } + // Label for task - $labeltoshow.=' - '.$obj->tref.' '.dol_trunc($obj->tlabel,$maxlength); + $labeltoshow.=$obj->tref.' '.dol_trunc($obj->tlabel,$maxlength); if (!empty($selected) && $selected == $obj->rowid) { diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index c8096559c9c..6e8c12793cc 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1141,10 +1141,10 @@ class Project extends CommonObject * * @param User $user User object * @param int $mode 0=All project I have permission on (assigned to me and public), 1=Projects assigned to me only, 2=Will return list of all projects with no test on contacts - * @param int $list 0=Return array,1=Return string list + * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party - * @param string $filter additionnal filter on project (statut, ref, ...) - * @return array or string Array of projects id, or string with projects id separated with "," + * @param string $filter additionnal filter on project (statut, ref, ...) + * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 */ function getProjectsAuthorizedForUser($user, $mode=0, $list=0, $socid=0, $filter='') { diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 11367951976..2eb9bc1e44f 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -455,29 +455,25 @@ else if ($id > 0 || ! empty($ref)) } } + print '
'; - /* - * Actions - */ - print '
'; - + // Link to create task if ($user->rights->projet->all->creer || $user->rights->projet->creer) { if ($object->public || $userWrite > 0) { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetask = ''.$langs->trans('AddTask').''; } - print '
'; print '
'; @@ -492,8 +488,9 @@ else if ($id > 0 || ! empty($ref)) $title=$langs->trans("ListOfTasks"); $linktotasks=''.$langs->trans("GoToListOfTimeConsumed").''; + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks,'title_generic.png'); + print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'title_generic.png'); // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 49e917e4b61..44bed2119d2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; $langs->load('projects'); @@ -38,6 +39,7 @@ $projectid=GETPOST('projectid','int'); $ref=GETPOST('ref','alpha'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); +$cancel=GETPOST('cancel','alpha'); $withproject=GETPOST('withproject','int'); $project_ref=GETPOST('project_ref','alpha'); @@ -89,6 +91,8 @@ $extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_e * Actions */ +if (GETPOST('cancel','alpha')) { $action=''; } + $parameters=array('socid'=>$socid, 'projectid'=>$projectid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -137,10 +141,17 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) if (! $error) { - $object->fetch($id, $ref); + if ($id || $ref) + { + $object->fetch($id, $ref); + } + else + { + $object->fetch(GETPOST('taskid','int')); + } $object->fetch_projet(); - if (empty($object->projet->statut)) + if (empty($object->project->statut)) { setEventMessages($langs->trans("ProjectMustBeValidatedFirst"), null, 'errors'); $error++; @@ -175,7 +186,8 @@ if ($action == 'addtimespent' && $user->rights->projet->lire) } else { - $action=''; + if (empty($id)) $action='createtime'; + else $action='createtime'; } } @@ -277,6 +289,7 @@ llxHeader("",$langs->trans("Task")); $form = new Form($db); $formother = new FormOther($db); +$formproject = new FormProjets($db); $userstatic = new User($db); if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) @@ -398,35 +411,26 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); - /* - * Actions - */ + print '
'; + // Link to create time if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) { - print '
'; - if ($user->rights->projet->all->creer || $user->rights->projet->creer) { if ($object->public || $userWrite > 0) { - print ''.$langs->trans('AddTask').''; + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetime = ''.$langs->trans('AddTime').''; } } else { - print ''.$langs->trans('AddTask').''; + $linktocreatetime = ''.$langs->trans('AddTime').''; } - - print '
'; - } - else - { - print '
'; } } } @@ -528,12 +532,14 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) /* - * Form to add time spent + * Form to add time spent on task */ + if ($user->rights->projet->lire) { print '
'; + print ''."\n"; print ''; print ''; print ''; @@ -676,7 +682,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $title=$langs->trans("ListTaskTimeUserProject"); $linktotasks=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks,'title_generic.png'); + print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime,'title_generic.png'); } $i = 0; @@ -694,6 +700,88 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) } + /* + * Form to add time spent + */ + if ($action == 'createtime' && empty($id) && $user->rights->projet->lire) + { + print ''."\n"; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + print ''; + + // Date + print ''; + + // Task + print ''; + + // Contributor + print ''; + + // Note + print ''; + + // Duration - Time spent + print ''; + + // Progress declared + print ''; + + print ''; + + print '
'.$langs->trans("Date").''.$langs->trans("Task").''.$langs->trans("By").''.$langs->trans("Note").''.$langs->trans("NewTimeSpent").''.$langs->trans("ProgressDeclared").'
'; + //$newdate=dol_mktime(12,0,0,$_POST["timemonth"],$_POST["timeday"],$_POST["timeyear"]); + $newdate=''; + print $form->select_date($newdate, 'time', ($conf->browser->layout == 'phone'?2:1), 1, 2, "timespent_date", 1, 0, 1); + print ''; + $formproject->selectTasks(-1, GETPOST('taskid','int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); + print ''; + print img_object('','user','class="hideonsmartphone"'); + $contactsofproject=$projectstatic->getListContactId('internal'); + if (count($contactsofproject)>0) + { + if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; + else $userid=$contactsofproject[0]; + if ($projectstatic->public) $contactsofproject = array(); + print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); + } + else + { + print img_error($langs->trans('FirstAddRessourceToAllocateTime')).$langs->trans('FirstAddRessourceToAllocateTime'); + } + print ''; + print ''; + print ''; + print $form->select_duration('timespent_duration', ($_POST['timespent_duration']?$_POST['timespent_duration']:''), 0, 'text'); + print ''; + print $formother->select_percent(GETPOST('progress')?GETPOST('progress'):$object->progress,'progress'); + print ''; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + + $arrayofselected=is_array($toselect)?$toselect:array(); $params=''; From 46f70ebf8e2cea36b5ccd0d2c3d9617b5a01b3d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 12:01:13 +0100 Subject: [PATCH 110/125] FIX Useless clean of tree --- htdocs/projet/tasks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 2eb9bc1e44f..4a5bcdab70b 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -575,7 +575,7 @@ else if ($id > 0 || ! empty($ref)) } else { - if ($nboftaskshown < count($tasksarray)) + if ($nboftaskshown < count($tasksarray) && ! GETPOST('search_user_id','int')) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; cleanCorruptedTree($db, 'projet_task', 'fk_task_parent'); From 46c2f098e04be71ccb2e9ab78b2fd7ceca9b4fde Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 12:21:01 +0100 Subject: [PATCH 111/125] NEW Can enter time spent from the list of time spent of project --- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/tasks/time.php | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ab044618556..dd79af04bcb 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -91,6 +91,7 @@ ListDonationsAssociatedProject=List of donations associated with the project ListVariousPaymentsAssociatedProject=List of miscellaneous payments associated with the project ListActionsAssociatedProject=List of events associated with the project ListTaskTimeUserProject=List of time consumed on tasks of project +ListTaskTimeForTask=List of time consumed on task ActivityOnProjectToday=Activity on project today ActivityOnProjectYesterday=Activity on project yesterday ActivityOnProjectThisWeek=Activity on project this week diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 44bed2119d2..57294fda1de 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -410,17 +410,16 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); - print '
'; // Link to create time - if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) - { + //if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) + //{ if ($user->rights->projet->all->creer || $user->rights->projet->creer) { - if ($object->public || $userWrite > 0) + if ($projectstatic->public || $userWrite > 0) { - $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; + $linktocreatetime = ''.$langs->trans('AddTimeSpent').''; } else { @@ -431,7 +430,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { $linktocreatetime = ''.$langs->trans('AddTime').''; } - } + //} } } @@ -531,14 +530,17 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); + $title=$langs->trans("ListTaskTimeForTask"); + //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); + print load_fiche_titre($title, $linktocreatetime, 'title_generic.png'); + + /* * Form to add time spent on task */ - if ($user->rights->projet->lire) + if ($action == 'createtime' && $object->id > 0 && $user->rights->projet->lire) { - print '
'; - print ''."\n"; print '
'; print ''; @@ -597,7 +599,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''; print ''; - print ''; + print ''; + print '   '; + print ''; print ''; print '
'; @@ -682,7 +686,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $title=$langs->trans("ListTaskTimeUserProject"); $linktotasks=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); - print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime,'title_generic.png'); + print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime, 'title_generic.png'); } $i = 0; From ce928d915058e94e4ba09959639feeb971f9572b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 12:32:26 +0100 Subject: [PATCH 112/125] Fix search criteria lost --- htdocs/projet/tasks/time.php | 38 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 57294fda1de..68da050c41e 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -529,6 +529,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) dol_fiche_end(); + print ''."\n"; $title=$langs->trans("ListTaskTimeForTask"); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); @@ -683,7 +684,9 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($projectidforalltimes)) { - $title=$langs->trans("ListTaskTimeUserProject"); + print ''."\n"; + + $title=$langs->trans("ListTaskTimeUserProject"); $linktotasks=''.$langs->trans("GoToListOfTasks").''; //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'title_generic.png', 0, '', '', 0, 1); print load_fiche_titre($title,$linktotasks.'   '.$linktocreatetime, 'title_generic.png'); @@ -788,19 +791,24 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayofselected=is_array($toselect)?$toselect:array(); - $params=''; + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_note != '') $params.= '&search_note='.urlencode($search_note); - if ($search_duration != '') $params.= '&search_field2='.urlencode($search_duration); - if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($search_month > 0) $param.= '&search_month='.urlencode($search_month); + if ($search_year > 0) $param.= '&search_year='.urlencode($search_year); + if ($search_user > 0) $param.= '&search_user='.urlencode($search_user); + if ($search_task_ref != '') $param.= '&search_task_ref='.urlencode($search_task_ref); + if ($search_task_label != '') $param.= '&search_task_label='.urlencode($search_task_label); + if ($search_note != '') $param.= '&search_note='.urlencode($search_note); + if ($search_duration != '') $param.= '&search_field2='.urlencode($search_duration); + if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); /* // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; */ - if ($id) $params.='&id='.$id; - if ($projectid) $params.='&projectid='.$projectid; - if ($withproject) $params.='&withproject='.$withproject; + if ($id) $param.='&id='.urlencode($id); + if ($projectid) $param.='&projectid='.urlencode($projectid); + if ($withproject) $param.='&withproject='.urlencode($withproject); $arrayofmassactions = array( @@ -886,16 +894,16 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''."\n"; print ''; - if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { - if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$params,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); } - if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$params,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$params,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$params,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; From cb45c867113583d37b9d1baed7afd63e577f95f1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 13:21:16 +0100 Subject: [PATCH 113/125] WIP Option PROJECT_BILL_TIME_SPENT --- htdocs/langs/en_US/main.lang | 1 + htdocs/projet/tasks/time.php | 49 ++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 19c7967e43a..0fd9fe52b3e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -334,6 +334,7 @@ PriceUHTCurrency=U.P (currency) PriceUTTC=U.P. (inc. tax) Amount=Amount AmountInvoice=Invoice amount +AmountInvoiced=Amount invoiced AmountPayment=Payment amount AmountHTShort=Amount (net) AmountTTCShort=Amount (inc. tax) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 68da050c41e..66323989d26 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2017 Laurent Destailleur + * Copyright (C) 2006-2018 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * @@ -241,7 +241,7 @@ if ($action == 'updateline' && ! $_POST["cancel"] && $user->rights->projet->lire if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->lire) { - $object->fetchTimeSpent($_GET['lineid']); + $object->fetchTimeSpent(GETPOST('lineid','int')); // TODO Check that ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids)) $result = $object->delTimeSpent($user); @@ -252,6 +252,10 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->l $error++; $action=''; } + else + { + setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); + } } // Retreive First Task ID of Project if withprojet is on to allow project prev next to work @@ -441,7 +445,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if ($action == 'deleteline') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST("lineid",'int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); } $param=($withproject?'&withproject=1':''); @@ -615,7 +619,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) { if ($action == 'deleteline') { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.'&lineid='.$_GET["lineid"].($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); + print $form->formconfirm($_SERVER["PHP_SELF"]."?".($object->id>0?"id=".$object->id:'projectid='.$projectstatic->id).'&lineid='.GETPOST('lineid','int').($withproject?'&withproject=1':''),$langs->trans("DeleteATimeSpent"),$langs->trans("ConfirmDeleteATimeSpent"),"confirm_delete",'','',1); } // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array @@ -634,6 +638,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $arrayfields['t.note']=array('label'=>$langs->trans("Note"), 'checked'=>1); $arrayfields['t.task_duration']=array('label'=>$langs->trans("Duration"), 'checked'=>1); $arrayfields['value'] =array('label'=>$langs->trans("Value"), 'checked'=>1, 'enabled'=>(empty($conf->salaries->enabled)?0:1)); + $arrayfields['valuebilled'] =array('label'=>$langs->trans("AmountInvoiced"), 'checked'=>1, 'enabled'=>(empty($conf->global->PROJECT_BILL_TIME_SPENT)?0:1)); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { @@ -650,8 +655,11 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $sql = "SELECT t.rowid, t.fk_task, t.task_date, t.task_datehour, t.task_date_withhour, t.task_duration, t.fk_user, t.note, t.thm,"; $sql .= " pt.ref, pt.label,"; - $sql .= " u.lastname, u.firstname, u.login, u.photo"; - $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; + $sql .= " u.lastname, u.firstname, u.login, u.photo,"; + $sql .= " il.fk_facture as invoice_id, il.total_ht"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facturedet as il ON il.rowid = t.invoice_line_id"; + $sql .= ", ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid"; if (empty($projectidforalltimes)) $sql .= " AND t.fk_task =".$object->id; else $sql.= " AND pt.fk_projet IN (".$projectidforalltimes.")"; @@ -876,9 +884,11 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) if (! empty($arrayfields['t.note']['checked'])) print ''; // Duration if (! empty($arrayfields['t.task_duration']['checked'])) print ''; - // Value in currency + // Value in main currency if (! empty($arrayfields['value']['checked'])) print ''; - /* + // Value billed + if (! empty($arrayfields['valuebilled']['checked'])) print ''; + /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; */ @@ -894,16 +904,17 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print ''."\n"; print ''; - if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_date']['checked'])) print_liste_field_titre($arrayfields['t.task_date']['label'],$_SERVER['PHP_SELF'],'t.task_date,t.task_datehour,t.rowid','',$param,'',$sortfield,$sortorder); if ((empty($id) && empty($ref)) || ! empty($projectidforalltimes)) // Not a dedicated task { if (! empty($arrayfields['t.task_ref']['checked'])) print_liste_field_titre($arrayfields['t.task_ref']['label'],$_SERVER['PHP_SELF'],'pt.ref','',$param,'',$sortfield,$sortorder); if (! empty($arrayfields['t.task_label']['checked'])) print_liste_field_titre($arrayfields['t.task_label']['label'],$_SERVER['PHP_SELF'],'pt.label','',$param,'',$sortfield,$sortorder); } - if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['author']['checked'])) print_liste_field_titre($arrayfields['author']['label'],$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.note']['checked'])) print_liste_field_titre($arrayfields['t.note']['label'],$_SERVER['PHP_SELF'],'t.note','',$param,'',$sortfield,$sortorder); + if (! empty($arrayfields['t.task_duration']['checked'])) print_liste_field_titre($arrayfields['t.task_duration']['label'],$_SERVER['PHP_SELF'],'t.task_duration','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['value']['checked'])) print_liste_field_titre($arrayfields['value']['label'],$_SERVER['PHP_SELF'],'','',$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['valuebilled']['checked'])) print_liste_field_titre($arrayfields['valuebilled']['label'],$_SERVER['PHP_SELF'],'il.total_ht','',$param,'align="right"',$sortfield,$sortorder); /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1052,6 +1063,18 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $totalarray['totalvalue'] += $value; } + // Value billed + if (! empty($arrayfields['valuebilled']['checked'])) + { + print ''; + $valuebilled = price2num($task_time->total_ht); + if (isset($task_time->total_ht)) print price($valuebilled, 1, $langs, 1, -1, -1, $conf->currency); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield']; + $totalarray['totalvaluebilled'] += $valuebilled; + } + /* // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; From de89893d5720189e0bb301b56903b4de4e3146c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 14:09:15 +0100 Subject: [PATCH 114/125] NEW Show total of time consumed in week in time spent entry page --- htdocs/core/js/timesheet.js | 16 +++++- .../class/fournisseur.commande.class.php | 50 +++---------------- htdocs/projet/activity/perday.php | 9 +++- htdocs/projet/activity/perweek.php | 12 ++--- htdocs/projet/tasks/time.php | 11 ++-- htdocs/theme/eldy/style.css.php | 3 ++ htdocs/theme/md/style.css.php | 3 ++ 7 files changed, 45 insertions(+), 59 deletions(-) diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js index 20a713ce220..ae7d839919c 100644 --- a/htdocs/core/js/timesheet.js +++ b/htdocs/core/js/timesheet.js @@ -216,6 +216,21 @@ function updateTotal(days,mode) if (total.getHours() || total.getMinutes()) jQuery('.totalDay'+days).addClass("bold"); else jQuery('.totalDay'+days).removeClass("bold"); jQuery('.totalDay'+days).text(pad(total.getHours())+':'+pad(total.getMinutes())); + + var total = new Date(0); + total.setHours(0); + total.setMinutes(0); + for (var i=0; i<7; i++) + { + var taskTime= new Date(0); + result=parseTime(jQuery('.totalDay'+i).text(),taskTime); + if (result >= 0) + { + total.setHours(total.getHours()+taskTime.getHours()); + total.setMinutes(total.getMinutes()+taskTime.getMinutes()); + } + } + jQuery('.totalDayAll').text(pad(total.getHours())+':'+pad(total.getMinutes())); } else { @@ -260,7 +275,6 @@ function updateTotal(days,mode) else jQuery('.totalDay'+days).removeClass("bold"); jQuery('.totalDay'+days).text(total); } - } \ No newline at end of file diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index e13e08acd7b..cf007659487 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2964,12 +2964,12 @@ class CommandeFournisseur extends CommonOrder } }elseif(! empty($conf->global->SUPPLIER_ORDER_MORE_THAN_WISHED) ) {//set livraison to 'tot' if more products received than wished. (and if $closeopenorder is set to 1 of course...) - + $close=0; - + if( count($diff_array) > 0 ) {//there are some difference between the two arrays - + //scan the array of results foreach($diff_array as $key => $value) {//if the quantity delivered is greater or equal to wish quantity @@ -2977,11 +2977,11 @@ class CommandeFournisseur extends CommonOrder { $close++; } - + } } - + if($close == count($diff_array)) {//all the products are received equal or more than the wished quantity if ($closeopenorder) @@ -3001,8 +3001,8 @@ class CommandeFournisseur extends CommonOrder } return 4; } - - + + } else {//all the products are not received @@ -3012,7 +3012,7 @@ class CommandeFournisseur extends CommonOrder } return 4; } - + } else { @@ -3157,40 +3157,6 @@ class CommandeFournisseurLigne extends CommonOrderLine } } - /** - * Mise a jour de l'objet ligne de commande en base - * - * @return int <0 si ko, >0 si ok - */ - public function updateTotal() - { - $this->db->begin(); - - // Mise a jour ligne en base - $sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseurdet SET"; - $sql.= " total_ht='".price2num($this->total_ht)."'"; - $sql.= ",total_tva='".price2num($this->total_tva)."'"; - $sql.= ",total_localtax1='".price2num($this->total_localtax1)."'"; - $sql.= ",total_localtax2='".price2num($this->total_localtax2)."'"; - $sql.= ",total_ttc='".price2num($this->total_ttc)."'"; - $sql.= " WHERE rowid = ".$this->rowid; - - dol_syslog(get_class($this)."::updateTotal", LOG_DEBUG); - - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -2; - } - } - /** * Insert line into database * diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 85848eefedc..b61c5aff922 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -595,10 +595,15 @@ if (count($tasksarray) > 0) if ($isdiff) { print ''; - print ''; + print ''; print $langs->trans("OtherFilteredTasks"); print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; $timeonothertasks=($totalforeachday[$daytoparse] - $totalforvisibletasks[$daytoparse]); //if ($timeonothertasks) //{ diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index d64a5fad6cd..a52ea4fd6d8 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -531,8 +531,8 @@ $colspan=7; if ($conf->use_javascript_ajax) { - print ' - '; + print ''; + print ''; print $langs->trans("Total"); print ' - '.$langs->trans("ExpectedWorkedHours").': '.price($usertoprocess->weeklyhours, 1, $langs, 0, 0).''; print ''; @@ -547,8 +547,8 @@ if ($conf->use_javascript_ajax) print '
 
'; } - print ' - '; + print '
 
'; + print ''; } @@ -625,7 +625,7 @@ if (count($tasksarray) > 0) $cssweekend='weekend'; } - print ''; + print ''; $tmpday=dol_time_plus_duree($firstdaytoshow, $idw, 'd'); $timeonothertasks=($totalforeachday[$tmpday] - $totalforvisibletasks[$tmpday]); if ($timeonothertasks) @@ -658,7 +658,7 @@ if (count($tasksarray) > 0) print '
 
'; } - print ' + print '
 
'; } } diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 66323989d26..912551012b0 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -79,11 +79,7 @@ $projectstatic = new Project($db); $extrafields_project = new ExtraFields($db); $extrafields_task = new ExtraFields($db); -if ($projectid > 0 || ! empty($ref)) -{ - // fetch optionals attributes and labels - $extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); -} +$extralabels_projet=$extrafields_project->fetch_name_optionals_label($projectstatic->table_element); $extralabels_task=$extrafields_task->fetch_name_optionals_label($object->table_element); @@ -278,10 +274,9 @@ if (! empty($project_ref) && ! empty($withproject)) // To show all time lines for project $projectidforalltimes=0; -if (GETPOST('projectid')) +if (GETPOST('projectid','none')) { - $projectidforalltimes=GETPOST('projectid','int'); - + $projectidforalltimes=GETPOST('projectid','int'); } diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 2b150d64a5e..df41d1301ef 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -407,6 +407,9 @@ td.onholidayallday { td.leftborder, td.hide0 { border-left: 1px solid #ccc; } +td.leftborder, td.hide6 { + border-right: 1px solid #ccc; +} td.actionbuttons a { padding-left: 6px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 07c02ba74fa..40b3fefc634 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -411,6 +411,9 @@ td.actionbuttons a { td.leftborder, td.hide0 { border-left: 1px solid #ccc; } +td.leftborder, td.hide6 { + border-right: 1px solid #ccc; +} select.flat, form.flat select { font-weight: normal; From 82475e2e5f17667bc7517baf5a46ac2c5327d7ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 14:28:51 +0100 Subject: [PATCH 115/125] WIP Option PROJECT_BILL_TIME_SPENT --- htdocs/langs/en_US/projects.lang | 1 + htdocs/projet/card.php | 26 ++++++++++++++++++++++++++ htdocs/projet/class/project.class.php | 7 ++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index dd79af04bcb..5f71b230537 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -55,6 +55,7 @@ TasksOnOpenedProject=Tasks on open projects WorkloadNotDefined=Workload not defined NewTimeSpent=Time spent MyTimeSpent=My time spent +BillTime=Bill the time spent Tasks=Tasks Task=Task TaskDateStart=Task start date diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 71be9b5d4a3..7494a5a15bb 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -161,6 +161,7 @@ if (empty($reshook)) $object->statut = $status; $object->opp_status = $opp_status; $object->opp_percent = $opp_percent; + $object->bill_time = (GETPOST('bill_time','alpha')=='on'?1:0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -261,6 +262,7 @@ if (empty($reshook)) if (isset($_POST['budget_amount'])) $object->budget_amount= price2num(GETPOST('budget_amount','alpha')); if (isset($_POST['opp_status'])) $object->opp_status = $opp_status; if (isset($_POST['opp_percent'])) $object->opp_percent = $opp_percent; + $object->bill_time = (GETPOST('bill_time','alpha')=='on'?1:0); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -599,6 +601,14 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; print ''; + // Bill time + if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''.$langs->trans("BillTime").''; + print ''; + print ''; + } + if ($conf->categorie->enabled) { // Categories print ''.$langs->trans("Categories").''; @@ -826,6 +836,14 @@ elseif ($object->id > 0) print ''; print ''; + // Bill time + if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''.$langs->trans("BillTime").''; + print 'bill_time) ? ' checked="checked"' : '').'">'; + print ''; + } + // Tags-Categories if ($conf->categorie->enabled) { @@ -948,6 +966,14 @@ elseif ($object->id > 0) print nl2br($object->description); print ''; + // Bill time + if (! empty($conf->global->PROJECT_BILL_TIME_SPENT)) + { + print ''.$langs->trans("BillTime").''; + print ''.yn($object->bill_time).''; + print ''; + } + // Categories if($conf->categorie->enabled) { print ''.$langs->trans("Categories").''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 6e8c12793cc..ed25f3ba813 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -64,6 +64,7 @@ class Project extends CommonObject var $user_close_id; var $public; //!< Tell if this is a public or private project var $budget_amount; + var $bill_time; // Is the time spent on project must be invoiced or not var $statuts_short; var $statuts_long; @@ -178,6 +179,7 @@ class Project extends CommonObject $sql.= ", datee"; $sql.= ", opp_amount"; $sql.= ", budget_amount"; + $sql.= ", bill_time"; $sql.= ", entity"; $sql.= ") VALUES ("; $sql.= "'" . $this->db->escape($this->ref) . "'"; @@ -297,6 +299,7 @@ class Project extends CommonObject $sql.= ", opp_amount = " . (strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null"); $sql.= ", budget_amount = " . (strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null"); $sql.= ", fk_user_modif = " . $user->id; + $sql.= ", bill_time = " . ($this->bill_time ? 1 : 0); $sql.= " WHERE rowid = " . $this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -394,7 +397,8 @@ class Project extends CommonObject if (empty($id) && empty($ref)) return -1; $sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,"; - $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf"; + $sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut, fk_opp_status, opp_percent,"; + $sql.= " note_private, note_public, model_pdf, bill_time"; $sql.= " FROM " . MAIN_DB_PREFIX . "projet"; if (! empty($id)) { @@ -441,6 +445,7 @@ class Project extends CommonObject $this->opp_percent = $obj->opp_percent; $this->budget_amount = $obj->budget_amount; $this->modelpdf = $obj->model_pdf; + $this->bill_time = (int) $obj->bill_time; $this->db->free($resql); From 7e48db2869981a17853d62c5e06e40d5fc31e5a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 15:03:09 +0100 Subject: [PATCH 116/125] Clean code --- htdocs/admin/system/filecheck.php | 2 +- htdocs/api/class/api_setup.class.php | 2 +- htdocs/cashdesk/class/Facturation.class.php | 2 +- htdocs/cashdesk/validation_verif.php | 2 +- htdocs/core/lib/admin.lib.php | 4 ++-- htdocs/core/lib/functions.lib.php | 2 +- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/holiday/define_holiday.php | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 60c20dfafe7..38cf0b3f0df 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -140,7 +140,7 @@ if (GETPOST('target') == 'remote') if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; - //print "eee".$xmlfile."eee"; + //print "xmlfilestart".$xmlfile."xmlfileend"; $xml = simplexml_load_string($xmlfile); } else diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 27b909c2dad..65ba8f4ff37 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -638,7 +638,7 @@ class Setup extends DolibarrApi if (! $xmlarray['curl_error_no'] && $xmlarray['http_code'] != '404') { $xmlfile = $xmlarray['content']; - //print "eee".$xmlfile."eee"; + //print "xmlfilestart".$xmlfile."endxmlfile"; $xml = simplexml_load_string($xmlfile); } else diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index 8bfd1d3082c..769a69a23fa 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -233,7 +233,7 @@ class Facturation $this->prix_total_localtax2 = $total_localtax2; $this->montant_tva = $total_ttc - $total_ht; - //print $this->prix_total_ttc.'eeee'; exit; + //print 'total: '.$this->prix_total_ttc; exit; } /** diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 399e2984ea8..431f921a1fb 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -324,7 +324,7 @@ switch ($action) { // We set status to payed $result=$invoice->set_paid($user); - //print 'eeeee';exit; + //print 'set paid';exit; } } diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 7991b711660..fcc3098c730 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -870,7 +870,7 @@ function activateModule($value,$withdeps=1) // Test if Dolibarr version ok $verdol=versiondolibarrarray(); $vermin=isset($objMod->need_dolibarr_version)?$objMod->need_dolibarr_version:0; - //print 'eee '.versioncompare($verdol,$vermin).' - '.join(',',$verdol).' - '.join(',',$vermin);exit; + //print 'version: '.versioncompare($verdol,$vermin).' - '.join(',',$verdol).' - '.join(',',$vermin);exit; if (is_array($vermin) && versioncompare($verdol, $vermin) < 0) { $ret['errors'][] = $langs->trans("ErrorModuleRequireDolibarrVersion", versiontostring($vermin)); return $ret; @@ -1498,7 +1498,7 @@ function showModulesExludedForExternal($modules) //if (empty($conf->global->$moduleconst)) continue; if (! in_array($modulename,$listofmodules)) continue; - //var_dump($modulename.'eee'.$langs->trans('Module'.$module->numero.'Name')); + //var_dump($modulename.' - '.$langs->trans('Module'.$module->numero.'Name')); if ($i > 0) $text.=', '; else $text.=' '; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3f194d3531a..72ff4343d38 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1999,7 +1999,7 @@ function dol_now($mode='gmt') }*/ else if ($mode == 'tzuser') // Time for now with user timezone added { - //print 'eeee'.time().'-'.mktime().'-'.gmmktime(); + //print 'time: '.time().'-'.mktime().'-'.gmmktime(); $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; $ret=(int) dol_now('gmt')+($offsettz+$offsetdst); diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 377f2215b6d..ab7ce8599b0 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1003,7 +1003,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass $freetextheight=0; if ($line) // Free text { - //$line="eee
\nfdsfsdf
\nghfghg
"; + //$line="sample text
\nfdsfsdf
\nghfghg
"; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { $width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text. diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index a7d4789468e..e4421505b00 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -128,7 +128,7 @@ if (empty($reshook)) //If the user set a comment, we add it to the log comment $comment = ((isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID])) ? ' ('.$_POST['note_holiday'][$userID].')' : ''); - //print 'eee'.$val['rowid'].'-'.$userValue; + //print 'holiday: '.$val['rowid'].'-'.$userValue; if ($userValue != '') { // We add the modification to the log (must be before update of sold because we read current value of sold) From 941a8e5e2bca02a80142e26d9d802d6de27b98fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 20:12:29 +0100 Subject: [PATCH 117/125] FIX: Properties updated if update successfull. --- htdocs/contrat/class/contrat.class.php | 95 ++++++++++++-------------- 1 file changed, 45 insertions(+), 50 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 0d5262ac66b..64ffd794453 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -262,9 +262,10 @@ class Contrat extends CommonObject * @param User $user Object User making action * @param int|string $date_start Date start (now if empty) * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function activateAll($user, $date_start='', $notrigger=0) + function activateAll($user, $date_start='', $notrigger=0, $comment='') { if (empty($date_start)) $date_start = dol_now(); @@ -282,7 +283,7 @@ class Contrat extends CommonObject { $contratline->context = $this->context; - $result = $contratline->active_line($user, $date_start, -1); + $result = $contratline->active_line($user, $date_start, -1, $comment); if ($result < 0) { $error++; @@ -1468,49 +1469,39 @@ class Contrat extends CommonObject { $contractlineid = $this->db->last_insert_id(MAIN_DB_PREFIX."contratdet"); - $result=$this->update_statut($user); - if ($result > 0) + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used { - - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options)>0) // For avoid conflicts if trigger used + $contractline = new ContratLigne($this->db); + $contractline->array_options=$array_options; + $contractline->id=$contractlineid; + $result=$contractline->insertExtraFields(); + if ($result < 0) { - $contractline = new ContratLigne($this->db); - $contractline->array_options=$array_options; - $contractline->id=$contractlineid; - $result=$contractline->insertExtraFields(); - if ($result < 0) - { - $this->error[]=$contractline->error; - $error++; - } - } - - if (empty($error)) { - // Call trigger - $result=$this->call_trigger('LINECONTRACT_INSERT',$user); - if ($result < 0) - { - $error++; - } - // End call triggers - } - - if ($error) - { - $this->db->rollback(); - return -1; - } - else - { - $this->db->commit(); - return $contractlineid; + $this->error[]=$contractline->error; + $error++; } } - else + + if (empty($error)) { + // Call trigger + $result=$this->call_trigger('LINECONTRACT_INSERT',$user); + if ($result < 0) + { + $error++; + } + // End call triggers + } + + if ($error) { $this->db->rollback(); return -1; } + else + { + $this->db->commit(); + return $contractlineid; + } } else { @@ -3095,13 +3086,6 @@ class ContratLigne extends CommonObjectLine { global $langs, $conf; - // Update object - $this->date_ouverture = $date; - $this->date_fin_validite = $date_end; - $this->fk_user_ouverture = $user->id; - $this->date_cloture = null; - $this->commentaire = $comment; - $error = 0; $this->db->begin(); @@ -3119,15 +3103,26 @@ class ContratLigne extends CommonObjectLine if ($resql) { // Call trigger $result = $this->call_trigger('LINECONTRACT_ACTIVATE', $user); - if ($result < 0) { - $error++; + if ($result < 0) $error++; + // End call triggers + + if (! $error) + { + $this->statut = 4; + $this->date_ouverture = $date; + $this->date_fin_validite = $date_end; + $this->fk_user_ouverture = $user->id; + $this->date_cloture = null; + $this->commentaire = $comment; + + $this->db->commit(); + return 1; + } + else + { $this->db->rollback(); return -1; } - // End call triggers - - $this->db->commit(); - return 1; } else { $this->error = $this->db->lasterror(); $this->db->rollback(); From 19ae24f693cc1531bc5ca6b2316aee189ed9373d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 21:03:52 +0100 Subject: [PATCH 118/125] Code comment --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 123330004ed..c1f218f15f8 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3392,7 +3392,7 @@ class Product extends CommonObject * @param int $id Id of product to search childs of * @param int $firstlevelonly Return only direct child * @param int $level Level of recursing call (start to 1) - * @return array Prod + * @return array Return array(prodid=>array(0=prodid, 1=>qty, 2=> ...) */ function getChildsArbo($id, $firstlevelonly=0, $level=1) { From 3c552cec15e48cb7a33cadfb4488f488150e3c2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 21:16:40 +0100 Subject: [PATCH 119/125] FIX Missing restore_lastsearch_values --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/fichinter/card.php | 2 +- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/holiday/card.php | 2 +- htdocs/livraison/card.php | 2 +- htdocs/product/stock/card.php | 2 +- htdocs/projet/card.php | 2 +- htdocs/projet/tasks/task.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/societe/list.php | 2 +- htdocs/user/card.php | 2 +- htdocs/user/group/card.php | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 02c1b0e65bb..9194ec62c49 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -201,7 +201,7 @@ if (empty($reshook)) { $result = $object->delete($user); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php'); + header('Location: ' . DOL_URL_ROOT . '/comm/propal/list.php?restore_lastsearch_values=1'); exit(); } else { $langs->load("errors"); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 2cb899fcfe6..26166ab3f75 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -185,7 +185,7 @@ if (empty($reshook)) $result = $object->delete($user); if ($result > 0) { - header('Location: index.php'); + header('Location: list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 969f4d532cb..a08b6663c38 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -191,7 +191,7 @@ if (empty($reshook)) $result = $object->delete($user, 0, $idwarehouse); if ($result > 0) { - header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php'); + header('Location: ' . DOL_URL_ROOT . '/compta/facture/list.php?restore_lastsearch_values=1'); exit(); } else { setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 3b7ab5ae49b..c92246cf82a 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -842,7 +842,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result >= 0) { - header("Location: index.php"); + header("Location: list.php?restore_lastsearch_values=1"); return; } else diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 9b623d21279..b2533ba553c 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -470,7 +470,7 @@ if (empty($reshook)) setEventMessages($object->error, $object->errors, 'errors'); } - header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); + header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1'); exit; } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f87b4c9bd25..6f541803d55 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -850,7 +850,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result > 0) { - header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php'); + header("Location: ".DOL_URL_ROOT.'/fourn/commande/list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index cc6fb29fa5a..0368d5cd7c8 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -224,7 +224,7 @@ if (empty($reshook)) $result=$object->delete($user); if ($result > 0) { - header('Location: list.php'); + header('Location: list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index ce985b51738..59cb522d7d5 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -299,7 +299,7 @@ if ($action == 'confirm_delete' && GETPOST('confirm') == 'yes' && $user->rights- if (! $error) { $db->commit(); - header('Location: list.php'); + header('Location: list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 06c602df330..0e61adcb279 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -165,7 +165,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->expeditio { $db->commit(); if (! empty($backtopage)) header("Location: ".$backtopage); - else header("Location: ".DOL_URL_ROOT.'/expedition/index.php'); + else header("Location: ".DOL_URL_ROOT.'/expedition/list.php?restore_lastsearch_values=1'); exit; } else diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 8ab36de3428..61bd5c3d47f 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -117,7 +117,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: ".DOL_URL_ROOT.'/product/stock/list.php'); + header("Location: ".DOL_URL_ROOT.'/product/stock/list.php?resotre_lastsearch_values=1'); exit; } else diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 7494a5a15bb..c5cfb9b3756 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -409,7 +409,7 @@ if (empty($reshook)) if ($result > 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - header("Location: index.php"); + header("Location: list.php?restore_lastsearch_values=1"); exit; } else diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 3d1ccfb8fe1..85a6461fbfb 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -125,7 +125,7 @@ if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->s if ($object->delete($user) > 0) { - header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?id='.$projectstatic->id.($withproject?'&withproject=1':'')); + header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject?'&withproject=1':'')); exit; } else diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 37f60150dd8..dfe6f07cd53 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -796,7 +796,7 @@ if (empty($reshook)) if ($result > 0) { - header("Location: ".DOL_URL_ROOT."/societe/list.php?delsoc=".urlencode($object->name)); + header("Location: ".DOL_URL_ROOT."/societe/list.php?restore_lastsearch_values=1&delsoc=".urlencode($object->name)); exit; } else diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 47852c71403..9861f4b8d66 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -998,7 +998,7 @@ while ($i < min($num, $limit)) $savalias = $obj->name_alias; if (! empty($arrayfields['s.name_alias']['checked'])) $companystatic->name_alias=''; print ''; - print $companystatic->getNomUrl(1,'',100); + print $companystatic->getNomUrl(1, '', 100, 0, 1); print "\n"; $companystatic->name_alias = $savalias; if (! $i) $totalarray['nbfield']++; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 9e7c90f79ac..a11c18daca7 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -157,7 +157,7 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorUserCannotBeDelete"), null, 'errors'); } else { - header("Location: index.php"); + header("Location: index.php?restore_lastsearch_values=1"); exit; } } diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 8f99fa1bb81..52de09d566d 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -91,7 +91,7 @@ if (empty($reshook)) { { $object->fetch($id); $object->delete(); - header("Location: index.php"); + header("Location: index.php?restore_lastsearch_values=1"); exit; } else From 8d963adb43846b1e1f5b43ac429fe1e5738cea64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Feb 2018 21:30:31 +0100 Subject: [PATCH 120/125] Fix error message --- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/langs/en_US/errors.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 64ffd794453..02868eb369c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1342,7 +1342,7 @@ class Contrat extends CommonObject // Check parameters if ($fk_product <= 0 && empty($desc)) { - $this->error="DescRequiredForFreeProductLines"; + $this->error="ErrorDescRequiredForFreeProductLines"; return -1; } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index f87a30ecfb2..86460452286 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -207,6 +207,7 @@ ErrorDiscountLargerThanRemainToPaySplitItBefore=The discount you try to apply is ErrorFileNotFoundWithSharedLink=File was not found. May be the share key was modified or file was removed recently. ErrorProductBarCodeAlreadyExists=The product barcode %s already exists on another product reference. ErrorNoteAlsoThatSubProductCantBeFollowedByLot=Note also that using virtual product to have auto increase/decrease of subproducts is not possible when at least one subproduct (or subproduct of subproducts) needs a serial/lot number. +ErrorDescRequiredForFreeProductLines=Description is mandatory for lines with free product # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. From 712fafb776634ce75bcf6aee8e8664f8c53470c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Feb 2018 10:07:38 +0100 Subject: [PATCH 121/125] code sample --- .../modulebuilder/template/class/actions_mymodule.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index b0265a28e3f..e11925f075f 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -175,7 +175,7 @@ class ActionsMyModule */ function beforePDFCreation($parameters, &$object, &$action) { - global $langs,$conf; + global $conf, $user, $langs; global $hookmanager; $outputlangs=$langs; @@ -204,7 +204,7 @@ class ActionsMyModule */ function afterPDFCreation($parameters, &$pdfhandler, &$action) { - global $langs,$conf; + global $conf, $user, $langs; global $hookmanager; $outputlangs=$langs; From 2294a50c8993e673da49bac039e0a1b7180fefac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Feb 2018 13:05:59 +0100 Subject: [PATCH 122/125] Fix tooltip --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 14 +++++++------- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index a48e8a5f31a..0c141d8933a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -93,15 +93,15 @@ $langs->load("modulebuilder"); else if (type == 'int') { size.val('10').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'text') { size.val('2000').removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } - else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").show();} else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} - else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} + else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();jQuery("#helppassword").hide();} else if (type == 'separate') { langfile.val('').prop('disabled',true);size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide(); diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index a919b545a36..63059964b74 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -91,16 +91,16 @@ $langs->load("modulebuilder"); else if (type == 'int') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();} else if (type == 'text') { size.removeAttr('disabled'); unique.prop('disabled', true).removeAttr('checked'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'varchar') { size.removeAttr('disabled'); unique.removeAttr('disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } - else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").show();} else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} - else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} - else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} - else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'checkbox') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'chkbxlst') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();jQuery("#helppassword").hide();} + else if (type == 'link') { size.val('').prop('disabled', true); unique.removeAttr('disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();jQuery("#helppassword").hide();} + else if (type == 'separate') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();jQuery("#helppassword").hide();} else { // type = string size.val('').prop('disabled', true); unique.removeAttr('disabled'); From 6bec121c9ffa83a381197169df747be2b8feadfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Feb 2018 13:26:57 +0100 Subject: [PATCH 123/125] Use name of var --- htdocs/product/admin/product.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php index 06cfc0e0eac..a51d19f5b97 100644 --- a/htdocs/product/admin/product.php +++ b/htdocs/product/admin/product.php @@ -129,7 +129,7 @@ if ($action == 'other') } - $value = GETPOST('activate_sousproduits','alpha'); + $value = GETPOST('PRODUIT_SOUSPRODUITS','alpha'); $res = dolibarr_set_const($db, "PRODUIT_SOUSPRODUITS", $value,'chaine',0,'',$conf->entity); $value = GETPOST('activate_viewProdDescInForm','alpha'); @@ -580,7 +580,7 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES)) print ''; print ''.$langs->trans("AssociatedProductsAbility").''; print ''; -print $form->selectyesno("activate_sousproduits",$conf->global->PRODUIT_SOUSPRODUITS,1); +print $form->selectyesno("PRODUIT_SOUSPRODUITS",$conf->global->PRODUIT_SOUSPRODUITS,1); print ''; print ''; From 48e042b66935826aa2422961b843776ee907b4ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Feb 2018 16:33:40 +0100 Subject: [PATCH 124/125] FIX css border missing --- htdocs/contrat/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index c92246cf82a..59688aab1a3 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1996,7 +1996,7 @@ else print ''; print ''; - print ''; + print '
'; // Definie date debut et fin par defaut $dateactstart = $objp->date_debut_reelle; From 8ac4cb9c430a162d3ae904ef63fb8a9702992fa0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Feb 2018 16:33:50 +0100 Subject: [PATCH 125/125] Add fetch_product --- htdocs/core/class/commonobject.class.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index fd221649141..5235e59ef34 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1231,7 +1231,7 @@ abstract class CommonObject } /** - * Charge le projet d'id $this->fk_project dans this->projet + * Load the project with id $this->fk_project into this->project * * @return int <0 if KO, >=0 if OK */ @@ -1251,7 +1251,25 @@ abstract class CommonObject } /** - * Charge le user d'id userid dans this->user + * Load the product with id $this->fk_product into this->product + * + * @return int <0 if KO, >=0 if OK + */ + function fetch_product() + { + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + + if (empty($this->fk_product)) return 0; + + $product = new Product($this->db); + $result = $product->fetch($this->fk_product); + + $this->product = $product; + return $result; + } + + /** + * Load the user with id $userid into this->user * * @param int $userid Id du contact * @return int <0 if KO, >0 if OK