From 1ae3b151c8c06b5ad936e3f20627aaf98a5b6d3e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 10 Feb 2021 09:11:53 +0100 Subject: [PATCH 01/70] Add new button to generate sitemap --- htdocs/langs/en_US/website.lang | 5 ++- htdocs/website/index.php | 58 ++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 7793fa5dead..27501c072fd 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -136,4 +136,7 @@ RSSFeedDesc=You can get a RSS feed of latest articles with type 'blogpost' using PagesRegenerated=%s page(s)/container(s) regenerated RegenerateWebsiteContent=Regenerate web site cache files AllowedInFrames=Allowed in Frames -DefineListOfAltLanguagesInWebsiteProperties=Define list of all available languages into web site properties. \ No newline at end of file +DefineListOfAltLanguagesInWebsiteProperties=Define list of all available languages into web site properties. +GenerateSitemaps=Generate web site sitemap file +BackToPreview= Back to preview +GeneratedSitemapsFiles = Generated sitemap files \ No newline at end of file diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ebcf31ad2c5..b29a1419e5c 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -38,6 +38,7 @@ 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.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; @@ -2254,6 +2255,7 @@ $form = new Form($db); $formadmin = new FormAdmin($db); $formwebsite = new FormWebsite($db); $formother = new FormOther($db); +$formfile = new FormFile($db); $helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website'; @@ -2469,6 +2471,10 @@ if (!GETPOST('hide_websitemenu')) print '   '; + print dolButtonToOpenUrlInDialogPopup('generate_sitemap', $langs->transnoentitiesnoconv("GenerateSitemaps"), '', '/website/index.php?action=generatesitemaps&website='.$website->ref, $disabled); + + print '   '; + print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">'; } @@ -2570,7 +2576,7 @@ if (!GETPOST('hide_websitemenu')) // Toolbar for pages // - if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm')) && !$file_manager) + if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm', 'generatesitemaps')) && !$file_manager) { print ''; // Close current websitebar to open a new one @@ -3791,6 +3797,56 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '
'; } +$domainname = '0.0.0.0:8080'; +$tempdir = $conf->website->dir_temp.'/'.$websitekey.'/'; + +// Generate web site sitemaps +if ($action == 'generatesitemaps') { + $container_array = array(); + $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; + $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; + $resql = $db->query($sql); + if ($resql) { + $num_rows = $db->num_rows($resql); + if ($num_rows > 0) { + $i = 0; + while ($i < $num_rows) { + $objp = $db->fetch_object($resql); + $container_array[] = $objp; + $i++; + } + } + }else{ + dol_print_error($db); + } + + if (!is_dir($tempdir)) { + mkdir($tempdir); + } + $domtree = new DOMDocument('1.0','UTF-8'); + $domtree->formatOutput = true; + $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9','urlset'); + foreach ($container_array as $container) { + $url = $domtree->createElement('url'); + $pageurl = $container->pageurl; + if ($container->lang) { + $pageurl = $container->lang.'/'.$pageurl; + } + $loc = $domtree->createElement('loc','http://'.$domainname.'/'.$pageurl); + $lastmod = $domtree->createElement('lastmod',$container->tms); + + $url->appendChild($loc); + $url->appendChild($lastmod); + $root->appendChild($url); + } + $domtree->appendChild($root); + $domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml'); + print '
'; + print $formfile->showdocuments('website', 'temp/'.$websitekey, $tempdir, $_SERVER["PHP_SELF"].'?action=""', $liste, 0,'', 1, 1, 0, 0, 0, '', $langs->trans("GeneratedSitemapsFiles")); + +} + if ($action == 'editfile' || $action == 'file_manager') { print ''."\n"; From 484b406985803487f9db30d9464c81e396a681fa Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 10 Feb 2021 10:41:13 +0100 Subject: [PATCH 02/70] Add website url form --- htdocs/langs/en_US/website.lang | 5 +++-- htdocs/website/index.php | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 27501c072fd..f59c7d23697 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -137,6 +137,7 @@ PagesRegenerated=%s page(s)/container(s) regenerated RegenerateWebsiteContent=Regenerate web site cache files AllowedInFrames=Allowed in Frames DefineListOfAltLanguagesInWebsiteProperties=Define list of all available languages into web site properties. -GenerateSitemaps=Generate web site sitemap file +GenerateSitemaps=Generate website sitemap file BackToPreview= Back to preview -GeneratedSitemapsFiles = Generated sitemap files \ No newline at end of file +GeneratedSitemapsFiles = Generated sitemap files +EnterWebsiteUrl= Enter your website URL diff --git a/htdocs/website/index.php b/htdocs/website/index.php index b29a1419e5c..d5459094737 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2471,7 +2471,10 @@ if (!GETPOST('hide_websitemenu')) print '   '; - print dolButtonToOpenUrlInDialogPopup('generate_sitemap', $langs->transnoentitiesnoconv("GenerateSitemaps"), '', '/website/index.php?action=generatesitemaps&website='.$website->ref, $disabled); + if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) + { + print dolButtonToOpenUrlInDialogPopup('generate_sitemap', $langs->transnoentitiesnoconv("GenerateSitemaps"), '', '/website/index.php?action=generatesitemapsdomainname&website='.$website->ref, $disabled); + } print '   '; @@ -3800,8 +3803,24 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of $domainname = '0.0.0.0:8080'; $tempdir = $conf->website->dir_temp.'/'.$websitekey.'/'; +if ($action == 'generatesitemapsdomainname'){ + print '
'; + print ''; + print ''; + print ''; + print '

'; + print '
'.$langs->trans('EnterWebsiteUrl').'

'; + print ''.$form->textwithpicto('', $langs->trans("Exemple").': www.exemple.com').'

'; + print ''; + print '
'; + print '
'; +} + // Generate web site sitemaps if ($action == 'generatesitemaps') { + if (!empty($_POST['domainname'])) { + $domainname = $_POST['domainname']; + } $container_array = array(); $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; From 865c678e3eb985d1594b412c7109a1f0f743449d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 10 Feb 2021 09:46:42 +0000 Subject: [PATCH 03/70] Fixing style errors. --- htdocs/website/index.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d5459094737..9af38431bcc 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3836,24 +3836,24 @@ if ($action == 'generatesitemaps') { $i++; } } - }else{ + }else { dol_print_error($db); } if (!is_dir($tempdir)) { mkdir($tempdir); } - $domtree = new DOMDocument('1.0','UTF-8'); + $domtree = new DOMDocument('1.0', 'UTF-8'); $domtree->formatOutput = true; - $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9','urlset'); + $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); foreach ($container_array as $container) { $url = $domtree->createElement('url'); $pageurl = $container->pageurl; if ($container->lang) { $pageurl = $container->lang.'/'.$pageurl; } - $loc = $domtree->createElement('loc','http://'.$domainname.'/'.$pageurl); - $lastmod = $domtree->createElement('lastmod',$container->tms); + $loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl); + $lastmod = $domtree->createElement('lastmod', $container->tms); $url->appendChild($loc); $url->appendChild($lastmod); @@ -3862,8 +3862,7 @@ if ($action == 'generatesitemaps') { $domtree->appendChild($root); $domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml'); print '
'; - print $formfile->showdocuments('website', 'temp/'.$websitekey, $tempdir, $_SERVER["PHP_SELF"].'?action=""', $liste, 0,'', 1, 1, 0, 0, 0, '', $langs->trans("GeneratedSitemapsFiles")); - + print $formfile->showdocuments('website', 'temp/'.$websitekey, $tempdir, $_SERVER["PHP_SELF"].'?action=""', $liste, 0, '', 1, 1, 0, 0, 0, '', $langs->trans("GeneratedSitemapsFiles")); } if ($action == 'editfile' || $action == 'file_manager') From e36391c6abeb964f7ccba56e1e1fd53b349735da Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 10 Feb 2021 13:15:56 +0100 Subject: [PATCH 04/70] Close #16218 : new button sitemap file --- htdocs/website/index.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 9af38431bcc..5475efc50eb 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3803,6 +3803,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of $domainname = '0.0.0.0:8080'; $tempdir = $conf->website->dir_temp.'/'.$websitekey.'/'; +// Form URL for generate web site sitemaps if ($action == 'generatesitemapsdomainname'){ print '
'; print ''; From 40b20d510d6dcf14d598929d6864809f5313f4c5 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 11 Feb 2021 10:05:40 +0100 Subject: [PATCH 05/70] fix to fix PR --- htdocs/langs/en_US/website.lang | 6 +- htdocs/website/index.php | 141 +++++++++++++++----------------- 2 files changed, 69 insertions(+), 78 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index f59c7d23697..6c43fa7fc7c 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -138,6 +138,6 @@ RegenerateWebsiteContent=Regenerate web site cache files AllowedInFrames=Allowed in Frames DefineListOfAltLanguagesInWebsiteProperties=Define list of all available languages into web site properties. GenerateSitemaps=Generate website sitemap file -BackToPreview= Back to preview -GeneratedSitemapsFiles = Generated sitemap files -EnterWebsiteUrl= Enter your website URL +ConfirmGenerateSitemaps=If you confirm, you will erase the existing sitemap file... +ConfirmSitemapsCreation=Confirm sitemap generation +SitemapGenerated=Sitemap Generated diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 5475efc50eb..49e1c4d0d55 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2155,6 +2155,65 @@ if ($action == 'regeneratesite') } } +$form = new Form($db); +$formadmin = new FormAdmin($db); +$formwebsite = new FormWebsite($db); +$formother = new FormOther($db); +$domainname = '0.0.0.0:8080'; +$tempdir = $conf->website->dir_output.'/'.$websitekey.'/'; + +// Confirm generation of website sitemaps +if($action == 'confirmgeneratesitemaps'){ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref),'generatesitemaps', '', "yes", 1); + $action = 'preview'; +} + +// Generate web site sitemaps +if ($action == 'generatesitemaps') { + $domtree = new DOMDocument('1.0', 'UTF-8'); + $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); + $domtree->formatOutput = true; + + $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms, w.virtualhost"; + $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp, ".MAIN_DB_PREFIX."website as w"; + $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; + $resql = $db->query($sql); + if ($resql) { + $num_rows = $db->num_rows($resql); + if ($num_rows > 0) { + $i = 0; + while ($i < $num_rows) { + $objp = $db->fetch_object($resql); + $url = $domtree->createElement('url'); + $pageurl = $objp->pageurl; + if ($objp->lang) { + $pageurl = $objp->lang.'/'.$pageurl; + } + if ($objp->virtualhost) { + $domainname = $objp->virtualhost; + } + $loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl); + $lastmod = $domtree->createElement('lastmod', $objp->tms); + + $url->appendChild($loc); + $url->appendChild($lastmod); + $root->appendChild($url); + $i++; + } + $domtree->appendChild($root); + if ($domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml')) + { + setEventMessages($langs->trans("SitemapGenerated"), null, 'mesgs'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + }else { + dol_print_error($db); + } + $action = 'preview'; +} + // Import site if ($action == 'importsiteconfirm') { @@ -2251,11 +2310,6 @@ if ($action == 'importsiteconfirm') * View */ -$form = new Form($db); -$formadmin = new FormAdmin($db); -$formwebsite = new FormWebsite($db); -$formother = new FormOther($db); -$formfile = new FormFile($db); $helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website'; @@ -2470,11 +2524,9 @@ if (!GETPOST('hide_websitemenu')) print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'">'; print '   '; - - if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) - { - print dolButtonToOpenUrlInDialogPopup('generate_sitemap', $langs->transnoentitiesnoconv("GenerateSitemaps"), '', '/website/index.php?action=generatesitemapsdomainname&website='.$website->ref, $disabled); - } + + // Generate site map + print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">'; print '   '; @@ -2579,7 +2631,7 @@ if (!GETPOST('hide_websitemenu')) // Toolbar for pages // - if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm', 'generatesitemaps')) && !$file_manager) + if ($websitekey && $websitekey != '-1' && !in_array($action, array('editcss', 'editmenu', 'importsite', 'file_manager', 'replacesite', 'replacesiteconfirm')) && !$file_manager) { print ''; // Close current websitebar to open a new one @@ -3800,70 +3852,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of print '
'; } -$domainname = '0.0.0.0:8080'; -$tempdir = $conf->website->dir_temp.'/'.$websitekey.'/'; - -// Form URL for generate web site sitemaps -if ($action == 'generatesitemapsdomainname'){ - print ''; - print ''; - print ''; - print ''; - print '

'; - print '
'.$langs->trans('EnterWebsiteUrl').'

'; - print ''.$form->textwithpicto('', $langs->trans("Exemple").': www.exemple.com').'

'; - print ''; - print '
'; - print ''; -} - -// Generate web site sitemaps -if ($action == 'generatesitemaps') { - if (!empty($_POST['domainname'])) { - $domainname = $_POST['domainname']; - } - $container_array = array(); - $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; - $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; - $resql = $db->query($sql); - if ($resql) { - $num_rows = $db->num_rows($resql); - if ($num_rows > 0) { - $i = 0; - while ($i < $num_rows) { - $objp = $db->fetch_object($resql); - $container_array[] = $objp; - $i++; - } - } - }else { - dol_print_error($db); - } - - if (!is_dir($tempdir)) { - mkdir($tempdir); - } - $domtree = new DOMDocument('1.0', 'UTF-8'); - $domtree->formatOutput = true; - $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); - foreach ($container_array as $container) { - $url = $domtree->createElement('url'); - $pageurl = $container->pageurl; - if ($container->lang) { - $pageurl = $container->lang.'/'.$pageurl; - } - $loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl); - $lastmod = $domtree->createElement('lastmod', $container->tms); - - $url->appendChild($loc); - $url->appendChild($lastmod); - $root->appendChild($url); - } - $domtree->appendChild($root); - $domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml'); - print '
'; - print $formfile->showdocuments('website', 'temp/'.$websitekey, $tempdir, $_SERVER["PHP_SELF"].'?action=""', $liste, 0, '', 1, 1, 0, 0, 0, '', $langs->trans("GeneratedSitemapsFiles")); +// Print formconfirm +if ($action == 'preview'){ + print $formconfirm; } if ($action == 'editfile' || $action == 'file_manager') From 7f6cb24909edfa393d95a9872803eeea4d5d9d0f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 11 Feb 2021 09:06:39 +0000 Subject: [PATCH 06/70] Fixing style errors. --- htdocs/website/index.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 49e1c4d0d55..2d3d1c80bfc 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2163,8 +2163,8 @@ $domainname = '0.0.0.0:8080'; $tempdir = $conf->website->dir_output.'/'.$websitekey.'/'; // Confirm generation of website sitemaps -if($action == 'confirmgeneratesitemaps'){ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref),'generatesitemaps', '', "yes", 1); +if ($action == 'confirmgeneratesitemaps'){ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); $action = 'preview'; } @@ -2210,7 +2210,7 @@ if ($action == 'generatesitemaps') { } }else { dol_print_error($db); - } + } $action = 'preview'; } @@ -2524,7 +2524,7 @@ if (!GETPOST('hide_websitemenu')) print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'">'; print '   '; - + // Generate site map print 'ref.'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">'; @@ -3854,7 +3854,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of // Print formconfirm if ($action == 'preview'){ - print $formconfirm; + print $formconfirm; } if ($action == 'editfile' || $action == 'file_manager') From 4032c8f8772e4b2173dcbcbac7df289443391154 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 12 Feb 2021 12:02:17 +0100 Subject: [PATCH 07/70] changes to fix pr + robots.txt --- htdocs/website/index.php | 145 +++++++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 61 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 2d3d1c80bfc..4d86b1f856b 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2155,65 +2155,6 @@ if ($action == 'regeneratesite') } } -$form = new Form($db); -$formadmin = new FormAdmin($db); -$formwebsite = new FormWebsite($db); -$formother = new FormOther($db); -$domainname = '0.0.0.0:8080'; -$tempdir = $conf->website->dir_output.'/'.$websitekey.'/'; - -// Confirm generation of website sitemaps -if ($action == 'confirmgeneratesitemaps'){ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); - $action = 'preview'; -} - -// Generate web site sitemaps -if ($action == 'generatesitemaps') { - $domtree = new DOMDocument('1.0', 'UTF-8'); - $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); - $domtree->formatOutput = true; - - $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms, w.virtualhost"; - $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp, ".MAIN_DB_PREFIX."website as w"; - $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; - $resql = $db->query($sql); - if ($resql) { - $num_rows = $db->num_rows($resql); - if ($num_rows > 0) { - $i = 0; - while ($i < $num_rows) { - $objp = $db->fetch_object($resql); - $url = $domtree->createElement('url'); - $pageurl = $objp->pageurl; - if ($objp->lang) { - $pageurl = $objp->lang.'/'.$pageurl; - } - if ($objp->virtualhost) { - $domainname = $objp->virtualhost; - } - $loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl); - $lastmod = $domtree->createElement('lastmod', $objp->tms); - - $url->appendChild($loc); - $url->appendChild($lastmod); - $root->appendChild($url); - $i++; - } - $domtree->appendChild($root); - if ($domtree->save($tempdir.'sitemaps.'.$websitekey.'.xml')) - { - setEventMessages($langs->trans("SitemapGenerated"), null, 'mesgs'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - }else { - dol_print_error($db); - } - $action = 'preview'; -} - // Import site if ($action == 'importsiteconfirm') { @@ -2307,9 +2248,91 @@ if ($action == 'importsiteconfirm') /* - * View - */ +* View +*/ +$form = new Form($db); +$formadmin = new FormAdmin($db); +$formwebsite = new FormWebsite($db); +$formother = new FormOther($db); +$domainname = '0.0.0.0:8080'; +$tempdir = $conf->website->dir_output.'/'.$websitekey.'/'; + +// Confirm generation of website sitemaps +if ($action == 'confirmgeneratesitemaps'){ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); + $action = 'preview'; +} + +// Generate web site sitemaps +if ($action == 'generatesitemaps') { + $domtree = new DOMDocument('1.0', 'UTF-8'); + $root = $domtree->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); + $domtree->formatOutput = true; + $xmlname = 'sitemap.'.$websitekey.'.xml'; + + $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms, w.virtualhost"; + $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp, ".MAIN_DB_PREFIX."website as w"; + $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; + $sql .= " AND wp.fk_website = w.rowid"; + $sql .= " AND w.ref = '".$websitekey."'"; + $resql = $db->query($sql); + if ($resql) { + $num_rows = $db->num_rows($resql); + if ($num_rows > 0) { + $i = 0; + while ($i < $num_rows) { + $objp = $db->fetch_object($resql); + $url = $domtree->createElement('url'); + $pageurl = $objp->pageurl; + if ($objp->lang) { + $pageurl = $objp->lang.'/'.$pageurl; + } + if ($objp->virtualhost) { + $domainname = $objp->virtualhost; + } + $loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl); + $lastmod = $domtree->createElement('lastmod', $objp->tms); + + $url->appendChild($loc); + $url->appendChild($lastmod); + $root->appendChild($url); + $i++; + } + $domtree->appendChild($root); + if ($domtree->save($tempdir.$xmlname)) + { + setEventMessages($langs->trans("SitemapGenerated"), null, 'mesgs'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + }else { + dol_print_error($db); + } + $robotcontent = @file_get_contents($filerobot); + $result = preg_replace('/\n/ims', '', $robotcontent); + if ($result) + { + $robotcontent = $result; + } + $robotsitemap = "Sitemap: ".$domainname."/".$xmlname; + $result = strpos($robotcontent,'Sitemap: '); + if ($result) + { + $result = preg_replace("/Sitemap.*\n/",$robotsitemap,$robotcontent); + $robotcontent = $result ? $result : $robotcontent; + }else{ + $robotcontent .= $robotsitemap."\n"; + } + $result = dolSaveRobotFile($filerobot, $robotcontent); + if (!$result) + { + $error++; + setEventMessages('Failed to write file '.$filerobot, null, 'errors'); + } + $action = 'preview'; +} $helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website'; From 08a21a7408b6da476de7e62787218a5cbbf6e9d2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 12 Feb 2021 11:03:09 +0000 Subject: [PATCH 08/70] Fixing style errors. --- htdocs/website/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 4d86b1f856b..04ed41b4004 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2317,12 +2317,12 @@ if ($action == 'generatesitemaps') { $robotcontent = $result; } $robotsitemap = "Sitemap: ".$domainname."/".$xmlname; - $result = strpos($robotcontent,'Sitemap: '); + $result = strpos($robotcontent, 'Sitemap: '); if ($result) { - $result = preg_replace("/Sitemap.*\n/",$robotsitemap,$robotcontent); + $result = preg_replace("/Sitemap.*\n/", $robotsitemap, $robotcontent); $robotcontent = $result ? $result : $robotcontent; - }else{ + }else { $robotcontent .= $robotsitemap."\n"; } $result = dolSaveRobotFile($filerobot, $robotcontent); From 44f4410c83ee1f1352c68d29a8bed83013ae77f8 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Fri, 12 Feb 2021 12:31:42 +0100 Subject: [PATCH 09/70] buid error repair --- 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 04ed41b4004..6570ec3d940 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2275,7 +2275,7 @@ if ($action == 'generatesitemaps') { $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp, ".MAIN_DB_PREFIX."website as w"; $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; $sql .= " AND wp.fk_website = w.rowid"; - $sql .= " AND w.ref = '".$websitekey."'"; + $sql .= " AND w.ref = '".dol_escape_json($websitekey)."'"; $resql = $db->query($sql); if ($resql) { $num_rows = $db->num_rows($resql); From 02a26104321593b14b61fc4ff83fa6d2205d52b7 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Feb 2021 19:22:36 +0100 Subject: [PATCH 10/70] NEW: Conf for default actiomm status when created from card --- htdocs/admin/agenda_other.php | 8 ++++++++ htdocs/comm/action/card.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a072869be8c..32fd289eff7 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -84,6 +84,7 @@ if ($action == 'set') dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, 'AGENDA_EVENT_DEFAULT_STATUS', GETPOST('AGENDA_EVENT_DEFAULT_STATUS'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'specimen') // For orders { $modele = GETPOST('module', 'alpha'); @@ -352,6 +353,13 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); print ''."\n"; } +// AGENDA_EVENT_DEFAULT_STATUS +print ''."\n"; +print ''.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").''."\n"; +print ' '."\n"; +print ''."\n"; +$formactions->form_select_status_action('formaction', $conf->global->AGENDA_EVENT_DEFAULT_STATUS, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); +print ''."\n"; // AGENDA_DEFAULT_FILTER_TYPE print ''."\n"; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index e34dffd6223..fd9849e3420 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1050,12 +1050,12 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print ''; - $percent = -1; if (GETPOSTISSET('status')) $percent = GETPOST('status'); elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage'); else { if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; + elseif ($conf->global->AGENDA_EVENT_DEFAULT_STATUS!=='na') $percent = $conf->global->AGENDA_EVENT_DEFAULT_STATUS; } $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 641cb8fb0af..78e38973caa 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2104,3 +2104,4 @@ AskThisIDToYourBank=Contact your bank to get this ID AdvancedModeOnly=Permision available in Advanced permission mode only ConfFileIsReadableOrWritableByAnyUsers=The conf file is reabable or writable by any users. Give permission to web server user and group only. MailToSendEventOrganization=Event Organization +AGENDA_EVENT_DEFAULT_STATUS=Default event status when event created manually From 8b5ac45e34c33777af31a6e8bb85b0d6e6cdc34d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 16 Feb 2021 19:29:45 +0100 Subject: [PATCH 11/70] fix typo --- htdocs/admin/agenda_other.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 32fd289eff7..f48298f2d53 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -358,7 +358,7 @@ print ''."\n"; print ''.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").''."\n"; print ' '."\n"; print ''."\n"; -$formactions->form_select_status_action('formaction', $conf->global->AGENDA_EVENT_DEFAULT_STATUS, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); +$formactions->form_select_status_action('agenda', $conf->global->AGENDA_EVENT_DEFAULT_STATUS, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); print ''."\n"; // AGENDA_DEFAULT_FILTER_TYPE From a5736345e39fb1506a7334766d7689a27dadf5b2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 17 Feb 2021 07:30:53 +0100 Subject: [PATCH 12/70] fix typo --- htdocs/comm/action/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index fd9849e3420..62175f882f9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1050,6 +1050,7 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print ''; + $percent = -1; if (GETPOSTISSET('status')) $percent = GETPOST('status'); elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage'); else { From e2b469dee436177abeff0ae29d5f286def2aa36b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Feb 2021 15:54:30 +0100 Subject: [PATCH 13/70] Update admin.lang --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 78e38973caa..c418987f74a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2104,4 +2104,4 @@ AskThisIDToYourBank=Contact your bank to get this ID AdvancedModeOnly=Permision available in Advanced permission mode only ConfFileIsReadableOrWritableByAnyUsers=The conf file is reabable or writable by any users. Give permission to web server user and group only. MailToSendEventOrganization=Event Organization -AGENDA_EVENT_DEFAULT_STATUS=Default event status when event created manually +AGENDA_EVENT_DEFAULT_STATUS=Default event status when creating a event from the form From aab4f8e02878e217e185180a7c31afee4ba50c43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Feb 2021 15:56:10 +0100 Subject: [PATCH 14/70] Update card.php --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 62175f882f9..f3ad41eb7f2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1056,7 +1056,7 @@ if ($action == 'create') else { if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; - elseif ($conf->global->AGENDA_EVENT_DEFAULT_STATUS!=='na') $percent = $conf->global->AGENDA_EVENT_DEFAULT_STATUS; + elseif (isset($conf->global->AGENDA_EVENT_DEFAULT_STATUS) && $conf->global->AGENDA_EVENT_DEFAULT_STATUS!=='na') $percent = $conf->global->AGENDA_EVENT_DEFAULT_STATUS; } $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; From b097e909a603a681d53127431fd374b0840158d5 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 1 Mar 2021 09:52:34 +0100 Subject: [PATCH 15/70] changes to fix pr with eldy advices --- htdocs/website/index.php | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index eff25950a46..8c42f491618 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2144,26 +2144,9 @@ if ($action == 'importsiteconfirm') { } } - - - -/* -* View -*/ - -$form = new Form($db); -$formadmin = new FormAdmin($db); -$formwebsite = new FormWebsite($db); -$formother = new FormOther($db); $domainname = '0.0.0.0:8080'; $tempdir = $conf->website->dir_output.'/'.$websitekey.'/'; -// Confirm generation of website sitemaps -if ($action == 'confirmgeneratesitemaps'){ - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); - $action = 'preview'; -} - // Generate web site sitemaps if ($action == 'generatesitemaps') { $domtree = new DOMDocument('1.0', 'UTF-8'); @@ -2234,6 +2217,21 @@ if ($action == 'generatesitemaps') { $action = 'preview'; } +/* +* View +*/ + +$form = new Form($db); +$formadmin = new FormAdmin($db); +$formwebsite = new FormWebsite($db); +$formother = new FormOther($db); + +// Confirm generation of website sitemaps +if ($action == 'confirmgeneratesitemaps'){ + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); + $action = 'preview'; +} + $helpurl = 'EN:Module_Website|FR:Module_Website_FR|ES:Módulo_Website'; $arrayofjs = array( From 96eb7a341a63d8e83f0eb92777fa25079463a330 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Mon, 1 Mar 2021 16:14:38 +0100 Subject: [PATCH 16/70] FIX: Bad project filter in ticket list --- htdocs/ticket/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 1a276c75f5f..5e8d9f640c5 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -362,7 +362,7 @@ foreach ($search as $key => $val) } if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_societe) $sql .= natural_search('s.nom', $search_societe); -//if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2); +if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2); if ($search_date_start) $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'"; if ($search_date_end) $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'"; if ($search_dateread_start) $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'"; From 861b583668ce9d881baee6b9508f409b728c66a3 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 1 Mar 2021 16:34:42 +0100 Subject: [PATCH 17/70] FIX : handling $heightforinfotot when he's superior to a page height on Supplier Invoice --- htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 26329ac889f..b5b93fec357 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -277,6 +277,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetAutoPageBreak(1, 0); $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part + if($heightforinfotot > 220) $heightforinfotot = 220; $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; From d20ba5a6657533d048d15553ed0c55334c404eb8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Mar 2021 15:38:15 +0000 Subject: [PATCH 18/70] Fixing style errors. --- .../core/modules/supplier_invoice/pdf/pdf_canelle.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index b5b93fec357..01f6369055b 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -277,7 +277,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetAutoPageBreak(1, 0); $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part - if($heightforinfotot > 220) $heightforinfotot = 220; + if($heightforinfotot > 220) $heightforinfotot = 220; $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; From eb62750aab0efaf141467bd61f62c1708a8807f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Mar 2021 18:06:03 +0100 Subject: [PATCH 19/70] fix typo --- htdocs/core/login/functions_openid.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index c06b10f109d..3f77eca1326 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -43,7 +43,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) $login = ''; // Get identity from user and redirect browser to OpenID Server - if (GETPOSISSET('username')) { + if (GETPOSTISSET('username')) { $openid = new SimpleOpenID(); $openid->SetIdentity($_POST['username']); $protocol = ($conf->file->main_force_https ? 'https://' : 'http://'); @@ -59,9 +59,8 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) return false; } return false; - } - // Perform HTTP Request to OpenID server to validate key - elseif ($_GET['openid_mode'] == 'id_res') { + } elseif ($_GET['openid_mode'] == 'id_res') { + // Perform HTTP Request to OpenID server to validate key $openid = new SimpleOpenID(); $openid->SetIdentity($_GET['openid_identity']); $openid_validation_result = $openid->ValidateWithServer(); From 0edae6e19a95b346f6dee0ba1e502b07d8cd2e3e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Mar 2021 18:25:23 +0100 Subject: [PATCH 20/70] add class default values --- htdocs/admin/defaultvalues.php | 110 +++---- htdocs/core/class/defaultvalues.class.php | 359 ++++++++++++++++++++++ 2 files changed, 414 insertions(+), 55 deletions(-) create mode 100644 htdocs/core/class/defaultvalues.class.php diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index ae9427d70e0..f9aa063c953 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors')); @@ -67,6 +68,7 @@ $value = GETPOST('value', 'restricthtml'); $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin')); +$object = new DefaultValues($db); /* * Actions */ @@ -133,27 +135,41 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac if ($action == 'add' || (GETPOST('add') && $action != 'update')) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; + $object->type=$mode; + $object->user_id=0; + $object->page=$defaulturl; + $object->param=$defaulturl; + $object->value=$defaultvalue; + $object->entity=$conf->entity; + $result=$object->create($user); + if ($result<0) { + $action = ''; + setEventMessages($object->error,$object->errors,'errors'); + } else { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $action = ""; + $defaulturl = ''; + $defaultkey = ''; + $defaultvalue = ''; + } } if (GETPOST('actionmodify')) { - $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; - $sql .= " WHERE rowid = ".$id; - } - - $result = $db->query($sql); - if ($result > 0) - { - $db->commit(); - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - $action = ""; - $defaulturl = ''; - $defaultkey = ''; - $defaultvalue = ''; - } else { - $db->rollback(); - setEventMessages($db->lasterror(), null, 'errors'); - $action = ''; + $object->id=$id; + $object->page=$defaulturl; + $object->param=$key; + $object->value=$defaultvalue; + $result=$object->update($user); + if ($result<0) { + $action = ''; + setEventMessages($object->error,$object->errors,'errors'); + } else { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + $action = ""; + $defaulturl = ''; + $defaultkey = ''; + $defaultvalue = ''; + } } } } @@ -161,14 +177,12 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac // Delete line from delete picto if ($action == 'delete') { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id); - // Delete const - $result = $db->query($sql); - if ($result >= 0) - { - setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); - } else { - dol_print_error($db); + $object->id=$id; + $result=$object->delete($user); + $result=$object->update($user); + if ($result<0) { + $action = ''; + setEventMessages($object->error,$object->errors,'errors'); } } @@ -323,39 +337,27 @@ print '\n"; print ''; +$result=$object->fetchAll( $sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); -// Show constants -$sql = "SELECT rowid, entity, type, page, param, value"; -$sql .= " FROM ".MAIN_DB_PREFIX."default_values"; -$sql .= " WHERE type = '".$db->escape($mode)."'"; -$sql .= " AND entity IN (".$user->entity.",".$conf->entity.")"; -$sql .= $db->order($sortfield, $sortorder); - -dol_syslog("translation::select from table", LOG_DEBUG); -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - $i = 0; - - while ($i < $num) +if (!is_array($result) && $result<0) { + setEventMessages($object->error, $object->errors,'errors'); +} else { + foreach($result as $key=>$defaultvalue) { - $obj = $db->fetch_object($result); - print "\n"; print ''; // Page print ''; - if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page; - else print ''; + if ($action != 'edit' || GETPOST('rowid', 'int') != $defaultvalue->rowid) print $defaultvalue->page; + else print ''; print ''."\n"; // Field print ''; - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; - else print ''; + if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->rowid) print $defaultvalue->param; + else print ''; print ''."\n"; // Value @@ -367,8 +369,8 @@ if ($result) print ''; print ''; */ - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); - else print ''; + if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->rowid) print dol_escape_htmltag($defaultvalue->value); + else print ''; print ''; } @@ -376,14 +378,14 @@ if ($result) // Actions print ''; - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) + if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) { - print ''.img_edit().''; - print ''.img_delete().''; + print ''.img_edit().''; + print ''.img_delete().''; } else { print ''; print ''; - print '
'; + print '
'; print ''; print ''; } @@ -393,8 +395,6 @@ if ($result) print "\n"; $i++; } -} else { - dol_print_error($db); } print ''; diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php new file mode 100644 index 00000000000..0552a2ed90e --- /dev/null +++ b/htdocs/core/class/defaultvalues.class.php @@ -0,0 +1,359 @@ + + * Copyright (C) 2021 Florian HENRY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/code/class/defaultvalues.class.php + * \brief This file is a CRUD class file for DefaultValues (Create/Read/Update/Delete) + */ + +// Put here all includes required by your class file +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; +//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + +/** + * Class for MyObject + */ +class DefaultValues extends CommonObject +{ + /** + * @var string ID to identify managed object. + */ + public $element = 'defaultvalues'; + + /** + * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management. + */ + public $table_element = 'default_values'; + + /** + * @var int Does this object support multicompany module ? + * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table + */ + public $ismultientitymanaged = 1; + + /** + * @var int Does object support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = ''; + + /** + * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'picto' is code of a picto to show before value in forms + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM) + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200' + * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), + 'type' =>array('type'=>'varchar(10)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'user_id' =>array('type'=>'integer', 'label'=>'Userid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'page' =>array('type'=>'varchar(255)', 'label'=>'RelativeURL', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'param' =>array('type'=>'varchar(255)', 'label'=>'Field', 'enabled'=>1, 'visible'=>-1, 'position'=>35), + 'value' =>array('type'=>'varchar(128)', 'label'=>'Value', 'enabled'=>1, 'visible'=>-1, 'position'=>40), + ); + + /** + * @var int ID + */ + public $rowid; + + /** + * @var int Entity + */ + public $entity; + + /** + * @var string Type + */ + public $type; + + /** + * @var int User Id + */ + public $user_id; + + /** + * @var string Page + */ + public $page; + + /** + * @var string Param + */ + public $param; + + /** + * @var string Value + */ + public $value; + // END MODULEBUILDER PROPERTIES + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) + { + foreach ($this->fields as $key => $val) + { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) + { + foreach ($val['arrayofkeyval'] as $key2 => $val2) + { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone an object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $extrafields; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $result = $object->fetchCommon($fromid); + if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines(); + + + // Reset some properties + unset($object->id); + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + return $result; + } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = 'SELECT '; + $sql .= $this->getFieldList(); + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + else $sql .= ' WHERE 1 = 1'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key.'='.$value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (is_array($value)) { + $sqlwhere[] = $key.' IN ('.implode(',',$value).')'; + } else { + $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' '.$this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) + { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } +} From 0ac5e370669b6ebd62529384467825b6977d50c7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Mar 2021 19:41:51 +0100 Subject: [PATCH 21/70] Update date of ticket in demo --- dev/initdemo/updatedemo.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index 5da0d4a2498..207cd07488c 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -73,7 +73,8 @@ $tables=array( 'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'), 'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture'), 'expensereport'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 4=>'date_approve', 5=>'date_refuse', 6=>'date_cancel'), - 'holiday'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel') + 'holiday'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel'), + 'ticket'=>array(0=>'datec', 1=>'date_read', 2=>'date_close') ); $year=2010; From 6e61ae8e56696e100a324a74ea568355efe39fa3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Mar 2021 19:50:35 +0100 Subject: [PATCH 22/70] Fix responsive --- htdocs/ticket/class/ticket.class.php | 4 ++-- htdocs/ticket/list.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 306f861097b..4571cbd679c 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -254,7 +254,7 @@ class Ticket extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''), 'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"), - 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'), + 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'tdoverflowmax125 maxwidth150onsmartphone'), 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'tdoverflowmax150'), 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth200 tdoverflowmax200', 'autofocusoncreate'=>1), 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth125 tdoverflowmax50'), @@ -266,7 +266,7 @@ class Ticket extends CommonObject 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1), 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1), - 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'css'=>'tdoverflowmax150'), + 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'css'=>'tdoverflowmax125'), 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1), 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 5e8d9f640c5..e9b36a2d364 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -667,7 +667,7 @@ foreach ($object->fields as $key => $val) print ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { print ''; - print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth150')); + print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth125')); print ''; } elseif ($key == 'fk_statut') { $arrayofstatus = array(); @@ -681,7 +681,7 @@ foreach ($object->fields as $key => $val) //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); $selectedarray = null; if ($search[$key]) $selectedarray = array_values($search[$key]); - print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', ''); + print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth100 maxwidth150', 1, 0, '', '', ''); print ''; } elseif ($key == "fk_soc") { print ''; From 7d3bd131abc8a98bb2b6fcfe06fbace16f434694 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Mar 2021 19:54:30 +0100 Subject: [PATCH 23/70] default envent status --- htdocs/admin/agenda_other.php | 38 +++++++++++++++++++++-- htdocs/comm/action/card.php | 2 -- htdocs/core/class/defaultvalues.class.php | 11 ++++--- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index f48298f2d53..edcffb00e71 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -30,6 +30,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php'; if (!$user->admin) accessforbidden(); @@ -84,7 +85,31 @@ if ($action == 'set') dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, 'AGENDA_EVENT_DEFAULT_STATUS', GETPOST('AGENDA_EVENT_DEFAULT_STATUS'), 'chaine', 0, '', $conf->entity); + + $defaultValues = new DefaultValues($db); + $result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 'entity'=>$conf->entity)); + if (!is_array($result) && $result<0) { + setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + } elseif(count($result)>0) { + foreach($result as $defval) { + $defaultValues->id=$defval->id; + $resultDel = $defaultValues->delete($user); + if ($resultDel<0) { + setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + } + } + } + $defaultValues->type='createform'; + $defaultValues->entity=$conf->entity; + $defaultValues->user_id=0; + $defaultValues->page='comm/action/card.php'; + $defaultValues->param='complete'; + $defaultValues->value=GETPOST('AGENDA_EVENT_DEFAULT_STATUS'); + $resultCreat=$defaultValues->create($user); + if ($resultCreat<0) { + setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + } + } elseif ($action == 'specimen') // For orders { $modele = GETPOST('module', 'alpha'); @@ -353,12 +378,21 @@ if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); print ''."\n"; } + // AGENDA_EVENT_DEFAULT_STATUS print ''."\n"; print ''.$langs->trans("AGENDA_EVENT_DEFAULT_STATUS").''."\n"; print ' '."\n"; print ''."\n"; -$formactions->form_select_status_action('agenda', $conf->global->AGENDA_EVENT_DEFAULT_STATUS, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); +$defval='na'; +$defaultValues = new DefaultValues($db); +$result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 'entity'=>$conf->entity)); +if (!is_array($result) && $result<0) { + setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); +} elseif(count($result)>0) { + $defval=reset($result)->value; +} +$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); print ''."\n"; // AGENDA_DEFAULT_FILTER_TYPE diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f3ad41eb7f2..a44747b0d7a 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1050,13 +1050,11 @@ if ($action == 'create') // Status print ''.$langs->trans("Status").' / '.$langs->trans("Percentage").''; print ''; - $percent = -1; if (GETPOSTISSET('status')) $percent = GETPOST('status'); elseif (GETPOSTISSET('percentage')) $percent = GETPOST('percentage'); else { if (GETPOST('complete') == '0' || GETPOST("afaire") == 1) $percent = '0'; elseif (GETPOST('complete') == 100 || GETPOST("afaire") == 2) $percent = 100; - elseif (isset($conf->global->AGENDA_EVENT_DEFAULT_STATUS) && $conf->global->AGENDA_EVENT_DEFAULT_STATUS!=='na') $percent = $conf->global->AGENDA_EVENT_DEFAULT_STATUS; } $formactions->form_select_status_action('formaction', $percent, 1, 'complete', 0, 0, 'maxwidth200'); print ''; diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index 0552a2ed90e..c43d3ae121c 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -235,12 +235,11 @@ class DefaultValues extends CommonObject * Load object in memory from the database * * @param int $id Id object - * @param string $ref Ref * @return int <0 if KO, 0 if not found, >0 if OK */ - public function fetch($id, $ref = null) + public function fetch($id) { - $result = $this->fetchCommon($id, $ref); + $result = $this->fetchCommon($id, null); return $result; } @@ -272,11 +271,13 @@ class DefaultValues extends CommonObject $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key == 't.rowid') { + if ($key == 't.rowid' || ($key == 't.entity' && !is_array($value)) || $key == 't.user_id') { $sqlwhere[] = $key.'='.$value; } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 'customsql') { + } elseif ($key == 't.page' || $key == 't.param' || $key == 't.type'){ + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } elseif ($key == 'customsql') { $sqlwhere[] = $value; } elseif (is_array($value)) { $sqlwhere[] = $key.' IN ('.implode(',',$value).')'; From f62386a6a57a2f429a8caf503d2b27488e320f7b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Mar 2021 20:36:42 +0100 Subject: [PATCH 24/70] set Default values as CURD classes --- htdocs/admin/agenda_other.php | 4 +- htdocs/admin/defaultvalues.php | 22 +++++----- htdocs/core/class/defaultvalues.class.php | 9 ++-- htdocs/user/class/user.class.php | 50 +++++++++++------------ 4 files changed, 42 insertions(+), 43 deletions(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 57a1f74d530..9e2f6acaebb 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -83,7 +83,7 @@ if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); $defaultValues = new DefaultValues($db); - $result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 'entity'=>$conf->entity)); + $result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); if (!is_array($result) && $result<0) { setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); } elseif(count($result)>0) { @@ -358,7 +358,7 @@ print ' '."\n"; print ''."\n"; $defval='na'; $defaultValues = new DefaultValues($db); -$result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 'entity'=>$conf->entity)); +$result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); if (!is_array($result) && $result<0) { setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); } elseif(count($result)>0) { diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 9904ff734c2..a6780df7b6e 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -43,7 +43,7 @@ $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); $optioncss = GETPOST('optionscss', 'alphanohtml'); -$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus' +$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'createform'; // 'createform', 'filters', 'sortorder', 'focus' $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -138,13 +138,12 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac } if (!$error) { - $db->begin(); if ($action == 'add' || (GETPOST('add') && $action != 'update')) { $object->type=$mode; $object->user_id=0; $object->page=$defaulturl; - $object->param=$defaulturl; + $object->param=$defaultkey; $object->value=$defaultvalue; $object->entity=$conf->entity; $result=$object->create($user); @@ -162,9 +161,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac if (GETPOST('actionmodify')) { $object->id=$id; - $object->page=$defaulturl; + $object->type=$mode; + $object->page=$urlpage; $object->param=$key; - $object->value=$defaultvalue; + $object->value=$value; + $object->entity=$conf->entity; $result=$object->update($user); if ($result<0) { $action = ''; @@ -358,8 +359,9 @@ print ''; $result=$object->fetchAll( $sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); if (!is_array($result) && $result<0) { + setEventMessages($object->error, $object->errors,'errors'); -} else { +} elseif (count($result)>0) { foreach($result as $key=>$defaultvalue) { print "\n"; @@ -367,13 +369,13 @@ if (!is_array($result) && $result<0) { // Page print ''; - if ($action != 'edit' || GETPOST('rowid', 'int') != $defaultvalue->rowid) print $defaultvalue->page; + if ($action != 'edit' || GETPOST('rowid', 'int') != $defaultvalue->id) print $defaultvalue->page; else print ''; print ''."\n"; // Field print ''; - if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->rowid) print $defaultvalue->param; + if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print $defaultvalue->param; else print ''; print ''."\n"; @@ -385,7 +387,7 @@ if (!is_array($result) && $result<0) { print ''; print ''; */ - if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->rowid) print dol_escape_htmltag($defaultvalue->value); + if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print dol_escape_htmltag($defaultvalue->value); else print ''; print ''; } @@ -400,7 +402,7 @@ if (!is_array($result) && $result<0) { } else { print ''; print ''; - print '
'; + print '
'; print ''; print ''; } diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index c43d3ae121c..ae5ed6e92fb 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -265,13 +265,12 @@ class DefaultValues extends CommonObject $sql = 'SELECT '; $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; - else $sql .= ' WHERE 1 = 1'; + $sql .= ' WHERE 1 = 1'; // Manage filter $sqlwhere = array(); if (count($filter) > 0) { foreach ($filter as $key => $value) { - if ($key == 't.rowid' || ($key == 't.entity' && !is_array($value)) || $key == 't.user_id') { + if ($key == 't.rowid' || ($key == 't.entity' && !is_array($value)) || ($key == 't.user_id' && !is_array($value))) { $sqlwhere[] = $key.'='.$value; } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; @@ -296,10 +295,12 @@ class DefaultValues extends CommonObject if (!empty($limit)) { $sql .= ' '.$this->db->plimit($limit, $offset); } - +print $sql; $resql = $this->db->query($sql); if ($resql) { + $num = $this->db->num_rows($resql); + var_dump($num); $i = 0; while ($i < ($limit ? min($limit, $num) : $num)) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8712bcc4615..bacbfa32f67 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -611,31 +611,32 @@ class User extends CommonObject public function loadDefaultValues() { global $conf; + if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - // Load user->default_values for user. TODO Save this in memcached ? - $sql = "SELECT rowid, entity, type, page, param, value"; - $sql .= " FROM ".MAIN_DB_PREFIX."default_values"; - $sql .= " WHERE entity IN (".($this->entity > 0 ? $this->entity.", " : "").$conf->entity.")"; // Entity of user (if defined) + current entity - $sql .= " AND user_id IN (0".($this->id > 0 ? ", ".$this->id : "").")"; // User 0 (all) + me (if defined) - $resql = $this->db->query($sql); - if ($resql) { - while ($obj = $this->db->fetch_object($resql)) { - if (!empty($obj->page) && !empty($obj->type) && !empty($obj->param)) { - // $obj->page is relative URL with or without params - // $obj->type can be 'filters', 'sortorder', 'createform', ... - // $obj->param is key or param - $pagewithoutquerystring = $obj->page; - $pagequeries = ''; - $reg = array(); - if (preg_match('/^([^\?]+)\?(.*)$/', $pagewithoutquerystring, $reg)) { // There is query param - $pagewithoutquerystring = $reg[1]; - $pagequeries = $reg[2]; + // Load user->default_values for user. TODO Save this in memcached ? + require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php'; + + $defaultValues = new DefaultValues($this->db); + $result = $defaultValues->fetchAll('','',0,0,array('t.user_id'=>array(0,$this->id), 'entity'=>array($this->entity,$conf->entity))); + + if (!is_array($result) && $result<0) { + setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + dol_print_error($this->db); + return -1; + } elseif(count($result)>0) { + foreach($result as $defval) { + if (!empty($defval->page) && !empty($defval->type) && !empty($defval->param)) { + $pagewithoutquerystring = $defval->page; + $pagequeries = ''; + $reg = array(); + if (preg_match('/^([^\?]+)\?(.*)$/', $pagewithoutquerystring, $reg)) { // There is query param + $pagewithoutquerystring = $reg[1]; + $pagequeries = $reg[2]; + } + $this->default_values[$pagewithoutquerystring][$defval->type][$pagequeries ? $pagequeries : '_noquery_'][$defval->param] = $defval->value; } - $this->default_values[$pagewithoutquerystring][$obj->type][$pagequeries ? $pagequeries : '_noquery_'][$obj->param] = $obj->value; - //if ($pagequeries) $this->default_values[$pagewithoutquerystring][$obj->type.'_queries']=$pagequeries; } } - // Sort by key, so _noquery_ is last if (!empty($this->default_values)) { foreach ($this->default_values as $a => $b) { foreach ($b as $c => $d) { @@ -643,13 +644,8 @@ class User extends CommonObject } } } - $this->db->free($resql); - - return 1; - } else { - dol_print_error($this->db); - return -1; } + return 1; } /** From a4e25359e7caef474e274d0e85b722d87cff9693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Mar 2021 20:37:16 +0100 Subject: [PATCH 25/70] add missing rule --- dev/setup/codesniffer/ruleset.xml | 2 +- htdocs/comm/propal/card.php | 126 ++--- htdocs/comm/propal/class/propal.class.php | 9 +- htdocs/comm/propal/list.php | 3 +- htdocs/comm/propal/stats/index.php | 9 +- .../bank/account_statement_document.php | 3 +- htdocs/compta/bank/bankentries_list.php | 7 +- htdocs/compta/bank/budget.php | 4 +- htdocs/compta/bank/categ.php | 3 +- htdocs/compta/bank/graph.php | 15 +- htdocs/compta/bank/line.php | 3 +- htdocs/compta/bank/list.php | 8 +- .../compta/cashcontrol/cashcontrol_card.php | 6 +- .../compta/cashcontrol/cashcontrol_list.php | 3 +- htdocs/compta/cashcontrol/report.php | 7 +- htdocs/compta/deplacement/card.php | 12 +- htdocs/compta/deplacement/stats/index.php | 9 +- htdocs/compta/facture/card-rec.php | 65 +-- htdocs/compta/facture/card.php | 16 +- htdocs/compta/facture/class/facture.class.php | 6 +- .../facture/class/paymentterm.class.php | 9 +- .../compta/facture/invoicetemplate_list.php | 3 +- htdocs/compta/facture/list.php | 3 +- htdocs/compta/facture/prelevement.php | 4 +- htdocs/compta/facture/stats/index.php | 9 +- htdocs/compta/journal/sellsjournal.php | 3 +- htdocs/compta/localtax/clients.php | 21 +- htdocs/compta/localtax/index.php | 30 +- htdocs/compta/localtax/quadri_detail.php | 15 +- htdocs/compta/paiement.php | 6 +- htdocs/compta/paiement/cheque/card.php | 4 +- .../compta/paiement/class/paiement.class.php | 5 +- htdocs/compta/resultat/clientfourn.php | 15 +- htdocs/compta/resultat/index.php | 15 +- htdocs/compta/resultat/result.php | 15 +- htdocs/compta/sociales/card.php | 3 +- .../sociales/class/chargesociales.class.php | 3 +- .../class/paymentsocialcontribution.class.php | 6 +- htdocs/compta/stats/byratecountry.php | 27 +- htdocs/compta/stats/cabyprodserv.php | 15 +- htdocs/compta/stats/cabyuser.php | 15 +- htdocs/compta/stats/casoc.php | 15 +- htdocs/compta/stats/index.php | 15 +- htdocs/compta/stats/supplier_turnover.php | 15 +- .../stats/supplier_turnover_by_prodserv.php | 15 +- .../stats/supplier_turnover_by_thirdparty.php | 15 +- htdocs/compta/tva/card.php | 3 +- htdocs/compta/tva/class/paymentvat.class.php | 6 +- htdocs/compta/tva/clients.php | 15 +- htdocs/compta/tva/index.php | 30 +- htdocs/compta/tva/quadri_detail.php | 18 +- htdocs/core/actions_sendmails.inc.php | 4 +- htdocs/core/actions_setmoduleoptions.inc.php | 3 +- htdocs/core/ajax/ajaxdirpreview.php | 5 +- htdocs/core/ajax/ajaxdirtree.php | 15 +- htdocs/core/ajax/pingresult.php | 5 +- .../boxes/box_graph_invoices_permonth.php | 9 +- .../box_graph_invoices_supplier_permonth.php | 6 +- .../core/boxes/box_graph_orders_permonth.php | 6 +- .../box_graph_orders_supplier_permonth.php | 6 +- .../boxes/box_graph_product_distribution.php | 22 +- .../boxes/box_graph_propales_permonth.php | 9 +- htdocs/core/class/CMailFile.class.php | 9 +- htdocs/core/class/CSMSFile.class.php | 3 +- htdocs/core/class/ccountry.class.php | 9 +- htdocs/core/class/comment.class.php | 9 +- htdocs/core/class/commoninvoice.class.php | 10 +- htdocs/core/class/commonobject.class.php | 66 ++- htdocs/core/class/conf.class.php | 19 +- htdocs/core/class/cstate.class.php | 9 +- htdocs/core/class/ctypent.class.php | 9 +- htdocs/core/class/cunits.class.php | 9 +- htdocs/core/class/dolgeoip.class.php | 3 +- htdocs/core/class/dolgraph.class.php | 10 +- htdocs/core/class/events.class.php | 3 +- htdocs/core/class/extrafields.class.php | 3 +- htdocs/core/class/fileupload.class.php | 15 +- htdocs/core/class/hookmanager.class.php | 21 +- htdocs/core/class/html.form.class.php | 57 +- htdocs/core/class/html.formactions.class.php | 3 +- htdocs/core/class/html.formcompany.class.php | 9 +- htdocs/core/class/html.formfile.class.php | 41 +- htdocs/core/class/html.formmail.class.php | 3 +- htdocs/core/class/html.formother.class.php | 6 +- htdocs/core/class/html.formprojet.class.php | 3 +- htdocs/core/class/html.formsms.class.php | 3 +- htdocs/core/class/html.formwebsite.class.php | 3 +- htdocs/core/class/lessc.class.php | 34 +- htdocs/core/class/menubase.class.php | 5 +- htdocs/core/class/rssparser.class.php | 43 +- htdocs/core/class/smtps.class.php | 53 +- htdocs/core/class/stats.class.php | 9 +- htdocs/core/class/translate.class.php | 13 +- htdocs/core/class/utils.class.php | 9 +- htdocs/core/class/vcard.class.php | 3 +- htdocs/core/customreports.php | 14 +- htdocs/core/datepicker.php | 4 +- htdocs/core/extrafieldsinexport.inc.php | 5 +- htdocs/core/lib/admin.lib.php | 40 +- htdocs/core/lib/barcode.lib.php | 7 +- htdocs/core/lib/date.lib.php | 11 +- htdocs/core/lib/files.lib.php | 316 ++++++------ htdocs/core/lib/functions.lib.php | 485 ++++++++++++------ htdocs/core/lib/functions2.lib.php | 27 +- htdocs/core/lib/images.lib.php | 6 +- htdocs/core/lib/order.lib.php | 3 +- htdocs/core/lib/pdf.lib.php | 18 +- htdocs/core/lib/project.lib.php | 18 +- htdocs/core/lib/security.lib.php | 91 ++-- htdocs/core/lib/security2.lib.php | 15 +- htdocs/core/lib/treeview.lib.php | 6 +- htdocs/core/lib/website2.lib.php | 5 +- htdocs/core/lib/ws.lib.php | 18 +- htdocs/core/login/functions_openid.php | 7 +- htdocs/core/menus/standard/auguria.lib.php | 21 +- htdocs/core/menus/standard/eldy.lib.php | 18 +- htdocs/core/menus/standard/empty.php | 4 +- htdocs/core/modules/action/modules_action.php | 4 +- .../barcode/mod_barcode_product_standard.php | 3 +- .../bom/doc/doc_generic_bom_odt.modules.php | 3 +- htdocs/core/modules/bom/mod_bom_standard.php | 6 +- .../modules/cheque/doc/pdf_blochet.class.php | 3 +- .../modules/cheque/mod_chequereceipt_mint.php | 6 +- .../doc/doc_generic_order_odt.modules.php | 3 +- .../commande/doc/pdf_einstein.modules.php | 6 +- .../commande/doc/pdf_eratosthene.modules.php | 6 +- .../modules/commande/mod_commande_marbre.php | 6 +- .../doc/doc_generic_contract_odt.modules.php | 3 +- .../contract/doc/pdf_strato.modules.php | 3 +- .../modules/contract/mod_contract_serpis.php | 6 +- .../delivery/doc/pdf_storm.modules.php | 3 +- .../delivery/doc/pdf_typhon.modules.php | 3 +- .../modules/delivery/mod_delivery_jade.php | 6 +- .../doc/doc_generic_shipment_odt.modules.php | 3 +- .../expedition/doc/pdf_espadon.modules.php | 9 +- .../expedition/doc/pdf_merou.modules.php | 3 +- .../expedition/doc/pdf_rouget.modules.php | 9 +- .../expedition/mod_expedition_safor.php | 6 +- .../doc/pdf_standard.modules.php | 12 +- .../expensereport/mod_expensereport_jade.php | 6 +- .../doc/doc_generic_invoice_odt.modules.php | 3 +- .../modules/facture/doc/pdf_crabe.modules.php | 6 +- .../facture/doc/pdf_sponge.modules.php | 6 +- .../core/modules/facture/mod_facture_mars.php | 9 +- .../modules/facture/mod_facture_terre.php | 12 +- .../fichinter/doc/pdf_soleil.modules.php | 3 +- htdocs/core/modules/fichinter/mod_pacific.php | 6 +- .../modules/fichinter/modules_fichinter.php | 4 +- .../modules/holiday/mod_holiday_madonna.php | 6 +- .../modules/import/import_csv.modules.php | 10 +- .../modules/import/import_xlsx.modules.php | 10 +- .../doc/doc_generic_member_odt.class.php | 3 +- .../modules/member/doc/pdf_standard.class.php | 18 +- htdocs/core/modules/member/modules_cards.php | 4 +- htdocs/core/modules/modAdherent.class.php | 4 +- htdocs/core/modules/modBom.class.php | 17 +- htdocs/core/modules/modCategorie.class.php | 28 +- htdocs/core/modules/modCommande.class.php | 16 +- htdocs/core/modules/modContrat.class.php | 8 +- htdocs/core/modules/modExpedition.class.php | 16 +- .../core/modules/modExpenseReport.class.php | 4 +- htdocs/core/modules/modFacture.class.php | 16 +- htdocs/core/modules/modFicheinter.class.php | 8 +- htdocs/core/modules/modHoliday.class.php | 4 +- htdocs/core/modules/modProduct.class.php | 8 +- htdocs/core/modules/modProjet.class.php | 8 +- htdocs/core/modules/modPropale.class.php | 16 +- htdocs/core/modules/modReception.class.php | 12 +- htdocs/core/modules/modResource.class.php | 4 +- htdocs/core/modules/modService.class.php | 8 +- htdocs/core/modules/modSociete.class.php | 12 +- htdocs/core/modules/modStock.class.php | 12 +- htdocs/core/modules/modUser.class.php | 4 +- htdocs/core/modules/modWebsite.class.php | 4 +- .../movement/doc/pdf_standard.modules.php | 3 +- .../mrp/doc/doc_generic_mo_odt.modules.php | 3 +- htdocs/core/modules/mrp/mod_mo_standard.php | 6 +- .../modules/payment/mod_payment_cicada.php | 6 +- .../doc/pdf_standardlabel.class.php | 18 +- .../printsheet/doc/pdf_tcpdflabel.class.php | 3 +- .../modules/printsheet/modules_labels.php | 4 +- .../doc/doc_generic_product_odt.modules.php | 3 +- .../product/mod_codeproduct_elephant.php | 3 +- .../doc/doc_generic_project_odt.modules.php | 3 +- .../project/doc/pdf_baleine.modules.php | 3 +- .../project/doc/pdf_beluga.modules.php | 3 +- .../project/doc/pdf_timespent.modules.php | 3 +- .../modules/project/mod_project_simple.php | 6 +- .../task/doc/doc_generic_task_odt.modules.php | 3 +- .../modules/project/task/mod_task_simple.php | 6 +- .../doc/doc_generic_proposal_odt.modules.php | 3 +- .../modules/propale/doc/pdf_azur.modules.php | 6 +- .../modules/propale/doc/pdf_cyan.modules.php | 6 +- .../modules/propale/mod_propale_marbre.php | 6 +- .../doc/doc_generic_reception_odt.modules.php | 3 +- .../reception/doc/pdf_squille.modules.php | 9 +- .../modules/reception/mod_reception_beryl.php | 6 +- .../societe/doc/doc_generic_odt.modules.php | 3 +- .../societe/mod_codeclient_elephant.php | 3 +- .../doc/doc_generic_stock_odt.modules.php | 3 +- .../stock/doc/pdf_standard.modules.php | 3 +- .../doc/pdf_canelle.modules.php | 6 +- .../mod_facture_fournisseur_cactus.php | 12 +- ...doc_generic_supplier_order_odt.modules.php | 3 +- .../supplier_order/doc/pdf_cornas.modules.php | 6 +- .../doc/pdf_muscadet.modules.php | 6 +- .../mod_commande_fournisseur_muguet.php | 6 +- .../doc/pdf_standard.modules.php | 3 +- .../mod_supplier_payment_bronan.php | 6 +- ..._generic_supplier_proposal_odt.modules.php | 3 +- .../doc/pdf_aurore.modules.php | 6 +- .../mod_supplier_proposal_marbre.php | 6 +- .../doc/doc_generic_ticket_odt.modules.php | 3 +- .../core/modules/ticket/mod_ticket_simple.php | 4 +- .../user/doc/doc_generic_user_odt.modules.php | 3 +- .../doc/doc_generic_usergroup_odt.modules.php | 3 +- .../workstation/mod_workstation_standard.php | 6 +- htdocs/core/photos_resize.php | 13 +- htdocs/core/tpl/objectline_create.tpl.php | 3 +- ...e_20_modWorkflow_WorkflowManager.class.php | 15 +- ...terface_50_modAgenda_ActionsAuto.class.php | 29 +- ...interface_50_modLdap_Ldapsynchro.class.php | 24 +- ...odMailmanspip_Mailmanspipsynchro.class.php | 6 +- htdocs/ecm/dir_add_card.php | 6 +- htdocs/user/class/user.class.php | 16 +- 225 files changed, 1968 insertions(+), 1202 deletions(-) diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 21186cfbe5c..e99b8673981 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -215,7 +215,7 @@ - + diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 754d01e3b78..bf0ad592e8e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -215,8 +215,8 @@ if (empty($reshook)) { } } } - } // Delete proposal - elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { + } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete) { + // Delete proposal $result = $object->delete($user); if ($result > 0) { header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'); @@ -225,8 +225,8 @@ if (empty($reshook)) { $langs->load("errors"); setEventMessages($object->error, $object->errors, 'errors'); } - } // Remove line - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { + // Remove line $result = $object->deleteline($lineid); // reorder lines if ($result) { @@ -250,8 +250,8 @@ if (empty($reshook)) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); exit(); - } // Validation - elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { + } elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate) { + // Validation $idwarehouse = GETPOST('idwarehouse', 'int'); $result = $object->valid($user); if ($result >= 0) { @@ -308,17 +308,17 @@ if (empty($reshook)) { if ($result < 0) { dol_print_error($db, $object->error); } - } // Positionne ref client - elseif ($action == 'setref_client' && $usercancreate) { + } elseif ($action == 'setref_client' && $usercancreate) { + // Positionne ref client $result = $object->set_ref_client($user, GETPOST('ref_client')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } - } // Set incoterm - elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercancreate) { + } elseif ($action == 'set_incoterms' && !empty($conf->incoterm->enabled) && $usercancreate) { + // Set incoterm $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); - } // Create proposal - elseif ($action == 'add' && $usercancreate) { + } elseif ($action == 'add' && $usercancreate) { + // Create proposal $object->socid = $socid; $object->fetch_thirdparty(); @@ -554,8 +554,8 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); $error++; } - } // Standard creation - else { + } else { + // Standard creation $id = $object->create($user); } @@ -616,8 +616,8 @@ if (empty($reshook)) { } } } - } // Classify billed - elseif ($action == 'classifybilled' && $usercanclose) { + } elseif ($action == 'classifybilled' && $usercanclose) { + // Classify billed $db->begin(); $result = $object->cloture($user, $object::STATUS_BILLED, ''); @@ -631,8 +631,8 @@ if (empty($reshook)) { } else { $db->rollback(); } - } // Close proposal - elseif ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) { + } elseif ($action == 'confirm_closeas' && $usercanclose && !GETPOST('cancel', 'alpha')) { + // Close proposal if (!(GETPOST('statut', 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CloseAs")), null, 'errors'); $action = 'closeas'; @@ -654,8 +654,8 @@ if (empty($reshook)) { } } } - } // Reopen proposal - elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { + } elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { + // Reopen proposal // prevent browser refresh from reopening proposal several times if ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) { $db->begin(); @@ -672,11 +672,11 @@ if (empty($reshook)) { $db->rollback(); } } - } // add lines from objectlinked - elseif ($action == 'import_lines_from_object' + } elseif ($action == 'import_lines_from_object' && $user->rights->propal->creer && $object->statut == Propal::STATUS_DRAFT ) { + // add lines from objectlinked $fromElement = GETPOST('fromelement'); $fromElementid = GETPOST('fromelementid'); $importLines = GETPOST('line_checkbox'); @@ -898,8 +898,8 @@ if (empty($reshook)) { $tva_npr = $prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } - } // If price per customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { + // If price per customer require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); @@ -924,8 +924,8 @@ if (empty($reshook)) { } } } - } // If price per quantity - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + // If price per quantity if ($prod->prices_by_qty[0]) { // yes, this product has some prices per quantity // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = GETPOST('pbq', 'int'); @@ -945,8 +945,8 @@ if (empty($reshook)) { break; } } - } // If price per quantity and customer - elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { + // If price per quantity and customer if ($prod->prices_by_qty[$object->thirdparty->price_level]) { // yes, this product has some prices per quantity // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. $pqp = GETPOST('pbq', 'int'); @@ -975,9 +975,9 @@ if (empty($reshook)) { if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tmpvat != $tmpprodvat) { + } elseif ($tmpvat != $tmpprodvat) { + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { @@ -1167,8 +1167,8 @@ if (empty($reshook)) { } } } - } // Update a line within proposal - elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { + } elseif ($action == 'updateline' && $usercancreate && GETPOST('save')) { + // Update a line within proposal // Define info_bits $info_bits = 0; if (preg_match('/\*/', GETPOST('tva_tx'))) { @@ -1313,36 +1313,36 @@ if (empty($reshook)) { } elseif ($action == 'classin' && $usercancreate) { // Set project $object->setProject(GETPOST('projectid', 'int')); - } // Delivery time - elseif ($action == 'setavailability' && $usercancreate) { + } elseif ($action == 'setavailability' && $usercancreate) { + // Delivery time $result = $object->set_availability($user, GETPOST('availability_id', 'int')); - } // Origin of the commercial proposal - elseif ($action == 'setdemandreason' && $usercancreate) { + } elseif ($action == 'setdemandreason' && $usercancreate) { + // Origin of the commercial proposal $result = $object->set_demand_reason($user, GETPOST('demand_reason_id', 'int')); - } // Terms of payment - elseif ($action == 'setconditions' && $usercancreate) { + } elseif ($action == 'setconditions' && $usercancreate) { + // Terms of payment $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); } elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise_percent($user, $_POST['remise_percent']); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); - } // Payment choice - elseif ($action == 'setmode' && $usercancreate) { + } elseif ($action == 'setmode' && $usercancreate) { + // Payment choice $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercancreate) { + } elseif ($action == 'setmulticurrencycode' && $usercancreate) { + // Multicurrency Code $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + // Multicurrency rate $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx'))); - } // bank account - elseif ($action == 'setbankaccount' && $usercancreate) { + } elseif ($action == 'setbankaccount' && $usercancreate) { + // bank account $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } // shipping method - elseif ($action == 'setshippingmethod' && $usercancreate) { + } elseif ($action == 'setshippingmethod' && $usercancreate) { + // shipping method $result = $object->setShippingMethod(GETPOST('shipping_method_id', 'int')); - }// warehouse - elseif ($action == 'setwarehouse' && $usercancreate) { + } elseif ($action == 'setwarehouse' && $usercancreate) { + // warehouse $result = $object->setWarehouse(GETPOST('warehouse_id', 'int')); } elseif ($action == 'update_extras') { $object->oldcopy = dol_clone($object); @@ -1383,15 +1383,15 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } // Toggle the status of a contact - elseif ($action == 'swapstatut') { + } elseif ($action == 'swapstatut') { + // Toggle the status of a contact if ($object->fetch($id) > 0) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } - } // Delete a contact - elseif ($action == 'deletecontact') { + } elseif ($action == 'deletecontact') { + // Delete a contact $object->fetch($id); $result = $object->delete_contact($lineid); @@ -1907,17 +1907,17 @@ if ($action == 'create') { } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetAcceptedRefused'), $text, 'confirm_closeas', $formquestion, '', 1, 250); - } // Confirm delete - elseif ($action == 'delete') { + } elseif ($action == 'delete') { + // Confirm delete $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp', $object->ref), 'confirm_delete', '', 0, 1); - } // Confirm reopen - elseif ($action == 'reopen') { + } elseif ($action == 'reopen') { + // Confirm reopen $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp', $object->ref), 'confirm_reopen', '', 0, 1); - } // Confirmation delete product/service line - elseif ($action == 'ask_deleteline') { + } elseif ($action == 'ask_deleteline') { + // Confirmation delete product/service line $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline', '', 0, 1); - } // Confirm validate proposal - elseif ($action == 'validate') { + } elseif ($action == 'validate') { + // Confirm validate proposal $error = 0; // We verify whether the object is provisionally numbering diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 553362687b6..af77b56bc15 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1651,7 +1651,8 @@ class Propal extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -1891,7 +1892,8 @@ class Propal extends CommonObject $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'propale/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments @@ -2457,7 +2459,8 @@ class Propal extends CommonObject dol_syslog(get_class($this)."::reopen", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { if (!$notrigger) { diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index c75589c1aa0..950d7438f07 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -222,7 +222,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 326299448f7..e18891f3c60 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -123,7 +123,8 @@ $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { $px1->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -158,7 +159,8 @@ $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { $px2->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -202,7 +204,8 @@ $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { $px3->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 929a7a483bb..4f433a28ac4 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -186,7 +186,8 @@ if ($id > 0 || !empty($ref)) { $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; $param = '&id='.$object->id.'&num='.urlencode($numref); - $moreparam = '&num='.urlencode($numref); ; + $moreparam = '&num='.urlencode($numref); + ; $relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($numref)."/"; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 390972912c1..6ec8fed517f 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -182,7 +182,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -1188,8 +1189,8 @@ if ($resql) { // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); - } // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show - else { + } else { + // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show $balance = $objforbalance->previoustotal; } } diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index dda8f13437d..d3ffbb37916 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -72,7 +72,9 @@ $sql .= " ORDER BY c.label"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i = 0; $total = 0; $totalnb = 0; + $i = 0; + $total = 0; + $totalnb = 0; while ($i < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index 48976f8ba25..fb9fead3089 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -126,7 +126,8 @@ $sql .= " ORDER BY rowid"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - $i = 0; $total = 0; + $i = 0; + $total = 0; while ($i < $num) { $objp = $db->fetch_object($result); diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index c2dd1c316a6..6dd588f51e1 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -795,13 +795,17 @@ print ''; // Graphs if ($mode == 'standard') { - $prevyear = $year; $nextyear = $year; - $prevmonth = $month - 1; $nextmonth = $month + 1; + $prevyear = $year; + $nextyear = $year; + $prevmonth = $month - 1; + $nextmonth = $month + 1; if ($prevmonth < 1) { - $prevmonth = 12; $prevyear--; + $prevmonth = 12; + $prevyear--; } if ($nextmonth > 12) { - $nextmonth = 1; $nextyear++; + $nextmonth = 1; + $nextyear++; } // For month @@ -818,7 +822,8 @@ if ($mode == 'standard') { print ''; // For year - $prevyear = $year - 1; $nextyear = $year + 1; + $prevyear = $year - 1; + $nextyear = $year + 1; $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print '
'.$link.'
'; diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 1f22b67ac7c..caca78033d6 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -272,7 +272,8 @@ $sql .= " WHERE rowid=".$rowid; $sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { - $i = 0; $total = 0; + $i = 0; + $total = 0; if ($db->num_rows($result)) { $objp = $db->fetch_object($result); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 6c2e595e3d1..2882a4635fd 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -134,7 +134,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -490,7 +491,10 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print "\n"; -$totalarray = array(); $found = 0; $i = 0; $lastcurrencycode = ''; +$totalarray = array(); +$found = 0; +$i = 0; +$lastcurrencycode = ''; foreach ($accounts as $key => $type) { if ($i >= $limit) { diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index d4bec1929ee..da018dd1f06 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -413,9 +413,11 @@ if ($action == "create" || $action == "start" || $action == 'close') { for ($i = 1; $i <= $numterminals; $i++) { $array[$i] = $i; } - $selectedposnumber = 0; $showempty = 1; + $selectedposnumber = 0; + $showempty = 1; if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') { - $selectedposnumber = 1; $showempty = 0; + $selectedposnumber = 1; + $showempty = 0; } print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); //print ''; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index a301caff80f..6c4141e4b6a 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -140,7 +140,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 8f85f5779a0..f6c58aa858c 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -233,10 +233,9 @@ if ($resql) { } else { if ($conf->global->$var1 == $bankaccount->id) { $cash += $objp->amount; - } - //elseif ($conf->global->$var2 == $bankaccount->id) $bank+=$objp->amount; - //elseif ($conf->global->$var3 == $bankaccount->id) $cheque+=$objp->amount; - else { + // } elseif ($conf->global->$var2 == $bankaccount->id) $bank+=$objp->amount; + //elseif ($conf->global->$var3 == $bankaccount->id) $cheque+=$objp->amount; + } else { $other += $objp->amount; } } diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 7ca8a2d591e..1d294df8cff 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -134,8 +134,8 @@ if ($action == 'validate' && $user->rights->deplacement->creer) { header("Location: index.php"); exit; } -} // Update record -elseif ($action == 'update' && $user->rights->deplacement->creer) { +} elseif ($action == 'update' && $user->rights->deplacement->creer) { + // Update record if (!GETPOST('cancel', 'alpha')) { $result = $object->fetch($id); @@ -159,15 +159,15 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } -} // Set into a project -elseif ($action == 'classin' && $user->rights->deplacement->creer) { +} elseif ($action == 'classin' && $user->rights->deplacement->creer) { + // Set into a project $object->fetch($id); $result = $object->setProject(GETPOST('projectid', 'int')); if ($result < 0) { dol_print_error($db, $object->error); } -} // Set fields -elseif ($action == 'setdated' && $user->rights->deplacement->creer) { +} elseif ($action == 'setdated' && $user->rights->deplacement->creer) { + // Set fields $dated = dol_mktime(GETPOST('datedhour', 'int'), GETPOST('datedmin', 'int'), GETPOST('datedsec', 'int'), GETPOST('datedmonth', 'int'), GETPOST('datedday', 'int'), GETPOST('datedyear', 'int')); $object->fetch($id); $result = $object->setValueFrom('dated', $dated, '', '', 'date', '', $user, 'DEPLACEMENT_MODIFY'); diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 4786e2ea1b5..892b2b86dff 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -110,7 +110,8 @@ $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { $px1->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -140,7 +141,8 @@ $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { $px2->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -184,7 +186,8 @@ $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { $px3->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 988dea7e45e..ee5cd3e00f9 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -133,7 +133,8 @@ $error = 0; */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -279,14 +280,14 @@ if (empty($reshook)) { // Set condition if ($action == 'setconditions' && $user->rights->facture->creer) { $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int')); - } // Set mode - elseif ($action == 'setmode' && $user->rights->facture->creer) { + } elseif ($action == 'setmode' && $user->rights->facture->creer) { + // Set mode $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); - } // Set project - elseif ($action == 'classin' && $user->rights->facture->creer) { + } elseif ($action == 'classin' && $user->rights->facture->creer) { + // Set project $object->setProject(GETPOST('projectid', 'int')); - } // Set bank account - elseif ($action == 'setref' && $user->rights->facture->creer) { + } elseif ($action == 'setref' && $user->rights->facture->creer) { + // Set bank account //var_dump(GETPOST('ref', 'alpha'));exit; $result = $object->setValueFrom('titre', $ref, '', null, 'text', '', $user, 'BILLREC_MODIFY'); if ($result > 0) { @@ -302,32 +303,32 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } // Set bank account - elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { + } elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { + // Set bank account $result = $object->setBankAccount(GETPOST('fk_account', 'int')); - } // Set frequency and unit frequency - elseif ($action == 'setfrequency' && $user->rights->facture->creer) { + } elseif ($action == 'setfrequency' && $user->rights->facture->creer) { + // Set frequency and unit frequency $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); - } // Set next date of execution - elseif ($action == 'setdate_when' && $user->rights->facture->creer) { + } elseif ($action == 'setdate_when' && $user->rights->facture->creer) { + // Set next date of execution $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); if (!empty($date)) { $object->setNextDate($date); } - } // Set max period - elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) { + } elseif ($action == 'setnb_gen_max' && $user->rights->facture->creer) { + // Set max period $object->setMaxPeriod(GETPOST('nb_gen_max', 'int')); - } // Set auto validate - elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { + } elseif ($action == 'setauto_validate' && $user->rights->facture->creer) { + // Set auto validate $object->setAutoValidate(GETPOST('auto_validate', 'int')); - } // Set generate pdf - elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { + } elseif ($action == 'setgenerate_pdf' && $user->rights->facture->creer) { + // Set generate pdf $object->setGeneratepdf(GETPOST('generate_pdf', 'int')); - } // Set model pdf - elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) { + } elseif ($action == 'setmodelpdf' && $user->rights->facture->creer) { + // Set model pdf $object->setModelpdf(GETPOST('modelpdf', 'alpha')); - } // Set status disabled - elseif ($action == 'disable' && $user->rights->facture->creer) { + } elseif ($action == 'disable' && $user->rights->facture->creer) { + // Set status disabled $db->begin(); $object->fetch($id); @@ -343,8 +344,8 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } // Set status enabled - elseif ($action == 'enable' && $user->rights->facture->creer) { + } elseif ($action == 'enable' && $user->rights->facture->creer) { + // Set status enabled $db->begin(); $object->fetch($id); @@ -360,11 +361,11 @@ if (empty($reshook)) { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } - } // Multicurrency Code - elseif ($action == 'setmulticurrencycode' && $usercancreate) { + } elseif ($action == 'setmulticurrencycode' && $usercancreate) { + // Multicurrency Code $result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha')); - } // Multicurrency rate - elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + } elseif ($action == 'setmulticurrencyrate' && $usercancreate) { + // Multicurrency rate $result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int')); } @@ -525,9 +526,9 @@ if (empty($reshook)) { if (!empty($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - elseif ($tmpvat != $tmpprodvat) { + } elseif ($tmpvat != $tmpprodvat) { + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if ($price_base_type != 'HT') { $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); } else { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ba4e4e8e8d1..3598b678711 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -233,8 +233,8 @@ if (empty($reshook)) { $action = ''; } } - } // Delete line - elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { + } elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate) { + // Delete line $object->fetch($id); $object->fetch_thirdparty(); @@ -563,8 +563,8 @@ if (empty($reshook)) { } elseif ($action == 'setref_client' && $usercancreate) { $object->fetch($id); $object->set_ref_client(GETPOST('ref_client')); - } // Classify to validated - elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { + } elseif ($action == 'confirm_valid' && $confirm == 'yes' && $usercanvalidate) { + // Classify to validated $idwarehouse = GETPOST('idwarehouse', 'int'); $object->fetch($id); @@ -2770,15 +2770,15 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - } // bascule du statut d'un contact - elseif ($action == 'swapstatut') { + } elseif ($action == 'swapstatut') { + // bascule du statut d'un contact if ($object->fetch($id)) { $result = $object->swapContactStatus(GETPOST('ligne')); } else { dol_print_error($db); } - } // Efface un contact - elseif ($action == 'deletecontact') { + } elseif ($action == 'deletecontact') { + // Efface un contact $object->fetch($id); $result = $object->delete_contact($lineid); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 983e42f5ff5..4a6d767f6c6 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1972,7 +1972,8 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -2807,7 +2808,8 @@ class Facture extends CommonInvoice $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'facture/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 4795a9b2062..d9c0fa36c9a 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -145,7 +145,8 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -317,7 +318,8 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -355,7 +357,8 @@ class PaymentTerm // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index d45439286fb..e419ed9260b 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -170,7 +170,8 @@ if ($socid > 0) { */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 9f5281dc20b..8f3a54fe4ba 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -248,7 +248,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index b6cf7ec5c06..719c92ca6f0 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -576,7 +576,9 @@ if ($object->id > 0) { print dol_get_fiche_end(); - $numopen = 0; $pending = 0; $numclosed = 0; + $numopen = 0; + $pending = 0; + $numclosed = 0; // How many Direct debit opened requests ? diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 536beff168d..2818fa5f3b9 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -133,7 +133,8 @@ $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { $px1->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -168,7 +169,8 @@ $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { $px2->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; @@ -212,7 +214,8 @@ $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { $px3->SetData($data); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { $legend[] = $i; $i++; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 39faf295c45..46c56f3dca5 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -88,7 +88,8 @@ $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_starty $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear); if (empty($date_start) || empty($date_end)) { // We define date_start and date_end - $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); + $date_start = dol_get_first_day($pastmonthyear, $pastmonth, false); + $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } $name = $langs->trans("SellsJournal"); diff --git a/htdocs/compta/localtax/clients.php b/htdocs/compta/localtax/clients.php index 603e8564927..72155845b0c 100644 --- a/htdocs/compta/localtax/clients.php +++ b/htdocs/compta/localtax/clients.php @@ -51,7 +51,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q"); if (empty($q)) { if (GETPOST("month")) { - $date_start = dol_get_first_day($year_start, GETPOST("month"), false); $date_end = dol_get_last_day($year_start, GETPOST("month"), false); + $date_start = dol_get_first_day($year_start, GETPOST("month"), false); + $date_end = dol_get_last_day($year_start, GETPOST("month"), false); } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { @@ -64,16 +65,20 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -206,7 +211,8 @@ if ($calc == 0 || $calc == 2) { $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { - $total = 0; $totalamount = 0; + $total = 0; + $totalamount = 0; $i = 1; foreach ($coll_list as $coll) { if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { @@ -270,7 +276,8 @@ if ($calc == 0 || $calc == 1) { $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (is_array($coll_list)) { - $total = 0; $totalamount = 0; + $total = 0; + $totalamount = 0; $i = 1; foreach ($coll_list as $coll) { if (($min == 0 || ($min > 0 && $coll->amount > $min)) && ($local == 1 ? $coll->localtax1 : $coll->localtax2) != 0) { diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 051a98a4b3b..86fa3fe52f0 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -50,23 +50,28 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q", "int"); if (empty($q)) { if (GETPOST("month", "int")) { - $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); + $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { $date_start = dol_get_first_day($year_start, $conf->global->SOCIETE_FISCAL_MONTH_START, false); $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; } } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -286,8 +291,12 @@ $tmp = dol_getdate($date_end); $yend = $tmp['year']; $mend = $tmp['mon']; -$total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; -$i = 0; $mcursor = 0; +$total = 0; +$subtotalcoll = 0; +$subtotalpaye = 0; +$subtotal = 0; +$i = 0; +$mcursor = 0; while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $mcursor is to avoid too large loop //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) { @@ -537,7 +546,8 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print " \n"; print "\n"; - $i++; $m++; + $i++; + $m++; if ($i > 2) { print ''; print ''.$langs->trans("SubTotal").':'; @@ -546,7 +556,9 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print ''.price(price2num($subtotal, 'MT')).''; print ' '; $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + $subtotalcoll = 0; + $subtotalpaye = 0; + $subtotal = 0; } } print ''.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).''; diff --git a/htdocs/compta/localtax/quadri_detail.php b/htdocs/compta/localtax/quadri_detail.php index aec90544e09..a2904c861f4 100644 --- a/htdocs/compta/localtax/quadri_detail.php +++ b/htdocs/compta/localtax/quadri_detail.php @@ -61,7 +61,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q", "int"); if (empty($q)) { if (GETPOST("month", "int")) { - $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); + $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { $date_start = dol_get_first_day($year_start, empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START, false); if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { @@ -74,16 +75,20 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 0fcbf6a914a..7f03f4a569c 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -559,12 +559,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $alreadypayedlabel = $langs->trans('Received'); $multicurrencyalreadypayedlabel = $langs->trans('MulticurrencyReceived'); if ($facture->type == 2) { - $alreadypayedlabel = $langs->trans("PaidBack"); $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); + $alreadypayedlabel = $langs->trans("PaidBack"); + $multicurrencyalreadypayedlabel = $langs->trans("MulticurrencyPaidBack"); } $remaindertopay = $langs->trans('RemainderToTake'); $multicurrencyremaindertopay = $langs->trans('MulticurrencyRemainderToTake'); if ($facture->type == 2) { - $remaindertopay = $langs->trans("RemainderToPayBack"); $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); + $remaindertopay = $langs->trans("RemainderToPayBack"); + $multicurrencyremaindertopay = $langs->trans("MulticurrencyRemainderToPayBack"); } $i = 0; diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index c8e6691afc6..e941f532efa 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -235,8 +235,8 @@ if ($action == 'builddoc' && $user->rights->banque->cheque) { header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#builddoc')); exit; } -} // Remove file in doc form -elseif ($action == 'remove_file' && $user->rights->banque->cheque) { +} elseif ($action == 'remove_file' && $user->rights->banque->cheque) { + // Remove file in doc form if ($object->fetch($id) > 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 7db9ff922d9..06d13e78023 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -335,9 +335,8 @@ class Paiement extends CommonObject dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more."); } elseif ($remaintopay) { dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more."); - } - //else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); - else { + // } else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more."); + } else { // If invoice is a down payment, we also convert down payment to discount if ($invoice->type == Facture::TYPE_DEPOSIT) { $amount_ht = $amount_tva = $amount_ttc = array(); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index d9073488567..9c700f509f9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -111,19 +111,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } else { $month_end = $month_start; } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } diff --git a/htdocs/compta/resultat/index.php b/htdocs/compta/resultat/index.php index 3c1d6d3fb0d..228269d135e 100644 --- a/htdocs/compta/resultat/index.php +++ b/htdocs/compta/resultat/index.php @@ -79,19 +79,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } else { $month_end = $month_start; } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 75d73eeca31..df3a82a4b7f 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -91,19 +91,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } else { $month_end = $month_start; } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 3c2b26a83d8..18c8e9aa59d 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -612,7 +612,8 @@ if ($id > 0) { $totalpaye = 0; $num = $db->num_rows($resql); - $i = 0; $total = 0; + $i = 0; + $total = 0; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index f718a9a48b7..91a0708c361 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -356,7 +356,8 @@ class ChargeSociales extends CommonObject $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4fda644e1c0..bb9a48b4c4c 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -369,7 +369,8 @@ class PaymentSocialContribution extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -420,7 +421,8 @@ class PaymentSocialContribution extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } } diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 1f4de217bac..e2047d00738 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -74,19 +74,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $year_end++; } } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -175,17 +180,21 @@ if ($modetax == 2) { $calcmode .= '
('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -$prevyear = $year_start; $prevquarter = $q; +$prevyear = $year_start; +$prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { - $prevquarter = 4; $prevyear--; + $prevquarter = 4; + $prevyear--; } -$nextyear = $year_start; $nextquarter = $q; +$nextyear = $year_start; +$nextquarter = $q; if ($nextquarter < 4) { $nextquarter++; } else { - $nextquarter = 1; $nextyear++; + $nextquarter = 1; + $nextyear++; } $description .= $fsearch; $builddate = dol_now(); diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index eb678900112..c6c0e8e0816 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -119,19 +119,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $year_end++; } } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } else { diff --git a/htdocs/compta/stats/cabyuser.php b/htdocs/compta/stats/cabyuser.php index 494786bd8a2..62e6fb3135d 100644 --- a/htdocs/compta/stats/cabyuser.php +++ b/htdocs/compta/stats/cabyuser.php @@ -100,19 +100,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $year_end++; } } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } else { // TODO We define q diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index 829e196a82e..c8c13ca8b27 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -120,19 +120,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $year_end++; } } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } else { // TODO We define q diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index eb039a63f92..083230da668 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -73,19 +73,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } else { $month_end = $month_start; } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } diff --git a/htdocs/compta/stats/supplier_turnover.php b/htdocs/compta/stats/supplier_turnover.php index a6adf2a2440..b199dcbeb9c 100644 --- a/htdocs/compta/stats/supplier_turnover.php +++ b/htdocs/compta/stats/supplier_turnover.php @@ -69,19 +69,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } else { $month_end = $month_start; } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } diff --git a/htdocs/compta/stats/supplier_turnover_by_prodserv.php b/htdocs/compta/stats/supplier_turnover_by_prodserv.php index 553bd62899e..bdf4e5e0f85 100644 --- a/htdocs/compta/stats/supplier_turnover_by_prodserv.php +++ b/htdocs/compta/stats/supplier_turnover_by_prodserv.php @@ -114,19 +114,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $year_end++; } } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } else { diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 0e653d542f6..fbfb0994e4a 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -114,19 +114,24 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $year_end++; } } - $date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false); + $date_start = dol_get_first_day($year_start, $month_start, false); + $date_end = dol_get_last_day($year_end, $month_end, false); } if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } else { // TODO We define q diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 87805ebf947..4421178a507 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -630,7 +630,8 @@ if ($id) { $totalpaye = 0; $num = $db->num_rows($resql); - $i = 0; $total = 0; + $i = 0; + $total = 0; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'; diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index ff1c8b46040..4f816164db0 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -372,7 +372,8 @@ class PaymentVAT extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -423,7 +424,8 @@ class PaymentVAT extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } } diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index e0801ba1db2..7ec5ad5b4f1 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -66,7 +66,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q", "int"); if (empty($q)) { if (GETPOST("month", 'int')) { - $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); + $date_start = dol_get_first_day($year_start, GETPOST("month", 'int'), false); + $date_end = dol_get_last_day($year_start, GETPOST("month", 'int'), false); } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); @@ -90,16 +91,20 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index c831d5fe61c..2602d00a216 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -59,7 +59,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q", "int"); if (empty($q)) { if (GETPOST("month", "int")) { - $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); + $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); @@ -83,16 +84,20 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -301,8 +306,12 @@ $tmp = dol_getdate($date_end); $yend = $tmp['year']; $mend = $tmp['mon']; //var_dump($m); -$total = 0; $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; -$i = 0; $mcursor = 0; +$total = 0; +$subtotalcoll = 0; +$subtotalpaye = 0; +$subtotal = 0; +$i = 0; +$mcursor = 0; while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $mcursor is to avoid too large loop //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); @@ -535,7 +544,8 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print "\n"; print "\n"; - $i++; $m++; + $i++; + $m++; if ($i > 2) { print ''; print ''; @@ -544,7 +554,9 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print ''; print ''; $i = 0; - $subtotalcoll = 0; $subtotalpaye = 0; $subtotal = 0; + $subtotalcoll = 0; + $subtotalpaye = 0; + $subtotal = 0; } } print ''; diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index 04f90ba02f9..788067ec696 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -66,7 +66,8 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e $q = GETPOST("q", "int"); if (empty($q)) { if (GETPOST("month", "int")) { - $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); + $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); + $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); @@ -90,16 +91,20 @@ if (empty($date_start) || empty($date_end)) { // We define date_start and date_e } } else { if ($q == 1) { - $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); + $date_start = dol_get_first_day($year_start, 1, false); + $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { - $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); + $date_start = dol_get_first_day($year_start, 4, false); + $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { - $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); + $date_start = dol_get_first_day($year_start, 7, false); + $date_end = dol_get_last_day($year_start, 9, false); } if ($q == 4) { - $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); + $date_start = dol_get_first_day($year_start, 10, false); + $date_end = dol_get_last_day($year_start, 12, false); } } } @@ -179,7 +184,8 @@ if ($modetax == 2) { $calcmode .= ' ('.$langs->trans("TaxModuleSetupToModifyRules", DOL_URL_ROOT.'/admin/taxes.php').')'; // Set period $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0); -$prevyear = $year_start; $prevquarter = $q; +$prevyear = $year_start; +$prevquarter = $q; if ($prevquarter > 1) { $prevquarter--; } else { diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 1bea255bda2..d05985b1aa3 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -108,7 +108,9 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST $trackid = GETPOST('trackid', 'aZ09'); } - $subject = ''; $actionmsg = ''; $actionmsg2 = ''; + $subject = ''; + $actionmsg = ''; + $actionmsg2 = ''; $langs->load('mails'); diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index e56c4a95dcd..5f0d6823978 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -84,7 +84,8 @@ if ($action == 'setModuleOptions') { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { if (empty($nomessageinsetmoduleoptions)) { diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 43438c66dc4..cf619f70de6 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -284,9 +284,8 @@ if ($type == 'directory') { $perm = $user->rights->ecm->upload; $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); - } - // Manual list - else { + } else { + // Manual list if ($module == 'medias') { /* $_POST is array like diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index 52182e2205d..432a0e628db 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -237,17 +237,14 @@ if (empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_ECM_DISABLE_ // If directory is son of expanded directory, we show line if (in_array($val['id_mere'], $expandedsectionarray)) { $showline = 4; - } - // If directory is brother of selected directory, we show line - elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) { + } elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) { + // If directory is brother of selected directory, we show line $showline = 3; - } - // If directory is parent of selected directory or is selected directory, we show line - elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) { + } elseif (preg_match('/'.$val['fullpath'].'_/i', $fullpathselected.'_')) { + // If directory is parent of selected directory or is selected directory, we show line $showline = 2; - } - // If we are level one we show line - elseif ($val['level'] < 2) { + } elseif ($val['level'] < 2) { + // If we are level one we show line $showline = 1; } diff --git a/htdocs/core/ajax/pingresult.php b/htdocs/core/ajax/pingresult.php index 990c3f6f858..4398a3e8d4c 100644 --- a/htdocs/core/ajax/pingresult.php +++ b/htdocs/core/ajax/pingresult.php @@ -71,9 +71,8 @@ if ($action == 'firstpingok') { dolibarr_set_const($db, 'MAIN_FIRST_PING_OK_ID', $hash_unique_id); print 'First ping OK saved for entity '.$conf->entity; -} -// If ko -elseif ($action == 'firstpingko') { +} elseif ($action == 'firstpingko') { + // If ko // Note: pings are by installation, done on entity 1. dolibarr_set_const($db, 'MAIN_LAST_PING_KO_DATE', dol_print_date($now, 'dayhourlog'), 'gmt'); // erase last value print 'First ping KO saved for entity '.$conf->entity; diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index ab39a14e2cd..ca77fec51e4 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -122,7 +122,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); } if (empty($shownb) && empty($showtot)) { - $shownb = 1; $showtot = 1; + $shownb = 1; + $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) { @@ -154,7 +155,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $px1->SetData($data1); unset($data1); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); @@ -197,7 +199,8 @@ class box_graph_invoices_permonth extends ModeleBoxes $px2->SetData($data2); unset($data2); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 75b58a28de1..21931b1a071 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -119,7 +119,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); } if (empty($shownb) && empty($showtot)) { - $shownb = 1; $showtot = 1; + $shownb = 1; + $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($year)) { @@ -197,7 +198,8 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px2->SetData($data2); unset($data2); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 3fafa464993..ec11d07a28f 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -122,7 +122,8 @@ class box_graph_orders_permonth extends ModeleBoxes $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); } if (empty($shownb) && empty($showtot)) { - $shownb = 1; $showtot = 1; + $shownb = 1; + $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) { @@ -193,7 +194,8 @@ class box_graph_orders_permonth extends ModeleBoxes if (!$mesg) { $px2->SetData($data2); unset($data2); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 419e3afba83..a6dfead80f0 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -121,7 +121,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); } if (empty($shownb) && empty($showtot)) { - $shownb = 1; $showtot = 1; + $shownb = 1; + $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) { @@ -192,7 +193,8 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if (!$mesg) { $px2->SetData($data2); unset($data2); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 91a5f598347..5c3e55fcc2f 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -101,7 +101,9 @@ class box_graph_product_distribution extends ModeleBoxes $showordernb = (!empty($tmparray['showordernb']) ? $tmparray['showordernb'] : ''); } if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { - $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; + $showpropalnb = 1; + $showinvoicenb = 1; + $showordernb = 1; } if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) { $showinvoicenb = 0; @@ -154,7 +156,8 @@ class box_graph_product_distribution extends ModeleBoxes $langs->load("propal"); include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; - $showpointvalue = 1; $nocolor = 0; + $showpointvalue = 1; + $nocolor = 0; $stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0)); $data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); if (empty($data2)) { @@ -169,7 +172,8 @@ class box_graph_product_distribution extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); if (!$mesg) { - $i = 0; $legend = array(); + $i = 0; + $legend = array(); foreach ($data2 as $key => $val) { $data2[$key][0] = dol_trunc($data2[$key][0], 32); @@ -210,7 +214,8 @@ class box_graph_product_distribution extends ModeleBoxes $langs->load("orders"); include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $showpointvalue = 1; $nocolor = 0; + $showpointvalue = 1; + $nocolor = 0; $mode = 'customer'; $stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); $data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); @@ -226,7 +231,8 @@ class box_graph_product_distribution extends ModeleBoxes $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); if (!$mesg) { - $i = 0; $legend = array(); + $i = 0; + $legend = array(); foreach ($data3 as $key => $val) { $data3[$key][0] = dol_trunc($data3[$key][0], 32); @@ -268,7 +274,8 @@ class box_graph_product_distribution extends ModeleBoxes $langs->load("bills"); include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $showpointvalue = 1; $nocolor = 0; + $showpointvalue = 1; + $nocolor = 0; $mode = 'customer'; $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); @@ -284,7 +291,8 @@ class box_graph_product_distribution extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); if (!$mesg) { - $i = 0; $legend = array(); + $i = 0; + $legend = array(); foreach ($data1 as $key => $val) { $data1[$key][0] = dol_trunc($data1[$key][0], 32); diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 8193e81d060..f8028e3bdb8 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -122,7 +122,8 @@ class box_graph_propales_permonth extends ModeleBoxes $showtot = (!empty($tmparray['showtot']) ? $tmparray['showtot'] : ''); } if (empty($shownb) && empty($showtot)) { - $shownb = 1; $showtot = 1; + $shownb = 1; + $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) { @@ -149,7 +150,8 @@ class box_graph_propales_permonth extends ModeleBoxes $px1->SetType($datatype1); $px1->SetData($data1); unset($data1); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); @@ -195,7 +197,8 @@ class box_graph_propales_permonth extends ModeleBoxes $px2->SetType($datatype2); $px2->SetData($data2); unset($data2); - $i = $startyear; $legend = array(); + $i = $startyear; + $legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 0d235a21798..863bb9a6794 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -578,7 +578,8 @@ class CMailFile $hookmanager = new HookManager($db); $hookmanager->initHooks(array('mail')); - $parameters = array(); $action = ''; + $parameters = array(); + $action = ''; $reshook = $hookmanager->executeHooks('sendMail', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = "Error in hook maildao sendMail ".$reshook; @@ -815,7 +816,8 @@ class CMailFile $this->smtps->setHost($server); $this->smtps->setPort($port); // 25, 465...; - $loginid = ''; $loginpass = ''; + $loginid = ''; + $loginpass = ''; if (!empty($conf->global->$keyforsmtpid)) { $loginid = $conf->global->$keyforsmtpid; $this->smtps->setID($loginid); @@ -946,7 +948,8 @@ class CMailFile return 'Bad value for sendmode'; } - $parameters = array(); $action = ''; + $parameters = array(); + $action = ''; $reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = "Error in hook maildao sendMailAfter ".$reshook; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 65cf7091d39..ca221a366ed 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -151,7 +151,8 @@ class CSMSFile } } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) { // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module' $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); - $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); + $classfile = $tmp[0]; + $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); try { $classname = ucfirst($classfile); diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 1c886a526ed..ad088002caf 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -130,7 +130,8 @@ class Ccountry // extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -246,7 +247,8 @@ class Ccountry // extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -284,7 +286,8 @@ class Ccountry // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 3f9ca42e136..a8da44b0d79 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -141,7 +141,8 @@ class Comment extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -268,7 +269,8 @@ class Comment extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -318,7 +320,8 @@ class Comment extends CommonObject $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index fc4e2058273..d951807976f 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -632,9 +632,8 @@ abstract class CommonInvoice extends CommonObject $datelim = $this->date + ($cdr_nbjour * 3600 * 24); $datelim += ($cdr_decalage * 3600 * 24); - } - // 1 : application of the "end of the month" rule - elseif ($cdr_type == 1) { + } elseif ($cdr_type == 1) { + // 1 : application of the "end of the month" rule $datelim = $this->date + ($cdr_nbjour * 3600 * 24); $mois = date('m', $datelim); @@ -650,9 +649,8 @@ abstract class CommonInvoice extends CommonObject $datelim -= (3600 * 24); $datelim += ($cdr_decalage * 3600 * 24); - } - // 2 : application of the rule, the N of the current or next month - elseif ($cdr_type == 2 && !empty($cdr_decalage)) { + } elseif ($cdr_type == 2 && !empty($cdr_decalage)) { + // 2 : application of the rule, the N of the current or next month include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $datelim = $this->date + ($cdr_nbjour * 3600 * 24); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1500595d74e..3140b06b23b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -762,7 +762,8 @@ abstract class CommonObject $out .= img_picto($langs->trans("Address"), 'map-marker-alt'); $out .= ' '; } - $out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++; + $out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); + $outdone++; $outdone++; // List of extra languages @@ -1181,7 +1182,8 @@ abstract class CommonObject if (!$notrigger) { $result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); if ($result < 0) { - $this->db->rollback(); return -1; + $this->db->rollback(); + return -1; } } @@ -3154,9 +3156,8 @@ abstract class CommonObject return $this->getRangOfLine($fk_parent_line); } } - } - // If not, search the last rang of element - else { + } else { + // If not, search the last rang of element $sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql .= ' WHERE '.$this->fk_element.' = '.$this->id; @@ -3745,42 +3746,60 @@ abstract class CommonObject if ($objecttype == 'facture') { $classpath = 'compta/facture/class'; } elseif ($objecttype == 'facturerec') { - $classpath = 'compta/facture/class'; $module = 'facture'; + $classpath = 'compta/facture/class'; + $module = 'facture'; } elseif ($objecttype == 'propal') { $classpath = 'comm/propal/class'; } elseif ($objecttype == 'supplier_proposal') { $classpath = 'supplier_proposal/class'; } elseif ($objecttype == 'shipping') { - $classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon'; + $classpath = 'expedition/class'; + $subelement = 'expedition'; + $module = 'expedition_bon'; } elseif ($objecttype == 'delivery') { - $classpath = 'delivery/class'; $subelement = 'delivery'; $module = 'delivery_note'; + $classpath = 'delivery/class'; + $subelement = 'delivery'; + $module = 'delivery_note'; } elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') { - $classpath = 'fourn/class'; $module = 'fournisseur'; + $classpath = 'fourn/class'; + $module = 'fournisseur'; } elseif ($objecttype == 'fichinter') { - $classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter'; + $classpath = 'fichinter/class'; + $subelement = 'fichinter'; + $module = 'ficheinter'; } elseif ($objecttype == 'subscription') { - $classpath = 'adherents/class'; $module = 'adherent'; + $classpath = 'adherents/class'; + $module = 'adherent'; } elseif ($objecttype == 'contact') { $module = 'societe'; } // Set classfile - $classfile = strtolower($subelement); $classname = ucfirst($subelement); + $classfile = strtolower($subelement); + $classname = ucfirst($subelement); if ($objecttype == 'order') { - $classfile = 'commande'; $classname = 'Commande'; + $classfile = 'commande'; + $classname = 'Commande'; } elseif ($objecttype == 'invoice_supplier') { - $classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur'; + $classfile = 'fournisseur.facture'; + $classname = 'FactureFournisseur'; } elseif ($objecttype == 'order_supplier') { - $classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur'; + $classfile = 'fournisseur.commande'; + $classname = 'CommandeFournisseur'; } elseif ($objecttype == 'supplier_proposal') { - $classfile = 'supplier_proposal'; $classname = 'SupplierProposal'; + $classfile = 'supplier_proposal'; + $classname = 'SupplierProposal'; } elseif ($objecttype == 'facturerec') { - $classfile = 'facture-rec'; $classname = 'FactureRec'; + $classfile = 'facture-rec'; + $classname = 'FactureRec'; } elseif ($objecttype == 'subscription') { - $classfile = 'subscription'; $classname = 'Subscription'; + $classfile = 'subscription'; + $classname = 'Subscription'; } elseif ($objecttype == 'project' || $objecttype == 'projet') { - $classpath = 'projet/class'; $classfile = 'project'; $classname = 'Project'; + $classpath = 'projet/class'; + $classfile = 'project'; + $classname = 'Project'; } // Here $module, $classfile and $classname are set @@ -4618,7 +4637,8 @@ abstract class CommonObject $element = $this->element; - $text = ''; $description = ''; + $text = ''; + $description = ''; // Line in view mode if ($action != 'editline' || $selected != $line->id) { @@ -4985,7 +5005,8 @@ abstract class CommonObject if (!$notrigger) { $result = $this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user); if ($result < 0) { - $this->db->rollback(); return -1; + $this->db->rollback(); + return -1; } } $this->db->commit(); @@ -5106,7 +5127,8 @@ abstract class CommonObject $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (is_dir($tmpdir)) { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 19555adf3fb..b73f7ae3257 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -196,13 +196,13 @@ class Conf $this->modules_parts[$partname] = array(); } $this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array - } - // If this is constant for all generic part activated by a module. It initializes - // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'], - // modules_parts['models'], modules_parts['theme'] - // modules_parts['sms'], - // modules_parts['css'], ... - elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) { + } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) { + // If this is constant for all generic part activated by a module. It initializes + // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'], + // modules_parts['models'], modules_parts['theme'] + // modules_parts['sms'], + // modules_parts['css'], ... + $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) { @@ -221,9 +221,8 @@ class Conf $value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe } $this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array - } - // If this is a module constant (must be at end) - elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { + } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) { + // If this is a module constant (must be at end) $modulename = strtolower($reg[1]); if ($modulename == 'propale') { $modulename = 'propal'; diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index acddb09d547..66ee803d41a 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -123,7 +123,8 @@ class Cstate // extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -229,7 +230,8 @@ class Cstate // extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -266,7 +268,8 @@ class Cstate // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index ff2bcc58f40..01a6eb5e697 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -130,7 +130,8 @@ class Ctypent // extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -244,7 +245,8 @@ class Ctypent // extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -282,7 +284,8 @@ class Ctypent // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 757e3fb0e66..e55d227de0e 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -133,7 +133,8 @@ class CUnits // extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } if (!$error) { @@ -351,7 +352,8 @@ class CUnits // extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback @@ -389,7 +391,8 @@ class CUnits // extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->errors[] = "Error ".$this->db->lasterror(); + $error++; + $this->errors[] = "Error ".$this->db->lasterror(); } // Commit or rollback diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 0eecbbf6d36..2427b2da1e4 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -61,7 +61,8 @@ class DolGeoIP require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar'; } } else { - print 'ErrorBadParameterInConstructor'; return 0; + print 'ErrorBadParameterInConstructor'; + return 0; } // Here, function exists (embedded into PHP or exists because we made include) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 607993dc325..3672f7faa07 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -908,9 +908,8 @@ class DolGraph $this->stringtoshow .= 'legend: {show: ' . ($showlegend ? 'true' : 'false') . ', position: \'ne\' } }); }' . "\n"; - } - // Other cases, graph of type 'bars', 'lines' - else { + } else { + // Other cases, graph of type 'bars', 'lines' // Add code to support tooltips // TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes $this->stringtoshow .= ' @@ -1262,9 +1261,8 @@ class DolGraph $this->stringtoshow .= ']' . "\n"; $this->stringtoshow .= '}' . "\n"; $this->stringtoshow .= '});' . "\n"; - } - // Other cases, graph of type 'bars', 'lines', 'linesnopoint' - else { + } else { + // Other cases, graph of type 'bars', 'lines', 'linesnopoint' $type = 'bar'; if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') { diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index 6f674c0b600..980c8c53dde 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -147,7 +147,8 @@ class Events // extends CommonObject // Check parameters if (empty($this->description)) { - $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; + $this->error = 'ErrorBadValueForParameterCreateEventDesc'; + return -1; } // Insert request diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 35747920ec5..5a5b06054ff 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -251,7 +251,8 @@ class ExtraFields } if ($type == 'separate') { - $unique = 0; $required = 0; + $unique = 0; + $required = 0; } // Force unique and not required if this is a separator field to avoid troubles. if ($elementtype == 'thirdparty') { $elementtype = 'societe'; diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 21d948b2160..45bc622b9db 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -70,7 +70,8 @@ class FileUpload $element = $pathname = 'projet'; $dir_output = $conf->$element->dir_output; } elseif ($element == 'project_task') { - $pathname = 'projet'; $filename = 'task'; + $pathname = 'projet'; + $filename = 'task'; $dir_output = $conf->projet->dir_output; $parentForeignKey = 'fk_project'; $parentClass = 'Project'; @@ -80,20 +81,24 @@ class FileUpload $element = 'ficheinter'; $dir_output = $conf->$element->dir_output; } elseif ($element == 'order_supplier') { - $pathname = 'fourn'; $filename = 'fournisseur.commande'; + $pathname = 'fourn'; + $filename = 'fournisseur.commande'; $dir_output = $conf->fournisseur->commande->dir_output; } elseif ($element == 'invoice_supplier') { - $pathname = 'fourn'; $filename = 'fournisseur.facture'; + $pathname = 'fourn'; + $filename = 'fournisseur.facture'; $dir_output = $conf->fournisseur->facture->dir_output; } elseif ($element == 'product') { $dir_output = $conf->product->multidir_output[$conf->entity]; } elseif ($element == 'productbatch') { $dir_output = $conf->productbatch->multidir_output[$conf->entity]; } elseif ($element == 'action') { - $pathname = 'comm/action'; $filename = 'actioncomm'; + $pathname = 'comm/action'; + $filename = 'actioncomm'; $dir_output = $conf->agenda->dir_output; } elseif ($element == 'chargesociales') { - $pathname = 'compta/sociales'; $filename = 'chargesociales'; + $pathname = 'compta/sociales'; + $filename = 'chargesociales'; $dir_output = $conf->tax->dir_output; } else { $dir_output = $conf->$element->dir_output; diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 8b211a34864..9d3ea8f39d6 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -228,11 +228,14 @@ class HookManager } // Init return properties - $this->resPrint = ''; $this->resArray = array(); $this->resNbOfHooks = 0; + $this->resPrint = ''; + $this->resArray = array(); + $this->resNbOfHooks = 0; // Loop on each hook to qualify modules that have declared context $modulealreadyexecuted = array(); - $resaction = 0; $error = 0; + $resaction = 0; + $error = 0; foreach ($this->hooks as $context => $modules) { // $this->hooks is an array with context as key and value is an array of modules that handle this context if (!empty($modules)) { foreach ($modules as $module => $actionclassinstance) { @@ -265,7 +268,8 @@ class HookManager $resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example) if ($resaction < 0 || !empty($actionclassinstance->error) || (!empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) { $error++; - $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); + $this->error = $actionclassinstance->error; + $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); } @@ -275,9 +279,8 @@ class HookManager if (!empty($actionclassinstance->resprints)) { $this->resPrint .= $actionclassinstance->resprints; } - } - // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) - else { + } else { + // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...) // TODO. this test should be done into the method of hook by returning nothing if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) { continue; @@ -294,14 +297,16 @@ class HookManager } if (is_numeric($resaction) && $resaction < 0) { $error++; - $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); + $this->error = $actionclassinstance->error; + $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors); dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR); } // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string if (!is_array($resaction) && !is_numeric($resaction)) { dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR); if (empty($actionclassinstance->resprints)) { - $this->resPrint .= $resaction; $resaction = 0; + $this->resPrint .= $resaction; + $resaction = 0; } } } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5f2497a5827..42be90ac4e9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -488,7 +488,8 @@ class Form $out .= ''."\n"; // Use for timestamp format } elseif (preg_match('/^(select|autocomplete)/', $inputType)) { $tmp = explode(':', $inputType); - $inputType = $tmp[0]; $loadmethod = $tmp[1]; + $inputType = $tmp[0]; + $loadmethod = $tmp[1]; if (!empty($tmp[2])) { $savemethod = $tmp[2]; } @@ -502,7 +503,8 @@ class Form $cols = (empty($tmp[2]) ? '80' : $tmp[2]); } elseif (preg_match('/^ckeditor/', $inputType)) { $tmp = explode(':', $inputType); - $inputType = $tmp[0]; $toolbar = $tmp[1]; + $inputType = $tmp[0]; + $toolbar = $tmp[1]; if (!empty($tmp[2])) { $width = $tmp[2]; } @@ -594,15 +596,18 @@ class Form $extrastyle = ''; if ($direction < 0) { - $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-left: 3px !important;'; + $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); + $extrastyle = 'padding: 0px; padding-left: 3px !important;'; } if ($direction > 0) { - $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-right: 3px !important;'; + $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); + $extrastyle = 'padding: 0px; padding-right: 3px !important;'; } $classfortooltip = 'classfortooltip'; - $s = ''; $textfordialog = ''; + $s = ''; + $textfordialog = ''; if ($tooltiptrigger == '') { $htmltext = str_replace('"', '"', $htmltext); @@ -2084,7 +2089,8 @@ class Form if ($nbassignetouser) { $out .= '
    '; } - $i = 0; $ownerid = 0; + $i = 0; + $ownerid = 0; foreach ($assignedtouser as $key => $value) { if ($value['id'] == $ownerid) { continue; @@ -2094,7 +2100,8 @@ class Form $userstatic->fetch($value['id']); $out .= $userstatic->getNomUrl(-1); if ($i == 0) { - $ownerid = $value['id']; $out .= ' ('.$langs->trans("Owner").')'; + $ownerid = $value['id']; + $out .= ' ('.$langs->trans("Owner").')'; } if ($nbassignetouser > 1 && $action != 'view') { $out .= ' '; @@ -5811,7 +5818,8 @@ class Form } // Disabled if seller is not subject to VAT - $disabled = false; $title = ''; + $disabled = false; + $title = ''; if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") { // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses instead // of using supplier invoices (this is a very bad idea !) @@ -5991,10 +5999,12 @@ class Form $stepminutes = 1; } if ($empty == 1) { - $emptydate = 1; $emptyhours = 1; + $emptydate = 1; + $emptyhours = 1; } if ($empty == 2) { - $emptydate = 0; $emptyhours = 1; + $emptydate = 0; + $emptyhours = 1; } $orig_set_time = $set_time; @@ -6149,9 +6159,8 @@ class Form } else { $retstring .= "Bad value of MAIN_POPUP_CALENDAR"; } - } - // Show date with combo selects - else { + } else { + // Show date with combo selects // Day $retstring .= ''; @@ -6448,7 +6457,8 @@ class Form $retstring = ''; - $hourSelected = 0; $minSelected = 0; + $hourSelected = 0; + $minSelected = 0; // Hours if ($iSecond != '') { @@ -6914,7 +6924,8 @@ class Form $style = empty($tmpvalue['css']) ? ' class="'.$tmpvalue['css'].'"' : ''; } else { $value = $tmpvalue; - $disabled = ''; $style = ''; + $disabled = ''; + $style = ''; } if (!empty($disablebademail)) { if (($disablebademail == 1 && !preg_match('/<.+@.+>/', $value)) @@ -7720,9 +7731,8 @@ class Form //$linktoelem.=($linktoelem?'   ':''); if ($num > 0) { $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' ('.$num.')
  • '; - } - //else $linktoelem.=$langs->trans($possiblelink['label']); - else { + // } else $linktoelem.=$langs->trans($possiblelink['label']); + } else { $linktoelemlist .= '
  • '.$langs->trans($possiblelink['label']).' (0)
  • '; } } @@ -7777,7 +7787,8 @@ class Form { global $langs; - $yes = "yes"; $no = "no"; + $yes = "yes"; + $no = "no"; if ($option) { $yes = "1"; $no = "0"; @@ -8093,7 +8104,13 @@ class Form $entity = (!empty($object->entity) ? $object->entity : $conf->entity); $id = (!empty($object->id) ? $object->id : $object->rowid); - $ret = ''; $dir = ''; $file = ''; $originalfile = ''; $altfile = ''; $email = ''; $capture = ''; + $ret = ''; + $dir = ''; + $file = ''; + $originalfile = ''; + $altfile = ''; + $email = ''; + $capture = ''; if ($modulepart == 'societe') { $dir = $conf->societe->multidir_output[$entity]; if (!empty($object->logo)) { diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 7d909440ecc..f1b80843488 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -227,7 +227,8 @@ class FormActions print ''."\n"; print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter); - $page = 0; $param = ''; + $page = 0; + $param = ''; print '
    '; print '
 
'.$langs->trans("SubTotal").':'.price(price2num($subtotal, 'MT')).' 
'.$langs->trans("TotalToPay").':'.price(price2num($total, 'MT')).'
'; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index e7d8d94b6d2..34c522745d9 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -547,7 +547,8 @@ class FormCompany extends Form $num = $this->db->num_rows($resql); if ($num) { $i = 0; - $country = ''; $arraydata = array(); + $country = ''; + $arraydata = array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); @@ -622,7 +623,8 @@ class FormCompany extends Form // Use Ajax search $minLength = (is_numeric($conf->global->COMPANY_USE_SEARCH_TO_SELECT) ? $conf->global->COMPANY_USE_SEARCH_TO_SELECT : 2); - $socid = 0; $name = ''; + $socid = 0; + $name = ''; if ($selected > 0) { $tmpthirdparty = new Societe($this->db); $result = $tmpthirdparty->fetch($selected); @@ -937,7 +939,8 @@ class FormCompany extends Form $maxlength = $formlength; if (empty($formlength)) { - $formlength = 24; $maxlength = 128; + $formlength = 24; + $maxlength = 128; } $out = ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index d5586a2c9d2..21327a9a37e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -659,9 +659,8 @@ class FormFile $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); if (file_exists($file)) { $res = include_once $file; - } - // For normalized external modules. - else { + } else { + // For normalized external modules. $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); $res = include_once $file; } @@ -699,7 +698,8 @@ class FormFile $out .= ''; $addcolumforpicto = ($delallowed || $printer || $morepicto); - $colspan = (3 + ($addcolumforpicto ? 1 : 0)); $colspanmore = 0; + $colspan = (3 + ($addcolumforpicto ? 1 : 0)); + $colspanmore = 0; $out .= ''; print ''."\n"; print ''; -$result=$object->fetchAll( $sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); +$result=$object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); if (!is_array($result) && $result<0) { - - setEventMessages($object->error, $object->errors,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } elseif (count($result)>0) { - foreach($result as $key=>$defaultvalue) { + foreach ($result as $key=>$defaultvalue) { print "\n"; print ''; @@ -383,10 +380,10 @@ if (!is_array($result) && $result<0) { if ($mode != 'focus' && $mode != 'mandatory') { print ''; diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index 2f70dda34e5..4c399bbd5e5 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -148,23 +148,17 @@ class DefaultValues extends CommonObject if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0; // Unset fields that are disabled - foreach ($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { unset($this->fields[$key]); } } // Translate some data of arrayofkeyval - if (is_object($langs)) - { - foreach ($this->fields as $key => $val) - { - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) - { - foreach ($val['arrayofkeyval'] as $key2 => $val2) - { + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } @@ -274,12 +268,12 @@ class DefaultValues extends CommonObject $sqlwhere[] = $key.'='.$value; } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; - } elseif ($key == 't.page' || $key == 't.param' || $key == 't.type'){ + } elseif ($key == 't.page' || $key == 't.param' || $key == 't.type') { $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; } elseif ($key == 'customsql') { $sqlwhere[] = $value; } elseif (is_array($value)) { - $sqlwhere[] = $key.' IN ('.implode(',',$value).')'; + $sqlwhere[] = $key.' IN ('.implode(',', $value).')'; } else { $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\''; } @@ -300,8 +294,7 @@ class DefaultValues extends CommonObject if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) - { + while ($i < ($limit ? min($limit, $num) : $num)) { $obj = $this->db->fetch_object($resql); $record = new self($this->db); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index bacbfa32f67..6e79e5763b6 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -612,19 +612,18 @@ class User extends CommonObject { global $conf; if (!empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { - // Load user->default_values for user. TODO Save this in memcached ? require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php'; $defaultValues = new DefaultValues($this->db); - $result = $defaultValues->fetchAll('','',0,0,array('t.user_id'=>array(0,$this->id), 'entity'=>array($this->entity,$conf->entity))); + $result = $defaultValues->fetchAll('', '', 0, 0, array('t.user_id'=>array(0,$this->id), 'entity'=>array($this->entity,$conf->entity))); if (!is_array($result) && $result<0) { - setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); dol_print_error($this->db); return -1; - } elseif(count($result)>0) { - foreach($result as $defval) { + } elseif (count($result)>0) { + foreach ($result as $defval) { if (!empty($defval->page) && !empty($defval->type) && !empty($defval->param)) { $pagewithoutquerystring = $defval->page; $pagequeries = ''; From a5974bcf57447f94ee4c34e240b564166a14599a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Mar 2021 21:10:06 +0100 Subject: [PATCH 28/70] fix merge --- htdocs/public/payment/newpayment.php | 136 +++------------------------ 1 file changed, 15 insertions(+), 121 deletions(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 85ad11bb74b..1fa873d3fc8 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -914,13 +914,9 @@ if ($source == 'order') { if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment $amount = $order->total_ttc; -<<<<<<< HEAD - if (GETPOST("amount", 'int')) { - $amount = GETPOST("amount", 'int'); + if (GETPOST("amount", 'alpha')) { + $amount = GETPOST("amount", 'alpha'); } -======= - if (GETPOST("amount", 'alpha')) $amount = GETPOST("amount", 'alpha'); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git $amount = price2num($amount); } @@ -969,14 +965,8 @@ if ($source == 'order') { print ' ('.$langs->trans("ToComplete").')'; } print ' - - + diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index a4c21ddcc2d..0010b87ff90 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -94,14 +94,14 @@ if (empty($conf) || !is_object($conf)) { - - + From 13c9a961072564bb149ac632e6a16356d95dc0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Mar 2021 21:44:59 +0100 Subject: [PATCH 30/70] fix phpcs --- htdocs/compta/bank/various_payment/card.php | 3 +-- htdocs/don/card.php | 3 +-- test/phpunit/DateLibTzFranceTest.php | 6 +++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 27dfe941f88..d19ccbed908 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -341,8 +341,7 @@ foreach ($bankcateg->fetchAll() as $bankcategory) { /* ************************************************************************** */ if ($action == 'create') { // Update fields properties in realtime - if (!empty($conf->use_javascript_ajax)) - { + if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; - } - - $out .= ' '."\n"; - } - } - - $out .= $hookmanager->resPrint; - return $out; } - /** * Returns the rights used for this class * @return stdClass From 3a00952cd1005dee192e3e0873235857600910da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 14:44:31 +0100 Subject: [PATCH 57/70] Update user.class.php --- htdocs/user/class/user.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 6e79e5763b6..d0ef0c03adc 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -616,13 +616,13 @@ class User extends CommonObject require_once DOL_DOCUMENT_ROOT.'/core/class/defaultvalues.class.php'; $defaultValues = new DefaultValues($this->db); - $result = $defaultValues->fetchAll('', '', 0, 0, array('t.user_id'=>array(0,$this->id), 'entity'=>array($this->entity,$conf->entity))); + $result = $defaultValues->fetchAll('', '', 0, 0, array('t.user_id'=>array(0, $this->id), 'entity'=>array($this->entity, $conf->entity))); // User 0 (all) + me (if defined) - if (!is_array($result) && $result<0) { + if (!is_array($result) && $result < 0) { setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); dol_print_error($this->db); return -1; - } elseif (count($result)>0) { + } elseif (count($result) > 0) { foreach ($result as $defval) { if (!empty($defval->page) && !empty($defval->type) && !empty($defval->param)) { $pagewithoutquerystring = $defval->page; From 3982a36a3e2917ebfc069b1b2a738b72ab45034e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 14:47:35 +0100 Subject: [PATCH 58/70] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 85789c98b24..6ee753051c5 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7001,8 +7001,8 @@ abstract class CommonObject } /** - * @param string $type - * @return string + * @param string $type Type for prefix + * @return string Javacript code to manage dependency */ public function getJSListDependancies($type='_extra') { $out .= ' From 13e1ccb7956b5caa85348640886bb76f80e99e5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 14:55:42 +0100 Subject: [PATCH 59/70] Update index.php --- htdocs/website/index.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8c42f491618..ab094c384b6 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3770,12 +3770,11 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties // Print formconfirm -if ($action == 'preview'){ +if ($action == 'preview') { print $formconfirm; } -if ($action == 'editfile' || $action == 'file_manager') -{ +if ($action == 'editfile' || $action == 'file_manager') { print ''."\n"; print '

'; //print '
'.$langs->trans("FeatureNotYetAvailable").''; From 5af8e49c86b038e3c696804f3a5f8d57a8bbf663 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 15:05:29 +0100 Subject: [PATCH 60/70] Fix permission on generated sitemap file --- htdocs/website/index.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ab094c384b6..bae797b96c9 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2154,7 +2154,7 @@ if ($action == 'generatesitemaps') { $domtree->formatOutput = true; $xmlname = 'sitemap.'.$websitekey.'.xml'; - $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, DATE(wp.tms) as tms, w.virtualhost"; + $sql = "SELECT wp.type_container , wp.pageurl, wp.lang, wp.tms as tms, w.virtualhost"; $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp, ".MAIN_DB_PREFIX."website as w"; $sql .= " WHERE wp.type_container IN ('page', 'blogpost')"; $sql .= " AND wp.fk_website = w.rowid"; @@ -2175,7 +2175,7 @@ if ($action == 'generatesitemaps') { $domainname = $objp->virtualhost; } $loc = $domtree->createElement('loc', 'http://'.$domainname.'/'.$pageurl); - $lastmod = $domtree->createElement('lastmod', $objp->tms); + $lastmod = $domtree->createElement('lastmod', $db->jdate($objp->tms)); $url->appendChild($loc); $url->appendChild($lastmod); @@ -2183,8 +2183,10 @@ if ($action == 'generatesitemaps') { $i++; } $domtree->appendChild($root); - if ($domtree->save($tempdir.$xmlname)) - { + if ($domtree->save($tempdir.$xmlname)) { + if (!empty($conf->global->MAIN_UMASK)) { + @chmod($tempdir.$xmlname, octdec($conf->global->MAIN_UMASK)); + } setEventMessages($langs->trans("SitemapGenerated"), null, 'mesgs'); } else { setEventMessages($object->error, $object->errors, 'errors'); From 1f25f2bb7e14b90bfd2cef53caf8aa9aabf77508 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 15:09:29 +0100 Subject: [PATCH 61/70] Fix phpcs --- htdocs/core/class/commonobject.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6ee753051c5..9ebe63c44d0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7004,7 +7004,8 @@ abstract class CommonObject * @param string $type Type for prefix * @return string Javacript code to manage dependency */ - public function getJSListDependancies($type='_extra') { + public function getJSListDependancies($type = '_extra') + { $out .= ' '; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b8061bcea93..0e2540087c6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1576,7 +1576,8 @@ if ($action == 'create' && $usercancreate) console.log("We have changed the company - Reload page"); var socid = $(this).val(); // reload page - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&ref_client="+$("input[name=ref_client]").val(); + $("input[name=action]").val("create"); + $("form[name=crea_commande]").submit(); }); }); '; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index cd3175cdce0..b790f24f843 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -384,7 +384,8 @@ if ($action == 'create') var socid = $(this).val(); var fac_rec = $(\'#fac_rec\').val(); // reload page - window.location.href = "'.$_SERVER["PHP_SELF"].'?action=create&socid="+socid+"&fac_rec="+fac_rec; + $("input[name=action]").val("create"); + $("form[name=add]").submit(); }); }); '; From c81d5ff4d080d59249139e73352b97398a32603a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Mar 2021 16:13:00 +0100 Subject: [PATCH 66/70] Introduce a variable to cache some data. --- htdocs/core/class/conf.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index b73f7ae3257..6b50c73da8e 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -80,6 +80,9 @@ class Conf 'syslog' => array(), ); + // An array to store cache results ->cache['nameofcache']=... + public $cache = array(); + public $logbuffer = array(); /** From 5d78c3530b4c516e8feaf1136023c353a2b746c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 16:34:04 +0100 Subject: [PATCH 67/70] test stickler --- htdocs/website/index.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index bae797b96c9..ecaf9e8d11b 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2211,8 +2211,7 @@ if ($action == 'generatesitemaps') { $robotcontent .= $robotsitemap."\n"; } $result = dolSaveRobotFile($filerobot, $robotcontent); - if (!$result) - { + if (!$result) { $error++; setEventMessages('Failed to write file '.$filerobot, null, 'errors'); } From 15623ae852646021c1826afe2e97b68585772b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 16:39:04 +0100 Subject: [PATCH 68/70] fix --- htdocs/website/index.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ecaf9e8d11b..508a871de68 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2192,22 +2192,20 @@ if ($action == 'generatesitemaps') { setEventMessages($object->error, $object->errors, 'errors'); } } - }else { + } else { dol_print_error($db); } $robotcontent = @file_get_contents($filerobot); $result = preg_replace('/\n/ims', '', $robotcontent); - if ($result) - { + if ($result) { $robotcontent = $result; } $robotsitemap = "Sitemap: ".$domainname."/".$xmlname; $result = strpos($robotcontent, 'Sitemap: '); - if ($result) - { + if ($result) { $result = preg_replace("/Sitemap.*\n/", $robotsitemap, $robotcontent); $robotcontent = $result ? $result : $robotcontent; - }else { + } else { $robotcontent .= $robotsitemap."\n"; } $result = dolSaveRobotFile($filerobot, $robotcontent); @@ -2228,7 +2226,7 @@ $formwebsite = new FormWebsite($db); $formother = new FormOther($db); // Confirm generation of website sitemaps -if ($action == 'confirmgeneratesitemaps'){ +if ($action == 'confirmgeneratesitemaps') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?website='.$website->ref, $langs->trans('ConfirmSitemapsCreation'), $langs->trans('ConfirmGenerateSitemaps', $object->ref), 'generatesitemaps', '', "yes", 1); $action = 'preview'; } From 66ad8fbb24ecf72265318607e0648fb9d978752a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 2 Mar 2021 17:21:55 +0100 Subject: [PATCH 69/70] FIX select list dependancies on common object (FIX #16510) --- 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 1f0717ae042..e09ea7d96a9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7501,7 +7501,7 @@ abstract class CommonObject $out .= "\n"; // Add code to manage list depending on others if (!empty($conf->use_javascript_ajax)) { - $out .= getJSListDependancies(); + $out .= $this->getJSListDependancies(); } $out .= ' '."\n"; From bb2a505404dd0fb8ccf89824bed36fd833aad276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 2 Mar 2021 18:26:04 +0100 Subject: [PATCH 70/70] Update eventorganization.php --- htdocs/admin/eventorganization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index feb200744d2..8625f182f47 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -248,7 +248,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } else { print ''; }
'; @@ -1221,7 +1221,9 @@ class FormFile include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; } - $i = 0; $nboflines = 0; $lastrowid = 0; + $i = 0; + $nboflines = 0; + $lastrowid = 0; foreach ($filearray as $key => $file) { // filearray must be only files here if ($file['name'] != '.' && $file['name'] != '..' @@ -1639,19 +1641,24 @@ class FormFile // Define relative path used to store the file $relativefile = preg_replace('/'.preg_quote($upload_dir.'/', '/').'/', '', $file['fullname']); - $id = 0; $ref = ''; + $id = 0; + $ref = ''; // To show ref or specific information according to view to show (defined by $module) $reg = array(); if ($modulepart == 'company' || $modulepart == 'tax') { - preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); + preg_match('/(\d+)\/[^\/]+$/', $relativefile, $reg); + $id = (isset($reg[1]) ? $reg[1] : ''); } elseif ($modulepart == 'invoice_supplier') { - preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); if (is_numeric($ref)) { - $id = $ref; $ref = ''; + preg_match('/([^\/]+)\/[^\/]+$/', $relativefile, $reg); + $ref = (isset($reg[1]) ? $reg[1] : ''); if (is_numeric($ref)) { + $id = $ref; + $ref = ''; } - } // $ref may be also id with old supplier invoices - elseif ($modulepart == 'user' || $modulepart == 'holiday') { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $id = (isset($reg[1]) ? $reg[1] : ''); + } elseif ($modulepart == 'user' || $modulepart == 'holiday') { + // $ref may be also id with old supplier invoices + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); + $id = (isset($reg[1]) ? $reg[1] : ''); } elseif (in_array($modulepart, array( 'invoice', 'propal', @@ -1666,7 +1673,8 @@ class FormFile 'recruitment-recruitmentcandidature', 'mrp-mo', 'banque'))) { - preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : ''); + preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); + $ref = (isset($reg[1]) ? $reg[1] : ''); } else { $parameters = array('modulepart'=>$modulepart,'fileinfo'=>$file); $reshook = $hookmanager->executeHooks('addSectionECMAuto', $parameters); @@ -1703,10 +1711,13 @@ class FormFile } if ($result > 0) { // Save object loaded into a cache - $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; + $found = 1; + $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance; } if ($result == 0) { - $found = 1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = 'notfound'; unset($filearray[$key]); + $found = 1; + $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = 'notfound'; + unset($filearray[$key]); } } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index e0c31336f8c..b265700419b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -911,7 +911,8 @@ class FormMail extends Form } // Complete substitution array with the url to make online payment - $paymenturl = ''; $validpaymentmethod = array(); + $paymenturl = ''; + $validpaymentmethod = array(); if (empty($this->substit['__REF__'])) { $paymenturl = ''; } else { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 6fee9eb1000..127bfd2fd50 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1211,7 +1211,8 @@ class FormOther } // Define boxlista and boxlistb - $boxlista = ''; $boxlistb = ''; + $boxlista = ''; + $boxlistb = ''; $nbboxactivated = count($boxidactivatedforuser); if ($nbboxactivated) { @@ -1357,7 +1358,8 @@ class FormOther { global $langs; - $automatic = "automatic"; $manual = "manual"; + $automatic = "automatic"; + $manual = "manual"; if ($option) { $automatic = "1"; $manual = "0"; diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 21f8b2684fe..422a193030a 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -393,7 +393,8 @@ class FormProjets continue; } - $labeltoshow = ''; $titletoshow = ''; + $labeltoshow = ''; + $titletoshow = ''; $disabled = 0; if ($obj->fk_statut == Project::STATUS_DRAFT) { diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index ac69ca5ce26..57d8876c3ea 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -200,7 +200,8 @@ function limitChars(textarea, limit, infodiv) } } elseif (!empty($conf->global->MAIN_SMS_SENDMODE)) { // $conf->global->MAIN_SMS_SENDMODE looks like a value 'class@module' $tmp = explode('@', $conf->global->MAIN_SMS_SENDMODE); - $classfile = $tmp[0]; $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); + $classfile = $tmp[0]; + $module = (empty($tmp[1]) ? $tmp[0] : $tmp[1]); dol_include_once('/'.$module.'/class/'.$classfile.'.class.php'); try { $classname = ucfirst($classfile); diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 9f1afab13f7..4210113f990 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -246,7 +246,8 @@ class FormWebsite if ($atleastonepage) { if (empty($pageid) && $action != 'createcontainer') { // Page id is not defined, we try to take one - $firstpageid = 0; $homepageid = 0; + $firstpageid = 0; + $homepageid = 0; foreach ($website->lines as $key => $valpage) { if (empty($firstpageid)) { $firstpageid = $valpage->id; diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 73007db9363..bd2d6d020cd 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -8,7 +8,7 @@ * Copyright 2013, Leaf Corcoran * Licensed under MIT or GPLv3, see LICENSE */ - +// phpcs:disable /** * The LESS compiler and parser. * @@ -3385,7 +3385,7 @@ class lessc_parser return false; } - // a # color + // a # color protected function color(&$out) { if ($this->match('(#(?:[0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{3}))', $m)) { @@ -3400,11 +3400,11 @@ class lessc_parser return false; } - // consume an argument definition list surrounded by () - // each argument is a variable name with optional value - // or at the end a ... or a variable named followed by ... - // arguments are separated by , unless a ; is in the list, then ; is the - // delimiter. + // consume an argument definition list surrounded by () + // each argument is a variable name with optional value + // or at the end a ... or a variable named followed by ... + // arguments are separated by , unless a ; is in the list, then ; is the + // delimiter. protected function argumentDef(&$args, &$isVararg) { $s = $this->seek(); @@ -3726,7 +3726,7 @@ class lessc_parser return false; } - // consume a less variable + // consume a less variable protected function variable(&$name) { $s = $this->seek(); @@ -3746,10 +3746,10 @@ class lessc_parser return false; } - /** - * Consume an assignment operator - * Can optionally take a name that will be set to the current property name - */ + /** + * Consume an assignment operator + * Can optionally take a name that will be set to the current property name + */ protected function assign($name = null) { if ($name) { @@ -3758,7 +3758,7 @@ class lessc_parser return $this->literal(':') || $this->literal('='); } - // consume a keyword + // consume a keyword protected function keyword(&$word) { if ($this->match('([\w_\-\*!"][\w\-_"]*)', $m)) { @@ -3768,7 +3768,7 @@ class lessc_parser return false; } - // consume an end of statement delimiter + // consume an end of statement delimiter protected function end() { if ($this->literal(';', false)) { @@ -3807,8 +3807,8 @@ class lessc_parser return true; } - // a bunch of guards that are and'd together - // TODO rename to guardGroup + // a bunch of guards that are and'd together + // TODO rename to guardGroup protected function guardGroup(&$guardGroup) { $s = $this->seek(); @@ -3846,7 +3846,7 @@ class lessc_parser return false; } - /* raw parsing functions */ + /* raw parsing functions */ protected function literal($what, $eatWhitespace = null) { diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index a9fb8b01c16..97c63e62d67 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -578,7 +578,10 @@ class Menubase //var_dump($this->newmenu->liste); } else { // Search first menu with this couple (mainmenu,leftmenu)=(fk_mainmenu,fk_leftmenu) - $searchlastsub = 0; $lastid = 0; $nextid = 0; $found = 0; + $searchlastsub = 0; + $lastid = 0; + $nextid = 0; + $found = 0; foreach ($this->newmenu->liste as $keyparent => $valparent) { //var_dump($valparent); if ($searchlastsub) { // If we started to search for last submenu diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index aae4acd7bc0..0f09d232712 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -410,9 +410,10 @@ class RssParser } } if (!empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) { - $tmprss = xml2php($rss); $items = $tmprss['entry']; - } // With simplexml - else { + $tmprss = xml2php($rss); + $items = $tmprss['entry']; + } else { + // With simplexml $items = $rss->items; // With xmlparse } //var_dump($items);exit; @@ -552,45 +553,36 @@ class RssParser if (isset($attrs['rdf:about'])) { $this->current_item['about'] = $attrs['rdf:about']; } - } - - // if we're in the default namespace of an RSS feed, - // record textinput or image fields - elseif ($this->_format == 'rss' and + } elseif ($this->_format == 'rss' and $this->current_namespace == '' and $el == 'textinput') { + // if we're in the default namespace of an RSS feed, + // record textinput or image fields $this->intextinput = true; } elseif ($this->_format == 'rss' and $this->current_namespace == '' and $el == 'image') { $this->inimage = true; - } - - // handle atom content constructs - elseif ($this->_format == 'atom' and in_array($el, $this->_CONTENT_CONSTRUCTS)) { + } elseif ($this->_format == 'atom' and in_array($el, $this->_CONTENT_CONSTRUCTS)) { + // handle atom content constructs // avoid clashing w/ RSS mod_content if ($el == 'content') { $el = 'atom_content'; } $this->incontent = $el; - } - - // if inside an Atom content construct (e.g. content or summary) field treat tags as text - elseif ($this->_format == 'atom' and $this->incontent) { + } elseif ($this->_format == 'atom' and $this->incontent) { + // if inside an Atom content construct (e.g. content or summary) field treat tags as text // if tags are inlined, then flatten $attrs_str = join(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs))); $this->append_content("<$element $attrs_str>"); array_unshift($this->stack, $el); - } - - // Atom support many links per containging element. - // Magpie treats link elements of type rel='alternate' - // as being equivalent to RSS's simple link element. - // - elseif ($this->_format == 'atom' and $el == 'link') { + } elseif ($this->_format == 'atom' and $el == 'link') { + // Atom support many links per containging element. + // Magpie treats link elements of type rel='alternate' + // as being equivalent to RSS's simple link element. if (isset($attrs['rel']) && $attrs['rel'] == 'alternate') { $link_el = 'link'; } elseif (!isset($attrs['rel'])) { @@ -600,9 +592,8 @@ class RssParser } $this->append($link_el, $attrs['href']); - } - // set stack[0] to current element - else { + } else { + // set stack[0] to current element array_unshift($this->stack, $el); } } diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 3618cfc2413..ef26dc4ac65 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -426,9 +426,8 @@ class SMTPs if ($_retVal = $this->server_parse($this->socket, "220")) { $_retVal = $this->socket; } - } - // This connection attempt failed. - else { + } else { + // This connection attempt failed. // @CHANGE LDR if (empty($this->errstr)) { $this->errstr = 'Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); @@ -580,10 +579,8 @@ class SMTPs if (!empty($this->_smtpsID) && !empty($this->_smtpsPW)) { // Send the RFC2554 specified EHLO. $_retVal = $this->_server_authenticate(); - } - - // This is a "normal" SMTP Server "handshack" - else { + } else { + // This is a "normal" SMTP Server "handshack" // Send the RFC821 specified HELO. $host = $this->getHost(); $usetls = preg_match('@tls://@i', $host); @@ -705,10 +702,8 @@ class SMTPs $this->_setErr(110, '"'.$_strConfigPath.'" is not a valid path.'); $_retVal = false; } - } - - // Read the Systems php.ini file - else { + } else { + // Read the Systems php.ini file // Set these properties ONLY if they are set in the php.ini file. // Otherwise the default values will be used. if ($_host = ini_get('SMTPs')) { @@ -1048,10 +1043,8 @@ class SMTPs if (strstr($_addrList, ',')) { // "explode "list" into an array $_addrList = explode(',', $_addrList); - } - - // Stick it in an array - else { + } else { + // Stick it in an array $_addrList = array($_addrList); } } @@ -1070,9 +1063,8 @@ class SMTPs $_tmpHost = explode('@', $_tmpaddr[1]); $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0]; - } - // We only have an eMail address - else { + } else { + // We only have an eMail address // Strip off the beggining '<' $_strAddr = str_replace('<', '', $_strAddr); @@ -1449,10 +1441,8 @@ class SMTPs // If we have ZERO, we have a problem if ($keyCount === 0) { die("Sorry, no content"); - } - - // If we have ONE, we can use the simple format - elseif ($keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { + } elseif ($keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { + // If we have ONE, we can use the simple format $_msgData = $this->_msgContent; $_msgData = $_msgData[$_types[0]]; @@ -1467,10 +1457,8 @@ class SMTPs $content .= "\r\n" . $_msgData['data']."\r\n"; - } - - // If we have more than ONE, we use the multi-part format - elseif ($keyCount >= 1 || !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { + } elseif ($keyCount >= 1 || !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { + // If we have more than ONE, we use the multi-part format // Since this is an actual multi-part message // We need to define a content message Boundary // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. @@ -1512,9 +1500,8 @@ class SMTPs $content .= "\r\n".$_data['data']."\r\n\r\n"; } - } - // @CHANGE LDR - elseif ($type == 'image') { + } elseif ($type == 'image') { + // @CHANGE LDR // loop through all images foreach ($_content as $_image => $_data) { $content .= "--".$this->_getBoundary('related')."\r\n"; // always related for an inline image @@ -1546,7 +1533,8 @@ class SMTPs $content .= "--".$this->_getBoundary('related')."\r\n"; } - if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { // Add plain text message part before html part + if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { + // Add plain text message part before html part $content .= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"'."\r\n"; $content .= "\r\n"; $content .= "--".$this->_getBoundary('alternative')."\r\n"; @@ -1566,7 +1554,8 @@ class SMTPs $content .= "\r\n".$_content['data']."\r\n"; - if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { // Add plain text message part after html part + if (!key_exists('image', $this->_msgContent) && $_content['dataText'] && !empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { + // Add plain text message part after html part $content .= "--".$this->_getBoundary('alternative')."--\r\n"; } @@ -1599,7 +1588,7 @@ class SMTPs $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; if ($this->getMD5flag()) { - $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); + $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); } } } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index b2c9b069095..4ac164b1d3a 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -424,7 +424,8 @@ abstract class Stats $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i = 0; $j = 0; + $i = 0; + $j = 0; while ($i < $num) { $row = $this->db->fetch_row($resql); $j = $row[0] * 1; @@ -539,7 +540,8 @@ abstract class Stats $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i = 0; $j = 0; + $i = 0; + $j = 0; while ($i < $num) { $row = $this->db->fetch_row($resql); $j = $row[0] * 1; @@ -594,7 +596,8 @@ abstract class Stats $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i = 0; $other = 0; + $i = 0; + $other = 0; while ($i < $num) { $row = $this->db->fetch_row($resql); if ($i < $limit || $num == $limit) { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 0aa00153f5b..007b812cfa4 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -81,7 +81,8 @@ class Translate foreach ($conf->file->dol_document_root as $dir) { $newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX' if (!in_array($newdir, $this->dir)) { - $more['module_'.$i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir. + $more['module_'.$i] = $newdir; + $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir. } } $this->dir = array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir) @@ -267,9 +268,8 @@ class Translate // Using a memcached server if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) { $usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars - } - // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) - elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { + } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { + // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) $usecachekey = $newdomain; } @@ -458,9 +458,8 @@ class Translate // Using a memcached server if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) { $usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars - } - // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) - elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { + } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) { + // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file) $usecachekey = $newdomain; } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 3806e5bda4d..7be7e8f28cc 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -222,11 +222,13 @@ class Utils $prefix = 'dump'; $ext = 'sql'; if (in_array($type, array('mysql', 'mysqli'))) { - $prefix = 'mysqldump'; $ext = 'sql'; + $prefix = 'mysqldump'; + $ext = 'sql'; } //if ($label == 'PostgreSQL') { $prefix='pg_dump'; $ext='dump'; } if (in_array($type, array('pgsql'))) { - $prefix = 'pg_dump'; $ext = 'sql'; + $prefix = 'pg_dump'; + $ext = 'sql'; } $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext; } @@ -350,7 +352,8 @@ class Utils // TODO Replace with executeCLI function if ($execmethod == 1) { - $output_arr = array(); $retval = null; + $output_arr = array(); + $retval = null; exec($fullcommandclear, $output_arr, $retval); if ($retval != 0) { diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index 229966468c1..d513262b871 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -63,7 +63,8 @@ function dol_quoted_printable_encode($input, $line_max = 76) if (($dec == 32) && ($i == ($linlen - 1))) { // convert space at eol only $c = "=20"; } elseif (($dec == 61) || ($dec < 32) || ($dec > 126)) { // always encode "\t", which is *not* required - $h2 = floor($dec / 16); $h1 = floor($dec % 16); + $h2 = floor($dec / 16); + $h1 = floor($dec % 16); $c = $escape.$hex["$h2"].$hex["$h1"]; } if ((strlen($newline) + strlen($c)) >= $line_max) { // CRLF is not counted diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 2d3210cad66..c5e0137b98d 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -615,7 +615,9 @@ if ($sql) { dol_print_error($db); } - $ifetch = 0; $xi = 0; $oldlabeltouse = ''; + $ifetch = 0; + $xi = 0; + $oldlabeltouse = ''; while ($obj = $db->fetch_object($resql)) { $ifetch++; if ($useagroupby) { @@ -681,9 +683,8 @@ if ($sql) { if ($objfieldforg == '0') { // The record we fetch is for this group $data[$xi][$fieldforybis] = $obj->$fieldfory; - } - // The record we fetch is not for this group - elseif (!isset($data[$xi][$fieldforybis])) { + } elseif (!isset($data[$xi][$fieldforybis])) { + // The record we fetch is not for this group $data[$xi][$fieldforybis] = '0'; } } else { @@ -691,9 +692,8 @@ if ($sql) { if ((string) $objfieldforg === (string) $gvaluepossiblekey) { // The record we fetch is for this group $data[$xi][$fieldforybis] = $obj->$fieldfory; - } - // The record we fetch is not for this group - elseif (!isset($data[$xi][$fieldforybis])) { + } elseif (!isset($data[$xi][$fieldforybis])) { + // The record we fetch is not for this group $data[$xi][$fieldforybis] = '0'; } } diff --git a/htdocs/core/datepicker.php b/htdocs/core/datepicker.php index c6aaef77f9c..7842457db0f 100644 --- a/htdocs/core/datepicker.php +++ b/htdocs/core/datepicker.php @@ -228,7 +228,9 @@ function displayBox($selectedDate, $month, $year) $mydate = dol_get_first_day_week(1, $month, $year, true); // mydate = cursor date // Loop on each day of month - $stoploop = 0; $day = 1; $cols = 0; + $stoploop = 0; + $day = 1; + $cols = 0; while (!$stoploop) { //print_r($mydate); if ($mydate < $firstdate) { // At first run diff --git a/htdocs/core/extrafieldsinexport.inc.php b/htdocs/core/extrafieldsinexport.inc.php index 0c47e97aef9..0d29c0d1323 100644 --- a/htdocs/core/extrafieldsinexport.inc.php +++ b/htdocs/core/extrafieldsinexport.inc.php @@ -58,9 +58,8 @@ if ($resql) { // This can fail when class is used on old database (during mig $this->export_fields_array[$r][$fieldname] = $fieldlabel; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter; $this->export_entities_array[$r][$fieldname] = $keyforelement; - } - // If this is a computed field - else { + } else { + // If this is a computed field $this->export_fields_array[$r][$fieldname] = $fieldlabel; $this->export_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute'; $this->export_special_array[$r][$fieldname] = $obj->fieldcomputed; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 15b8e8bb188..759b97aaedb 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -106,10 +106,12 @@ function versioncompare($versionarray1, $versionarray2) $level++; //print 'level '.$level.' '.$operande1.'-'.$operande2.'
'; if ($operande1 < $operande2) { - $ret = -$level; break; + $ret = -$level; + break; } if ($operande1 > $operande2) { - $ret = $level; break; + $ret = $level; + break; } } //print join('.',$versionarray1).'('.count($versionarray1).') / '.join('.',$versionarray2).'('.count($versionarray2).') => '.$ret.'
'."\n"; @@ -1240,40 +1242,52 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab //var_dump($objMod->dictionaries['tabname']); $nbtabname = $nbtablib = $nbtabsql = $nbtabsqlsort = $nbtabfield = $nbtabfieldvalue = $nbtabfieldinsert = $nbtabrowid = $nbtabcond = $nbtabfieldcheck = $nbtabhelp = 0; foreach ($objMod->dictionaries['tabname'] as $val) { - $nbtabname++; $taborder[] = max($taborder) + 1; $tabname[] = $val; + $nbtabname++; + $taborder[] = max($taborder) + 1; + $tabname[] = $val; } // Position foreach ($objMod->dictionaries['tablib'] as $val) { - $nbtablib++; $tablib[] = $val; + $nbtablib++; + $tablib[] = $val; } foreach ($objMod->dictionaries['tabsql'] as $val) { - $nbtabsql++; $tabsql[] = $val; + $nbtabsql++; + $tabsql[] = $val; } foreach ($objMod->dictionaries['tabsqlsort'] as $val) { - $nbtabsqlsort++; $tabsqlsort[] = $val; + $nbtabsqlsort++; + $tabsqlsort[] = $val; } foreach ($objMod->dictionaries['tabfield'] as $val) { - $nbtabfield++; $tabfield[] = $val; + $nbtabfield++; + $tabfield[] = $val; } foreach ($objMod->dictionaries['tabfieldvalue'] as $val) { - $nbtabfieldvalue++; $tabfieldvalue[] = $val; + $nbtabfieldvalue++; + $tabfieldvalue[] = $val; } foreach ($objMod->dictionaries['tabfieldinsert'] as $val) { - $nbtabfieldinsert++; $tabfieldinsert[] = $val; + $nbtabfieldinsert++; + $tabfieldinsert[] = $val; } foreach ($objMod->dictionaries['tabrowid'] as $val) { - $nbtabrowid++; $tabrowid[] = $val; + $nbtabrowid++; + $tabrowid[] = $val; } foreach ($objMod->dictionaries['tabcond'] as $val) { - $nbtabcond++; $tabcond[] = $val; + $nbtabcond++; + $tabcond[] = $val; } if (!empty($objMod->dictionaries['tabhelp'])) { foreach ($objMod->dictionaries['tabhelp'] as $val) { - $nbtabhelp++; $tabhelp[] = $val; + $nbtabhelp++; + $tabhelp[] = $val; } } if (!empty($objMod->dictionaries['tabfieldcheck'])) { foreach ($objMod->dictionaries['tabfieldcheck'] as $val) { - $nbtabfieldcheck++; $tabfieldcheck[] = $val; + $nbtabfieldcheck++; + $tabfieldcheck[] = $val; } } diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index cbf56136978..cd8764a8a87 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -167,7 +167,9 @@ function barcode_encode($code, $encoding) */ function barcode_gen_ean_sum($ean) { - $even = true; $esum = 0; $osum = 0; + $even = true; + $esum = 0; + $osum = 0; $ln = strlen($ean) - 1; for ($i = $ln; $i >= 0; $i--) { if ($even) { @@ -300,7 +302,8 @@ function barcode_encode_genbarcode($code, $encoding) ); //var_dump($ret); if (preg_match('/permission denied/i', $ret['bars'])) { - $ret['error'] = $ret['bars']; $ret['bars'] = ''; + $ret['error'] = $ret['bars']; + $ret['bars'] = ''; return $ret; } if (!$ret['bars']) { diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php index 87653786b9f..426b486a8cf 100644 --- a/htdocs/core/lib/date.lib.php +++ b/htdocs/core/lib/date.lib.php @@ -84,7 +84,10 @@ function getServerTimeZoneInt($refgmtdate = 'now') { if (method_exists('DateTimeZone', 'getOffset')) { // Method 1 (include daylight) - $gmtnow = dol_now('gmt'); $yearref = dol_print_date($gmtnow, '%Y'); $monthref = dol_print_date($gmtnow, '%m'); $dayref = dol_print_date($gmtnow, '%d'); + $gmtnow = dol_now('gmt'); + $yearref = dol_print_date($gmtnow, '%Y'); + $monthref = dol_print_date($gmtnow, '%m'); + $dayref = dol_print_date($gmtnow, '%d'); if ($refgmtdate == 'now') { $newrefgmtdate = $yearref.'-'.$monthref.'-'.$dayref; } elseif ($refgmtdate == 'summer') { @@ -134,10 +137,12 @@ function dol_time_plus_duree($time, $duration_value, $duration_unit) $deltastring = 'P'; if ($duration_value > 0) { - $deltastring .= abs($duration_value); $sub = false; + $deltastring .= abs($duration_value); + $sub = false; } if ($duration_value < 0) { - $deltastring .= abs($duration_value); $sub = true; + $deltastring .= abs($duration_value); + $sub = true; } if ($duration_unit == 'd') { $deltastring .= "D"; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index bde5408eb65..b7e7ffd5e7e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -123,7 +123,8 @@ function dol_dir_list($path, $types = "all", $recursive = 0, $filter = "", $excl // Check if file is qualified foreach ($excludefilterarray as $filt) { if (preg_match('/'.$filt.'/i', $file) || preg_match('/'.$filt.'/i', $fullpathfile)) { - $qualified = 0; break; + $qualified = 0; + break; } } //print $fullpathfile.' '.$file.' '.$qualified.'
'; @@ -400,9 +401,11 @@ function dol_compare_file($a, $b) $sortorder = strtoupper($sortorder); if ($sortorder == 'ASC') { - $retup = -1; $retdown = 1; + $retup = -1; + $retdown = 1; } else { - $retup = 1; $retdown = -1; + $retup = 1; + $retdown = -1; } if ($sortfield == 'name') { @@ -1916,9 +1919,11 @@ function dol_compress_file($inputfile, $outputfile, $mode = "gz", &$errorstring $data = implode("", file(dol_osencode($inputfile))); if ($mode == 'gz') { - $foundhandler = 1; $compressdata = gzencode($data, 9); + $foundhandler = 1; + $compressdata = gzencode($data, 9); } elseif ($mode == 'bz') { - $foundhandler = 1; $compressdata = bzcompress($data, 9); + $foundhandler = 1; + $compressdata = bzcompress($data, 9); } elseif ($mode == 'zip') { if (class_exists('ZipArchive') && !empty($conf->global->MAIN_USE_ZIPARCHIVE_FOR_ZIP_COMPRESS)) { $foundhandler = 1; @@ -2037,7 +2042,8 @@ function dol_uncompress($inputfile, $outputdir) if (!is_array($result) && $result <= 0) { return array('error'=>$archive->errorInfo(true)); } else { - $ok = 1; $errmsg = ''; + $ok = 1; + $errmsg = ''; // Loop on each file to check result for unzipping file foreach ($result as $key => $val) { if ($val['status'] == 'path_creation_fail') { @@ -2250,9 +2256,13 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } // Define possible keys to use for permission check - $lire = 'lire'; $read = 'read'; $download = 'download'; + $lire = 'lire'; + $read = 'read'; + $download = 'download'; if ($mode == 'write') { - $lire = 'creer'; $read = 'write'; $download = 'upload'; + $lire = 'creer'; + $read = 'write'; + $download = 'upload'; } // Wrapping for miscellaneous medias files @@ -2262,100 +2272,100 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $accessallowed = 1; $original_file = $conf->medias->multidir_output[$entity].'/'.$original_file; - } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log - elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root)) { + } elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root)) { + // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log $accessallowed = ($user->admin && basename($original_file) == $original_file && preg_match('/^dolibarr.*\.log$/', basename($original_file))); $original_file = $dolibarr_main_data_root.'/'.$original_file; - } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log - elseif ($modulepart == 'doctemplates' && !empty($dolibarr_main_data_root)) { + } elseif ($modulepart == 'doctemplates' && !empty($dolibarr_main_data_root)) { + // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log $accessallowed = $user->admin; $original_file = $dolibarr_main_data_root.'/doctemplates/'.$original_file; - } // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip - elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { + } elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { + // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip $accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); $original_file = $dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; - } // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip - elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { + } elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { + // Wrapping for *.zip files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip // Dir for custom dirs $tmp = explode(',', $dolibarr_main_document_root_alt); $dirins = $tmp[0]; $accessallowed = ($user->admin && preg_match('/^module_.*\.zip$/', basename($original_file))); $original_file = $dirins.'/'.$original_file; - } // Wrapping for some images - elseif ($modulepart == 'mycompany' && !empty($conf->mycompany->dir_output)) { + } elseif ($modulepart == 'mycompany' && !empty($conf->mycompany->dir_output)) { + // Wrapping for some images $accessallowed = 1; $original_file = $conf->mycompany->dir_output.'/'.$original_file; - } // Wrapping for users photos - elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) { + } elseif ($modulepart == 'userphoto' && !empty($conf->user->dir_output)) { + // Wrapping for users photos $accessallowed = 1; $original_file = $conf->user->dir_output.'/'.$original_file; - } // Wrapping for members photos - elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output)) { + } elseif ($modulepart == 'memberphoto' && !empty($conf->adherent->dir_output)) { + // Wrapping for members photos $accessallowed = 1; $original_file = $conf->adherent->dir_output.'/'.$original_file; - } // Wrapping pour les apercu factures - elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity])) { + } elseif ($modulepart == 'apercufacture' && !empty($conf->facture->multidir_output[$entity])) { + // Wrapping pour les apercu factures if ($fuser->rights->facture->{$lire}) { $accessallowed = 1; } $original_file = $conf->facture->multidir_output[$entity].'/'.$original_file; - } // Wrapping pour les apercu propal - elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) { + } elseif ($modulepart == 'apercupropal' && !empty($conf->propal->multidir_output[$entity])) { + // Wrapping pour les apercu propal if ($fuser->rights->propale->{$lire}) { $accessallowed = 1; } $original_file = $conf->propal->multidir_output[$entity].'/'.$original_file; - } // Wrapping pour les apercu commande - elseif ($modulepart == 'apercucommande' && !empty($conf->commande->multidir_output[$entity])) { + } elseif ($modulepart == 'apercucommande' && !empty($conf->commande->multidir_output[$entity])) { + // Wrapping pour les apercu commande if ($fuser->rights->commande->{$lire}) { $accessallowed = 1; } $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; - } // Wrapping pour les apercu intervention - elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) { + } elseif (($modulepart == 'apercufichinter' || $modulepart == 'apercuficheinter') && !empty($conf->ficheinter->dir_output)) { + // Wrapping pour les apercu intervention if ($fuser->rights->ficheinter->{$lire}) { $accessallowed = 1; } $original_file = $conf->ficheinter->dir_output.'/'.$original_file; - } // Wrapping pour les apercu conat - elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->multidir_output[$entity])) { + } elseif (($modulepart == 'apercucontract') && !empty($conf->contrat->multidir_output[$entity])) { + // Wrapping pour les apercu contrat if ($fuser->rights->contrat->{$lire}) { $accessallowed = 1; } $original_file = $conf->contrat->multidir_output[$entity].'/'.$original_file; - } // Wrapping pour les apercu supplier proposal - elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { + } elseif (($modulepart == 'apercusupplier_proposal' || $modulepart == 'apercusupplier_proposal') && !empty($conf->supplier_proposal->dir_output)) { + // Wrapping pour les apercu supplier proposal if ($fuser->rights->supplier_proposal->{$lire}) { $accessallowed = 1; } $original_file = $conf->supplier_proposal->dir_output.'/'.$original_file; - } // Wrapping pour les apercu supplier order - elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { + } elseif (($modulepart == 'apercusupplier_order' || $modulepart == 'apercusupplier_order') && !empty($conf->fournisseur->commande->dir_output)) { + // Wrapping pour les apercu supplier order if ($fuser->rights->fournisseur->commande->{$lire}) { $accessallowed = 1; } $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; - } // Wrapping pour les apercu supplier invoice - elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) { + } elseif (($modulepart == 'apercusupplier_invoice' || $modulepart == 'apercusupplier_invoice') && !empty($conf->fournisseur->facture->dir_output)) { + // Wrapping pour les apercu supplier invoice if ($fuser->rights->fournisseur->facture->{$lire}) { $accessallowed = 1; } $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; - } // Wrapping pour les apercu supplier invoice - elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) { + } elseif (($modulepart == 'apercuexpensereport') && !empty($conf->expensereport->dir_output)) { + // Wrapping pour les apercu supplier invoice if ($fuser->rights->expensereport->{$lire}) { $accessallowed = 1; } $original_file = $conf->expensereport->dir_output.'/'.$original_file; - } // Wrapping pour les images des stats propales - elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) { + } elseif ($modulepart == 'propalstats' && !empty($conf->propal->multidir_temp[$entity])) { + // Wrapping pour les images des stats propales if ($fuser->rights->propale->{$lire}) { $accessallowed = 1; } $original_file = $conf->propal->multidir_temp[$entity].'/'.$original_file; - } // Wrapping pour les images des stats commandes - elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) { + } elseif ($modulepart == 'orderstats' && !empty($conf->commande->dir_temp)) { + // Wrapping pour les images des stats commandes if ($fuser->rights->commande->{$lire}) { $accessallowed = 1; } @@ -2365,8 +2375,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->fournisseur->commande->dir_temp.'/'.$original_file; - } // Wrapping pour les images des stats factures - elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp)) { + } elseif ($modulepart == 'billstats' && !empty($conf->facture->dir_temp)) { + // Wrapping pour les images des stats factures if ($fuser->rights->facture->{$lire}) { $accessallowed = 1; } @@ -2376,45 +2386,45 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->fournisseur->facture->dir_temp.'/'.$original_file; - } // Wrapping pour les images des stats expeditions - elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) { + } elseif ($modulepart == 'expeditionstats' && !empty($conf->expedition->dir_temp)) { + // Wrapping pour les images des stats expeditions if ($fuser->rights->expedition->{$lire}) { $accessallowed = 1; } $original_file = $conf->expedition->dir_temp.'/'.$original_file; - } // Wrapping pour les images des stats expeditions - elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp)) { + } elseif ($modulepart == 'tripsexpensesstats' && !empty($conf->deplacement->dir_temp)) { + // Wrapping pour les images des stats expeditions if ($fuser->rights->deplacement->{$lire}) { $accessallowed = 1; } $original_file = $conf->deplacement->dir_temp.'/'.$original_file; - } // Wrapping pour les images des stats expeditions - elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp)) { + } elseif ($modulepart == 'memberstats' && !empty($conf->adherent->dir_temp)) { + // Wrapping pour les images des stats expeditions if ($fuser->rights->adherent->{$lire}) { $accessallowed = 1; } $original_file = $conf->adherent->dir_temp.'/'.$original_file; - } // Wrapping pour les images des stats produits - elseif (preg_match('/^productstats_/i', $modulepart) && !empty($conf->product->dir_temp)) { + } elseif (preg_match('/^productstats_/i', $modulepart) && !empty($conf->product->dir_temp)) { + // Wrapping pour les images des stats produits if ($fuser->rights->produit->{$lire} || $fuser->rights->service->{$lire}) { $accessallowed = 1; } $original_file = (!empty($conf->product->multidir_temp[$entity]) ? $conf->product->multidir_temp[$entity] : $conf->service->multidir_temp[$entity]).'/'.$original_file; - } // Wrapping for taxes - elseif (in_array($modulepart, array('tax', 'tax-vat')) && !empty($conf->tax->dir_output)) { + } elseif (in_array($modulepart, array('tax', 'tax-vat')) && !empty($conf->tax->dir_output)) { + // Wrapping for taxes if ($fuser->rights->tax->charges->{$lire}) { $accessallowed = 1; } $modulepartsuffix = str_replace('tax-', '', $modulepart); $original_file = $conf->tax->dir_output.'/'.($modulepartsuffix != 'tax' ? $modulepartsuffix.'/' : '').$original_file; - } // Wrapping for events - elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { + } elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { + // Wrapping for events if ($fuser->rights->agenda->myactions->{$read}) { $accessallowed = 1; } $original_file = $conf->agenda->dir_output.'/'.$original_file; - } // Wrapping for categories - elseif ($modulepart == 'category' && !empty($conf->categorie->multidir_output[$entity])) { + } elseif ($modulepart == 'category' && !empty($conf->categorie->multidir_output[$entity])) { + // Wrapping for categories if (empty($entity) || empty($conf->categorie->multidir_output[$entity])) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } @@ -2422,44 +2432,44 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->categorie->multidir_output[$entity].'/'.$original_file; - } // Wrapping pour les prelevements - elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) { + } elseif ($modulepart == 'prelevement' && !empty($conf->prelevement->dir_output)) { + // Wrapping pour les prelevements if ($fuser->rights->prelevement->bons->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->prelevement->dir_output.'/'.$original_file; - } // Wrapping pour les graph energie - elseif ($modulepart == 'graph_stock' && !empty($conf->stock->dir_temp)) { + } elseif ($modulepart == 'graph_stock' && !empty($conf->stock->dir_temp)) { + // Wrapping pour les graph energie $accessallowed = 1; $original_file = $conf->stock->dir_temp.'/'.$original_file; - } // Wrapping pour les graph fournisseurs - elseif ($modulepart == 'graph_fourn' && !empty($conf->fournisseur->dir_temp)) { + } elseif ($modulepart == 'graph_fourn' && !empty($conf->fournisseur->dir_temp)) { + // Wrapping pour les graph fournisseurs $accessallowed = 1; $original_file = $conf->fournisseur->dir_temp.'/'.$original_file; - } // Wrapping pour les graph des produits - elseif ($modulepart == 'graph_product' && !empty($conf->product->dir_temp)) { + } elseif ($modulepart == 'graph_product' && !empty($conf->product->dir_temp)) { + // Wrapping pour les graph des produits $accessallowed = 1; $original_file = $conf->product->multidir_temp[$entity].'/'.$original_file; - } // Wrapping pour les code barre - elseif ($modulepart == 'barcode') { + } elseif ($modulepart == 'barcode') { + // Wrapping pour les code barre $accessallowed = 1; // If viewimage is called for barcode, we try to output an image on the fly, with no build of file on disk. //$original_file=$conf->barcode->dir_temp.'/'.$original_file; $original_file = ''; - } // Wrapping pour les icones de background des mailings - elseif ($modulepart == 'iconmailing' && !empty($conf->mailing->dir_temp)) { + } elseif ($modulepart == 'iconmailing' && !empty($conf->mailing->dir_temp)) { + // Wrapping pour les icones de background des mailings $accessallowed = 1; $original_file = $conf->mailing->dir_temp.'/'.$original_file; - } // Wrapping pour le scanner - elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { + } elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { + // Wrapping pour le scanner $accessallowed = 1; $original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; - } // Wrapping pour les images fckeditor - elseif ($modulepart == 'fckeditor' && !empty($conf->fckeditor->dir_output)) { + } elseif ($modulepart == 'fckeditor' && !empty($conf->fckeditor->dir_output)) { + // Wrapping pour les images fckeditor $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; - } // Wrapping for users - elseif ($modulepart == 'user' && !empty($conf->user->dir_output)) { + } elseif ($modulepart == 'user' && !empty($conf->user->dir_output)) { + // Wrapping for users $canreaduser = (!empty($fuser->admin) || $fuser->rights->user->user->{$lire}); if ($fuser->id == (int) $refname) { $canreaduser = 1; @@ -2468,8 +2478,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->user->dir_output.'/'.$original_file; - } // Wrapping for third parties - elseif (($modulepart == 'company' || $modulepart == 'societe' || $modulepart == 'thirdparty') && !empty($conf->societe->multidir_output[$entity])) { + } elseif (($modulepart == 'company' || $modulepart == 'societe' || $modulepart == 'thirdparty') && !empty($conf->societe->multidir_output[$entity])) { + // Wrapping for third parties if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } @@ -2478,8 +2488,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->societe->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT rowid as fk_soc FROM ".MAIN_DB_PREFIX."societe WHERE rowid='".$db->escape($refname)."' AND entity IN (".getEntity('societe').")"; - } // Wrapping for contact - elseif ($modulepart == 'contact' && !empty($conf->societe->multidir_output[$entity])) { + } elseif ($modulepart == 'contact' && !empty($conf->societe->multidir_output[$entity])) { + // Wrapping for contact if (empty($entity) || empty($conf->societe->multidir_output[$entity])) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } @@ -2487,15 +2497,15 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->societe->multidir_output[$entity].'/contact/'.$original_file; - } // Wrapping for invoices - elseif (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->multidir_output[$entity])) { + } elseif (($modulepart == 'facture' || $modulepart == 'invoice') && !empty($conf->facture->multidir_output[$entity])) { + // Wrapping for invoices if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->facture->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('invoice').")"; - } // Wrapping for mass actions - elseif ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->multidir_output[$entity])) { + } elseif ($modulepart == 'massfilesarea_proposals' && !empty($conf->propal->multidir_output[$entity])) { + // Wrapping for mass actions if ($fuser->rights->propal->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } @@ -2545,36 +2555,36 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $accessallowed = 1; } $original_file = $conf->contrat->dir_output.'/temp/massgeneration/'.$user->id.'/'.$original_file; - } // Wrapping for interventions - elseif (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output)) { + } elseif (($modulepart == 'fichinter' || $modulepart == 'ficheinter') && !empty($conf->ficheinter->dir_output)) { + // Wrapping for interventions if ($fuser->rights->ficheinter->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->ficheinter->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } // Wrapping pour les deplacements et notes de frais - elseif ($modulepart == 'deplacement' && !empty($conf->deplacement->dir_output)) { + } elseif ($modulepart == 'deplacement' && !empty($conf->deplacement->dir_output)) { + // Wrapping pour les deplacements et notes de frais if ($fuser->rights->deplacement->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->deplacement->dir_output.'/'.$original_file; //$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."fichinter WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } // Wrapping pour les propales - elseif (($modulepart == 'propal' || $modulepart == 'propale') && !empty($conf->propal->multidir_output[$entity])) { + } elseif (($modulepart == 'propal' || $modulepart == 'propale') && !empty($conf->propal->multidir_output[$entity])) { + // Wrapping pour les propales if ($fuser->rights->propale->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->propal->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."propal WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('propal').")"; - } // Wrapping pour les commandes - elseif (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->multidir_output[$entity])) { + } elseif (($modulepart == 'commande' || $modulepart == 'order') && !empty($conf->commande->multidir_output[$entity])) { + // Wrapping pour les commandes if ($fuser->rights->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->commande->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('order').")"; - } // Wrapping pour les projets - elseif ($modulepart == 'project' && !empty($conf->projet->dir_output)) { + } elseif ($modulepart == 'project' && !empty($conf->projet->dir_output)) { + // Wrapping pour les projets if ($fuser->rights->projet->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } @@ -2586,29 +2596,29 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } $original_file = $conf->projet->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."projet WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('project').")"; - } // Wrapping pour les commandes fournisseurs - elseif (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output)) { + } elseif (($modulepart == 'commande_fournisseur' || $modulepart == 'order_supplier') && !empty($conf->fournisseur->commande->dir_output)) { + // Wrapping pour les commandes fournisseurs if ($fuser->rights->fournisseur->commande->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->fournisseur->commande->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } // Wrapping pour les factures fournisseurs - elseif (($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') && !empty($conf->fournisseur->facture->dir_output)) { + } elseif (($modulepart == 'facture_fournisseur' || $modulepart == 'invoice_supplier') && !empty($conf->fournisseur->facture->dir_output)) { + // Wrapping pour les factures fournisseurs if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->fournisseur->facture->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } // Wrapping pour les rapport de paiements - elseif ($modulepart == 'supplier_payment') { + } elseif ($modulepart == 'supplier_payment') { + // Wrapping pour les rapport de paiements if ($fuser->rights->fournisseur->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->fournisseur->payment->dir_output.'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."paiementfournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity; - } // Wrapping pour les rapport de paiements - elseif ($modulepart == 'facture_paiement' && !empty($conf->facture->dir_output)) { + } elseif ($modulepart == 'facture_paiement' && !empty($conf->facture->dir_output)) { + // Wrapping pour les rapport de paiements if ($fuser->rights->facture->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } @@ -2617,38 +2627,38 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } else { $original_file = $conf->facture->dir_output.'/payments/'.$original_file; } - } // Wrapping for accounting exports - elseif ($modulepart == 'export_compta' && !empty($conf->accounting->dir_output)) { + } elseif ($modulepart == 'export_compta' && !empty($conf->accounting->dir_output)) { + // Wrapping for accounting exports if ($fuser->rights->accounting->bind->write || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->accounting->dir_output.'/'.$original_file; - } // Wrapping pour les expedition - elseif (($modulepart == 'expedition' || $modulepart == 'shipment') && !empty($conf->expedition->dir_output)) { + } elseif (($modulepart == 'expedition' || $modulepart == 'shipment') && !empty($conf->expedition->dir_output)) { + // Wrapping pour les expedition if ($fuser->rights->expedition->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->expedition->dir_output."/sending/".$original_file; - } // Delivery Note Wrapping - elseif (($modulepart == 'livraison' || $modulepart == 'delivery') && !empty($conf->expedition->dir_output)) { + } elseif (($modulepart == 'livraison' || $modulepart == 'delivery') && !empty($conf->expedition->dir_output)) { + // Delivery Note Wrapping if ($fuser->rights->expedition->delivery->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->expedition->dir_output."/receipt/".$original_file; - } // Wrapping pour les actions - elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { + } elseif ($modulepart == 'actions' && !empty($conf->agenda->dir_output)) { + // Wrapping pour les actions if ($fuser->rights->agenda->myactions->{$read} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->agenda->dir_output.'/'.$original_file; - } // Wrapping pour les actions - elseif ($modulepart == 'actionsreport' && !empty($conf->agenda->dir_temp)) { + } elseif ($modulepart == 'actionsreport' && !empty($conf->agenda->dir_temp)) { + // Wrapping pour les actions if ($fuser->rights->agenda->allactions->{$read} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->agenda->dir_temp."/".$original_file; - } // Wrapping pour les produits et services - elseif ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') { + } elseif ($modulepart == 'product' || $modulepart == 'produit' || $modulepart == 'service' || $modulepart == 'produit|service') { + // Wrapping pour les produits et services if (empty($entity) || (empty($conf->product->multidir_output[$entity]) && empty($conf->service->multidir_output[$entity]))) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } @@ -2660,8 +2670,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } elseif (!empty($conf->service->enabled)) { $original_file = $conf->service->multidir_output[$entity].'/'.$original_file; } - } // Wrapping pour les lots produits - elseif ($modulepart == 'product_batch' || $modulepart == 'produitlot') { + } elseif ($modulepart == 'product_batch' || $modulepart == 'produitlot') { + // Wrapping pour les lots produits if (empty($entity) || (empty($conf->productbatch->multidir_output[$entity]))) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } @@ -2671,8 +2681,8 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (!empty($conf->productbatch->enabled)) { $original_file = $conf->productbatch->multidir_output[$entity].'/'.$original_file; } - } // Wrapping for stock movements - elseif ($modulepart == 'movement' || $modulepart == 'mouvement') { + } elseif ($modulepart == 'movement' || $modulepart == 'mouvement') { + // Wrapping for stock movements if (empty($entity) || empty($conf->stock->multidir_output[$entity])) { return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); } @@ -2682,89 +2692,89 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (!empty($conf->stock->enabled)) { $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file; } - } // Wrapping pour les contrats - elseif ($modulepart == 'contract' && !empty($conf->contrat->multidir_output[$entity])) { + } elseif ($modulepart == 'contract' && !empty($conf->contrat->multidir_output[$entity])) { + // Wrapping pour les contrats if ($fuser->rights->contrat->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->contrat->multidir_output[$entity].'/'.$original_file; $sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."contrat WHERE ref='".$db->escape($refname)."' AND entity IN (".getEntity('contract').")"; - } // Wrapping pour les dons - elseif ($modulepart == 'donation' && !empty($conf->don->dir_output)) { + } elseif ($modulepart == 'donation' && !empty($conf->don->dir_output)) { + // Wrapping pour les dons if ($fuser->rights->don->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->don->dir_output.'/'.$original_file; - } // Wrapping pour les dons - elseif ($modulepart == 'dolresource' && !empty($conf->resource->dir_output)) { + } elseif ($modulepart == 'dolresource' && !empty($conf->resource->dir_output)) { + // Wrapping pour les dons if ($fuser->rights->resource->{$read} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->resource->dir_output.'/'.$original_file; - } // Wrapping pour les remises de cheques - elseif ($modulepart == 'remisecheque' && !empty($conf->bank->dir_output)) { + } elseif ($modulepart == 'remisecheque' && !empty($conf->bank->dir_output)) { + // Wrapping pour les remises de cheques if ($fuser->rights->banque->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->bank->dir_output.'/checkdeposits/'.$original_file; // original_file should contains relative path so include the get_exdir result - } // Wrapping for bank - elseif (($modulepart == 'banque' || $modulepart == 'bank') && !empty($conf->bank->dir_output)) { + } elseif (($modulepart == 'banque' || $modulepart == 'bank') && !empty($conf->bank->dir_output)) { + // Wrapping for bank if ($fuser->rights->banque->{$lire}) { $accessallowed = 1; } $original_file = $conf->bank->dir_output.'/'.$original_file; - } // Wrapping for export module - elseif ($modulepart == 'export' && !empty($conf->export->dir_temp)) { + } elseif ($modulepart == 'export' && !empty($conf->export->dir_temp)) { + // Wrapping for export module // Aucun test necessaire car on force le rep de download sur // le rep export qui est propre a l'utilisateur $accessallowed = 1; $original_file = $conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file; - } // Wrapping for import module - elseif ($modulepart == 'import' && !empty($conf->import->dir_temp)) { + } elseif ($modulepart == 'import' && !empty($conf->import->dir_temp)) { + // Wrapping for import module $accessallowed = 1; $original_file = $conf->import->dir_temp.'/'.$original_file; - } // Wrapping pour l'editeur wysiwyg - elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { + } elseif ($modulepart == 'editor' && !empty($conf->fckeditor->dir_output)) { + // Wrapping pour l'editeur wysiwyg $accessallowed = 1; $original_file = $conf->fckeditor->dir_output.'/'.$original_file; - } // Wrapping for backups - elseif ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { + } elseif ($modulepart == 'systemtools' && !empty($conf->admin->dir_output)) { + // Wrapping for backups if ($fuser->admin) { $accessallowed = 1; } $original_file = $conf->admin->dir_output.'/'.$original_file; - } // Wrapping for upload file test - elseif ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp)) { + } elseif ($modulepart == 'admin_temp' && !empty($conf->admin->dir_temp)) { + // Wrapping for upload file test if ($fuser->admin) { $accessallowed = 1; } $original_file = $conf->admin->dir_temp.'/'.$original_file; - } // Wrapping pour BitTorrent - elseif ($modulepart == 'bittorrent' && !empty($conf->bittorrent->dir_output)) { + } elseif ($modulepart == 'bittorrent' && !empty($conf->bittorrent->dir_output)) { + // Wrapping pour BitTorrent $accessallowed = 1; $dir = 'files'; if (dol_mimetype($original_file) == 'application/x-bittorrent') { $dir = 'torrents'; } $original_file = $conf->bittorrent->dir_output.'/'.$dir.'/'.$original_file; - } // Wrapping pour Foundation module - elseif ($modulepart == 'member' && !empty($conf->adherent->dir_output)) { + } elseif ($modulepart == 'member' && !empty($conf->adherent->dir_output)) { + // Wrapping pour Foundation module if ($fuser->rights->adherent->{$lire} || preg_match('/^specimen/i', $original_file)) { $accessallowed = 1; } $original_file = $conf->adherent->dir_output.'/'.$original_file; - } // Wrapping for Scanner - elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { + } elseif ($modulepart == 'scanner_user_temp' && !empty($conf->scanner->dir_temp)) { + // Wrapping for Scanner $accessallowed = 1; $original_file = $conf->scanner->dir_temp.'/'.$fuser->id.'/'.$original_file; - } // GENERIC Wrapping - // If modulepart=module_user_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser - // If modulepart=module_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp - // If modulepart=module_user Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser - // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart - // If modulepart=module-abc Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart - else { + // If modulepart=module_user_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp/iduser + // If modulepart=module_temp Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/temp + // If modulepart=module_user Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart/iduser + // If modulepart=module Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart + // If modulepart=module-abc Allows any module to open a file if file is in directory called DOL_DATA_ROOT/modulepart + } else { + // GENERIC Wrapping //var_dump($modulepart); //var_dump($original_file); if (preg_match('/^specimen/i', $original_file)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e296fa5874e..801750beef8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -200,31 +200,39 @@ function getBrowserInfo($user_agent) // Name $reg = array(); if (preg_match('/firefox(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { - $name = 'firefox'; $version = $reg[2]; + $name = 'firefox'; + $version = $reg[2]; } elseif (preg_match('/edge(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { - $name = 'edge'; $version = $reg[2]; + $name = 'edge'; + $version = $reg[2]; } elseif (preg_match('/chrome(\/|\s)([\d\.]+)/i', $user_agent, $reg)) { - $name = 'chrome'; $version = $reg[2]; - } // we can have 'chrome (Mozilla...) chrome x.y' in one string - elseif (preg_match('/chrome/i', $user_agent, $reg)) { + $name = 'chrome'; + $version = $reg[2]; + } elseif (preg_match('/chrome/i', $user_agent, $reg)) { + // we can have 'chrome (Mozilla...) chrome x.y' in one string $name = 'chrome'; } elseif (preg_match('/iceweasel/i', $user_agent)) { $name = 'iceweasel'; } elseif (preg_match('/epiphany/i', $user_agent)) { $name = 'epiphany'; } elseif (preg_match('/safari(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { - $name = 'safari'; $version = $reg[2]; - } // Safari is often present in string for mobile but its not. - elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { - $name = 'opera'; $version = $reg[2]; + $name = 'safari'; + $version = $reg[2]; + } elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { + // Safari is often present in string for mobile but its not. + $name = 'opera'; + $version = $reg[2]; } elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { - $name = 'ie'; $version = end($reg); - } // MS products at end - elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { - $name = 'ie'; $version = end($reg); - } // MS products at end - elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { - $name = 'lynxlinks'; $version = $reg[4]; + $name = 'ie'; + $version = end($reg); + } elseif (preg_match('/(Windows NT\s([0-9]+\.[0-9])).*(Trident\/[0-9]+.[0-9];.*rv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { + // MS products at end + $name = 'ie'; + $version = end($reg); + } elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { + // MS products at end + $name = 'lynxlinks'; + $version = $reg[4]; } if ($tablet) { @@ -253,9 +261,11 @@ function getBrowserInfo($user_agent) function dol_shutdown() { global $conf, $user, $langs, $db; - $disconnectdone = false; $depth = 0; + $disconnectdone = false; + $depth = 0; if (is_object($db) && !empty($db->connected)) { - $depth = $db->transaction_opened; $disconnectdone = $db->close(); + $depth = $db->transaction_opened; + $disconnectdone = $db->close(); } dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ?LOG_WARNING:LOG_INFO)); } @@ -393,8 +403,9 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) { $out = $_SESSION['lastsearch_limit_'.$relativepathstring]; } - } // Else, retrieve default values if we are not doing a sort - elseif (!isset($_GET['sortfield'])) { // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set + } elseif (!isset($_GET['sortfield'])) { + // Else, retrieve default values if we are not doing a sort + // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set if (!empty($_GET['action']) && $_GET['action'] == 'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { // Search default value from $object->field global $object; @@ -435,12 +446,15 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null } } } - } // Management of default search_filters and sort order - elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { - if (!empty($user->default_values)) { // $user->default_values defined from menu 'Setup - Default values' + } elseif (!empty($paramname) && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) { + // Management of default search_filters and sort order + if (!empty($user->default_values)) { + // $user->default_values defined from menu 'Setup - Default values' //var_dump($user->default_values[$relativepathstring]); - if ($paramname == 'sortfield' || $paramname == 'sortorder') { // Sorted on which fields ? ASC or DESC ? - if (isset($user->default_values[$relativepathstring]['sortorder'])) { // Even if paramname is sortfield, data are stored into ['sortorder...'] + if ($paramname == 'sortfield' || $paramname == 'sortorder') { + // Sorted on which fields ? ASC or DESC ? + if (isset($user->default_values[$relativepathstring]['sortorder'])) { + // Even if paramname is sortfield, data are stored into ['sortorder...'] foreach ($user->default_values[$relativepathstring]['sortorder'] as $defkey => $defval) { $qualified = 0; if ($defkey != '_noquery_') { @@ -524,9 +538,11 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text. if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) { $reg = array(); - $maxloop = 20; $loopnb = 0; // Protection against infinite loop + $maxloop = 20; + $loopnb = 0; // Protection against infinite loop while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) { // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side. - $loopnb++; $newout = ''; + $loopnb++; + $newout = ''; if ($reg[1] == 'DAY') { $tmp = dol_getdate(dol_now(), true); @@ -837,13 +853,14 @@ function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0) } } } - if ($returnemptyifnotfound) { // Not found into alternate dir + if ($returnemptyifnotfound) { + // Not found into alternate dir if ($returnemptyifnotfound == 1 || !file_exists($res)) { return ''; } } - } else // For an url path - { + } else { + // For an url path // We try to get local path of file on filesystem from url // Note that trying to know if a file on disk exist by forging path on disk from url // works only for some web server and some setup. This is bugged when @@ -1095,16 +1112,19 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0) $substitjs = array("'"=>"\\'", "\r"=>'\\r'); //$substitjs[' '.$data['ip']; } - } // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) - elseif (!empty($_SERVER['SERVER_ADDR'])) { + } elseif (!empty($_SERVER['SERVER_ADDR'])) { + // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) $data['ip'] = $_SERVER['SERVER_ADDR']; - } - // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). - elseif (!empty($_SERVER['COMPUTERNAME'])) { + } elseif (!empty($_SERVER['COMPUTERNAME'])) { + // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME']) ? '' : '@'.$_SERVER['USERNAME']); - } - // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). - elseif (!empty($_SERVER['LOGNAME'])) { + } elseif (!empty($_SERVER['LOGNAME'])) { + // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). $data['ip'] = '???@'.$_SERVER['LOGNAME']; } // Loop on each log handler and send output @@ -1694,7 +1712,8 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } if ($object->element == 'product') { - $width = 80; $cssclass = 'photoref'; + $width = 80; + $cssclass = 'photoref'; $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); if ($conf->browser->layout == 'phone') { @@ -1712,7 +1731,8 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } } elseif ($object->element == 'ticket') { - $width = 80; $cssclass = 'photoref'; + $width = 80; + $cssclass = 'photoref'; $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->ref); $maxvisiblephotos = (isset($conf->global->TICKET_MAX_VISIBLE_PHOTO) ? $conf->global->TICKET_MAX_VISIBLE_PHOTO : 2); if ($conf->browser->layout == 'phone') { @@ -1812,7 +1832,8 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $cssclass = 'photorefcenter'; $nophoto = img_picto('No photo', 'title_agenda'); } else { - $width = 14; $cssclass = 'photorefcenter'; + $width = 14; + $cssclass = 'photorefcenter'; $picto = $object->picto; if ($object->element == 'project' && !$object->public) { $picto = 'project'; // instead of projectpub @@ -2000,7 +2021,8 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : $object->address); } // Zip/Town/State - if (isset($object->country_code) && in_array($object->country_code, array('AU', 'CA', 'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) { // US: title firstname name \n address lines \n town, state, zip \n country + if (isset($object->country_code) && in_array($object->country_code, array('AU', 'CA', 'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) { + // US: title firstname name \n address lines \n town, state, zip \n country $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : $object->town); $ret .= ($ret ? $sep : '').$town; if (!empty($object->state)) { @@ -2009,7 +2031,8 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs if ($object->zip) { $ret .= ($ret ? ", " : '').$object->zip; } - } elseif (isset($object->country_code) && in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country + } elseif (isset($object->country_code) && in_array($object->country_code, array('GB', 'UK'))) { + // UK: title firstname name \n address lines \n town state \n zip \n country $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : $object->town); $ret .= ($ret ? $sep : '').$town; if (!empty($object->state)) { @@ -2018,14 +2041,16 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs if ($object->zip) { $ret .= ($ret ? $sep : '').$object->zip; } - } elseif (isset($object->country_code) && in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country + } elseif (isset($object->country_code) && in_array($object->country_code, array('ES', 'TR'))) { + // ES: title firstname name \n address lines \n zip town \n state \n country $ret .= ($ret ? $sep : '').$object->zip; $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : $object->town); $ret .= ($town ? (($object->zip ? ' ' : '').$town) : ''); if (!empty($object->state)) { $ret .= "\n".$object->state; } - } elseif (isset($object->country_code) && in_array($object->country_code, array('IT'))) { // IT: tile firstname name\n address lines \n zip (Code Departement) \n country + } elseif (isset($object->country_code) && in_array($object->country_code, array('IT'))) { + // IT: tile firstname name\n address lines \n zip (Code Departement) \n country $ret .= ($ret ? $sep : '').$object->zip; $town = ($extralangcode ? $object->array_languages['town'][$extralangcode] : $object->town); $ret .= ($town ? (($object->zip ? ' ' : '').$town) : ''); @@ -2129,7 +2154,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $format = preg_replace('/inputnoreduce/', '', $format); // so format 'dayinputnoreduce' is processed like day $formatwithoutreduce = preg_replace('/reduceformat/', '', $format); if ($formatwithoutreduce != $format) { - $format = $formatwithoutreduce; $reduceformat = 1; + $format = $formatwithoutreduce; + $reduceformat = 1; } // so format 'dayreduceformat' is processed like day // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. @@ -2152,9 +2178,8 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); } elseif ($format == 'dayhourtextshort') { $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); - } - // Format not sensitive to language - elseif ($format == 'dayhourlog') { + } elseif ($format == 'dayhourlog') { + // Format not sensitive to language $format = '%Y%m%d%H%M%S'; } elseif ($format == 'dayhourldap') { $format = '%Y%m%d%H%M%SZ'; @@ -2440,13 +2465,13 @@ function dol_now($mode = 'auto') require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time $ret = (int) (dol_now('gmt') + ($tzsecond * 3600)); - } /*elseif ($mode == 'tzref') // Time for now with parent company timezone is added - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time - $ret=dol_now('gmt')+($tzsecond*3600); - }*/ - elseif ($mode == 'tzuser' || $mode == 'tzuserrel') { // Time for now with user timezone added + //} elseif ($mode == 'tzref') {// Time for now with parent company timezone is added + // require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + // $tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time + // $ret=dol_now('gmt')+($tzsecond*3600); + //} + } elseif ($mode == 'tzuser' || $mode == 'tzuserrel') { + // Time for now with user timezone added //print 'time: '.time(); $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; @@ -2570,7 +2595,8 @@ function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, } if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - $type = 'AC_EMAIL'; $link = ''; + $type = 'AC_EMAIL'; + $link = ''; if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) { $link = ''.img_object($langs->trans("AddAction"), "calendar").''; } @@ -2938,7 +2964,8 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli //if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { - $type = 'AC_TEL'; $link = ''; + $type = 'AC_TEL'; + $link = ''; if ($addlink == 'AC_FAX') { $type = 'AC_FAX'; } @@ -3453,7 +3480,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ $pictowithouttext = str_replace('object_', '', $pictowithouttext); $fakey = $pictowithouttext; - $facolor = ''; $fasize = ''; + $facolor = ''; + $fasize = ''; $fa = 'fas'; if (in_array($pictowithouttext, array('clock', 'generic', 'minus-square', 'object_generic', 'pdf', 'plus-square', 'timespent', 'note', 'off', 'on', 'object_bookmark', 'bookmark', 'vcard'))) { $fa = 'far'; @@ -5011,7 +5039,8 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $ $nbdecimal = $rounding; // Output separators by default (french) - $dec = ','; $thousand = ' '; + $dec = ','; + $thousand = ' '; // If $outlangs not forced, we use use language if (!is_object($outlangs)) { @@ -5113,7 +5142,8 @@ function price2num($amount, $rounding = '', $option = 0) // Round PHP function does not allow number like '1,234.56' nor '1.234,56' nor '1 234,56' // Numbers must be '1234.56' // Decimal delimiter for PHP and database SQL requests must be '.' - $dec = ','; $thousand = ' '; + $dec = ','; + $thousand = ' '; if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { $dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); } @@ -5904,7 +5934,8 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id function yn($yesno, $case = 1, $color = 0) { global $langs; - $result = 'unknown'; $classname = ''; + $result = 'unknown'; + $classname = ''; if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') { // A mettre avant test sur no a cause du == 0 $result = $langs->trans('yes'); if ($case == 1 || $case == 3) { @@ -6254,8 +6285,8 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8') $text = strtr($text, $repTable); if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; - } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support - else { + } else { + // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. } $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); @@ -6421,9 +6452,11 @@ function dol_string_is_good_iso($s, $clean = 0) $ordchar = ord($s[$scursor]); //print $scursor.'-'.$ordchar.'
'; if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { - $ok = 0; break; + $ok = 0; + break; } elseif ($ordchar > 126 && $ordchar < 160) { - $ok = 0; break; + $ok = 0; + break; } elseif ($clean) { $out .= $s[$scursor]; } @@ -6473,8 +6506,8 @@ function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') $text = strtr($text, $repTable); if ($charset == 'UTF-8') { $pattern = '/(]*>)/Uu'; - } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support - else { + } else { + // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support $pattern = '/(]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. } $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); @@ -7413,7 +7446,8 @@ function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $ { global $conf, $langs; - $ret = 0; $return = ''; + $ret = 0; + $return = ''; $out = ''; $divstart = $divend = ''; @@ -7507,10 +7541,12 @@ function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'o if (is_array($mesgarray)) { foreach ($mesgarray as $val) { if ($val && preg_match('/class="error"/i', $val)) { - $iserror++; break; + $iserror++; + break; } if ($val && preg_match('/class="warning"/i', $val)) { - $iswarning++; break; + $iswarning++; + break; } } } elseif ($mesgstring && preg_match('/class="error"/i', $mesgstring)) { @@ -8515,7 +8551,8 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $j = 0; foreach ($crits as $crit) { $crit = trim($crit); - $i = 0; $i2 = 0; + $i = 0; + $i2 = 0; $newres = ''; foreach ($fields as $field) { if ($mode == 1) { @@ -8595,7 +8632,8 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $tmpcrit = trim($tmpcrit); $tmpcrit2 = $tmpcrit; - $tmpbefore = '%'; $tmpafter = '%'; + $tmpbefore = '%'; + $tmpafter = '%'; if (preg_match('/^[\^\$]/', $tmpcrit)) { $tmpbefore = ''; $tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2); @@ -8810,209 +8848,357 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) // Plain text files if (preg_match('/\.txt$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $famime = 'file-text-o'; } if (preg_match('/\.rtx$/i', $tmpfile)) { - $mime = 'text/richtext'; $imgmime = 'text.png'; $famime = 'file-text-o'; + $mime = 'text/richtext'; + $imgmime = 'text.png'; + $famime = 'file-text-o'; } if (preg_match('/\.csv$/i', $tmpfile)) { - $mime = 'text/csv'; $imgmime = 'text.png'; $famime = 'file-text-o'; + $mime = 'text/csv'; + $imgmime = 'text.png'; + $famime = 'file-text-o'; } if (preg_match('/\.tsv$/i', $tmpfile)) { - $mime = 'text/tab-separated-values'; $imgmime = 'text.png'; $famime = 'file-text-o'; + $mime = 'text/tab-separated-values'; + $imgmime = 'text.png'; + $famime = 'file-text-o'; } if (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $famime = 'file-text-o'; } if (preg_match('/\.ini$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'ini'; $famime = 'file-text-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'ini'; + $famime = 'file-text-o'; } if (preg_match('/\.md$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'md'; $famime = 'file-text-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'md'; + $famime = 'file-text-o'; } if (preg_match('/\.css$/i', $tmpfile)) { - $mime = 'text/css'; $imgmime = 'css.png'; $srclang = 'css'; $famime = 'file-text-o'; + $mime = 'text/css'; + $imgmime = 'css.png'; + $srclang = 'css'; + $famime = 'file-text-o'; } if (preg_match('/\.lang$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'lang'; $famime = 'file-text-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'lang'; + $famime = 'file-text-o'; } // Certificate files if (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $famime = 'file-text-o'; } // XML based (HTML/XML/XAML) if (preg_match('/\.(html|htm|shtml)$/i', $tmpfile)) { - $mime = 'text/html'; $imgmime = 'html.png'; $srclang = 'html'; $famime = 'file-text-o'; + $mime = 'text/html'; + $imgmime = 'html.png'; + $srclang = 'html'; + $famime = 'file-text-o'; } if (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { - $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xml'; $famime = 'file-text-o'; + $mime = 'text/xml'; + $imgmime = 'other.png'; + $srclang = 'xml'; + $famime = 'file-text-o'; } if (preg_match('/\.xaml$/i', $tmpfile)) { - $mime = 'text/xml'; $imgmime = 'other.png'; $srclang = 'xaml'; $famime = 'file-text-o'; + $mime = 'text/xml'; + $imgmime = 'other.png'; + $srclang = 'xaml'; + $famime = 'file-text-o'; } // Languages if (preg_match('/\.bas$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'bas'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'bas'; + $famime = 'file-code-o'; } if (preg_match('/\.(c)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'c'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'c'; + $famime = 'file-code-o'; } if (preg_match('/\.(cpp)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cpp'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'cpp'; + $famime = 'file-code-o'; } if (preg_match('/\.cs$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'cs'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'cs'; + $famime = 'file-code-o'; } if (preg_match('/\.(h)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'h'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'h'; + $famime = 'file-code-o'; } if (preg_match('/\.(java|jsp)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'java'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'java'; + $famime = 'file-code-o'; } if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'php.png'; + $srclang = 'php'; + $famime = 'file-code-o'; } if (preg_match('/\.phtml$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'php.png'; + $srclang = 'php'; + $famime = 'file-code-o'; } if (preg_match('/\.(pl|pm)$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'pl.png'; $srclang = 'perl'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'pl.png'; + $srclang = 'perl'; + $famime = 'file-code-o'; } if (preg_match('/\.sql$/i', $tmpfile)) { - $mime = 'text/plain'; $imgmime = 'text.png'; $srclang = 'sql'; $famime = 'file-code-o'; + $mime = 'text/plain'; + $imgmime = 'text.png'; + $srclang = 'sql'; + $famime = 'file-code-o'; } if (preg_match('/\.js$/i', $tmpfile)) { - $mime = 'text/x-javascript'; $imgmime = 'jscript.png'; $srclang = 'js'; $famime = 'file-code-o'; + $mime = 'text/x-javascript'; + $imgmime = 'jscript.png'; + $srclang = 'js'; + $famime = 'file-code-o'; } // Open office if (preg_match('/\.odp$/i', $tmpfile)) { - $mime = 'application/vnd.oasis.opendocument.presentation'; $imgmime = 'ooffice.png'; $famime = 'file-powerpoint-o'; + $mime = 'application/vnd.oasis.opendocument.presentation'; + $imgmime = 'ooffice.png'; + $famime = 'file-powerpoint-o'; } if (preg_match('/\.ods$/i', $tmpfile)) { - $mime = 'application/vnd.oasis.opendocument.spreadsheet'; $imgmime = 'ooffice.png'; $famime = 'file-excel-o'; + $mime = 'application/vnd.oasis.opendocument.spreadsheet'; + $imgmime = 'ooffice.png'; + $famime = 'file-excel-o'; } if (preg_match('/\.odt$/i', $tmpfile)) { - $mime = 'application/vnd.oasis.opendocument.text'; $imgmime = 'ooffice.png'; $famime = 'file-word-o'; + $mime = 'application/vnd.oasis.opendocument.text'; + $imgmime = 'ooffice.png'; + $famime = 'file-word-o'; } // MS Office if (preg_match('/\.mdb$/i', $tmpfile)) { - $mime = 'application/msaccess'; $imgmime = 'mdb.png'; $famime = 'file-o'; + $mime = 'application/msaccess'; + $imgmime = 'mdb.png'; + $famime = 'file-o'; } if (preg_match('/\.doc(x|m)?$/i', $tmpfile)) { - $mime = 'application/msword'; $imgmime = 'doc.png'; $famime = 'file-word-o'; + $mime = 'application/msword'; + $imgmime = 'doc.png'; + $famime = 'file-word-o'; } if (preg_match('/\.dot(x|m)?$/i', $tmpfile)) { - $mime = 'application/msword'; $imgmime = 'doc.png'; $famime = 'file-word-o'; + $mime = 'application/msword'; + $imgmime = 'doc.png'; + $famime = 'file-word-o'; } if (preg_match('/\.xlt(x)?$/i', $tmpfile)) { - $mime = 'application/vnd.ms-excel'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; + $mime = 'application/vnd.ms-excel'; + $imgmime = 'xls.png'; + $famime = 'file-excel-o'; } if (preg_match('/\.xla(m)?$/i', $tmpfile)) { - $mime = 'application/vnd.ms-excel'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; + $mime = 'application/vnd.ms-excel'; + $imgmime = 'xls.png'; + $famime = 'file-excel-o'; } if (preg_match('/\.xls$/i', $tmpfile)) { - $mime = 'application/vnd.ms-excel'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; + $mime = 'application/vnd.ms-excel'; + $imgmime = 'xls.png'; + $famime = 'file-excel-o'; } if (preg_match('/\.xls(b|m|x)$/i', $tmpfile)) { - $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime = 'xls.png'; $famime = 'file-excel-o'; + $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + $imgmime = 'xls.png'; + $famime = 'file-excel-o'; } if (preg_match('/\.pps(m|x)?$/i', $tmpfile)) { - $mime = 'application/vnd.ms-powerpoint'; $imgmime = 'ppt.png'; $famime = 'file-powerpoint-o'; + $mime = 'application/vnd.ms-powerpoint'; + $imgmime = 'ppt.png'; + $famime = 'file-powerpoint-o'; } if (preg_match('/\.ppt(m|x)?$/i', $tmpfile)) { - $mime = 'application/x-mspowerpoint'; $imgmime = 'ppt.png'; $famime = 'file-powerpoint-o'; + $mime = 'application/x-mspowerpoint'; + $imgmime = 'ppt.png'; + $famime = 'file-powerpoint-o'; } // Other if (preg_match('/\.pdf$/i', $tmpfile)) { - $mime = 'application/pdf'; $imgmime = 'pdf.png'; $famime = 'file-pdf-o'; + $mime = 'application/pdf'; + $imgmime = 'pdf.png'; + $famime = 'file-pdf-o'; } // Scripts if (preg_match('/\.bat$/i', $tmpfile)) { - $mime = 'text/x-bat'; $imgmime = 'script.png'; $srclang = 'dos'; $famime = 'file-code-o'; + $mime = 'text/x-bat'; + $imgmime = 'script.png'; + $srclang = 'dos'; + $famime = 'file-code-o'; } if (preg_match('/\.sh$/i', $tmpfile)) { - $mime = 'text/x-sh'; $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; + $mime = 'text/x-sh'; + $imgmime = 'script.png'; + $srclang = 'bash'; + $famime = 'file-code-o'; } if (preg_match('/\.ksh$/i', $tmpfile)) { - $mime = 'text/x-ksh'; $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; + $mime = 'text/x-ksh'; + $imgmime = 'script.png'; + $srclang = 'bash'; + $famime = 'file-code-o'; } if (preg_match('/\.bash$/i', $tmpfile)) { - $mime = 'text/x-bash'; $imgmime = 'script.png'; $srclang = 'bash'; $famime = 'file-code-o'; + $mime = 'text/x-bash'; + $imgmime = 'script.png'; + $srclang = 'bash'; + $famime = 'file-code-o'; } // Images if (preg_match('/\.ico$/i', $tmpfile)) { - $mime = 'image/x-icon'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/x-icon'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.(jpg|jpeg)$/i', $tmpfile)) { - $mime = 'image/jpeg'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/jpeg'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.png$/i', $tmpfile)) { - $mime = 'image/png'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/png'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.gif$/i', $tmpfile)) { - $mime = 'image/gif'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/gif'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.bmp$/i', $tmpfile)) { - $mime = 'image/bmp'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/bmp'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.(tif|tiff)$/i', $tmpfile)) { - $mime = 'image/tiff'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/tiff'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.svg$/i', $tmpfile)) { - $mime = 'image/svg+xml'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/svg+xml'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } if (preg_match('/\.webp$/i', $tmpfile)) { - $mime = 'image/webp'; $imgmime = 'image.png'; $famime = 'file-image-o'; + $mime = 'image/webp'; + $imgmime = 'image.png'; + $famime = 'file-image-o'; } // Calendar if (preg_match('/\.vcs$/i', $tmpfile)) { - $mime = 'text/calendar'; $imgmime = 'other.png'; $famime = 'file-text-o'; + $mime = 'text/calendar'; + $imgmime = 'other.png'; + $famime = 'file-text-o'; } if (preg_match('/\.ics$/i', $tmpfile)) { - $mime = 'text/calendar'; $imgmime = 'other.png'; $famime = 'file-text-o'; + $mime = 'text/calendar'; + $imgmime = 'other.png'; + $famime = 'file-text-o'; } // Other if (preg_match('/\.torrent$/i', $tmpfile)) { - $mime = 'application/x-bittorrent'; $imgmime = 'other.png'; $famime = 'file-o'; + $mime = 'application/x-bittorrent'; + $imgmime = 'other.png'; + $famime = 'file-o'; } // Audio if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i', $tmpfile)) { - $mime = 'audio'; $imgmime = 'audio.png'; $famime = 'file-audio-o'; + $mime = 'audio'; + $imgmime = 'audio.png'; + $famime = 'file-audio-o'; } // Video if (preg_match('/\.ogv$/i', $tmpfile)) { - $mime = 'video/ogg'; $imgmime = 'video.png'; $famime = 'file-video-o'; + $mime = 'video/ogg'; + $imgmime = 'video.png'; + $famime = 'file-video-o'; } if (preg_match('/\.webm$/i', $tmpfile)) { - $mime = 'video/webm'; $imgmime = 'video.png'; $famime = 'file-video-o'; + $mime = 'video/webm'; + $imgmime = 'video.png'; + $famime = 'file-video-o'; } if (preg_match('/\.avi$/i', $tmpfile)) { - $mime = 'video/x-msvideo'; $imgmime = 'video.png'; $famime = 'file-video-o'; + $mime = 'video/x-msvideo'; + $imgmime = 'video.png'; + $famime = 'file-video-o'; } if (preg_match('/\.divx$/i', $tmpfile)) { - $mime = 'video/divx'; $imgmime = 'video.png'; $famime = 'file-video-o'; + $mime = 'video/divx'; + $imgmime = 'video.png'; + $famime = 'file-video-o'; } if (preg_match('/\.xvid$/i', $tmpfile)) { - $mime = 'video/xvid'; $imgmime = 'video.png'; $famime = 'file-video-o'; + $mime = 'video/xvid'; + $imgmime = 'video.png'; + $famime = 'file-video-o'; } if (preg_match('/\.(wmv|mpg|mpeg)$/i', $tmpfile)) { - $mime = 'video'; $imgmime = 'video.png'; $famime = 'file-video-o'; + $mime = 'video'; + $imgmime = 'video.png'; + $famime = 'file-video-o'; } // Archive if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh)$/i', $tmpfile)) { - $mime = 'archive'; $imgmime = 'archive.png'; $famime = 'file-archive-o'; + $mime = 'archive'; + $imgmime = 'archive.png'; + $famime = 'file-archive-o'; } // application/xxx where zzz is zip, ... // Exe if (preg_match('/\.(exe|com)$/i', $tmpfile)) { - $mime = 'application/octet-stream'; $imgmime = 'other.png'; $famime = 'file-o'; + $mime = 'application/octet-stream'; + $imgmime = 'other.png'; + $famime = 'file-o'; } // Lib if (preg_match('/\.(dll|lib|o|so|a)$/i', $tmpfile)) { - $mime = 'library'; $imgmime = 'library.png'; $famime = 'file-o'; + $mime = 'library'; + $imgmime = 'library.png'; + $famime = 'file-o'; } // Err if (preg_match('/\.err$/i', $tmpfile)) { - $mime = 'error'; $imgmime = 'error.png'; $famime = 'file-text-o'; + $mime = 'error'; + $imgmime = 'error.png'; + $famime = 'file-text-o'; } // Return string @@ -9129,7 +9315,8 @@ function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal $found = 0; foreach ($tmploops as $tmploop) { if (in_array($tmploop, $listofmodulesforexternal)) { - $found++; break; + $found++; + break; } } if (!$found) { @@ -9251,8 +9438,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st $return = !empty($html) ? $html : (empty($conf->dol_optimize_smallscreen) ? $statusLabel : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort)); } elseif ($displayMode == 1) { $return = !empty($html) ? $html : (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); - } // Use status with images (for backward compatibility) - elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) { + } elseif (!empty($conf->global->MAIN_STATUS_USES_IMAGES)) { + // Use status with images (for backward compatibility) $return = ''; $htmlLabel = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : $statusLabel).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); $htmlLabelShort = (in_array($displayMode, array(1, 2, 5)) ? '' : '').(!empty($html) ? $html : (!empty($statusLabelShort) ? $statusLabelShort : $statusLabel)).(in_array($displayMode, array(1, 2, 5)) ? '' : ''); @@ -9299,8 +9486,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st } else { // $displayMode >= 6 $return = $htmlLabel.' '.$htmlImg; } - } // Use new badge - elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) { + } elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) { + // Use new badge $statusLabelShort = (empty($statusLabelShort) ? $statusLabel : $statusLabelShort); $dolGetBadgeParams['attr']['class'] = 'badge-status'; @@ -9857,17 +10044,15 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1) // Solution 0 if ($method == 0) { readfile($fullpath_original_file_osencoded); - } - // Solution 1 - elseif ($method == 1) { + } elseif ($method == 1) { + // Solution 1 $handle = fopen($fullpath_original_file_osencoded, "rb"); while (!feof($handle)) { print fread($handle, 8192); } fclose($handle); - } - // Solution 2 - elseif ($method == 2) { + } elseif ($method == 2) { + // Solution 2 $handle1 = fopen($fullpath_original_file_osencoded, "rb"); $handle2 = fopen("php://output", "wb"); stream_copy_to_stream($handle1, $handle2); diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 2e81af654cf..9fd7f5e7e8a 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1090,9 +1090,11 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ // Define posy, posm and reg if ($maskraz > 1) { // if reset is not first month, we need month and year into mask if (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { - $posy = 2; $posm = 3; + $posy = 2; + $posm = 3; } elseif (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { - $posy = 3; $posm = 2; + $posy = 3; + $posm = 2; } else { return 'ErrorCantUseRazInStartedYearIfNoYearMonthInMask'; } @@ -1103,11 +1105,14 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } else // if reset is for a specific month in year, we need year { if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { - $posy = 3; $posm = 2; + $posy = 3; + $posm = 2; } elseif (preg_match('/^(.*)\{(y+)\}\{(m+)\}/i', $maskwithonlyymcode, $reg)) { - $posy = 2; $posm = 3; + $posy = 2; + $posm = 3; } elseif (preg_match('/^(.*)\{(y+)\}/i', $maskwithonlyymcode, $reg)) { - $posy = 2; $posm = 0; + $posy = 2; + $posm = 0; } else { return 'ErrorCantUseRazIfNoYearInMask'; } @@ -1892,7 +1897,8 @@ function getListOfModels($db, $type, $maxfilenamelength = 0) $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (is_dir($tmpdir)) { // all type of template is allowed @@ -2128,7 +2134,8 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') } // Generic case for $classfile and $classname - $classfile = strtolower($myobject); $classname = ucfirst($myobject); + $classfile = strtolower($myobject); + $classname = ucfirst($myobject); //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath; if ($objecttype == 'invoice_supplier') { @@ -2227,7 +2234,8 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent) // Check depth //print 'Analyse record id='.$id.' with parent '.$pid.'
'; - $cursor = $id; $arrayidparsed = array(); // We start from child $id + $cursor = $id; + $arrayidparsed = array(); // We start from child $id while ($cursor > 0) { $arrayidparsed[$cursor] = 1; if ($arrayidparsed[$listofparentid[$cursor]]) { // We detect a loop. A record with a parent that was already into child @@ -2627,7 +2635,8 @@ if (!function_exists('dolEscapeXML')) { function autoOrManual($automaticmanual, $case = 1, $color = 0) { global $langs; - $result = 'unknown'; $classname = ''; + $result = 'unknown'; + $classname = ''; if ($automaticmanual == 1 || strtolower($automaticmanual) == 'automatic' || strtolower($automaticmanual) == 'true') { // A mettre avant test sur no a cause du == 0 $result = $langs->trans('automatic'); if ($case == 1 || $case == 3) { diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index ed7d5b1efcc..7041eabfc5e 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -23,8 +23,10 @@ */ // Define size of logo small and mini -$maxwidthsmall = 480; $maxheightsmall = 270; // Near 16/9eme -$maxwidthmini = 128; $maxheightmini = 72; // 16/9eme +$maxwidthsmall = 480; +$maxheightsmall = 270; // Near 16/9eme +$maxwidthmini = 128; +$maxheightmini = 72; // 16/9eme $quality = 80; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 9e7d4f8d55a..2bd8707f86b 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -62,7 +62,8 @@ function commande_prepare_head(Commande $object) if (($conf->expedition_bon->enabled && $user->rights->expedition->lire) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire)) { - $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; + $nbShipments = $object->getNbOfShipments(); + $nbReceiption = 0; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; $text = ''; if ($conf->expedition_bon->enabled) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 08559c3ebd6..6e2ad1c2f05 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -49,7 +49,9 @@ function pdf_getFormat(Translate $outputlangs = null, $mode = 'setup') dol_syslog("pdf_getFormat Get paper format with mode=".$mode." MAIN_PDF_FORMAT=".(empty($conf->global->MAIN_PDF_FORMAT) ? 'null' : $conf->global->MAIN_PDF_FORMAT)." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')." and langs->defaultlang=".(is_object($langs) ? $langs->defaultlang : 'null')); // Default value if setup was not done and/or entry into c_paper_format not defined - $width = 210; $height = 297; $unit = 'mm'; + $width = 210; + $height = 297; + $unit = 'mm'; if ($mode == 'auto' || empty($conf->global->MAIN_PDF_FORMAT) || $conf->global->MAIN_PDF_FORMAT == 'auto') { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; @@ -725,7 +727,8 @@ function pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text) $text = make_substitutions($text, $substitutionarray, $outputlangs); $text = $outputlangs->convToOutputCharset($text); - $savx = $pdf->getX(); $savy = $pdf->getY(); + $savx = $pdf->getX(); + $savy = $pdf->getY(); $watermark_angle = atan($h / $w) / 2; $watermark_x_pos = 0; @@ -961,7 +964,10 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } // First line of company infos - $line1 = ""; $line2 = ""; $line3 = ""; $line4 = ""; + $line1 = ""; + $line2 = ""; + $line3 = ""; + $line4 = ""; if ($showdetails == 1 || $showdetails == 3) { // Company name @@ -1086,9 +1092,11 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ if ($line) { // Free text //$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. + $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. if (!empty($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT)) { - $width = 200; $align = 'C'; + $width = 200; + $align = 'C'; } $freetextheight = $pdf->getStringHeight($width, $line); } else { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 5702240e94c..2b35c2c7779 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -1125,7 +1125,8 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec print dol_print_date($lines[$i]->timespent_datehour, 'day'); print ''; - $disabledproject = 1; $disabledtask = 1; + $disabledproject = 1; + $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); @@ -1480,7 +1481,8 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr } print "\n"; - $disabledproject = 1; $disabledtask = 1; + $disabledproject = 1; + $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); @@ -1870,7 +1872,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ } print "\n"; - $disabledproject = 1; $disabledtask = 1; + $disabledproject = 1; + $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); @@ -1887,7 +1890,8 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ //var_dump($projectstatic->weekWorkLoadPerTask); // Fields to show current time - $tableCell = ''; $modeinput = 'hours'; + $tableCell = ''; + $modeinput = 'hours'; for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); @@ -2148,7 +2152,8 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & } print "\n"; - $disabledproject = 1; $disabledtask = 1; + $disabledproject = 1; + $disabledtask = 1; //print "x".$lines[$i]->fk_project; //var_dump($lines[$i]); //var_dump($projectsrole[$lines[$i]->fk_project]); @@ -2165,7 +2170,8 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & //var_dump($projectstatic->weekWorkLoadPerTask); //TODO // Fields to show current time - $tableCell = ''; $modeinput = 'hours'; + $tableCell = ''; + $modeinput = 'hours'; $TFirstDay = getFirstDayOfEachWeek($TWeek, date('Y', $firstdaytoshow)); $TFirstDay[reset($TWeek)] = 1; foreach ($TFirstDay as &$fday) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 6b95187e5df..a4299e925df 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -207,10 +207,13 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f $features = 'adherent'; } if ($features == 'subscription') { - $features = 'adherent'; $feature2 = 'cotisation'; + $features = 'adherent'; + $feature2 = 'cotisation'; }; if ($features == 'websitepage') { - $features = 'website'; $tableandshare = 'website_page'; $parentfortableentity = 'fk_website@website'; + $features = 'website'; + $tableandshare = 'website_page'; + $parentfortableentity = 'fk_website@website'; } if ($features == 'project') { $features = 'projet'; @@ -252,48 +255,58 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f $listofmodules = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); // Check read permission from module - $readok = 1; $nbko = 0; + $readok = 1; + $nbko = 0; foreach ($featuresarray as $feature) { // first we check nb of test ko $featureforlistofmodule = $feature; if ($featureforlistofmodule == 'produit') { $featureforlistofmodule = 'product'; } if (!empty($user->socid) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users - $readok = 0; $nbko++; + $readok = 0; + $nbko++; continue; } if ($feature == 'societe') { if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'contact') { if (!$user->rights->societe->contact->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'produit|service') { if (!$user->rights->produit->lire && !$user->rights->service->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'prelevement') { if (!$user->rights->prelevement->bons->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'cheque') { if (!$user->rights->banque->cheque) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'projet') { if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'payment') { if (!$user->rights->facture->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif ($feature == 'payment_supplier') { if (!$user->rights->fournisseur->facture->lire) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } elseif (!empty($feature2)) { // This is for permissions on 2 levels $tmpreadok = 1; @@ -306,7 +319,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; } else { - $tmpreadok = 1; break; + $tmpreadok = 1; + break; } // Break is to bypass second test if the first is ok } if (!$tmpreadok) { // We found a test on feature that is ko @@ -317,7 +331,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (empty($user->rights->$feature->lire) && empty($user->rights->$feature->read) && empty($user->rights->$feature->run)) { - $readok = 0; $nbko++; + $readok = 0; + $nbko++; } } } @@ -333,7 +348,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f //print "Read access is ok"; // Check write permission from module (we need to know write permission to create but also to delete drafts record or to upload files) - $createok = 1; $nbko = 0; + $createok = 1; + $nbko = 0; $wemustcheckpermissionforcreate = (GETPOST('sendit', 'alpha') || GETPOST('linkit', 'alpha') || GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update'); $wemustcheckpermissionfordeletedraft = ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete'); @@ -341,35 +357,43 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f foreach ($featuresarray as $feature) { if ($feature == 'contact') { if (!$user->rights->societe->contact->creer) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'produit|service') { if (!$user->rights->produit->creer && !$user->rights->service->creer) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'prelevement') { if (!$user->rights->prelevement->bons->creer) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'commande_fournisseur') { if (!$user->rights->fournisseur->commande->creer) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'banque') { if (!$user->rights->banque->modifier) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'cheque') { if (!$user->rights->banque->cheque) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'import') { if (!$user->rights->import->run) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif ($feature == 'ecm') { if (!$user->rights->ecm->upload) { - $createok = 0; $nbko++; + $createok = 0; + $nbko++; } } elseif (!empty($feature2)) { // This is for permissions on one level foreach ($feature2 as $subfeature) { @@ -427,7 +451,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } // Check delete permission from module - $deleteok = 1; $nbko = 0; + $deleteok = 1; + $nbko = 0; if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') { foreach ($featuresarray as $feature) { if ($feature == 'contact') { @@ -471,7 +496,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) { $deleteok = 0; } else { - $deleteok = 1; break; + $deleteok = 1; + break; } // For bypass the second test if the first is ok } } elseif (!empty($feature)) { // This is used for permissions on 1 level @@ -622,22 +648,23 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND dbt.fk_soc = ".$user->socid; - } // If internal user: Check permission for internal users that are restricted on their objects - elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { + } elseif (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) { + // If internal user: Check permission for internal users that are restricted on their objects $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; - } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (!empty($conf->multicompany->enabled)) { + } elseif (!empty($conf->multicompany->enabled)) { + // If multicompany and internal users with all permissions, check user is in correct entity $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } - if ($feature == 'agenda') {// Also check owner or attendee for users without allactions->read + if ($feature == 'agenda') { + // Also check owner or attendee for users without allactions->read if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $action = new ActionComm($db); @@ -712,8 +739,8 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql .= " AND (sc.fk_user = ".$user->id." OR sc.fk_user IS NULL)"; } - } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (!empty($conf->multicompany->enabled)) { + } elseif (!empty($conf->multicompany->enabled)) { + // If multicompany and internal users with all permissions, check user is in correct entity $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 9181b3dd07d..523b8ccf2cb 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -179,7 +179,8 @@ if (!function_exists('dol_loginfunction')) { foreach ($dirtpls as $reldir) { $tmp = dol_buildpath($reldir.'login.tpl.php'); if (file_exists($tmp)) { - $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp); break; + $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp); + break; } } } else { @@ -322,14 +323,20 @@ function makesalt($type = CRYPT_SALT_LENGTH) dol_syslog("makesalt type=".$type); switch ($type) { case 12: // 8 + 4 - $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; + $saltlen = 8; + $saltprefix = '$1$'; + $saltsuffix = '$'; break; case 8: // 8 (Pour compatibilite, ne devrait pas etre utilise) - $saltlen = 8; $saltprefix = '$1$'; $saltsuffix = '$'; + $saltlen = 8; + $saltprefix = '$1$'; + $saltsuffix = '$'; break; case 2: // 2 default: // by default, fall back on Standard DES (should work everywhere) - $saltlen = 2; $saltprefix = ''; $saltsuffix = ''; + $saltlen = 2; + $saltprefix = ''; + $saltsuffix = ''; break; } $salt = ''; diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index a20170e3a95..255bc47d9a9 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -156,7 +156,8 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset continue; } - print ''; $ulprinted++; + print ''; + $ulprinted++; } print "\n".'
  • '; if ($showfk) { @@ -184,7 +185,8 @@ function tree_recur($tab, $pere, $rang, $iddivjstree = 'iddivjstree', $donoreset continue; } - print ''; $ulprinted++; + print ''; + $ulprinted++; } print "\n".'
  • '; if ($showfk) { diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index a01aa02b468..2efeec151a3 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -102,9 +102,8 @@ function dolSavePageAlias($filealias, $object, $objectpage) if (!empty($conf->global->MAIN_UMASK)) { @chmod($filealiassub, octdec($conf->global->MAIN_UMASK)); } - } - // Save also alias into all language subdirectories if it is a main language - elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { + } elseif (empty($objectpage->lang) || !in_array($objectpage->lang, explode(',', $object->otherlang))) { + // Save also alias into all language subdirectories if it is a main language if (empty($conf->global->WEBSITE_DISABLE_MAIN_LANGUAGE_INTO_LANGSUBDIR)) { $dirname = dirname($filealias); $filename = basename($filealias); diff --git a/htdocs/core/lib/ws.lib.php b/htdocs/core/lib/ws.lib.php index 14d7162358b..ad4688f9134 100644 --- a/htdocs/core/lib/ws.lib.php +++ b/htdocs/core/lib/ws.lib.php @@ -41,27 +41,32 @@ function check_authentication($authentication, &$error, &$errorcode, &$errorlabe if (!$error && ($authentication['dolibarrkey'] != $conf->global->WEBSERVICES_KEY)) { $error++; - $errorcode = 'BAD_VALUE_FOR_SECURITY_KEY'; $errorlabel = 'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; + $errorcode = 'BAD_VALUE_FOR_SECURITY_KEY'; + $errorlabel = 'Value provided into dolibarrkey entry field does not match security key defined in Webservice module setup'; } if (!$error && !empty($authentication['entity']) && !is_numeric($authentication['entity'])) { $error++; - $errorcode = 'BAD_PARAMETERS'; $errorlabel = "The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used)."; + $errorcode = 'BAD_PARAMETERS'; + $errorlabel = "The entity parameter must be empty (or filled with numeric id of instance if multicompany module is used)."; } if (!$error) { $result = $fuser->fetch('', $authentication['login'], '', 0); if ($result < 0) { $error++; - $errorcode = 'ERROR_FETCH_USER'; $errorlabel = 'A technical error occurred during fetch of user'; + $errorcode = 'ERROR_FETCH_USER'; + $errorlabel = 'A technical error occurred during fetch of user'; } elseif ($result == 0) { $error++; - $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password'; + $errorcode = 'BAD_CREDENTIALS'; + $errorlabel = 'Bad value for login or password'; } if (!$error && $fuser->statut == 0) { $error++; - $errorcode = 'ERROR_USER_DISABLED'; $errorlabel = 'This user has been locked or disabled'; + $errorcode = 'ERROR_USER_DISABLED'; + $errorlabel = 'This user has been locked or disabled'; } // Validation of login @@ -83,7 +88,8 @@ function check_authentication($authentication, &$error, &$errorcode, &$errorlabe $login = checkLoginPassEntity($authentication['login'], $authentication['password'], $authentication['entity'], $authmode, 'ws'); if (empty($login)) { $error++; - $errorcode = 'BAD_CREDENTIALS'; $errorlabel = 'Bad value for login or password'; + $errorcode = 'BAD_CREDENTIALS'; + $errorlabel = 'Bad value for login or password'; } } } diff --git a/htdocs/core/login/functions_openid.php b/htdocs/core/login/functions_openid.php index c06b10f109d..3f77eca1326 100644 --- a/htdocs/core/login/functions_openid.php +++ b/htdocs/core/login/functions_openid.php @@ -43,7 +43,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) $login = ''; // Get identity from user and redirect browser to OpenID Server - if (GETPOSISSET('username')) { + if (GETPOSTISSET('username')) { $openid = new SimpleOpenID(); $openid->SetIdentity($_POST['username']); $protocol = ($conf->file->main_force_https ? 'https://' : 'http://'); @@ -59,9 +59,8 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest) return false; } return false; - } - // Perform HTTP Request to OpenID server to validate key - elseif ($_GET['openid_mode'] == 'id_res') { + } elseif ($_GET['openid_mode'] == 'id_res') { + // Perform HTTP Request to OpenID server to validate key $openid = new SimpleOpenID(); $openid->SetIdentity($_GET['openid_identity']); $openid_validation_result = $openid->ValidateWithServer(); diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 155a5f55ce0..11dc0a6ce7d 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -147,12 +147,11 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); - } - /*elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); - }*/ - else { + /*} elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); + }*/ + } else { $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png'; $logoContainerAdditionalClass = ''; } @@ -467,7 +466,9 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t // Show menu $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert"; if (empty($noout)) { - $altok = 0; $blockvmenuopened = false; $lastlevel0 = ''; + $altok = 0; + $blockvmenuopened = false; + $lastlevel0 = ''; $num = count($menu_array); for ($i = 0; $i < $num; $i++) { // Loop on each menu entry $showmenu = true; @@ -591,7 +592,8 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t print ''."\n"; } if ($blockvmenuopened) { - print ''."\n"; $blockvmenuopened = false; + print ''."\n"; + $blockvmenuopened = false; } } } @@ -627,7 +629,8 @@ function dol_auguria_showmenu($type_user, &$menuentry, &$listofmodulesforexterna $found = 0; foreach ($tmploops as $tmploop) { if (in_array($tmploop, $listofmodulesforexternal)) { - $found++; break; + $found++; + break; } } if (!$found) { diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index fecc57a74e7..e150d07e063 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -516,12 +516,11 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout = if (!empty($mysoc->logo_squarred_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_squarred_mini)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_squarred_mini); - } - /*elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); - }*/ - else { + /*} elseif (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('logos/thumbs/'.$mysoc->logo_mini); + }*/ + } else { $urllogo = DOL_URL_ROOT.'/theme/dolibarr_512x512_white.png'; $logoContainerAdditionalClass = ''; } @@ -1931,7 +1930,9 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM // Show menu $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert"; if (empty($noout)) { - $altok = 0; $blockvmenuopened = false; $lastlevel0 = ''; + $altok = 0; + $blockvmenuopened = false; + $lastlevel0 = ''; $num = count($menu_array); for ($i = 0; $i < $num; $i++) { // Loop on each menu entry $showmenu = true; @@ -2055,7 +2056,8 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM print ''."\n"; } if ($blockvmenuopened) { - print ''."\n"; $blockvmenuopened = false; + print ''."\n"; + $blockvmenuopened = false; } } } diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 5ab8ff24f9f..f51aacdd90e 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -370,7 +370,9 @@ class MenuManager } if (empty($noout)) { - $alt = 0; $altok = 0; $blockvmenuopened = false; + $alt = 0; + $altok = 0; + $blockvmenuopened = false; $num = count($menu_array); for ($i = 0; $i < $num; $i++) { $alt++; diff --git a/htdocs/core/modules/action/modules_action.php b/htdocs/core/modules/action/modules_action.php index ea51eea4745..b496e32f5e1 100644 --- a/htdocs/core/modules/action/modules_action.php +++ b/htdocs/core/modules/action/modules_action.php @@ -96,7 +96,9 @@ function action_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $h } // Search template files - $file = ''; $classname = ''; $filefound = 0; + $file = ''; + $classname = ''; + $filefound = 0; $dirmodels = array('/'); if (is_array($conf->modules_parts['models'])) { $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 944a285b341..a1cba7f8399 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -199,7 +199,8 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode return ''; } - $field = 'barcode'; $where = ''; + $field = 'barcode'; + $where = ''; $now = dol_now(); diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index af9207eb1c5..20ce1373b66 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -128,7 +128,8 @@ class doc_generic_bom_odt extends ModelePDFBom $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index dad731758f7..f5a9fb75976 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -81,7 +81,8 @@ class mod_bom_standard extends ModeleNumRefboms { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -93,7 +94,8 @@ class mod_bom_standard extends ModeleNumRefboms if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 5855ec24e55..21c131ad2a6 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -360,7 +360,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts // Add page break if we do not have space to add current line if ($lineinpage >= ($this->line_per_page - 1)) { - $lineinpage = 0; $yp = 0; + $lineinpage = 0; + $yp = 0; // New page $pdf->AddPage(); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 6e9f03ad927..a882c1e0068 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -78,7 +78,8 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts { global $conf, $langs, $db; - $payyymm = ''; $max = ''; + $payyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -90,7 +91,8 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $payyymm = substr($row[0], 0, 6); $max = $row[0]; + $payyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) { diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 1138801a078..33b31135caf 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -135,7 +135,8 @@ class doc_generic_order_odt extends ModelePDFCommandes $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index f8f196a9fa3..ebae616c45b 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -472,7 +472,8 @@ class pdf_einstein extends ModelePDFCommandes // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -896,7 +897,8 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index b64a0066390..17837529354 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -658,7 +658,8 @@ class pdf_eratosthene extends ModelePDFCommandes // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -1109,7 +1110,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index 315a1f27302..0cc9324ef16 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -81,7 +81,8 @@ class mod_commande_marbre extends ModeleNumRefCommandes { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -93,7 +94,8 @@ class mod_commande_marbre extends ModeleNumRefCommandes if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { 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 25cf13f57d9..7b451287ae1 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 @@ -134,7 +134,8 @@ class doc_generic_contract_odt extends ModelePDFContract $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 439ae2ef338..c440cbf1cba 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -415,7 +415,8 @@ class pdf_strato extends ModelePDFContract // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 2506b77e540..6bc09464dba 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -91,7 +91,8 @@ class mod_contract_serpis extends ModelNumRefContracts { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -103,7 +104,8 @@ class mod_contract_serpis extends ModelNumRefContracts if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index ad197f442dd..057310a9976 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -513,7 +513,8 @@ class pdf_storm extends ModelePDFDeliveryOrder // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 3f86dc1ac67..66f232653ac 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -426,7 +426,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index c18b1c98e62..605265fde00 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -94,7 +94,8 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder $langs->load("bills"); // Check invoice num - $fayymm = ''; $max = ''; + $fayymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL @@ -106,7 +107,8 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 16161e97a65..82d61a41943 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -136,7 +136,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index c11fb8e60c9..42a777a196f 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -523,12 +523,14 @@ class pdf_espadon extends ModelePdfExpedition // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -695,7 +697,8 @@ class pdf_espadon extends ModelePdfExpedition $pdf->SetFont('', 'B', $default_font_size - 1); // Total table - $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; + $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index af73123b2d5..f2434c93d26 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -333,7 +333,8 @@ class pdf_merou extends ModelePdfExpedition // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 3); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 4cf93a31b55..c41fd92f524 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -533,12 +533,14 @@ class pdf_rouget extends ModelePdfExpedition // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -700,7 +702,8 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('', 'B', $default_font_size - 1); // Tableau total - $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; + $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 04cc09c2313..aa1628e7482 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -86,7 +86,8 @@ class mod_expedition_safor extends ModelNumRefExpedition { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -98,7 +99,8 @@ class mod_expedition_safor extends ModelNumRefExpedition if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 9984a9ccc24..d1f959f5460 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -849,7 +849,8 @@ class pdf_standard extends ModeleExpenseReport if ($object->fk_statut == 99) { if ($object->fk_user_refuse > 0) { $userfee = new User($this->db); - $userfee->fetch($object->fk_user_refuse); $posy += 6; + $userfee->fetch($object->fk_user_refuse); + $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("REFUSEUR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; @@ -862,7 +863,8 @@ class pdf_standard extends ModeleExpenseReport } elseif ($object->fk_statut == 4) { if ($object->fk_user_cancel > 0) { $userfee = new User($this->db); - $userfee->fetch($object->fk_user_cancel); $posy += 6; + $userfee->fetch($object->fk_user_cancel); + $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("CANCEL_USER")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; @@ -875,7 +877,8 @@ class pdf_standard extends ModeleExpenseReport } else { if ($object->fk_user_approve > 0) { $userfee = new User($this->db); - $userfee->fetch($object->fk_user_approve); $posy += 6; + $userfee->fetch($object->fk_user_approve); + $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("VALIDOR")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; @@ -887,7 +890,8 @@ class pdf_standard extends ModeleExpenseReport if ($object->fk_statut == 6) { if ($object->fk_user_paid > 0) { $userfee = new User($this->db); - $userfee->fetch($object->fk_user_paid); $posy += 6; + $userfee->fetch($object->fk_user_paid); + $posy += 6; $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell(96, 4, $outputlangs->transnoentities("AUTHORPAIEMENT")." : ".dolGetFirstLastname($userfee->firstname, $userfee->lastname), 0, 'L'); $posy += 5; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index c80bd693620..bbe2245a97d 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -87,7 +87,8 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -99,7 +100,8 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 762b9fb89e9..eb48373a443 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -135,7 +135,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 67e61cb7815..847901c0147 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -584,7 +584,8 @@ class pdf_crabe extends ModelePDFFactures // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -1191,7 +1192,8 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b1072a50008..d7d69fc4a18 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -695,7 +695,8 @@ class pdf_sponge extends ModelePDFFactures // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -1284,7 +1285,8 @@ class pdf_sponge extends ModelePDFFactures $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 5a6df69babd..cd36b4d322a 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -95,7 +95,8 @@ class mod_facture_mars extends ModeleNumRefFactures $langs->load("bills"); // Check invoice num - $fayymm = ''; $max = ''; + $fayymm = ''; + $max = ''; $posindice = strlen($this->prefixinvoice) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL @@ -107,7 +108,8 @@ class mod_facture_mars extends ModeleNumRefFactures if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($fayymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { @@ -129,7 +131,8 @@ class mod_facture_mars extends ModeleNumRefFactures if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($fayymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 9d844953306..2f142a1adc7 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -105,7 +105,8 @@ class mod_facture_terre extends ModeleNumRefFactures $langs->load("bills"); // Check invoice num - $fayymm = ''; $max = ''; + $fayymm = ''; + $max = ''; $posindice = strlen($this->prefixinvoice) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL @@ -117,7 +118,8 @@ class mod_facture_terre extends ModeleNumRefFactures if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($fayymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { @@ -139,7 +141,8 @@ class mod_facture_terre extends ModeleNumRefFactures if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($fayymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { @@ -160,7 +163,8 @@ class mod_facture_terre extends ModeleNumRefFactures if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($fayymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 25a30d3ac84..ac0cb1fac80 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -392,7 +392,8 @@ class pdf_soleil extends ModelePDFFicheinter // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index b4d492e31ce..b2ffe3a7e98 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -89,7 +89,8 @@ class mod_pacific extends ModeleNumRefFicheinter $langs->load("bills"); - $fayymm = ''; $max = ''; + $fayymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -101,7 +102,8 @@ class mod_pacific extends ModeleNumRefFicheinter if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $fayymm = substr($row[0], 0, 6); $max = $row[0]; + $fayymm = substr($row[0], 0, 6); + $max = $row[0]; } } if (!$fayymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm)) { diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index ae9ba58726e..8cf79227d4f 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -195,7 +195,9 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, } // Search template files - $file = ''; $classname = ''; $filefound = 0; + $file = ''; + $classname = ''; + $filefound = 0; $dirmodels = array('/'); if (is_array($conf->modules_parts['models'])) { $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index ddec553216d..fd2271198bc 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -92,7 +92,8 @@ class mod_holiday_madonna extends ModelNumRefHolidays { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -104,7 +105,8 @@ class mod_holiday_madonna extends ModelNumRefHolidays if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index f324f268ba3..63a28fbe3d2 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -397,9 +397,8 @@ class ImportCsv extends ModeleImports $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; $error++; - } - // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) - else { + } else { + // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) // We convert field if required if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; @@ -677,9 +676,8 @@ class ImportCsv extends ModeleImports $errorforthistable++; $error++; } - } - // If test is just a static regex - elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + } elseif (!preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { + // If test is just a static regex //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
    "; $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); $this->errors[$error]['type'] = 'REGEX'; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 1f5764c810d..257e8f5253e 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -440,9 +440,8 @@ class ImportXlsx extends ModeleImports $this->errors[$error]['type'] = 'NOTNULL'; $errorforthistable++; $error++; - } - // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) - else { + } else { + // Test format only if field is not a missing mandatory field (field may be a value or empty but not mandatory) // We convert field if required if (!empty($objimport->array_import_convertvalue[0][$val])) { //print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. '; @@ -718,9 +717,8 @@ class ImportXlsx extends ModeleImports $errorforthistable++; $error++; } - } - // If test is just a static regex - elseif (!preg_match('/' . $objimport->array_import_regex[0][$val] . '/i', $newval)) { + } elseif (!preg_match('/' . $objimport->array_import_regex[0][$val] . '/i', $newval)) { + // If test is just a static regex //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
    "; $this->errors[$error]['lib'] = $langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); $this->errors[$error]['type'] = 'REGEX'; diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 8e1737b3e9f..5f2ad86c7b5 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -131,7 +131,8 @@ class doc_generic_member_odt extends ModelePDFMember $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index d3fd804a662..1d1a892cc56 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -123,7 +123,8 @@ class pdf_standard extends CommonStickerGenerator $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); } - $xleft = 2; $ytop = 2; + $xleft = 2; + $ytop = 2; // Top if ($header != '') { @@ -140,16 +141,20 @@ class pdf_standard extends CommonStickerGenerator $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); // Define widthtouse and heighttouse - $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); + $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); $defaultratio = ($maxwidthtouse / $maxheighttouse); - $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image + $widthtouse = $maxwidthtouse; + $heighttouse = 0; // old value for image $tmp = dol_getImageSize($photo, false); if ($tmp['height']) { $imgratio = $tmp['width'] / $tmp['height']; if ($imgratio >= $defaultratio) { - $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); + $widthtouse = $maxwidthtouse; + $heighttouse = round($widthtouse / $imgratio); } else { - $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); + $heightouse = $maxheighttouse; + $widthtouse = round($heightouse * $imgratio); } } //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; @@ -312,7 +317,8 @@ class pdf_standard extends CommonStickerGenerator $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { - dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; + dol_print_error('', 'ErrorBadTypeForCard'.$this->code); + exit; } $this->type = 'pdf'; // standard format or custom diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index e879bdb3562..0e041a17559 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -114,7 +114,9 @@ function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $o } // Search template files - $file = ''; $classname = ''; $filefound = 0; + $file = ''; + $classname = ''; + $filefound = 0; $dirmodels = array('/'); if (is_array($conf->modules_parts['models'])) { $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 1f9c75b66b4..63ca0c6ad49 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -305,7 +305,9 @@ class modAdherent extends DolibarrModules 'c.rowid'=>'subscription', 'c.dateadh'=>'subscription', 'c.datef'=>'subscription', 'c.subscription'=>'subscription' ); // Add extra fields - $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra'; + $keyforselect = 'adherent'; + $keyforelement = 'member'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // End add axtra fields $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 889bcbb8d0e..b040e4cec99 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -287,14 +287,23 @@ class modBom extends DolibarrModules $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'bom'; - $keyforclass = 'BOM'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bom'; + $keyforclass = 'BOM'; + $keyforclassfile = '/bom/class/bom.class.php'; + $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforclass = 'BOMLine'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bomline'; $keyforalias = 'tl'; + $keyforclass = 'BOMLine'; + $keyforclassfile = '/bom/class/bom.class.php'; + $keyforelement = 'bomline'; + $keyforalias = 'tl'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; unset($this->export_fields_array[$r]['tl.fk_bom']); - $keyforselect = 'bom_bom'; $keyforaliasextra = 'extra'; $keyforelement = 'bom'; + $keyforselect = 'bom_bom'; + $keyforaliasextra = 'extra'; + $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'bom_bomline'; $keyforaliasextra = 'extraline'; $keyforelement = 'bomline'; + $keyforselect = 'bom_bomline'; + $keyforaliasextra = 'extraline'; + $keyforelement = 'bomline'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index d5c2e699da2..d1f58dd7451 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -185,7 +185,9 @@ class modCategorie extends DolibarrModules $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 'p.label'=>'Text'); $this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product'); // We define here only fields that use another picto - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -227,7 +229,9 @@ class modCategorie extends DolibarrModules 't.libelle'=>'company' ); // We define here only fields that use another picto - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; + $keyforselect = 'societe'; + $keyforelement = 'company'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -271,7 +275,9 @@ class modCategorie extends DolibarrModules 't.libelle'=>'company', 'pl.code'=>'company', 'st.code'=>'company' ); // We define here only fields that use another picto - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; + $keyforselect = 'societe'; + $keyforelement = 'company'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -297,7 +303,9 @@ class modCategorie extends DolibarrModules $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); $this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto - $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra'; + $keyforselect = 'adherent'; + $keyforelement = 'member'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -348,7 +356,9 @@ class modCategorie extends DolibarrModules 's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company" ); // We define here only fields that use another picto - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra'; + $keyforselect = 'socpeople'; + $keyforelement = 'contact'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -375,7 +385,9 @@ class modCategorie extends DolibarrModules $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.ref'=>'Text', 's.rowid'=>"List:societe:nom:rowid", 's.nom'=>"Text"); $this->export_entities_array[$r] = array('p.rowid'=>'project', 'p.ref'=>'project', 's.rowid'=>"company", 's.nom'=>"company"); // We define here only fields that use another picto - $keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra'; + $keyforselect = 'projet'; + $keyforelement = 'project'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -398,7 +410,9 @@ class modCategorie extends DolibarrModules $this->export_TypeFields_array[$r] = array('cat.label'=>"Text", 'cat.description'=>"Text", 'cat.fk_parent'=>'List:categorie:label:rowid', 'p.login'=>'Text', 'p.lastname'=>'Text', 'p.firstname'=>'Text'); $this->export_entities_array[$r] = array('p.rowid'=>'user', 'p.login'=>'user', 'p.lastname'=>'user', 'p.firstname'=>'user'); // We define here only fields that use another picto - $keyforselect = 'user'; $keyforelement = 'user'; $keyforaliasextra = 'extra'; + $keyforselect = 'user'; + $keyforelement = 'user'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 36a35894636..6fa8b730c24 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -236,13 +236,21 @@ class modCommande extends DolibarrModules 'cd.total_ttc'=>"order_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' ); $this->export_dependencies_array[$r] = array('order_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'commande'; $keyforelement = 'order'; $keyforaliasextra = 'extra'; + $keyforselect = 'commande'; + $keyforelement = 'order'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'commandedet'; $keyforelement = 'order_line'; $keyforaliasextra = 'extra2'; + $keyforselect = 'commandedet'; + $keyforelement = 'order_line'; + $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra3'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra4'; + $keyforselect = 'societe'; + $keyforelement = 'company'; + $keyforaliasextra = 'extra4'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index d9d8558e35a..1b927346f1e 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -193,9 +193,13 @@ class modContrat extends DolibarrModules 'p.rowid'=>'List:product:label', 'p.ref'=>'Text', 'p.label'=>'Text'); - $keyforselect = 'contrat'; $keyforelement = 'contract'; $keyforaliasextra = 'coextra'; + $keyforselect = 'contrat'; + $keyforelement = 'contract'; + $keyforaliasextra = 'coextra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'contratdet'; $keyforelement = 'contract_line'; $keyforaliasextra = 'codextra'; + $keyforselect = 'contratdet'; + $keyforelement = 'contract_line'; + $keyforaliasextra = 'codextra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 6cc31b05c22..b4bac22fd1a 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -280,14 +280,22 @@ class modExpedition extends DolibarrModules } $this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; + $keyforselect = 'socpeople'; + $keyforelement = 'contact'; + $keyforaliasextra = 'extra3'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; } - $keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra'; + $keyforselect = 'expedition'; + $keyforelement = 'shipment'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'expeditiondet'; $keyforelement = 'shipment_line'; $keyforaliasextra = 'extra2'; + $keyforselect = 'expeditiondet'; + $keyforelement = 'shipment_line'; + $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extraprod'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extraprod'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index 2d0036faef9..dca32b4fad7 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -211,7 +211,9 @@ class modExpenseReport extends DolibarrModules $this->export_alias_array[$r] = array('d.rowid'=>"idtrip", 'd.type'=>"type", 'd.note_private'=>'note_private', 'd.note_public'=>'note_public', 'u.lastname'=>'name', 'u.firstname'=>'firstname', 'u.login'=>'login'); $this->export_dependencies_array[$r] = array('expensereport_line'=>'ed.rowid', 'type_fees'=>'tf.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'expensereport'; $keyforelement = 'expensereport'; $keyforaliasextra = 'extra'; + $keyforselect = 'expensereport'; + $keyforelement = 'expensereport'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 51d3377a965..eed92413c8a 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -266,11 +266,17 @@ class modFacture extends DolibarrModules ); $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay'); $this->export_dependencies_array[$r] = array('invoice_line'=>'fd.rowid', 'product'=>'fd.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc', 'f.close_code')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra'; + $keyforselect = 'facture'; + $keyforelement = 'invoice'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'facturedet'; $keyforelement = 'invoice_line'; $keyforaliasextra = 'extra2'; + $keyforselect = 'facturedet'; + $keyforelement = 'invoice_line'; + $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra3'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; @@ -350,7 +356,9 @@ class modFacture extends DolibarrModules ); $this->export_special_array[$r] = array('none.rest'=>'getRemainToPay'); $this->export_dependencies_array[$r] = array('payment'=>'p.rowid', 'none.rest'=>array('f.rowid', 'f.total_ttc', 'f.close_code')); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them, or just to have field we need - $keyforselect = 'facture'; $keyforelement = 'invoice'; $keyforaliasextra = 'extra'; + $keyforselect = 'facture'; + $keyforelement = 'invoice'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index 422ca6b22d5..9364b75d9f7 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -165,7 +165,9 @@ class modFicheinter extends DolibarrModules 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 'f.rowid'=>"InterId", 'f.ref'=>"InterRef", 'f.datec'=>"InterDateCreation", 'f.duree'=>"InterDuration", 'f.fk_statut'=>'InterStatus', 'f.description'=>"InterNote"); - $keyforselect = 'fichinter'; $keyforelement = 'intervention'; $keyforaliasextra = 'extra'; + $keyforselect = 'fichinter'; + $keyforelement = 'intervention'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] += array( 'pj.ref'=>'ProjectRef', 'pj.title'=>'ProjectLabel', @@ -195,7 +197,9 @@ class modFicheinter extends DolibarrModules 'fd.duree'=>'inter_line', 'fd.description'=>'inter_line' ); $this->export_dependencies_array[$r] = array('inter_line'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'fichinterdet'; $keyforelement = 'inter_line'; $keyforaliasextra = 'extradet'; + $keyforselect = 'fichinterdet'; + $keyforelement = 'inter_line'; + $keyforaliasextra = 'extradet'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index c3bbf2c3faf..3fa92d8a7c5 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -221,7 +221,9 @@ class modHoliday extends DolibarrModules $this->export_special_array[$r] = array('none.num_open_days'=>'getNumOpenDays'); $this->export_dependencies_array[$r] = array(); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'holiday'; $keyforelement = 'holiday'; $keyforaliasextra = 'extra'; + $keyforselect = 'holiday'; + $keyforelement = 'holiday'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4335913be6f..f972c235802 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -210,7 +210,9 @@ class modProduct extends DolibarrModules if (!empty($conf->barcode->enabled)) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); } - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (!empty($conf->fournisseur->enabled)) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); @@ -431,7 +433,9 @@ class modProduct extends DolibarrModules $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); } $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 69a359d6fb9..ff135a74d1d 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -253,13 +253,17 @@ class modProjet extends DolibarrModules // Add fields for project $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array()); // Add extra fields for project - $keyforselect = 'projet'; $keyforelement = 'project'; $keyforaliasextra = 'extra'; + $keyforselect = 'projet'; + $keyforelement = 'project'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // Add fields for tasks $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pt.rowid'=>'TaskId', 'pt.ref'=>'RefTask', 'pt.label'=>'LabelTask', 'pt.dateo'=>"TaskDateStart", 'pt.datee'=>"TaskDateEnd", 'pt.duration_effective'=>"DurationEffective", 'pt.planned_workload'=>"PlannedWorkload", 'pt.progress'=>"Progress", 'pt.description'=>"TaskDescription")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pt.rowid'=>'projecttask', 'pt.ref'=>'projecttask', 'pt.label'=>'projecttask', 'pt.dateo'=>"projecttask", 'pt.datee'=>"projecttask", 'pt.duration_effective'=>"projecttask", 'pt.planned_workload'=>"projecttask", 'pt.progress'=>"projecttask", 'pt.description'=>"projecttask")); // Add extra fields for task - $keyforselect = 'projet_task'; $keyforelement = 'projecttask'; $keyforaliasextra = 'extra2'; + $keyforselect = 'projet_task'; + $keyforelement = 'projecttask'; + $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; // End add extra fields $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ptt.rowid'=>'IdTaskTime', 'ptt.task_date'=>'TaskTimeDate', 'ptt.task_duration'=>"TimesSpent", 'ptt.fk_user'=>"TaskTimeUser", 'ptt.note'=>"TaskTimeNote")); diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 1003bc5e09c..a1f52bbd906 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -227,13 +227,21 @@ class modPropale extends DolibarrModules 'cd.total_ht'=>"propal_line", 'cd.total_tva'=>"propal_line", 'cd.total_ttc'=>"propal_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product' ); $this->export_dependencies_array[$r] = array('propal_line'=>'cd.rowid', 'product'=>'cd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - $keyforselect = 'propal'; $keyforelement = 'propal'; $keyforaliasextra = 'extra'; + $keyforselect = 'propal'; + $keyforelement = 'propal'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'propaldet'; $keyforelement = 'propal_line'; $keyforaliasextra = 'extra2'; + $keyforselect = 'propaldet'; + $keyforelement = 'propal_line'; + $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra3'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra3'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'societe'; $keyforelement = 'societe'; $keyforaliasextra = 'extra4'; + $keyforselect = 'societe'; + $keyforelement = 'societe'; + $keyforaliasextra = 'extra4'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 54334cdc285..17f765d2caf 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -208,12 +208,18 @@ class modReception extends DolibarrModules } $this->export_dependencies_array[$r] = array('reception_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them if ($idcontacts && !empty($conf->global->RECEPTION_ADD_CONTACTS_IN_EXPORT)) { - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3'; + $keyforselect = 'socpeople'; + $keyforelement = 'contact'; + $keyforaliasextra = 'extra3'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; } - $keyforselect = 'reception'; $keyforelement = 'reception'; $keyforaliasextra = 'extra'; + $keyforselect = 'reception'; + $keyforelement = 'reception'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'commande_fournisseur_dispatch'; $keyforelement = 'reception_line'; $keyforaliasextra = 'extra2'; + $keyforselect = 'commande_fournisseur_dispatch'; + $keyforelement = 'reception_line'; + $keyforaliasextra = 'extra2'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 46be038a21c..ee3836cde26 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -242,7 +242,9 @@ class modResource extends DolibarrModules $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification"); $this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text'); $this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource"); - $keyforselect = 'resource'; $keyforelement = 'resource'; $keyforaliasextra = 'extra'; + $keyforselect = 'resource'; + $keyforelement = 'resource'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 75af0f103f5..6009af638fb 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -175,7 +175,9 @@ class modService extends DolibarrModules if (!empty($conf->barcode->enabled)) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); } - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (!empty($conf->fournisseur->enabled)) { $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier', 'pf.ref_fourn'=>'SupplierRef', 'pf.quantity'=>'QtyMin', 'pf.remise_percent'=>'DiscountQtyMin', 'pf.unitprice'=>'BuyingPrice', 'pf.delivery_time_days'=>'NbDaysToDelivery')); @@ -392,7 +394,9 @@ class modService extends DolibarrModules $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); } $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct')); - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description")); $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct")); diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 42456c4ae80..9151673f996 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -288,7 +288,9 @@ class modSociete extends DolibarrModules $this->export_fields_array[$r] += array('s.entity'=>'Entity'); } } - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extra'; + $keyforselect = 'societe'; + $keyforelement = 'company'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] += array('u.login'=>'SaleRepresentativeLogin', 'u.firstname'=>'SaleRepresentativeFirstname', 'u.lastname'=>'SaleRepresentativeLastname'); @@ -386,9 +388,13 @@ class modSociete extends DolibarrModules unset($this->export_fields_array[$r]['s.code_fournisseur']); unset($this->export_entities_array[$r]['s.code_fournisseur']); } - $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra'; + $keyforselect = 'socpeople'; + $keyforelement = 'contact'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect = 'societe'; $keyforelement = 'company'; $keyforaliasextra = 'extrasoc'; + $keyforselect = 'societe'; + $keyforelement = 'company'; + $keyforaliasextra = 'extrasoc'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'socpeople as c'; diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index 76f5a1910ba..ffa80d9a748 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -205,7 +205,9 @@ class modStock extends DolibarrModules ); $this->export_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into export_icon $this->export_aggregate_array[$r] = array(); - $keyforselect = 'warehouse'; $keyforelement = 'warehouse'; $keyforaliasextra = 'extra'; + $keyforselect = 'warehouse'; + $keyforelement = 'warehouse'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; @@ -243,7 +245,9 @@ class modStock extends DolibarrModules ); // We define here only fields that use another icon that the one defined into export_icon $this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('stock'=>array('p.rowid', 'e.rowid')); // We must keep this until the aggregate_array is used. To have a unique key, if we ask a field of a child, to avoid the DISTINCT to discard them. - $keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra'; + $keyforselect = 'product'; + $keyforelement = 'product'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('ps.reel'=>'Stock')); @@ -288,7 +292,9 @@ class modStock extends DolibarrModules ); // We define here only fields that use another icon that the one defined into export_icon $this->export_aggregate_array[$r] = array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r] = array('stockbatch'=>array('pb.rowid'), 'batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. - $keyforselect = 'product_lot'; $keyforelement = 'batch'; $keyforaliasextra = 'extra'; + $keyforselect = 'product_lot'; + $keyforelement = 'batch'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; $this->export_sql_start[$r] = 'SELECT DISTINCT '; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index af4443be5d1..4c1a6bcfded 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -256,7 +256,9 @@ class modUser extends DolibarrModules 'u.admin'=>"user", 'u.statut'=>'user', 'u.datelastlogin'=>'user', 'u.datepreviouslogin'=>'user', 'u.fk_socpeople'=>"contact", 'u.fk_soc'=>"company", 'u.fk_member'=>"member" ); - $keyforselect = 'user'; $keyforelement = 'user'; $keyforaliasextra = 'extra'; + $keyforselect = 'user'; + $keyforelement = 'user'; + $keyforaliasextra = 'extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (empty($conf->adherent->enabled)) { unset($this->export_fields_array[$r]['u.fk_member']); diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index a7dfa2fdd82..efb5a38f297 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -130,7 +130,9 @@ class modWebsite extends DolibarrModules $this->export_code[$r] = $this->rights_class.'_'.$r; $this->export_label[$r] = 'MyWebsitePages'; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_icon[$r] = 'globe'; - $keyforclass = 'WebsitePage'; $keyforclassfile = '/website/class/websitepage.class.php'; $keyforelement = 'Website'; + $keyforclass = 'WebsitePage'; + $keyforclassfile = '/website/class/websitepage.class.php'; + $keyforelement = 'Website'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; //$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra'; //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; diff --git a/htdocs/core/modules/movement/doc/pdf_standard.modules.php b/htdocs/core/modules/movement/doc/pdf_standard.modules.php index b84976dd212..c8a0c50862b 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard.modules.php @@ -602,7 +602,8 @@ class pdf_stdandard extends ModelePDFMovement // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 8053d4f4f45..374ae5b4337 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -135,7 +135,8 @@ class doc_generic_mo_odt extends ModelePDFMo $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index ba7cdccdafa..d47b4eb708e 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -81,7 +81,8 @@ class mod_mo_standard extends ModeleNumRefMos { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -93,7 +94,8 @@ class mod_mo_standard extends ModeleNumRefMos if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index 535fdab38bc..d3259db513c 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -88,7 +88,8 @@ class mod_payment_cicada extends ModeleNumRefPayments { global $conf, $langs, $db; - $payyymm = ''; $max = ''; + $payyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -100,7 +101,8 @@ class mod_payment_cicada extends ModeleNumRefPayments if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $payyymm = substr($row[0], 0, 6); $max = $row[0]; + $payyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) { diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index c09ce7bcbd8..079b46003c4 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -111,7 +111,8 @@ class pdf_standardlabel extends CommonStickerGenerator $pdf->image($backgroundimage, $_PosX, $_PosY, $this->_Width, $this->_Height); } - $xleft = 2; $ytop = 2; + $xleft = 2; + $ytop = 2; // Top if ($header != '') { @@ -128,16 +129,20 @@ class pdf_standardlabel extends CommonStickerGenerator $ytop += (empty($header) ? 0 : (1 + $this->_Line_Height)); // Define widthtouse and heighttouse - $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); + $maxwidthtouse = round(($this->_Width - 2 * $xleft) * $imgscalewidth); + $maxheighttouse = round(($this->_Height - 2 * $ytop) * $imgscaleheight); $defaultratio = ($maxwidthtouse / $maxheighttouse); - $widthtouse = $maxwidthtouse; $heighttouse = 0; // old value for image + $widthtouse = $maxwidthtouse; + $heighttouse = 0; // old value for image $tmp = dol_getImageSize($photo, false); if ($tmp['height']) { $imgratio = $tmp['width'] / $tmp['height']; if ($imgratio >= $defaultratio) { - $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); + $widthtouse = $maxwidthtouse; + $heighttouse = round($widthtouse / $imgratio); } else { - $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); + $heightouse = $maxheighttouse; + $widthtouse = round($heightouse * $imgratio); } } //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; @@ -239,7 +244,8 @@ class pdf_standardlabel extends CommonStickerGenerator $this->code = $srctemplatepath; $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { - dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; + dol_print_error('', 'ErrorBadTypeForCard'.$this->code); + exit; } $this->type = 'pdf'; // standard format or custom diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index 1be4e6d8432..907b18daef3 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -267,7 +267,8 @@ class pdf_tcpdflabel extends CommonStickerGenerator $this->code = $srctemplatepath; $this->Tformat = $_Avery_Labels[$this->code]; if (empty($this->Tformat)) { - dol_print_error('', 'ErrorBadTypeForCard'.$this->code); exit; + dol_print_error('', 'ErrorBadTypeForCard'.$this->code); + exit; } $this->type = 'pdf'; // standard format or custom diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index 9365f19f783..ae4c6888a6c 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -117,7 +117,9 @@ function doc_label_pdf_create($db, $arrayofrecords, $modele, $outputlangs, $outp dol_syslog("modele=".$modele." outputdir=".$outputdir." template=".$template." code=".$code." srctemplatepath=".$srctemplatepath." filename=".$filename, LOG_DEBUG); // Search template files - $file = ''; $classname = ''; $filefound = 0; + $file = ''; + $classname = ''; + $filefound = 0; $dirmodels = array('/'); if (is_array($conf->modules_parts['models'])) { $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']); diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 8970cbeea79..19a752d5be7 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -138,7 +138,8 @@ class doc_generic_product_odt extends ModelePDFProduct $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 24d9c0690c8..0a302c0fb6b 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -200,7 +200,8 @@ class mod_codeproduct_elephant extends ModeleProductCode return ''; } - $field = ''; $where = ''; + $field = ''; + $where = ''; if ($type == 0) { $field = 'ref'; //$where = ' AND client in (1,2)'; 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 960bf21ef69..091f26a0872 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 @@ -426,7 +426,8 @@ class doc_generic_project_odt extends ModelePDFProjects $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 446de761418..373d41abc31 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -421,7 +421,8 @@ class pdf_baleine extends ModelePDFProjects // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); - $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage + $heightoftitleline + 1; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index dbb4e28d03a..21af4b94ade 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -640,7 +640,8 @@ class pdf_beluga extends ModelePDFProjects // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); - $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage + $heightoftitleline + 1; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index b2d90af0da2..ef2ec4fcaf8 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -425,7 +425,8 @@ class pdf_timespent extends ModelePDFProjects // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); - $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage + $heightoftitleline + 1; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 1fb88f5454c..b1dbe4bae48 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -90,7 +90,8 @@ class mod_project_simple extends ModeleNumRefProjects { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -101,7 +102,8 @@ class mod_project_simple extends ModeleNumRefProjects if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { 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 3f321c6f022..fc444babe0d 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 @@ -393,7 +393,8 @@ class doc_generic_task_odt extends ModelePDFTask $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 654da5fff23..f0cdddfbc88 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -90,7 +90,8 @@ class mod_task_simple extends ModeleNumRefTask { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -102,7 +103,8 @@ class mod_task_simple extends ModeleNumRefTask if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 0ac3bc5e35d..4a292d4a97b 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -137,7 +137,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 1f36c874c2b..9575577ecbd 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -565,7 +565,8 @@ class pdf_azur extends ModelePDFPropales // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -1047,7 +1048,8 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 6a550018f7a..550339a8afc 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -673,7 +673,8 @@ class pdf_cyan extends ModelePDFPropales // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -1194,7 +1195,8 @@ class pdf_cyan extends ModelePDFPropales $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index 77b1a97e17b..28d66dfc40a 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -90,7 +90,8 @@ class mod_propale_marbre extends ModeleNumRefPropales { global $conf, $langs, $db; - $pryymm = ''; $max = ''; + $pryymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -102,7 +103,8 @@ class mod_propale_marbre extends ModeleNumRefPropales if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $pryymm = substr($row[0], 0, 6); $max = $row[0]; + $pryymm = substr($row[0], 0, 6); + $max = $row[0]; } } diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 0b19633b40e..13a05b3378d 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -130,7 +130,8 @@ class doc_generic_reception_odt extends ModelePdfReception $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index ad1a702a622..4aa6db074f6 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -439,12 +439,14 @@ class pdf_squille extends ModelePdfReception // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -599,7 +601,8 @@ class pdf_squille extends ModelePdfReception $pdf->SetFont('', 'B', $default_font_size - 1); // Tableau total - $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; + $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format { $col2x-=20; diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index d75e82070df..bbfc0daee45 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -66,7 +66,8 @@ class mod_reception_beryl extends ModelNumRefReception { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -78,7 +79,8 @@ class mod_reception_beryl extends ModelNumRefReception if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 588ecaf747f..ff9e4da5f0c 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -117,7 +117,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 49e4ffbe80a..5586ad82fda 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -223,7 +223,8 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode return ''; } - $field = ''; $where = ''; + $field = ''; + $where = ''; if ($type == 0) { $field = 'code_client'; //$where = ' AND client in (1,2)'; diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index ad6f51e342b..2819adea021 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -132,7 +132,8 @@ class doc_generic_stock_odt extends ModelePDFStock $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index 6297921dbcc..a57b996086b 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -409,7 +409,8 @@ class pdf_standard extends ModelePDFStock // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut diff --git a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php index 8fec70458c0..167e4a79bde 100644 --- a/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php @@ -454,7 +454,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font @@ -665,7 +666,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('', '', $default_font_size - 1); // Total table - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 1b76b805efc..3d8f62ce3ca 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -99,7 +99,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices $langs->load("bills"); // Check invoice num - $siyymm = ''; $max = ''; + $siyymm = ''; + $max = ''; $posindice = strlen($this->prefixinvoice) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -110,7 +111,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $siyymm = substr($row[0], 0, 6); $max = $row[0]; + $siyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($siyymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $siyymm)) { @@ -132,7 +134,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $siyymm = substr($row[0], 0, 6); $max = $row[0]; + $siyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($siyymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $siyymm)) { @@ -153,7 +156,8 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $siyymm = substr($row[0], 0, 6); $max = $row[0]; + $siyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($siyymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $siyymm)) { diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index f75641f2b9d..9e9799f44c6 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -136,7 +136,8 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 5bf915fb764..e256ad8f4aa 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -611,7 +611,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -941,7 +942,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); // Tableau total - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index bccf6c75195..879cbba7578 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -519,7 +519,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -819,7 +820,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); // Tableau total - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index ae33e2875f5..5aa92995c4c 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -102,7 +102,8 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -113,7 +114,8 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if (!$coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 18d597eb8ba..25dde592779 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -388,7 +388,8 @@ class pdf_standard extends ModelePDFSuppliersPayments // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index 7dae12ee64e..f86950c24d6 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -88,7 +88,8 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments { global $conf, $langs, $db; - $payyymm = ''; $max = ''; + $payyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -100,7 +101,8 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $payyymm = substr($row[0], 0, 6); $max = $row[0]; + $payyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($payyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $payyymm)) { diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index e9280b346e1..4b761f8099b 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -139,7 +139,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index e8a3861541b..356c3550100 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -509,7 +509,8 @@ class pdf_aurore extends ModelePDFSupplierProposal // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); + $curY = $tab_top_newpage; } $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -912,7 +913,8 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdf->SetFont('', '', $default_font_size - 1); // Tableau total - $col1x = 120; $col2x = 170; + $col1x = 120; + $col2x = 170; if ($this->page_largeur < 210) { // To work with US executive format $col2x -= 20; } diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index d61f6db2a36..b225899cef2 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -90,7 +90,8 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal { global $conf, $langs, $db; - $pryymm = ''; $max = ''; + $pryymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -102,7 +103,8 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $pryymm = substr($row[0], 0, 6); $max = $row[0]; + $pryymm = substr($row[0], 0, 6); + $max = $row[0]; } } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index 176cdd1191c..eb90baef7e5 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -127,7 +127,8 @@ class doc_generic_ticket_odt extends ModelePDFTicket $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 2badaf4a33f..523da47191d 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -151,8 +151,8 @@ class mod_ticket_simple extends ModeleNumRefTicket if ($max >= (pow(10, 4) - 1)) { $num = $max + 1; - } // If counter > 9999, we do not format on 4 chars, we take number as it is - else { + } else { + // If counter > 9999, we do not format on 4 chars, we take number as it is $num = sprintf("%04s", $max + 1); } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index cf39a523605..fb24e2782c9 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -136,7 +136,8 @@ class doc_generic_user_odt extends ModelePDFUser $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 2538f83dfa8..45a9469753e 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -139,7 +139,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); if (!$tmpdir) { - unset($listofdir[$key]); continue; + unset($listofdir[$key]); + continue; } if (!is_dir($tmpdir)) { $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); diff --git a/htdocs/core/modules/workstation/mod_workstation_standard.php b/htdocs/core/modules/workstation/mod_workstation_standard.php index d504f9191f5..34e727dd272 100755 --- a/htdocs/core/modules/workstation/mod_workstation_standard.php +++ b/htdocs/core/modules/workstation/mod_workstation_standard.php @@ -83,7 +83,8 @@ class mod_workstation_standard extends ModeleNumRefWorkstation { global $conf, $langs, $db; - $coyymm = ''; $max = ''; + $coyymm = ''; + $max = ''; $posindice = strlen($this->prefix) + 6; $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; @@ -99,7 +100,8 @@ class mod_workstation_standard extends ModeleNumRefWorkstation if ($resql) { $row = $db->fetch_row($resql); if ($row) { - $coyymm = substr($row[0], 0, 6); $max = $row[0]; + $coyymm = substr($row[0], 0, 6); + $max = $row[0]; } } if ($coyymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm)) { diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index a8196f60056..008e524f299 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -102,8 +102,8 @@ if ($modulepart == 'produit' || $modulepart == 'product' || $modulepart == 'serv accessforbidden(); } $accessallowed = 1; -} else // ticket, holiday, expensereport, societe... -{ +} else { + // ticket, holiday, expensereport, societe... $result = restrictedArea($user, $modulepart, $id, $modulepart); if (empty($user->rights->$modulepart->read) && empty($user->rights->$modulepart->lire)) { accessforbidden(); @@ -320,9 +320,8 @@ if (empty($backtourl)) { $section_dir .= '/'; } $backtourl = DOL_URL_ROOT."/website/index.php?action=file_manager&website=".$website.'§ion_dir='.urlencode($section_dir); - } - // Generic case that should work for everybody else - else { + } else { + // Generic case that should work for everybody else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($file); } } @@ -532,7 +531,9 @@ if (!empty($conf->use_javascript_ajax)) { $infoarray = dol_getImageSize($dir."/".GETPOST("file")); $height = $infoarray['height']; $width = $infoarray['width']; - $widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1; + $widthforcrop = $width; + $refsizeforcrop = 'orig'; + $ratioforcrop = 1; // If image is too large, we use another scale. if (!empty($_SESSION['dol_screenwidth']) && ($widthforcrop > round($_SESSION['dol_screenwidth'] / 2))) { $ratioforcrop = 2; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index ee3a1ab71a4..dc181f891b1 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -352,7 +352,8 @@ if ($nolinesbefore) { echo ''; } if (is_object($objectline)) { - $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line');; + $temps = $objectline->showOptionals($extrafields, 'create', array(), '', '', 1, 'line'); + ; if (!empty($temps)) { print '
    '; print $temps; diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 410918b99ed..afdfd904299 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -79,7 +79,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers $ret = $newobject->createFromProposal($object, $user); if ($ret < 0) { - $this->error = $newobject->error; $this->errors[] = $newobject->error; + $this->error = $newobject->error; + $this->errors[] = $newobject->error; } return $ret; } @@ -98,7 +99,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers $ret = $newobject->createFromOrder($object, $user); if ($ret < 0) { - $this->error = $newobject->error; $this->errors[] = $newobject->error; + $this->error = $newobject->error; + $this->errors[] = $newobject->error; } return $ret; } @@ -266,12 +268,14 @@ class InterfaceWorkflowManager extends DolibarrTriggers $order = new Commande($this->db); $ret = $order->fetch($object->origin_id); if ($ret < 0) { - $this->error = $order->error; $this->errors = $order->errors; + $this->error = $order->error; + $this->errors = $order->errors; return $ret; } $ret = $order->fetchObjectLinked($order->id, 'commande', null, 'shipping'); if ($ret < 0) { - $this->error = $order->error; $this->errors = $order->errors; + $this->error = $order->error; + $this->errors = $order->errors; return $ret; } //Build array of quantity shipped by product for an order @@ -307,7 +311,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers //No diff => mean everythings is shipped $ret = $object->setStatut(Commande::STATUS_CLOSED, $object->origin_id, $object->origin, 'ORDER_CLOSE'); if ($ret < 0) { - $this->error = $object->error; $this->errors = $object->errors; + $this->error = $object->error; + $this->errors = $object->errors; return $ret; } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index f9988e770bf..6d69c2d8a31 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -628,10 +628,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg = $langs->transnoentities("InvoiceCanceledInDolibarr", $object->ref); $object->sendtoid = 0; - } - - // Members - elseif ($action == 'MEMBER_VALIDATE') { + } elseif ($action == 'MEMBER_VALIDATE') { + // Members // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "members")); @@ -745,10 +743,8 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("Type").': '.$object->type; $object->sendtoid = 0; - } - - // Projects - elseif ($action == 'PROJECT_CREATE') { + } elseif ($action == 'PROJECT_CREATE') { + // Projects // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -784,10 +780,8 @@ class InterfaceActionsAuto extends DolibarrTriggers } $object->sendtoid = 0; - } - - // Project tasks - elseif ($action == 'TASK_CREATE') { + } elseif ($action == 'TASK_CREATE') { + // Project tasks // Load translation files required by the page $langs->loadLangs(array("agenda", "other", "projects")); @@ -843,10 +837,9 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= "\n".$langs->transnoentities("NewUser").': '.$langs->trans("None"); } $object->sendtoid = 0; - } - // TODO Merge all previous cases into this generic one - else // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... - { + } else { + // TODO Merge all previous cases into this generic one + // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). // Note that these key can be set in agenda setup, only if defined into c_action_trigger // Load translation files required by the page @@ -1026,7 +1019,9 @@ class InterfaceActionsAuto extends DolibarrTriggers } } - unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. + unset($object->actionmsg); + unset($object->actionmsg2); + unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. if ($ret > 0) { $_SESSION['LAST_ACTION_CREATED'] = $ret; diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index 19f23b0bfe4..c3d91fefc33 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -251,10 +251,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers $this->error = "ErrorLDAP ".$ldap->error; } } - } - - // Groupes - elseif ($action == 'USERGROUP_CREATE') { + } elseif ($action == 'USERGROUP_CREATE') { + // Groupes dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { $ldap = new Ldap(); @@ -326,10 +324,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers $this->error = "ErrorLDAP ".$ldap->error; } } - } - - // Contacts - elseif ($action == 'CONTACT_CREATE') { + } elseif ($action == 'CONTACT_CREATE') { + // Contacts dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_CONTACT_ACTIVE)) { $ldap = new Ldap(); @@ -396,10 +392,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers $this->error = "ErrorLDAP ".$ldap->error; } } - } - - // Members - elseif ($action == 'MEMBER_CREATE') { + } elseif ($action == 'MEMBER_CREATE') { + // Members dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { $ldap = new Ldap(); @@ -665,10 +659,8 @@ class InterfaceLdapsynchro extends DolibarrTriggers $this->errors[] = "ErrorLDAP ".$ldap->error; } } - } - - // Members types - elseif ($action == 'MEMBER_TYPE_CREATE') { + } elseif ($action == 'MEMBER_TYPE_CREATE') { + // Members types dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { $ldap = new Ldap(); diff --git a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php index ca1a33279bd..3233fb8eaaf 100644 --- a/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modMailmanspip_Mailmanspipsynchro.class.php @@ -92,10 +92,8 @@ class InterfaceMailmanSpipsynchro extends DolibarrTriggers } return $return; - } - - // Members - elseif ($action == 'MEMBER_VALIDATE') { + } elseif ($action == 'MEMBER_VALIDATE') { + // Members dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); $return = 0; diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index 8c13c377bd6..f5140cf296a 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -186,10 +186,8 @@ if ($action == 'add' && $permtoadd) { exit; } } -} - -// Deleting file -elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { +} elseif ($action == 'confirm_deletesection' && $confirm == 'yes') { + // Deleting file $result = $ecmdir->delete($user); setEventMessages($langs->trans("ECMSectionWasRemoved", $ecmdir->label), null, 'mesgs'); } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 8712bcc4615..cf117611500 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2503,9 +2503,8 @@ class User extends CommonObject // Only picto if ($withpictoimg > 0) { $picto = ''.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1).''; - } - // Picto must be a photo - else { + } else { + // Picto must be a photo $picto = ''.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1).''; } $result .= $picto; @@ -2740,9 +2739,9 @@ class User extends CommonObject if (!empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) { $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) } - } - // Set LDAP password if possible - elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password + } elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { + // Set LDAP password if possible + // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { // Just for the default MD5 ! if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { @@ -2750,9 +2749,8 @@ class User extends CommonObject $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase_crypted, 5); // Create OpenLDAP MD5 password from Dolibarr MD5 password } } - } - // Use $this->pass_indatabase value if exists - elseif (!empty($this->pass_indatabase)) { + } elseif (!empty($this->pass_indatabase)) { + // Use $this->pass_indatabase value if exists if (!empty($conf->global->LDAP_FIELD_PASSWORD)) { $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte } From 32ef55cd9e227db6cf32ab1cfe11c65da9cf949b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 1 Mar 2021 20:58:02 +0100 Subject: [PATCH 26/70] working default status/percent for event actioncomm --- htdocs/comm/action/card.php | 2 +- htdocs/core/class/defaultvalues.class.php | 4 +--- htdocs/core/lib/functions.lib.php | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 3b539895348..f572379d42e 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1072,7 +1072,7 @@ if ($action == 'create') { // Status print '
  • '.$langs->trans("Status").' / '.$langs->trans("Percentage").''; - $percent = -1; + $percent = GETPOST('complete')!=='' ? GETPOST('complete') : -1; if (GETPOSTISSET('status')) { $percent = GETPOST('status'); } elseif (GETPOSTISSET('percentage')) { diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php index ae5ed6e92fb..2f70dda34e5 100644 --- a/htdocs/core/class/defaultvalues.class.php +++ b/htdocs/core/class/defaultvalues.class.php @@ -295,12 +295,10 @@ class DefaultValues extends CommonObject if (!empty($limit)) { $sql .= ' '.$this->db->plimit($limit, $offset); } -print $sql; + $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); - var_dump($num); $i = 0; while ($i < ($limit ? min($limit, $num) : $num)) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e296fa5874e..9b35d8a2eda 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -311,7 +311,7 @@ function GETPOSTISSET($paramname) /** * Return value of a param into GET or POST supervariable. - * Use the property $user->default_values[path]['creatform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] + * Use the property $user->default_values[path]['createform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] * Note: The property $user->default_values is loaded by main.php when loading the user. * * @param string $paramname Name of parameter to found From 54d35fa59fe2ff680cbfe7fa8aae95838fcde599 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Mar 2021 20:00:32 +0000 Subject: [PATCH 27/70] Fixing style errors. --- htdocs/admin/agenda_other.php | 19 ++++++++-------- htdocs/admin/defaultvalues.php | 27 ++++++++++------------- htdocs/core/class/defaultvalues.class.php | 25 ++++++++------------- htdocs/user/class/user.class.php | 9 ++++---- 4 files changed, 34 insertions(+), 46 deletions(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 9e2f6acaebb..c355131b48b 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -83,15 +83,15 @@ if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); $defaultValues = new DefaultValues($db); - $result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); + $result = $defaultValues->fetchAll('', '', 0, 0, array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); if (!is_array($result) && $result<0) { - setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); - } elseif(count($result)>0) { - foreach($result as $defval) { + setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); + } elseif (count($result)>0) { + foreach ($result as $defval) { $defaultValues->id=$defval->id; $resultDel = $defaultValues->delete($user); if ($resultDel<0) { - setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); } } } @@ -103,9 +103,8 @@ if ($action == 'set') { $defaultValues->value=GETPOST('AGENDA_EVENT_DEFAULT_STATUS'); $resultCreat=$defaultValues->create($user); if ($resultCreat<0) { - setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); + setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); } - } elseif ($action == 'specimen') { // For orders $modele = GETPOST('module', 'alpha'); @@ -358,10 +357,10 @@ print ' '."\n"; $defval='na'; $defaultValues = new DefaultValues($db); -$result = $defaultValues->fetchAll('','',0,0,array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); +$result = $defaultValues->fetchAll('', '', 0, 0, array('t.page'=>'comm/action/card.php', 't.param'=>'complete','t.user_id'=>'0', 't.type'=>'createform', 't.entity'=>$conf->entity)); if (!is_array($result) && $result<0) { - setEventMessages($defaultValues->error,$defaultValues->errors,'errors'); -} elseif(count($result)>0) { + setEventMessages($defaultValues->error, $defaultValues->errors, 'errors'); +} elseif (count($result)>0) { $defval=reset($result)->value; } $formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index a6780df7b6e..14bccefcbd3 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -149,7 +149,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $result=$object->create($user); if ($result<0) { $action = ''; - setEventMessages($object->error,$object->errors,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action = ""; @@ -158,8 +158,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $defaultvalue = ''; } } - if (GETPOST('actionmodify')) - { + if (GETPOST('actionmodify')) { $object->id=$id; $object->type=$mode; $object->page=$urlpage; @@ -169,7 +168,7 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac $result=$object->update($user); if ($result<0) { $action = ''; - setEventMessages($object->error,$object->errors,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action = ""; @@ -182,13 +181,12 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac } // Delete line from delete picto -if ($action == 'delete') -{ +if ($action == 'delete') { $object->id=$id; $result=$object->delete($user); if ($result<0) { $action = ''; - setEventMessages($object->error,$object->errors,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -356,13 +354,12 @@ print '\n"; print '
    '; /*print ''; - print ''; - print ''; - print ''; - */ + print ''; + print ''; + print ''; + */ if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print dol_escape_htmltag($defaultvalue->value); else print ''; print ''; -<<<<<<< HEAD if (empty($amount) || !is_numeric($amount)) { - print ''; -======= - if (empty($amount) || !is_numeric($amount)) - { print ''; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git print ''; } else { print ''.price($amount).''; @@ -1048,13 +1038,9 @@ if ($source == 'invoice') { if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment $amount = price2num($invoice->total_ttc - ($invoice->getSommePaiement() + $invoice->getSumCreditNotesUsed() + $invoice->getSumDepositsUsed())); -<<<<<<< HEAD if (GETPOST("amount", 'int')) { - $amount = GETPOST("amount", 'int'); + $amount = GETPOST("amount", 'alpha'); } -======= - if (GETPOST("amount", 'int')) $amount = GETPOST("amount", 'alpha'); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git $amount = price2num($amount); } @@ -1106,14 +1092,8 @@ if ($source == 'invoice') { if ($object->type == $object::TYPE_CREDIT_NOTE) { print ''.$langs->trans("CreditNote").''; } elseif (empty($object->paye)) { -<<<<<<< HEAD if (empty($amount) || !is_numeric($amount)) { - print ''; -======= - if (empty($amount) || !is_numeric($amount)) - { print ''; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git print ''; } else { print ''.price($amount).''; @@ -1224,13 +1204,9 @@ if ($source == 'contractline') { } } -<<<<<<< HEAD - if (GETPOST("amount", 'int')) { - $amount = GETPOST("amount", 'int'); + if (GETPOST("amount", 'alpha')) { + $amount = GETPOST("amount", 'alpha'); } -======= - if (GETPOST("amount", 'alpha')) $amount = GETPOST("amount", 'alpha'); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git $amount = price2num($amount); } @@ -1320,14 +1296,8 @@ if ($source == 'contractline') { print ' ('.$langs->trans("ToComplete").')'; } print ''; -<<<<<<< HEAD if (empty($amount) || !is_numeric($amount)) { - print ''; -======= - if (empty($amount) || !is_numeric($amount)) - { print ''; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git print ''; } else { print ''.price($amount).''; @@ -1400,15 +1370,10 @@ if ($source == 'membersubscription') { if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment $amount = $subscription->total_ttc; -<<<<<<< HEAD - if (GETPOST("amount", 'int')) { - $amount = GETPOST("amount", 'int'); + if (GETPOST("amount", 'alpha')) { + $amount = GETPOST("amount", 'alpha'); } - $amount = price2num($amount); -======= - if (GETPOST("amount", 'alpha')) $amount = GETPOST("amount", 'alpha'); $amount = price2num($amount, 'MT'); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git } if (GETPOST('fulltag', 'alpha')) { @@ -1505,14 +1470,9 @@ if ($source == 'membersubscription') { } if (empty($amount) || !is_numeric($amount)) { //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); -<<<<<<< HEAD if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); } - print ''; - print ''; -======= - if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); print ''; if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { print ''; @@ -1520,15 +1480,11 @@ if ($source == 'membersubscription') { } else { print ''; } ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git } else { $valtoshow = $amount; if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); -<<<<<<< HEAD -======= $amount = $valtoshow; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git } print ''.price($valtoshow).''; print ''; @@ -1598,13 +1554,9 @@ if ($source == 'donation') { if ($action != 'dopayment') { // Do not change amount if we just click on first dopayment $amount = $subscription->total_ttc; -<<<<<<< HEAD - if (GETPOST("amount", 'int')) { - $amount = GETPOST("amount", 'int'); + if (GETPOST("amount", 'alpha')) { + $amount = GETPOST("amount", 'alpha'); } -======= - if (GETPOST("amount", 'alpha')) $amount = GETPOST("amount", 'alpha'); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git $amount = price2num($amount); } @@ -1678,24 +1630,16 @@ if ($source == 'donation') { } if (empty($amount) || !is_numeric($amount)) { //$valtoshow=price2num(GETPOST("newamount",'alpha'),'MT'); -<<<<<<< HEAD if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); } - print ''; -======= - if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); print ''; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git print ''; } else { $valtoshow = $amount; if (!empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) { $valtoshow = max($conf->global->MEMBER_MIN_AMOUNT, $valtoshow); -<<<<<<< HEAD -======= $amount = $valtoshow; ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git } print ''.price($valtoshow).''; print ''; @@ -2181,7 +2125,6 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme console.log("We click on buttontopay"); event.preventDefault(); -<<<<<<< HEAD if (cardholderName.value == '') { console.log("Field Card holder is empty"); @@ -2190,6 +2133,10 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme } else { + /* Disable button to pay and show hourglass cursor */ + jQuery('#hourglasstopay').show(); + jQuery('#buttontopay').hide(); + stripe.handleCardPayment( clientSecret, cardElement, { payment_method_data: { @@ -2240,63 +2187,10 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme }); } }); -======= - if (cardholderName.value == '') - { - console.log("Field Card holder is empty"); - var displayError = document.getElementById('card-errors'); - displayError.textContent = 'trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CardOwner"))); ?>'; - } - else - { - /* Disable button to pay and show hourglass cursor */ - jQuery('#hourglasstopay').show(); - jQuery('#buttontopay').hide(); - - stripe.handleCardPayment( - clientSecret, cardElement, { - payment_method_data: { - billing_details: { - name: cardholderName.value - thirdparty) && !empty($object->thirdparty->email))) { ?>, email: 'thirdparty->email); ?>' - thirdparty) && !empty($object->thirdparty->phone)) { ?>, phone: 'thirdparty->phone); ?>' - thirdparty)) { ?>, address: { - city: 'thirdparty->town); ?>', - thirdparty->country_code) { ?>country: 'thirdparty->country_code); ?>', - line1: 'thirdparty->address)); ?>', - postal_code: 'thirdparty->zip); ?>' - } - - } - }, - save_payment_method: /* true when a customer was provided when creating payment intent. true ask to save the card */ - } - ).then(function(result) { - console.log(result); - if (result.error) { - console.log("Error on result of handleCardPayment"); - jQuery('#buttontopay').show(); - jQuery('#hourglasstopay').hide(); - // Inform the user if there was an error - var errorElement = document.getElementById('card-errors'); - errorElement.textContent = result.error.message; - } else { - // The payment has succeeded. Display a success message. - console.log("No error on result of handleCardPayment, so we submit the form"); - // Submit the form - jQuery('#buttontopay').hide(); - jQuery('#hourglasstopay').show(); - // Send form (action=charge that will do nothing) - jQuery('#payment-form').submit(); - } - }); - } - }); ->>>>>>> branch '13.0' of git@github.com:Dolibarr/dolibarr.git // Old code for payment with option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION off and STRIPE_USE_NEW_CHECKOUT off From 287b215ef07cb790301cb41712a144cf6b55302e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Mar 2021 21:40:22 +0100 Subject: [PATCH 29/70] use tabs --- .../canvas/company/tpl/card_create.tpl.php | 16 ++++++++-------- .../canvas/individual/tpl/card_create.tpl.php | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/societe/canvas/company/tpl/card_create.tpl.php b/htdocs/societe/canvas/company/tpl/card_create.tpl.php index 8e1eda02c33..2deb1dba8b1 100644 --- a/htdocs/societe/canvas/company/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_create.tpl.php @@ -86,14 +86,14 @@ if (empty($conf) || !is_object($conf)) {
    trans('Supplier'); ?> control->tpl['yn_supplier']; ?>trans('SupplierCode'); ?> - - - - - -
    control->tpl['help_suppliercode']; ?>
    +
    trans('SupplierCode'); ?> + + + + + +
    control->tpl['help_suppliercode']; ?>
    trans('Supplier'); ?> control->tpl['yn_supplier']; ?>trans('SupplierCode'); ?> - - - - - -
    control->tpl['help_suppliercode']; ?>
    +
    trans('SupplierCode'); ?> + + + + + +
    control->tpl['help_suppliercode']; ?>