From 41a0727481ad099cdd98aad8e3e287ac5e0af57a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Wed, 18 Apr 2018 18:02:38 +0200 Subject: [PATCH 01/17] NEW: work on CommonObject 'array' field type --- htdocs/core/class/commonobject.class.php | 56 ++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f7e0d451506..0fe540cb3ac 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5555,6 +5555,39 @@ abstract class CommonObject // If prefix is 'search_', field is used as a filter, we use a common text field. $out=''; } + elseif ($type == 'array') + { + $newval = $val; + $newval['type'] = 'varchar(256)'; + + $out=''; + + $inputs = array(); + if(! empty($value)) { + foreach($value as $option) { + $out.= ' '; + $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'
'; + } + } + + $out.= ''; + + $newInput = ' '; + $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; + + $out.= ' +'; + } if (!empty($hidden)) { $out=''; } @@ -5926,6 +5959,10 @@ abstract class CommonObject { $value=preg_replace('/./i','*',$value); } + elseif ($type == 'array') + { + $value = implode('
', $value); + } //print $type.'-'.$size; $out=$value; @@ -6614,7 +6651,14 @@ abstract class CommonObject } else if($this->isArray($info)) { - $queryarray[$field] = serialize($this->{$field}); + if(! empty($this->{$field})) { + if(! is_array($this->{$field})) { + $this->{$field} = array($this->{$field}); + } + $queryarray[$field] = serialize($this->{$field}); + } else { + $queryarray[$field] = NULL; + } } else if($this->isInt($info)) { @@ -6658,9 +6702,13 @@ abstract class CommonObject } elseif($this->isArray($info)) { - $this->{$field} = @unserialize($obj->{$field}); - // Hack for data not in UTF8 - if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); + if(! empty($obj->{$field})) { + $this->{$field} = @unserialize($obj->{$field}); + // Hack for data not in UTF8 + if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field})); + } else { + $this->{$field} = array(); + } } elseif($this->isInt($info)) { From 2bf66780cbb788a0c068f11e360de1316a52577a Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 19 Apr 2018 10:25:19 +0200 Subject: [PATCH 02/17] FIX: travis + code readability --- htdocs/core/class/commonobject.class.php | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0fe540cb3ac..e3c93618b08 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5566,27 +5566,27 @@ abstract class CommonObject if(! empty($value)) { foreach($value as $option) { $out.= ' '; - $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'
'; + $out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'
'; } } $out.= ''; $newInput = ' '; - $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; + $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; $out.= ' -'; + $(document).on("click", "a.'.dol_escape_js($keyprefix.$key.$keysuffix).'_del", function() { + $(this).parent().remove(); + }); + }); + '; } if (!empty($hidden)) { $out=''; @@ -5961,7 +5961,7 @@ $(document).ready(function() { } elseif ($type == 'array') { - $value = implode('
', $value); + $value = implode('
', $value); } //print $type.'-'.$size; From 39e890e2d75f76ca69d1587e2936786a5d76dbf0 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Fri, 20 Apr 2018 16:43:27 +0200 Subject: [PATCH 03/17] FIX: handle non-js users --- htdocs/core/class/commonobject.class.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e3c93618b08..478bb3ea460 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5575,18 +5575,20 @@ abstract class CommonObject $newInput = ' '; $newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'
'; - $out.= ' - '; + '; + } } if (!empty($hidden)) { $out=''; From 8256bd1889e2daee5040f71a673f87ffdec3f453 Mon Sep 17 00:00:00 2001 From: Julien BARRET Date: Mon, 23 Apr 2018 11:39:34 +0200 Subject: [PATCH 04/17] Fix Year selector issue in turnover statistics page --- htdocs/compta/stats/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index a4c32302a47..b9a7db32b51 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -114,7 +114,7 @@ if ($modecompta=="CREANCES-DETTES") $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCADue"); if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $description.= $langs->trans("DepositsAreNotIncluded"); else $description.= $langs->trans("DepositsAreIncluded"); @@ -128,7 +128,7 @@ else if ($modecompta=="RECETTES-DEPENSES") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInBookkeepingMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCAIn"); $description.= $langs->trans("DepositsAreIncluded"); $builddate=dol_now(); @@ -141,7 +141,7 @@ else if ($modecompta=="BOOKKEEPING") $calcmode.='
('.$langs->trans("SeeReportInDueDebtMode",'','').')'; $calcmode.='
('.$langs->trans("SeeReportInInputOutputMode",'','').')'; $period=$form->select_date($date_start,'date_start',0,0,0,'',1,0,1).' - '.$form->select_date($date_end,'date_end',0,0,0,'',1,0,1); - $periodlink=($year_start?"".img_previous()." ".img_next()."":""); + $periodlink=($year_start?"".img_previous()." ".img_next()."":""); $description=$langs->trans("RulesCATotalSaleJournal"); $builddate=dol_now(); //$exportlink=$langs->trans("NotYetAvailable"); From 6d552a2ae6931fcf8d0bff8920b302ae652f4ce4 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Mon, 23 Apr 2018 15:05:37 +0200 Subject: [PATCH 05/17] Add ordersupplierdispatch hook --- htdocs/fourn/commande/dispatch.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index c6a6034c684..3fb62407814 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -62,6 +62,8 @@ if (empty($conf->stock->enabled)) { accessforbidden(); } +$hookmanager->initHooks(array('ordersupplierdispatch')); + // Recuperation de l'id de projet $projectid = 0; if ($_GET["projectid"]) @@ -85,6 +87,10 @@ if ($id > 0 || ! empty($ref)) { * Actions */ +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($action == 'checkdispatchline' && ! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande->receptionner)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->fournisseur->commande_advance->check)))) { $error=0; @@ -430,6 +436,9 @@ if ($id > 0 || ! empty($ref)) { print '' . $author->getNomUrl(1, '', 0, 0, 0) . ''; print ''; + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + print ""; print ''; From f402753fa31338c5af555748fdd9163f2aba598d Mon Sep 17 00:00:00 2001 From: Thomas OURSEL Date: Mon, 23 Apr 2018 15:14:34 +0200 Subject: [PATCH 06/17] Fix french holidays (Easter related) --- htdocs/core/lib/date.lib.php | 46 +++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 931f30ce998..8a52941091e 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -562,56 +562,70 @@ function num_public_holiday($timestampStart, $timestampEnd, $countrycode='FR') { $countryfound=1; - // Definition des dates feriees fixes + // Définition des dates fériées fixes if($jour == 1 && $mois == 1) $ferie=true; // 1er janvier if($jour == 1 && $mois == 5) $ferie=true; // 1er mai if($jour == 8 && $mois == 5) $ferie=true; // 5 mai if($jour == 14 && $mois == 7) $ferie=true; // 14 juillet - if($jour == 15 && $mois == 8) $ferie=true; // 15 aout + if($jour == 15 && $mois == 8) $ferie=true; // 15 août if($jour == 1 && $mois == 11) $ferie=true; // 1 novembre if($jour == 11 && $mois == 11) $ferie=true; // 11 novembre if($jour == 25 && $mois == 12) $ferie=true; // 25 decembre - // Calcul du jour de paques + // Calcul du jour de Pâques $date_paques = easter_date($annee); $jour_paques = date("d", $date_paques); $mois_paques = date("m", $date_paques); if($jour_paques == $jour && $mois_paques == $mois) $ferie=true; - // Paques + // Pâques - // Calcul du jour de l ascension (38 jours apres Paques) + // Calcul du jour du lundi de Pâques + $date_lundi_paques = mktime( + date("H", $date_paques), + date("i", $date_paques), + date("s", $date_paques), + date("m", $date_paques), + date("d", $date_paques) + 1, + date("Y", $date_paques) + ); + $jour_lundi_ascension = date("d", $date_lundi_paques); + $mois_lundi_ascension = date("m", $date_lundi_paques); + if($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) $ferie=true; + // Lundi de Pâques + + // Calcul du jour de l'ascension (38 jours apres Pâques) $date_ascension = mktime( date("H", $date_paques), date("i", $date_paques), date("s", $date_paques), date("m", $date_paques), - date("d", $date_paques) + 38, + date("d", $date_paques) + 39, date("Y", $date_paques) ); $jour_ascension = date("d", $date_ascension); $mois_ascension = date("m", $date_ascension); if($jour_ascension == $jour && $mois_ascension == $mois) $ferie=true; - //Ascension + // Ascension - // Calcul de Pentecote (11 jours apres Paques) + // Calcul de Pentecôte (11 jours apres Pâques) $date_pentecote = mktime( - date("H", $date_ascension), - date("i", $date_ascension), - date("s", $date_ascension), - date("m", $date_ascension), - date("d", $date_ascension) + 11, - date("Y", $date_ascension) + date("H", $date_paques), + date("i", $date_paques), + date("s", $date_paques), + date("m", $date_paques), + date("d", $date_paques) + 49, + date("Y", $date_paques) ); $jour_pentecote = date("d", $date_pentecote); $mois_pentecote = date("m", $date_pentecote); if($jour_pentecote == $jour && $mois_pentecote == $mois) $ferie=true; - //Pentecote + // Pentecôte // Calul des samedis et dimanches $jour_julien = unixtojd($timestampStart); $jour_semaine = jddayofweek($jour_julien, 0); if($jour_semaine == 0 || $jour_semaine == 6) $ferie=true; - //Samedi (6) et dimanche (0) + // Samedi (6) et dimanche (0) } // Pentecoste and Ascensione in Italy go to the sunday after: isn't holiday. From 11d739494df83b3b282d23daf49cb9005c852d0a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 23 Apr 2018 15:51:21 +0200 Subject: [PATCH 07/17] clean code --- htdocs/accountancy/admin/accountmodel.php | 4 +--- htdocs/accountancy/admin/categories_list.php | 2 -- htdocs/accountancy/admin/journals_list.php | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index a06d8a3f8d1..fc3c74af9d0 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * Copyright (C) 2011 Remy Younes * Copyright (C) 2012-2015 Marcos García * Copyright (C) 2012 Christophe Battarel @@ -683,7 +683,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; @@ -1062,7 +1061,6 @@ function fieldListAccountModel($fieldlist, $obj='', $tabname='', $context='') global $form; global $region_id; global $elementList,$sourceList; - global $bc; $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index dedc55b3fd5..3e30e680890 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -471,7 +471,6 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $var=false; $fieldlist=explode(',',$tabfield[$id]); @@ -565,7 +564,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index 8aea0463fc3..0a36fd376dc 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -432,7 +432,6 @@ if ($id) if ($tabname[$id]) { $alabelisused=0; - $var=false; $fieldlist=explode(',',$tabfield[$id]); @@ -512,7 +511,6 @@ if ($id) { $num = $db->num_rows($resql); $i = 0; - $var=true; $param = '&id='.$id; if ($search_country_id > 0) $param.= '&search_country_id='.$search_country_id; From bcf5c5d78a502c8dffe58112f655d72ea108308c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 23 Apr 2018 16:04:52 +0200 Subject: [PATCH 08/17] clean code --- .../adherents/tpl/linkedobjectblock.tpl.php | 3 +- htdocs/admin/system/constall.php | 2 +- htdocs/admin/tools/eaccelerator.php | 35 +++++++------------ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index f89b8da20f6..a3033ec090d 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -36,13 +36,12 @@ $langs = $GLOBALS['langs']; $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; $langs->load("members"); -$var=true; $total=0; foreach($linkedObjectBlock as $key => $objectlink) { ?> - > + trans("Subscription"); ?> getNomUrl(1); ?> diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index eee003b0872..82e8481c2dd 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -140,7 +140,7 @@ $configfilelib=array( 'Limit nb of email sent by page', 'Strict mode is on/off' ); -$var=true; + print ''; print ''; print ''; diff --git a/htdocs/admin/tools/eaccelerator.php b/htdocs/admin/tools/eaccelerator.php index 68d56bd2ded..d3253c02514 100644 --- a/htdocs/admin/tools/eaccelerator.php +++ b/htdocs/admin/tools/eaccelerator.php @@ -116,8 +116,7 @@ function revcompare($x, $y) */ function create_script_table($list) { - global $sortby,$bc,$langs; - $var=true; + global $sortby,$langs; if (GETPOT('order') == "asc" || GETPOST('order') =="desc") { $order = GETPOST('order'); @@ -173,7 +172,6 @@ function create_script_table($list) } foreach($list as $script) { - $var = ! $var; print ''; print ''; print ''; @@ -194,8 +192,7 @@ function create_script_table($list) */ function create_key_table($list) { - global $bc,$langs; - $var=true; + global $langs; print '
'.$langs->trans("Label").''.$langs->trans("Parameter").'
'.dol_trunc($script['file'],80,'left').''.dol_print_date($script['mtime'],'dayhour').'
'; print ''; @@ -206,7 +203,6 @@ function create_key_table($list) print ''; foreach($list as $key) { - $var = !$var; print ''; print ''; print ''; @@ -229,54 +225,49 @@ function create_key_table($list) $form=new Form($db); print load_fiche_titre('Dolibarr eAccelerator '.$info['version'].' control panel','','title_setup'); -$var=true; - print '
'; - print '
'.dol_trunc($key['name'],80,'left').''.dol_print_date($key['created'],'dayhour').'
'; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = !$var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; -$var = ! $var; + print ''; print ''; print ''; print ''; print '
Information
Caching enabled'.($info['cache']?'yes':'no').'
Optimizer enabled'.$info['optimizer']?'yes':'no'.'
Memory usage'.number_format(100 * $info['memoryAllocated']/$info['memorySize'], 2).'%('.number_format($info['memoryAllocated'] / (1024*1024), 2).'MB / '.number_format($info['memorySize']/(1024*1024), 2).'MB)
Free memory in reserved cache'.number_format($info['memoryAvailable']/(1024*1024), 2).'MB
Cached scripts'.$info['cachedScripts'].'
Removed scripts'.$info['removedScripts'].'
Cached keys'.(isset($info['cachedKeys'])?$info['cachedKeys']:'').'
'; -$var=true; - $resCached = @eaccelerator_cached_scripts(); // If success return an array $resRemoved = @eaccelerator_removed_scripts(); @@ -288,12 +279,11 @@ if (is_array($resCached) || is_array($resRemoved)) { print 'Actions'; if (is_array($resCached)) { - $var = ! $var; print ''; print "Caching"; print ''; print ""; - $var = ! $var; + print ''; print "Optimizer"; print ''; @@ -301,17 +291,16 @@ if (is_array($resCached) || is_array($resRemoved)) { } if (is_array($resRemoved)) { - $var = ! $var; print ''; print "Clear cache"; print ''; print ""; - $var = ! $var; + print ''; print "Clean cache"; print ''; print ""; - $var = ! $var; + print ''; print "Purge cache"; print ''; From 9e9d52a662f258d1a0f0538490bdbbe6efce3a4c Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 23 Apr 2018 16:23:30 +0200 Subject: [PATCH 09/17] clean and update code --- htdocs/admin/agenda_extsites.php | 2 -- htdocs/admin/barcode.php | 3 --- htdocs/admin/chequereceipts.php | 15 +++------------ htdocs/admin/clicktodial.php | 2 -- htdocs/admin/commande.php | 4 ---- htdocs/admin/contract.php | 12 +++--------- htdocs/admin/delais.php | 5 +---- 7 files changed, 7 insertions(+), 36 deletions(-) diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 4c1b49d75e6..f40ab648e42 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -148,7 +148,6 @@ print "
\n"; $selectedvalue=$conf->global->AGENDA_DISABLE_EXT; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; -$var=true; print ""; print ""; @@ -202,7 +201,6 @@ print ''; print ""; $i=1; -$var=true; while ($i <= $MAXAGENDA) { $key=$i; diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 313a852e384..db2b85fa986 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -157,7 +157,6 @@ foreach($dirbarcode as $reldir) /* * CHOIX ENCODAGE */ -$var=true; print '
'; print load_fiche_titre($langs->trans("BarcodeEncodeModule"),'',''); @@ -185,7 +184,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $var=true; while ($i < $num) { @@ -277,7 +275,6 @@ print ""; print ''; print ""; -$var=true; print '
'.$langs->trans("Color").'
'; print ''; print ''; diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index 86b38283649..0d2363f60c8 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -1,7 +1,7 @@ * Copyright (C) 2010-2016 Juanjo Menent - * Copyright (C) 2013-2014 Philippe Grand + * Copyright (C) 2013-2018 Philippe Grand * Copyright (C) 2015 Jean-François Ferry * * This program is free software; you can redistribute it and/or modify @@ -31,11 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; -$langs->load("admin"); -$langs->load("companies"); -$langs->load("bills"); -$langs->load("other"); -$langs->load("banks"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","companies","bills","other","banks")); if (!$user->admin) accessforbidden(); @@ -133,8 +130,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; - while (($file = readdir($handle))!==false) { if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) @@ -166,7 +161,6 @@ foreach ($dirmodels as $reldir) if ($module->isEnabled()) { - $var = !$var; print ''; print ''; print ''; print "\n"; -$var=true; - -$var=! $var; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index e9224ba4688..582131b22f3 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -72,8 +72,6 @@ print ''; print ''; print ''; -$var=true; - print '
'.$langs->trans("Parameter").'
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -254,9 +248,6 @@ print ''.$langs->trans("Parameters").'  
'; print ''; print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 5db56c82aa2..cd4f4ca4ab2 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -286,7 +286,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -406,7 +405,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -537,7 +535,6 @@ print ''; print ''; print "\n"; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -545,7 +542,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; print ''; print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 83c3634c35c..82fa51e5ca8 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2011-2018 Philippe Grand * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,9 +28,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; -$langs->load("admin"); -$langs->load("errors"); -$langs->load("contracts"); +// Load traductions files requiredby by page +$langs->loadLangs(array("admin","errors","contracts")); if (!$user->admin) accessforbidden(); @@ -220,7 +219,6 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - $var=true; while (($file = readdir($handle))!==false) { @@ -339,7 +337,6 @@ print "\n"; clearstatcache(); -$var=true; foreach ($dirmodels as $reldir) { foreach (array('','/doc') as $valdir) @@ -377,7 +374,6 @@ foreach ($dirmodels as $reldir) if ($modulequalified) { - $var = !$var; print ''; print ''; print ''; print "\n"; -$var=true; $substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); @@ -480,7 +475,6 @@ $htmltext = ''.$langs->trans("AvailableVariables").':
'; foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; $htmltext.='
'; -$var=! $var; print ''; + print ''; + print ''; + print ''; + } + print '
'.$langs->trans("Name").'
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print (empty($module->name)?$name:$module->name); print "\n"; @@ -472,7 +468,6 @@ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 37f66427225..4cf423b317f 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -144,7 +144,7 @@ if ($action == 'update') $plus=''; if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; // Update values - for($i=0;$i<4;$i++) { + for($i=0; $i<4; $i++) { if(isset($_POST['MAIN_METEO'.$plus.'_LEVEL'.$i])) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'),'chaine',0,'',$conf->entity); } @@ -172,7 +172,6 @@ if ($action == 'edit') print ''; print ''; print ''; - $var=true; print ''; print ''; @@ -215,7 +214,6 @@ else print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; print ''; - $var=true; foreach($modules as $module => $delays) { @@ -241,7 +239,6 @@ else print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; print ''; - $var=false; print ''; print ''; From 5f4e2dc565e94b7e6cd1d9431a2ed6d85e2791a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 24 Apr 2018 11:01:17 +0200 Subject: [PATCH 10/17] variant on services --- htdocs/core/lib/product.lib.php | 2 +- htdocs/product/card.php | 2 +- htdocs/variants/combinations.php | 19 ++++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index eedb994baed..731f8859eba 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -97,7 +97,7 @@ function product_prepare_head($object) $head[$h][2] = 'referers'; $h++; - if (!empty($conf->variants->enabled) && $object->isProduct()) { + if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { global $db; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 549eca022b0..a0ab4508d9c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1771,7 +1771,7 @@ else } //Parent product. - if (!empty($conf->variants->enabled) && $object->isProduct()) { + if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) { $combination = new ProductCombination($db); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 04f53e55d21..3460718c680 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -71,7 +71,7 @@ if ($cancel) { unset($_SESSION['addvariant_'.$object->id]); } -if (! $object->isProduct()) { +if (! $object->isProduct() && ! $object->isService()) { header('Location: '.dol_buildpath('/product/card.php?id='.$object->id, 2)); exit(); } @@ -523,12 +523,13 @@ if (! empty($id) || ! empty($ref)) - - - - -
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_METEO").'' . yn($conf->global->MAIN_DISABLE_METEO) . '
>
- isProduct()) { + print '
'; } print dol_fiche_end(); @@ -678,7 +679,7 @@ if (! empty($id) || ! empty($ref)) trans('Product') ?> trans('Combination') ?> trans('PriceImpact') ?> - trans('WeightImpact') ?> + isProduct()) print''.$langs->trans('WeightImpact').''; ?> trans('OnSell') ?> trans('OnBuy') ?> @@ -714,7 +715,7 @@ if (! empty($id) || ! empty($ref)) } ?> variation_price >= 0 ? '+' : '').price($currcomb->variation_price).($currcomb->variation_price_percentage ? ' %' : '') ?> - variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight') ?> + isProduct()) print ''.($currcomb->variation_weight >= 0 ? '+' : '').price($currcomb->variation_weight).' '.measuring_units_string($prodstatic->weight_units, 'weight').''; ?> getLibStatut(2, 0) ?> getLibStatut(2, 1) ?> From 64dde1595b71838db9160f549ac4fe09f4c1672a Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 24 Apr 2018 11:48:26 +0200 Subject: [PATCH 11/17] FIX : Credit note links set from source invoice links --- htdocs/compta/facture/card.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ec14ec3da14..dbce9c2e76d 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -983,15 +983,13 @@ if (empty($reshook)) // Add link between credit note and origin if(! empty($object->fk_facture_source)) { $facture_source->fetch($object->fk_facture_source); - } - $facture_source->fetchObjectLinked(); + $facture_source->fetchObjectLinked(); - if(! empty($facture_source->linkedObjectsIds)) { - $linkedObjectIds = $facture_source->linkedObjectsIds; - $sourcetype = key($linkedObjectIds); - $fk_origin = current($facture_source->linkedObjectsIds[$sourcetype]); - - $object->add_object_linked($sourcetype, $fk_origin); + if(! empty($facture_source->linkedObjectsIds)) { + foreach($facture_source->linkedObjectsIds as $sourcetype => $TIds) { + $object->add_object_linked($sourcetype, current($TIds)); + } + } } } } From 6fc444e045fb9a67cda6354e32b16ff3b86caadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 24 Apr 2018 12:08:17 +0200 Subject: [PATCH 12/17] we can see what we are doing --- htdocs/variants/combinations.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 3460718c680..dbc413542c4 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -327,11 +327,31 @@ if (! empty($id) || ! empty($ref)) if ($action == 'add') { $title = $langs->trans('NewProductCombination'); + print dol_fiche_head(); + $features = $_SESSION['addvariant_'.$object->id]; + //First, sanitize + print '
'; + if (! empty($features)) { + foreach ($features as $feature) { + + $explode = explode(':', $feature); + + if ($prodattr->fetch($explode[0]) < 0) { + continue; + } + + if ($prodattr_val->fetch($explode[1]) < 0) { + continue; + } + + print '' . $prodattr->label . ':'. $prodattr_val->value . ' '; + } + } + print '
'; + print dol_fiche_end(); } else { $title = $langs->trans('EditProductCombination'); } - - print '
'; print_fiche_titre($title); if ($action == 'add') { @@ -346,8 +366,8 @@ if (! empty($id) || ! empty($ref)) foreach ($prodattr_all as $each) { $prodattr_alljson[$each->id] = $each; } - - ?> + + ?>