From 88fb094a78e42f721e1494e5cbe098910b58a87a Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Fri, 8 Nov 2019 22:02:30 +0100 Subject: [PATCH 001/248] Fix problem of display photo in the model Fix a problem with photo in the model : Before : Check in the current entity the product's repertory to find a photo Now : Check all entities product's repertories to find a photo --- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 14f4dfe8f9f..7fb456fc4d6 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2017-2018 Ferran Marcet * Copyright (C) 2018 Frédéric France + * Copyright (C) 2019 Pierre Ardoin * * 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 @@ -257,7 +258,13 @@ class pdf_azur extends ModelePDFPropales { if (! $arephoto) { - $dir = $conf->product->dir_output.'/'.$midir; + if ($conf->product->entity != $objphoto->entity) { + + $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities + }else{ + + $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product + } foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { From f7e81314775b74eb05f772a44ecc747a36b79b9e Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 26 Nov 2019 12:30:05 +0100 Subject: [PATCH 002/248] NEW : delay picto is currently useless because always displaied. If one day we add conf for supplier proposal in alert card, it will make sense, but not for now --- htdocs/supplier_proposal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 178c88a14ad..a3ffe34fff3 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -642,7 +642,7 @@ if ($resql) print ''; // Warning $warnornote = ''; - if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); + //if ($obj->fk_statut == 1 && $db->jdate($obj->date_valid) < ($now - $conf->supplier_proposal->warning_delay)) $warnornote .= img_warning($langs->trans("Late")); if (!empty($obj->note_private)) { $warnornote .= ($warnornote ? ' ' : ''); From 057ab6a059d6b63624fe90b87d4aa0318ddbf276 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Tue, 26 Nov 2019 11:52:04 +0000 Subject: [PATCH 003/248] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/holiday.php | 126 +++--- htdocs/core/lib/security.lib.php | 374 +++++++++--------- .../class/emailcollector.class.php | 340 ++++++++-------- 3 files changed, 420 insertions(+), 420 deletions(-) diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 5f6d52e1169..5eb36b111c8 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -39,7 +39,7 @@ $action = GETPOST('action', 'alpha'); $value = GETPOST('value', 'alpha'); $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); -$type='contract'; +$type = 'contract'; if (empty($conf->global->HOLIDAY_ADDON)) { @@ -56,12 +56,12 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { $maskconst = GETPOST('maskconstholiday', 'alpha'); - $maskvalue = GETPOST('maskholiday', 'alpha'); + $maskvalue = GETPOST('maskholiday', 'alpha'); if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; + if (!$res > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -73,20 +73,20 @@ if ($action == 'updateMask') elseif ($action == 'specimen') // For contract { - $modele= GETPOST('module', 'alpha'); + $modele = GETPOST('module', 'alpha'); $holiday = new Holiday($db); $holiday->initAsSpecimen(); // Search template files - $file=''; $classname=''; $filefound=0; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); + $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = "pdf_".$modele; break; } @@ -159,15 +159,15 @@ elseif ($action == 'setmod') elseif ($action == 'set_other') { - $freetext= GETPOST('HOLIDAY_FREE_TEXT', 'none'); // No alpha here, we want exact string + $freetext = GETPOST('HOLIDAY_FREE_TEXT', 'none'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - $draft= GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha'); + $draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (! $res1 > 0 || ! $res2 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0) $error++; - if (! $error) + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -182,16 +182,16 @@ elseif ($action == 'set_other') * View */ -$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader(); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("HolidaySetup"), $linkback, 'title_setup'); -$head=holiday_admin_prepare_head(); +$head = holiday_admin_prepare_head(); dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); @@ -222,18 +222,18 @@ foreach ($dirmodels as $reldir) $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file)-3, 3) == 'php') + if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; if ($module->isEnabled()) @@ -244,9 +244,9 @@ foreach ($dirmodels as $reldir) // Show example of numbering model print ''; - $tmp=$module->getExample(); + $tmp = $module->getExample(); if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } - elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); else print $tmp; print ''."\n"; @@ -263,21 +263,21 @@ foreach ($dirmodels as $reldir) } print ''; - $holiday=new Holiday($db); + $holiday = new Holiday($db); $holiday->initAsSpecimen(); // Info - $htmltooltip=''; - $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; - $nextval=$module->getNextValue($mysoc, $holiday); + $htmltooltip = ''; + $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval = $module->getNextValue($mysoc, $holiday); if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval - $htmltooltip.=''.$langs->trans("NextValue").': '; + $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') $nextval = $langs->trans($nextval); - $htmltooltip.=$nextval.'
'; + $htmltooltip .= $nextval.'
'; } else { - $htmltooltip.=$langs->trans($module->error).'
'; + $htmltooltip .= $langs->trans($module->error).'
'; } } @@ -317,14 +317,14 @@ print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', ''); // Defined model definition table $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = '".$type."'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = '".$type."'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -353,42 +353,42 @@ clearstatcache(); foreach ($dirmodels as $reldir) { - foreach (array('','/doc') as $valdir) + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/holiday".$valdir); if (is_dir($dir)) { - $handle=opendir($dir); + $handle = opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { - $filelist[]=$file; + $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach($filelist as $file) + foreach ($filelist as $file) { if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { if (file_exists($dir.'/'.$file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); require_once $dir.'/'.$file; $module = new $classname($db); - $modulequalified=1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; if ($modulequalified) { print ''; - print (empty($module->name)?$name:$module->name); + print (empty($module->name) ? $name : $module->name); print "\n"; if (method_exists($module, 'info')) print $module->info($langs); else print $module->description; @@ -423,18 +423,18 @@ foreach ($dirmodels as $reldir) print ''; // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); - $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); - $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); - $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1); + $htmltooltip .= '
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1); + $htmltooltip .= '
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1); + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1); print ''; @@ -485,16 +485,16 @@ print ''.$langs->trans("Parameter").''; print ''.$langs->trans("Value").''; print "\n"; -$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); -$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); +$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; -$htmltext.='
'; +foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +$htmltext .= ''; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; -$variablename='HOLIDAY_FREE_TEXT'; +$variablename = 'HOLIDAY_FREE_TEXT'; if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; @@ -502,7 +502,7 @@ if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); + $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes'); print $doleditor->Create(); } print ''."\n"; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 7a3102e8aca..5a7b8342bd6 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -38,24 +38,24 @@ function dol_encode($chain, $key = '1') { if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { - $output_tab=array(); - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength; $i++) + $output_tab = array(); + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $output_tab[$i] = chr(ord(substr($chain, $i, 1))+17); + $output_tab[$i] = chr(ord(substr($chain, $i, 1)) + 17); } $chain = implode("", $output_tab); } elseif ($key) { - $result=''; - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength; $i++) + $result = ''; + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $keychar = substr($key, ($i % strlen($key))-1, 1); - $result.= chr(ord(substr($chain, $i, 1))+(ord($keychar)-65)); + $keychar = substr($key, ($i % strlen($key)) - 1, 1); + $result .= chr(ord(substr($chain, $i, 1)) + (ord($keychar) - 65)); } - $chain=$result; + $chain = $result; } return base64_encode($chain); @@ -76,25 +76,25 @@ function dol_decode($chain, $key = '1') if (is_numeric($key) && $key == '1') // rule 1 is offset of 17 for char { - $output_tab=array(); - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength;$i++) + $output_tab = array(); + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $output_tab[$i] = chr(ord(substr($chain, $i, 1))-17); + $output_tab[$i] = chr(ord(substr($chain, $i, 1)) - 17); } $chain = implode("", $output_tab); } elseif ($key) { - $result=''; - $strlength=dol_strlen($chain); - for ($i=0; $i < $strlength; $i++) + $result = ''; + $strlength = dol_strlen($chain); + for ($i = 0; $i < $strlength; $i++) { - $keychar = substr($key, ($i % strlen($key))-1, 1); - $result.= chr(ord(substr($chain, $i, 1))-(ord($keychar)-65)); + $keychar = substr($key, ($i % strlen($key)) - 1, 1); + $result .= chr(ord(substr($chain, $i, 1)) - (ord($keychar) - 65)); } - $chain=$result; + $chain = $result; } return $chain; @@ -116,21 +116,21 @@ function dol_hash($chain, $type = '0') global $conf; // No need to add salt for password_hash - if (($type == '0' || $type == 'auto') && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) + if (($type == '0' || $type == 'auto') && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_hash')) { return password_hash($chain, PASSWORD_DEFAULT); } // Salt value - if (! empty($conf->global->MAIN_SECURITY_SALT)) $chain=$conf->global->MAIN_SECURITY_SALT.$chain; + if (!empty($conf->global->MAIN_SECURITY_SALT)) $chain = $conf->global->MAIN_SECURITY_SALT.$chain; if ($type == '1' || $type == 'sha1') return sha1($chain); elseif ($type == '2' || $type == 'sha1md5') return sha1(md5($chain)); elseif ($type == '3' || $type == 'md5') return md5($chain); elseif ($type == '4' || $type == 'md5openldap') return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base) elseif ($type == '5') return hash('sha256', $chain); - elseif (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); - elseif (! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); + elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1') return sha1($chain); + elseif (!empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'sha1md5') return sha1(md5($chain)); // No particular encoding defined, use default return md5($chain); @@ -151,10 +151,10 @@ function dol_verifyHash($chain, $hash, $type = '0') { global $conf; - if ($type == '0' && ! empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { + if ($type == '0' && !empty($conf->global->MAIN_SECURITY_HASH_ALGO) && $conf->global->MAIN_SECURITY_HASH_ALGO == 'password_hash' && function_exists('password_verify')) { if ($hash[0] == '$') return password_verify($chain, $hash); - elseif(strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 - elseif(strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 + elseif (strlen($hash) == 32) return dol_verifyHash($chain, $hash, '3'); // md5 + elseif (strlen($hash) == 40) return dol_verifyHash($chain, $hash, '2'); // sha1md5 return false; } @@ -189,9 +189,9 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; // Get more permissions checks from hooks - $parameters=array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); - $reshook=$hookmanager->executeHooks('restrictedArea', $parameters); - if (! empty($hookmanager->resArray['result'])) return true; + $parameters = array('features'=>$features, 'objectid'=>$objectid, 'idtype'=>$dbt_select); + $reshook = $hookmanager->executeHooks('restrictedArea', $parameters); + if (!empty($hookmanager->resArray['result'])) return true; if ($reshook > 0) return false; if ($dbt_select != 'rowid' && $dbt_select != 'id') $objectid = "'".$objectid."'"; @@ -202,227 +202,227 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f elseif (preg_match('/\|/', $features)) $featuresarray = explode("|", $features); // More subfeatures to check - if (! empty($feature2)) $feature2 = explode("|", $feature2); + if (!empty($feature2)) $feature2 = explode("|", $feature2); // More parameters $params = explode('&', $tableandshare); - $dbtablename=(! empty($params[0]) ? $params[0] : ''); - $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); + $dbtablename = (!empty($params[0]) ? $params[0] : ''); + $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); - $listofmodules=explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + $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 + $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++; } + if (!$user->rights->societe->lire && !$user->rights->fournisseur->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'contact') { - if (! $user->rights->societe->contact->lire) { $readok=0; $nbko++; } + if (!$user->rights->societe->contact->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'produit|service') { - if (! $user->rights->produit->lire && ! $user->rights->service->lire) { $readok=0; $nbko++; } + if (!$user->rights->produit->lire && !$user->rights->service->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'prelevement') { - if (! $user->rights->prelevement->bons->lire) { $readok=0; $nbko++; } + if (!$user->rights->prelevement->bons->lire) { $readok = 0; $nbko++; } } elseif ($feature == 'cheque') { - if (! $user->rights->banque->cheque) { $readok=0; $nbko++; } + if (!$user->rights->banque->cheque) { $readok = 0; $nbko++; } } elseif ($feature == 'projet') { - if (! $user->rights->projet->lire && ! $user->rights->projet->all->lire) { $readok=0; $nbko++; } + if (!$user->rights->projet->lire && !$user->rights->projet->all->lire) { $readok = 0; $nbko++; } } - elseif (! empty($feature2)) // This is for permissions on 2 levels + elseif (!empty($feature2)) // This is for permissions on 2 levels { - $tmpreadok=1; - foreach($feature2 as $subfeature) + $tmpreadok = 1; + foreach ($feature2 as $subfeature) { if ($subfeature == 'user' && $user->id == $objectid) continue; // A user can always read its own card - if (! empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok=0; } - elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok=0; } - else { $tmpreadok=1; break; } // Break is to bypass second test if the first is ok + if (!empty($subfeature) && empty($user->rights->$feature->$subfeature->lire) && empty($user->rights->$feature->$subfeature->read)) { $tmpreadok = 0; } + elseif (empty($subfeature) && empty($user->rights->$feature->lire) && empty($user->rights->$feature->read)) { $tmpreadok = 0; } + else { $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 + if (!$tmpreadok) // We found a test on feature that is ko { - $readok=0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). + $readok = 0; // All tests are ko (we manage here the and, the or will be managed later using $nbko). $nbko++; } } - elseif (! empty($feature) && ($feature!='user' && $feature!='usergroup')) // This is permissions on 1 level + elseif (!empty($feature) && ($feature != 'user' && $feature != 'usergroup')) // This is permissions on 1 level { if (empty($user->rights->$feature->lire) && empty($user->rights->$feature->read) - && empty($user->rights->$feature->run)) { $readok=0; $nbko++; } + && empty($user->rights->$feature->run)) { $readok = 0; $nbko++; } } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok=1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $readok = 1; - if (! $readok) accessforbidden(); + if (!$readok) accessforbidden(); //print "Read access is ok"; // Check write permission from module (we need to know write permission to create but also to delete drafts record) - $createok=1; $nbko=0; - if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) + $createok = 1; $nbko = 0; + if (GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update' || ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete')) { foreach ($featuresarray as $feature) { if ($feature == 'contact') { - if (! $user->rights->societe->contact->creer) { $createok=0; $nbko++; } + if (!$user->rights->societe->contact->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'produit|service') { - if (! $user->rights->produit->creer && ! $user->rights->service->creer) { $createok=0; $nbko++; } + if (!$user->rights->produit->creer && !$user->rights->service->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'prelevement') { - if (! $user->rights->prelevement->bons->creer) { $createok=0; $nbko++; } + if (!$user->rights->prelevement->bons->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'commande_fournisseur') { - if (! $user->rights->fournisseur->commande->creer) { $createok=0; $nbko++; } + if (!$user->rights->fournisseur->commande->creer) { $createok = 0; $nbko++; } } elseif ($feature == 'banque') { - if (! $user->rights->banque->modifier) { $createok=0; $nbko++; } + if (!$user->rights->banque->modifier) { $createok = 0; $nbko++; } } elseif ($feature == 'cheque') { - if (! $user->rights->banque->cheque) { $createok=0; $nbko++; } + if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; } } - elseif (! empty($feature2)) // This is for permissions on one level + elseif (!empty($feature2)) // This is for permissions on one level { - foreach($feature2 as $subfeature) + foreach ($feature2 as $subfeature) { if (empty($user->rights->$feature->$subfeature->creer) && empty($user->rights->$feature->$subfeature->write) && empty($user->rights->$feature->$subfeature->create)) { - $createok=0; + $createok = 0; $nbko++; } else { - $createok=1; + $createok = 1; // Break to bypass second test if the first is ok break; } } } - elseif (! empty($feature)) // This is for permissions on 2 levels ('creer' or 'write') + elseif (!empty($feature)) // This is for permissions on 2 levels ('creer' or 'write') { //print '
feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; if (empty($user->rights->$feature->creer) && empty($user->rights->$feature->write) && empty($user->rights->$feature->create)) { - $createok=0; + $createok = 0; $nbko++; } } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok=1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $createok = 1; - if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && ! $createok) accessforbidden(); + if ((GETPOST('action', 'aZ09') == 'create' || GETPOST('action', 'aZ09') == 'update') && !$createok) accessforbidden(); //print "Write access is ok"; } // Check create user permission - $createuserok=1; + $createuserok = 1; if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') { - if (! $user->rights->user->user->creer) $createuserok=0; + if (!$user->rights->user->user->creer) $createuserok = 0; - if (! $createuserok) accessforbidden(); + if (!$createuserok) accessforbidden(); //print "Create user access is ok"; } // Check delete permission from module - $deleteok=1; $nbko=0; - if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') + $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') { - if (! $user->rights->societe->contact->supprimer) $deleteok=0; + if (!$user->rights->societe->contact->supprimer) $deleteok = 0; } elseif ($feature == 'produit|service') { - if (! $user->rights->produit->supprimer && ! $user->rights->service->supprimer) $deleteok=0; + if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) $deleteok = 0; } elseif ($feature == 'commande_fournisseur') { - if (! $user->rights->fournisseur->commande->supprimer) $deleteok=0; + if (!$user->rights->fournisseur->commande->supprimer) $deleteok = 0; } elseif ($feature == 'banque') { - if (! $user->rights->banque->modifier) $deleteok=0; + if (!$user->rights->banque->modifier) $deleteok = 0; } elseif ($feature == 'cheque') { - if (! $user->rights->banque->cheque) $deleteok=0; + if (!$user->rights->banque->cheque) $deleteok = 0; } elseif ($feature == 'ecm') { - if (! $user->rights->ecm->upload) $deleteok=0; + if (!$user->rights->ecm->upload) $deleteok = 0; } elseif ($feature == 'ftp') { - if (! $user->rights->ftp->write) $deleteok=0; + if (!$user->rights->ftp->write) $deleteok = 0; }elseif ($feature == 'salaries') { - if (! $user->rights->salaries->delete) $deleteok=0; + if (!$user->rights->salaries->delete) $deleteok = 0; } elseif ($feature == 'salaries') { - if (! $user->rights->salaries->delete) $deleteok=0; + if (!$user->rights->salaries->delete) $deleteok = 0; } - elseif (! empty($feature2)) // This is for permissions on 2 levels + elseif (!empty($feature2)) // This is for permissions on 2 levels { - foreach($feature2 as $subfeature) + foreach ($feature2 as $subfeature) { - if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok=0; - else { $deleteok=1; break; } // For bypass the second test if the first is ok + if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) $deleteok = 0; + else { $deleteok = 1; break; } // For bypass the second test if the first is ok } } - elseif (! empty($feature)) // This is used for permissions on 1 level + elseif (!empty($feature)) // This is used for permissions on 1 level { //print '
feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete; if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) - && empty($user->rights->$feature->run)) $deleteok=0; + && empty($user->rights->$feature->run)) $deleteok = 0; } } // If a or and at least one ok - if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok=1; + if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) $deleteok = 1; - if (! $deleteok && ! ($isdraft && $createok)) accessforbidden(); + if (!$deleteok && !($isdraft && $createok)) accessforbidden(); //print "Delete access is ok"; } // If we have a particular object to check permissions on, we check this object // is linked to a company allowed to $user. - if (! empty($objectid) && $objectid > 0) + if (!empty($objectid) && $objectid > 0) { $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); - $params=array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); + $params = array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); } @@ -449,65 +449,65 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand // More parameters $params = explode('&', $tableandshare); - $dbtablename=(! empty($params[0]) ? $params[0] : ''); - $sharedelement=(! empty($params[1]) ? $params[1] : $dbtablename); + $dbtablename = (!empty($params[0]) ? $params[0] : ''); + $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); foreach ($featuresarray as $feature) { - $sql=''; + $sql = ''; // For backward compatibility - if ($feature == 'member') $feature='adherent'; - if ($feature == 'project') $feature='projet'; - if ($feature == 'task') $feature='projet_task'; + if ($feature == 'member') $feature = 'adherent'; + if ($feature == 'project') $feature = 'projet'; + if ($feature == 'task') $feature = 'projet_task'; - $check = array('adherent','banque','bom','don','user','usergroup','product','produit','service','produit|service','categorie','resource','expensereport','holiday'); // Test on entity only (Objects with no link to company) - $checksoc = array('societe'); // Test for societe object - $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). - $checkproject = array('projet','project'); // Test for project object + $check = array('adherent', 'banque', 'bom', 'don', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource', 'expensereport', 'holiday'); // Test on entity only (Objects with no link to company) + $checksoc = array('societe'); // Test for societe object + $checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). + $checkproject = array('projet', 'project'); // Test for project object $checktask = array('projet_task'); - $nocheck = array('barcode','stock'); // No test + $nocheck = array('barcode', 'stock'); // No test //$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). // If dbtablename not defined, we use same name for table than module name if (empty($dbtablename)) { $dbtablename = $feature; - $sharedelement = (! empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. + $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too. } // Check permission for object with entity if (in_array($feature, $check)) { $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - if (($feature == 'user' || $feature == 'usergroup') && ! empty($conf->multicompany->enabled)) + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) { - if (! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if ($conf->entity == 1 && $user->admin && ! $user->entity) + if ($conf->entity == 1 && $user->admin && !$user->entity) { - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IS NOT NULL"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IS NOT NULL"; } else { - $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND ((ug.fk_user = dbt.rowid"; - $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; - $sql.= " OR dbt.entity = 0)"; // Show always superadmin + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND ((ug.fk_user = dbt.rowid"; + $sql .= " AND ug.entity IN (".getEntity('usergroup')."))"; + $sql .= " OR dbt.entity = 0)"; // Show always superadmin } } else { - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } else { - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checksoc)) // We check feature = checksoc @@ -518,23 +518,23 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($user->socid <> $objectid) return false; } // 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)) { $sql = "SELECT COUNT(sc.fk_soc) as nb"; - $sql.= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s)"; - $sql.= " WHERE sc.fk_soc IN (".$objectid.")"; - $sql.= " AND sc.fk_user = ".$user->id; - $sql.= " AND sc.fk_soc = s.rowid"; - $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s)"; + $sql .= " WHERE sc.fk_soc IN (".$objectid.")"; + $sql .= " AND sc.fk_user = ".$user->id; + $sql .= " AND sc.fk_soc = s.rowid"; + $sql .= " AND s.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)) { $sql = "SELECT COUNT(s.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE s.rowid IN (".$objectid.")"; - $sql.= " AND s.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid IN (".$objectid.")"; + $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checkother)) // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...). @@ -543,110 +543,110 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand if ($user->socid > 0) { $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.fk_soc = ".$user->socid; + $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)) { $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 = '".$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).")"; + $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 = '".$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)) { $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).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checkproject)) { - if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) + if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic=new Project($db); - $tmps=$projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); - $tmparray=explode(',', $tmps); - if (! in_array($objectid, $tmparray)) return false; + $projectstatic = new Project($db); + $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); + $tmparray = explode(',', $tmps); + if (!in_array($objectid, $tmparray)) return false; } else { $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).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } elseif (in_array($feature, $checktask)) { - if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) + if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) { $task = new Task($db); $task->fetch($objectid); include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic=new Project($db); - $tmps=$projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); - $tmparray=explode(',', $tmps); - if (! in_array($task->fk_project, $tmparray)) return false; + $projectstatic = new Project($db); + $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0); + $tmparray = explode(',', $tmps); + if (!in_array($task->fk_project, $tmparray)) return false; } else { $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).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } - elseif (! in_array($feature, $nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield + elseif (!in_array($feature, $nocheck)) // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield { // If external user: Check permission for external users if ($user->socid > 0) { if (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= " WHERE dbt.rowid IN (".$objectid.")"; - $sql.= " AND dbt.".$dbt_keyfield." = ".$user->socid; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.rowid IN (".$objectid.")"; + $sql .= " AND dbt.".$dbt_keyfield." = ".$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 (empty($dbt_keyfield)) dol_print_error('', 'Param dbt_keyfield is required but not defined'); $sql = "SELECT COUNT(sc.fk_soc) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND sc.fk_soc = dbt.".$dbt_keyfield; - $sql.= " AND dbt.".$dbt_keyfield." = s.rowid"; - $sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; - $sql.= " AND sc.fk_user = ".$user->id; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield; + $sql .= " AND dbt.".$dbt_keyfield." = s.rowid"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; + $sql .= " AND sc.fk_user = ".$user->id; } // If multicompany and internal users with all permissions, check user is in correct entity - elseif (! empty($conf->multicompany->enabled)) + elseif (!empty($conf->multicompany->enabled)) { $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).")"; + $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt"; + $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; + $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; } } if ($sql) { - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if (! $obj || $obj->nb < count(explode(',', $objectid))) return false; + if (!$obj || $obj->nb < count(explode(',', $objectid))) return false; } else { @@ -671,10 +671,10 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { global $conf, $db, $user, $langs, $hookmanager; - if (! is_object($langs)) + if (!is_object($langs)) { include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs=new Translate('', $conf); + $langs = new Translate('', $conf); $langs->setDefaultLang(); } @@ -686,7 +686,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho elseif (function_exists("llxHeaderVierge")) llxHeaderVierge(''); } print '
'; - if (! $message) print $langs->trans("ErrorForbidden"); + if (!$message) print $langs->trans("ErrorForbidden"); else print $message; print '
'; print '
'; @@ -700,7 +700,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho $hookmanager->initHooks(array('main')); } $parameters = array('message'=>$message, 'params'=>$params); - $reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) { diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 711249576a1..d988711ae12 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -64,11 +64,11 @@ class EmailCollector extends CommonObject /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array(); + protected $childtables = array(); /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade=array('emailcollector_emailcollectorfilter','emailcollector_emailcollectoraction'); + protected $childtablesoncascade = array('emailcollector_emailcollectorfilter', 'emailcollector_emailcollectoraction'); /** @@ -94,10 +94,10 @@ class EmailCollector extends CommonObject /** * @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','visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), - 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), + public $fields = array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), + 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector'), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1), 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>100, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com'), @@ -107,7 +107,7 @@ class EmailCollector extends CommonObject //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), - 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect','visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), + 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), @@ -222,13 +222,13 @@ class EmailCollector extends CommonObject } // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) + foreach ($this->fields as $key => $val) { if (is_array($val['arrayofkeyval'])) { - foreach($val['arrayofkeyval'] as $key2 => $val2) + foreach ($val['arrayofkeyval'] as $key2 => $val2) { - $this->fields[$key]['arrayofkeyval'][$key2]=$langs->trans($val2); + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); } } } @@ -279,10 +279,10 @@ class EmailCollector extends CommonObject if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); - foreach($object->array_options as $key => $option) + foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); @@ -437,38 +437,38 @@ class EmailCollector extends CommonObject { global $conf, $langs, $hookmanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; - $label = '' . $langs->trans("EmailCollector") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = ''.$langs->trans("EmailCollector").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref; $url = dol_buildpath('/admin/emailcollector_card.php', 1).'?id='.$this->id; if ($option != 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { - $add_save_lastsearch_values=1; + $add_save_lastsearch_values = 1; } if ($add_save_lastsearch_values) { - $url.='&save_lastsearch_values=1'; + $url .= '&save_lastsearch_values=1'; } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowEmailCollector"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowEmailCollector"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; /* $hookmanager->initHooks(array('myobjectdao')); @@ -681,7 +681,7 @@ class EmailCollector extends CommonObject $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; - if ($norsh || ! empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; + if ($norsh || !empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; $connectstringserver = '{'.$this->host.':993'.$flags.'}'; @@ -698,13 +698,13 @@ class EmailCollector extends CommonObject { if (function_exists('mb_convert_encoding')) { // change spaces by entropy because mb_convert fail with spaces - $str=preg_replace("/ /", "xyxy", $str); + $str = preg_replace("/ /", "xyxy", $str); // if mb_convert work if ($str = mb_convert_encoding($str, "UTF-7")) { // change characters - $str=preg_replace("/\+A/", "&A", $str); + $str = preg_replace("/\+A/", "&A", $str); // change to spaces again - $str=preg_replace("/xyxy/", " ", $str); + $str = preg_replace("/xyxy/", " ", $str); return $str; } else { // print error and return false @@ -762,59 +762,59 @@ class EmailCollector extends CommonObject // Overwrite values with values extracted from source email // $this->actionparam = 'opportunity_status=123;abc=EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); - foreach($arrayvaluetouse as $propertytooverwrite => $valueforproperty) + foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { - $tmpclass=''; $tmpproperty=''; - $tmparray=explode('.', $propertytooverwrite); + $tmpclass = ''; $tmpproperty = ''; + $tmparray = explode('.', $propertytooverwrite); if (count($tmparray) == 2) { - $tmpclass=$tmparray[0]; - $tmpproperty=$tmparray[1]; + $tmpclass = $tmparray[0]; + $tmpproperty = $tmparray[1]; } else { - $tmpproperty=$tmparray[0]; + $tmpproperty = $tmparray[0]; } - if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object + if ($tmpclass && ($tmpclass != $object->element)) continue; // Property is for another type of object //if (property_exists($object, $tmpproperty) || preg_match('/^options_/', $tmpproperty)) if ($tmpproperty) { - $sourcestring=''; - $sourcefield=''; - $regexstring=''; + $sourcestring = ''; + $sourcefield = ''; + $regexstring = ''; //$transformationstring=''; - $regforregex=array(); + $regforregex = array(); if (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*):([^:])$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[1]; - $regexstring=$regforregex[2]; + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; //$transofrmationstring=$regforregex[3]; } elseif (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[1]; - $regexstring=$regforregex[2]; + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; } - if (! empty($sourcefield) && ! empty($regexstring)) + if (!empty($sourcefield) && !empty($regexstring)) { - if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext; - elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject; - elseif (strtolower($sourcefield) == 'header') $sourcestring=$header; + if (strtolower($sourcefield) == 'body') $sourcestring = $messagetext; + elseif (strtolower($sourcefield) == 'subject') $sourcestring = $subject; + elseif (strtolower($sourcefield) == 'header') $sourcestring = $header; if ($sourcestring) { - $regforval=array(); - $regexoptions=''; - if (strtolower($sourcefield) == 'body') $regexoptions='ms'; // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too - if (strtolower($sourcefield) == 'header') $regexoptions='m'; // The m means ^ and $ char is valid at each new line. + $regforval = array(); + $regexoptions = ''; + if (strtolower($sourcefield) == 'body') $regexoptions = 'ms'; // The m means ^ and $ char is valid at each new line. The s means the char '.' is valid for new lines char too + if (strtolower($sourcefield) == 'header') $regexoptions = 'm'; // The m means ^ and $ char is valid at each new line. //var_dump($tmpproperty.' - '.$regexstring.' - '.$regexoptions.' - '.$sourcestring); if (preg_match('/'.$regexstring.'/'.$regexoptions, $sourcestring, $regforval)) { //var_dump($regforval[1]);exit; // Overwrite param $tmpproperty - $object->$tmpproperty = isset($regforval[1])?trim($regforval[1]):null; + $object->$tmpproperty = isset($regforval[1]) ?trim($regforval[1]) : null; } else { @@ -832,24 +832,24 @@ class EmailCollector extends CommonObject } elseif (preg_match('/^(SET|SETIFEMPTY):(.*)$/', $valueforproperty, $regforregex)) { - $valuecurrent=''; + $valuecurrent = ''; if (preg_match('/^options_/', $tmpproperty)) $valuecurrent = $object->array_options[preg_replace('/^options_/', '', $tmpproperty)]; else $valuecurrent = $object->$tmpproperty; if ($regforregex[1] == 'SET' || empty($valuecurrent)) { $valuetouse = $regforregex[2]; - $substitutionarray=array(); - $matcharray=array(); + $substitutionarray = array(); + $matcharray = array(); preg_match_all('/__([a-z0-9]+(?:_[a-z0-9]+)?)__/i', $valuetouse, $matcharray); //var_dump($tmpproperty.' - '.$object->$tmpproperty.' - '.$valuetouse); var_dump($matcharray); if (is_array($matcharray[1])) // $matcharray[1] is array with list of substitution key found without the __ { - foreach($matcharray[1] as $keytoreplace) + foreach ($matcharray[1] as $keytoreplace) { if ($keytoreplace && isset($object->$keytoreplace)) { - $substitutionarray['__'.$keytoreplace.'__']=$object->$keytoreplace; + $substitutionarray['__'.$keytoreplace.'__'] = $object->$keytoreplace; } } } @@ -921,73 +921,73 @@ class EmailCollector extends CommonObject $this->fetchActions(); $sourcedir = $this->source_directory; - $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' + $targetdir = ($this->target_directory ? $this->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' $connectstringserver = $this->getConnectStringIMAP(); $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); $connection = imap_open($connectstringsource, $this->login, $this->password); - if (! $connection) + if (!$connection) { $this->error = 'Failed to open IMAP connection '.$connectstringsource; return -3; } - imap_errors(); // Clear stack of errors. + imap_errors(); // Clear stack of errors. // $conf->global->MAIL_PREFIX_FOR_EMAIL_ID must be defined - $host=dol_getprefix('email'); + $host = dol_getprefix('email'); // Define the IMAP search string // See https://tools.ietf.org/html/rfc3501#section-6.4.4 for IMAPv4 (PHP not yet compatible) // See https://tools.ietf.org/html/rfc1064 page 13 for IMAPv2 //$search='ALL'; - $search='UNDELETED'; // Seems not supported by some servers - $searchhead=''; - $searchfilterdoltrackid=0; - $searchfilternodoltrackid=0; - foreach($this->filters as $rule) + $search = 'UNDELETED'; // Seems not supported by some servers + $searchhead = ''; + $searchfilterdoltrackid = 0; + $searchfilternodoltrackid = 0; + foreach ($this->filters as $rule) { if (empty($rule['status'])) continue; - if ($rule['type'] == 'to') $search.=($search?' ':'').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'bcc') $search.=($search?' ':'').'BCC'; - if ($rule['type'] == 'cc') $search.=($search?' ':'').'CC'; - if ($rule['type'] == 'from') $search.=($search?' ':'').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'subject') $search.=($search?' ':'').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'body') $search.=($search?' ':'').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'header') $search.=($search?' ':'').'HEADER '.$rule['rulevalue']; + if ($rule['type'] == 'to') $search .= ($search ? ' ' : '').'TO "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'bcc') $search .= ($search ? ' ' : '').'BCC'; + if ($rule['type'] == 'cc') $search .= ($search ? ' ' : '').'CC'; + if ($rule['type'] == 'from') $search .= ($search ? ' ' : '').'FROM "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'subject') $search .= ($search ? ' ' : '').'SUBJECT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'body') $search .= ($search ? ' ' : '').'BODY "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'header') $search .= ($search ? ' ' : '').'HEADER '.$rule['rulevalue']; - if ($rule['type'] == 'notinsubject') $search.=($search?' ':'').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'notinbody') $search.=($search?' ':'').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'notinsubject') $search .= ($search ? ' ' : '').'SUBJECT NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'notinbody') $search .= ($search ? ' ' : '').'BODY NOT "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'seen') $search.=($search?' ':'').'SEEN'; - if ($rule['type'] == 'unseen') $search.=($search?' ':'').'UNSEEN'; - if ($rule['type'] == 'unanswered') $search.=($search?' ':'').'UNANSWERED'; - if ($rule['type'] == 'answered') $search.=($search?' ':'').'ANSWERED'; - if ($rule['type'] == 'smaller') $search.=($search?' ':'').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'larger') $search.=($search?' ':'').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'seen') $search .= ($search ? ' ' : '').'SEEN'; + if ($rule['type'] == 'unseen') $search .= ($search ? ' ' : '').'UNSEEN'; + if ($rule['type'] == 'unanswered') $search .= ($search ? ' ' : '').'UNANSWERED'; + if ($rule['type'] == 'answered') $search .= ($search ? ' ' : '').'ANSWERED'; + if ($rule['type'] == 'smaller') $search .= ($search ? ' ' : '').'SMALLER "'.str_replace('"', '', $rule['rulevalue']).'"'; + if ($rule['type'] == 'larger') $search .= ($search ? ' ' : '').'LARGER "'.str_replace('"', '', $rule['rulevalue']).'"'; - if ($rule['type'] == 'withtrackingid') { $searchfilterdoltrackid++; $searchhead.='/References.*@'.preg_quote($host, '/').'/'; } - if ($rule['type'] == 'withouttrackingid') { $searchfilternodoltrackid++; $searchhead.='! /References.*@'.preg_quote($host, '/').'/';} + if ($rule['type'] == 'withtrackingid') { $searchfilterdoltrackid++; $searchhead .= '/References.*@'.preg_quote($host, '/').'/'; } + if ($rule['type'] == 'withouttrackingid') { $searchfilternodoltrackid++; $searchhead .= '! /References.*@'.preg_quote($host, '/').'/'; } } if (empty($targetdir)) // Use last date as filter if there is no targetdir defined. { - $fromdate=0; + $fromdate = 0; if ($this->datelastok) $fromdate = $this->datelastok; - if ($fromdate > 0) $search.=($search?' ':'').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10) + if ($fromdate > 0) $search .= ($search ? ' ' : '').'SINCE '.date('j-M-Y', $fromdate - 1); // SENTSINCE not supported. Date must be X-Abc-9999 (X on 1 digit if < 10) //$search.=($search?' ':'').'SINCE 8-Apr-2018'; } dol_syslog("IMAP search string = ".$search); //var_dump($search); - $nbemailprocessed=0; - $nbemailok=0; - $nbactiondone=0; + $nbemailprocessed = 0; + $nbemailok = 0; + $nbactiondone = 0; // Scan IMAP inbox - $arrayofemail= imap_search($connection, $search, null, "UTF-8"); + $arrayofemail = imap_search($connection, $search, null, "UTF-8"); if ($arrayofemail === false) { // Nothing found or search string not understood @@ -1001,7 +1001,7 @@ class EmailCollector extends CommonObject } // Loop on each email found - if (! $error && ! empty($arrayofemail) && count($arrayofemail) > 0) + if (!$error && !empty($arrayofemail) && count($arrayofemail) > 0) { // Loop to get part html and plain /* @@ -1078,15 +1078,15 @@ class EmailCollector extends CommonObject dol_syslog("Start of loop on email", LOG_INFO, 1); - foreach($arrayofemail as $imapemail) + foreach ($arrayofemail as $imapemail) { if ($nbemailprocessed > 1000) { - break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect + break; // Do not process more than 1000 email per launch (this is a different protection than maxnbcollectedpercollect } $header = imap_fetchheader($connection, $imapemail, 0); - $matches=array(); + $matches = array(); preg_match_all('/([^: ]+): (.+?(?:\r\n\s(?:.+?))*)\r\n/m', $header, $matches); $headers = array_combine($matches[1], $matches[2]); //var_dump($headers); @@ -1206,26 +1206,26 @@ class EmailCollector extends CommonObject //print $messagetext; //exit; - $fromstring=$overview[0]->from; - $sender=$overview[0]->sender; - $to=$overview[0]->to; - $sendtocc=$overview[0]->cc; - $sendtobcc=$overview[0]->bcc; - $date=$overview[0]->udate; - $msgid=str_replace(array('<','>'), '', $overview[0]->message_id); - $subject=$overview[0]->subject; + $fromstring = $overview[0]->from; + $sender = $overview[0]->sender; + $to = $overview[0]->to; + $sendtocc = $overview[0]->cc; + $sendtobcc = $overview[0]->bcc; + $date = $overview[0]->udate; + $msgid = str_replace(array('<', '>'), '', $overview[0]->message_id); + $subject = $overview[0]->subject; //var_dump($msgid);exit; - $reg=array(); + $reg = array(); if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { - $from=$reg[2]; - $fromtext=$reg[1]; + $from = $reg[2]; + $fromtext = $reg[1]; } else { $from = $fromstring; - $fromtext=''; + $fromtext = ''; } $fk_element_id = 0; $fk_element_type = ''; @@ -1375,10 +1375,10 @@ class EmailCollector extends CommonObject else $descriptiontitle = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)':'').' : '.dol_escape_htmltag($fromstring)); - if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)':'').' : '.dol_escape_htmltag($sender)); - $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)':'').' : '.dol_escape_htmltag($to)); - if ($sendtocc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)':'').' : '.dol_escape_htmltag($sendtocc)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)' : '').' : '.dol_escape_htmltag($fromstring)); + if ($sender) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)' : '').' : '.dol_escape_htmltag($to)); + if ($sendtocc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); //if ($bcc) $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Bcc").' : '.dol_escape_htmltag($bcc)); } @@ -1394,38 +1394,38 @@ class EmailCollector extends CommonObject else { $actionparam = $operation['actionparam']; - $nametouseforthirdparty=''; + $nametouseforthirdparty = ''; // $this->actionparam = 'SET:aaa' or 'EXTRACT:BODY:....' $arrayvaluetouse = dolExplodeIntoArray($actionparam, ';', '='); - foreach($arrayvaluetouse as $propertytooverwrite => $valueforproperty) + foreach ($arrayvaluetouse as $propertytooverwrite => $valueforproperty) { - $sourcestring=''; - $sourcefield=''; - $regexstring=''; - $regforregex=array(); + $sourcestring = ''; + $sourcefield = ''; + $regexstring = ''; + $regforregex = array(); if (preg_match('/^EXTRACT:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[1]; - $regexstring=$regforregex[2]; + $sourcefield = $regforregex[1]; + $regexstring = $regforregex[2]; } - if (! empty($sourcefield) && ! empty($regexstring)) + if (!empty($sourcefield) && !empty($regexstring)) { - if (strtolower($sourcefield) == 'body') $sourcestring=$messagetext; - elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject; - elseif (strtolower($sourcefield) == 'header') $sourcestring=$header; + if (strtolower($sourcefield) == 'body') $sourcestring = $messagetext; + elseif (strtolower($sourcefield) == 'subject') $sourcestring = $subject; + elseif (strtolower($sourcefield) == 'header') $sourcestring = $header; if ($sourcestring) { - $regforval=array(); + $regforval = array(); //var_dump($regexstring);var_dump($sourcestring); if (preg_match('/'.$regexstring.'/ms', $sourcestring, $regforval)) { //var_dump($regforval[1]);exit; // Overwrite param $tmpproperty - $nametouseforthirdparty = isset($regforval[1])?trim($regforval[1]):null; + $nametouseforthirdparty = isset($regforval[1]) ?trim($regforval[1]) : null; } else { @@ -1515,7 +1515,7 @@ class EmailCollector extends CommonObject // TODO Check if $msg ID already in database for $conf->entity - if (! $alreadycreated) + if (!$alreadycreated) { if ($projectstatic->id > 0) { @@ -1542,30 +1542,30 @@ class EmailCollector extends CommonObject // Insert record of emails sent $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$actioncode; $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; - $actioncomm->note_private= $descriptionfull; + $actioncomm->note_private = $descriptionfull; $actioncomm->fk_project = $projectstatic->id; $actioncomm->datep = $date; $actioncomm->datef = $date; - $actioncomm->percentage = -1; // Not applicable + $actioncomm->percentage = -1; // Not applicable $actioncomm->socid = $thirdpartystatic->id; $actioncomm->contactid = $contactstatic->id; $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action // Fields when action is an email (content should be added into note) $actioncomm->email_msgid = $msgid; $actioncomm->email_from = $fromstring; - $actioncomm->email_sender= $sender; + $actioncomm->email_sender = $sender; $actioncomm->email_to = $to; $actioncomm->email_tocc = $sendtocc; $actioncomm->email_tobcc = $sendtobcc; $actioncomm->email_subject = $subject; $actioncomm->errors_to = ''; - if (! in_array($fk_element_type, array('societe','contact','project','user'))) + if (!in_array($fk_element_type, array('societe', 'contact', 'project', 'user'))) { $actioncomm->fk_element = $fk_element_id; $actioncomm->elementtype = $fk_element_type; @@ -1637,18 +1637,18 @@ class EmailCollector extends CommonObject if (empty($projecttocreate->ref)) { // Get next project Ref - $defaultref=''; - $modele = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; + $defaultref = ''; + $modele = empty($conf->global->PROJECT_ADDON) ? 'mod_project_simple' : $conf->global->PROJECT_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; $reldir=''; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/project/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -1656,7 +1656,7 @@ class EmailCollector extends CommonObject if ($filefound) { - $result=dol_include_once($reldir."core/modules/project/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/project/".$modele.'.php'); $modProject = new $classname; if ($savesocid > 0) @@ -1752,18 +1752,18 @@ class EmailCollector extends CommonObject if (empty($tickettocreate->ref)) { // Get next project Ref - $defaultref=''; - $modele = empty($conf->global->TICKET_ADDON)?'mod_ticket_simple':$conf->global->TICKET_ADDON; + $defaultref = ''; + $modele = empty($conf->global->TICKET_ADDON) ? 'mod_ticket_simple' : $conf->global->TICKET_ADDON; // Search template files - $file=''; $classname=''; $filefound=0; $reldir=''; - $dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach($dirmodels as $reldir) + $file = ''; $classname = ''; $filefound = 0; $reldir = ''; + $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + foreach ($dirmodels as $reldir) { - $file=dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); + $file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0); if (file_exists($file)) { - $filefound=1; + $filefound = 1; $classname = $modele; break; } @@ -1771,7 +1771,7 @@ class EmailCollector extends CommonObject if ($filefound) { - $result=dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); + $result = dol_include_once($reldir."core/modules/ticket/".$modele.'.php'); $modTicket = new $classname; if ($savesocid > 0) @@ -1878,16 +1878,16 @@ class EmailCollector extends CommonObject } } - $output=$langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone); + $output = $langs->trans('XEmailsDoneYActionsDone', $nbemailprocessed, $nbemailok, $nbactiondone); dol_syslog("End of loop on emails", LOG_INFO, -1); } else { - $output=$langs->trans('NoNewEmailToProcess'); + $output = $langs->trans('NoNewEmailToProcess'); } - imap_expunge($connection); // To validate any move + imap_expunge($connection); // To validate any move imap_close($connection); @@ -1896,7 +1896,7 @@ class EmailCollector extends CommonObject $this->debuginfo = 'IMAP search string used : '.$search; if ($searchhead) $this->debuginfo .= '
Then search string into email header : '.$searchhead; - if (! $error) $this->datelastok = $now; + if (!$error) $this->datelastok = $now; if (!empty($this->errors)) $this->lastresult .= " - ".join(" - ", $this->errors); $this->codelastresult = ($error ? 'KO' : 'OK'); @@ -1922,7 +1922,7 @@ class EmailCollector extends CommonObject { // input $mbox = IMAP stream, $mid = message id // output all the following: - global $charset,$htmlmsg,$plainmsg,$attachments; + global $charset, $htmlmsg, $plainmsg, $attachments; $htmlmsg = $plainmsg = $charset = ''; $attachments = array(); @@ -1935,11 +1935,11 @@ class EmailCollector extends CommonObject if (!$s->parts) { // simple - $this->getpart($mbox, $mid, $s, 0); // pass 0 as part-number + $this->getpart($mbox, $mid, $s, 0); // pass 0 as part-number } else { // multipart: cycle through each part foreach ($s->parts as $partno0 => $p) { - $this->getpart($mbox, $mid, $p, $partno0+1); + $this->getpart($mbox, $mid, $p, $partno0 + 1); } } } @@ -1971,16 +1971,16 @@ class EmailCollector extends CommonObject private function getpart($mbox, $mid, $p, $partno) { // $partno = '1', '2', '2.1', '2.1.3', etc for multipart, 0 if simple - global $htmlmsg,$plainmsg,$charset,$attachments; + global $htmlmsg, $plainmsg, $charset, $attachments; // DECODE DATA - $data = ($partno)? - imap_fetchbody($mbox, $mid, $partno): // multipart - imap_body($mbox, $mid); // simple + $data = ($partno) ? + imap_fetchbody($mbox, $mid, $partno) : // multipart + imap_body($mbox, $mid); // simple // Any part may be encoded, even plain text messages, so check everything. - if ($p->encoding==4) + if ($p->encoding == 4) $data = quoted_printable_decode($data); - elseif ($p->encoding==3) + elseif ($p->encoding == 3) $data = base64_decode($data); // PARAMETERS @@ -2006,20 +2006,20 @@ class EmailCollector extends CommonObject // so an attached text file (type 0) is not mistaken as the message. if ($params['filename'] || $params['name']) { // filename may be given as 'Filename' or 'Name' or both - $filename = ($params['filename'])? $params['filename'] : $params['name']; + $filename = ($params['filename']) ? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() - $attachments[$filename] = $data; // this is a problem if two files have same name + $attachments[$filename] = $data; // this is a problem if two files have same name } // TEXT - if ($p->type==0 && $data) { + if ($p->type == 0 && $data) { // Messages may be split in different parts because of inline attachments, // so append parts together with blank row. - if (strtolower($p->subtype)=='plain') - $plainmsg .= trim($data) ."\n\n"; + if (strtolower($p->subtype) == 'plain') + $plainmsg .= trim($data)."\n\n"; else - $htmlmsg .= $data ."

"; - $charset = $params['charset']; // assume all parts are same charset + $htmlmsg .= $data."

"; + $charset = $params['charset']; // assume all parts are same charset } // EMBEDDED MESSAGE @@ -2027,7 +2027,7 @@ class EmailCollector extends CommonObject // but AOL uses type 1 (multipart), which is not handled here. // There are no PHP functions to parse embedded messages, // so this just appends the raw source to the main message. - elseif ($p->type==2 && $data) { + elseif ($p->type == 2 && $data) { $plainmsg .= $data."\n\n"; } @@ -2035,7 +2035,7 @@ class EmailCollector extends CommonObject if ($p->parts) { foreach ($p->parts as $partno0=>$p2) { - $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0+1)); // 1.2, 1.2.1, etc. + $this->getpart($mbox, $mid, $p2, $partno.'.'.($partno0 + 1)); // 1.2, 1.2.1, etc. } } } From 1e6b93500a50ebfb0d4d2253cd168981be645908 Mon Sep 17 00:00:00 2001 From: oscim Date: Tue, 26 Nov 2019 16:34:16 +0100 Subject: [PATCH 004/248] Put $object in complete_head_from_modules Add object for correctly usage in function complete_head_from_modules --- htdocs/core/lib/admin.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index a38a9c4289c..948064d3b5c 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -702,9 +702,9 @@ function modulehelp_prepare_head($object) $h++; } - complete_head_from_modules($conf, $langs, null, $head, $h, 'modulehelp_admin'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'modulehelp_admin'); - complete_head_from_modules($conf, $langs, null, $head, $h, 'modulehelp_admin', 'remove'); + complete_head_from_modules($conf, $langs, $object, $head, $h, 'modulehelp_admin', 'remove'); return $head; From d36cc22d392c1b77172d76860a1c888b687c451a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 26 Nov 2019 17:38:49 +0100 Subject: [PATCH 005/248] NEW get company info by API --- htdocs/api/class/api_setup.class.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 72ad45921d5..6b1c7eb6ee9 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1326,7 +1326,21 @@ class Setup extends DolibarrApi return $list; } + + /** + * Get properties of company + * + * @url GET /company + * + * @return array|mixed Data without useless information + * + */ + public function getCompany() + { + global $mysoc; + return $this->_cleanObjectDatas($mysoc); + } /** * Do a test of integrity for files and setup. From 247ef7b6195a65e57865c09b98aa0b217a6c79a0 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 26 Nov 2019 16:40:45 +0000 Subject: [PATCH 006/248] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 6b1c7eb6ee9..0dfdc9362ed 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1326,7 +1326,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get properties of company * From 250b8d0b67e76d7bef4b2f36cf52bd82091b21a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 17:54:48 +0100 Subject: [PATCH 007/248] delete file not used --- htdocs/takepos/admin/about.php | 75 ---------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 htdocs/takepos/admin/about.php diff --git a/htdocs/takepos/admin/about.php b/htdocs/takepos/admin/about.php deleted file mode 100644 index 7882ee3eb08..00000000000 --- a/htdocs/takepos/admin/about.php +++ /dev/null @@ -1,75 +0,0 @@ - - * Copyright (C) 2018 SuperAdmin - * - * 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 takepos/admin/about.php - * \ingroup takepos - * \brief About page of module TakePos. - */ - -require '../../main.inc.php'; // Load $user and permissions -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once '../lib/takepos.lib.php'; - -// Translations -$langs->loadLangs(array("errors","admin","cashdesk")); - -// Access control -if (! $user->admin) { - accessforbidden(); -} - -// Parameters -$action = GETPOST('action', 'alpha'); -$backtopage = GETPOST('backtopage', 'alpha'); - - -/* - * Actions - */ - -// None - - -/* - * View - */ - -$form = new Form($db); - -$page_name = "TakePosAbout"; -llxHeader('', $langs->trans($page_name)); - -// Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans($page_name), $linkback, 'object_takepos@takepos'); - -// Configuration header -$head = takeposAdminPrepareHead(); -dol_fiche_head($head, 'about', '', 0, 'takepos@takepos'); - -dol_include_once('/takepos/core/modules/modTakePos.class.php'); -$tmpmodule = new modTakePos($db); -print $tmpmodule->getDescLong(); - -// Page end -dol_fiche_end(); -llxFooter(); -$db->close(); From 59e85d5518f552472d5435e7c15b2235893b7352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 17:55:33 +0100 Subject: [PATCH 008/248] Create index.html --- htdocs/takepos/admin/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/takepos/admin/index.html diff --git a/htdocs/takepos/admin/index.html b/htdocs/takepos/admin/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/takepos/admin/index.html @@ -0,0 +1 @@ + From a04fa05b6ca8f0cfe93a9ac461730a84f22cf848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:41:38 +0100 Subject: [PATCH 009/248] image2wbmp() is deprecated as of PHP 7.3.0 https://www.php.net/manual/en/function.image2wbmp.php image2wbmp() is deprecated as of PHP 7.3.0, and will be removed in the next major version. Use imagewbmp() instead. --- htdocs/core/lib/images.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 4c089640915..177bad24376 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -281,7 +281,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, imagepng($imgThumb, $imgThumbName, $newquality); break; case 4: // Bmp - image2wbmp($imgThumb, $imgThumbName); + imagewbmp($imgThumb, $imgThumbName); break; } @@ -584,7 +584,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Not supported by PHP GD break; case IMAGETYPE_WBMP: // 15 - image2wbmp($imgThumb, $imgThumbName); + imagewbmp($imgThumb, $imgThumbName); break; } From 0357d134d52fb2c68c504706a3f45ee222286879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 18:46:27 +0100 Subject: [PATCH 010/248] fix missing $langs --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 769f879061c..b6ff684fa7c 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -405,7 +405,7 @@ class SupplierProposal extends CommonObject */ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0, $date_start = 0, $date_end = 0) { - global $mysoc, $conf; + global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::addline supplier_proposalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; From 32aca5f1863be0cde0c4a2c6009775544935db9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 19:52:10 +0100 Subject: [PATCH 011/248] Update pdf_standard.class.php --- htdocs/core/modules/member/doc/pdf_standard.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index a2d70dc98f4..b9acf8c9c9c 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -261,7 +261,7 @@ class pdf_standard extends CommonStickerGenerator // List of values to scan for a replacement $substitutionarray = array ( - '__ID__'=>$object->rowid, + '__ID__' => $object->id, '__LOGIN__'=>$object->login, '__FIRSTNAME__'=>$object->firstname, '__LASTNAME__'=>$object->lastname, From 28b70a539929e8f87c3008b2ed75cf78418e392a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 20:14:46 +0100 Subject: [PATCH 012/248] remove deprecated --- htdocs/product/stock/card.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 034e0076f09..c169c22f0a9 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -355,10 +355,10 @@ else $formconfirm = ''; - // Confirm delete third party + // Confirm delete warehouse if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->libelle), "confirm_delete", '', 0, 2); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteAWarehouse"), $langs->trans("ConfirmDeleteWarehouse", $object->label), "confirm_delete", '', 0, 2); } // Call Hook formConfirm @@ -389,10 +389,10 @@ else print ''; // Parent entrepot - $e = new Entrepot($db); - if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) { + $parentwarehouse = new Entrepot($db); + if(!empty($object->fk_parent) && $parentwarehouse->fetch($object->fk_parent) > 0) { print ''; } @@ -668,7 +668,7 @@ else print '
'.$langs->trans("ParentWarehouse").''; - print $e->getNomUrl(3); + print $parentwarehouse->getNomUrl(3); print '
'; // Ref - print ''; + print ''; print ''; From 6ea204bd739d415d4e86a3dd381a20fb2a9c3642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 26 Nov 2019 20:20:46 +0100 Subject: [PATCH 013/248] Update entrepot.class.php --- htdocs/product/stock/class/entrepot.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index a8a9a3a55b8..a8a724f3575 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -53,9 +53,13 @@ class Entrepot extends CommonObject /** * @var string Label * @deprecated + * @see $label */ public $libelle; + /** + * @var string Label + */ public $label; /** @@ -64,6 +68,10 @@ class Entrepot extends CommonObject public $description; public $statut; + + /** + * @var string Place + */ public $lieu; /** @@ -82,11 +90,13 @@ class Entrepot extends CommonObject public $town; /** - * @var int ID + * @var int ID of parent */ public $fk_parent; - // List of short language codes for status + /** + * @var array List of short language codes for status + */ public $statuts = array(); /** From d910b05a3803fc7b398be8243bfa388cd0e6393f Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 20:28:24 +0100 Subject: [PATCH 014/248] Look & Feel v11 --- htdocs/compta/bank/various_payment/list.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index d279041e2af..7b8730ebc93 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -154,12 +154,10 @@ if ($result) if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - $newcardbutton=''; + $newcardbutton = ''; if ($user->rights->banque->modifier) { - $newcardbutton=''.$langs->trans('MenuNewVariousPayment').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment', ($ltt + 1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'); } print '
'; @@ -306,7 +304,7 @@ if ($result) } // Debit - print "
"; // Credit - print ""; + print '' ; + print ''; - print ""; + if (! $i) $totalarray['nbfield']++; + + print "\n"; $i++; } - $colspan = 4; - if (!empty($conf->banque->enabled)) $colspan++; - if (!empty($conf->accounting->enabled)) $colspan++; - // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; From 6a210945b7d70256f3386bdeca41972cd0eed90d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Nov 2019 20:38:06 +0100 Subject: [PATCH 015/248] Prepare 10.0.4 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 274f1953d40..7c71221ba3c 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE', 'Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION', '10.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION', '10.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO', chr(128)); From 659e3aca8e2f0924fae187befaf5d78a0905808e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 21:14:44 +0100 Subject: [PATCH 016/248] Look & field v11 --- htdocs/compta/sociales/list.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 1ac766a4e34..b7ee278f02c 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -171,9 +171,7 @@ if ($resql) $newcardbutton = ''; if ($user->rights->tax->charges->creer) { - $newcardbutton = ''.$langs->trans('MenuNewSocialContribution').''; - $newcardbutton .= ''; - $newcardbutton .= ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); } print ''; @@ -267,15 +265,16 @@ if ($resql) print ''; // Ref - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Label - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Type - print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Date end period print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; // Amount - print ''; + print ''; if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield'; $totalarray['val']['totalttcfield'] += $obj->amount; // Due date print ''; + if (! $i) $totalarray['nbfield']++; print ''; + if (! $i) $totalarray['nbfield']++; print ''; + if (! $i) $totalarray['nbfield']++; + print ''; $i++; } From 0f6de0049cfe1c9fa011b04d25d47b3d5b0f6a72 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Nov 2019 21:17:22 +0100 Subject: [PATCH 017/248] Fix --- htdocs/compta/bank/various_payment/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 7b8730ebc93..81c2a10ba13 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -157,7 +157,7 @@ if ($result) $newcardbutton = ''; if ($user->rights->banque->modifier) { - $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment', ($ltt + 1)), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create'); } print ''; From 27d6071a73bcde203566a1bb7d8f977efd3cf0b5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 26 Nov 2019 21:33:42 +0100 Subject: [PATCH 018/248] NEW add list of group and object group API --- htdocs/user/class/api_users.class.php | 110 ++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 1fa9e971306..a155827c673 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -363,6 +363,116 @@ class Users extends DolibarrApi return 1; } + + /** + * List Groups + * + * Return an array with a list of Groups + * + * @url GET /groups + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $group_ids Groups ids filter field. Example: '1' or '1,2,3' {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" + * @return array Array of User objects + */ + public function listGroups($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $group_ids = 0, $sqlfilters = '') + { + global $db, $conf; + + $obj_ret = array(); + + if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { + throw new RestException(401, "You are not allowed to read list of groups"); + } + + // case of external user, $societe param is ignored and replaced by user's socid + //$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $societe; + + $sql = "SELECT t.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as t"; + $sql .= ' WHERE t.entity IN ('.getEntity('user').')'; + if ($group_ids) $sql .= " AND t.rowid IN (".$group_ids.")"; + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $i = 0; + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + while ($i < $min) + { + $obj = $db->fetch_object($result); + $group_static = new UserGroup($this->db); + if ($group_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($group_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieve Group list : '.$db->lasterror()); + } + if (!count($obj_ret)) { + throw new RestException(404, 'No Group found'); + } + return $obj_ret; + } + + /** + * Get properties of an user object + * + * Return an array with group informations + * + * @url GET /groups/{id} + * + * @param int $id ID of group + * @param int $load_members Load members list or not {@min 0} {@max 1} + * @return array Array of User objects + */ + public function infoGroups($id, $load_members = 0) + { + global $db, $conf; + + if (!DolibarrApiAccess::$user->rights->user->group_advance->read) { + throw new RestException(401, "You are not allowed to read groups"); + } + + $group_static = new UserGroup($this->db); + $result = $group_static->fetch($id, '', $load_members); + + if (!$result) + { + throw new RestException(404, 'Group not found'); + } + + return $this->_cleanObjectDatas($group_static); + } /** * Delete account From bc1f9f5aaa00fb1f2a85a1f7b14af200ced070cd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 26 Nov 2019 21:34:45 +0100 Subject: [PATCH 019/248] Update api_users.class.php --- htdocs/user/class/api_users.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index a155827c673..ab85177c6f0 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -449,13 +449,13 @@ class Users extends DolibarrApi * * Return an array with group informations * - * @url GET /groups/{id} + * @url GET /groups/{group} * * @param int $id ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} * @return array Array of User objects */ - public function infoGroups($id, $load_members = 0) + public function infoGroups($group, $load_members = 0) { global $db, $conf; @@ -464,7 +464,7 @@ class Users extends DolibarrApi } $group_static = new UserGroup($this->db); - $result = $group_static->fetch($id, '', $load_members); + $result = $group_static->fetch($group, '', $load_members); if (!$result) { From bba4ed02d285be2e4d577e8a1f47b92bdaff14b2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 26 Nov 2019 20:36:30 +0000 Subject: [PATCH 020/248] Fixing style errors. --- htdocs/user/class/api_users.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index ab85177c6f0..761638f007b 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -363,12 +363,12 @@ class Users extends DolibarrApi return 1; } - + /** * List Groups * * Return an array with a list of Groups - * + * * @url GET /groups * * @param string $sortfield Sort field @@ -443,12 +443,12 @@ class Users extends DolibarrApi } return $obj_ret; } - + /** * Get properties of an user object * * Return an array with group informations - * + * * @url GET /groups/{group} * * @param int $id ID of group @@ -464,13 +464,13 @@ class Users extends DolibarrApi } $group_static = new UserGroup($this->db); - $result = $group_static->fetch($group, '', $load_members); + $result = $group_static->fetch($group, '', $load_members); if (!$result) { throw new RestException(404, 'Group not found'); } - + return $this->_cleanObjectDatas($group_static); } From aa3b6533f11a90518285ef549250e4a56d8550d7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 27 Nov 2019 02:45:43 +0100 Subject: [PATCH 021/248] Look & Feel v11 --- htdocs/salaries/list.php | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index 51fd8462180..e9014e423c6 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -150,9 +150,7 @@ if ($result) $newcardbutton=''; if (! empty($user->rights->salaries->write)) { - $newcardbutton=''.$langs->trans('NewSalaryPayment').''; - $newcardbutton.= ''; - $newcardbutton.= ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/salaries/card.php?action=create'); } print ''; @@ -234,14 +232,24 @@ if ($result) // Ref print "\n"; + if (! $i) $totalarray['nbfield']++; + // Employee print "\n"; + if (! $i) $totalarray['nbfield']++; + // Label payment print "\n"; + if (! $i) $totalarray['nbfield']++; + // Date payment print '\n"; + if (! $i) $totalarray['nbfield']++; + // Type print ''; + if (! $i) $totalarray['nbfield']++; + // Account if (! empty($conf->banque->enabled)) { @@ -267,22 +275,26 @@ if ($result) } else print ' '; print ''; + if (! $i) $totalarray['nbfield']++; } - // Amount - print ''; - print ''; - print "\n"; - $total = $total + $obj->amount; + // Amount + print ''; + if (! $i) $totalarray['nbfield']++; + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield'; + $totalarray['val']['totalttcfield'] += $obj->amount; + + print ''; + + if (! $i) $totalarray['nbfield']++; + + print "\n"; $i++; } - $colspan=5; - if (! empty($conf->banque->enabled)) $colspan++; - print ''; - print '"; - print ""; + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; print "
'.$langs->trans("Ref").'
'.$langs->trans("Ref").'
'.$langs->trans("LocationSummary").'
"; + print ''; if ($obj->sens == 0) { print price($obj->amount); @@ -317,7 +315,7 @@ if ($result) print ""; + print ''; if ($obj->sens == 1) { print price($obj->amount); @@ -325,17 +323,16 @@ if ($result) } if (! $i) $totalarray['nbfield']++; if (! $i) $totalarray['pos'][$totalarray['nbfield']]='total_cred'; - print "
'; - print $chargesociale_static->getNomUrl(1, '20'); - print '".$chargesociale_static->getNomUrl(1, '20')."'.dol_trunc($obj->label, 42).'".dol_trunc($obj->label, 42)."'.$obj->type_label.'".$obj->type_label."'; @@ -287,21 +286,26 @@ if ($resql) { print ' '; } - print ''.price($obj->amount).''.price($obj->amount).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
".$salstatic->getNomUrl(1)."".$userstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''.price($obj->amount).'
'.price($obj->amount).'
'.$langs->trans("Total").''.price($total)."
"; print ''; From 355d7545f62beb5658c948bb2b0f8743ae3e9813 Mon Sep 17 00:00:00 2001 From: altairis Date: Wed, 27 Nov 2019 10:23:01 +0100 Subject: [PATCH 022/248] filter language is an array --- htdocs/core/class/html.formfile.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 9411e8bc824..7b885d36a52 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -741,7 +741,7 @@ class FormFile $defaultlang=$codelang?$codelang:$langs->getDefaultLang(); $morecss='maxwidth150'; if ($conf->browser->layout == 'phone') $morecss='maxwidth100'; - $out.= $formadmin->select_language($defaultlang, 'lang_id', 0, 0, 0, 0, 0, $morecss); + $out.= $formadmin->select_language($defaultlang, 'lang_id', 0, null, 0, 0, 0, $morecss); } else { From 425f88082fbd26b1a45c2805add7b9a76c20f75b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 27 Nov 2019 11:53:37 +0100 Subject: [PATCH 023/248] Prepare 10.0.4 --- ChangeLog | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9cb2225cd08..99e70e960c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,31 @@ English Dolibarr ChangeLog -------------------------------------------------------------- + +***** ChangeLog for 10.0.4 compared to 10.0.3 ***** +FIX: The pdf templates were using the large logo making PDF too large (and edition of proposal, order, invoice VERY slow) +FIX: #12258 +FIX: #12319 Restore feature ACCOUNTANCY_AUTOFILL_ACCOUNT_WITH_GENERIC. +FIX: #12356 +FIX: #12372 +FIX: #12385 +FIX: Advisory ID: usd20190053 +FIX: Advisory ID: usd20190067 +FIX: Avoid fatal error when creating thumb from PDF +FIX: compatibility with Multicompany +FIX: display job of contact list +FIX: Extrafields missing in export of expense report +FIX: Hook getAccessForbiddenMessage was missing parameters +FIX: limit 20 prevent to see all products/services +FIX: Search on leave request ref +FIX: security check. A user can see holiday with link without permissions +FIX: Set unpaid of expense report +FIX: shipping extrafields line +FIX: the SELECT examine more than MAX_JOIN_SIZE rows #12305 +FIX: triggers: directories read with opendir() never closed +FIX: we need to be able to recalculate tva only if invoice not in accountancy +FIX: wrong invoice id for fetchObjetctLinked + ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. The unit were not saved correctly in database making calculation on shipments wrong. From 825349e07e8815e3e0f6a3ec070fbcb6b22abf61 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 27 Nov 2019 16:04:52 +0100 Subject: [PATCH 024/248] Update api_users.class.php --- htdocs/user/class/api_users.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 761638f007b..be768a3e15a 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -445,13 +445,13 @@ class Users extends DolibarrApi } /** - * Get properties of an user object + * Get properties of an group object * * Return an array with group informations * * @url GET /groups/{group} * - * @param int $id ID of group + * @param int $group ID of group * @param int $load_members Load members list or not {@min 0} {@max 1} * @return array Array of User objects */ From 5f99e25c45d619f1e3a5174bf2035d516b1d4228 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Thu, 28 Nov 2019 11:36:20 +0000 Subject: [PATCH 025/248] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/admin/emailcollector_card.php | 2 +- htdocs/admin/expensereport_rules.php | 28 +- htdocs/admin/mails.php | 236 +++++------ htdocs/bom/bom_agenda.php | 16 +- htdocs/bom/bom_card.php | 10 +- htdocs/comm/remx.php | 8 +- htdocs/compta/bank/graph.php | 382 +++++++++--------- htdocs/core/boxes/box_shipments.php | 56 +-- .../core/class/emailsenderprofile.class.php | 38 +- htdocs/core/class/events.class.php | 144 +++---- htdocs/core/class/html.formcron.class.php | 42 +- htdocs/core/lib/functions.lib.php | 80 ++-- htdocs/core/modules/modExpedition.class.php | 140 +++---- htdocs/main.inc.php | 78 ++-- htdocs/mrp/mo_agenda.php | 80 ++-- htdocs/product/class/api_products.class.php | 186 ++++----- htdocs/product/inventory/inventory.php | 58 +-- htdocs/takepos/admin/setup.php | 20 +- htdocs/takepos/admin/terminal.php | 74 ++-- htdocs/takepos/pay.php | 66 +-- htdocs/takepos/smpcb.php | 4 +- htdocs/zapier/hook_agenda.php | 16 +- 22 files changed, 882 insertions(+), 882 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 6bd27da529b..804c2a37a6f 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -431,7 +431,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connection = imap_open($connectstringsource, $object->login, $object->password); } - catch(Exception $e) + catch (Exception $e) { print $e->getMessage(); } diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index 6a719c25b5f..becf50fa7a2 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.php'; // Load translation files required by the page -$langs->loadLangs(array("admin","other","trips","errors","dict")); +$langs->loadLangs(array("admin", "other", "trips", "errors", "dict")); if (!$user->admin) accessforbidden(); @@ -96,18 +96,18 @@ if ($action == 'save') { $object->setValues($_POST); - if($apply_to=='U'){ + if ($apply_to == 'U') { $object->fk_user = (int) $fk_user; - $object->fk_usergroup=0; - $object->is_for_all=0; - }elseif($apply_to=='G'){ + $object->fk_usergroup = 0; + $object->is_for_all = 0; + }elseif ($apply_to == 'G') { $object->fk_usergroup = (int) $fk_usergroup; - $object->fk_user=0; - $object->is_for_all=0; - }elseif($apply_to=='A'){ - $object->is_for_all=1; - $object->fk_user=0; - $object->fk_usergroup=0; + $object->fk_user = 0; + $object->is_for_all = 0; + }elseif ($apply_to == 'A') { + $object->is_for_all = 1; + $object->fk_user = 0; + $object->fk_usergroup = 0; } $object->dates = $dates; @@ -145,12 +145,12 @@ $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->tr llxHeader('', $langs->trans("ExpenseReportsSetup")); -$form=new Form($db); +$form = new Form($db); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup'); -$head=expensereport_admin_prepare_head(); +$head = expensereport_admin_prepare_head(); dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip'); echo $langs->trans('ExpenseReportRulesDesc'); diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 5f59a198fa4..fb76c3c0676 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -30,23 +30,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors")); -$action=GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); -if (! $user->admin) accessforbidden(); +if (!$user->admin) accessforbidden(); -$usersignature=$user->signature; +$usersignature = $user->signature; // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. if ($action == 'test' || $action == 'send') { - $usersignature=dol_string_nohtmltag($usersignature); + $usersignature = dol_string_nohtmltag($usersignature); } -$substitutionarrayfortest=array( +$substitutionarrayfortest = array( '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, '__ID__' => 'RecipientIdRecord', //'__EMAIL__' => 'RecipientEMail', // Done into actions_sendmails -'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'':'', -'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''), // Done into actions_sendmails +'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty)) ? '' : '', +'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails '__LOGIN__' => 'RecipientLogin', '__LASTNAME__' => 'RecipientLastname', '__FIRSTNAME__' => 'RecipientFirstname', @@ -93,16 +93,16 @@ if ($action == 'update' && empty($_POST["cancel"])) // Actions to send emails -$id=0; -$actiontypecode=''; // Not an event for agenda -$trigger_name=''; // Disable triggers -$paramname='id'; -$mode='emailfortest'; -$trackid=(($action == 'testhtml')?"testhtml":"test"); +$id = 0; +$actiontypecode = ''; // Not an event for agenda +$trigger_name = ''; // Disable triggers +$paramname = 'id'; +$mode = 'emailfortest'; +$trackid = (($action == 'testhtml') ? "testhtml" : "test"); include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; -if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action='test'; -if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action='testhtml'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action = 'test'; +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $action = 'testhtml'; @@ -113,18 +113,18 @@ if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') $ $form = new Form($db); -$linuxlike=1; -if (preg_match('/^win/i', PHP_OS)) $linuxlike=0; -if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0; +$linuxlike = 1; +if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; +if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; -if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail'; -$port=! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:ini_get('smtp_port'); -if (! $port) $port=25; -$server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:ini_get('SMTP'); -if (! $server) $server='127.0.0.1'; +if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE = 'mail'; +$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port'); +if (!$port) $port = 25; +$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP'); +if (!$server) $server = '127.0.0.1'; -$wikihelp='EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; +$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails'; llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup'); @@ -132,11 +132,11 @@ print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup'); $head = email_admin_prepare_head(); // List of sending methods -$listofmethods=array(); -$listofmethods['mail']='PHP mail function'; +$listofmethods = array(); +$listofmethods['mail'] = 'PHP mail function'; //$listofmethods['simplemail']='Simplemail class'; -$listofmethods['smtps']='SMTP/SMTPS socket library'; -$listofmethods['swiftmailer']='Swift Mailer socket library'; +$listofmethods['smtps'] = 'SMTP/SMTPS socket library'; +$listofmethods['swiftmailer'] = 'Swift Mailer socket library'; if ($action == 'edit') @@ -267,7 +267,7 @@ if ($action == 'edit') // Force e-mail recipient print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''; - print ''; + print ''; print ''; @@ -299,7 +299,7 @@ if ($action == 'edit') // Host server print ''; - if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print ''; @@ -307,21 +307,21 @@ if ($action == 'edit') } else { - $mainserver = (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:''); - $smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined"); + $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ''); + $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver); print ''; // SuperAdministrator access only - if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; - print ''; + print ''; + print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { - $text = ! empty($mainserver) ? $mainserver : $smtpserver; + $text = !empty($mainserver) ? $mainserver : $smtpserver; $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; @@ -331,7 +331,7 @@ if ($action == 'edit') // Port print ''; - if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') { print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print ''; @@ -339,21 +339,21 @@ if ($action == 'edit') } else { - $mainport = (! empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ''); - $smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined"); + $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ''); + $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport); print ''; // SuperAdministrator access only - if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) + if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; - print ''; + print ''; + print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { - $text = (! empty($mainport) ? $mainport : $smtpport); + $text = (!empty($mainport) ? $mainport : $smtpport); $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; @@ -362,14 +362,14 @@ if ($action == 'edit') print ''; // ID - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - $mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:''); + $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : ''); print ''.$langs->trans("MAIN_MAIL_SMTPS_ID").''; // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { @@ -381,16 +381,16 @@ if ($action == 'edit') } // PW - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { - $mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:''); + $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : ''); print ''; print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword")); print ''; // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { @@ -403,11 +403,11 @@ if ($action == 'edit') // TLS print ''.$langs->trans("MAIN_MAIL_EMAIL_TLS").''; - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (! empty($conf->global->MAIN_MAIL_EMAIL_TLS)?$conf->global->MAIN_MAIL_EMAIL_TLS:0), 1); + print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -416,11 +416,11 @@ if ($action == 'edit') // STARTTLS print ''.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").''; - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer')))) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)?$conf->global->MAIN_MAIL_EMAIL_STARTTLS:0), 1); + print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -429,11 +429,11 @@ if ($action == 'edit') // DKIM print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").''; - if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer')))) { if (function_exists('openssl_open')) { - print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (! empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED)?$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED:0), 1); + print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1); } else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')'; } @@ -442,31 +442,31 @@ if ($action == 'edit') // DKIM Domain print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print ''; // DKIM Selector print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print ''; // DKIM PRIVATE KEY print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print ''; + print ''; print ''; // Separator print ' '; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; + print ''; // Default from type $liste = array(); $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; /* $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; $resql = $db->query($sql); @@ -495,12 +495,12 @@ if ($action == 'edit') // From print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; - print ''; // Autocopy to print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; - print ''; print ''; @@ -527,14 +527,14 @@ else // Disable print ''.$langs->trans("MAIN_DISABLE_ALL_MAILS").''.yn($conf->global->MAIN_DISABLE_ALL_MAILS); - if (! empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); + if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled")); print ''; // Force e-mail recipient print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.$conf->global->MAIN_MAIL_FORCE_SENDTO; - if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) + if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO)) { - if (! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); + if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail")); else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue")); } print ''; @@ -547,8 +547,8 @@ else // Method print ''.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; - if (empty($text)) $text=$langs->trans("Undefined").img_warning(); + $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE]; + if (empty($text)) $text = $langs->trans("Undefined").img_warning(); print $text; print ''; @@ -559,7 +559,7 @@ else } else { - print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:'').''; + print ''.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').''; } // Port @@ -569,7 +569,7 @@ else } else { - print ''.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).''.(! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:'').''; + print ''.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').''; } // SMTPS ID @@ -628,17 +628,17 @@ else // Domain print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").''; - print '' . $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN; print ''; // Selector print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").''; - print '' . $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR; print ''; // PRIVATE KEY print ''.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").''; - print '' . $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; + print ''.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY; print ''; } @@ -646,22 +646,22 @@ else print ' '; // From - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; + print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).''; print ''.$conf->global->MAIN_MAIL_EMAIL_FROM; - if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail")); print ''; // Default from type $liste = array(); $liste['user'] = $langs->trans('UserEmail'); - $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')'; - $sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; + $liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')'; + $sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1'; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $i=0; - while($i < $num) + $i = 0; + while ($i < $num) { $obj = $db->fetch_object($resql); if ($obj) @@ -705,16 +705,16 @@ else // Errors To print ''.$langs->trans("MAIN_MAIL_ERRORS_TO").''; print ''.$conf->global->MAIN_MAIL_ERRORS_TO; - if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); + if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail")); print ''; // Autocopy to print ''.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").''; print ''; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) { print $conf->global->MAIN_MAIL_AUTOCOPY_TO; - if (! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); + if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); } else { @@ -732,7 +732,7 @@ else print ''.$langs->trans("Modify").''; - if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || ! $linuxlike) + if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike) { if (function_exists('fsockopen') && $port && $server) { @@ -746,7 +746,7 @@ else print ''.$langs->trans("DoTestSend").''; - if (! empty($conf->fckeditor->enabled)) + if (!empty($conf->fckeditor->enabled)) { print ''.$langs->trans("DoTestSendHTML").''; } @@ -770,17 +770,17 @@ else print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA")); } - if (! in_array($action, array('testconnect', 'test', 'testhtml'))) + if (!in_array($action, array('testconnect', 'test', 'testhtml'))) { $text = ''; if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') { - $text.= $langs->trans("WarningPHPMail"); + $text .= $langs->trans("WarningPHPMail"); } //$conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS='1.2.3.4'; - if (! empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) + if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS)) { - $text.= ($text?'
':'').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); + $text .= ($text ? '
' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS); } if ($text) print info_admin($text); } @@ -792,7 +792,7 @@ else include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mail = new CMailFile('', '', '', ''); - $result=$mail->check_server_port($server, $port); + $result = $mail->check_server_port($server, $port); if ($result) print '
'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'
'; else { @@ -811,45 +811,45 @@ else if ($action == 'test' || $action == 'testhtml') { print '
'; - print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend")); + print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend")); dol_fiche_head(''); // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->trackid=(($action == 'testhtml')?"testhtml":"test"); - $formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->fromid=$user->id; - $formmail->fromalsorobot=1; - $formmail->fromtype=(GETPOSTISSET('fromtype')?GETPOST('fromtype', 'aZ09'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user')); - $formmail->withfromreadonly=1; - $formmail->withsubstit=1; - $formmail->withfrom=1; - $formmail->witherrorsto=1; - $formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1)); - $formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1); // ! empty to keep field if empty - $formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1); // ! empty to keep field if empty - $formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test")); - $formmail->withtopicreadonly=0; - $formmail->withfile=2; - $formmail->withbody=(isset($_POST['message'])?$_POST['message']:($action == 'testhtml'?$langs->transnoentities("PredefinedMailTestHtml"):$langs->transnoentities("PredefinedMailTest"))); - $formmail->withbodyreadonly=0; - $formmail->withcancel=1; - $formmail->withdeliveryreceipt=1; - $formmail->withfckeditor=($action == 'testhtml'?1:0); - $formmail->ckeditortoolbar='dolibarr_mailings'; + $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); + $formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromid = $user->id; + $formmail->fromalsorobot = 1; + $formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user')); + $formmail->withfromreadonly = 1; + $formmail->withsubstit = 1; + $formmail->withfrom = 1; + $formmail->witherrorsto = 1; + $formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1)); + $formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty + $formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty + $formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test")); + $formmail->withtopicreadonly = 0; + $formmail->withfile = 2; + $formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest"))); + $formmail->withbodyreadonly = 0; + $formmail->withcancel = 1; + $formmail->withdeliveryreceipt = 1; + $formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0); + $formmail->ckeditortoolbar = 'dolibarr_mailings'; // Tableau des substitutions - $formmail->substit=$substitutionarrayfortest; + $formmail->substit = $substitutionarrayfortest; // Tableau des parametres complementaires du post - $formmail->param["action"]="send"; - $formmail->param["models"]="body"; - $formmail->param["mailid"]=0; - $formmail->param["returnurl"]=$_SERVER["PHP_SELF"]; + $formmail->param["action"] = "send"; + $formmail->param["models"] = "body"; + $formmail->param["mailid"] = 0; + $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode", "aZ09")=='init') + if (GETPOST("mode", "aZ09") == 'init') { $formmail->clear_attached_files(); } diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 8e0afc77d0a..af41824fa08 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -32,32 +32,32 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("mrp","other")); +$langs->loadLangs(array("mrp", "other")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action', 'alpha'); +$action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); +$search_agenda_label = GETPOST('search_agenda_label'); // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 252caa8da10..75f87067a4e 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -625,28 +625,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Close / Cancel if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) { - print '' . $langs->trans("Disable") . ''; + print ''.$langs->trans("Disable").''; } // Re-open if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) { - print '' . $langs->trans("ReOpen") . ''; + print ''.$langs->trans("ReOpen").''; } // Create MO if ($conf->mrp->enabled) { - if ($object->status == $object::STATUS_VALIDATED && ! empty($user->rights->mrp->write)) + if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) { - print '' . $langs->trans("CreateMO") . ''; + print ''.$langs->trans("CreateMO").''; } } // Clone if ($permissiontoadd) { - print '' . $langs->trans("ToClone") . ''; + print ''.$langs->trans("ToClone").''; } /* diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 47a31f11a72..68be93f7ed1 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -745,7 +745,7 @@ if ($socid > 0) $sql .= " , ".MAIN_DB_PREFIX."facturedet as fc"; $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql .= " WHERE rc.fk_soc =". $object->id; + $sql .= " WHERE rc.fk_soc =".$object->id; $sql .= " AND rc.fk_facture_line = fc.rowid"; $sql .= " AND fc.fk_facture = f.rowid"; $sql .= " AND rc.fk_user = u.rowid"; @@ -763,7 +763,7 @@ if ($socid > 0) $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid"; - $sql2 .= " WHERE rc.fk_soc =". $object->id; + $sql2 .= " WHERE rc.fk_soc =".$object->id; $sql2 .= " AND rc.fk_facture = f.rowid"; $sql2 .= " AND rc.fk_user = u.rowid"; $sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts @@ -920,7 +920,7 @@ if ($socid > 0) $sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc"; $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql .= " WHERE rc.fk_soc =". $object->id; + $sql .= " WHERE rc.fk_soc =".$object->id; $sql .= " AND rc.fk_invoice_supplier_line = fc.rowid"; $sql .= " AND fc.fk_facture_fourn = f.rowid"; $sql .= " AND rc.fk_user = u.rowid"; @@ -938,7 +938,7 @@ if ($socid > 0) $sql2 .= " , ".MAIN_DB_PREFIX."user as u"; $sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid"; - $sql2 .= " WHERE rc.fk_soc =". $object->id; + $sql2 .= " WHERE rc.fk_soc =".$object->id; $sql2 .= " AND rc.fk_invoice_supplier = f.rowid"; $sql2 .= " AND rc.fk_user = u.rowid"; $sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 0f0c3d11386..fbcd06a51bc 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -31,22 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories')); -$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 768); -$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 200); +$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 768); +$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 200); // Security check if (isset($_GET["account"]) || isset($_GET["ref"])) { - $id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:''); + $id = isset($_GET["account"]) ? $_GET["account"] : (isset($_GET["ref"]) ? $_GET["ref"] : ''); } -$fieldid = isset($_GET["ref"])?'ref':'rowid'; -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); +$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid); -$account=GETPOST("account"); -$mode='standard'; -if (GETPOST("mode") == 'showalltime') $mode='showalltime'; -$error=0; +$account = GETPOST("account"); +$mode = 'standard'; +if (GETPOST("mode") == 'showalltime') $mode = 'showalltime'; +$error = 0; /* @@ -63,22 +63,22 @@ $datetime = dol_now(); $year = dol_print_date($datetime, "%Y"); $month = dol_print_date($datetime, "%m"); $day = dol_print_date($datetime, "%d"); -if (GETPOST("year")) $year=sprintf("%04d", GETPOST("year")); -if (GETPOST("month")) $month=sprintf("%02d", GETPOST("month")); +if (GETPOST("year")) $year = sprintf("%04d", GETPOST("year")); +if (GETPOST("month")) $month = sprintf("%02d", GETPOST("month")); $object = new Account($db); -if ($_GET["account"] && ! preg_match('/,/', $_GET["account"])) // if for a particular account and not a list +if ($_GET["account"] && !preg_match('/,/', $_GET["account"])) // if for a particular account and not a list { - $result=$object->fetch(GETPOST("account", "int")); + $result = $object->fetch(GETPOST("account", "int")); } if ($_GET["ref"]) { - $result=$object->fetch(0, GETPOST("ref")); - $account=$object->id; + $result = $object->fetch(0, GETPOST("ref")); + $account = $object->id; } -$result=dol_mkdir($conf->bank->dir_temp); +$result = dol_mkdir($conf->bank->dir_temp); if ($result < 0) { $langs->load("errors"); @@ -89,11 +89,11 @@ else { // Calcul $min and $max $sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); if ($resql) @@ -109,7 +109,7 @@ else } if (empty($min)) $min = dol_now() - 3600 * 24; - $log="graph.php: min=".$min." max=".$max; + $log = "graph.php: min=".$min." max=".$max; dol_syslog($log); @@ -120,24 +120,24 @@ else // Loading table $amounts $amounts = array(); - $monthnext = $month+1; + $monthnext = $month + 1; $yearnext = $year; if ($monthnext > 12) { - $monthnext=1; + $monthnext = 1; $yearnext++; } $sql = "SELECT date_format(b.datev,'%Y%m%d')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; - $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; - $sql.= " GROUP BY date_format(b.datev,'%Y%m%d')"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; + $sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; + $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; $resql = $db->query($sql); if ($resql) @@ -161,12 +161,12 @@ else $solde = 0; $sql = "SELECT SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev < '".$year."-".sprintf("%02s", $month)."-01'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev < '".$year."-".sprintf("%02s", $month)."-01'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); if ($resql) @@ -225,36 +225,36 @@ else //exit; // Fabrication tableau 1 - $file= $conf->bank->dir_temp."/balance".$account."-".$year.$month.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png"; - $title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($datas as $i => $val) + $file = $conf->bank->dir_temp."/balance".$account."-".$year.$month.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png"; + $title = $langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($datas as $i => $val) { - $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); + $graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]); if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]); if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]); } $px1 = new DolGraph(); $px1->SetData($graph_datas); - $arraylegends=array($langs->transnoentities("Balance")); + $arraylegends = array($langs->transnoentities("Balance")); if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired")); if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed")); $px1->SetLegend($arraylegends); $px1->SetLegendWidthMin(180); - $px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue()); - $px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue()); + $px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue()); + $px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue()); $px1->SetTitle($title); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); - $px1->SetType(array('lines','lines','lines')); + $px1->SetType(array('lines', 'lines', 'lines')); $px1->setBgColor('onglet'); - $px1->setBgColorGrid(array(255,255,255)); + $px1->setBgColorGrid(array(255, 255, 255)); $px1->SetHorizTickIncrement(1); $px1->draw($file, $fileurl); - $show1=$px1->show(); + $show1 = $px1->show(); unset($graph_datas); unset($px1); unset($datas); @@ -271,14 +271,14 @@ else // Loading table $amounts $amounts = array(); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".$year."-12-31 23:59:59'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; $resql = $db->query($sql); @@ -303,12 +303,12 @@ else $solde = 0; $sql = "SELECT SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev < '".$year."-01-01'"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev < '".$year."-01-01'"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $resql = $db->query($sql); if ($resql) @@ -361,36 +361,36 @@ else } // Fabrication tableau 2 - $file= $conf->bank->dir_temp."/balance".$account."-".$year.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png"; - $title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($datas as $i => $val) + $file = $conf->bank->dir_temp."/balance".$account."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png"; + $title = $langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($datas as $i => $val) { - $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); + $graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]); if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]); if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]); } $px2 = new DolGraph(); $px2->SetData($graph_datas); - $arraylegends=array($langs->transnoentities("Balance")); + $arraylegends = array($langs->transnoentities("Balance")); if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired")); if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed")); $px2->SetLegend($arraylegends); $px2->SetLegendWidthMin(180); - $px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue()); - $px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue()); + $px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue()); + $px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue()); $px2->SetTitle($title); $px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); - $px2->SetType(array('linesnopoint','linesnopoint','linesnopoint')); + $px2->SetType(array('linesnopoint', 'linesnopoint', 'linesnopoint')); $px2->setBgColor('onglet'); - $px2->setBgColorGrid(array(255,255,255)); + $px2->setBgColorGrid(array(255, 255, 255)); $px2->SetHideXGrid(true); //$px2->SetHorizTickIncrement(30.41); // 30.41 jours/mois en moyenne $px2->draw($file, $fileurl); - $show2=$px2->show(); + $show2 = $px2->show(); unset($px2); unset($graph_datas); @@ -409,13 +409,13 @@ else $amounts = array(); $sql = "SELECT date_format(b.datev,'%Y%m%d')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; - $sql.= " GROUP BY date_format(b.datev,'%Y%m%d')"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; + $sql .= " GROUP BY date_format(b.datev,'%Y%m%d')"; $resql = $db->query($sql); if ($resql) @@ -447,20 +447,20 @@ else $subtotal = 0; $day = $min; - $textdate=strftime("%Y%m%d", $day); + $textdate = strftime("%Y%m%d", $day); //print "x".$textdate; $i = 0; - while ($day <= ($max+86400)) // On va au dela du dernier jour + while ($day <= ($max + 86400)) // On va au dela du dernier jour { $subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0); //print strftime ("%e %d %m %y",$day)." ".$subtotal."\n
"; - if ($day > ($max+86400)) + if ($day > ($max + 86400)) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph } else { - $datas[$i] = '' + $solde + $subtotal; + $datas[$i] = '' +$solde + $subtotal; } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; @@ -470,40 +470,40 @@ else } $day += 86400; - $textdate=strftime("%Y%m%d", $day); + $textdate = strftime("%Y%m%d", $day); $i++; } // Fabrication tableau 3 - $file= $conf->bank->dir_temp."/balance".$account.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png"; - $title=$langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime"); - $graph_datas=array(); - foreach($datas as $i => $val) + $file = $conf->bank->dir_temp."/balance".$account.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png"; + $title = $langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime"); + $graph_datas = array(); + foreach ($datas as $i => $val) { - $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); + $graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]); if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]); if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]); } $px3 = new DolGraph(); $px3->SetData($graph_datas); - $arraylegends=array($langs->transnoentities("Balance")); + $arraylegends = array($langs->transnoentities("Balance")); if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired")); if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed")); $px3->SetLegend($arraylegends); $px3->SetLegendWidthMin(180); - $px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()>0?0:$px3->GetFloorMinValue()); + $px3->SetMaxValue($px3->GetCeilMaxValue() < 0 ? 0 : $px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue() > 0 ? 0 : $px3->GetFloorMinValue()); $px3->SetTitle($title); $px3->SetWidth($WIDTH); $px3->SetHeight($HEIGHT); - $px3->SetType(array('linesnopoint','linesnopoint','linesnopoint')); + $px3->SetType(array('linesnopoint', 'linesnopoint', 'linesnopoint')); $px3->setBgColor('onglet'); - $px3->setBgColorGrid(array(255,255,255)); + $px3->setBgColorGrid(array(255, 255, 255)); $px3->draw($file, $fileurl); - $show3=$px3->show(); + $show3 = $px3->show(); unset($px3); unset($graph_datas); @@ -522,25 +522,25 @@ else $credits = array(); $debits = array(); - $monthnext = $month+1; + $monthnext = $month + 1; $yearnext = $year; if ($monthnext > 12) { - $monthnext=1; + $monthnext = 1; $yearnext++; } $sql = "SELECT date_format(b.datev,'%d')"; - $sql.= ", SUM(b.amount)"; + $sql .= ", SUM(b.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; - $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; - $sql.= " AND b.amount > 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; - $sql.= " GROUP BY date_format(b.datev,'%d')"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; + $sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; + $sql .= " AND b.amount > 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; + $sql .= " GROUP BY date_format(b.datev,'%d')"; $resql = $db->query($sql); if ($resql) @@ -560,24 +560,24 @@ else dol_print_error($db); } - $monthnext = $month+1; + $monthnext = $month + 1; $yearnext = $year; if ($monthnext > 12) { - $monthnext=1; + $monthnext = 1; $yearnext++; } $sql = "SELECT date_format(b.datev,'%d')"; - $sql.= ", SUM(b.amount)"; + $sql .= ", SUM(b.amount)"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; - $sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; - $sql.= " AND b.amount < 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'"; + $sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'"; + $sql .= " AND b.amount < 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%d')"; $resql = $db->query($sql); @@ -599,40 +599,40 @@ else $labels = array(); $data_credit = array(); $data_debit = array(); - for ($i = 0 ; $i < 31 ; $i++) + for ($i = 0; $i < 31; $i++) { - $data_credit[$i] = isset($credits[substr("0".($i+1), -2)]) ? $credits[substr("0".($i+1), -2)] : 0; - $data_debit[$i] = isset($debits[substr("0".($i+1), -2)]) ? $debits[substr("0".($i+1), -2)] : 0; - $labels[$i] = sprintf("%02d", $i+1); + $data_credit[$i] = isset($credits[substr("0".($i + 1), -2)]) ? $credits[substr("0".($i + 1), -2)] : 0; + $data_debit[$i] = isset($debits[substr("0".($i + 1), -2)]) ? $debits[substr("0".($i + 1), -2)] : 0; + $labels[$i] = sprintf("%02d", $i + 1); $datamin[$i] = $object->min_desired; } // Fabrication tableau 4a - $file= $conf->bank->dir_temp."/movement".$account."-".$year.$month.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png"; - $title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($data_credit as $i => $val) + $file = $conf->bank->dir_temp."/movement".$account."-".$year.$month.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png"; + $title = $langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($data_credit as $i => $val) { - $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); + $graph_datas[$i] = array($labels[$i], $data_credit[$i], $data_debit[$i]); } $px4 = new DolGraph(); $px4->SetData($graph_datas); - $px4->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit"))); + $px4->SetLegend(array($langs->transnoentities("Credit"), $langs->transnoentities("Debit"))); $px4->SetLegendWidthMin(180); - $px4->SetMaxValue($px4->GetCeilMaxValue()<0?0:$px4->GetCeilMaxValue()); - $px4->SetMinValue($px4->GetFloorMinValue()>0?0:$px4->GetFloorMinValue()); + $px4->SetMaxValue($px4->GetCeilMaxValue() < 0 ? 0 : $px4->GetCeilMaxValue()); + $px4->SetMinValue($px4->GetFloorMinValue() > 0 ? 0 : $px4->GetFloorMinValue()); $px4->SetTitle($title); $px4->SetWidth($WIDTH); $px4->SetHeight($HEIGHT); - $px4->SetType(array('bars','bars')); + $px4->SetType(array('bars', 'bars')); $px4->SetShading(3); $px4->setBgColor('onglet'); - $px4->setBgColorGrid(array(255,255,255)); + $px4->setBgColorGrid(array(255, 255, 255)); $px4->SetHorizTickIncrement(1); $px4->draw($file, $fileurl); - $show4=$px4->show(); + $show4 = $px4->show(); unset($graph_datas); unset($px4); @@ -648,15 +648,15 @@ else $credits = array(); $debits = array(); $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; - $sql.= " AND b.amount > 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".$year."-12-31 23:59:59'"; + $sql .= " AND b.amount > 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%m');"; $resql = $db->query($sql); @@ -677,15 +677,15 @@ else dol_print_error($db); } $sql = "SELECT date_format(b.datev,'%m')"; - $sql.= ", SUM(b.amount)"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql.= ", ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= " WHERE b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql.= " AND b.datev >= '".$year."-01-01 00:00:00'"; - $sql.= " AND b.datev <= '".$year."-12-31 23:59:59'"; - $sql.= " AND b.amount < 0"; - if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")"; + $sql .= ", SUM(b.amount)"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE b.fk_account = ba.rowid"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.datev >= '".$year."-01-01 00:00:00'"; + $sql .= " AND b.datev <= '".$year."-12-31 23:59:59'"; + $sql .= " AND b.amount < 0"; + if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")"; $sql .= " GROUP BY date_format(b.datev,'%m')"; $resql = $db->query($sql); @@ -707,40 +707,40 @@ else $labels = array(); $data_credit = array(); $data_debit = array(); - for ($i = 0 ; $i < 12 ; $i++) + for ($i = 0; $i < 12; $i++) { - $data_credit[$i] = isset($credits[substr("0".($i+1), -2)]) ? $credits[substr("0".($i+1), -2)] : 0; - $data_debit[$i] = isset($debits[substr("0".($i+1), -2)]) ? $debits[substr("0".($i+1), -2)] : 0; - $labels[$i] = dol_print_date(dol_mktime(12, 0, 0, $i+1, 1, 2000), "%b"); + $data_credit[$i] = isset($credits[substr("0".($i + 1), -2)]) ? $credits[substr("0".($i + 1), -2)] : 0; + $data_debit[$i] = isset($debits[substr("0".($i + 1), -2)]) ? $debits[substr("0".($i + 1), -2)] : 0; + $labels[$i] = dol_print_date(dol_mktime(12, 0, 0, $i + 1, 1, 2000), "%b"); $datamin[$i] = $object->min_desired; } // Fabrication tableau 4b - $file= $conf->bank->dir_temp."/movement".$account."-".$year.".png"; - $fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png"; - $title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year; - $graph_datas=array(); - foreach($data_credit as $i => $val) + $file = $conf->bank->dir_temp."/movement".$account."-".$year.".png"; + $fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png"; + $title = $langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year; + $graph_datas = array(); + foreach ($data_credit as $i => $val) { - $graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]); + $graph_datas[$i] = array($labels[$i], $data_credit[$i], $data_debit[$i]); } $px5 = new DolGraph(); $px5->SetData($graph_datas); - $px5->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit"))); + $px5->SetLegend(array($langs->transnoentities("Credit"), $langs->transnoentities("Debit"))); $px5->SetLegendWidthMin(180); - $px5->SetMaxValue($px5->GetCeilMaxValue()<0?0:$px5->GetCeilMaxValue()); - $px5->SetMinValue($px5->GetFloorMinValue()>0?0:$px5->GetFloorMinValue()); + $px5->SetMaxValue($px5->GetCeilMaxValue() < 0 ? 0 : $px5->GetCeilMaxValue()); + $px5->SetMinValue($px5->GetFloorMinValue() > 0 ? 0 : $px5->GetFloorMinValue()); $px5->SetTitle($title); $px5->SetWidth($WIDTH); $px5->SetHeight($HEIGHT); - $px5->SetType(array('bars','bars')); + $px5->SetType(array('bars', 'bars')); $px5->SetShading(3); $px5->setBgColor('onglet'); - $px5->setBgColorGrid(array(255,255,255)); + $px5->setBgColorGrid(array(255, 255, 255)); $px5->SetHorizTickIncrement(1); $px5->draw($file, $fileurl); - $show5=$px5->show(); + $show5 = $px5->show(); unset($graph_datas); unset($px5); @@ -751,7 +751,7 @@ else // Onglets -$head=bank_prepare_head($object); +$head = bank_prepare_head($object); dol_fiche_head($head, 'graph', $langs->trans("FinancialAccount"), 0, 'account'); @@ -759,32 +759,32 @@ $linkback = ''.$langs->trans("ShowAllAccounts").''; + $morehtml = ''.$langs->trans("ShowAllAccounts").''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); } else { - $morehtml=''.$langs->trans("BackToAccount").''; + $morehtml = ''.$langs->trans("BackToAccount").''; print $langs->trans("AllAccounts"); //print $morehtml; } } else { - $bankaccount=new Account($db); - $listid=explode(',', $account); - foreach($listid as $key => $id) + $bankaccount = new Account($db); + $listid = explode(',', $account); + foreach ($listid as $key => $id) { $bankaccount->fetch($id); - $bankaccount->label=$bankaccount->ref; + $bankaccount->label = $bankaccount->ref; print $bankaccount->getNomUrl(1); - if ($key < (count($listid)-1)) print ', '; + if ($key < (count($listid) - 1)) print ', '; } } } @@ -818,13 +818,13 @@ print '

'; // Graphs if ($mode == 'standard') { - $prevyear=$year; $nextyear=$year; - $prevmonth=$month-1;$nextmonth=$month+1; - if ($prevmonth < 1) { $prevmonth=12; $prevyear--; } - if ($nextmonth > 12) { $nextmonth=1; $nextyear++; } + $prevyear = $year; $nextyear = $year; + $prevmonth = $month - 1; $nextmonth = $month + 1; + if ($prevmonth < 1) { $prevmonth = 12; $prevyear--; } + if ($nextmonth > 12) { $nextmonth = 1; $nextyear++; } // For month - $link="".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; print ''.$link.''; print ''; @@ -837,8 +837,8 @@ if ($mode == 'standard') print ''; // For year - $prevyear=$year-1;$nextyear=$year+1; - $link="".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; + $prevyear = $year - 1; $nextyear = $year + 1; + $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; print ''.$link.''; print ''; diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 957c738ad22..3b07b5bbd68 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_shipments extends ModeleBoxes { - public $boxcode="lastcustomershipments"; - public $boximg="sending"; - public $boxlabel="BoxLastCustomerShipments"; + public $boxcode = "lastcustomershipments"; + public $boximg = "sending"; + public $boxlabel = "BoxLastCustomerShipments"; public $depends = array("expedition"); /** @@ -58,9 +58,9 @@ class box_shipments extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden=! ($user->rights->expedition->lire); + $this->hidden = !($user->rights->expedition->lire); } /** @@ -88,26 +88,26 @@ class box_shipments extends ModeleBoxes if ($user->rights->expedition->lire) { $sql = "SELECT s.nom as name"; - $sql.= ", s.rowid as socid"; - $sql.= ", s.code_client"; - $sql.= ", s.logo, s.email"; - $sql.= ", e.ref, e.tms"; - $sql.= ", e.rowid"; - $sql.= ", e.ref_customer"; - $sql.= ", e.fk_statut"; - $sql.= ", e.fk_user_valid"; - $sql.= ", c.ref as commande_ref"; - $sql.= ", c.rowid as commande_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; - $sql.= " WHERE e.entity = ".$conf->entity; - if (! empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql.=" AND e.fk_statut = 1"; - if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND sc.fk_user = " .$user->id; - else $sql.= " ORDER BY e.date_delivery, e.ref DESC "; - $sql.= $this->db->plimit($max, 0); + $sql .= ", s.rowid as socid"; + $sql .= ", s.code_client"; + $sql .= ", s.logo, s.email"; + $sql .= ", e.ref, e.tms"; + $sql .= ", e.rowid"; + $sql .= ", e.ref_customer"; + $sql .= ", e.fk_statut"; + $sql .= ", e.fk_user_valid"; + $sql .= ", c.ref as commande_ref"; + $sql .= ", c.rowid as commande_id"; + $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql .= " WHERE e.entity = ".$conf->entity; + if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1"; + if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND sc.fk_user = ".$user->id; + else $sql .= " ORDER BY e.date_delivery, e.ref DESC "; + $sql .= $this->db->plimit($max, 0); $result = $this->db->query($sql); if ($result) { @@ -122,8 +122,8 @@ class box_shipments extends ModeleBoxes $shipmentstatic->ref = $objp->ref; $shipmentstatic->ref_customer = $objp->ref_customer; - $orderstatic->id= $objp->commande_id; - $orderstatic->ref=$objp->commande_ref; + $orderstatic->id = $objp->commande_id; + $orderstatic->ref = $objp->commande_ref; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; @@ -157,7 +157,7 @@ class box_shipments extends ModeleBoxes $line++; } - if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedShipments")); + if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedShipments")); $this->db->free($result); } else { diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 41a0d485ce0..9fbf98fc19c 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -26,7 +26,7 @@ */ // Put here all includes required by your class file -require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; +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'; @@ -84,7 +84,7 @@ class EmailSenderProfile extends CommonObject /** * @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( + public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), @@ -167,8 +167,8 @@ class EmailSenderProfile extends CommonObject $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0; + if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0; } /** @@ -244,7 +244,7 @@ class EmailSenderProfile extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); return $result; } @@ -255,11 +255,11 @@ class EmailSenderProfile extends CommonObject */ public function fetchLines() { - $this->lines=array(); + $this->lines = array(); // Load lines with object EmailSenderProfileLine - return count($this->lines)?1:0; + return count($this->lines) ? 1 : 0; } /** @@ -301,19 +301,19 @@ class EmailSenderProfile extends CommonObject $result = ''; $companylink = ''; - $label=$this->label; + $label = $this->label; - $url=''; + $url = ''; //$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id; $linkstart = ''; - $linkend=''; + $linkend = ''; if ($withpicto) { - $result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); - if ($withpicto != 2) $result.=' '; + $result .= ($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend); + if ($withpicto != 2) $result .= ' '; } - $result.= $linkstart . $this->label . $linkend; + $result .= $linkstart.$this->label.$linkend; return $result; } @@ -381,10 +381,10 @@ class EmailSenderProfile extends CommonObject public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); + $sql .= ' fk_user_creat, fk_user_modif'; + $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql .= ' WHERE t.rowid = '.$id; + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -395,7 +395,7 @@ class EmailSenderProfile extends CommonObject { $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; } if ($obj->fk_user_valid) @@ -409,7 +409,7 @@ class EmailSenderProfile extends CommonObject { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; + $this->user_cloture = $cluser; } $this->date_creation = $this->db->jdate($obj->datec); diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php index f6537bf6528..c32fe1d77f2 100644 --- a/htdocs/core/class/events.class.php +++ b/htdocs/core/class/events.class.php @@ -31,12 +31,12 @@ class Events // extends CommonObject /** * @var string ID to identify managed object */ - public $element='events'; + public $element = 'events'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='events'; + public $table_element = 'events'; /** * @var int ID @@ -51,7 +51,7 @@ class Events // extends CommonObject /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var int timestamp @@ -91,18 +91,18 @@ class Events // extends CommonObject public $prefix_session; // List of all Audit/Security events supported by triggers - public $eventstolog=array( - array('id'=>'USER_LOGIN', 'test'=>1), - array('id'=>'USER_LOGIN_FAILED', 'test'=>1), - array('id'=>'USER_LOGOUT', 'test'=>1), - array('id'=>'USER_CREATE', 'test'=>1), - array('id'=>'USER_MODIFY', 'test'=>1), - array('id'=>'USER_NEW_PASSWORD', 'test'=>1), - array('id'=>'USER_ENABLEDISABLE', 'test'=>1), - array('id'=>'USER_DELETE', 'test'=>1), - array('id'=>'GROUP_CREATE', 'test'=>1), - array('id'=>'GROUP_MODIFY', 'test'=>1), - array('id'=>'GROUP_DELETE', 'test'=>1), + public $eventstolog = array( + array('id'=>'USER_LOGIN', 'test'=>1), + array('id'=>'USER_LOGIN_FAILED', 'test'=>1), + array('id'=>'USER_LOGOUT', 'test'=>1), + array('id'=>'USER_CREATE', 'test'=>1), + array('id'=>'USER_MODIFY', 'test'=>1), + array('id'=>'USER_NEW_PASSWORD', 'test'=>1), + array('id'=>'USER_ENABLEDISABLE', 'test'=>1), + array('id'=>'USER_DELETE', 'test'=>1), + array('id'=>'GROUP_CREATE', 'test'=>1), + array('id'=>'GROUP_MODIFY', 'test'=>1), + array('id'=>'GROUP_DELETE', 'test'=>1), ); @@ -110,11 +110,11 @@ class Events // extends CommonObject /** * @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'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), - 'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000), - 'user_agent' =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20), + 'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'user_agent' =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000), ); @@ -140,35 +140,35 @@ class Events // extends CommonObject global $conf; // Clean parameters - $this->description=trim($this->description); - if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent=$_SERVER['HTTP_USER_AGENT']; + $this->description = trim($this->description); + if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent = $_SERVER['HTTP_USER_AGENT']; // Check parameters - if (empty($this->description)) { $this->error='ErrorBadValueForParameterCreateEventDesc'; return -1; } + if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."events("; - $sql.= "type,"; - $sql.= "entity,"; - $sql.= "ip,"; - $sql.= "user_agent,"; - $sql.= "dateevent,"; - $sql.= "fk_user,"; - $sql.= "description,"; - $sql.= "prefix_session"; - $sql.= ") VALUES ("; - $sql.= " '".$this->db->escape($this->type)."',"; - $sql.= " ".$conf->entity.","; - $sql.= " '".$this->db->escape(getUserRemoteIP())."',"; - $sql.= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; - $sql.= " '".$this->db->idate($this->dateevent)."',"; - $sql.= " ".($user->id?"'".$this->db->escape($user->id)."'":'NULL').","; - $sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; - $sql.= " '".$this->db->escape(dol_getprefix())."'"; - $sql.= ")"; + $sql .= "type,"; + $sql .= "entity,"; + $sql .= "ip,"; + $sql .= "user_agent,"; + $sql .= "dateevent,"; + $sql .= "fk_user,"; + $sql .= "description,"; + $sql .= "prefix_session"; + $sql .= ") VALUES ("; + $sql .= " '".$this->db->escape($this->type)."',"; + $sql .= " ".$conf->entity.","; + $sql .= " '".$this->db->escape(getUserRemoteIP())."',"; + $sql .= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').","; + $sql .= " '".$this->db->idate($this->dateevent)."',"; + $sql .= " ".($user->id ? "'".$this->db->escape($user->id)."'" : 'NULL').","; + $sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."',"; + $sql .= " '".$this->db->escape(dol_getprefix())."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events"); @@ -176,7 +176,7 @@ class Events // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -193,24 +193,24 @@ class Events // extends CommonObject { // Clean parameters $this->id = (int) $this->id; - $this->type=trim($this->type); - $this->description=trim($this->description); + $this->type = trim($this->type); + $this->description = trim($this->description); // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."events SET"; - $sql.= " type='".$this->db->escape($this->type)."',"; - $sql.= " dateevent='".$this->db->idate($this->dateevent)."',"; - $sql.= " description='".$this->db->escape($this->description)."'"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " type='".$this->db->escape($this->type)."',"; + $sql .= " dateevent='".$this->db->idate($this->dateevent)."',"; + $sql .= " description='".$this->db->escape($this->description)."'"; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } return 1; @@ -227,20 +227,20 @@ class Events // extends CommonObject public function fetch($id, $user = null) { $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.tms,"; - $sql.= " t.type,"; - $sql.= " t.entity,"; - $sql.= " t.dateevent,"; - $sql.= " t.description,"; - $sql.= " t.ip,"; - $sql.= " t.user_agent,"; - $sql.= " t.prefix_session"; - $sql.= " FROM ".MAIN_DB_PREFIX."events as t"; - $sql.= " WHERE t.rowid = ".$id; + $sql .= " t.rowid,"; + $sql .= " t.tms,"; + $sql .= " t.type,"; + $sql .= " t.entity,"; + $sql .= " t.dateevent,"; + $sql .= " t.description,"; + $sql .= " t.ip,"; + $sql .= " t.user_agent,"; + $sql .= " t.prefix_session"; + $sql .= " FROM ".MAIN_DB_PREFIX."events as t"; + $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -263,7 +263,7 @@ class Events // extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } } @@ -278,13 +278,13 @@ class Events // extends CommonObject public function delete($user) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."events"; - $sql.= " WHERE rowid=".$this->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) + if (!$resql) { - $this->error="Error ".$this->db->lasterror(); + $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -301,12 +301,12 @@ class Events // extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->tms=time(); - $this->type=''; - $this->dateevent=time(); - $this->description='This is a specimen event'; + $this->tms = time(); + $this->type = ''; + $this->dateevent = time(); + $this->description = 'This is a specimen event'; $this->ip = '1.2.3.4'; $this->user_agent = 'Mozilla specimen User Agent X.Y'; $this->prefix_session = dol_getprefix(); diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 2a2a6c97078..2701d126331 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -36,7 +36,7 @@ class FormCron extends Form /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * Constructor @@ -66,35 +66,35 @@ class FormCron extends Form $langs->load('cron@cron'); $out = ''; if (!empty($readonly)) { - if ($selected=='command') { - $out= $langs->trans('CronType_command'); - $out.=''; - } elseif ($selected=='method') { - $out= $langs->trans('CronType_method'); - $out.=''; + if ($selected == 'command') { + $out = $langs->trans('CronType_command'); + $out .= ''; + } elseif ($selected == 'method') { + $out = $langs->trans('CronType_method'); + $out .= ''; } } else { - $out=''; - if ($selected=='command') { - $selected_attr=' selected '; + if ($selected == 'command') { + $selected_attr = ' selected '; } else { - $selected_attr=''; + $selected_attr = ''; } - $out.= ''; + $out .= ''; - if ($selected=='method') { - $selected_attr=' selected '; + if ($selected == 'method') { + $selected_attr = ' selected '; } else { - $selected_attr=''; + $selected_attr = ''; } - $out.= ''; + $out .= ''; - $out.=''; + $out .= ''; } return $out; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0d614198d1e..9c5b92a47a0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -6061,49 +6061,49 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if (is_object($object) && $object->element == 'societe') { - $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:''); - $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:''); - $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:''); - $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object)?$object->code_client:''); - $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object)?$object->code_fournisseur:''); - $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:''); - $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object)?$object->phone:''); - $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->fax:''); - $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object)?$object->address:''); - $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object)?$object->zip:''); - $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object)?$object->town:''); - $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object)?$object->idprof1:''); - $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object)?$object->idprof2:''); - $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object)?$object->idprof3:''); - $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object)?$object->idprof4:''); - $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object)?$object->idprof5:''); - $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object)?$object->idprof6:''); - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:''); - $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object)?dol_htmlentitiesbr($object->note_public):''); - $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object)?dol_htmlentitiesbr($object->note_private):''); + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object) ? $object->id : ''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name : ''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias : ''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client : ''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur : ''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email : ''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object) ? $object->phone : ''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object) ? $object->fax : ''); + $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : ''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : ''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : ''); + $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 : ''); + $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 : ''); + $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 : ''); + $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 : ''); + $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 : ''); + $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 : ''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra : ''); + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?dol_htmlentitiesbr($object->note_public) : ''); + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?dol_htmlentitiesbr($object->note_private) : ''); } elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0) { - $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:''); - $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:''); - $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:''); - $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:''); - $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:''); - $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:''); - $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->thirdparty->phone:''); - $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->thirdparty->fax:''); - $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty)?$object->thirdparty->address:''); - $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->thirdparty->zip:''); - $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->thirdparty->town:''); - $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof1:''); - $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof2:''); - $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof3:''); - $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof4:''); - $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof5:''); - $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof6:''); - $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->thirdparty->tva_intra:''); - $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_public):''); - $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_private):''); + $substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id : ''); + $substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name : ''); + $substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias : ''); + $substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client : ''); + $substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur : ''); + $substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email : ''); + $substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ? $object->thirdparty->phone : ''); + $substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ? $object->thirdparty->fax : ''); + $substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : ''); + $substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : ''); + $substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : ''); + $substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 : ''); + $substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 : ''); + $substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 : ''); + $substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 : ''); + $substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 : ''); + $substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 : ''); + $substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra : ''); + $substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?dol_htmlentitiesbr($object->thirdparty->note_public) : ''); + $substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?dol_htmlentitiesbr($object->thirdparty->note_private) : ''); } if (is_object($object->project) && $object->project->id > 0) diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 8f99dcc59a1..96d3d3f45a5 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -27,7 +27,7 @@ * \brief Fichier de description et activation du module Expedition */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -76,11 +76,11 @@ class modExpedition extends DolibarrModules $this->depends = array("modCommande"); $this->requiredby = array(); $this->conflictwith = array(); - $this->langfiles = array('deliveries','sendings'); + $this->langfiles = array('deliveries', 'sendings'); // Constants $this->const = array(); - $r=0; + $r = 0; $this->const[$r][0] = "EXPEDITION_ADDON_PDF"; $this->const[$r][1] = "chaine"; @@ -133,13 +133,13 @@ class modExpedition extends DolibarrModules // Boxes $this->boxes = array( - 0=>array('file'=>'box_shipments.php','enabledbydefaulton'=>'Home'), + 0=>array('file'=>'box_shipments.php', 'enabledbydefaulton'=>'Home'), ); // Permissions $this->rights = array(); $this->rights_class = 'expedition'; - $r=0; + $r = 0; $r++; $this->rights[$r][0] = 101; @@ -221,92 +221,92 @@ class modExpedition extends DolibarrModules // Menus //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports //-------- - $r=0; + $r = 0; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $shipment=new Commande($this->db); - $contact_arrays=$shipment->liste_type_contact('external', '', 0, 0, ''); - if (is_array($contact_arrays) && count($contact_arrays)>0){ - $idcontacts=join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, ''))); + $shipment = new Commande($this->db); + $contact_arrays = $shipment->liste_type_contact('external', '', 0, 0, ''); + if (is_array($contact_arrays) && count($contact_arrays) > 0) { + $idcontacts = join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, ''))); } else { - $idcontacts=0; + $idcontacts = 0; } $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("expedition","shipment","export")); - $this->export_fields_array[$r]=array( - 's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country', - 'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5', - 's.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation", - 'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth", - 'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic", - 'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel', - 'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits' + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_permission[$r] = array(array("expedition", "shipment", "export")); + $this->export_fields_array[$r] = array( + 's.rowid'=>"IdCompany", 's.nom'=>'ThirdParty', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country', + 'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', + 's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation", + 'c.date_delivery'=>"DateDeliveryPlanned", 'c.tracking_number'=>"TrackingNumber", 'c.height'=>"Height", 'c.width'=>"Width", 'c.size'=>"Depth", + 'c.size_units'=>'SizeUnits', 'c.weight'=>"Weight", 'c.weight_units'=>"WeightUnits", 'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic", + 'ed.rowid'=>'LineId', 'cd.description'=>'Description', 'ed.qty'=>"Qty", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', + 'p.weight'=>'ProductWeight', 'p.weight_units'=>'WeightUnits', 'p.volume'=>'ProductVolume', 'p.volume_units'=>'VolumeUnits' ); - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic'); + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic'); //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", // 'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", // 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text" //); - $this->export_TypeFields_array[$r]=array( - 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text', - 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date", - 'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status', - 'c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text' + $this->export_TypeFields_array[$r] = array( + 's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text', + 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date", + 'c.date_delivery'=>"Date", 'c.tracking_number'=>"Numeric", 'c.height'=>"Numeric", 'c.width'=>"Numeric", 'c.weight'=>"Numeric", 'c.fk_statut'=>'Status', + 'c.note_public'=>"Text", 'ed.qty'=>"Numeric", 'd.nom'=>'Text' ); - $this->export_entities_array[$r]=array( - 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', - 'co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company', - 's.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment", - 'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment", - 'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment", - 'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product', - 'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product' + $this->export_entities_array[$r] = array( + 's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company', + 'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company', + 's.idprof5'=>'company', 's.idprof6'=>'company', 'c.rowid'=>"shipment", 'c.ref'=>"shipment", 'c.ref_customer'=>"shipment", 'c.fk_soc'=>"shipment", + 'c.date_creation'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment", + 'c.size'=>'shipment', 'c.size_units'=>'shipment', 'c.weight'=>"shipment", 'c.weight_units'=>'shipment', 'c.fk_statut'=>"shipment", 'c.note_public'=>"shipment", + 'ed.rowid'=>'shipment_line', 'cd.description'=>'shipment_line', 'ed.qty'=>"shipment_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product', + 'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product' ); - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact'); - $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)) + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact'); + $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 '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'expedition as c'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object'; - $this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; - if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'expedition as c'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,'; + $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'expeditiondet as ed'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object'; + $this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commandedet as cd'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object'; + if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) { + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object'; } - $this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; - $this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')'; - if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id; + $this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid'; + $this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')'; + if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id; } @@ -320,25 +320,25 @@ class modExpedition extends DolibarrModules */ public function init($options = '') { - global $conf,$langs; + global $conf, $langs; // Permissions $this->remove($options); //ODT template - $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; - $dirodt=DOL_DATA_ROOT.'/doctemplates/shipment'; - $dest=$dirodt.'/template_shipment.odt'; + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/shipment'; + $dest = $dirodt.'/template_shipment.odt'; - if (file_exists($src) && ! file_exists($dest)) + if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; dol_mkdir($dirodt); - $result=dol_copy($src, $dest, 0, 0); + $result = dol_copy($src, $dest, 0, 0); if ($result < 0) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + $this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest); return 0; } } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 938f4411b57..1b538b016df 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -880,7 +880,7 @@ if (!defined('NOLOGIN')) if (GETPOST('theme', 'alpha')) { $conf->theme = GETPOST('theme', 'alpha', 1); - $conf->css = "/theme/".$conf->theme."/style.css.php"; + $conf->css = "/theme/".$conf->theme."/style.css.php"; } @@ -926,7 +926,7 @@ if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1; if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok'))) { $conf->theme = 'eldy'; - $conf->css = "/theme/".$conf->theme."/style.css.php"; + $conf->css = "/theme/".$conf->theme."/style.css.php"; } if (!defined('NOREQUIRETRAN')) @@ -1361,93 +1361,93 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } // Output standard javascript links - if (! defined('DISABLE_JQUERY') && ! $disablejs && ! empty($conf->use_javascript_ajax)) + if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { // JQuery. Must be before other includes print ''."\n"; - if (defined('JS_JQUERY') && constant('JS_JQUERY')) print ''."\n"; - else print ''."\n"; + if (defined('JS_JQUERY') && constant('JS_JQUERY')) print ''."\n"; + else print ''."\n"; /*if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED')) { if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print ''."\n"; else print ''."\n"; }*/ - if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print ''."\n"; - else print ''."\n"; - if (! defined('DISABLE_JQUERY_TABLEDND')) print ''."\n"; + if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print ''."\n"; + else print ''."\n"; + if (!defined('DISABLE_JQUERY_TABLEDND')) print ''."\n"; // jQuery jnotify - if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY')) + if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) { - print ''."\n"; + print ''."\n"; } // Flot - if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && ! defined('DISABLE_JQUERY_FLOT')) + if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && !defined('DISABLE_JQUERY_FLOT')) { if (constant('JS_JQUERY_FLOT')) { - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } else { - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; } } // jQuery jeditable - if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! defined('DISABLE_JQUERY_JEDITABLE')) + if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE')) { print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; print ''."\n"; - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } // jQuery Timepicker - if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) + if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER')) { - print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''."\n"; } - if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) // jQuery plugin "mutiselect", "multiple-select", "select2", ... + if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) // jQuery plugin "mutiselect", "multiple-select", "select2", ... { - $tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT; - print ''."\n"; // We include full because we need the support of containerCssClass + $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT; + print ''."\n"; // We include full because we need the support of containerCssClass } } - if (! $disablejs && ! empty($conf->use_javascript_ajax)) + if (!$disablejs && !empty($conf->use_javascript_ajax)) { // CKEditor - if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && ! defined('DISABLE_CKEDITOR')) + if (!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR')) { print ''."\n"; - $pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/'; - $jsckeditor='ckeditor.js'; + $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/'; + $jsckeditor = 'ckeditor.js'; if (constant('JS_CKEDITOR')) // To use external ckeditor 4 js lib { - $pathckeditor=constant('JS_CKEDITOR'); + $pathckeditor = constant('JS_CKEDITOR'); } print ''."\n"; - print ''."\n"; + print ''."\n"; print ' + array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key + 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done + 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) + ); + $alsoproductwithnosupplierprice=0; + } + else + { + $ajaxoptions = array( + 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key + ); + $alsoproductwithnosupplierprice=1; + } + $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth500'); + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { ?> - - array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key - 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done - 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) - ); - $alsoproductwithnosupplierprice=0; - } - else - { - $ajaxoptions = array( - 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key - ); - $alsoproductwithnosupplierprice=1; - } - - $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth300'); - - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) - { - ?> - - '; - echo ''; -} - -if (is_object($hookmanager) && empty($senderissupplier)) -{ - $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); - $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); - if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; - } -} -if (is_object($hookmanager) && ! empty($senderissupplier)) -{ - $parameters=array('htmlname'=>'addproduct'); - $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); - if (!empty($hookmanager->resPrint)) { - print $hookmanager->resPrint; - } -} - - -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { - if (!empty($conf->variants->enabled)) { - echo '
'; - } - - echo '
'; -} - -// Editor wysiwyg -require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; -$nbrows=ROWS_2; -$enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); -if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; -$toolbarname='dolibarr_details'; -if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; -$doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); -$doleditor->Create(); - -// Show autofill date for recurring invoices -if (! empty($conf->service->enabled) && $object->element == 'facturerec') -{ - echo '

'; - echo $langs->trans('AutoFillDateFrom').' '; - echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); - echo ' - '; - echo $langs->trans('AutoFillDateTo').' '; - echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); - echo '
'; -} -echo ''; - -if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines -{ - $coldisplay++; - ?> + + '; + echo ''; + } + if (is_object($hookmanager) && empty($senderissupplier)) + { + $parameters=array('fk_parent_line'=>GETPOST('fk_parent_line', 'int')); + $reshook=$hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } + } + if (is_object($hookmanager) && ! empty($senderissupplier)) + { + $parameters=array('htmlname'=>'addproduct'); + $reshook=$hookmanager->executeHooks('formCreateProductSupplierOptions', $parameters, $object, $action); + if (!empty($hookmanager->resPrint)) { + print $hookmanager->resPrint; + } + } + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) { + if (!empty($conf->variants->enabled)) { + echo '
'; + } + echo '
'; + } + // Editor wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $nbrows=ROWS_2; + $enabled=(! empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; + $toolbarname='dolibarr_details'; + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; + $doleditor=new DolEditor('dp_desc', GETPOST('dp_desc', 'none'), '', (empty($conf->global->MAIN_DOLEDITOR_HEIGHT)?100:$conf->global->MAIN_DOLEDITOR_HEIGHT), $toolbarname, '', false, true, $enabled, $nbrows, '98%'); + $doleditor->Create(); + // Show autofill date for recurring invoices + if (! empty($conf->service->enabled) && $object->element == 'facturerec') + { + echo '

'; + echo $langs->trans('AutoFillDateFrom').' '; + echo $form->selectyesno('date_start_fill', $line->date_start_fill, 1); + echo ' - '; + echo $langs->trans('AutoFillDateTo').' '; + echo $form->selectyesno('date_end_fill', $line->date_end_fill, 1); + echo '
'; + } + echo ''; + if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines + { + $coldisplay++; + ?> "> '; $coldisplay++; if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); @@ -381,84 +353,78 @@ else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", ' - "> + "> -multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { - $coldisplay++; + multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { + $coldisplay++; + ?> + + "> + + + + "> + + - - "> - - - - "> - - "> -global->PRODUCT_USE_UNITS) -{ - $coldisplay++; - print ''; - print $form->selectUnits($line->fk_unit, "units"); - print ''; -} -$remise_percent = $buyer->remise_percent; -if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') -{ - $remise_percent = $seller->remise_supplier_percent; -} - -$coldisplay++; -?> + global->PRODUCT_USE_UNITS) + { + $coldisplay++; + print ''; + print $form->selectUnits($line->fk_unit, "units"); + print ''; + } + $remise_percent = $buyer->remise_percent; + if($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') + { + $remise_percent = $seller->remise_supplier_percent; + } + $coldisplay++; + ?> ">% -situation_cycle_ref) { - $coldisplay++; - print '%'; - $coldisplay++; - print ''; -} - -if (! empty($usemargins)) -{ - if (!empty($user->rights->margins->creer)) { - $coldisplay++; - ?> + situation_cycle_ref) { + $coldisplay++; + print '%'; + $coldisplay++; + print ''; + } + if (! empty($usemargins)) + { + if (!empty($user->rights->margins->creer)) { + $coldisplay++; + ?> - product->enabled) || ! empty($conf->service->enabled)) { ?> - - + product->enabled) || ! empty($conf->service->enabled)) { ?> + + "> - global->DISPLAY_MARGIN_RATES)) - { - echo '%'; - $coldisplay++; - } - if (! empty($conf->global->DISPLAY_MARK_RATES)) - { - echo '%'; - $coldisplay++; + global->DISPLAY_MARGIN_RATES)) + { + echo '%'; + $coldisplay++; + } + if (! empty($conf->global->DISPLAY_MARK_RATES)) + { + echo '%'; + $coldisplay++; + } } } -} - -$coldisplay+=$colspan; -?> + $coldisplay+=$colspan; + ?> @@ -468,196 +434,193 @@ $coldisplay+=$colspan; if (is_object($objectline)) { print $objectline->showOptionals($extrafields, 'edit', array('colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD) ? 0 : 1); } - if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { - ?> +?> - > +> global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> - element) && $object->element == 'contrat') - { - print $langs->trans("DateStartPlanned").' '; - print $form->selectDate($date_start, "date_start", $usehm, $usehm, 1, "addproduct"); - print '   '.$langs->trans("DateEndPlanned").' '; - print $form->selectDate($date_end, "date_end", $usehm, $usehm, 1, "addproduct"); - } - else - { - echo $langs->trans('ServiceLimitedDuration').' '.$langs->trans('From').' '; - print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); - echo ' '.$langs->trans('to').' '; - print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); - }; - print ''; + print ''; + print "\n"; } - } - print ''; - print ''; - print "\n"; -} + print " + /* At loading, no product are yet selected, so we hide field of buying_price */ + $("#buying_price").hide(); - + /* Define default price at loading */ + var defaultprice = $("#fournprice_predef").find('option:selected').attr("price"); + $("#buying_price").val(defaultprice); + + $("#fournprice_predef").change(function() { + console.log("change on fournprice_predef"); + /* Hide field buying_price according to choice into list (if 'inputprice' or not) */ + var linevalue=$(this).find('option:selected').val(); + var pricevalue = $(this).find('option:selected').attr("price"); + if (linevalue != 'inputprice' && linevalue != 'pmpprice') { + $("#buying_price").val(pricevalue).hide(); /* We set value then hide field */ + } + if (linevalue == 'inputprice') { + $('#buying_price').show(); + } + if (linevalue == 'pmpprice') { + $("#buying_price").val(pricevalue); + $('#buying_price').hide(); + } + }); + } + }, + 'json'); + + + + /* To process customer price per quantity */ + var pbq = parseInt($('option:selected', this).attr('data-pbq')); + var pbqqty = parseFloat($('option:selected', this).attr('data-pbqqty')); + var pbqpercent = parseFloat($('option:selected', this).attr('data-pbqpercent')); + + if ((jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val()) && typeof pbq !== "undefined") + { + console.log("We choose a price by quanty price_by_qty id = "+pbq+" price_by_qty qty = "+pbqqty+" price_by_qty percent = "+pbqpercent); + jQuery("#pbq").val(pbq); + if (jQuery("#qty").val() < pbqqty) + { + jQuery("#qty").val(pbqqty); + } + if (jQuery("#remise_percent").val() < pbqpercent) + { + jQuery("#remise_percent").val(pbqpercent); + } + } + else + { + jQuery("#pbq").val(''); + } + + /* To set focus */ + if (jQuery('#idprod').val() > 0 || jQuery('#idprodfournprice').val() > 0) + { + /* focus work on a standard textarea but not if field was replaced with CKEDITOR */ + jQuery('#dp_desc').focus(); + /* focus if CKEDITOR */ + if (typeof CKEDITOR == "object" && typeof CKEDITOR.instances != "undefined") + { + var editor = CKEDITOR.instances['dp_desc']; + if (editor) { editor.focus(); } + } + } + }); + + + setforpredef(); + + }); + + /* Function to set fields from choice */ + function setforfree() { + console.log("Call setforfree. We show most fields"); + jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product + jQuery("#prod_entry_mode_free").prop('checked',true).change(); + jQuery("#prod_entry_mode_predef").prop('checked',false).change(); + jQuery("#search_idprod, #idprod, #search_idprodfournprice, #buying_price").val(''); + jQuery("#price_ht, #multicurrency_price_ht, #price_ttc, #price_ttc, #fourn_ref, #tva_tx, #buying_price, #title_vat, #title_up_ht, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").show(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); + jQuery("#fournprice_predef").hide(); + } + function setforpredef() { + console.log("Call setforpredef. We hide some fields and show dates"); + jQuery("#select_type").val(-1); + jQuery("#prod_entry_mode_free").prop('checked',false).change(); + jQuery("#prod_entry_mode_predef").prop('checked',true).change(); + global->MAIN_DISABLE_EDIT_PREDEF_PRICEHT)) { ?> + jQuery("#price_ht").val('').show(); + jQuery("#multicurrency_price_ht").val('').show(); + + jQuery("#price_ht").val('').hide(); + jQuery("#multicurrency_price_ht").val('').hide(); + + jQuery("#price_ht").val(''); + jQuery("#price_ttc, #fourn_ref, #tva_tx, #title_vat, #title_up_ht_currency, #title_up_ttc, #title_up_ttc_currency").hide(); + jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); + jQuery("#buying_price").show(); + jQuery('#trlinefordates, .divlinefordates').show(); + } + + + + From 9095482113a40e10a6e39edf26cfc7047e52b0dd Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 30 Nov 2019 14:47:48 +0100 Subject: [PATCH 070/248] Fix margins access + menu display --- htdocs/core/menus/standard/eldy.lib.php | 3 ++- htdocs/margin/productMargins.php | 2 +- htdocs/margin/tabs/productMargins.php | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 6325643cf87..c875c0c28a5 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -165,9 +165,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0,$mode if (! empty($conf->salaries->enabled)) $menuqualified++; if (! empty($conf->supplier_invoice->enabled)) $menuqualified++; if (! empty($conf->loan->enabled)) $menuqualified++; + if (! empty($conf->margins->enabled)) $menuqualified++; $tmpentry=array( 'enabled'=>$menuqualified, - 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read)), + 'perms'=>(! empty($user->rights->facture->lire) || ! empty($user->rights->don->lire) || ! empty($user->rights->tax->charges->lire) || ! empty($user->rights->salaries->read) || ! empty($user->rights->fournisseur->facture->lire) || ! empty($user->rights->loan->read) || ! empty($user->rights->margins->liretous)), 'module'=>'facture|supplier_invoice|don|tax|salaries|loan'); $showmode=isVisibleToUserType($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index d827f5d985e..38018852ffe 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -42,7 +42,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); -$result=restrictedArea($user,'margins'); +if(empty($user->rights->margins->liretous)) accessforbidden(); $mesg = ''; diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 3b826501614..cd6b93e04e1 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -41,6 +41,7 @@ $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); $fieldtype = (! empty($ref) ? 'ref' : 'rowid'); if (! empty($user->societe_id)) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service',$fieldvalue,'product&product','','',$fieldtype); +if(empty($user->rights->margins->liretous)) accessforbidden(); $object = new Product($db); From 916954b301a1168064489a73d4111225f8ab5499 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 30 Nov 2019 14:48:05 +0100 Subject: [PATCH 071/248] Fix #12371 : access rights on contacts --- htdocs/core/lib/company.lib.php | 2 +- htdocs/societe/contact.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 68ad744dee2..8528c25bac7 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -52,7 +52,7 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) { - if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->societe->contact->lire) { //$nbContact = count($object->liste_contact(-1,'internal')) + count($object->liste_contact(-1,'external')); $nbContact = 0; // TODO diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 37fb07eb652..8a988edc413 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -88,6 +88,7 @@ if (! empty($canvas)) // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); +if(empty($user->rights->societe->contact->lire)) accessforbidden(); From a13b2267aaf4abd139cae4239eaa1415c4dfe6f9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 30 Nov 2019 14:22:25 +0000 Subject: [PATCH 072/248] Fixing style errors. --- htdocs/core/tpl/objectline_create.tpl.php | 90 +++++++++++------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index ee71032bfff..656c93cca55 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -236,9 +236,9 @@ if ($nolinesbefore) { { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) - { - ?> + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + { + ?> - array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for example shown we select a disabled option into combo) - ); - $alsoproductwithnosupplierprice=0; - } - else - { - $ajaxoptions = array( + ); + $alsoproductwithnosupplierprice=0; + } + else + { + $ajaxoptions = array( 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key - ); - $alsoproductwithnosupplierprice=1; - } - $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth500'); - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) - { - ?> + ); + $alsoproductwithnosupplierprice=1; + } + $form->select_produits_fournisseurs($object->socid, GETPOST('idprodfournprice'), 'idprodfournprice', '', '', $ajaxoptions, 1, $alsoproductwithnosupplierprice, 'maxwidth500'); + if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_SUPPLIER_PRODUCTS)) + { + ?> - '; echo ''; @@ -341,15 +341,15 @@ if ($nolinesbefore) { echo ''; if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines { - $coldisplay++; - ?> + $coldisplay++; + ?> "> -'; -$coldisplay++; -if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); -else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); -?> + '; + $coldisplay++; + if ($seller->tva_assuj == "0") echo ''.vatrate(0, true); + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?GETPOST("tva_tx", 'alpha', 2):-1), $seller, $buyer, 0, 0, '', false, 1); + ?> @@ -436,7 +436,7 @@ if (is_object($objectline)) { } if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { -?> + ?> > global->MAIN_VIEW_LINE_NUMBER)) { print ''; } ?> @@ -478,28 +478,28 @@ if ((!empty($conf->service->enabled) || ($object->element == 'contrat')) && $dat print ''; print ''; print "\n"; - } +} print " - + global->TAKEPOS_NUM_TERMINALS != "1" && $_SESSION["takeposterminal"] == "") print '
'.$langs->trans('TerminalSelect').'
'; ?> From 755417e9a92e719bad39a9cbddb613dda6187b8c Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Sat, 30 Nov 2019 23:43:22 +0100 Subject: [PATCH 084/248] add location on combobox usefull for BOM, etc --- htdocs/product/stock/class/entrepot.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index a8a724f3575..07eeea82137 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -107,7 +107,7 @@ class Entrepot extends CommonObject 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-2, 'showoncombobox'=>1, 'position'=>25), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35), - 'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>-2, 'position'=>40), + 'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>-2, 'position'=>40, 'showoncombobox'=>1), 'fk_parent' =>array('type'=>'integer', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41), 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45), 'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50), From 89f57d7d3be94584dbaeaf94744c4174d45749d4 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Sat, 30 Nov 2019 23:45:24 +0100 Subject: [PATCH 085/248] add label to combobox useful for BOM, etc --- htdocs/product/class/product.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 3a1cca3a139..68675b3e9dd 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -385,7 +385,8 @@ class Product extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), From a2a96f879615171292a4bd49db9ff2b7076ff02e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 00:41:11 +0100 Subject: [PATCH 086/248] # WARNING: head commit changed in the meantime Restore file for travis --- htdocs/comm/propal/card.php | 4 ++-- htdocs/product/card.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index b3d8360e39a..e916c544ced 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1588,7 +1588,7 @@ if ($action == 'create') }); '; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '; print ''; } print ''."\n"; @@ -1675,7 +1675,7 @@ if ($action == 'create') print ''; print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id).'">'.$langs->trans("AddProject").''; + print '   id).'">'; print ''; print ''; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index db6b60172be..8c139382eb3 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1048,7 +1048,9 @@ else // Default warehouse print ''.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses(GETPOST('fk_default_warehouse'), 'fk_default_warehouse', 'warehouseopen', 1); - print ' '.$langs->trans("AddWarehouse").''; + print ' '; + print ''; + print ''; print ''; // Stock min level print ''.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).''; From a220d43bd6c612945a590dc1a2dfe4b78fce5ea1 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 1 Dec 2019 01:41:13 +0100 Subject: [PATCH 087/248] Fix #11849 : missing price2num in discount split --- htdocs/comm/remx.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index eb1c14a4beb..aa9307df8d2 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -61,8 +61,10 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ttc_1=GETPOST('amount_ttc_1'); - $amount_ttc_2=GETPOST('amount_ttc_2'); + $amount_ttc_1 = GETPOST('amount_ttc_1'); + $amount_ttc_1 = price2num($amount_ttc_1); + $amount_ttc_2 = GETPOST('amount_ttc_2'); + $amount_ttc_2 = price2num($amount_ttc_2); $error=0; $remid=GETPOST("remid")?GETPOST("remid"):0; From 270f4c250025b45e434c25729c860b83c187390c Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 1 Dec 2019 09:26:54 +0100 Subject: [PATCH 088/248] Fix #12044 : with replenish function, use product supplier desc in order --- htdocs/product/stock/replenish.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 87d60263e4f..a31a184731f 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -147,7 +147,13 @@ if ($action == 'order' && isset($_POST['valid'])) { $productsupplier->getMultiLangs(); } - $line->desc = $productsupplier->description; + + // if we use supplier description of the products + if(!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { + $desc = $productsupplier->desc_supplier; + } else $desc = $productsupplier->description; + + $line->desc = $desc; if (! empty($conf->global->MAIN_MULTILANGS)) { // TODO Get desc in language of thirdparty From 096e50aaf6cdc4cf107d7696ac6d3606a3edf683 Mon Sep 17 00:00:00 2001 From: ATM John BOTELLA Date: Sun, 1 Dec 2019 10:08:43 +0100 Subject: [PATCH 089/248] add link to widget --- htdocs/core/lib/project.lib.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 58a46aef0ec..00a1e8ea505 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2071,18 +2071,23 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide else { if ($task->hasDelay()) $out .= img_warning($langs->trans("Late")).' '; - $out .= !empty($diff) ? $diff.' ' : ''; + $url = DOL_URL_ROOT.'/projet/tasks/time.php?id='.$task->id; + $out .= !empty($diff) ? $diff.' ' : ''; + $out .= ''; $out .= ''; if ($task->duration_effective) $out .= convertSecondToTime($task->duration_effective, $timespentoutputformat); else $out .= '--:--'; $out .= ''; + $out .= ''; $out .= '/'; + $out .= ''; $out .= ''; if ($task->planned_workload) $out .= convertSecondToTime($task->planned_workload, $plannedworkloadoutputformat); else $out .= '--:--'; + $out .= ''; } $out .= ' '; } From 773f82374807a085a41bfff43b71455dea4b076e Mon Sep 17 00:00:00 2001 From: ATM John BOTELLA Date: Sun, 1 Dec 2019 10:20:11 +0100 Subject: [PATCH 090/248] factoring token usage --- htdocs/adherents/list.php | 2 +- .../compta/bank/various_payment/document.php | 2 +- htdocs/compta/charges/index.php | 2 +- .../compta/facture/invoicetemplate_list.php | 2 +- htdocs/compta/facture/list.php | 2 +- .../boxes/box_graph_invoices_permonth.php | 2 +- .../box_graph_invoices_supplier_permonth.php | 2 +- .../core/boxes/box_graph_orders_permonth.php | 2 +- .../box_graph_orders_supplier_permonth.php | 2 +- .../boxes/box_graph_product_distribution.php | 2 +- .../boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/boxes/box_task.php | 2 +- htdocs/core/class/html.form.class.php | 40 +++++++++---------- htdocs/core/class/html.formbarcode.class.php | 4 +- htdocs/core/class/html.formcompany.class.php | 2 +- htdocs/core/class/html.formcontract.class.php | 2 +- htdocs/core/class/html.formfile.class.php | 12 +++--- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/class/html.formsms.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 4 +- htdocs/core/lib/functions.lib.php | 9 +++++ .../doc/doc_generic_order_odt.modules.php | 2 +- .../modules/commande/mod_commande_saphir.php | 2 +- .../doc/doc_generic_contract_odt.modules.php | 2 +- .../modules/contract/mod_contract_magre.php | 2 +- .../doc/doc_generic_product_odt.modules.php | 2 +- .../product/mod_codeproduct_elephant.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 2 +- .../modules/project/mod_project_universal.php | 2 +- .../task/doc/doc_generic_task_odt.modules.php | 2 +- .../project/task/mod_task_universal.php | 2 +- .../doc/doc_generic_proposal_odt.modules.php | 2 +- .../modules/propale/mod_propale_saphir.php | 2 +- .../societe/doc/doc_generic_odt.modules.php | 2 +- .../societe/mod_codeclient_elephant.php | 2 +- .../societe/mod_codecompta_aquarium.php | 2 +- .../societe/mod_codecompta_digitaria.php | 2 +- .../core/tpl/admin_extrafields_edit.tpl.php | 2 +- htdocs/core/tpl/bloc_comment.tpl.php | 4 +- htdocs/core/tpl/extrafields_view.tpl.php | 2 +- htdocs/core/tpl/login.tpl.php | 2 +- htdocs/core/tpl/resource_add.tpl.php | 2 +- htdocs/loan/createschedule.php | 2 +- htdocs/loan/list.php | 2 +- htdocs/loan/payment/payment.php | 2 +- htdocs/loan/schedule.php | 2 +- htdocs/main.inc.php | 6 +-- htdocs/projet/tasks.php | 4 +- htdocs/user/agenda_extsites.php | 2 +- htdocs/user/bank.php | 4 +- htdocs/user/card.php | 8 ++-- htdocs/user/clicktodial.php | 2 +- htdocs/user/group/card.php | 6 +-- htdocs/user/group/list.php | 2 +- htdocs/user/hierarchy.php | 2 +- htdocs/user/home.php | 2 +- htdocs/user/list.php | 2 +- htdocs/user/note.php | 2 +- htdocs/user/param_ihm.php | 2 +- 59 files changed, 103 insertions(+), 94 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 1cf99284074..7497ededc8f 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -412,7 +412,7 @@ if ($user->rights->adherent->creer) print ''; if ($optioncss != '') print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 6e8fb2a65ea..476f94c8937 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -99,7 +99,7 @@ if ($object->id) //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref.=''; $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref.=''; $morehtmlref.=''; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index fd270cba3f1..265685a2f4b 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -92,7 +92,7 @@ if ($sortorder) $param .= '&sortorder='.$sortorder; print '
'; if ($optioncss != '') print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index a4b1eb0e188..c3714b28360 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -317,7 +317,7 @@ if ($resql) print ''; if ($optioncss != '') print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ca8c78dd478..a7db0fc332e 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -637,7 +637,7 @@ if ($resql) print ''."\n"; if ($optioncss != '') print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 91ec36fd500..48baff0f8fd 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -239,7 +239,7 @@ class box_graph_invoices_permonth extends ModeleBoxes '; $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 9be3a986fa9..f9e2d3ccc25 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -237,7 +237,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes '; $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 5ea1bb9f764..244bd7d7083 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -236,7 +236,7 @@ class box_graph_orders_permonth extends ModeleBoxes '; $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index fba42b42eba..3ceb04b7d4c 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -235,7 +235,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes '; $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 7bcc85aa47f..48493eeac92 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -332,7 +332,7 @@ class box_graph_product_distribution extends ModeleBoxes '; $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 150e9517c8a..f02ad99657c 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -236,7 +236,7 @@ class box_graph_propales_permonth extends ModeleBoxes '; $stringtoshow.='
'; // hideobject is to start hidden $stringtoshow.=''; - $stringtoshow.=''; + $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; $stringtoshow.=''; diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 0f5a5e35225..80264796186 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -121,7 +121,7 @@ class box_task extends ModeleBoxes $boxcontent.= '
'."\n"; $boxcontent.= '
'."\n"; $boxcontent.= 'boxcode.'">'."\n"; - $boxcontent.= ''."\n"; + $boxcontent.= ''."\n"; $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); $boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue); $boxcontent.= ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f044d5fac3d..11c6e4899b5 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -185,7 +185,7 @@ class Form $ret .= "\n"; $ret .= ''; $ret .= ''; - $ret .= ''; + $ret .= ''; $ret .= ''; if (empty($notabletag)) $ret .= ''; if (empty($notabletag)) $ret .= '
'; @@ -825,7 +825,7 @@ class Form { $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; } $out .= ''; - print ''; + print ''; $this->selectShippingMethod($selected, $htmlname, '', $addempty); print ''; print ''; @@ -3918,7 +3918,7 @@ class Form if ($htmlname != "none") { print '
'; print ''; - print ''; + print ''; $nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty); if ($nbaccountfound > 0) print ''; print '
'; @@ -4256,7 +4256,7 @@ class Form closeOnEscape: false, buttons: { "'.dol_escape_js($langs->transnoentities("Yes")).'": function() { - var options = "&token='.urlencode($_SESSION['newtoken']).'"; + var options = "&token='.urlencode(newToken()).'"; var inputok = '.json_encode($inputok).'; var pageyes = "'.dol_escape_js(!empty($pageyes) ? $pageyes : '').'"; if (inputok.length>0) { @@ -4275,7 +4275,7 @@ class Form $(this).dialog("close"); }, "'.dol_escape_js($langs->transnoentities("No")).'": function() { - var options = "&token='.urlencode($_SESSION['newtoken']).'"; + var options = "&token='.urlencode(newToken()).'"; var inputko = '.json_encode($inputko).'; var pageno="'.dol_escape_js(!empty($pageno) ? $pageno : '').'"; if (inputko.length>0) { @@ -4314,7 +4314,7 @@ class Form if (empty($disableformtag)) $formconfirm .= '
'."\n"; $formconfirm .= ''."\n"; - $formconfirm .= ''."\n"; + $formconfirm .= ''."\n"; $formconfirm .= ''."\n"; @@ -4382,7 +4382,7 @@ class Form $out .= "\n"; $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1); $out .= ''; $out .= ''; @@ -4428,7 +4428,7 @@ class Form { print ''; print ''; - print ''; + print ''; $this->select_conditions_paiements($selected, $htmlname, -1, $addempty); print ''; print ''; @@ -4463,7 +4463,7 @@ class Form { print ''; print ''; - print ''; + print ''; $this->selectAvailabilityDelay($selected, $htmlname, -1, $addempty); print ''; print ''; @@ -4497,7 +4497,7 @@ class Form { print ''; print ''; - print ''; + print ''; $this->selectInputReason($selected, $htmlname, -1, $addempty); print ''; print ''; @@ -4545,7 +4545,7 @@ class Form { $ret .= ''; $ret .= ''; - $ret .= ''; + $ret .= ''; $ret .= '
'; $ret .= '
'; $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0); @@ -4584,7 +4584,7 @@ class Form { print ''; print ''; - print ''; + print ''; print $this->select_dolusers($selected, $htmlname, 1, $exclude, 0, $include); print ''; print ''; @@ -4624,7 +4624,7 @@ class Form { print '
'; print ''; - print ''; + print ''; $this->select_types_paiements($selected, $htmlname, $filtertype, 0, $addempty, 0, 0, $active); print ''; print '
'; @@ -4658,7 +4658,7 @@ class Form { print '
'; print ''; - print ''; + print ''; print $this->selectMultiCurrency($selected, $htmlname, 0); print ''; print '
'; @@ -4689,7 +4689,7 @@ class Form { print '
'; print ''; - print ''; + print ''; print ' '; print ''; - print ''; + print ''; print '
'; if (!empty($discount_type)) { if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) @@ -4829,7 +4829,7 @@ class Form { print ''; print ''; - print ''; + print ''; print ''; print ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; $num = $this->select_contacts($societe->id, $selected, $htmlname); @@ -4881,7 +4881,7 @@ class Form { $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events); $out .= ''; $out .= ''; @@ -6940,7 +6940,7 @@ class Form print '
'; print '
'; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 64b84a8d9f9..5298a57eb25 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -90,7 +90,7 @@ class FormBarCode if (!empty($conf->use_javascript_ajax)) { $select_encoder = ''; - $select_encoder.= ''; + $select_encoder.= ''; $select_encoder.= ''; $select_encoder.= ''; } @@ -213,7 +213,7 @@ class FormBarCode $out = ''; if ($htmlname != "none") { $out .= ''; - $out .= ''; + $out .= ''; $out .= ''; $out .= '
'; $out .= '
'; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 759b7cc4c0d..a08694560ec 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -135,7 +135,7 @@ class FormCompany extends Form print ''; print ''; - print ''; + print ''; dol_syslog(get_class($this).'::form_prospect_level', LOG_DEBUG); $sql = "SELECT code, label"; diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index 6740ecb7bbf..fde88fd1499 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -183,7 +183,7 @@ class FormContract print "\n"; print ''; print ''; - print ''; + print ''; $this->select_contract($socid, $selected, $htmlname, $maxlength, $showempty); print ''; print ''; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 8c4db3dc373..55b8f5666b2 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -118,7 +118,7 @@ class FormFile if (empty($usewithoutform)) // Try to avoid this and set instead the form by the caller. { $out .= '
'; - $out .= ''; + $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -232,7 +232,7 @@ class FormFile if (empty($usewithoutform)) { $out .= ''."\n"; - $out .= ''."\n"; + $out .= ''."\n"; $out .= ''."\n"; $out .= ''."\n"; } @@ -707,7 +707,7 @@ class FormFile if ($conf->browser->layout == 'phone') $urlsource .= '#'.$forname.'_form'; // So we switch to form after a generation if (empty($noform)) $out .= ''; $out .= ''; - $out .= ''; + $out .= ''; $out .= load_fiche_titre($titletoshow, '', ''); $out .= '
'; @@ -1178,7 +1178,7 @@ class FormFile if (GETPOST('action', 'aZ09') == 'editfile' && $permtoeditline) { print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -1496,7 +1496,7 @@ class FormFile if (!empty($addfilterfields)) { print ''; - print ''; + print ''; print ''; } @@ -1790,7 +1790,7 @@ class FormFile print load_fiche_titre($langs->trans("LinkedFiles")); print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 66f05010662..d1c0dedc16e 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -410,7 +410,7 @@ class FormMail extends Form $out.= ''; $out.= ''; - $out.= ''; + $out.= ''; $out.= ''; } if (! empty($this->withfrom)) diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 3b949814691..fc30f0798b3 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -135,7 +135,7 @@ function limitChars(textarea, limit, infodiv) if ($showform) print "param["returnurl"]."\">\n"; - print ''; + print ''; foreach ($this->param as $key=>$value) { print "\n"; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index e29b817b0b7..3ffa2d7d5de 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -153,7 +153,7 @@ class FormTicket if ($withdolfichehead) dol_fiche_head(null, 'card', '', 0, ''); print ''; - print ''; + print ''; print ''; foreach ($this->param as $key => $value) { print ''; @@ -859,7 +859,7 @@ class FormTicket '; print ''; - print ''; + print ''; print ''; print ''; foreach ($this->param as $key => $value) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9c5b92a47a0..d55d66bf563 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8473,3 +8473,12 @@ function isAFileWithExecutableContent($filename) } return false; } + +/** + * Return new session token + * + * @return string + */ +function newToken(){ + return $_SESSION['newtoken']; +} 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 c90eca21ae4..f052d6a55f8 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 @@ -119,7 +119,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $texte = $this->description.".
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 80589d70253..62634ec07b8 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -66,7 +66,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; 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 f1324605874..54fd4ebff57 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 @@ -118,7 +118,7 @@ class doc_generic_contract_odt extends ModelePDFContract $texte = $this->description.".
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 0df16f3cad6..e441cc81365 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -73,7 +73,7 @@ class mod_contract_magre extends ModelNumRefContracts $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; 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 3d1b4f998e2..c2fec907775 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 @@ -117,7 +117,7 @@ class doc_generic_product_odt extends ModelePDFProduct $texte = $this->description.".
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 10ab060d26e..cb6a8411543 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -103,7 +103,7 @@ class mod_codeproduct_elephant extends ModeleProductCode $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; 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 9029fc82dfc..938d58a4065 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 @@ -390,7 +390,7 @@ class doc_generic_project_odt extends ModelePDFProjects $texte = $this->description.".
\n"; $texte .= ''; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; $texte .= '
'; diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 342eaa26320..4219d8100cb 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -70,7 +70,7 @@ class mod_project_universal extends ModeleNumRefProjects $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; 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 78e8312b0bb..98158e4cf05 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 @@ -350,7 +350,7 @@ class doc_generic_task_odt extends ModelePDFTask $texte = $this->description.".
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 018a10c80a2..2740f522ff2 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -70,7 +70,7 @@ class mod_task_universal extends ModeleNumRefTask $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; 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 5412343941c..3404d450a9f 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 @@ -116,7 +116,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $texte = $this->description.".
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 536d94d694c..3004a15d1ba 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -72,7 +72,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; 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 2f78deefe68..59ca0a1a97e 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -101,7 +101,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc $texte = $this->description.".
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= '
'; diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 3a7d2c00613..49af977c0d1 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -96,7 +96,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 4bacb290313..a38f27997c9 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -77,7 +77,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $tooltip=''; $texte = ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index 7a1fe53a87f..bb7defa67e0 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -78,7 +78,7 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode $tooltip=''; $texte = ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index a4472d90cb8..4063111a6fb 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -139,7 +139,7 @@ $langs->load("modulebuilder"); ?attrname=" id="formeditextrafield" method="post"> - + diff --git a/htdocs/core/tpl/bloc_comment.tpl.php b/htdocs/core/tpl/bloc_comment.tpl.php index 30badf59efa..c6151cb5cd1 100644 --- a/htdocs/core/tpl/bloc_comment.tpl.php +++ b/htdocs/core/tpl/bloc_comment.tpl.php @@ -21,7 +21,7 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; print '
'; print '
'; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -99,7 +99,7 @@ if (!empty($object->comments)) if ($action === 'editcomment' && $comment->id == $idcomment) { print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 32fff114739..72a6c140ee1 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -169,7 +169,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print ''; print ''; print ''; - print ''; + print ''; print ''; print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id, $object->table_element); diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 6ea964bbc66..403c4daefe9 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -90,7 +90,7 @@ $(document).ready(function () {
'; print '
'; print $langs->trans("LDAPUsers"); @@ -786,7 +786,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; - print ''; + print ''; print ''; if (!empty($ldap_sid)) print ''; print ''; @@ -2015,7 +2015,7 @@ else if ($caneditgroup) { print ''."\n"; - print ''; + print ''; print ''; } @@ -2086,7 +2086,7 @@ else if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) { print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/user/clicktodial.php b/htdocs/user/clicktodial.php index ba56a9e8fc3..b155173c868 100644 --- a/htdocs/user/clicktodial.php +++ b/htdocs/user/clicktodial.php @@ -91,7 +91,7 @@ if ($id > 0) print ''; - print ''; + print ''; print ''; dol_fiche_head($head, 'clicktodial', $title, -1, 'user'); diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index ff0c74dad69..cd8607a764b 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -271,7 +271,7 @@ if ($action == 'create') print dol_set_focus('#nom'); print ''; - print ''; + print ''; print ''; dol_fiche_head('', '', '', 0, ''); @@ -441,7 +441,7 @@ else if ($caneditperms) { print ''."\n"; - print ''; + print ''; print ''; print ''."\n"; print ''."\n"; @@ -539,7 +539,7 @@ else if ($action == 'edit' && $caneditperms) { print ''; - print ''; + print ''; print ''; dol_fiche_head($head, 'group', $title, 0, 'group'); diff --git a/htdocs/user/group/list.php b/htdocs/user/group/list.php index 44f09dea869..5e187660a11 100644 --- a/htdocs/user/group/list.php +++ b/htdocs/user/group/list.php @@ -148,7 +148,7 @@ if ($resql) print ''."\n"; if ($optioncss != '') print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index 59e39058629..22169c99da1 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -157,7 +157,7 @@ else print ''."\n"; if ($optioncss != '') print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/user/home.php b/htdocs/user/home.php index 8840ba698c9..fbf90e44cc6 100644 --- a/htdocs/user/home.php +++ b/htdocs/user/home.php @@ -71,7 +71,7 @@ print '
'; // Search User print ''; -print ''; +print ''; print '
'.$langs->trans("NonAffectedUsers").'
'; print ''; print '
'.$langs->trans("Search").'
'; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index c082c8485c6..c73825df145 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -311,7 +311,7 @@ if ($canadduser) print ''."\n"; if ($optioncss != '') print ''; -print ''; +print ''; print ''; print ''; print ''; diff --git a/htdocs/user/note.php b/htdocs/user/note.php index 51f6740d636..cdf6f65b9a1 100644 --- a/htdocs/user/note.php +++ b/htdocs/user/note.php @@ -101,7 +101,7 @@ if ($id) print '
'; print ""; - print ''; + print ''; print '
'; print ''; diff --git a/htdocs/user/param_ihm.php b/htdocs/user/param_ihm.php index c9ddaaed4aa..22a06e352c8 100644 --- a/htdocs/user/param_ihm.php +++ b/htdocs/user/param_ihm.php @@ -190,7 +190,7 @@ $title = $langs->trans("User"); if ($action == 'edit') { print ''; - print ''; + print ''; print ''; print ''; } From bf99e8af5d2561f6f6fb0318c35c7daac2aa5f3b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 10:33:55 +0100 Subject: [PATCH 091/248] Fix phpcs --- htdocs/core/lib/pdf.lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ac139be95d6..6c2fb96e76c 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -264,7 +264,7 @@ function pdf_getHeightForLogo($logo, $url = false) * @param TCPDF $pdf PDF initialized object * @param string $htmlcontent HTML Contect * @return int Height - * @see getStringHeight + * @see getStringHeight() */ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) { @@ -1286,7 +1286,6 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromDeposit",$sourceref); // Add date of deposit if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.= ' ('.dol_print_date($discount->datec,'day','',$outputlangs).')'; - } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { From 073274072fe2982f4e18833a640897c0435d4ca8 Mon Sep 17 00:00:00 2001 From: Norbert Penel Date: Sun, 1 Dec 2019 10:47:25 +0100 Subject: [PATCH 092/248] FIX #12558 --- htdocs/contact/class/contact.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 88cc24dcb2a..ba04782eafe 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1617,7 +1617,7 @@ class Contact extends CommonObject $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id;; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); From d76608729b212dc23e85bb6c6b31f65dfbc0e68c Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 1 Dec 2019 10:50:28 +0100 Subject: [PATCH 093/248] Fix #12569 : update qty on expensereport prevented decimals --- htdocs/expensereport/card.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index e2d1b29772d..6bfbe405b40 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2076,12 +2076,12 @@ else $i = 0;$total = 0; print ''; - print ''; - //print ''; - print ''; + print ''; + //print ''; + print ''; if (! empty($conf->projet->enabled)) print ''; if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -2106,16 +2106,16 @@ else { print ''; - print ''; - /*print '';*/ - print ''; + print ''; if (! empty($conf->projet->enabled)) { print ''; - print ''; + print ''; // Select date print ''; if ($action != 'editline') @@ -2224,7 +2226,7 @@ else print ''; } - print ''; + print ''; foreach ($tab as $key => $val) { print ''; + print ''; foreach ($tab as $key => $val) { print ''; if (! $i) $totalarray['nbfield']++; - print''."\n"; + print ''."\n"; if (! $i) $totalarray['nbfield']++; // Extra fields From a6408ce9b66e2612df65c85a8d4015e0d30fd066 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 13:05:22 +0100 Subject: [PATCH 097/248] Typo --- htdocs/langs/en_US/opensurvey.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/opensurvey.lang b/htdocs/langs/en_US/opensurvey.lang index c4554a7a76c..7d26151fa16 100644 --- a/htdocs/langs/en_US/opensurvey.lang +++ b/htdocs/langs/en_US/opensurvey.lang @@ -1,7 +1,7 @@ # Dolibarr language file - Source file is en_US - opensurvey Survey=Poll Surveys=Polls -OrganizeYourMeetingEasily=Organize your meetings and polls easily. First select type of poll... +OrganizeYourMeetingEasily=Organize your meetings and polls easily. First select the type of poll... NewSurvey=New poll OpenSurveyArea=Polls area AddACommentForPoll=You can add a comment into poll... From 41b5e82d48f670096c05758203e2b1f7bb5db343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 16:42:18 +0100 Subject: [PATCH 098/248] The variable $error seems to be never defined --- htdocs/core/class/notify.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 8c86631fc17..535d5bef3cd 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -341,6 +341,7 @@ class Notify $object_type = ''; $link = ''; $num = 0; + $error = 0; $oldref=(empty($object->oldref)?$object->ref:$object->oldref); $newref=(empty($object->newref)?$object->ref:$object->newref); From b1a8e39e7f7fafc1f081997b866197e76fc30b91 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 1 Dec 2019 17:45:01 +0100 Subject: [PATCH 099/248] Add product line label --- htdocs/bom/tpl/objectline_view.tpl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index f2c78827b2d..16d7d427c75 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -72,6 +72,7 @@ $coldisplay++; $tmpproduct = new Product($object->db); $tmpproduct->fetch($line->fk_product); print $tmpproduct->getNomUrl(1); +print ' - '.$tmpproduct->label; print ''; print '
'.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('LineNb').''.$langs->trans('Piece').''.$langs->trans('Date').''.$langs->trans('Project').''.$langs->trans('CarCategory').''.$langs->trans('Type').''.$langs->trans('Type').''.$langs->trans('Description').''.$langs->trans('VAT').''.$langs->trans('PriceUTTC').'
'; + print ''; print $numline; print ''; + /*print ''; print img_picto($langs->trans("Document"), "object_generic"); print ' '.$piece_comptable.''; print ''.dol_print_date($db->jdate($line->date), 'day').''.dol_print_date($db->jdate($line->date), 'day').''; @@ -2170,7 +2170,9 @@ else { print '
'; + print $numline; + print ''; @@ -2215,7 +2217,7 @@ else // Quantity print ''; - print ''; + print ''; print ''.$langs->trans('AmountTTC').''; + print ''; print ''; print ''; print '
'; From 5882f7eb45c8b1ff964ead4e205e13b76dbf7b8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 12:12:01 +0100 Subject: [PATCH 094/248] Remove not required setup --- htdocs/datapolicy/admin/setup.php | 66 +++++++++---------------------- 1 file changed, 19 insertions(+), 47 deletions(-) diff --git a/htdocs/datapolicy/admin/setup.php b/htdocs/datapolicy/admin/setup.php index ce6aa1eb4fa..34c4980598d 100644 --- a/htdocs/datapolicy/admin/setup.php +++ b/htdocs/datapolicy/admin/setup.php @@ -39,19 +39,29 @@ if (!$user->admin) accessforbidden(); $action = GETPOST('action', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); -$arrayofparameters = array( +$arrayofparameters = array(); +$arrayofparameters['ThirdParty'] = array( 'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200'), 'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200'), 'DATAPOLICY_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200'), 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'), 'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200'), - 'DATAPOLICY_ADHERENT'=>array('css'=>'minwidth200'), ); +if (! empty($conf->global->DATAPOLICY_USE_SPECIFIC_DELAY_FOR_CONTACT)) { + $arrayofparameters['Contact'] = array( + 'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200'), + 'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200'), + 'DATAPOLICY_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200'), + 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'), + 'DATAPOLICY_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200'), + ); +} +if (! empty($conf->adherent->enabled)) { + $arrayofparameters['Member'] = array( + 'DATAPOLICY_ADHERENT'=>array('css'=>'minwidth200'), + ); +} + /* @@ -60,44 +70,6 @@ $arrayofparameters = array( include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -// if (DOL_VERSION < '7' && $action == 'update') { -// foreach ($arrayofparameters as $k => $v) { -// $res = dolibarr_set_const($db, $k, GETPOST($k), 'chaine', 0, '', $conf->entity); -// if (! $res > 0) $error++; -// } -// if (! $error) -// { -// $db->commit(); -// if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); -// } -// else -// { -// $db->rollback(); -// if (empty($nomessageinsetmoduleoptions)) setEventMessages($langs->trans("SetupNotSaved"), null, 'errors'); -// } -// } - - -$arrayofparameters = array( - 'ThirdParty' => array( - 'DATAPOLICY_TIERS_CLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_TIERS_PROSPECT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_TIERS_PROSPECT_CLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_TIERS_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_TIERS_FOURNISSEUR'=>array('css'=>'minwidth200'), - ), - 'Contact' => array( - 'DATAPOLICY_CONTACT_CLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_PROSPECT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_PROSPECT_CLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_NIPROSPECT_NICLIENT'=>array('css'=>'minwidth200'), - 'DATAPOLICY_CONTACT_FOURNISSEUR'=>array('css'=>'minwidth200'), - ), - 'Member' => array( - 'DATAPOLICY_ADHERENT'=>array('css'=>'minwidth200'), - ) -); - $valTab = array( '' => $langs->trans('Never'), '6' => $langs->trans('NB_MONTHS', 6), @@ -143,7 +115,7 @@ if ($action == 'edit') foreach ($arrayofparameters as $title => $tab) { - print '
'.$langs->trans($title).'
'.$langs->trans($title).'
'; @@ -174,7 +146,7 @@ if ($action == 'edit') foreach ($arrayofparameters as $title => $tab) { - print '
'.$langs->trans($title).'
'.$langs->trans($title).'
'; From f378141fbdd6397ceb411b1c73e5a1e065015b95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 12:51:01 +0100 Subject: [PATCH 095/248] PHPCS --- htdocs/core/lib/functions.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index d55d66bf563..4d0d72cbcbe 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8479,6 +8479,7 @@ function isAFileWithExecutableContent($filename) * * @return string */ -function newToken(){ +function newToken() +{ return $_SESSION['newtoken']; } From b8ffafc60337143c7b718412e476ed9e2206d532 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 13:04:14 +0100 Subject: [PATCH 096/248] Look and feel v11 --- .../class/opensurveysondage.class.php | 51 +++++++------------ htdocs/opensurvey/list.php | 2 +- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index b1cdeac1f36..1b6d35e65a3 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -646,42 +646,25 @@ class Opensurveysondage extends CommonObject // phpcs:enable global $langs, $conf; - //print 'x'.$status.'-'.$billed; - if ($mode == 0) + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { - if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); - elseif ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); - elseif ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Opened'); + $this->labelStatus[self::STATUS_CLOSED] = $langs->trans('Closed'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Opened'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->trans('Closed'); } - elseif ($mode == 1) - { - if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); - elseif ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); - elseif ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); - } - elseif ($mode == 2) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1').' '.$langs->trans('Opened'); - elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); - } - elseif ($mode == 3) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1'); - elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6'); - } - elseif ($mode == 4) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext, 'statut1').' '.$langs->trans('Opened'); - elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); - } - elseif ($mode == 5) - { - if ($status==self::STATUS_DRAFT) return ''.$langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - elseif ($status==self::STATUS_VALIDATED) return ''.$langs->trans('Opened').' '.img_picto($langs->trans('Opened'), 'statut1'); - elseif ($status==self::STATUS_CLOSED) return ''.$langs->trans('Closed').' '.img_picto($langs->trans('Closed'), 'statut6'); + + $statusType = 'status'.$status; + if ($status == self::STATUS_VALIDATED) { + if (0) $statusType = 'status1'; + else $statusType = 'status4'; } + if ($status == self::STATUS_CLOSED) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } } diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 6f5fd824b06..a1d218e4e3c 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -413,7 +413,7 @@ while ($i < min($num, $limit)) print ''.$opensurvey_static->getLibStatut(5).''.$opensurvey_static->getLibStatut(5).''; $coldisplay++; From 83f7f3a6e9a0a4900dc27549e263c83f5c4ac067 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 18:16:51 +0100 Subject: [PATCH 100/248] Trans --- htdocs/adherents/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index e19afe70e13..00db45c36b8 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -43,7 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page -$langs->loadLangs(array("companies", "bills", "members", "users", "other")); +$langs->loadLangs(array("companies", "bills", "members", "users", "other", "paypal")); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); From 83928b4708108c921b212d65edd141f92428b203 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 1 Dec 2019 17:58:58 +0100 Subject: [PATCH 101/248] Fix duration must be double(24,8) to store seconds --- htdocs/bom/class/bom.class.php | 2 +- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 +- htdocs/install/mysql/tables/llx_bom_bom.sql | 4 ++-- htdocs/install/mysql/tables/llx_bom_bomline.sql | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 8b62277617f..85d5de2e322 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1051,7 +1051,7 @@ class BOMLine extends CommonObjectLine 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), - //'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), + //'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index d9ea8c01a62..340b3720dd7 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -78,7 +78,7 @@ ALTER TABLE llx_rights_def ADD COLUMN family_position INTEGER NOT NULL DEFAULT 0 UPDATE llx_rights_def SET subperms = 'write' WHERE perms = 'fiscalyear' AND module = 'accounting' AND subperms IS NULL; -ALTER TABLE llx_bom_bom ADD COLUMN duration double(8,4) DEFAULT NULL; +ALTER TABLE llx_bom_bom ADD COLUMN duration double(24,8) DEFAULT NULL; ALTER TABLE llx_bom_bom ADD COLUMN fk_warehouse integer; ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0; ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_bom_bom.sql b/htdocs/install/mysql/tables/llx_bom_bom.sql index cc35af666d3..d61b404806d 100644 --- a/htdocs/install/mysql/tables/llx_bom_bom.sql +++ b/htdocs/install/mysql/tables/llx_bom_bom.sql @@ -26,8 +26,8 @@ CREATE TABLE llx_bom_bom( note_private text, fk_warehouse integer, qty double(24,8), - efficiency double(8,4) DEFAULT 1, - duration double(8,4) DEFAULT NULL, + efficiency double(24,8) DEFAULT 1, + duration double(24,8) DEFAULT NULL, date_creation datetime NOT NULL, date_valid datetime, tms timestamp, diff --git a/htdocs/install/mysql/tables/llx_bom_bomline.sql b/htdocs/install/mysql/tables/llx_bom_bomline.sql index 3fa1c2be528..e7eae15fc15 100644 --- a/htdocs/install/mysql/tables/llx_bom_bomline.sql +++ b/htdocs/install/mysql/tables/llx_bom_bomline.sql @@ -24,7 +24,7 @@ CREATE TABLE llx_bom_bomline( qty double(24,8) NOT NULL, qty_frozen smallint DEFAULT 0, disable_stock_change smallint DEFAULT 0, - efficiency double(8,4) NOT NULL DEFAULT 1, + efficiency double(24,8) NOT NULL DEFAULT 1, position integer NOT NULL DEFAULT 0 -- END MODULEBUILDER FIELDS ) ENGINE=innodb; From fc2fc81bb0022e37e6d1af4c19da8c86f9fb7a96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 18:22:08 +0100 Subject: [PATCH 102/248] Fix image --- .../{POS-CAR => POS-CARROT}/FR-CAR-Carrot.jpg | Bin .../thumbs/FR-CAR-Carrot_mini.jpg | Bin .../thumbs/FR-CAR-Carrot_small.jpg | Bin 3 files changed, 0 insertions(+), 0 deletions(-) rename dev/initdemo/documents_demo/produit/{POS-CAR => POS-CARROT}/FR-CAR-Carrot.jpg (100%) rename dev/initdemo/documents_demo/produit/{POS-CAR => POS-CARROT}/thumbs/FR-CAR-Carrot_mini.jpg (100%) rename dev/initdemo/documents_demo/produit/{POS-CAR => POS-CARROT}/thumbs/FR-CAR-Carrot_small.jpg (100%) diff --git a/dev/initdemo/documents_demo/produit/POS-CAR/FR-CAR-Carrot.jpg b/dev/initdemo/documents_demo/produit/POS-CARROT/FR-CAR-Carrot.jpg similarity index 100% rename from dev/initdemo/documents_demo/produit/POS-CAR/FR-CAR-Carrot.jpg rename to dev/initdemo/documents_demo/produit/POS-CARROT/FR-CAR-Carrot.jpg diff --git a/dev/initdemo/documents_demo/produit/POS-CAR/thumbs/FR-CAR-Carrot_mini.jpg b/dev/initdemo/documents_demo/produit/POS-CARROT/thumbs/FR-CAR-Carrot_mini.jpg similarity index 100% rename from dev/initdemo/documents_demo/produit/POS-CAR/thumbs/FR-CAR-Carrot_mini.jpg rename to dev/initdemo/documents_demo/produit/POS-CARROT/thumbs/FR-CAR-Carrot_mini.jpg diff --git a/dev/initdemo/documents_demo/produit/POS-CAR/thumbs/FR-CAR-Carrot_small.jpg b/dev/initdemo/documents_demo/produit/POS-CARROT/thumbs/FR-CAR-Carrot_small.jpg similarity index 100% rename from dev/initdemo/documents_demo/produit/POS-CAR/thumbs/FR-CAR-Carrot_small.jpg rename to dev/initdemo/documents_demo/produit/POS-CARROT/thumbs/FR-CAR-Carrot_small.jpg From 3227f12a6ee8b8ef57ced438cfee1b3b05017193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 18:27:06 +0100 Subject: [PATCH 103/248] The variable $arraylist seems to be defined... The variable $arraylist seems to be defined by a foreach iteration. Are you sure the iterator is never empty, otherwise this variable is not defined? --- htdocs/core/class/html.form.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 11c6e4899b5..ef074c6466a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -228,6 +228,7 @@ class Form elseif (preg_match('/^select;/', $typeofdata)) { $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata)); + $arraylist = array(); foreach ($arraydata as $val) { $tmp = explode(':', $val); @@ -265,6 +266,7 @@ class Form elseif (preg_match('/^select;/', $typeofdata)) { $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata)); + $arraylist = array(); foreach ($arraydata as $val) { $tmp = explode(':', $val); From 97541587566c5d6509bad44854674152248176ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 18:33:57 +0100 Subject: [PATCH 104/248] Fix avoid duplicate product when searching on product with n categories --- htdocs/takepos/ajax/ajax.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index c6b9f309293..7e3049f9f6e 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -43,7 +43,7 @@ $id = GETPOST('id', 'int'); * View */ -if ($action == "getProducts") { +if ($action == 'getProducts') { $object = new Categorie($db); $result = $object->fetch($category); if ($result > 0) @@ -65,7 +65,7 @@ if ($action == "getProducts") { echo 'Failed to load category with id='.$category; } } -elseif ($action == "search" && $term != '') { +elseif ($action == 'search' && $term != '') { // Define $filteroncategids, the filter on category ID if there is a Root category defined. $filteroncategids = ''; if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { // A root category is defined, we must filter on products inside this category tree @@ -81,10 +81,10 @@ elseif ($action == "search" && $term != '') { } $sql = 'SELECT rowid, ref, label, tosell, tobuy FROM '.MAIN_DB_PREFIX.'product as p'; - if ($filteroncategids) { - $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product = p.rowid AND cp.fk_categorie IN ('.$filteroncategids.')'; - } $sql .= ' WHERE entity IN ('.getEntity('product').')'; + if ($filteroncategids) { + $sql.= ' AND rowid IN (SELECT DISTINCT fk_product FROM '.MAIN_DB_PREFIX.'categorie_product WHERE fk_categorie IN ('.$filteroncategids.'))'; + } $sql .= ' AND tosell = 1'; $sql .= natural_search(array('ref', 'label', 'barcode'), $term); $resql = $db->query($sql); From 1d0900445bd40f81be36090960451fb86481aa14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 18:52:50 +0100 Subject: [PATCH 105/248] The variable $letter does not seem... The variable $letter does not seem to be defined for all execution paths --- htdocs/core/modules/export/export_excel.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 9d89d53de2a..43cb4d6e9cd 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -510,6 +510,7 @@ class ExportExcel extends ModeleExports { $c = intval($c); + $letter = ''; if ($c <= 0) { return ''; } From 590d2cda17def1dce3328d867077d3e206dc9142 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 18:56:34 +0100 Subject: [PATCH 106/248] Complete #12556 --- dev/dolibarr_changes.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 0ace2d856df..51eeef8af31 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -67,6 +67,21 @@ with } } +* In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace + + if (strpos($filename, '://') === false) { + +with + + if (strpos($filename, '//') === 0) + { + // Share folder on a (windows) server + // e.g.: "//[MyServerName]/[MySharedFolder]/" + // + // nothing to change + } + elseif (strpos($filename, '://') === false) + * To avoid to have QRcode changed because generated with a random mask, replace define('QR_FIND_FROM_RANDOM', 2); with From 5cb014435b34f91ab58568ae48d95281eef52f1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Dec 2019 19:29:53 +0100 Subject: [PATCH 107/248] Try better fix for #12567 --- .../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 e688b7c9dae..a5e8530d4bb 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -825,7 +825,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } // Escompte - if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) + if ($object->close_code == FactureFournisseur::CLOSECODE_DISCOUNTVAT) { $index++; $pdf->SetFillColor(255, 255, 255); From 97b1bf0ea131b54b3f8a607247ac73e03c4ff377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:05:48 +0100 Subject: [PATCH 108/248] The variable $error seems to be never defined --- htdocs/ticket/class/ticket.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index c1acd22f3e0..cf1e2502676 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1368,6 +1368,8 @@ class Ticket extends CommonObject { global $conf, $langs; + $error = 0; + if ($this->statut != self::STATUS_CANCELED) { // no closed $this->db->begin(); @@ -1420,6 +1422,7 @@ class Ticket extends CommonObject { global $conf, $langs; + $error = 0; $this->db->begin(); $this->oldcopy = dol_clone($this); From 36bb4eece9cedc71e0f17578d84a1f161f72c48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:34:05 +0100 Subject: [PATCH 109/248] $key is overwriting a variable from outer foreach loop --- scripts/bank/export-bank-receipts.php | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/bank/export-bank-receipts.php b/scripts/bank/export-bank-receipts.php index 8b6ab1d60e1..45c6969d4de 100755 --- a/scripts/bank/export-bank-receipts.php +++ b/scripts/bank/export-bank-receipts.php @@ -253,10 +253,11 @@ if ($resql) { $paymentstatic->fetch($links[$key]['url_id']); $tmparray = $paymentstatic->getBillsArray(''); if (is_array($tmparray)) { - foreach ($tmparray as $key => $val) { - $invoicestatic->fetch($val); - if ($accountelem) + foreach ($tmparray as $tmpkey => $tmpval) { + $invoicestatic->fetch($tmpval); + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $invoicestatic->ref; } } @@ -264,28 +265,32 @@ if ($resql) { $paymentsupplierstatic->fetch($links[$key]['url_id']); $tmparray = $paymentsupplierstatic->getBillsArray(''); if (is_array($tmparray)) { - foreach ($tmparray as $key => $val) { - $invoicesupplierstatic->fetch($val); - if ($accountelem) + foreach ($tmparray as $tmpkey => $tmpval) { + $invoicesupplierstatic->fetch($tmpval); + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $invoicesupplierstatic->ref; } } } elseif ($links[$key]['type'] == 'payment_sc') { $paymentsocialcontributionstatic->fetch($links[$key]['url_id']); - if ($accountelem) + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $langs->transnoentitiesnoconv("SocialContribution") . ' ' . $paymentsocialcontributionstatic->ref; } elseif ($links[$key]['type'] == 'payment_vat') { $paymentvatstatic->fetch($links[$key]['url_id']); - if ($accountelem) + if ($accountelem) { $accountelem .= ', '; + } $accountelem .= $langs->transnoentitiesnoconv("VATPayments") . ' ' . $paymentvatstatic->ref; } elseif ($links[$key]['type'] == 'banktransfert') { $comment = $outputlangs->transnoentitiesnoconv("Transfer"); if ($objp->amount > 0) { - if ($comment) + if ($comment) { $comment .= ' '; + } $banklinestatic->fetch($links[$key]['url_id']); $bankstatic->id = $banklinestatic->fk_account; $bankstatic->label = $banklinestatic->bank_account_label; @@ -297,8 +302,9 @@ if ($resql) { $comment .= $bankstatic->getNomUrl(1, ''); $comment .= ')'; } else { - if ($comment) + if ($comment) { $comment .= ' '; + } $bankstatic->id = $objp->bankid; $bankstatic->label = $objp->bankref; $comment .= ' (' . $langs->transnoentitiesnoconv("from") . ' '; @@ -311,13 +317,15 @@ if ($resql) { $comment .= ')'; } } elseif ($links[$key]['type'] == 'company') { - if ($thirdparty) + if ($thirdparty) { $thirdparty .= ', '; + } $thirdparty .= dol_trunc($links[$key]['label'], 24); $newline = 0; } elseif ($links[$key]['type'] == 'member') { - if ($thirdparty) + if ($thirdparty) { $accountelem .= ', '; + } $thirdparty .= $links[$key]['label']; $newline = 0; } From 454d79db586f7cd3800b71401456cdbbcb2a3f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:44:13 +0100 Subject: [PATCH 110/248] The variable xxx does not seem to be defined for all exec paths --- htdocs/core/class/discount.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 6b5ba21be7b..d89db86aa10 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -689,6 +689,11 @@ class DiscountAbsolute global $langs; $result=''; + $link = ''; + $linkend = ''; + $label = ''; + $picto = ''; + $ref = ''; if ($option == 'invoice') { $facid=! empty($this->discount_type)?$this->fk_invoice_supplier_source:$this->fk_facture_source; From c780838e34ec7cdf9a48e47a4fba60ee43b9dbe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:50:18 +0100 Subject: [PATCH 111/248] The property db does not exist on mod_propale_saphir --- htdocs/core/modules/propale/mod_propale_saphir.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 3004a15d1ba..049c80f595e 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -64,11 +64,11 @@ class mod_propale_saphir extends ModeleNumRefPropales */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; @@ -77,7 +77,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $texte.= ''; $texte.= ''; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); $tooltip.=$langs->trans("GenericMaskCodes2"); $tooltip.=$langs->trans("GenericMaskCodes3"); $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); From 318ba895e5a626cb02ab5b88d09b12895b4b9bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:55:22 +0100 Subject: [PATCH 112/248] The property db does not exist on mod_reception_moonstone --- .../core/modules/reception/mod_reception_moonstone.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index f77b0a97ce1..b3075d67bca 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2018 Quentin Vial-Gouteyron + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; */ class mod_reception_moonstone extends ModelNumRefReception { - public $version='dolibarr'; + public $version = 'dolibarr'; public $error = ''; public $nom = 'Moonstone'; @@ -40,11 +41,11 @@ class mod_reception_moonstone extends ModelNumRefReception */ public function info() { - global $conf,$langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; From 5d9901bf594e75558d785aaed0755f24b6fc51ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:57:14 +0100 Subject: [PATCH 113/248] The property db does not exist on mod_supplier_proposal_saphir --- .../supplier_proposal/mod_supplier_proposal_saphir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index 65935ea9a60..a2b76da03e4 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -64,11 +64,11 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte.= ''; From 0b37d54841435d68cddfe035a6b056743baeabf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Dec 2019 20:58:45 +0100 Subject: [PATCH 114/248] The property db does not exist on mod_livraison_saphir --- htdocs/core/modules/livraison/mod_livraison_saphir.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 286a5e7c52c..bd6fa731294 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -62,11 +62,11 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder */ public function info() { - global $conf, $langs; + global $conf, $langs, $db; $langs->load("bills"); - $form = new Form($this->db); + $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; $texte .= ''; From 7908e0cd266401f96aafde4d653884ac007cca0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Dec 2019 08:46:59 +0100 Subject: [PATCH 115/248] Fix crop for MO --- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/photos_resize.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 55b8f5666b2..3b2a7fcb872 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1099,7 +1099,7 @@ class FormFile if ($disablecrop == -1) { $disablecrop = 1; - if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; + if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; } // Define relative path used to store the file diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 181bd1d84f1..eeff5007c55 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -210,6 +210,17 @@ elseif ($modulepart == 'bom') $dir = $conf->$modulepart->dir_output; // By default } } +elseif ($modulepart == 'mrp') +{ + require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; + $object = new MO($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db, 'Failed to load object'); + $dir = $conf->$modulepart->dir_output; // By default + } +} elseif ($modulepart == 'bank') { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -222,7 +233,7 @@ elseif ($modulepart == 'bank') } } else { - print 'Action crop for modulepart = '.$modulepart.' is not supported yet.'; + print 'Action crop for modulepart = '.$modulepart.' is not supported yet by photos_resize.php.'; } if (empty($backtourl)) @@ -237,6 +248,7 @@ if (empty($backtourl)) elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('user'))) $backtourl = DOL_URL_ROOT."/user/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('bank'))) $backtourl = DOL_URL_ROOT."/compta/bank/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + elseif (in_array($modulepart, array('mrp'))) $backtourl = DOL_URL_ROOT."/mrp/mo_document.php?id=".$id.'&file='.urldecode($_POST["file"]); else $backtourl = DOL_URL_ROOT."/".$modulepart."/".$modulepart."_document.php?id=".$id.'&file='.urldecode($_POST["file"]); } From 32a539a8c0c381815e25ca97c9eebd04043707a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Dec 2019 09:19:05 +0100 Subject: [PATCH 116/248] Update website templates --- htdocs/core/modules/modWebsite.class.php | 2 +- htdocs/website/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 52c25f2450e..dc19ce2e29b 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -189,7 +189,7 @@ class modWebsite extends DolibarrModules $src=$srcroot.'/'.$cursorfile['name']; $dest=$destroot.'/'.$cursorfile['name']; - $result=dol_copy($src, $dest, 0, 0); + $result=dol_copy($src, $dest, 0, 1); // For full zip templates, we overwrite old existing files if ($result < 0) { $langs->load("errors"); $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index dff0dd70175..ef05483d705 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2124,7 +2124,7 @@ if (!GETPOST('hide_websitemenu')) } elseif (empty($virtualurl)) { - $htmltext .= '
'.$langs->trans("VirtualHostUrlNotDefined").'

'; + //$htmltext .= '
'.$langs->trans("VirtualHostUrlNotDefined").'

'; } else { From b678100c8d44fb1d7e5be2c0b1aac3d57de33524 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Dec 2019 09:19:20 +0100 Subject: [PATCH 117/248] Update website temp --- .../websites/website_template-corporate.zip | Bin 1721251 -> 1721229 bytes .../websites/website_template-stellar.zip | Bin 114796 -> 114796 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/htdocs/install/doctemplates/websites/website_template-corporate.zip b/htdocs/install/doctemplates/websites/website_template-corporate.zip index d2d46226b196fa975cf3629df92cf44819052267..a9773ce496bcfcc711ffd015051fb56741f66a38 100644 GIT binary patch delta 12780 zcmZv@1zc3^^FF+Qboa8PNOwxNf`D|VfP}PkvmgRW_Ywlq-6bW`-3Zbk-Q5W9vhsZX zzvubB`{CwXJLj62Yvw+C*o7f0*fKoW5>r_o;Rzbx;bCR`AsUk!;o-o=06Q3PKO8Dz zli?nYRUGga@DCuC39$=iI6*Xnoe9uGuG2$?)7pQqLTb+7`mmrti9_p+W+5>EFijkt zMp0LE4%bHfK&X3<1+R$*L%me+bI351&j4>h4D;dw;Yi@Y0RXSzAG&fV004$Aw&)B}$Px<(84}6@ z!mi7Bg%v>tBdz~-QV*8}0IHyi<&i{CXK#iDk%fgrEyF^@h9TVVSl@(UXy6(v3>Aj- zo?zc{!H_N=_9iY2y_Cg{L4cu|*VtHe4=8xY5xZ{35vQySW>2NYt;>TUtv=inmInk; zxWK)GnG`Q^8~!FlN5RW*hS|!z@tPeTP_X?zUY-3uK0G7L?o3Re4eM*&Fpz*P=fPI{ zoxl&49TLz=0BdHQavQ-7Z0Ca&I|=F(I|=s(Vcue~L|1>QLJ%U_2NUEigoxt-1Sdd< z>JlKt(O+RqCVn6m9wyYT6emZ&difjxAgOyP2VB7gPl)-n-0!EF{5qC~Y5tdKlliDr?+nWK-UB*`U)KTWA4;m~MVFVgD(hL?94 zAt&vv9cYQS5e!4Ps{Wi$Az`ZDqiKlOzu#KJ%O}Ctz361u)qJs1_(RM}Yv7kz4X0x` zV~J4ssBp@F;|rZe1x*wyK{R{02wkRu%!x3=GO%JW$~A^&9jZC|SrV{Y$yUtFeF}r( zt)4^Ws~iEBwrbw)-gkmU*+`~H-fc31HB>(XIdq@WsLj~p2V$oGfyC|02jb-0d&y?B zt!=xPOdBtUF-(tBFwilnswJNmtn+BC7uXZpu@04bPx#R?brDoGWdxy{@t=&~uJ8z{ z8i1uOqQ`nSw$hruqid|%ZSmizgXxgJB{{Y`YQO3uoq`MqmXjc;V{P17ECbD?eW}Bd z%~t4p68E&@B9{tVC5k4k4vVJP<3qhE6#@2N-lq$fdMA`hy&;2}q7TWGF)fx#XIXgJ zcj`Rx=Xg(kk7_33mTaDDLW~jZ`~3Yfog>&yqNJp9Ku#m+6}s8-R@3Ven!Y;i#0RxB0{ipvT`Uh=|77eA(>j0n%W z=viqd_n{rmVb8tP6n!c-k{l;}S~l{P`nRe?C|c(+>3X|tH|G@%gemUXN^fGr7pcMX zV_1f5B)=LQT8~lHlEse{zv0;VZjif`>U)SeYt6iiYII7}vwJpQNB7jwbP^sHw9?mn z%6?K?ZSyn`bL3QNd}l;wSi3-a{xr>nZ6&#Ja%@#P(j~3NO&)vOYOA8b(??6ItY~kc z8Ltg{wfUE+u}izqOb8mfrn?1%OokS$OM$350N}N&%|Jl++|$vu#}O}je~5irJn;%a znhv8$$GV!nhe@m(l zEsI7R{(h_*Gu$@t3)jDvM)bCX`*41vjK5qTvVV|q1aLI|K6Q6ELzEnPY$)TQ^hSH}ci|I5~&Zx=rCO~xaGi12=ouoP{D<+zk%dGKD`8wpPKt*fL?{_DyDeYBRu?f_Z zqAYaSIa56l46Weds!^I@9g7X?q`+g)tm!?KeH=%d=dS&Rb=gPTv@+-yIe2U^_@t(# z3S1e!VHHYm5E!;yUMQ%}ExJJVX@?Ho^(#wryK6B9}kDykv~Qkl^^D+do$UE;J#_P3Dz+^Hpyi{P6sN<4ONy#8YH236288I-Oi z9+Jax6f;vus=PM6(J5?q&w#qW^Ss9<5<%=Fqf!vnd_Lg5HWI=S&WYiI?(R?|smQK1 z#QS6=MhJ4wE9D>2iO`Wyx`r+DD@3}@Juxjx9=jWEzCB-bA#u#mC9H}$ogkvYkkZDi^%2g`}T?@d>N0y(N`mqcd77j)F+g@ zL!LA;_XKTdtclV@dp}n%*$x`>Tt_mgIjQ{tvD<&=YTCZZ(J_rgvn6u#I-0uWLk8|dO((Z_ z-Xf|PPCR3IsvqDBzW=;K(fT7GF_-Vxw-#1O^@_KGZTDUGrd5#L+tIDo#(*h{-Luhd zY>SH_So0F2Wc8%o{%;bwN z<0FqCQGXm*{p9S+QGMky9g#4zBS#7sBGu2g04Ic;6ril8QM39bvvWZ{Z} z$4yHlNjB$kU{};XpZ7(^wFaN?o>o%uD(5zugM#gwzMdN>LokFN`>WS2jkJ!q%0w zTTrSz^_-uS^JEBmj!?##TP0Vrb7gx$soWq269NwY&WEVa&%27a`=<~#yluAvLCPVQ zFg2u+0LYQR5ME#2{oP{S&kVq)z>2PkK z=z3s6>nre=@gEoTr-Vx5*PDAiRUoSvVrIEDUJzouMnoKjYZfM^5(PZJz>K5qRKjYWaR!qppr{0rs-Rj!!|OuDnQmHysZns zUdJk0s+2gA|IhmmIDlvQ*ZGLFJ00fn3A*SrO!nXbc)61S9;#lRhGd1g#kBJydGJlI zhYfx!wt;YN;G(VP-39nh%dy5$2&=TLg*E)-gzYprk*9Z%gC9vf(Pu(4QtbUd^7EA{ z$yJ;9^e7EZs1 z>1zj;&JNQ0Sg1PueOfKv@iRA;7Gg|>c2_56y}G0MCz5R|iT7DGzzV(r#qKjHehy*l z9~KKXCB@4oak0JYKvt&&sUD=}Q1(yO`ywArHX@nax2HZ8D-NG44PhzT!Ra?6UgGU# zGu}jM+z5vfW&t#ac%oJ0%~Uf2x`o^+UR8lp8W(@p|1)s&JSMK3^&KayTg?my$_J* zD!R{Z|mzuW2Stj=}TMTSoM2@K~M*QN2Js~(IdveDL$AkD0Rigf=$cZz{76h zSe-kr0nJ6~cKpSfZ9;>}(>yMPXH8vGFGf*T26HS<`O7ROEbAbJ@2c}bAx+;B$0cRW zQl=8p`ro}s0=sUF>kv_MeeQ@a>3mE52hWng1Za4viS+a^zC87L#UVw70S26=d#_0P z#(<*iJoCisk0wHl$apH+d~1}?&}JhrW1nnlyu5nWh2gq0U@dD<`nnpmHe`QvK2<5`h*))L}C)wbi#k~xb0g6*TCT8p?d@RFM zdH9%Ye>Ttkyx{5pJx+)jg}UUGVaG z&%?YJR$3fL#4U_DHK1WC8T>gJ}C*Es0vO3BCRQ&Eftxjri{t2rM0TtjD{a^G6!;@szVcWbWcgIh(0 z4Zf}?x)5$~ZHI_lL@-*PgHG(Yj)pYx?Rk&-Qf>hB6waSqgiiKF*5}-3n(==B{@_H+ zs#a#cXmuXXa{)Ibsup}?jke&Jnlsca_PL^c;S(Jg|KJzCyIT0Pvv^IicTum_&9dgf zq73nF&yilN`~{AZ!D!<&ZOMFPbL`lU)93Q*=XY&4Eb@yuD(3kswH~cHWFAqb=)R>Y>t8L%4#*%SdiQw^-}iSoI(hCI4xa z=nFJ3@CNJD6tg-%&hsL2I>mIW`9QuQKoCyUu#8=K1CwK?{UAW}^RNeN_v)0cx|WPD zqYF;{cVqSbm38>0B|ANjF#QxCz;g2DOH;j~OHU7{tjIU7y|ANfA$)N~N;#O}qQ3h< z>+>XRM{x`Xtw(Vb<^sgU@m3lOB=$PRy+4w{QvOvv<{I2pToQQApFheokj3)7#aurR zR9{BFdO6uVW}U`6nWOCKl9S(>a%^U9GXl^E47?-$`7G;JTPmI>vyDngjAw+4Gx=j# zg7Q1{4EL2A*QB8Dil9&m9%2BVK{EQU5*L-Inp>+Zx9y%*nIqa#-M+AT z@HLG=%!{Uepk6JBOym%bQCn->s^_;NFY)PL_rb_nUBl@wOe49r6>-M936fa)gg+5r z85n63Vri=)b2lSRWfpln0XRQ!D7xM;)C<#kaxc_ zn~ns5pITDn`^$eBGYCq$V8u8a)+2(&y3==pq)&{iJK#oHRQIN(#zSX*GPl1jE@tGL zsUAM0(e1xaa)Pw#j&wJ2;Kv!2XWDz#Ep^g2t#X;=nsG&(r#h$ze2|sVl(TKx=pd7z za~$m;rTnm)k?Qb#nKj{;kxVz1Rs;6g2!iV;BK*-q%9$&v@x}yI35*verEhe>5eZmr zM`PzWL=8kU3l({l&ev?LPihTqd>T;esUw&9aMZnd2{bXOF^9fs@{Fh@N;({waAO3cNt&NRO&pl-#A8jn<_4d zJMGXVCrQ_vFLUyn9UL;Rc_T$?fJa;pp3o#8vguL*ZA-ndhGr_heLxLmEE9INKRW>b z;lub2fAx9!UGGQ3ywe~oTckMvQYT#oXOOg%=$u|}=j}$kJ`2qs3`fo^XSWTLquo!b zVjfIY(!ee&i)~B{o|=ZdZu@NygIC$RrPbkmQ0XD z8qq+h4?7{)-ui^UxejqG{M!-M7Vr#Sgu75Kygp^v(tFko`hXIos(@}F=Sb_MhLxqe zD{}{J-GzL0d@uQ{z-R0U{tWQ6dK$@oqNJWCF{M3n9MAt;*7Ho8QHg+apFM3BJ1mmc z^#$auA9Kb0d=1vj$Xj?lU6!_zRd_BWl0P-kWzM$N2Tm>HIo?x8xif!7@y&2-VOYjp z|GtZi0ed0I{ovyMdU>f^?NhzMvBrg;Tj>SucT~!2Es|1p zz4r!Nw{}i=y}A5f_%Q-qutwb*``_OT;TX{MzCi5t7!bzk4 z)EA_4<%PH9toaR|+0>6lqS2$gnnRYD`t4RlkVi*??W*5$mo~>wF#qo0NL2>hS>av0 z2BZE>Oo(tn47H%#TJOPE8Fp6Rm-gE0ZurJQ&%3!BA*z2iW-|iueM;hGe+7IbIim{0 z!4`e@X2;tWebTpFaa?38lOPC9kWhXHt#eyKY1YZGOOAJXq!+MA)*q^FvX#MdkbuFg zwn;{E);NumY2>AV1;$M9j1XogD%WnltYp<-r{NuX@n*Iv(5_UzdHY00+_;kZfkrJchE8m7cZpc_PI3}wO_BWhEDzz&(8L`hru&2nlN_J)EL)!LQ2|Ca z-~1odtUq)*r)Iw=Gxjovi?F(rSL>tPR^i|s<)_GB6zf9>0pLsXU^+0lgQL-&)Kg{O zKG{V1L?-y}_tz^&DSxUE%x9v&y_jJ-w_Bv(EpYC>0A=?PvnBSP=Gjr2dY}w}|#kEKXcIUVp_Lar&=1o_OOypyWQgDlB zjKI_2i=!py<{+Y!0splD^N6o0HmsQ#1B<-3l+&(#Vk_YL&H8|rhP@%~l0O8j3$?S& z=dSjR1{nLIJ1%aViP?9$>gau#%tUKn8cX;>JZ5&`3U`Osk@G<(W?$p3^N`{v{rX9W zU%fgSdnUWR4)@MGo#W8CyIW6KL^|?$Sct7t^PV9>u4>Cy&eK8aL+c<4%p?kHrQ5Oo zV6z&k9JvIr?0%>$K)Rbe?yRI82&|B zuu+^Gcs-Tl-rT3&9-EU20C%(5;;pvu9|V*_$ovI_xyGDpZ)B5(T3a+_%w$7_?$F#oTroRB~dPtQY>YicWnJ z)^kWK!eijiWH?KlA91+8X>dO{x)XVTE&An5DI#JBCBNO%Hni|tph-dC>ynoT)mS>r zI+3}P>0m3{n=A~83d5QX+Xe#7e(A9AP=k8G5?$^V&uL4D_p#V?xs?h<0xd>#MEn#Q zbmi;fmD7k;S_WV$2e4zfy7!5CdtXG5r#1=j8<+W-SdsL-_a9s!|1Kun9%kkv$E3Ce zssE)TReMJoZ}cp1rGDcxlP6rie|+yX3-NF`cxvAA_wQ$_%=kn{u-3 zrM%$cl;4Hj)e&BUJ+%^gBJNrK-|yVrVqf0RmMHQC$a)snU`|xo2F*4PZbcrZauoK=WywkHsX09%5z8@4kt5(sj1%z z<$3;aJDo;pzi|$uMR6P@W8(8xohP)Ht_FjqE|By@H9Ycya%}ff9r>2tefr?y_S|^i zEp4ppRV>L_70{;K*{~*sn^90)GE=+~d)!9f1lOe^wgP9SAH=~IrZM-GQAw>nGWI%} zQSPa2J>MnD=)4U*y_Qi^O6;`N)|h6$YitS8Dgjo=WN`CORfW*Ll7vrOqq*G<+ke3P z7p&0VVeci(4_P&u)y!AU*cB-H*w^Z13bf4FIb_>>Fe~EqThoaRhj@pC$btriQMYq2 z>!eedRi9^mBzLoX%ksNtG*^x+V|$sd53a_#%Z_IkJ@=rGH%gVhfxE(oyi}`t-_4Ek zO*=U7;O&btBI~tA)va?3TR11`s96(mBDLrY1+xFnMQ!b&ud6!Q!l<;o?q)J(=$6ne z8eX$X`gChArsZ)wpFD2=9JPN< z-{0;^T!cr>QYk=Vpp3maJu+6tQ<&adUm}tviC0#XZ#u|o@!;j-9FOE3sE?Bc4^{yh z12nX+RBcicOoYM{Ow!E0+HJHOe%6T1^rWRj#b@t`nev&X&>T_p4&(4c9Lr% z*Pd1(^1L`#TI)pBC1mf*vU1A=c=S$Ns1vk0gS+!ft-pJFLAni-|Ai9SsYGqn7fkb{ z?*!~)$lrJvf~8{+eb*NqJM!HG?7YeNJ~S4g0cZpX=zY*GxD2pFMh&*zwZE*&N@+x>eSl z_?wI3n~Rqr2Kj|=%IdC2H+;cwElw_-xT#CLgDtp+FR`XhNrkY*lsr(UhI_99mUR&B zs0;#Qm9{(I4>kuYV?+-R78>gMv*YWertPJFA^$Q5|IHKqurvLuY6j15O9wE;4SZFo ziXRhtvhtg$vyUWgO+j^j(||vy>E6a1AsEv=zQgT#`&ER#y32X%Bwz{fu*Y$nS9#zE~F; zu}YfFA1^uD2xtv!nDo(p9q0KH7oa}B7BRY3>1R!o5~+l>K}k!%%1aN7UDys>`JJ|Ibb7j=F8q? z({CBZZf1;~rBw_2L0r0s<_&F?pZ!YLuf`cS`-jg+2Sx9%sah}n-(K5T%bTpd4UCV( zWp0VluGcv_(S{430w_f8q$DGRbK8}E9O<}x`(gr)L4Fnzrn8!qa92G1Ie2tK^A-I&+4&F{jS=i5s%+I@*H5 zeQ#s`91R}zei1BF^4zoF8}(o%Ih%G6&12eSVXci9-Ib$s&B4}l)!-bY&BZoke2(Y+ za#@DaZUgCU(s#xpRsIsn8Fu|760hFMDbk-{zpl^H37Nk#0&aucQ6iK{LG22Hc!;aU zTn$@2*?;m`-696S!@krOp*;M(0@A8Of&$xsQ6VC%#W2yvb3QCS_H{HAbB5cW$$ccDh|}$t`p3;P zFxsB-w!_}YO7NP+cK&Sbx8wMWNPn~0#7e{$M%_*-%kN*kY-k81=h zvgz^h)khTXCpc-c2W=D77uQqZmFpZWOBzOpJ+dNuJl#GjT>-3?sqx~-;WF@% z3mP?0it_Pt1pykCZOB6rl;5Uo$_`|I2Zu1_kJ(fcZF)bK?lw=XpFyVOV=~1^lk{(S zj}~baITw75-Lj2gCs*ZP{(W|N>RLMh^{Fb?}GYxZi~`d^cX z5Hsx|+CtlF(vtdaZdDQNg#3n2pH$>YbkD?t#N? zI7e)4BW*&-ecin#x_5DE26S2x*BLnd_+GWC0U1#`D+J2?TsJW{kkryonbi|`T%LWG z{8O{UzaMort@#8CE@;vzCzRcFqx&x^UgQD;%F+2%q2vy7=nXHvbA+qy$ z|DqDV`x~>k2)~0=Q$Yl0J+c~__-D>8iW%^kpkuxKm);E(8fv1yXUuQy!Bj^*b+29s157h45JzI!*oJ%< zFLS6e)4FBFJ-7%U;^QtFW7hK$_r49yt#j{<^zO7HDtaY%sivNTGK2it3Xar~%{wkE zEV}b-$nSpuIGPI3-+}{zF3s_%=F?MsTNdYi1~B#!SCeVQhfP8!WgGCoFJ-sdntoWm zs&O(4mg{+6;FaK4zl1K-A$oogM;oIK--jKL5>_G=#qv!%({i4KfsL#kolZ03^=5aQW`t8!M z@sKd!XG7LoifwN1Z{9epf|GVKbiG)eY|eY1Ty;w~f*Y%EF1}6gQyyze+&!~+Z?QO8VArTl=~06U=wL#lY)WjYMFSzR}C-l zuGLkyv{Cowb|ia@yhsCr4e$4Q(MXD;TG2=dR2NB2sq$_Df)Ur~-Pujk^YG}K=vha5 z&3z(8?C#m-JK5jm(NJh`EPYOR*OeARzaQ{aj?uO)ph7&&+1uIkxs&wU^=RxarUu;z zQlx1D0s_mTPM0yRMP=~!d`=X5_sk%TPS0TfAA@=+;{d$&r%xJc?G7u-jV~n<$=Cth zOZ_=^!9aGGu%qq(ZX5DL>^GjTM{M1SyG2P;28X{*Qd~$09rDh$r2ve4O1U1iS zrwW%OfKS>O8RxK(@tKW|h3pyxBo#Y9e&CX8r3p6sdg}jXriLASpL=UAUo!SCpXPeE z^2@~LOq-~Di^cYvkfoUPReTr4;}D`h!5LBr)x%}1Vuu-3(!%2Y2Q7%VPrWW{kehlD zQ2k1EVpj#k7!p&qkK4z`5q=(c5OdNFseP9)aN>MX5n1YC)fdcyN;dND17r4znsK5) z+wz*CX%2RPx&v4U{HC4z_rssrA?#1LM$?}fbL!N0Lpp3XkIujQX>1;%GN8t|-c~-;|DfesZ6DFuBy%RXAo^}k0V5<%;HP%rGOD2qmUX=MU^!|B) zkU%1JA?CcKBE+9o5*o4B6s-9Zrr<;C!ZN2K-mxQoAAnv7BF|ym$d4+zcU0n?&B2&Y z3b&L|pF}Zzmh-Z?dcDeeGeQR6(aKHrgJhLOh{PUqIYlywN1Dy0%svR8n224Rjxt(g ze!jcTG-`E)2}7UIVEp_&@DKQ3BYF^be;{lmtS-YJhzlDcgVclow_syd8KFRNWZ0M$ z*62n3&=UY49inHj!z>5Bf(?;Dv@3ucFur8vUr@(V1&oD* z&Gm&BN4=Lv1OWCiAj?omb*t4tLqr()Wy7O<&PE{0-)S`ACScBAfhDeRZg5byt_OiY z$ZH`GY8`ev5FO@PN8SSz{fi6-fh0(kQ&V5M-S41 zff;&`It*|!JbDE(fHYv1d4@+aHzPzU?*dKu% zJIENu8DoFUPRa3DyFCX;8Fs3T<1sQB=VQrEoR8!moFGLQ2bb#+m~cJ1SN;RwxgRUl z=6=*u%l)VspXaf47CazcSe$eokT?wd=6Q_6#S4=C_XH*66Yt{|HuHi=g*5zufVcK` z&c>E@W{ytm%JOjV1b~OpUX+K?UL}>YEYCR<0Du@ekqd$i{QmRJ*B^2u2*QWZJqHoO za*93&k;275bf1Ihs2*Hp({C`*kpTc^{Qq$ch4>3WU90|a?T5O;x5oSpcmuV<0xa`W zM*)xkfK06a2Iz+T4S$<|Z~0hH z#o!s_KmtSrM+tEh0MWq8P7;6yLahQqgsXt$|D)*t-9Z1VD82e`A^3uiikJnV8%Pb2 z5qvE7J@h#ORwEE1(Fo*Y{;xu_EJDb8XqhrN{|!t6ITQpj!nBbIJ#1{--$c;6@ZXKS zF-wy|h2CC}F#hX$-Tgp?&5=WjAAE%d|N8n30#W}*LX=E2(LcL}_pe>kg5U^)p2GG& z38kth6uS3)@Bje8zeu7GWns`W*#55$&F@k}PtriwzezVgA+f?BYFPVg`!48)0bI1R%sBAX-?-Vj|Gzv=BWJ&@$;DT=RcKbNx$C8Dv=m zBmpDUkL9=}Lpv1pKh3R$NQgc**H#qTpifJG87UU5&c6a#6no5{*k5@0|4-_NP>Da1c>B{R7oqPm3eo?2nN&fH#UGmxE)Km& z`wmGUe-24V{^trgr?>yC50!2VU4;KCp%!u=4x)iI!-&WJG#GlLVu5zz-!Iyi5H5+w zJcbg`GM_*^B_8i?HoTIljnIhu(Dm=;99~0yNIW)Y`@!os1WEGoVqukpsvWo`f!yDc zkp7R_-@cu|f4V~XFSTxvXh{$oOzj$%W~U|edX|G;&(Qxc_&*P8$buw@8MY}HQV%a( f6c9uL1@ymp{@;)H{}%ik@?HwWiljyR(1-sI5q)ql delta 12585 zcmZu%1yqz>x2C%#hM^^-ySuwVLQ;@UDd_=`5|C!-?(PNwLFp2ZZlojyX}H74ckliF zduMUh`<#9Des-LB&tlHnQK2?@p*EQ6O7IA1FpnQokZ&yJbNI&xCq49G#P#^7iBE-n zeAcnUUBEqpct*spP{D6R3+PIa0dkW8GOX_5qZHh54m*ei0cz~JCOV}=FfemOv67uDKn5ygpg{(D)6!QAgFUF4Pz|Oa z)T3t&CV@Q^#gJhsQ9{wO2v#5(?qlrley*N=AccVeK?ZAV4hh(i8A#ZaBaiio6uSO% z-BmkE0S2ZHGMJy%k(QC;~QcK{Rts-u|G=HTGxD*ZvPnLd2XYSmm*UHER1GllCJg z??cTp)(*(>6MG7Ca9G{q8Y(%?>I)0 zEzV9DCL0~CI%bB%wjJeQbm~S2Wd158biDh;u#Hr&g!qH9Z1P5k1TQV345(V5MD-`h zd*+4>G$(6Lvb2u}Snz>)-+tz|BP(OV4Fp{2&1#Yvk^9!asz90^I@d?FSmi>9`!Mv9 zU+y!V4=-jezWyi1QEcRAOs1zoaAI=u8Q(q_aw=Xe#~TjaoK~S4TBBhQy7yVr;zgCg z4V4(ZF$Yh7?dK`1KjfDEoz4RqlD0VD)u$@nrEg~tuq|Pa(B$&&5F~ql$fbw#g8lQ< zh#9F^gL&eb5tnDAL*Kx2mYu1bsTtDHlHKw+V9eGrD#h;9du^f~>);q=o6jn4!oGh@ zH1{|OB(pmYXoJzfWzSkHwU`NuBG7gU(tuAYR?-?i z4N>GsSQ~a#jQsu!--9?q#+xy#$mf)iQ#-b;V8dP}Acb_*@)~F8H5CK0u?gpXmnDXJ zR{Bj=uzA89;>QG<1pRDE^IdZd(f8<>$e6Fox~q&oYqOsE@x!*i?eTM&Jk@W-T6%|I zm_`4QJk}4}uhx@@!ERdP0yNab)(~Wk{M*%SNc|z7{?g+iG_8LLk)UIclWE%jd0%31 z(Qi(I6#5$<`bEN*z_O}7E1|>>ff<<0Eu3`QW5#>!3-Ye=?$Lk+4r6J_$WM#Vl6>;c=G6QyB+O}l#)rj|Ei_2Exq>;^x#Np^`$Ci$F zE2$qmFZ9u+ts|M5Rz44-&(sFv^NQQysyL}zW!Mw|-M^R3wM5!gS}8G+iOhJ-EVGC# zlofp2Yy4xhG*ii&c%cYF5sT5ai4UH}ta4{!WY$~DFgoQ)qz}QD=YXGTo(sWZ-f6J1 zc_{@`(bFw9UZ)w32}of-?pcdYkJVL8F3<1bLZ~KbNk|Yy8`rmzW{|c&7j$*CF&XsJ z(g#~$1uhv0pu~Ntl~`rJtb%3D*jY|cF|~}%9qBraFUiz=UMU0Wy*U2_3hbI5o{imR zjHq2t;E33&S+gYM?35)GzDcrI5Jl%QmqVD3yF6|h?RuB>dA-ZUsP#1T4^sa=>hd}2 z=C)6dXWdArOlE`u2V5yEXnQydqcummPy)oqSp+5EMa~_MO8`NLMNYeOSSDWm@in9plXj|%7YHlDywV6NF_`3x7}_w zNXi(YlSjv30l}kfz4{V`pmFlWYv*!-loc!UV&u9j+NQUr*IjA1Ia5R(;4i=Fx6llJ zzs^8&_#MzN|H1gKW-Iqf=oR8F>#;%mGrFTxi*)NM+0#?m+GE-3@ta`5)tPUnIv!U| zV$ulj&_Jg=r#b#?atG1rIOSU(NQr()c~t@2Zz*eO`BG9;9lFV|d(l~vm>ptq^S*f| zcibi=A1{vD9bX=hp`g~A5MLEvw49l(z|3Q_jA4iA{GKh6TGHv-&5?@nXP4Kwb)0d*FhoPws>8hY# zj!+K$>Kz(F7<0(f&+n5zD1_HBJ3} z=y^yWYP*h{U@$qp>;|Q);b~f2_ba`8g&lDw<&fLl^Oz-brYf(qv6msVwX4j4W7 zXI-B2nOw!yOm6#2iXGvKA|`UW>wZ3ZK4r@ZfOvf@gCl!KC*c@Yk>4=vaB7-pVDCzP9*@2?cx?90l<5*R6 zJpqkErAnFZ*6DLp^2}*^C~uv&JK8D^gR)%6Q`S|rZ^0+Z{9Q!gUZX&skIfPLXD4GDl~X_^iYvEv@>$+7|^$S z3miXdkJ{E+T4jIgSRyXu2zQ3Zn$TxrO*s58vobJfJvo3?)XK=iRg597T#hbDHxH;9 zWj4W1|J_hPWGl|Fu4LS>ix&0i?VoZy^a5Uf`LTjZxA5@ag+Ti6l=Pn6_BwA$OF&_! zY23Br>U(;>k; z&exa5(VSFYZ-};RCBYcB>_ugMwXbdBozB)aY$+AA(C}MZyK-pNyx6WGMig^9Nhb7f+PzwNIDZ(_?PF>L&}LMi>S;Auywlq`A^r+$ zx%rAlC&59u`GU=TNY-XFSIzCibVMWIaA%v&t?0~4%P&U?&%cm-Y&bH_$Ug-XtKgEu zp+lWLl1yZv)PKjFSLoZ%7~?Vn$5Fx2ZXhLS+|vgHEjV}@AiYKaMTt)R$) zn1B#}3!?Km;i^)7e4(N20)N}g6QU1UqSQ#aq>icGRgTfBpFcA9`Kmq_@yzDeV^k-V&)%tuF&h~3MeO*- z6jbRfWdOeU`C;o2hE+A&RE3~irnuaI-0&02_Fjvkatnf6YDm0GOsa1&XQ&5G-jD_C zkJ)3!^I$P?;#0%6%jCt`d6(M?Pld?YzMpKWpxM{ZrxV$V>86fXAo0 zj26Qb_pKI zE&b`bnJPMMqJy!4H)|fQ#e9L9m3~-14W4czVRZPJQocsmYtJ@v}34PU8l3ndapl>#_QD4<@I9;8eN1Z zc2F)>3kTh5b2p#mEx;clF2YfcRrL4kxV?w8~-LTN$`#^j3Pj%@R}Ne~iJp93#_ z>TmQqI`5t+_vLD>C44n}%ndT+(yBO-3}X@wS`btj^5Ud!3f~OK&*qOmiF`rv+)e%P z7xy+mYpJhafLW%j4>Y^9WRY>myD;as*n8Gj%V@ZVR^K@@nDJsJmDKGX`SZ*K1AHq? zy8gM$u#52R?)Iz2-#hb|CVv)%3d`s0hT8^ug$z{Mr+b;44&l>1$EiRw2g7X_$*vnV z7m8sK=%YsU${neGWplcdi^%*p%4A=w7@AMv8tYpwUT}EKl1#i=C-Z@GD&UFTim<5*?CVU;BV)$OTJ#h`|X&Mcwc+rML|VD$FqBeUM5O+qKCJI>y9oX z9&v;08w~71jHkx1<|~1j<$;8WnnxU*KJm;Q7k&!w)L(Rc+doI#YlpS;yYw4>aUxK) zm3;duVsEdXtpE#dnlIAUYtb-(XwiWwI@YcZo6_)EN0_}GfeD)v$noqX!sZCJ_TV(c z<-DXmXX4w~(s;Yj7urm`EfN0A$uG>??;A8L28A|QB6x`PT zgUwGZ%exmlV;Fs@bO&2?y+`W4w&E*RRpRq_YIP1rVgj>EtH&R5z278I*cHdgY6CWR zLy=z5$;KZ~J;po~z^v+t$E}R-0tv;ATxG za7o|U`%)=|LpLj5DK6|CvH1}1#?AyWoHGAqk|FjxcWio+n}=i5smrVQuwNRoOQ>eo z$TJO0U=S8X#DTtqt45!`e3=!;mEpCh zWJ)H!i73CAV)ZbW@T|$LB6ZMV4L)wx!M)zaFG;_7ePJfDbhLg-1k7+Wrdqfz`{$!9 z*9ECAO==Ct*%fO2&b?#?&fowVt$obUi_D^*xRkV^a|G_C_+&H-l)swXB`ep>GiDit z9*z>iGE~E7cbP$q9zZyFREB%(C95r(x^?_ynr*ZN zUz3dmj!(e125?|uH?!F68(m#p7Ez8?mbIwVy=b0D9oa3A<;`{CoczbUFH*Ha)GDDo zboc8^##*?T1_^w|$nYocTy2O6g)n5~ibo~lMwyycw=Z3n#;rvollUo9WlBYSti3hb zye*Q$6M42|)BX@=O50tDxgK)rp05&Wfu2=p#(aFWiD966r zuUHawk)BKq>X&9s_1ut(5vk`IrEBlQBl)#6yQX-NL+;&$HDUG~crPUcviAO=$ru(W zKYXq>kAR;vcKlo zN(?=$xWB7<2ciBM{Lmg35uBeT!D^Xs zcxcF+2_mccEf=dT464Wbh_0QlO@E)W(7}}BN$8E$YN3zXr_6dGLx0~tN8m-$yy|F5 z+^X^(<4yW2{#@rXDWUO+h_Eof3dMJHn~hOtsJAM-C^o_TiC1eXwt5dZbZ*}{wOEpnE3HaZE6E|WAwB41~A_RL;1$c-qjIsB3qPEPA*x2Y$E)2&`=lcS_i z`3B@T_*y&SuKxj2JOA)T&KCF*=gmG&9GUDlWs1+nt)$eHCkgaXzZO!6f$7>X^1r#! z8&RkM-xb?bC3Mkk>kUO(CI{Ue5x<&ayJ+&4UFOy>o6=11G9a z40|5=2i)~;=~QZ7e)!79(9Q#GaI8EJ&_$7pV1+`5;_t=;?*>BuUJK9 zk%X81$)8yUsHDMd>Y3`+)H%*?osHK zU-AYoy#P7-rC(@dS$PJ$LDQPtEJ`7}l^itb2j(u8e6dU`%=N}~B~#v7;nXPy)gQUm zNB!g%e9_m3O_1D($X|Bpy`alQ>s3%wgjf}ngdPYYlzdL^?z)?qxL*qgv+`?vvx-_3 ztK5$sVNgu~)fH7srt884B;?oQFsUYU zK>aMJ_4e|vdjR&M($I(G@IR|-pfvx7t14J;QfdkT-!F|>Zpn?`1ef;Oxf`7fiU&V6 zYiSWiWIkLUf7$IGAQrlH_UJt=nJL*+Dd+B-47%l{71&~ zsJ@#YgqwI@RhJXyYY$Aaz1pN^t&B*>7nyO8${EvlX^~xy+~EKm?hC|b{Mb>!JHNwu zw<>=@d_$d>;dBSrLfowJ>a9<0EovPN2=X(S6m}9TltSR1XkB98?c^(0o8^d}SgRm5|=)@8^}+~YqejvQ-uKyA~zmh1}A4UK``jU&!& z7gz0xY)jts*>R&AWG*WPi9A@>#Y#KC$q>c^mfW&TF+yGZcGeZIvqZPb6@|H@jr(x{ zhR)I0prP)Wu6uYP$nq08-hRZV8UzW}RH>~HwbHirkuaT&>t)lSBF3Ys>iUWftwSVI zOpWTpQM%!~QLTA^4QHM|VGw50XqksAoeZ+PJih#&*QrrT%(<){oP?4-`tUzPYCe*1 zZ`m+jyww!rlwknnvs@riP_?EVY;K}OzH{X?U@@AvopY?6exKeWF>zhp^s3ZGqh%UT zgKqweU$ui`yR%?pv|*`sLEoXNywN~sfn~bnXv9N_ds}ybJ3(hNEuRrdF^m&ZIMN3fou=Z$ZS-IU-y|&3zFuZ^gFu7 zsxRjsXYLLUH|#E}j{PEcrp+pRbs3j3b68AO5nK!~w0h+hHYlC%mS+f;$3A`hA~bKU zfNoUxn!_*DL?V}Ok4uPOz_LnhSvUFPFyfYpQhz&F+Ayt~FT zDo6BZF@L}r=)2Jp;I{$gYi`Duuv_LXS)!sCin$CVOQeg>8S?N3ZNe}7&iJZ+(pg^D zgb08+OS}k8-&LbAnS6Bku4!L1p*dWKF?HZO%T!~lsa@4e^Ljm4@3hrv!R=YRulBX) zw;)!(Y&`o~UZvcz8g8G(g(ZEK5gnzv>B(}z^A7z~T+k{q>v>}N2-@&-$kisdb?%M| zu2Z-6)w<)dwzADESL3&k>8TxC<5Ja{3@*|=u;4s}U6Edpp^zDwkL{J-(t><5Z0JsS zkZ8Y0Qe8LmcksH*H4GSOYh1oIyLEM-OMJN9E1^=3T5J!II*@ri<{Wa9wt?m%vC#P_Xp^a zjj^Avy!P}|NVmBB^$!=nf7(bhs8n17zuOUwBNHULE|{D!5NGotgiSG&0^_oR}t z(>8T$O&;fwn*-)Lf=uay#9a}sv`(Ae!Ul$Z_0Hf;!+j;p+n=wIFnB{N` zWNu>W!GWf3A@OW)zcrIxD*4ATAv;O7*x$<=Dw4S)ugfXF#vV1M+bQ7GSqy1` zMeZPzCGre^chZ^$0`+#0|8sdGr?dgRyb+p%Uf$$}yZ--|Hz1do(zZp8RzpJPs5ie) z{^#nZ*fOSTXh9NeE%Z?tA8l2z^=)9$MYBK=mmB78vK{6j-v*7p* zZdG>+JqFb!FP%@?x;Q-O8lPo{J?jowZ(B|Z7c`G^(-Ez~2|i91+l8xNW;u!0mxA9P zh9oS3-K_v5pqs-e$WNzpKLS+>8i1Iya+ZUGLb-2w^(lwhmM$I>ACo^hQ}zikd-tuM zmTUIguOo>#sQ^$U^h&1yZK`;y#F8EnZ!hH1ia1p)IGwX(11!{T+AQ^|q7Ad*6`Q*` z8WY0;XMWReX!-Ihm3YDP8H`{}?@9pHZ(&q6bR|%zoR@vASf_w!iq`hILe9R1 zJW-+1ZSCNUg1*MdP@~;1m1nPqDj5q~de6F<`eff%(cjYd9W0tMf9JD!iB@zjbra0Q zWzMGm$2$)=&Ogzwi7(_9vx0-&jcY4q-mD;(8z8JK%SV<{PtmY78hdp#r?zPyi}XU^ zoBSY1|AibGrT4dn*Gx>cc-zPZ;#4*aN#zyRb}cfW37ewbp4&6<(Y#y~6x0jII4M zk?@o$T@A#SsZld<8Dn2}W-+*QZ?ZRKgCo1O=#Pn1*E9}dZ`2>wbp2r9s1~UC=?fk#0}{qzcFA^O>9i=sYK>LHcHu|;Ol}J*fX+-C8eMc+{QftLQtV7KgY^Uh!WU|~O0jB0I zQd*>ABn3}2YQ!9V-fe<$td6xs)4h2AV9;P(p<}OZ@#h)8(YdQvBHOSD0aCNQ2QKJK z=%$mf@|{;ghjOfBB&Is>w&`w4=yjh=>Strk)m|5_MJ$@hJV;dp@3fc_Wg7z`fq;7P zy0q~-dXZ&e#|@Oe@X%XHN~tdbYeh=&)OrQGHG0c;#vbc{cZkKvFC4@8ra9;?OhJmU z^c-JjrEaQ>Sydvkt(cIFBJdE z9i^A7#zF$$)Yg+*O^b!yzl|tPWT?FM?u-v>(U1c-j2cF2pb1v)JxtpfGrjf)*i%K* ztHR(Lxj*$UDdm&czA8#@5gGcKRkMJC4!aZ`BYfl;*4N}$dS_g|VT-sWam0ltGJ+^O z*v8(|q9ZxJm?1w0ZIC%BL$TsI?rKZ@&X?ZgDx*{*{fBm{lsMw$Yz=ZI*zy9SkjCq5 zwbF5l;#aSo<7?be;t+|HxTAcDK+=sLNHk`S<>e93+t%@_X>!9h6QuJhV`Mul2g^s2 zKX+G4P4S0`N9LDGb_Q7NpmLtT47c`3EJVf~#M;eNvnf)k@2Ko3lxgk43n z?W!z3jfkdDKFnHQIDtJL$oUrT^56+Z{8ktIr+bU%{%GYZ{5jrS`~G%~7IZE4!`Qf~ zqxEy=e3ik$kC#QAayRa_wPKeQt!=X@WyuA6O)NSml<)F<4bSO%!lZTH#L%=>IY-X) z1Cv{>-XAOp)7c;Aqw*fN9Cr8Yy@n66Rn&%qR{+aPW+^g~G38|V7@-i`JDDGk?|&B2 zrwStA)T0WL-17;-*mMIOSA()|5srd?{nlRpaFI_dI9GmD^X*`zpzRXzAfY!84M}(c zZ)8^Mq}PvKnxR0&lbx_X{u87v#d6eoSopMCPeym>?H9_l_wS!OG&HNe`bjcK#Dlbk zsWw$zs&~YW)9hvE3KTcv{~-Qj22+%f7efpsegn}I$+ubI9{(em< z8nyM{)A_8GdEFK9kNFLMYvfK#gXU-EQj~lV4ocrjJ2zhu2%`jv^V0_3teKi2D*Jy^ z;gjnxNmf^vWk}wv#z+u7R%-jRwUV%6U-A-&nJArQloSs%GMKg6y->bW!ZkdN_stzu zFrLVLV0W_)_;b~;g)Hg@nh8UuKfY@U5PO6D`A-0!7bWaCk6oPbHZr2CmXW`ww|Dln z$kFq{UavvEVmsCl`acsqYARPTw1MzI74~2^Uq%crIsW#=@ba_QF^q>!+jgF^zMX&G z{W+zj5xM4~VWwlcxQuI#8u%IJluUgct#HK+%%x-=XfK4(IoOlM0s#dU$G%%~YZ+^8 zXi{I43?kZl;lHolOqW=JUo|9WKyv7pbWhu(!HBg{-AV=7aJ8+zFPG0U;7IV&qtisd)5*AH>qoj+HNkBFi7Hj4TA&Aa_#2HvGN|U z|JA?;HVXtmTgRFr0s*+tW;1ZsN5C$$9V;RNApW=8ZZr-6j|lCyTjPHo1A_zulZyrB zXa^92nfZWdO%GrI8WPk5BNOm|@QA=zd4O{$K*|T~K}}iZvnHL9VPMQip{7mv1%MBK z>C?&q`hQ#5E~)_X&`vY3WDQ^&YR_Ez7c>#p0pkC5p_SJI0uZ5#Y^_hRlC%L({w~tB z0}B2IGui{-g{n0n_X9-#BKZ*jF?1FD<~v~Xk)ugz3efu3C&~;!14?T+^WrfDpHkfS(um$BL+6DZ41dV$Dvx`U2WU)pZh5}tX-X;F4G`sf~Gh%=nMah`{U;kXZaqiDUnI#JzqpxVt7kg3=$|5N|_0 z&fO9h|MmC*5qJU>c_IO`|JIZQ1vv4y7xRb$==RsSB`pxzk_b+t1@c3=W@v#@P(Vrt z{98w7I-m+v()Eu7{{>JBDzSY5)P;iH7eH+&AfbPTn9u!b8KIynK0u7;(DMp|o6i_h%UqONYKVX3gs1KF!F+YKL=BF?Yn4gptS)L^M zEI=Ko@*NA%016CPpCt9HPhlXjJpny7;A^N(JKK|YRQ9Lb_1S^y(4}(rCuSs$r<9F2 zo|H>DfT~cPn}2{Z=aYH*Kj0VVQ>Kz!Pw`}PJ;i*-^;9|yZXgeoC!8B74h6&9PdubN zK!tzzR)Sr4fSkgRubUdAoALsyAjmEd0Audt==R#i(Za=*O$vVii~ z{|jE_0g}KbfNyz#3{;OqRD&8FO^{VGSQr?h|0a3_#UBCSs*jM@!9jKV;zi^8arMKbS)hNC&llB?!rYrVRjQY6I|rs|25_)Cm#8vVrFXfeg@$ zDm-A{!6L%IeEmNa{?YT-_i+!zx0ukAy{Zr-ES&zoOa4MY0w_!8brsbngar%hKkK3~ z@>lgML=_s>GK2uu0eme4q=L@Lg&}iou%IxI8ag+H%;9inz<$EO=g@2$2QLHv$(G=M z)d~j20^BJKq(OPy7%zsj2e7jUkPuc43@h?fcLos%wGdcFGgM|2gjeGr7#wzsZG)J|&m+Xvz<669qnpQmsDD zDZ#g*Kx$~692{lw*zkq+aTm{FAKY8qc z*g{gC69>{fMvx={nHqpeC7#Xzll)Wbf3|?=UmU<|VldS;F#zl@@f21R#15N>L)(jS{w8hzaR5Y_61|kdlkd#e^~~xp3h|R_7K;nUC^O zXXn_?>8qwxKh+W_UK5=Auz$uv|M=E@@=~)mD<~gA>#~{6c$}MAE|6X#mf(B2!qUrMRY{n*PrW`e=D)F-_}o78~ZG zKZq1t{qwL^k%rc>Wd2Wj+Z@U_5q$E6iybTz`gie0TiU~#8JO9}y}5U;pq|#Zf+m79 zigv<{9 delta 619 zcmXw#O(+C$7{)#AW>KqLl%hl{7o}x42Vp~+d@LuWD2tNAa#*1jdvI`Y5j9sN<+FU$ z?2O&n%|YTq%AQDRV{0XH5y{Roe{*?%z3=b+Khv8I+0r4Ky}R9F&C4>r;rZaQz06`1 zXC+I2jZqF)e(#KWyqXwkH$eF*Lw Date: Mon, 2 Dec 2019 09:38:16 +0100 Subject: [PATCH 118/248] Fix name of variable $trigger_name into $triggersendname --- htdocs/adherents/card.php | 2 +- htdocs/admin/mails.php | 2 +- htdocs/admin/mails_emailing.php | 2 +- htdocs/asset/card.php | 2 +- htdocs/bom/bom_card.php | 2 +- htdocs/comm/propal/card.php | 2 +- htdocs/comm/propal/class/propal.class.php | 8 +++---- htdocs/commande/card.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/contact/card.php | 2 +- htdocs/contrat/card.php | 2 +- htdocs/core/actions_sendmails.inc.php | 8 +++---- htdocs/core/class/commonobject.class.php | 6 +++--- htdocs/ecm/class/ecmdirectory.class.php | 6 +++--- htdocs/expedition/card.php | 2 +- htdocs/expensereport/card.php | 2 +- htdocs/fichinter/card.php | 2 +- .../class/fournisseur.commande.class.php | 21 ++++++++++--------- htdocs/fourn/commande/card.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/holiday/card.php | 2 +- .../modulebuilder/template/myobject_card.php | 2 +- htdocs/mrp/mo_card.php | 2 +- htdocs/mrp/mo_production.php | 2 +- htdocs/product/inventory/card.php | 2 +- htdocs/product/inventory/inventory.php | 2 +- htdocs/projet/card.php | 2 +- htdocs/public/ticket/view.php | 2 +- htdocs/reception/card.php | 2 +- htdocs/societe/card.php | 2 +- htdocs/supplier_proposal/card.php | 2 +- .../class/supplier_proposal.class.php | 8 +++---- htdocs/ticket/card.php | 2 +- htdocs/user/card.php | 2 +- htdocs/website/websiteaccount_card.php | 2 +- htdocs/zapier/hook_card.php | 2 +- 37 files changed, 60 insertions(+), 59 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 00db45c36b8..455c6181552 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -822,7 +822,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name = 'MEMBER_SENTBYMAIL'; + $triggersendname = 'MEMBER_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfrommember'; $trackid = 'mem'.$object->id; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index fb76c3c0676..eea2aaad9b4 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -95,7 +95,7 @@ if ($action == 'update' && empty($_POST["cancel"])) // Actions to send emails $id = 0; $actiontypecode = ''; // Not an event for agenda -$trigger_name = ''; // Disable triggers +$triggersendname = ''; // Disable triggers $paramname = 'id'; $mode = 'emailfortest'; $trackid = (($action == 'testhtml') ? "testhtml" : "test"); diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 811ffa3bece..3221c67fbc8 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -77,7 +77,7 @@ if ($action == 'update' && empty($_POST["cancel"])) // Actions to send emails $id=0; $actiontypecode=''; // Not an event for agenda -$trigger_name=''; // Disable triggers +$triggersendname = ''; // Disable triggers $paramname='id'; $mode='emailfortest'; $trackid=(($action == 'testhtml')?"testhtml":"test"); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index b23bf03f29b..d6b92639233 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -97,7 +97,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'ASSET_SENTBYMAIL'; + $triggersendname = 'ASSET_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_ASSET_TO'; $trackid = 'asset'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 150d3a69717..e5647fc5b5a 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -119,7 +119,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name = 'BOM_SENTBYMAIL'; + $triggersendname = 'BOM_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_BOM_TO'; $trackid = 'bom'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e916c544ced..e6b1b47d0b6 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -781,7 +781,7 @@ if (empty($reshook)) // Actions to send emails $actiontypecode = 'AC_OTH_AUTO'; - $trigger_name = 'PROPAL_SENTBYMAIL'; + $triggersendname = 'PROPAL_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_PROPOSAL_TO'; $trackid = 'pro'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index ac5b35eef44..f654ed932b7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2501,11 +2501,11 @@ class Propal extends CommonObject if ($resql) { $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->modelpdf; - $trigger_name = 'PROPAL_CLOSE_REFUSED'; + $triggerName = 'PROPAL_CLOSE_REFUSED'; if ($statut == self::STATUS_SIGNED) { - $trigger_name = 'PROPAL_CLOSE_SIGNED'; + $triggerName = 'PROPAL_CLOSE_SIGNED'; $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->modelpdf; // The connected company is classified as a client @@ -2522,7 +2522,7 @@ class Propal extends CommonObject } if ($statut == self::STATUS_BILLED) // Why this ? { - $trigger_name = 'PROPAL_CLASSIFY_BILLED'; + $triggerName = 'PROPAL_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -2550,7 +2550,7 @@ class Propal extends CommonObject if (!$notrigger && empty($error)) { // Call trigger - $result = $this->call_trigger($trigger_name, $user); + $result = $this->call_trigger($triggerName, $user); if ($result < 0) { $error++; } // End call triggers } diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 803d699077f..8d43c54cc7c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1415,7 +1415,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name = 'ORDER_SENTBYMAIL'; + $triggersendname = 'ORDER_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_ORDER_TO'; // used to know the automatic BCC to add $trackid = 'ord'.$object->id; diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9e34c745fab..70a504f23f3 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -223,7 +223,7 @@ if (empty($reshook)) $permissiontoread = $user->rights->commande->lire; $permissiontodelete = $user->rights->commande->supprimer; $uploaddir = $conf->commande->multidir_output[$conf->entity]; - $trigger_name = 'ORDER_SENTBYMAIL'; + $triggersendname = 'ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index cdfa106e755..14a4f4bae9b 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2481,7 +2481,7 @@ if (empty($reshook)) // Actions to send emails if (empty($id)) $id = $facid; - $trigger_name = 'BILL_SENTBYMAIL'; + $triggersendname = 'BILL_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_INVOICE_TO'; $trackid = 'inv'.$object->id; diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index ea6ef4d0530..2998e0890f2 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -482,7 +482,7 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name = 'CONTACT_SENTBYMAIL'; + $triggersendname = 'CONTACT_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromcontact'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index efd521e9ec0..accbbfa242e 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1002,7 +1002,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails - $trigger_name = 'CONTRACT_SENTBYMAIL'; + $triggersendname = 'CONTRACT_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromcontract'; $trackid = 'con'.$object->id; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 9c87e6ebe36..f490397754d 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -26,7 +26,7 @@ // $id must be defined // $paramname may be defined // $autocopy may be defined (used to know the automatic BCC to add) -// $trigger_name must be set (can be '') +// $triggersendname must be set (can be '') // $actiontypecode can be set // $object and $uobject may be defined @@ -453,12 +453,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $object->email_subject = $subject; $object->email_msgid = $mailfile->msgid; - // Call of triggers - if (! empty($trigger_name)) + // Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprcated) + if (! empty($triggersendname) || ! empty($trigger_name)) { include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($db); - $result=$interface->run_triggers($trigger_name, $object, $user, $langs, $conf); + $result=$interface->run_triggers(empty($triggersendname)?$trigger_name:$triggersendname, $object, $user, $langs, $conf); if ($result < 0) { setEventMessages($interface->error, $interface->errors, 'errors'); } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index afe47934e4a..a6084a49f7e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4956,11 +4956,11 @@ abstract class CommonObject * NB: Error from trigger are stacked in interface->errors * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. * - * @param string $trigger_name trigger's name to execute + * @param string $triggerName trigger's name to execute * @param User $user Object user * @return int Result of run_triggers */ - public function call_trigger($trigger_name, $user) + public function call_trigger($triggerName, $user) { // phpcs:enable global $langs, $conf; @@ -4972,7 +4972,7 @@ abstract class CommonObject include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interface = new Interfaces($this->db); - $result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf); + $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf); if ($result < 0) { diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 979ffe416b4..7471b3d30a4 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -795,18 +795,18 @@ class EcmDirectory // extends CommonObject * NB2: if trigger fail, action should be canceled. * NB3: Should be deleted if EcmDirectory extend CommonObject * - * @param string $trigger_name trigger's name to execute + * @param string $triggerName trigger's name to execute * @param User $user Object user * @return int Result of run_triggers */ - public function call_trigger($trigger_name, $user) + public function call_trigger($triggerName, $user) { // phpcs:enable global $langs,$conf; include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); - $result=$interface->run_triggers($trigger_name, $this, $user, $langs, $conf); + $result=$interface->run_triggers($triggerName, $this, $user, $langs, $conf); if ($result < 0) { if (!empty($this->errors)) { diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ca543f5f2d5..40445b522da 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -849,7 +849,7 @@ if (empty($reshook)) // Actions to send emails if (empty($id)) $id = $facid; - $trigger_name = 'SHIPPING_SENTBYMAIL'; + $triggersendname = 'SHIPPING_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromshipment'; $trackid = 'shi'.$object->id; diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index b24259d797a..b44c9b0e9d6 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -1411,7 +1411,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'EXPENSEREPORT_SENTBYMAIL'; + $triggersendname = 'EXPENSEREPORT_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_EXPENSEREPORT_TO'; $trackid = 'exp'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 9371c6a308a..2d4dc5f7143 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -721,7 +721,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'FICHINTER_SENTBYMAIL'; + $triggersendname = 'FICHINTER_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_FICHINTER_TO'; $trackid = 'int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index b1ebe4a3895..abda1519002 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2420,18 +2420,19 @@ class CommandeFournisseur extends CommonOrder if ($resql) { // Trigger names for each status - $trigger_name[0] = 'DRAFT'; - $trigger_name[1] = 'VALIDATED'; - $trigger_name[2] = 'APPROVED'; - $trigger_name[3] = 'ORDERED'; // Ordered - $trigger_name[4] = 'RECEIVED_PARTIALLY'; - $trigger_name[5] = 'RECEIVED_COMPLETELY'; - $trigger_name[6] = 'CANCELED'; - $trigger_name[7] = 'CANCELED'; - $trigger_name[9] = 'REFUSED'; + $triggerName = array(); + $triggerName[0] = 'DRAFT'; + $triggerName[1] = 'VALIDATED'; + $triggerName[2] = 'APPROVED'; + $triggerName[3] = 'ORDERED'; // Ordered + $triggerName[4] = 'RECEIVED_PARTIALLY'; + $triggerName[5] = 'RECEIVED_COMPLETELY'; + $triggerName[6] = 'CANCELED'; + $triggerName[7] = 'CANCELED'; + $triggerName[9] = 'REFUSED'; // Call trigger - $result = $this->call_trigger("ORDER_SUPPLIER_STATUS_".$trigger_name[$status], $user); + $result = $this->call_trigger("ORDER_SUPPLIER_STATUS_".$triggerName[$status], $user); if ($result < 0) { $error++; } // End call triggers } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 7e330635de8..a8ec90f86fe 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1028,7 +1028,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'ORDER_SUPPLIER_SENTBYMAIL'; + $triggersendname = 'ORDER_SUPPLIER_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO'; $trackid = 'sor'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a4a7964ca5a..51cf62258a6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1497,7 +1497,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'BILL_SUPPLIER_SENTBYMAIL'; + $triggersendname = 'BILL_SUPPLIER_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO'; $trackid = 'sin'.$object->id; diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index c5a88028586..5c09090dde1 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -872,7 +872,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name='HOLIDAY_SENTBYMAIL'; + $triggersendname = 'HOLIDAY_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_HOLIDAY_TO'; $trackid='leav'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 564cd14d5ec..bd06d9594ee 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -160,7 +160,7 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name = 'MYOBJECT_SENTBYMAIL'; + $triggersendname = 'MYOBJECT_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; $trackid = 'myobject'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 7fe93d795a1..baa4c09725f 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -146,7 +146,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'MO_SENTBYMAIL'; + $triggersendname = 'MO_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; $trackid = 'mo'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 45507e44928..28800d23bd2 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -133,7 +133,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'MO_SENTBYMAIL'; + $triggersendname = 'MO_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO'; $trackid = 'mo'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 09949ee3791..bb6802469e3 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -112,7 +112,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - /*$trigger_name='MYOBJECT_SENTBYMAIL'; + /*$triggersendname = 'MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; $trackid='myobject'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/ diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 093d1c2c3f9..e7f7799691d 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -119,7 +119,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - /*$trigger_name='MYOBJECT_SENTBYMAIL'; + /*$triggersendname = 'MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; $trackid='myobject'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/ diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 493978f738e..455a5742a68 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -456,7 +456,7 @@ if (empty($reshook)) } // Actions to send emails - $trigger_name = 'PROJECT_SENTBYMAIL'; + $triggersendname = 'PROJECT_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_PROJECT_TO'; // used to know the automatic BCC to add $trackid = 'proj'.$object->id; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index 43e03ef4c07..fd57df992ca 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -198,7 +198,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a //$object->doActions($action); // Actions to send emails (for ticket, we need to manage the addfile and removefile only) -$trigger_name = 'TICKET_SENTBYMAIL'; +$triggersendname = 'TICKET_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add $trackid = 'tic'.$object->id; diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 4989e0484a2..e8a67222a30 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -688,7 +688,7 @@ if (empty($reshook)) // Actions to send emails if (empty($id)) $id = $facid; - $trigger_name = 'RECEPTION_SENTBYMAIL'; + $triggersendname = 'RECEPTION_SENTBYMAIL'; $paramname = 'id'; $mode = 'emailfromreception'; $trackid = 'shi'.$object->id; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 464f94d71cb..83da4d9aed9 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -862,7 +862,7 @@ if (empty($reshook)) $object->fetch($socid); // Actions to send emails - $trigger_name = 'COMPANY_SENTBYMAIL'; + $triggersendname = 'COMPANY_SENTBYMAIL'; $paramname = 'socid'; $mode = 'emailfromthirdparty'; $trackid = 'thi'.$object->id; diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 584fcd0f4a5..609dc8d3b0c 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -491,7 +491,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; + $triggersendname = 'PROPOSAL_SUPPLIER_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO'; $trackid = 'spr'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index b6ff684fa7c..b0369dc1661 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -1729,11 +1729,11 @@ class SupplierProposal extends CommonObject if ($resql) { $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; + $triggerName = 'SUPPLIER_PROPOSAL_CLOSE_REFUSED'; if ($status == 2) { - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; + $triggerName='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; if (! empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) // TODO This option was not tested correctly. Error if product ref does not exists @@ -1743,7 +1743,7 @@ class SupplierProposal extends CommonObject } if ($status == 4) { - $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; + $triggerName='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) @@ -1760,7 +1760,7 @@ class SupplierProposal extends CommonObject } // Call trigger - $result=$this->call_trigger($trigger_name, $user); + $result=$this->call_trigger($triggerName, $user); if ($result < 0) { $error++; } // End call triggers diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index edbd1257c68..cc7f5a60dbb 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -593,7 +593,7 @@ $permissiontoadd = $user->rights->ticket->write; include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; // Actions to send emails -$trigger_name = 'TICKET_SENTBYMAIL'; +$triggersendname = 'TICKET_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add $trackid = 'tic'.$object->id; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index c6f9123d9c1..e72c2833933 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -657,7 +657,7 @@ if (empty($reshook)) { } // Actions to send emails - $trigger_name = 'USER_SENTBYMAIL'; + $triggersendname = 'USER_SENTBYMAIL'; $paramname = 'id'; // Name of param key to open the card $mode = 'emailfromuser'; $trackid = 'use'.$id; diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 2241b128dee..6a151a71519 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -97,7 +97,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'WEBSITEACCOUNT_SENTBYMAIL'; + $triggersendname = 'WEBSITEACCOUNT_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_WEBSITEACCOUNT_TO'; $trackid = 'websiteaccount'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; diff --git a/htdocs/zapier/hook_card.php b/htdocs/zapier/hook_card.php index 1070a02af9d..a2d82904f58 100644 --- a/htdocs/zapier/hook_card.php +++ b/htdocs/zapier/hook_card.php @@ -138,7 +138,7 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; // Actions to send emails - $trigger_name = 'MYOBJECT_SENTBYMAIL'; + $triggersendname = 'MYOBJECT_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; $trackid = 'myobject'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; From 4a33ee60f862e109e6efc0c239ccba01f10b7b63 Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 2 Dec 2019 10:34:14 +0100 Subject: [PATCH 119/248] Fix user card : use comma in amounts inputs --- htdocs/user/card.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index ef0ed3743dd..cf9f82d7483 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -218,8 +218,11 @@ if (empty($reshook)) { $object->employee = GETPOST('employee', 'alphanohtml'); $object->thm = GETPOST("thm", 'alphanohtml') != '' ? GETPOST("thm", 'alphanohtml') : ''; + $object->thm = price2num($object->thm); $object->tjm = GETPOST("tjm", 'alphanohtml') != '' ? GETPOST("tjm", 'alphanohtml') : ''; + $object->tjm = price2num($object->tjm); $object->salary = GETPOST("salary", 'alphanohtml') != '' ? GETPOST("salary", 'alphanohtml') : ''; + $object->salary = price2num($object->salary); $object->salaryextra = GETPOST("salaryextra", 'alphanohtml') != '' ? GETPOST("salaryextra", 'alphanohtml') : ''; $object->weeklyhours = GETPOST("weeklyhours", 'alphanohtml') != '' ? GETPOST("weeklyhours", 'alphanohtml') : ''; @@ -366,8 +369,11 @@ if (empty($reshook)) { $object->employee = GETPOST('employee','int'); $object->thm = GETPOST("thm",'alphanohtml') != '' ? GETPOST("thm",'alphanohtml') : ''; + $object->thm = price2num($object->thm); $object->tjm = GETPOST("tjm",'alphanohtml') != '' ? GETPOST("tjm",'alphanohtml') : ''; + $object->tjm = price2num($object->tjm); $object->salary = GETPOST("salary",'alphanohtml') != '' ? GETPOST("salary",'alphanohtml') : ''; + $object->salary = price2num($object->salary); $object->salaryextra = GETPOST("salaryextra",'alphanohtml') != '' ? GETPOST("salaryextra",'alphanohtml') : ''; $object->weeklyhours = GETPOST("weeklyhours",'alphanohtml') != '' ? GETPOST("weeklyhours",'alphanohtml') : ''; From 6d81bc77cba9f43f6e2901ee175294fd43e4434b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Dec 2019 11:00:09 +0100 Subject: [PATCH 120/248] Fix look and feel v11 --- htdocs/blockedlog/lib/blockedlog.lib.php | 2 +- htdocs/comm/card.php | 14 +++++++------- htdocs/comm/index.php | 6 +++--- htdocs/compta/index.php | 4 ++-- htdocs/contrat/index.php | 2 +- htdocs/core/lib/agenda.lib.php | 2 +- htdocs/core/lib/bank.lib.php | 2 +- htdocs/core/lib/company.lib.php | 2 +- htdocs/core/lib/project.lib.php | 2 +- htdocs/fourn/card.php | 8 ++++---- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index 0d7c69a6d00..13c7ac61d1a 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -46,7 +46,7 @@ function blockedlogadmin_prepare_head() $b=new BlockedLog($db); if ($b->alreadyUsed()) { - $head[$h][1].=' ...'; + $head[$h][1].='...'; } $head[$h][2] = 'fingerprints'; $h++; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 6e42b1068c1..010a3c6785a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -695,7 +695,7 @@ if ($object->id > 0) print '
'; print ''; - print '
'; + print ''; print ''; @@ -780,7 +780,7 @@ if ($object->id > 0) print '
'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPropals").' '.$num.''; print ''; print '
'.$langs->trans("LastPropals", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPropals").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print ''; - print ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; + print '
'.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''; print ''; //if($num2 > 0) print ''; //else print ''; @@ -856,7 +856,7 @@ if ($object->id > 0) print '
'.$langs->trans("LastCustomerOrders", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').''.img_picto($langs->trans("CreateInvoiceForThisCustomer"),'object_bill').''.img_picto($langs->trans("NoOrdersToInvoice"),'object_bill').'
'; print ''; - print '
'; + print ''; print ''; @@ -921,7 +921,7 @@ if ($object->id > 0) print ''; print ''; print ''; @@ -990,7 +990,7 @@ if ($object->id > 0) print '
'.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''; print ''; print '
'.$langs->trans("LastSendings", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllSendings").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; - print ''; + print ''; //print ''; print '
'.$langs->trans("LastContracts", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllContracts").' '.$num.''.$langs->trans("AllContracts").''.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; print ''; - print '
'; + print ''; print ''; @@ -1063,7 +1063,7 @@ if ($object->id > 0) print '
'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllInterventions").' '.$num.''; print ''; print '
'.$langs->trans("LastInterventions", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllInterventions").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print ''; - print '\n"; + $showinfobcc = ''; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && !empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; + if ($showinfobcc) $out .= ' + '.$showinfobcc; + $out .= "\n"; return $out; } @@ -1093,16 +1093,16 @@ class FormMail extends Form { global $conf, $langs; //if (! $this->errorstomail) $this->errorstomail=$this->frommail; - $errorstomail = (! empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); + $errorstomail = (!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail); if ($this->witherrorstoreadonly) { - $out= '\n"; + $out = '\n"; } else { - $out= '\n"; + $out = '\n"; } return $out; } @@ -1117,17 +1117,17 @@ class FormMail extends Form global $conf, $langs, $form; $out = '\n"; + $out .= "\n"; return $out; } @@ -1143,28 +1143,28 @@ class FormMail extends Form global $conf, $langs, $form; $defaulttopic = GETPOST('subject', 'none'); - if (! GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { if ($arraydefaultmessage && $arraydefaultmessage->topic) { $defaulttopic = $arraydefaultmessage->topic; - } elseif (! is_numeric($this->withtopic)) { + } elseif (!is_numeric($this->withtopic)) { $defaulttopic = $this->withtopic; } } - $defaulttopic=make_substitutions($defaulttopic, $this->substit); + $defaulttopic = make_substitutions($defaulttopic, $this->substit); $out = ''; - $out.= ''; - $out.= ''; + $out .= '\n"; + $out .= "\n"; return $out; } @@ -1197,18 +1197,18 @@ class FormMail extends Form if ($languagetosearchmain == $languagetosearch) $languagetosearchmain = ''; $sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; - $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned - if ($active >= 0) $sql.=" AND active = ".$active; - if ($label) $sql.=" AND label ='".$db->escape($label)."'"; - if (! ($id > 0) && $languagetosearch) $sql.= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')"; - if ($id > 0) $sql.= " AND rowid=".$id; - if ($id == -1) $sql.= " AND position=0"; - if ($languagetosearch) $sql.= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' - else $sql.= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined - $sql.= $db->plimit(1); + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; + $sql .= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; + $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // Get all public or private owned + if ($active >= 0) $sql .= " AND active = ".$active; + if ($label) $sql .= " AND label ='".$db->escape($label)."'"; + if (!($id > 0) && $languagetosearch) $sql .= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')"; + if ($id > 0) $sql .= " AND rowid=".$id; + if ($id == -1) $sql .= " AND position=0"; + if ($languagetosearch) $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' + else $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined + $sql .= $db->plimit(1); //print $sql; $resql = $db->query($sql); @@ -1226,32 +1226,32 @@ class FormMail extends Form $ret->content_lines = $obj->content_lines; $ret->joinfiles = $obj->joinfiles; } - elseif($id == -2) { + elseif ($id == -2) { // Not found with the provided label return -1; } else { // If there is no template at all - $defaultmessage=''; - if ($type_template=='body') { $defaultmessage=$this->withbody; } // Special case to use this->withbody as content - elseif ($type_template=='facture_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } - elseif ($type_template=='facture_relance') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } - elseif ($type_template=='propal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendProposal"); } - elseif ($type_template=='supplier_proposal_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } - elseif ($type_template=='order_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendOrder"); } - elseif ($type_template=='order_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } - elseif ($type_template=='invoice_supplier_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } - elseif ($type_template=='shipping_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendShipping"); } - elseif ($type_template=='fichinter_send') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } - elseif ($type_template=='thirdparty') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentThirdparty"); } - elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } - elseif (!empty($type_template)) { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } + $defaultmessage = ''; + if ($type_template == 'body') { $defaultmessage = $this->withbody; } // Special case to use this->withbody as content + elseif ($type_template == 'facture_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice"); } + elseif ($type_template == 'facture_relance') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } + elseif ($type_template == 'propal_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal"); } + elseif ($type_template == 'supplier_proposal_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierProposal"); } + elseif ($type_template == 'order_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder"); } + elseif ($type_template == 'order_supplier_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder"); } + elseif ($type_template == 'invoice_supplier_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } + elseif ($type_template == 'shipping_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping"); } + elseif ($type_template == 'fichinter_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); } + elseif ($type_template == 'thirdparty') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty"); } + elseif ($type_template == 'user') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentUser"); } + elseif (!empty($type_template)) { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); } $ret->label = 'default'; $ret->lang = $outputlangs->defaultlang; $ret->topic = ''; $ret->joinfiles = 1; $ret->content = $defaultmessage; - $ret->content_lines =''; + $ret->content_lines = ''; } $db->free($resql); @@ -1275,27 +1275,27 @@ class FormMail extends Form */ public function isEMailTemplate($type_template, $user, $outputlangs) { - $ret=array(); + $ret = array(); $sql = "SELECT label, topic, content, lang"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE type_template='".$this->db->escape($type_template)."'"; - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; - $sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; - if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; - $sql.= $this->db->order("lang,label", "ASC"); + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; + $sql .= " WHERE type_template='".$this->db->escape($type_template)."'"; + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; + $sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; + if (is_object($outputlangs)) $sql .= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; + $sql .= $this->db->order("lang,label", "ASC"); //print $sql; $resql = $this->db->query($sql); if ($resql) { - $num= $this->db->num_rows($resql); + $num = $this->db->num_rows($resql); $this->db->free($resql); return $num; } else { - $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); + $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); return -1; } } @@ -1312,44 +1312,44 @@ class FormMail extends Form */ public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active = 1) { - $ret=array(); + $ret = array(); $sql = "SELECT rowid, label, topic, content, content_lines, lang, fk_user, private, position"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; - $sql.= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; - $sql.= " AND entity IN (".getEntity('c_email_templates').")"; - $sql.= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. - if ($active >= 0) $sql.=" AND active = ".$active; + $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; + $sql .= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; + $sql .= " AND entity IN (".getEntity('c_email_templates').")"; + $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. + if ($active >= 0) $sql .= " AND active = ".$active; //if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')"; // Return all languages - $sql.= $this->db->order("position,lang,label", "ASC"); + $sql .= $this->db->order("position,lang,label", "ASC"); //print $sql; $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $this->lines_model=array(); + $num = $this->db->num_rows($resql); + $this->lines_model = array(); while ($obj = $this->db->fetch_object($resql)) { $line = new ModelMail(); - $line->id=$obj->rowid; - $line->label=$obj->label; - $line->lang=$obj->lang; - $line->fk_user=$obj->fk_user; - $line->private=$obj->private; - $line->position=$obj->position; - $line->topic=$obj->topic; - $line->content=$obj->content; - $line->content_lines=$obj->content_lines; + $line->id = $obj->rowid; + $line->label = $obj->label; + $line->lang = $obj->lang; + $line->fk_user = $obj->fk_user; + $line->private = $obj->private; + $line->position = $obj->position; + $line->topic = $obj->topic; + $line->content = $obj->content; + $line->content_lines = $obj->content_lines; - $this->lines_model[]=$line; + $this->lines_model[] = $line; } $this->db->free($resql); return $num; } else { - $this->error=get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); + $this->error = get_class($this).' '.__METHOD__.' ERROR:'.$this->db->lasterror(); return -1; } } @@ -1368,11 +1368,11 @@ class FormMail extends Form { global $conf, $user; - $parameters=array(); - $tmparray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $parameters = array(); + $tmparray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($tmparray, $outputlangs, null, $parameters); - $this->substit=$tmparray; + $this->substit = $tmparray; // Fill substit_lines with each object lines content if (is_array($object->lines)) @@ -1396,7 +1396,7 @@ class FormMail extends Form // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ if (!empty($line->fk_product)) { - if (! is_object($extrafields)) $extrafields = new ExtraFields($this->db); + if (!is_object($extrafields)) $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label('product', true); $product = new Product($this->db); $product->fetch($line->fk_product, '', '', 1); @@ -1404,7 +1404,7 @@ class FormMail extends Form if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { - $substit_line['__PRODUCT_EXTRAFIELD_' . strtoupper($key) . '__'] = $product->array_options['options_' . $key]; + $substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key]; } } } @@ -1425,27 +1425,27 @@ class FormMail extends Form { global $conf, $langs; - $tmparray=array(); + $tmparray = array(); if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { - $parameters=array('mode'=>$mode); - $tmparray=getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects + $parameters = array('mode'=>$mode); + $tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects complete_substitutions_array($tmparray, $langs, null, $parameters); if ($mode == 'formwithlines') { - $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function + $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function } if ($mode == 'formforlines') { - $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function + $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function } } if ($mode == 'emailing') { - $parameters=array('mode'=>$mode); - $tmparray=getCommonSubstitutionArray($langs, 2, array('object','objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects + $parameters = array('mode'=>$mode); + $tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects complete_substitutions_array($tmparray, $langs, null, $parameters); // For mass emailing, we have different keys @@ -1465,18 +1465,18 @@ class FormMail extends Form //,'__PERSONALIZED__' => 'Personalized' // Hidden because not used yet in mass emailing $onlinepaymentenabled = 0; - if (! empty($conf->paypal->enabled)) $onlinepaymentenabled++; - if (! empty($conf->paybox->enabled)) $onlinepaymentenabled++; - if (! empty($conf->stripe->enabled)) $onlinepaymentenabled++; - if ($onlinepaymentenabled && ! empty($conf->global->PAYMENT_SECURITY_TOKEN)) + if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; + if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; + if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { - $tmparray['__SECUREKEYPAYMENT__']=$conf->global->PAYMENT_SECURITY_TOKEN; - if (! empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) + $tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN; + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { - if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__']='SecureKeyPAYMENTUniquePerMember'; - if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__']='SecureKeyPAYMENTUniquePerInvoice'; - if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__']='SecureKeyPAYMENTUniquePerOrder'; - if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__']='SecureKeyPAYMENTUniquePerContractLine'; + if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; + if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; + if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; + if ($conf->contrat->enabled) $tmparray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'SecureKeyPAYMENTUniquePerContractLine'; } } else @@ -1491,9 +1491,9 @@ class FormMail extends Form } } - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { - if (empty($val)) $tmparray[$key]=$key; + if (empty($val)) $tmparray[$key] = $key; } return $tmparray; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 535d5bef3cd..12be3854ed6 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -23,7 +23,7 @@ * \ingroup notification * \brief File of class to manage notifications */ -require_once DOL_DOCUMENT_ROOT .'/core/class/CMailFile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; /** @@ -44,7 +44,7 @@ class Notify /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -110,27 +110,27 @@ class Notify global $langs; $langs->load("mails"); - $listofnotiftodo=$this->getNotificationsArray($action, $socid, $object, 0); + $listofnotiftodo = $this->getNotificationsArray($action, $socid, $object, 0); - $nb=-1; - if (is_array($listofnotiftodo)) $nb=count($listofnotiftodo); - if ($nb < 0) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); - if ($nb == 0) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); - if ($nb == 1) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); - if ($nb >= 2) $texte=img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); + $nb = -1; + if (is_array($listofnotiftodo)) $nb = count($listofnotiftodo); + if ($nb < 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ErrorFailedToGetListOfNotificationsToSend"); + if ($nb == 0) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("NoNotificationsWillBeSent"); + if ($nb == 1) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("ANotificationsWillBeSent"); + if ($nb >= 2) $texte = img_object($langs->trans("Notifications"), 'email').' '.$langs->trans("SomeNotificationsWillBeSent", $nb); if (is_array($listofnotiftodo)) { - $i=0; + $i = 0; foreach ($listofnotiftodo as $key => $val) { - if ($i) $texte.=', '; - else $texte.=' ('; - if ($val['isemailvalid']) $texte.=$val['email']; - else $texte.=$val['emaildesc']; + if ($i) $texte .= ', '; + else $texte .= ' ('; + if ($val['isemailvalid']) $texte .= $val['email']; + else $texte .= $val['emaildesc']; $i++; } - if ($i) $texte.=')'; + if ($i) $texte .= ')'; } return $texte; @@ -150,31 +150,31 @@ class Notify { global $conf, $user; - $error=0; - $resarray=array(); + $error = 0; + $resarray = array(); $valueforthreshold = 0; if (is_object($object)) $valueforthreshold = $object->total_ht; - if (! $error) + if (!$error) { if ($socid >= 0 && in_array('thirdparty', $scope)) { $sql = "SELECT a.code, c.email, c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; - $sql.= " ".MAIN_DB_PREFIX."socpeople as c,"; - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; - $sql.= " ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE n.fk_contact = c.rowid"; - $sql.= " AND a.rowid = n.fk_action"; - $sql.= " AND n.fk_soc = s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; + $sql .= " ".MAIN_DB_PREFIX."socpeople as c,"; + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a,"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE n.fk_contact = c.rowid"; + $sql .= " AND a.rowid = n.fk_action"; + $sql .= " AND n.fk_soc = s.rowid"; if ($notifcode) { - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage - else $sql.= " AND a.code = '".$notifcode."'"; // New usage + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage + else $sql .= " AND a.code = '".$notifcode."'"; // New usage } - $sql.= " AND s.entity IN (".getEntity('societe').")"; - if ($socid > 0) $sql.= " AND s.rowid = ".$socid; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + if ($socid > 0) $sql .= " AND s.rowid = ".$socid; dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); @@ -182,14 +182,14 @@ class Notify if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { - $newval2=trim($obj->email); - $isvalid=isValidEmail($newval2); + $newval2 = trim($obj->email); + $isvalid = isValidEmail($newval2); if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tocontact', 'code'=>trim($obj->code), 'emaildesc'=>'Contact id '.$obj->rowid, 'email'=>$newval2, 'contactid'=>$obj->rowid, 'isemailvalid'=>$isvalid); } $i++; @@ -198,28 +198,28 @@ class Notify else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } } - if (! $error) + if (!$error) { if ($userid >= 0 && in_array('user', $scope)) { $sql = "SELECT a.code, c.email, c.rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; - $sql.= " ".MAIN_DB_PREFIX."user as c,"; - $sql.= " ".MAIN_DB_PREFIX."c_action_trigger as a"; - $sql.= " WHERE n.fk_user = c.rowid"; - $sql.= " AND a.rowid = n.fk_action"; + $sql .= " FROM ".MAIN_DB_PREFIX."notify_def as n,"; + $sql .= " ".MAIN_DB_PREFIX."user as c,"; + $sql .= " ".MAIN_DB_PREFIX."c_action_trigger as a"; + $sql .= " WHERE n.fk_user = c.rowid"; + $sql .= " AND a.rowid = n.fk_action"; if ($notifcode) { - if (is_numeric($notifcode)) $sql.= " AND n.fk_action = ".$notifcode; // Old usage - else $sql.= " AND a.code = '".$notifcode."'"; // New usage + if (is_numeric($notifcode)) $sql .= " AND n.fk_action = ".$notifcode; // Old usage + else $sql .= " AND a.code = '".$notifcode."'"; // New usage } - $sql.= " AND c.entity IN (".getEntity('user').")"; - if ($userid > 0) $sql.= " AND c.rowid = ".$userid; + $sql .= " AND c.entity IN (".getEntity('user').")"; + if ($userid > 0) $sql .= " AND c.rowid = ".$userid; dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); @@ -227,14 +227,14 @@ class Notify if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); if ($obj) { - $newval2=trim($obj->email); - $isvalid=isValidEmail($newval2); + $newval2 = trim($obj->email); + $isvalid = isValidEmail($newval2); if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'touser', 'code'=>trim($obj->code), 'emaildesc'=>'User id '.$obj->rowid, 'email'=>$newval2, 'userid'=>$obj->rowid, 'isemailvalid'=>$isvalid); } $i++; @@ -243,49 +243,49 @@ class Notify else { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } } - if (! $error) + if (!$error) { if (in_array('global', $scope)) { // List of notifications enabled for fixed email - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { if ($notifcode) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; } else { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_.*_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; } $threshold = (float) $reg[1]; if ($valueforthreshold < $threshold) continue; - $tmpemail=explode(',', $val); - foreach($tmpemail as $key2 => $val2) + $tmpemail = explode(',', $val); + foreach ($tmpemail as $key2 => $val2) { - $newval2=trim($val2); + $newval2 = trim($val2); if ($newval2 == '__SUPERVISOREMAIL__') { if ($user->fk_user > 0) { - $tmpuser=new User($this->db); + $tmpuser = new User($this->db); $tmpuser->fetch($user->fk_user); - if ($tmpuser->email) $newval2=trim($tmpuser->email); - else $newval2=''; + if ($tmpuser->email) $newval2 = trim($tmpuser->email); + else $newval2 = ''; } - else $newval2=''; + else $newval2 = ''; } if ($newval2) { - $isvalid=isValidEmail($newval2, 0); - if (empty($resarray[$newval2])) $resarray[$newval2]=array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); + $isvalid = isValidEmail($newval2, 0); + if (empty($resarray[$newval2])) $resarray[$newval2] = array('type'=> 'tofixedemail', 'code'=>trim($key), 'emaildesc'=>trim($val2), 'email'=>$newval2, 'isemailvalid'=>$isvalid); } } } @@ -311,17 +311,17 @@ class Notify */ public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) { - global $user,$conf,$langs,$mysoc; + global $user, $conf, $langs, $mysoc; global $hookmanager; global $dolibarr_main_url_root; - if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0; + if (!in_array($notifcode, $this->arrayofnotifsupported)) return 0; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('notification')); @@ -409,77 +409,77 @@ class Notify { $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($obj->default_lang); - $outputlangs->loadLangs(array("main","other")); + $outputlangs->loadLangs(array("main", "other")); } - $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); + $subject = '['.$mysoc->name.'] '.$outputlangs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); switch ($notifcode) { case 'BILL_VALIDATE': - $link='/compta/facture/card.php?facid='.$object->id; + $link = '/compta/facture/card.php?facid='.$object->id; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref); break; case 'BILL_PAYED': - $link='/compta/facture/card.php?facid='.$object->id; + $link = '/compta/facture/card.php?facid='.$object->id; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $newref); break; case 'ORDER_VALIDATE': - $link='/commande/card.php?id='.$object->id; + $link = '/commande/card.php?id='.$object->id; $dir_output = $conf->commande->dir_output; $object_type = 'order'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $newref); break; case 'PROPAL_VALIDATE': - $link='/comm/propal/card.php?id='.$object->id; + $link = '/comm/propal/card.php?id='.$object->id; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $newref); break; case 'PROPAL_CLOSE_SIGNED': - $link='/comm/propal/card.php?id='.$object->id; + $link = '/comm/propal/card.php?id='.$object->id; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $newref); break; case 'FICHINTER_ADD_CONTACT': - $link='/fichinter/card.php?id='.$object->id; + $link = '/fichinter/card.php?id='.$object->id; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $newref); break; case 'FICHINTER_VALIDATE': - $link='/fichinter/card.php?id='.$object->id; + $link = '/fichinter/card.php?id='.$object->id; $dir_output = $conf->ficheinter->dir_output; $object_type = 'ficheinter'; $mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $newref); break; case 'ORDER_SUPPLIER_VALIDATE': - $link='/fourn/commande/card.php?id='.$object->id; + $link = '/fourn/commande/card.php?id='.$object->id; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs)); - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE': - $link='/fourn/commande/card.php?id='.$object->id; + $link = '/fourn/commande/card.php?id='.$object->id; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs)); - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': - $link='/fourn/commande/card.php?id='.$object->id; + $link = '/fourn/commande/card.php?id='.$object->id; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs)); - $mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs)); + $mesg .= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'SHIPPING_VALIDATE': $dir_output = $conf->expedition->dir_output.'/sending/'; @@ -509,7 +509,7 @@ class Notify } $ref = dol_sanitizeFileName($newref); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; - if (! dol_is_file($pdf_path)) + if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; @@ -520,17 +520,17 @@ class Notify } $message = $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; - $message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; - $message.= "\n"; - $message.= $mesg; - if ($link) $message.= "\n" . $urlwithroot . $link; + $message .= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; + $message .= "\n"; + $message .= $mesg; + if ($link) $message .= "\n".$urlwithroot.$link; - $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); - $reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); + $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; - if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; + if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; + if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; } $mailfile = new CMailFile( @@ -556,13 +556,13 @@ class Notify { if ($obj->type_target == 'touserid') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_user, type, objet_type, type_target, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; } else { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, objet_type, type_target, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", ".$obj->cid.", '".$obj->type."', '".$object_type."', '".$obj->type_target."', ".$object->id.", '".$this->db->escape($obj->email)."')"; } - if (! $this->db->query($sql)) + if (!$this->db->query($sql)) { dol_print_error($this->db); } @@ -570,7 +570,7 @@ class Notify else { $error++; - $this->errors[]=$mailfile->error; + $this->errors[] = $mailfile->error; } } else @@ -588,17 +588,17 @@ class Notify else { $error++; - $this->errors[]=$this->db->lasterror(); + $this->errors[] = $this->db->lasterror(); dol_syslog("Failed to get list of notification to send ".$this->db->lasterror(), LOG_ERR); return -1; } // Check notification using fixed email - if (! $error) + if (!$error) { - foreach($conf->global as $key => $val) + foreach ($conf->global as $key => $val) { - if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; + if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue; $threshold = (float) $reg[1]; if (!empty($object->total_ht) && $object->total_ht <= $threshold) @@ -607,7 +607,7 @@ class Notify continue; } - $param='NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; + $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_'.$reg[1]; $sendto = $conf->global->$param; $notifcodedefid = dol_getIdFromCode($this->db, $notifcode, 'c_action_trigger', 'code', 'rowid'); @@ -617,82 +617,82 @@ class Notify $link = ''; $num++; - $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle?' '.$projtitle:''); + $subject = '['.$mysoc->name.'] '.$langs->transnoentitiesnoconv("DolibarrNotification").($projtitle ? ' '.$projtitle : ''); switch ($notifcode) { case 'BILL_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $langs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link); break; case 'BILL_PAYED': - $link ='' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'facture'; $mesg = $langs->transnoentitiesnoconv("EMailTextInvoicePayed", $link); break; case 'ORDER_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->commande->dir_output; $object_type = 'order'; $mesg = $langs->transnoentitiesnoconv("EMailTextOrderValidated", $link); break; case 'PROPAL_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalValidated", $link); break; case 'PROPAL_CLOSE_SIGNED': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->propal->multidir_output[$object->entity]; $object_type = 'propal'; $mesg = $langs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link); break; case 'FICHINTER_ADD_CONTACT': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link); break; case 'FICHINTER_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->facture->dir_output; $object_type = 'ficheinter'; $mesg = $langs->transnoentitiesnoconv("EMailTextInterventionValidated", $link); break; case 'ORDER_SUPPLIER_VALIDATE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_APPROVE2': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->commande->dir_output; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'ORDER_SUPPLIER_REFUSE': - $link = '' . $newref . ''; + $link = ''.$newref.''; $dir_output = $conf->fournisseur->dir_output.'/commande/'; $object_type = 'order_supplier'; $mesg = $langs->transnoentitiesnoconv("Hello").",\n\n"; - $mesg.= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs)); - $mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; + $mesg .= $langs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($langs)); + $mesg .= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n"; break; case 'SHIPPING_VALIDATE': $dir_output = $conf->expedition->dir_output.'/sending/'; @@ -722,7 +722,7 @@ class Notify } $ref = dol_sanitizeFileName($newref); $pdf_path = $dir_output."/".$ref."/".$ref.".pdf"; - if (! dol_is_file($pdf_path)) + if (!dol_is_file($pdf_path)) { // We can't add PDF as it is not generated yet. $filepdf = ''; @@ -733,9 +733,9 @@ class Notify } $message = $langs->transnoentities("YouReceiveMailBecauseOfNotification", $application, $mysoc->name)."\n"; - $message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; - $message.= "\n"; - $message.= $mesg; + $message .= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n"; + $message .= "\n"; + $message .= $mesg; //if ($link) $message.= "\n" . $urlwithroot . $link; // link already added around the ref into the text $message = nl2br($message); @@ -743,28 +743,28 @@ class Notify // Replace keyword __SUPERVISOREMAIL__ if (preg_match('/__SUPERVISOREMAIL__/', $sendto)) { - $newval=''; + $newval = ''; if ($user->fk_user > 0) { - $supervisoruser=new User($this->db); + $supervisoruser = new User($this->db); $supervisoruser->fetch($user->fk_user); - if ($supervisoruser->email) $newval=trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); + if ($supervisoruser->email) $newval = trim(dolGetFirstLastname($supervisoruser->firstname, $supervisoruser->lastname).' <'.$supervisoruser->email.'>'); } dol_syslog("Replace the __SUPERVISOREMAIL__ key into recipient email string with ".$newval); $sendto = preg_replace('/__SUPERVISOREMAIL__/', $newval, $sendto); - $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid - $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string - $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string + $sendto = preg_replace('/,\s*,/', ',', $sendto); // in some case you can have $sendto like "email, __SUPERVISOREMAIL__ , otheremail" then you have "email, , othermail" and it's not valid + $sendto = preg_replace('/^[\s,]+/', '', $sendto); // Clean start of string + $sendto = preg_replace('/[\s,]+$/', '', $sendto); // Clean end of string } if ($sendto) { - $parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); - $reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); + $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { - if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; - if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; + if (!empty($hookmanager->resArray['subject'])) $subject .= $hookmanager->resArray['subject']; + if (!empty($hookmanager->resArray['message'])) $message .= $hookmanager->resArray['message']; } $mailfile = new CMailFile( $subject, @@ -788,8 +788,8 @@ class Notify if ($mailfile->sendfile()) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify (daten, fk_action, fk_soc, fk_contact, type, type_target, objet_type, objet_id, email)"; - $sql.= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid?$object->socid:'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; - if (! $this->db->query($sql)) + $sql .= " VALUES ('".$this->db->idate(dol_now())."', ".$notifcodedefid.", ".($object->socid ? $object->socid : 'null').", null, 'email', 'tofixedemail', '".$object_type."', ".$object->id.", '".$this->db->escape($conf->global->$param)."')"; + if (!$this->db->query($sql)) { dol_print_error($this->db); } @@ -797,13 +797,13 @@ class Notify else { $error++; - $this->errors[]=$mailfile->error; + $this->errors[] = $mailfile->error; } } } } - if (! $error) return $num; + if (!$error) return $num; else return -1 * $error; } } diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 86f5043f1bf..fea8e204aeb 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1311,7 +1311,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $sourceref = !empty($discount->discount_type) ? $discount->ref_invoive_supplier_source : $discount->ref_facture_source; $libelleproduitservice = $outputlangs->transnoentitiesnoconv("DiscountFromDeposit", $sourceref); // Add date of deposit - if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice.= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; + if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) $libelleproduitservice .= ' ('.dol_print_date($discount->datec, 'day', '', $outputlangs).')'; } elseif ($desc == '(EXCESS RECEIVED)' && $object->lines[$i]->fk_remise_except) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 962d3ec9766..0c0c70b5708 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -2099,8 +2099,8 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide if ($diffval >= 0) { // good $out .= '
'; - if(!empty($task->progress)) { - $out .= '
'; + if (!empty($task->progress)) { + $out .= '
'; } $out .= '
'; } 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 f052d6a55f8..22154d40d79 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 @@ -68,37 +68,37 @@ class doc_generic_order_odt extends ModelePDFCommandes global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -110,83 +110,83 @@ class doc_generic_order_odt extends ModelePDFCommandes */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '
'; + print ''; print ''; } @@ -1168,7 +1168,7 @@ if ($object->id > 0) print '
'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").' '.$num.''; print '
'.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").''.$num.'
'; print ''; - print '
'; + print ''; print ''; diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 6e26e732010..9243ee361c1 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -251,7 +251,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa print '
'; print '
'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllBills").' '.$num.''; print ''; print '
'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllBills").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print ''; - print ''; + print ''; if ($num > 0) { @@ -333,7 +333,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'; print '
'.$langs->trans("SupplierProposalsDraft").($num ? ' '.$num.'' : '').'
'.$langs->trans("SupplierProposalsDraft").($num ? ''.$num.'' : '').'
'; print ''; - print ''; + print ''; if ($num > 0) { @@ -422,7 +422,7 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande- print '
'; print '
'.$langs->trans("DraftOrders").($num ? ' '.$num.'' : '').'
'.$langs->trans("DraftOrders").($num ? ''.$num.'' : '').'
'; print ''; - print ''; + print ''; if ($num > 0) { diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 37400ab25a3..ae6b0855f39 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -170,7 +170,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) print '
'; print '
'.$langs->trans("DraftSuppliersOrders").($num ? ' '.$num.'' : '').'
'.$langs->trans("DraftSuppliersOrders").($num ? ''.$num.'' : '').'
'; print ''; - print ''; + print ''; if ($num) { $companystatic = new Societe($db); @@ -257,7 +257,7 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-> print '
'; print '
'.$langs->trans("CustomersDraftInvoices").($num ? ' '.$num.'' : '').'
'.$langs->trans("CustomersDraftInvoices").($num ? ''.$num.'' : '').'
'; print ''; - print ''; + print ''; if ($num) { $companystatic = new Societe($db); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 98af77f2627..2b19050c5b9 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -260,7 +260,7 @@ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) print '
'; print '
'.$langs->trans("SuppliersDraftInvoices").($num ? ' '.$num.'' : '').'
'.$langs->trans("SuppliersDraftInvoices").($num ? ''.$num.'' : '').'
'; print ''; - print ''; + print ''; if ($num) { $companystatic = new Societe($db); diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index ed228294bf5..d9bfc7986c1 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -486,7 +486,7 @@ function actions_prepare_head($object) $nbLinks=Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; + if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ''.($nbFiles+$nbLinks).''; $head[$h][2] = 'documents'; $h++; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index fb9c607eb72..0cb6163aa49 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -185,7 +185,7 @@ function account_statement_prepare_head($object, $num) $head[$h][0] = DOL_URL_ROOT."/compta/bank/account_statement_document.php?account=".$object->id."&num=".$num; $head[$h][1] = $langs->trans("Documents"); - if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ' '.($nbFiles + $nbLinks).''; + if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= ''.($nbFiles + $nbLinks).''; $head[$h][2] = 'document'; $h++; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 90ea0e4fbf6..8435271380f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -228,7 +228,7 @@ function societe_prepare_head(Societe $object) $head[$h][0] = DOL_URL_ROOT.'/societe/paymentmodes.php?socid='.$object->id; $head[$h][1] = $title; - if ($foundonexternalonlinesystem) $head[$h][1] .= ' ...'; + if ($foundonexternalonlinesystem) $head[$h][1] .= '...'; elseif ($nbBankAccount > 0) $head[$h][1] .= ''.$nbBankAccount.''; $head[$h][2] = 'rib'; $h++; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 9b7f9c76efb..962d3ec9766 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -111,7 +111,7 @@ function project_prepare_head($object) if (!empty($object->note_public)) $nbNote++; $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); - if ($nbNote > 0) $head[$h][1] .= ' '.$nbNote.''; + if ($nbNote > 0) $head[$h][1] .= ''.$nbNote.''; $head[$h][2] = 'notes'; $h++; } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 2fabe28728d..9056d1217ca 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -468,7 +468,7 @@ if ($object->id > 0) print '
'.$langs->trans("DraftContracts").($num ? ' '.$num.'' : '').'
'.$langs->trans("DraftContracts").($num ? ''.$num.'' : '').'
'; print ''; print ''; $return = array(); @@ -542,7 +542,7 @@ if ($object->id > 0) print ''; print ''; @@ -653,7 +653,7 @@ if ($object->id > 0) print ''; print ''; @@ -725,7 +725,7 @@ if ($object->id > 0) print ''; print ''; From 18db8dd9007b172be5dd5d4059382d9814fd1fda Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 2 Dec 2019 11:34:35 +0100 Subject: [PATCH 121/248] Fix shown ECM symbols on missing access --- htdocs/core/ajax/ajaxdirpreview.php | 60 ++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index b369550dda2..ef37981369e 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -289,25 +289,49 @@ if ($type == 'directory') } else $textifempty=($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection")); - if ($module == 'medias') - { - $useinecm = 6; - $modulepart='medias'; - $perm=($user->rights->website->write || $user->rights->emailing->creer); - $title='none'; - } - else - { - $useinecm = 5; - $modulepart='ecm'; - $perm=$user->rights->ecm->upload; - $title=''; // Use default - } + if ($module == 'medias') + { + $useinecm = 6; + $modulepart='medias'; + $perm=($user->rights->website->write || $user->rights->emailing->creer); + $title='none'; + } + elseif($module == 'ecm') // DMS/ECM -> manual structure + { + if($user->rights->ecm->read) + { + // Buttons: Preview + $useinecm = 2; + } - // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param - // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath - //var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); - $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); + if($user->rights->ecm->upload) + { + // Buttons: Preview + Delete + $useinecm = 4; + } + + if($user->rights->ecm->setup) + { + // Buttons: Preview + Delete + Edit + $useinecm = 5; + } + + $perm=$user->rights->ecm->upload; + $modulepart='ecm'; + $title=''; // Use default + } + else + { + $useinecm = 5; + $modulepart='ecm'; + $perm=$user->rights->ecm->upload; + $title=''; // Use default + } + + // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param + // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath + //var_dump("title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url); + $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm); } } From d7a8fb98fcab470be944fac7a7501c71c5c731e1 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 2 Dec 2019 13:02:16 +0100 Subject: [PATCH 122/248] Fix style of add folder button based on rights --- htdocs/core/tpl/filemanager.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 9494b414b92..55acf28e3b7 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -81,7 +81,7 @@ if ($permtoadd) else { print ''; - print ''; + print ''; print ''; } if ($module == 'ecm') From f4e4e1e5184d0257a38e80d833dc1cdd5c0f40f5 Mon Sep 17 00:00:00 2001 From: Tobias Sekan Date: Mon, 2 Dec 2019 13:53:28 +0100 Subject: [PATCH 123/248] Add preview for MD, CSS, XAML files --- htdocs/core/lib/functions.lib.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9c5b92a47a0..4db91575a6e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7896,23 +7896,26 @@ function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0) $tmpfile = preg_replace('/\.noexe$/', '', $file); - // Text files + // Plain text files if (preg_match('/\.txt$/i', $tmpfile)) { $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'; } if (preg_match('/\.csv$/i', $tmpfile)) { $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'; } if (preg_match('/\.(cf|conf|log)$/i', $tmpfile)) { $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'; } + if (preg_match('/\.md$/i', $tmpfile)) { $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'; } // Certificate files if (preg_match('/\.(crt|cer|key|pub)$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'text.png'; $famime = 'file-text-o'; } - // HTML/XML + // 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'; } if (preg_match('/\.(xml|xhtml)$/i', $tmpfile)) { $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'; } // Languages if (preg_match('/\.bas$/i', $tmpfile)) { $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'; } if (preg_match('/\.(cpp)$/i', $tmpfile)) { $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'; } if (preg_match('/\.(h)$/i', $tmpfile)) { $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'; } if (preg_match('/\.php([0-9]{1})?$/i', $tmpfile)) { $mime = 'text/plain'; $imgmime = 'php.png'; $srclang = 'php'; $famime = 'file-code-o'; } From 66571df449bac021d2f9fabd8eb5b15dd414994f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Dec 2019 15:19:14 +0100 Subject: [PATCH 124/248] Fix remove a link that is private --- 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 c45688b3557..ece9f4b3d06 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1125,7 +1125,7 @@ TriggerAlwaysActive=Triggers in this file are always active, whatever are the ac TriggerActiveAsModuleActive=Triggers in this file are active as module %s is enabled. GeneratedPasswordDesc=Choose the method to be used for auto-generated passwords. DictionaryDesc=Insert all reference data. You can add your values to the default. -ConstDesc=This page allows you to edit (override) parameters not available in other pages. These are mostly reserved parameters for developers/advanced troubleshooting. For a full list of the parameters available see here. +ConstDesc=This page allows you to edit (override) parameters not available in other pages. These are mostly reserved parameters for developers/advanced troubleshooting only. MiscellaneousDesc=All other security related parameters are defined here. LimitsSetup=Limits/Precision setup LimitsDesc=You can define limits, precisions and optimizations used by Dolibarr here From 310e65b93c7a984fde3fd6699268f7a580ce8507 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Dec 2019 15:23:21 +0100 Subject: [PATCH 125/248] Work on MRP cration --- htdocs/mrp/class/mo.class.php | 14 +++++++++++++- htdocs/mrp/tpl/originproductline.tpl.php | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 725427e249f..cf8e45b5901 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -231,7 +231,19 @@ class Mo extends CommonObject */ public function create(User $user, $notrigger = false) { - return $this->createCommon($user, $notrigger); + $this->db->begin(); + + $result = $this->createCommon($user, $notrigger); + + // Insert lines in mrp_production table + + if ($result > 0) { + $this->db->commit(); + } else { + $this->db->rollback(); + } + + return $result; } /** diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 67032eea7fe..88240e21efb 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -30,8 +30,8 @@ if (empty($conf) || ! is_object($conf)) print ''; print ''; print ''; -print ''; -print ''; +print ''; +print ''; //print ''; $selected=1; From 4846885eea9606fc3d8049b4df63066937970eba Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Mon, 2 Dec 2019 16:54:05 +0100 Subject: [PATCH 126/248] NEW 9.0: enable user to use the mysqldump '--quick' option (useful if the server has low RAM or large tables) --- htdocs/admin/tools/dolibarr_export.php | 9 ++++++++- htdocs/core/class/utils.class.php | 1 + htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/fr_FR/admin.lang | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 231699dc636..d04840e2d71 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -211,7 +211,6 @@ print ''; print ''; // Group @@ -1002,7 +1002,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print ''; print ''; // Severity @@ -1010,7 +1010,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print ''; print ''; } else { From 261e1660299cc74297160ac073bc86e979c8fc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 2 Dec 2019 20:18:12 +0100 Subject: [PATCH 129/248] doxygen --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ef074c6466a..cdb55c66049 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4871,7 +4871,7 @@ class Form * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param int $nooutput No print output. Return it only. - * @return void + * @return void|string */ public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) { From 579f570abf07952358947f8c5213c2455a36e180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 2 Dec 2019 20:42:48 +0100 Subject: [PATCH 130/248] $id parameter was removed long time ago --- htdocs/product/class/product.class.php | 31 +++++++++----------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 68675b3e9dd..0664458f513 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1122,31 +1122,19 @@ class Product extends CommonObject /** * Delete a product from database (if not used) * - * @param User $user Product id (usage of this is deprecated, delete should be called without parameters on a fetched object) + * @param User $user User (object) deleting product * @param int $notrigger Do not execute trigger * @return int < 0 if KO, 0 = Not possible, > 0 if OK */ public function delete(User $user, $notrigger = 0) { - // Deprecation warning - if ($id > 0) { - dol_syslog(__METHOD__." with parameter is deprecated", LOG_WARNING); - } - global $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; - // Clean parameters - if (empty($id)) { - $id = $this->id; - } else { - $this->fetch($id); - } - // Check parameters - if (empty($id)) { + if (empty($this->id)) { $this->error = "Object must be fetched before calling delete"; return -1; } @@ -1155,14 +1143,15 @@ class Product extends CommonObject return 0; } - $objectisused = $this->isObjectUsed($id); + $objectisused = $this->isObjectUsed($this->id); if (empty($objectisused)) { $this->db->begin(); if (!$error && empty($notrigger)) { // Call trigger $result = $this->call_trigger('PRODUCT_DELETE', $user); - if ($result < 0) { $error++; + if ($result < 0) { + $error++; } // End call triggers } @@ -1172,7 +1161,7 @@ class Product extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX.'product_batch'; $sql .= " WHERE fk_product_stock IN ("; $sql .= "SELECT rowid FROM ".MAIN_DB_PREFIX.'product_stock'; - $sql .= " WHERE fk_product = ".$id.")"; + $sql .= " WHERE fk_product = ".(int) $this->id.")"; $result = $this->db->query($sql); if (!$result) { @@ -1188,7 +1177,7 @@ class Product extends CommonObject { if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$table; - $sql .= " WHERE fk_product = ".$id; + $sql .= " WHERE fk_product = ".(int) $this->id; $result = $this->db->query($sql); if (!$result) { @@ -1206,7 +1195,7 @@ class Product extends CommonObject //If it is a parent product, then we remove the association with child products $prodcomb = new ProductCombination($this->db); - if ($prodcomb->deleteByFkProductParent($user, $id) < 0) { + if ($prodcomb->deleteByFkProductParent($user, $this->id) < 0) { $error++; $this->errors[] = 'Error deleting combinations'; } @@ -1221,7 +1210,7 @@ class Product extends CommonObject // Delete from product_association if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_association"; - $sql .= " WHERE fk_product_pere = ".$id." OR fk_product_fils = ".$id; + $sql .= " WHERE fk_product_pere = ".(int) $this->id." OR fk_product_fils = ".(int) $this->id; $result = $this->db->query($sql); if (!$result) { @@ -1233,7 +1222,7 @@ class Product extends CommonObject // Delete product if (!$error) { $sqlz = "DELETE FROM ".MAIN_DB_PREFIX."product"; - $sqlz .= " WHERE rowid = ".$id; + $sqlz .= " WHERE rowid = ".(int) $this->id; $resultz = $this->db->query($sqlz); if (!$resultz) { From ac674aae6af79d077516390f2e632f7a3fbb50e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 2 Dec 2019 20:45:28 +0100 Subject: [PATCH 131/248] Update product.class.php --- htdocs/product/class/product.class.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 68675b3e9dd..e6ffd8888b3 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1308,7 +1308,7 @@ class Product extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$this->id; - $sql .= " AND lang='".$key."'"; + $sql .= " AND lang='".$this->db->escape($key)."'"; $result = $this->db->query($sql); @@ -1330,7 +1330,8 @@ class Product extends CommonObject $sql2 .= ")"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',"; $sql2 .= " '".$this->db->escape($this->description)."'"; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->other)."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { + $sql2 .= ", '".$this->db->escape($this->other)."'"; } $sql2 .= ")"; } @@ -1344,7 +1345,7 @@ class Product extends CommonObject $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; $sql .= " WHERE fk_product=".$this->id; - $sql .= " AND lang='".$key."'"; + $sql .= " AND lang='".$this->db->escape($key)."'"; $result = $this->db->query($sql); @@ -1354,7 +1355,8 @@ class Product extends CommonObject $sql2 .= " SET "; $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { + $sql2 .= ", note='".$this->db->escape($this->multilangs["$key"]["other"])."'"; } $sql2 .= " WHERE fk_product=".$this->id." AND lang='".$this->db->escape($key)."'"; } @@ -1366,7 +1368,8 @@ class Product extends CommonObject $sql2 .= ")"; $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',"; $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'"; - if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; + if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) { + $sql2 .= ", '".$this->db->escape($this->multilangs["$key"]["other"])."'"; } $sql2 .= ")"; } From 15715aa12c933b7ee7dc90becd748e3e0410f35a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 2 Dec 2019 23:53:01 +0100 Subject: [PATCH 132/248] FIX not fee in payout list --- htdocs/stripe/payout.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/stripe/payout.php b/htdocs/stripe/payout.php index 0149775c360..b975680838e 100644 --- a/htdocs/stripe/payout.php +++ b/htdocs/stripe/payout.php @@ -107,7 +107,6 @@ if (! $rowid) { print_liste_field_titre("DateOperation", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'left '); print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Fee", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right '); print "\n"; @@ -205,7 +204,6 @@ if (! $rowid) { print ''; // Amount print '"; - print '"; // Status print "'; - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { print ''; } print ''; print ''; } -print ''; -$coldisplay=0; +print ''; +$coldisplay = 0; // Adds a line numbering column -if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { +if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay++; echo ''; } @@ -87,15 +87,15 @@ $coldisplay++; print ''; -if($conf->global->PRODUCT_USE_UNITS) +if ($conf->global->PRODUCT_USE_UNITS) { $coldisplay++; print ''; $coldisplay++; -print ''; //$coldisplay++; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 46ce0c78345..0d3c5de514d 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -63,7 +63,7 @@ class AgendaEvents extends DolibarrApi */ public function get($id) { - if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insufficient rights to read an event"); } if ($id == 0) { @@ -75,15 +75,15 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->fetchObjectLinked(); } } - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Agenda Events not found'); } - if (! DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { + if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, "Insufficient rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + if (!DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } return $this->_cleanObjectDatas($this->actioncomm); @@ -108,30 +108,30 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); - if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insufficient rights to read events"); } // case of external user $socid = 0; - if (! empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; + if (!empty(DolibarrApiAccess::$user->socid)) $socid = DolibarrApiAccess::$user->socid; // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; - if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) $search_sale = DolibarrApiAccess::$user->id; + if (empty($conf->societe->enabled)) $search_sale = 0; // If module thirdparty not enabled, sale representative is something that does not exists $sql = "SELECT t.id as rowid"; - if (! empty($conf->societe->enabled)) + if (!empty($conf->societe->enabled)) if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; - if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; - if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; - if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('agenda').')'; + if (!empty($conf->societe->enabled)) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($user_ids) $sql .= " AND t.fk_user_action IN (".$user_ids.")"; + if ($socid > 0) $sql .= " AND t.fk_soc = ".$socid; // Insert sale filter if ($search_sale > 0) { @@ -140,30 +140,30 @@ class AgendaEvents extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } $result = $db->query($sql); if ($result) { - $i=0; + $i = 0; $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); while ($i < $min) @@ -179,7 +179,7 @@ class AgendaEvents extends DolibarrApi else { throw new RestException(503, 'Error when retrieve Agenda Event list : '.$db->lasterror()); } - if ( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No Agenda Event found'); } return $obj_ret; @@ -193,17 +193,17 @@ class AgendaEvents extends DolibarrApi */ public function post($request_data = null) { - if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } - if (! DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->actioncomm->$field = $value; } /*if (isset($request_data["lines"])) { @@ -273,7 +273,7 @@ class AgendaEvents extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { + if (!DolibarrApiAccess::$user->rights->agenda->myactions->delete) { throw new RestException(401, "Insufficient rights to delete your Agenda Event"); } @@ -284,19 +284,19 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->oldcopy = clone $this->actioncomm; } - if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { + if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Agenda Event not found'); } - if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { + if (!DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { + if (!$this->actioncomm->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); } @@ -338,7 +338,7 @@ class AgendaEvents extends DolibarrApi // phpcs:enable $object = parent::_cleanObjectDatas($object); - unset($object->note); // alreaydy into note_private + unset($object->note); // alreaydy into note_private unset($object->usermod); unset($object->libelle); unset($object->context); diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 476f94c8937..2a56122d6f3 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -39,7 +39,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Security check $socid = GETPOST("socid", "int"); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'banque', '', '', ''); // Get parameters @@ -74,50 +74,50 @@ include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; $form = new Form($db); -$title = $langs->trans("VariousPayment") . ' - ' . $langs->trans("Documents"); +$title = $langs->trans("VariousPayment").' - '.$langs->trans("Documents"); $help_url = ''; llxHeader("", $title, $help_url); if ($object->id) { - $head=various_payment_prepare_head($object); + $head = various_payment_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans("VariousPayment"), -1, $object->picto); - $morehtmlref='
'; + $morehtmlref = '
'; // Project - if (! empty($conf->projet->enabled)) + if (!empty($conf->projet->enabled)) { $langs->load("projects"); - $morehtmlref.=$langs->trans('Project') . ' : '; + $morehtmlref .= $langs->trans('Project').' : '; if ($user->rights->banque->modifier && 0) { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.=''; + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects(0, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } } else { - if (! empty($object->fk_project)) { + if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(1); + $morehtmlref .= $proj->getNomUrl(1); } else { - $morehtmlref.=''; + $morehtmlref .= ''; } } } - $morehtmlref.='
'; - $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref .= '
'; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index c3714b28360..9975357fc23 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -52,44 +52,44 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicetemplatelist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search // Security check -$id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int')); -$lineid=GETPOST('lineid', 'int'); -$ref=GETPOST('ref', 'alpha'); -if ($user->socid) $socid=$user->socid; +$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); +$lineid = GETPOST('lineid', 'int'); +$ref = GETPOST('ref', 'alpha'); +if ($user->socid) $socid = $user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); $projectid = GETPOST('projectid', 'int'); -$search_ref=GETPOST('search_ref'); -$search_societe=GETPOST('search_societe'); -$search_montant_ht=GETPOST('search_montant_ht'); -$search_montant_vat=GETPOST('search_montant_vat'); -$search_montant_ttc=GETPOST('search_montant_ttc'); -$search_payment_mode=GETPOST('search_payment_mode'); -$search_payment_term=GETPOST('search_payment_term'); -$search_day=GETPOST('search_day', 'int'); -$search_year=GETPOST('search_year', 'int'); -$search_month=GETPOST('search_month', 'int'); -$search_day_date_when=GETPOST('search_day_date_when', 'int'); -$search_year_date_when=GETPOST('search_year_date_when', 'int'); -$search_month_date_when=GETPOST('search_month_date_when', 'int'); -$search_recurring=GETPOST('search_recurring', 'int'); -$search_frequency=GETPOST('search_frequency', 'alpha'); -$search_unit_frequency=GETPOST('search_unit_frequency', 'alpha'); -$search_status=GETPOST('search_status', 'int'); +$search_ref = GETPOST('search_ref'); +$search_societe = GETPOST('search_societe'); +$search_montant_ht = GETPOST('search_montant_ht'); +$search_montant_vat = GETPOST('search_montant_vat'); +$search_montant_ttc = GETPOST('search_montant_ttc'); +$search_payment_mode = GETPOST('search_payment_mode'); +$search_payment_term = GETPOST('search_payment_term'); +$search_day = GETPOST('search_day', 'int'); +$search_year = GETPOST('search_year', 'int'); +$search_month = GETPOST('search_month', 'int'); +$search_day_date_when = GETPOST('search_day_date_when', 'int'); +$search_year_date_when = GETPOST('search_year_date_when', 'int'); +$search_month_date_when = GETPOST('search_month_date_when', 'int'); +$search_recurring = GETPOST('search_recurring', 'int'); +$search_frequency = GETPOST('search_frequency', 'alpha'); +$search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); +$search_status = GETPOST('search_status', 'int'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='f.titre'; +if (!$sortorder) $sortorder = 'DESC'; +if (!$sortfield) $sortfield = 'f.titre'; $pageprev = $page - 1; $pagenext = $page + 1; @@ -206,40 +206,40 @@ llxHeader('', $langs->trans("RepeatableInvoices"), 'ch-facture.html#s-fac-factur $form = new Form($db); $formother = new FormOther($db); -if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } +if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } $companystatic = new Societe($db); $invoicerectmp = new FactureRec($db); $now = dol_now(); -$tmparray=dol_getdate($now); -$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day +$tmparray = dol_getdate($now); +$today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day /* * List mode */ $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,"; -$sql.= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; -$sql.= " f.datec, f.tms,"; -$sql.= " f.fk_cond_reglement, f.fk_mode_reglement"; +$sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; +$sql .= " f.datec, f.tms,"; +$sql .= " f.fk_cond_reglement, f.fk_mode_reglement"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook -$sql.=preg_replace('/^,/', '', $hookmanager->resPrint); -$sql =preg_replace('/,\s*$/', '', $sql); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); +$sql = preg_replace('/,\s*$/', '', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid"; -if (! $user->rights->societe->client->voir && ! $socid) { +$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as f"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_rec_extrafields as ef ON ef.fk_object = f.rowid"; +if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= ' AND f.entity IN ('.getEntity('invoice').')'; -if (! $user->rights->societe->client->voir && ! $socid) { +$sql .= " WHERE f.fk_soc = s.rowid"; +$sql .= ' AND f.entity IN ('.getEntity('invoice').')'; +if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($search_ref) $sql .= natural_search('f.titre', $search_ref); @@ -333,126 +333,126 @@ if ($resql) $i = 0; print '
'; - print '
'.$langs->trans("ProductsAndServices").''; - print ''.$langs->trans("AllProductReferencesOfSupplier").' '.$object->nbOfProductRefs().''; + print ''.$langs->trans("AllProductReferencesOfSupplier").''.$object->nbOfProductRefs().''; print '
'; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("LastSupplierProposals", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllPriceRequests").' '.$num.''.$langs->trans("AllPriceRequests").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print '
'; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("LastSupplierOrders", ($num < $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllOrders").' '.$num.''.$langs->trans("AllOrders").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print '
'; - print ''; + print '
'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans('AllBills').' '.$num.'
'; print ''; print '
'.$langs->trans('LastSuppliersBills', ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans('AllBills').''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; print '
'.$this->tpl['label'].''.$this->tpl['qty'].''.yn($this->tpl['qty_frozen']).''.yn($this->tpl['disable_stock_change']).''.($this->tpl['qty_frozen'] ? yn($this->tpl['qty_frozen']) : '').''.($this->tpl['disable_stock_change'] ? yn($this->tpl['disable_stock_change']) : '').''.$this->tpl['efficiency'].'
';
-
global->MYSQL_OLD_OPTION_DISABLE_FK)) { ?> @@ -234,6 +233,14 @@ print '
';
+ + +
diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 6b6d2d42c67..8ce4cca7ca6 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -262,6 +262,7 @@ class Utils if (GETPOST("disable_fk", "alpha") || $usedefault) $param.=" -K"; if (GETPOST("sql_compat", "alpha") && GETPOST("sql_compat", "alpha") != 'NONE') $param.=" --compatible=".escapeshellarg(GETPOST("sql_compat", "alpha")); if (GETPOST("drop_database", "alpha")) $param.=" --add-drop-database"; + if (GETPOST("use_mysql_quick_param", "alpha"))$param.=" --quick"; if (GETPOST("sql_structure", "alpha") || $usedefault) { if (GETPOST("drop", "alpha") || $usedefault) $param.=" --add-drop-table=TRUE"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d70bfe959e9..b477298f88a 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -174,6 +174,8 @@ Compression=Compression CommandsToDisableForeignKeysForImport=Command to disable foreign keys on import CommandsToDisableForeignKeysForImportWarning=Mandatory if you want to be able to restore your sql dump later ExportCompatibility=Compatibility of generated export file +ExportUseMySQLQuickParameter=Use the --quick parameter +ExportUseMySQLQuickParameterHelp=The '--quick' parameter helps limit RAM consumption for large tables. MySqlExportParameters=MySQL export parameters PostgreSqlExportParameters= PostgreSQL export parameters UseTransactionnalMode=Use transactional mode diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 4b7cb82e4d4..8abb4dd8d29 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -174,6 +174,8 @@ Compression=Compression CommandsToDisableForeignKeysForImport=Commande pour désactiver les clés étrangères à l'importation CommandsToDisableForeignKeysForImportWarning=Requis si vous voulez être en mesure de restaurer votre « dump » SQL plus tard ExportCompatibility=Compatibilité du fichier d'exportation généré +ExportUseMySQLQuickParameter=Utiliser le paramètre --quick +ExportUseMySQLQuickParameterHelp=permet de limiter la consommation de mémoire vive (utile en cas de tables volumineuses) MySqlExportParameters=Paramètres de l'exportation MySQL PostgreSqlExportParameters= Paramètres de l'exportation PostgreSQL UseTransactionnalMode=Utiliser le mode transactionnel From 3b72cade4ed2fb9bbb529ed3aaf6b072f1659eea Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 2 Dec 2019 17:32:06 +0100 Subject: [PATCH 127/248] Fix exif image with conf MAIN_USE_EXIF_ROTATION --- htdocs/core/lib/images.lib.php | 166 +++++++++++++++++++++++++++------ htdocs/document.php | 14 ++- 2 files changed, 152 insertions(+), 28 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 2f7406bbaf9..bd0e9b5da79 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -306,35 +306,94 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, */ function dolRotateImage($file_path) { - $exif = @exif_read_data($file_path); - if ($exif === false) { - return false; - } - $orientation = intval(@$exif['Orientation']); - if (!in_array($orientation, array(3, 6, 8))) { - return false; - } - $image = @imagecreatefromjpeg($file_path); - switch ($orientation) { - case 3: - $image = @imagerotate($image, 180, 0); - break; - case 6: - $image = @imagerotate($image, 270, 0); - break; - case 8: - $image = @imagerotate($image, 90, 0); - break; - default: - return false; - } - $success = imagejpeg($image, $file_path); - // Free up memory (imagedestroy does not delete files): - @imagedestroy($image); - return $success; + return correctExifImageOrientation($file_path, $file_path); } +/** + * Add exif orientation correction for image + * + * @param $fileSource string + * @param $fileDest string | false | null : on false return gd img on null , on NULL the raw image stream will be outputted directly + * @param $quality int + * @return bool true on success or false on failure or gd img if $fileDest is false. + */ +function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) +{ + if (function_exists('exif_read_data') ) { + $exif = exif_read_data($fileSource); + if($exif && isset($exif['Orientation'])) { + + $infoImg = getimagesize($fileSource); // Get image infos + + $orientation = $exif['Orientation']; + if($orientation != 1){ + $img = imagecreatefromjpeg($fileSource); + $deg = 0; + switch ($orientation) { + case 3: + $deg = 180; + break; + case 6: + $deg = 270; + break; + case 8: + $deg = 90; + break; + } + if ($deg) { + if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + { + imagealphablending($img, false); + imagesavealpha($img, true); + $img = imagerotate($img, $deg, imageColorAllocateAlpha($img, 0, 0, 0, 127)); + imagealphablending($img, false); + imagesavealpha($img, true); + } + else{ + $img = imagerotate($img, $deg, 0); + } + } + // then rewrite the rotated image back to the disk as $fileDest + if($fileDest === false){ + return $img; + } + else + { + // In fact there exif is only for JPG but just in case + // Create image on disk + $image = false; + + switch($infoImg[2]) + { + case IMAGETYPE_GIF: // 1 + $image = imagegif($img, $fileDest); + break; + case IMAGETYPE_JPEG: // 2 + return imagejpeg($img, $fileDest, $quality); + break; + case IMAGETYPE_PNG: // 3 + $image = imagepng($img, $fileDest, $quality); + break; + case IMAGETYPE_BMP: // 6 + // Not supported by PHP GD + break; + case IMAGETYPE_WBMP: // 15 + $image = image2wbmp($img, $fileDest); + break; + } + + // Free up memory (imagedestroy does not delete files): + @imagedestroy($img); + + return $image; + } + } // if there is some rotation necessary + } // if have the exif orientation info + } // if function exists + + return false; +} /** * Create a thumbnail from an image file (Supported extensions are gif, jpg, png and bmp). @@ -394,6 +453,13 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $imgWidth = $infoImg[0]; // Largeur de l'image $imgHeight = $infoImg[1]; // Hauteur de l'image + $exif = exif_read_data($filetoread); + $ort= false; + if($exif && !empty($exif['Orientation'])){ + $ort = $exif['Orientation']; + } + + if ($maxWidth == -1) $maxWidth=$infoImg[0]; // If size is -1, we keep unchanged if ($maxHeight == -1) $maxHeight=$infoImg[1]; // If size is -1, we keep unchanged @@ -467,6 +533,54 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING); return 0; } + $exifAngle = false; + if($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)){ + + switch($ort) + { + case 3: // 180 rotate left + $exifAngle = 180; + break; + case 6: // 90 rotate right + $exifAngle = -90; + // changing sizes + $trueImgWidth = $infoImg[1]; + $trueImgHeight = $infoImg[0]; + break; + case 8: // 90 rotate left + $exifAngle = 90; + // changing sizes + $trueImgWidth = $infoImg[1]; // Largeur de l'image + $trueImgHeight = $infoImg[0]; // Hauteur de l'image + break; + } + } + + if($exifAngle) + { + $rotated = false; + + if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + { + imagealphablending($img, false); + imagesavealpha($img, true); + $rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127)); + imagealphablending($rotated, false); + imagesavealpha($rotated, true); + } + else{ + $rotated = imagerotate($img, $exifAngle, 0); + } + + // replace image with good orientation + if(!empty($rotated)){ + $img = $rotated; + $imgWidth = $trueImgWidth; + $imgHeight = $trueImgHeight; + } + } + + // Initialisation des dimensions de la vignette si elles sont superieures a l'original if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } diff --git a/htdocs/document.php b/htdocs/document.php index 2b37792d69a..991b0f3e861 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -71,6 +71,7 @@ function llxFooter() require 'main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $encoding = ''; $action=GETPOST('action', 'alpha'); @@ -250,11 +251,20 @@ if ($encoding) header('Content-Encoding: '.$encoding); // Add MIME Content-Disposition from RFC 2183 (inline=automatically displayed, attachment=need user action to open) if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"'); else header('Content-Disposition: inline; filename="'.$filename.'"'); -header('Content-Length: ' . dol_filesize($fullpath_original_file)); // Ajout directives pour resoudre bug IE header('Cache-Control: Public, must-revalidate'); header('Pragma: public'); +$readfile = true; -readfile($fullpath_original_file_osencoded); +// on view document, can output images with good orientation according to exif infos +if (!$attachment && !empty($conf->global->MAIN_USE_EXIF_ROTATION) && image_format_supported($fullpath_original_file_osencoded) == 1) { + $imgres = correctExifImageOrientation($fullpath_original_file_osencoded, null); + $readfile = !$imgres; +} + +if($readfile){ + header('Content-Length: ' . dol_filesize($fullpath_original_file)); + readfile($fullpath_original_file_osencoded); +} if (is_object($db)) $db->close(); From 09b8f321cee3a115a622c88ee377ede86f580a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 2 Dec 2019 20:16:35 +0100 Subject: [PATCH 128/248] functions return void --- htdocs/ticket/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index cc7f5a60dbb..9b24a8b68c6 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -994,7 +994,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd print '
'; print $langs->trans('TicketChangeType'); print ''; - print $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2); + $formticket->selectTypesTickets($object->type_code, 'update_value_type', '', 2); print '
'; print $langs->trans('TicketChangeCategory'); print ''; - print $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2); + $formticket->selectGroupTickets($object->category_code, 'update_value_category', '', 2); print '
'; print $langs->trans('TicketChangeSeverity'); print ''; - print $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); + $formticket->selectSeveritiesTickets($object->severity_code, 'update_value_severity', '', 2); print '
' . $payout->description . '' . price(($payout->amount) / 100, 0, '', 1, - 1, - 1, strtoupper($payout->currency)) . "' . price(($payout->fee) / 100, 0, '', 1, - 1, - 1, strtoupper($payout->currency)) . ""; if ($payout->status=='paid') { From b67fb8be0267a69d7476c97236d018da411cc1fb Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 3 Dec 2019 00:14:05 +0100 Subject: [PATCH 133/248] Fix stripe menu --- htdocs/core/modules/modStripe.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index ae15e763fd8..40c4b31cded 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -150,7 +150,9 @@ class modStripe extends DolibarrModules 'target' => '', 'user' => 0 ); - $this->menu[$r] = array( + + $r++; + $this->menu[$r] = array( 'fk_menu' => 'fk_mainmenu=bank,fk_leftmenu=stripe', 'type' => 'left', 'titre' => 'StripePayoutList', From 2b01576aa96e1995025ee4cbde2454b583909c2a Mon Sep 17 00:00:00 2001 From: John Botella Date: Tue, 3 Dec 2019 09:24:11 +0100 Subject: [PATCH 134/248] Fix comment --- htdocs/core/lib/images.lib.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index bd0e9b5da79..37627a15bf9 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -313,10 +313,10 @@ function dolRotateImage($file_path) /** * Add exif orientation correction for image * - * @param $fileSource string - * @param $fileDest string | false | null : on false return gd img on null , on NULL the raw image stream will be outputted directly - * @param $quality int - * @return bool true on success or false on failure or gd img if $fileDest is false. + * @param string $fileSource Full path to source image to rotate + * @param string $fileDest string : Full path to image to rotate | false return gd img | null the raw image stream will be outputted directly + * @param int $quality + * @return bool : true on success or false on failure or gd img if $fileDest is false. */ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) { From f806c0da78e8caef3aabd5f1346aca60b84e6df3 Mon Sep 17 00:00:00 2001 From: John Botella Date: Tue, 3 Dec 2019 09:29:04 +0100 Subject: [PATCH 135/248] Fix comment missing --- htdocs/core/lib/images.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 37627a15bf9..6204dd0dd9f 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -315,7 +315,7 @@ function dolRotateImage($file_path) * * @param string $fileSource Full path to source image to rotate * @param string $fileDest string : Full path to image to rotate | false return gd img | null the raw image stream will be outputted directly - * @param int $quality + * @param int $quality output image quality * @return bool : true on success or false on failure or gd img if $fileDest is false. */ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) From 36a74cd160562779a7301aa26422a5603f181dfe Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Tue, 3 Dec 2019 10:17:29 +0000 Subject: [PATCH 136/248] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/bom/tpl/objectline_create.tpl.php | 26 +- .../action/class/api_agendaevents.class.php | 68 +- .../compta/bank/various_payment/document.php | 38 +- .../compta/facture/invoicetemplate_list.php | 274 +++--- htdocs/contact/class/contact.class.php | 188 ++-- .../boxes/box_graph_invoices_permonth.php | 140 +-- .../box_graph_invoices_supplier_permonth.php | 142 +-- .../core/boxes/box_graph_orders_permonth.php | 140 +-- .../box_graph_orders_supplier_permonth.php | 140 +-- .../boxes/box_graph_product_distribution.php | 218 ++--- .../boxes/box_graph_propales_permonth.php | 140 +-- htdocs/core/boxes/box_task.php | 18 +- htdocs/core/class/html.formbarcode.class.php | 52 +- htdocs/core/class/html.formmail.class.php | 920 +++++++++--------- htdocs/core/class/notify.class.php | 276 +++--- htdocs/core/lib/pdf.lib.php | 2 +- htdocs/core/lib/project.lib.php | 4 +- .../doc/doc_generic_order_odt.modules.php | 282 +++--- .../modules/commande/mod_commande_saphir.php | 66 +- .../doc/doc_generic_contract_odt.modules.php | 258 ++--- .../modules/contract/mod_contract_magre.php | 40 +- .../expedition/doc/pdf_rouget.modules.php | 472 ++++----- .../doc/doc_generic_product_odt.modules.php | 248 ++--- .../product/mod_codeproduct_elephant.php | 110 +-- .../modules/project/mod_project_universal.php | 66 +- .../task/doc/doc_generic_task_odt.modules.php | 350 +++---- .../project/task/mod_task_universal.php | 68 +- .../doc/doc_generic_proposal_odt.modules.php | 318 +++--- .../modules/propale/mod_propale_saphir.php | 66 +- .../societe/doc/doc_generic_odt.modules.php | 230 ++--- .../societe/mod_codeclient_elephant.php | 126 +-- .../societe/mod_codecompta_aquarium.php | 104 +- .../societe/mod_codecompta_digitaria.php | 108 +- htdocs/core/tpl/extrafields_view.tpl.php | 68 +- htdocs/core/tpl/objectline_create.tpl.php | 132 +-- htdocs/core/tpl/resource_add.tpl.php | 14 +- htdocs/datapolicy/admin/setup.php | 4 +- htdocs/loan/class/loan.class.php | 248 ++--- htdocs/loan/schedule.php | 40 +- htdocs/margin/productMargins.php | 160 +-- htdocs/margin/tabs/productMargins.php | 124 +-- .../class/opensurveysondage.class.php | 286 +++--- htdocs/opensurvey/list.php | 134 +-- htdocs/product/card.php | 22 +- htdocs/product/class/product.class.php | 756 +++++++------- .../product/stock/tpl/stockcorrection.tpl.php | 24 +- .../product/stock/tpl/stocktransfer.tpl.php | 32 +- htdocs/societe/admin/societe.php | 232 ++--- htdocs/societe/contact.php | 22 +- htdocs/user/agenda_extsites.php | 76 +- 50 files changed, 4036 insertions(+), 4036 deletions(-) diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index a32110f782f..7f3072d8051 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -50,10 +50,10 @@ $objectline = new BOMLine($this->db); print "\n"; -$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); +$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { print '
'; @@ -74,11 +74,11 @@ if ($nolinesbefore) { print ' 
'; // Predefined product/service -if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) +if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { if ($forceall >= 0 && $freelines) echo '
'; echo ''; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + $filtertype = ''; + if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1'; $statustoshow = -1; - if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) + if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); @@ -109,10 +109,10 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) } $coldisplay++; -print '
'; +print ''; print ''; @@ -121,11 +121,11 @@ if($conf->global->PRODUCT_USE_UNITS) } $coldisplay++; -print ''; +print ''; print ''; +print ''; print '
'."\n"; + print '
'."\n"; // Filters lines print ''; // Ref - if (! empty($arrayfields['f.titre']['checked'])) + if (!empty($arrayfields['f.titre']['checked'])) { print ''; } // Thirpdarty - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (! empty($arrayfields['f.total']['checked'])) + if (!empty($arrayfields['f.total']['checked'])) { // Amount net print ''; } - if (! empty($arrayfields['f.tva']['checked'])) + if (!empty($arrayfields['f.tva']['checked'])) { // Amount Vat print ''; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { // Amount print ''; } - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { // Payment term print '"; } - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { // Payment mode print ''; } - if (! empty($arrayfields['recurring']['checked'])) + if (!empty($arrayfields['recurring']['checked'])) { // Recurring or not print ''; } - if (! empty($arrayfields['f.frequency']['checked'])) + if (!empty($arrayfields['f.frequency']['checked'])) { // Recurring or not print ''; } - if (! empty($arrayfields['f.unit_frequency']['checked'])) + if (!empty($arrayfields['f.unit_frequency']['checked'])) { // Frequency unit print ''; } - if (! empty($arrayfields['f.nb_gen_done']['checked'])) + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { // Nb generation print ''; } // Date invoice - if (! empty($arrayfields['f.date_last_gen']['checked'])) + if (!empty($arrayfields['f.date_last_gen']['checked'])) { print ''; } // Date next generation - if (! empty($arrayfields['f.date_when']['checked'])) + if (!empty($arrayfields['f.date_when']['checked'])) { print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; } // Date modification - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; } // Status - if (! empty($arrayfields['status']['checked'])) + if (!empty($arrayfields['status']['checked'])) { print ''; print "\n"; print ''; - if (! empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); - if (! empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); - if (! empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total']['checked'])) print_liste_field_titre($arrayfields['f.total']['label'], $_SERVER['PHP_SELF'], "f.total", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.tva']['checked'])) print_liste_field_titre($arrayfields['f.tva']['label'], $_SERVER['PHP_SELF'], "f.tva", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER['PHP_SELF'], "f.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['recurring']['checked'])) print_liste_field_titre($arrayfields['recurring']['label'], $_SERVER['PHP_SELF'], "recurring", "", $param, 'class="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.frequency']['checked'])) print_liste_field_titre($arrayfields['f.frequency']['label'], $_SERVER['PHP_SELF'], "f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.unit_frequency']['checked'])) print_liste_field_titre($arrayfields['f.unit_frequency']['label'], $_SERVER['PHP_SELF'], "f.unit_frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.nb_gen_done']['checked'])) print_liste_field_titre($arrayfields['f.nb_gen_done']['label'], $_SERVER['PHP_SELF'], "f.nb_gen_done", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_last_gen']['checked'])) print_liste_field_titre($arrayfields['f.date_last_gen']['label'], $_SERVER['PHP_SELF'], "f.date_last_gen", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_when']['checked'])) print_liste_field_titre($arrayfields['f.date_when']['label'], $_SERVER['PHP_SELF'], "f.date_when", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'], $_SERVER['PHP_SELF'], "f.datec", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.tms']['checked'])) print_liste_field_titre($arrayfields['f.tms']['label'], $_SERVER['PHP_SELF'], "f.tms", "", $param, 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'], $_SERVER['PHP_SELF'], "f.suspended,f.frequency", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'nomaxwidthsearch '); print "\n"; if ($num > 0) { - $i=0; - $totalarray=array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); if (empty($objp)) break; - $companystatic->id=$objp->socid; - $companystatic->name=$objp->name; + $companystatic->id = $objp->socid; + $companystatic->name = $objp->name; - $invoicerectmp->id=$objp->id?$objp->id:$objp->facid; - $invoicerectmp->frequency=$objp->frequency; - $invoicerectmp->suspended=$objp->suspended; - $invoicerectmp->unit_frequency=$objp->unit_frequency; - $invoicerectmp->nb_gen_max=$objp->nb_gen_max; - $invoicerectmp->nb_gen_done=$objp->nb_gen_done; - $invoicerectmp->ref=$objp->title; + $invoicerectmp->id = $objp->id ? $objp->id : $objp->facid; + $invoicerectmp->frequency = $objp->frequency; + $invoicerectmp->suspended = $objp->suspended; + $invoicerectmp->unit_frequency = $objp->unit_frequency; + $invoicerectmp->nb_gen_max = $objp->nb_gen_max; + $invoicerectmp->nb_gen_done = $objp->nb_gen_done; + $invoicerectmp->ref = $objp->title; print ''; - if (! empty($arrayfields['f.titre']['checked'])) + if (!empty($arrayfields['f.titre']['checked'])) { print '\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['s.nom']['checked'])) + if (!empty($arrayfields['s.nom']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.total']['checked'])) + if (!empty($arrayfields['f.total']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; $totalarray['val']['f.total'] += $objp->total; } - if (! empty($arrayfields['f.tva']['checked'])) + if (!empty($arrayfields['f.tva']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.tva'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; $totalarray['val']['f.tva'] += $objp->total_vat; } - if (! empty($arrayfields['f.total_ttc']['checked'])) + if (!empty($arrayfields['f.total_ttc']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; $totalarray['val']['f.total_ttc'] += $objp->total_ttc; } // Payment term - if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Payment mode - if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { print ''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['recurring']['checked'])) + if (!empty($arrayfields['recurring']['checked'])) { - print ''; - if (! $i) $totalarray['nbfield']++; + print ''; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.frequency']['checked'])) + if (!empty($arrayfields['f.frequency']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.unit_frequency']['checked'])) + if (!empty($arrayfields['f.unit_frequency']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.nb_gen_done']['checked'])) + if (!empty($arrayfields['f.nb_gen_done']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date last generation - if (! empty($arrayfields['f.date_last_gen']['checked'])) + if (!empty($arrayfields['f.date_last_gen']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date next generation - if (! empty($arrayfields['f.date_when']['checked'])) + if (!empty($arrayfields['f.date_when']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.datec']['checked'])) + if (!empty($arrayfields['f.datec']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } - if (! empty($arrayfields['f.tms']['checked'])) + if (!empty($arrayfields['f.tms']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } $obj = $objp; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$objp, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Status - if (! empty($arrayfields['status']['checked'])) { + if (!empty($arrayfields['status']['checked'])) { print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Action column print '\n"; + $out .= "\n"; } // Message - if (! empty($this->withbody)) + if (!empty($this->withbody)) { - $defaultmessage=GETPOST('message', 'none'); - if (! GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') + $defaultmessage = GETPOST('message', 'none'); + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { if ($arraydefaultmessage && $arraydefaultmessage->content) { $defaultmessage = $arraydefaultmessage->content; - } elseif (! is_numeric($this->withbody)) { + } elseif (!is_numeric($this->withbody)) { $defaultmessage = $this->withbody; } } // Complete substitution array with the url to make online payment - $paymenturl=''; $validpaymentmethod=array(); + $paymenturl = ''; $validpaymentmethod = array(); if (empty($this->substit['__REF__'])) { - $paymenturl=''; + $paymenturl = ''; } else { // Set the online payment url link into __ONLINE_PAYMENT_URL__ key require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; - $langs->loadLangs(array('paypal','other')); - $typeforonlinepayment='free'; - if ($this->param["models"]=='order' || $this->param["models"]=='order_send') $typeforonlinepayment='order'; // TODO use detection on something else than template - if ($this->param["models"]=='invoice' || $this->param["models"]=='facture_send') $typeforonlinepayment='invoice'; // TODO use detection on something else than template - if ($this->param["models"]=='member') $typeforonlinepayment='member'; // TODO use detection on something else than template - $url=getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); - $paymenturl=$url; + $langs->loadLangs(array('paypal', 'other')); + $typeforonlinepayment = 'free'; + if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') $typeforonlinepayment = 'order'; // TODO use detection on something else than template + if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template + if ($this->param["models"] == 'member') $typeforonlinepayment = 'member'; // TODO use detection on something else than template + $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); + $paymenturl = $url; $validpaymentmethod = getValidOnlinePaymentMethods(''); } @@ -934,13 +934,13 @@ class FormMail extends Form if (count($validpaymentmethod) > 0 && $paymenturl) { $langs->load('other'); - $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); - $this->substit['__ONLINE_PAYMENT_URL__']=$paymenturl; + $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); + $this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl; } else { - $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__']=''; - $this->substit['__ONLINE_PAYMENT_URL__']=''; + $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ''; + $this->substit['__ONLINE_PAYMENT_URL__'] = ''; } //Add lines substitution key from each line @@ -953,92 +953,92 @@ class FormMail extends Form $lines .= make_substitutions($defaultlines, $substit_line)."\n"; } } - $this->substit['__LINES__']=$lines; + $this->substit['__LINES__'] = $lines; - $defaultmessage=str_replace('\n', "\n", $defaultmessage); + $defaultmessage = str_replace('\n', "\n", $defaultmessage); // Deal with format differences between message and signature (text / HTML) if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $this->substit['__USER_SIGNATURE__'] = dol_nl2br($this->substit['__USER_SIGNATURE__']); - } elseif(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { + } elseif (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__USER_SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } - if (isset($_POST["message"]) && ! $_POST['modelselected']) $defaultmessage=$_POST["message"]; + if (isset($_POST["message"]) && !$_POST['modelselected']) $defaultmessage = $_POST["message"]; else { - $defaultmessage=make_substitutions($defaultmessage, $this->substit); + $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) - $defaultmessage=preg_replace("/^(
)+/", "", $defaultmessage); - $defaultmessage=preg_replace("/^\n+/", "", $defaultmessage); + $defaultmessage = preg_replace("/^(
)+/", "", $defaultmessage); + $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); } - $out.= ''; - $out.= ''; - $out.= ''; + $out .= ''; + $out .= '\n"; + $out .= "\n"; } - $out.= '
'; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; $form->select_conditions_paiements($search_payment_term, 'search_payment_term', -1, 1, 1, 'maxwidth100'); print "'; $form->select_types_paiements($search_payment_mode, 'search_payment_mode', '', 0, 1, 1, 0, 1, 'maxwidth100'); print ''; print $form->selectyesno('search_recurring', $search_recurring, 1, false, 1); print ''; print ''; print ''; print ''; print ''; print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year?$search_year:-1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year ? $search_year : -1, 'search_year', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; - if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; + if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ''; print ''; - $formother->select_year($search_year_date_when?$search_year_date_when:-1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); + $formother->select_year($search_year_date_when ? $search_year_date_when : -1, 'search_year_date_when', 1, 20, 5, 0, 0, '', 'widthauto valignmiddle'); print ''; print ''; print ''; - $liststatus=array( + $liststatus = array( 0=>$langs->trans("Draft"), 1=>$langs->trans("Active"), -1=>$langs->trans("Disabled"), @@ -462,145 +462,145 @@ if ($resql) } // Action column print ''; - $searchpicto=$form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); + $searchpicto = $form->showFilterAndCheckAddButtons(0, 'checkforselect', 1); print $searchpicto; print '
'; print $invoicerectmp->getNomUrl(1); print ""; print "'.$companystatic->getNomUrl(1, 'customer').''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_ttc).''; $form->form_conditions_reglement('', $objp->fk_cond_reglement, 'none'); print ''; $form->form_modes_reglement('', $objp->fk_mode_reglement, 'none'); print ''.yn($objp->frequency?1:0).''.yn($objp->frequency ? 1 : 0).''.($objp->frequency > 0 ? $objp->frequency : '').''.($objp->frequency > 0 ? $objp->unit_frequency : '').''; - print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max>0?' / '. $objp->nb_gen_max:'') : ''.$langs->trans('NA').''); + print ($objp->frequency > 0 ? $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : '') : ''.$langs->trans('NA').''); print ''; print ($objp->frequency > 0 ? dol_print_date($db->jdate($objp->date_last_gen), 'day') : ''.$langs->trans('NA').''); print ''; print '
'; - print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached()?'':'').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached()?'':'') : ''.$langs->trans('NA').''); - if (! $invoicerectmp->isMaxNbGenReached()) + print ($objp->frequency ? ($invoicerectmp->isMaxNbGenReached() ? '' : '').dol_print_date($db->jdate($objp->date_when), 'day').($invoicerectmp->isMaxNbGenReached() ? '' : '') : ''.$langs->trans('NA').''); + if (!$invoicerectmp->isMaxNbGenReached()) { - if (! $objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); + if (!$objp->suspended && $objp->frequency > 0 && $db->jdate($objp->date_when) && $db->jdate($objp->date_when) < $now) print img_warning($langs->trans("Late")); } else { @@ -608,36 +608,36 @@ if ($resql) } print '
'; print '
'; print dol_print_date($db->jdate($objp->datec), 'dayhour'); print ''; print dol_print_date($db->jdate($objp->tms), 'dayhour'); print ''; print $invoicerectmp->getLibStatut(3, 0); print ''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ba04782eafe..a945e8cb5a5 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -64,23 +64,23 @@ class Contact extends CommonObject /** * @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'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), - 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), + 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>1, 'position'=>1000), ); - public $civility_id; // In fact we store civility_code + public $civility_id; // In fact we store civility_code public $civility_code; public $civility; @@ -92,14 +92,14 @@ class Contact extends CommonObject public $zip; public $town; - public $state_id; // Id of department - public $state_code; // Code of department - public $state; // Label of department + public $state_id; // Id of department + public $state_code; // Code of department + public $state; // Label of department - public $poste; // Position + public $poste; // Position - public $socid; // fk_soc - public $statut; // 0=inactif, 1=actif + public $socid; // fk_soc + public $statut; // 0=inactif, 1=actif public $code; @@ -181,9 +181,9 @@ class Contact extends CommonObject * Old copy * @var Contact */ - public $oldcopy; // To contains a clone of this when we need to save old properties of object + public $oldcopy; // To contains a clone of this when we need to save old properties of object - public $roles=array(); + public $roles = array(); /** @@ -208,28 +208,28 @@ class Contact extends CommonObject // phpcs:enable global $user; - $this->nb=array(); + $this->nb = array(); $clause = "WHERE"; $sql = "SELECT count(sp.rowid) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; if (!$user->rights->societe->client->voir && !$user->socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE sp.fk_soc = s.rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $clause = "AND"; } - $sql.= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; - $sql.= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; - if ($user->socid > 0) $sql.=" AND sp.fk_soc = ".$user->socid; + $sql .= ' '.$clause.' sp.entity IN ('.getEntity($this->element).')'; + $sql .= " AND (sp.priv='0' OR (sp.priv='1' AND sp.fk_user_creat=".$user->id."))"; + if ($user->socid > 0) $sql .= " AND sp.fk_soc = ".$user->socid; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - while ($obj=$this->db->fetch_object($resql)) + while ($obj = $this->db->fetch_object($resql)) { - $this->nb["contacts"]=$obj->nb; + $this->nb["contacts"] = $obj->nb; } $this->db->free($resql); return 1; @@ -386,7 +386,7 @@ class Contact extends CommonObject $this->town = (empty($this->town) ? '' : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); if (empty($this->statut)) $this->statut = 0; - if (empty($this->civility_code) && ! is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility + if (empty($this->civility_code) && !is_numeric($this->civility_id)) $this->civility_code = $this->civility_id; // For backward compatibility $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET "; @@ -406,16 +406,16 @@ class Contact extends CommonObject $sql .= ", socialnetworks = '".$this->db->escape(json_encode($this->socialnetworks))."'"; $sql .= ", photo='".$this->db->escape($this->photo)."'"; $sql .= ", birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); - $sql .= ", note_private = ".(isset($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); - $sql .= ", note_public = ".(isset($this->note_public)?"'".$this->db->escape($this->note_public)."'":"null"); - $sql .= ", phone = ".(isset($this->phone_pro)?"'".$this->db->escape($this->phone_pro)."'":"null"); - $sql .= ", phone_perso = ".(isset($this->phone_perso)?"'".$this->db->escape($this->phone_perso)."'":"null"); - $sql .= ", phone_mobile = ".(isset($this->phone_mobile)?"'".$this->db->escape($this->phone_mobile)."'":"null"); + $sql .= ", note_private = ".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); + $sql .= ", note_public = ".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null"); + $sql .= ", phone = ".(isset($this->phone_pro) ? "'".$this->db->escape($this->phone_pro)."'" : "null"); + $sql .= ", phone_perso = ".(isset($this->phone_perso) ? "'".$this->db->escape($this->phone_perso)."'" : "null"); + $sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "null"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; $sql .= ", statut = ".$this->db->escape($this->statut); - $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'":"NULL"); - $sql .= ", default_lang=".($this->default_lang?"'".$this->db->escape($this->default_lang)."'":"NULL"); - $sql .= ", entity = " . $this->db->escape($this->entity); + $sql .= ", fk_user_modif=".($user->id > 0 ? "'".$this->db->escape($user->id)."'" : "NULL"); + $sql .= ", default_lang=".($this->default_lang ? "'".$this->db->escape($this->default_lang)."'" : "NULL"); + $sql .= ", entity = ".$this->db->escape($this->entity); $sql .= " WHERE rowid=".$this->db->escape($id); dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -525,15 +525,15 @@ class Contact extends CommonObject } } - if (! $error && ! $notrigger) + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('CONTACT_MODIFY', $user); + $result = $this->call_trigger('CONTACT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -757,37 +757,37 @@ class Contact extends CommonObject $langs->load("dict"); - dol_syslog(get_class($this) . "::fetch id=" . $id . " ref_ext=" . $ref_ext . " email=" . $email, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch id=".$id." ref_ext=".$ref_ext." email=".$email, LOG_DEBUG); if (empty($id) && empty($ref_ext) && empty($email)) { - $this->error='BadParameter'; + $this->error = 'BadParameter'; return -1; } $langs->load("companies"); $sql = "SELECT c.rowid, c.entity, c.fk_soc, c.ref_ext, c.civility as civility_code, c.lastname, c.firstname,"; - $sql.= " c.address, c.statut, c.zip, c.town,"; - $sql.= " c.fk_pays as country_id,"; - $sql.= " c.fk_departement as state_id,"; - $sql.= " c.birthday,"; - $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; - $sql.= " c.socialnetworks,"; - $sql.= " c.photo,"; - $sql.= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql.= " c.import_key,"; - $sql.= " c.datec as date_creation, c.tms as date_modification,"; - $sql.= " co.label as country, co.code as country_code,"; - $sql.= " d.nom as state, d.code_departement as state_code,"; - $sql.= " u.rowid as user_id, u.login as user_login,"; - $sql.= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; - $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; - if ($id) $sql.= " WHERE c.rowid = ". $id; + $sql .= " c.address, c.statut, c.zip, c.town,"; + $sql .= " c.fk_pays as country_id,"; + $sql .= " c.fk_departement as state_id,"; + $sql .= " c.birthday,"; + $sql .= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email,"; + $sql .= " c.socialnetworks,"; + $sql .= " c.photo,"; + $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; + $sql .= " c.import_key,"; + $sql .= " c.datec as date_creation, c.tms as date_modification,"; + $sql .= " co.label as country, co.code as country_code,"; + $sql .= " d.nom as state, d.code_departement as state_code,"; + $sql .= " u.rowid as user_id, u.login as user_login,"; + $sql .= " s.nom as socname, s.address as socaddress, s.zip as soccp, s.town as soccity, s.default_lang as socdefault_lang"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON c.fk_pays = co.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON c.fk_departement = d.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON c.rowid = u.fk_socpeople"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; + if ($id) $sql .= " WHERE c.rowid = ".$id; else { $sql .= " WHERE c.entity IN (".getEntity($this->element).")"; @@ -799,47 +799,47 @@ class Contact extends CommonObject } } - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->entity = $obj->entity; - $this->ref = $obj->rowid; - $this->ref_ext = $obj->ref_ext; + $this->id = $obj->rowid; + $this->entity = $obj->entity; + $this->ref = $obj->rowid; + $this->ref_ext = $obj->ref_ext; $this->civility_code = $obj->civility_code; - $this->civility = $obj->civility_code?($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code):''; + $this->civility = $obj->civility_code ? ($langs->trans("Civility".$obj->civility_code) != ("Civility".$obj->civility_code) ? $langs->trans("Civility".$obj->civility_code) : $obj->civility_code) : ''; - $this->lastname = $obj->lastname; - $this->firstname = $obj->firstname; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; + $this->lastname = $obj->lastname; + $this->firstname = $obj->firstname; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; $this->date_creation = $this->db->jdate($obj->date_creation); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->state_id = $obj->state_id; - $this->state_code = $obj->state_code; - $this->state = $obj->state; + $this->state_id = $obj->state_id; + $this->state_code = $obj->state_code; + $this->state = $obj->state; - $this->country_id = $obj->country_id; - $this->country_code = $obj->country_id?$obj->country_code:''; - $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_id ? $obj->country_code : ''; + $this->country = $obj->country_id ? ($langs->trans('Country'.$obj->country_code) != 'Country'.$obj->country_code ? $langs->transnoentities('Country'.$obj->country_code) : $obj->country) : ''; $this->socid = $obj->fk_soc; $this->socname = $obj->socname; $this->poste = $obj->poste; - $this->statut = $obj->statut; + $this->statut = $obj->statut; - $this->phone_pro = trim($obj->phone); - $this->fax = trim($obj->fax); - $this->phone_perso = trim($obj->phone_perso); - $this->phone_mobile = trim($obj->phone_mobile); + $this->phone_pro = trim($obj->phone); + $this->fax = trim($obj->fax); + $this->phone_perso = trim($obj->phone_perso); + $this->phone_mobile = trim($obj->phone_mobile); $this->email = $obj->email; $this->socialnetworks = (array) json_decode($obj->socialnetworks, true); @@ -847,14 +847,14 @@ class Contact extends CommonObject $this->priv = $obj->priv; $this->mail = $obj->email; - $this->birthday = $this->db->jdate($obj->birthday); - $this->note = $obj->note_private; // deprecated + $this->birthday = $this->db->jdate($obj->birthday); + $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; - $this->note_public = $obj->note_public; + $this->note_public = $obj->note_public; $this->default_lang = $obj->default_lang; - $this->user_id = $obj->user_id; + $this->user_id = $obj->user_id; $this->user_login = $obj->user_login; - $this->canvas = $obj->canvas; + $this->canvas = $obj->canvas; $this->import_key = $obj->import_key; @@ -1617,7 +1617,7 @@ class Contact extends CommonObject $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id;; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_contacts WHERE fk_soc=".$this->socid." AND fk_socpeople=".$this->id; ; dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 48baff0f8fd..6c0a20bc6db 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - public $boxcode="invoicespermonth"; - public $boximg="object_bill"; - public $boxlabel="BoxCustomersInvoicesPerMonth"; + public $boxcode = "invoicespermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxCustomersInvoicesPerMonth"; public $depends = array("facture"); /** @@ -52,9 +52,9 @@ class box_graph_invoices_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->facture->lire); + $this->hidden = !($user->rights->facture->lire); } /** @@ -67,14 +67,14 @@ class box_graph_invoices_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //$facturestatic=new Facture($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); @@ -89,50 +89,50 @@ class box_graph_invoices_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->facture->lire) { $mesg = ''; - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='customer'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'customer'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new FactureStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; // default value for customer mode @@ -141,22 +141,22 @@ class box_graph_invoices_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -168,7 +168,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfBillsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -178,7 +178,7 @@ class box_graph_invoices_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; // default value for customer mode @@ -187,22 +187,22 @@ class box_graph_invoices_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -214,7 +214,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -224,51 +224,51 @@ class box_graph_invoices_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfBillsByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfBillsByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index f9e2d3ccc25..52dcdc995cd 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - public $boxcode="invoicessupplierpermonth"; - public $boximg="object_bill"; - public $boxlabel="BoxSuppliersInvoicesPerMonth"; + public $boxcode = "invoicessupplierpermonth"; + public $boximg = "object_bill"; + public $boxlabel = "BoxSuppliersInvoicesPerMonth"; public $depends = array("fournisseur"); /** @@ -52,9 +52,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->rights->fournisseur->facture->lire); } /** @@ -67,13 +67,13 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxSuppliersInvoicesPerMonth", $max); @@ -88,48 +88,48 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->fournisseur->facture->lire) { - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='supplier'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'supplier'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new FactureStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; // default value for customer mode @@ -138,23 +138,23 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -166,7 +166,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfBillsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -176,7 +176,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; // default value for customer mode @@ -185,22 +185,22 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $langs->load("bills"); $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -212,7 +212,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfBillsByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -222,51 +222,51 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfBillsByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfBillsByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfBillsByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfBillsByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"','td' => 'class="nohover center"','textnoformat'=>$stringtoshow); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 244bd7d7083..45459805f00 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - public $boxcode="orderspermonth"; - public $boximg="object_order"; - public $boxlabel="BoxCustomersOrdersPerMonth"; + public $boxcode = "orderspermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxCustomersOrdersPerMonth"; public $depends = array("commande"); /** @@ -52,9 +52,9 @@ class box_graph_orders_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->commande->lire); + $this->hidden = !($user->rights->commande->lire); } /** @@ -67,14 +67,14 @@ class box_graph_orders_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; //$commandestatic=new Commande($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxCustomersOrdersPerMonth", $max); @@ -89,50 +89,50 @@ class box_graph_orders_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->commande->lire) { $langs->load("orders"); - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='customer'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'customer'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new CommandeStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersnbinyear-".$endyear.".png"; // default value for customer mode @@ -141,21 +141,21 @@ class box_graph_orders_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -167,7 +167,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -177,7 +177,7 @@ class box_graph_orders_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."ordersamountinyear-".$endyear.".png"; // default value for customer mode @@ -186,20 +186,20 @@ class box_graph_orders_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + 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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -211,7 +211,7 @@ class box_graph_orders_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -221,49 +221,49 @@ class box_graph_orders_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfOrdersByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfOrdersByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index 3ceb04b7d4c..99426be8cb1 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_supplier_permonth extends ModeleBoxes { - public $boxcode="orderssupplierpermonth"; - public $boximg="object_order"; - public $boxlabel="BoxSuppliersOrdersPerMonth"; + public $boxcode = "orderssupplierpermonth"; + public $boximg = "object_order"; + public $boxlabel = "BoxSuppliersOrdersPerMonth"; public $depends = array("fournisseur"); /** @@ -52,9 +52,9 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { global $user; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->rights->fournisseur->commande->lire); } /** @@ -67,13 +67,13 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $text = $langs->trans("BoxSuppliersOrdersPerMonth", $max); @@ -88,50 +88,50 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->fournisseur->commande->lire) { $langs->load("orders"); - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $mode='supplier'; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $mode = 'supplier'; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new CommandeStats($this->db, $socid, $mode, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."orderssuppliernbinyear-".$endyear.".png"; // default value for customer mode @@ -140,21 +140,21 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -166,7 +166,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfOrdersByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -176,7 +176,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); $filenamenb = $dir."/".$prefix."orderssupplieramountinyear-".$endyear.".png"; // default value for customer mode @@ -185,20 +185,20 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + 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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -210,7 +210,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfOrdersByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -220,49 +220,49 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfOrdersByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfOrdersByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfOrdersByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfOrdersByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index 48493eeac92..c61bc2569be 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,10 +29,10 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - public $boxcode="productdistribution"; - public $boximg="object_product"; - public $boxlabel="BoxProductDistribution"; - public $depends = array("product|service","facture|propal|commande"); + public $boxcode = "productdistribution"; + public $boximg = "object_product"; + public $boxlabel = "BoxProductDistribution"; + public $depends = array("product|service", "facture|propal|commande"); /** * @var DoliDB Database handler. @@ -55,12 +55,12 @@ class box_graph_product_distribution extends ModeleBoxes { global $user, $conf; - $this->db=$db; + $this->db = $db; - $this->hidden = ! ( - (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire)) - || (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) - || (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire)) + $this->hidden = !( + (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) + || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) + || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) ); } @@ -74,43 +74,43 @@ class box_graph_product_distribution extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_showinvoicenb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; - $param_showpropalnb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; - $param_showordernb='DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_showinvoicenb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showinvoicenb'; + $param_showpropalnb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showpropalnb'; + $param_showordernb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showordernb'; + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $year=GETPOST($param_year, 'int'); - $showinvoicenb=GETPOST($param_showinvoicenb, 'alpha'); - $showpropalnb=GETPOST($param_showpropalnb, 'alpha'); - $showordernb=GETPOST($param_showordernb, 'alpha'); + $year = GETPOST($param_year, 'int'); + $showinvoicenb = GETPOST($param_showinvoicenb, 'alpha'); + $showpropalnb = GETPOST($param_showpropalnb, 'alpha'); + $showordernb = GETPOST($param_showordernb, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $year=$tmparray['year']; - $showinvoicenb=$tmparray['showinvoicenb']; - $showpropalnb=$tmparray['showpropalnb']; - $showordernb=$tmparray['showordernb']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $year = $tmparray['year']; + $showinvoicenb = $tmparray['showinvoicenb']; + $showpropalnb = $tmparray['showpropalnb']; + $showordernb = $tmparray['showordernb']; } - if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb=1; $showinvoicenb=1; $showordernb=1; } - if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb=0; - if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb=0; - if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb=0; + if (empty($showinvoicenb) && empty($showpropalnb) && empty($showordernb)) { $showpropalnb = 1; $showinvoicenb = 1; $showordernb = 1; } + if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) $showinvoicenb = 0; + if (empty($conf->propal->enabled) || empty($user->rights->propale->lire)) $showpropalnb = 0; + if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) $showordernb = 0; - $nowarray=dol_getdate(dol_now(), true); - if (empty($year)) $year=$nowarray['year']; + $nowarray = dol_getdate(dol_now(), true); + if (empty($year)) $year = $nowarray['year']; - $nbofgraph=0; + $nbofgraph = 0; if ($showinvoicenb) $nbofgraph++; if ($showpropalnb) $nbofgraph++; if ($showordernb) $nbofgraph++; @@ -128,13 +128,13 @@ class box_graph_product_distribution extends ModeleBoxes ); - $socid=empty($user->socid)?0:$user->socid; - $userid=0; // No filter on user creation + $socid = empty($user->socid) ? 0 : $user->socid; + $userid = 0; // No filter on user creation - $WIDTH=($nbofgraph >= 2 || ! empty($conf->dol_optimize_smallscreen))?'160':'320'; - $HEIGHT='192'; + $WIDTH = ($nbofgraph >= 2 || !empty($conf->dol_optimize_smallscreen)) ? '160' : '320'; + $HEIGHT = '192'; - if (! empty($conf->facture->enabled) && ! empty($user->rights->facture->lire)) + if (!empty($conf->facture->enabled) && !empty($user->rights->facture->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showinvoicenb) @@ -143,34 +143,34 @@ class box_graph_product_distribution extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facturestats.class.php'; $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))); + $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))); if (empty($data1)) { - $showpointvalue=0; - $nocolor=1; - $data1=array(array(0=>$langs->trans("None"),1=>1)); + $showpointvalue = 0; + $nocolor = 1; + $data1 = array(array(0=>$langs->trans("None"), 1=>1)); } $filenamenb = $dir."/prodserforinvoice-".$year.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=productstats&file=prodserforinvoice-'.$year.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { - $i=0;$tot=count($data1);$legend=array(); + $i = 0; $tot = count($data1); $legend = array(); while ($i <= $tot) { - $data1[$i][0]=dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[]=$data1[$i][0]; + $data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[] = $data1[$i][0]; $i++; } $px1->SetData($data1); unset($data1); - if ($nocolor) $px1->SetDataColor(array(array(220,220,220))); + if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); $px1->SetLegend($legend); $px1->setShowLegend(0); $px1->setShowPointValue($showpointvalue); @@ -192,7 +192,7 @@ class box_graph_product_distribution extends ModeleBoxes } } - if (! empty($conf->propal->enabled) && ! empty($user->rights->propale->lire)) + if (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showpropalnb) @@ -201,13 +201,13 @@ class box_graph_product_distribution extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; $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))); + $stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0)); + $data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); if (empty($data2)) { $showpointvalue = 0; $nocolor = 1; - $data2=array(array(0=>$langs->trans("None"),1=>1)); + $data2 = array(array(0=>$langs->trans("None"), 1=>1)); } $filenamenb = $dir."/prodserforpropal-".$year.".png"; @@ -215,20 +215,20 @@ class box_graph_product_distribution extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { - $i=0;$tot=count($data2);$legend=array(); + $i = 0; $tot = count($data2); $legend = array(); while ($i <= $tot) { - $data2[$i][0]=dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[]=$data2[$i][0]; + $data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[] = $data2[$i][0]; $i++; } $px2->SetData($data2); unset($data2); - if ($nocolor) $px2->SetDataColor(array(array(220,220,220))); + if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220))); $px2->SetLegend($legend); $px2->setShowLegend(0); $px2->setShowPointValue($showpointvalue); @@ -250,7 +250,7 @@ class box_graph_product_distribution extends ModeleBoxes } } - if (! empty($conf->commande->enabled) && ! empty($user->rights->commande->lire)) + if (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) { // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showordernb) @@ -259,14 +259,14 @@ class box_graph_product_distribution extends ModeleBoxes include_once DOL_DOCUMENT_ROOT.'/commande/class/commandestats.class.php'; $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))); + $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))); if (empty($data3)) { $showpointvalue = 0; $nocolor = 1; - $data3=array(array(0=>$langs->trans("None"),1=>1)); + $data3 = array(array(0=>$langs->trans("None"), 1=>1)); } $filenamenb = $dir."/prodserfororder-".$year.".png"; @@ -274,20 +274,20 @@ class box_graph_product_distribution extends ModeleBoxes $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); - if (! $mesg) + if (!$mesg) { - $i=0;$tot=count($data3);$legend=array(); + $i = 0; $tot = count($data3); $legend = array(); while ($i <= $tot) { - $data3[$i][0]=dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[]=$data3[$i][0]; + $data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" + $legend[] = $data3[$i][0]; $i++; } $px3->SetData($data3); unset($data3); - if ($nocolor) $px3->SetDataColor(array(array(220,220,220))); + if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220))); $px3->SetLegend($legend); $px3->setShowLegend(0); $px3->setShowPointValue($showpointvalue); @@ -312,76 +312,76 @@ class box_graph_product_distribution extends ModeleBoxes if (empty($nbofgraph)) { $langs->load("errors"); - $mesg=$langs->trans("ReadPermissionNotAllowed"); + $mesg = $langs->trans("ReadPermissionNotAllowed"); } if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - if (! empty($conf->facture->enabled) || ! empty($user->rights->facture->lire)) + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + if (!empty($conf->facture->enabled) || !empty($user->rights->facture->lire)) { - $stringtoshow.=' '.$langs->trans("ForCustomersInvoices"); - $stringtoshow.='   '; + $stringtoshow .= ' '.$langs->trans("ForCustomersInvoices"); + $stringtoshow .= '   '; } - if (! empty($conf->propal->enabled) || ! empty($user->rights->propale->lire)) + if (!empty($conf->propal->enabled) || !empty($user->rights->propale->lire)) { - $stringtoshow.=' '.$langs->trans("ForProposals"); - $stringtoshow.=' '; + $stringtoshow .= ' '.$langs->trans("ForProposals"); + $stringtoshow .= ' '; } - if (! empty($conf->commande->enabled) || ! empty($user->rights->commande->lire)) + if (!empty($conf->commande->enabled) || !empty($user->rights->commande->lire)) { - $stringtoshow.=' '.$langs->trans("ForCustomersOrders"); + $stringtoshow .= ' '.$langs->trans("ForCustomersOrders"); } - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= '
'; if ($nbofgraph == 1) { - if ($showinvoicenb) $stringtoshow.=$px1->show(); - elseif ($showpropalnb) $stringtoshow.=$px2->show(); - else $stringtoshow.=$px3->show(); + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + else $stringtoshow .= $px3->show(); } if ($nbofgraph == 2) { - $stringtoshow.='
'; - if ($showinvoicenb) $stringtoshow.=$px1->show(); - elseif ($showpropalnb) $stringtoshow.=$px2->show(); - $stringtoshow.='
'; - if ($showordernb) $stringtoshow.=$px3->show(); - elseif ($showpropalnb) $stringtoshow.=$px2->show(); - $stringtoshow.='
'; + $stringtoshow .= '
'; + if ($showinvoicenb) $stringtoshow .= $px1->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; + if ($showordernb) $stringtoshow .= $px3->show(); + elseif ($showpropalnb) $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; } if ($nbofgraph == 3) { - $stringtoshow.='
'; - $stringtoshow.=$px1->show(); - $stringtoshow.='
'; - $stringtoshow.=$px2->show(); - $stringtoshow.='
'; - $stringtoshow.='
'; - $stringtoshow.=$px3->show(); - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= $px1->show(); + $stringtoshow .= '
'; + $stringtoshow .= $px2->show(); + $stringtoshow .= '
'; + $stringtoshow .= '
'; + $stringtoshow .= $px3->show(); + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index f02ad99657c..42b95e516b5 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,9 +28,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - public $boxcode="propalpermonth"; - public $boximg="object_propal"; - public $boxlabel="BoxProposalsPerMonth"; + public $boxcode = "propalpermonth"; + public $boximg = "object_propal"; + public $boxlabel = "BoxProposalsPerMonth"; public $depends = array("propal"); /** @@ -54,7 +54,7 @@ class box_graph_propales_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = ! ($user->rights->propale->lire); + $this->hidden = !($user->rights->propale->lire); } /** @@ -67,14 +67,14 @@ class box_graph_propales_permonth extends ModeleBoxes { global $conf, $user, $langs; - $this->max=$max; + $this->max = $max; - $refreshaction='refresh_'.$this->boxcode; + $refreshaction = 'refresh_'.$this->boxcode; //include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; //$propalstatic=new Propal($this->db); - $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START?($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; + $startmonth = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1; if (empty($conf->global->GRAPH_USE_FISCAL_YEAR)) $startmonth = 1; $langs->load("propal"); @@ -83,7 +83,7 @@ class box_graph_propales_permonth extends ModeleBoxes $this->info_box_head = array( 'text' => $text, 'limit'=> dol_strlen($text), - 'graph'=> 1, // Set to 1 if it's a box graph + 'graph'=> 1, // Set to 1 if it's a box graph 'sublink'=>'', 'subtext'=>$langs->trans("Filter"), 'subpicto'=>'filter.png', @@ -91,69 +91,69 @@ class box_graph_propales_permonth extends ModeleBoxes 'target'=>'none' // Set '' to get target="_blank" ); - $dir=''; // We don't need a path because image file will not be saved into disk - $prefix=''; - $socid=0; - if ($user->socid) $socid=$user->socid; - if (! $user->rights->societe->client->voir || $socid) $prefix.='private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user + $dir = ''; // We don't need a path because image file will not be saved into disk + $prefix = ''; + $socid = 0; + if ($user->socid) $socid = $user->socid; + if (!$user->rights->societe->client->voir || $socid) $prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user if ($user->rights->propale->lire) { - $param_year='DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; - $param_shownb='DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; - $param_showtot='DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; + $param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year'; + $param_shownb = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_shownb'; + $param_showtot = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_showtot'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propalestats.class.php'; - $autosetarray=preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); + $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_box_'.$this->boxcode, $autosetarray)) { - $endyear=GETPOST($param_year, 'int'); - $shownb=GETPOST($param_shownb, 'alpha'); - $showtot=GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray=json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); - $endyear=$tmparray['year']; - $shownb=$tmparray['shownb']; - $showtot=$tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_box_'.$this->boxcode], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } - if (empty($shownb) && empty($showtot)) { $shownb=1; $showtot=1; } - $nowarray=dol_getdate(dol_now(), true); - if (empty($endyear)) $endyear=$nowarray['year']; - $startyear=$endyear-1; - $WIDTH=(($shownb && $showtot) || ! empty($conf->dol_optimize_smallscreen))?'256':'320'; - $HEIGHT='192'; + if (empty($shownb) && empty($showtot)) { $shownb = 1; $showtot = 1; } + $nowarray = dol_getdate(dol_now(), true); + if (empty($endyear)) $endyear = $nowarray['year']; + $startyear = $endyear - 1; + $WIDTH = (($shownb && $showtot) || !empty($conf->dol_optimize_smallscreen)) ? '256' : '320'; + $HEIGHT = '192'; $stats = new PropaleStats($this->db, $socid, 0); // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($shownb) { - $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); - $datatype1 = array_pad(array(), ($endyear-$startyear+1), 'bars'); + $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); + $datatype1 = array_pad(array(), ($endyear - $startyear + 1), 'bars'); $filenamenb = $dir."/".$prefix."propalsnbinyear-".$endyear.".png"; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=propalsnbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); - if (! $mesg) + if (!$mesg) { $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -165,7 +165,7 @@ class box_graph_propales_permonth extends ModeleBoxes $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->SetCssPrefix("cssboxes"); - $px1->mode='depth'; + $px1->mode = 'depth'; $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); $px1->draw($filenamenb, $fileurlnb); @@ -175,8 +175,8 @@ class box_graph_propales_permonth extends ModeleBoxes // Build graphic number of object. $data = array(array('Lib',val1,val2,val3),...) if ($showtot) { - $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09')==$refreshaction?-1:(3600*24)), ($WIDTH<300?2:0), $startmonth); - $datatype2 = array_pad(array(), ($endyear-$startyear+1), 'bars'); + $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); + $datatype2 = array_pad(array(), ($endyear - $startyear + 1), 'bars'); //$datatype2 = array('lines','bars'); $filenamenb = $dir."/".$prefix."propalsamountinyear-".$endyear.".png"; @@ -185,21 +185,21 @@ class box_graph_propales_permonth extends ModeleBoxes $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); - if (! $mesg) + if (!$mesg) { $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); + $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); } else { - $legend[]=$i; + $legend[] = $i; } $i++; } @@ -211,7 +211,7 @@ class box_graph_propales_permonth extends ModeleBoxes $px2->SetShading(3); $px2->SetHorizTickIncrement(1); $px2->SetCssPrefix("cssboxes"); - $px2->mode='depth'; + $px2->mode = 'depth'; $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); $px2->draw($filenamenb, $fileurlnb); @@ -221,49 +221,49 @@ class box_graph_propales_permonth extends ModeleBoxes if (empty($conf->use_javascript_ajax)) { $langs->load("errors"); - $mesg=$langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); + $mesg = $langs->trans("WarningFeatureDisabledWithDisplayOptimizedForBlindNoJs"); } - if (! $mesg) + if (!$mesg) { - $stringtoshow=''; - $stringtoshow.=''; - $stringtoshow.='
'; // hideobject is to start hidden - $stringtoshow.='
'; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=''; - $stringtoshow.=' '.$langs->trans("NumberOfProposalsByMonth"); - $stringtoshow.='   '; - $stringtoshow.=' '.$langs->trans("AmountOfProposalsByMonthHT"); - $stringtoshow.='
'; - $stringtoshow.=$langs->trans("Year").' '; - $stringtoshow.=''; - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; // hideobject is to start hidden + $stringtoshow .= '
'; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ''; + $stringtoshow .= ' '.$langs->trans("NumberOfProposalsByMonth"); + $stringtoshow .= '   '; + $stringtoshow .= ' '.$langs->trans("AmountOfProposalsByMonthHT"); + $stringtoshow .= '
'; + $stringtoshow .= $langs->trans("Year").' '; + $stringtoshow .= ''; + $stringtoshow .= '
'; + $stringtoshow .= '
'; if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($shownb) $stringtoshow.=$px1->show(); + if ($shownb) $stringtoshow .= $px1->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } - if ($showtot) $stringtoshow.=$px2->show(); + if ($showtot) $stringtoshow .= $px2->show(); if ($shownb && $showtot) { - $stringtoshow.='
'; - $stringtoshow.='
'; + $stringtoshow .= '
'; + $stringtoshow .= '
'; } $this->info_box_contents[0][0] = array( 'tr'=>'class="oddeven nohover"', diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 80264796186..2ae0ede3c21 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -118,16 +118,16 @@ class box_task extends ModeleBoxes // list the summary of the orders if ($user->rights->projet->lire) { - $boxcontent.= '
'."\n"; - $boxcontent.= '
'."\n"; - $boxcontent.= '
boxcode.'">'."\n"; - $boxcontent.= ''."\n"; + $boxcontent .= '
'."\n"; + $boxcontent .= '
'."\n"; + $boxcontent .= 'boxcode.'">'."\n"; + $boxcontent .= ''."\n"; $selectArray = array('all' => $langs->trans("NoFilter"), 'im_task_contact' => $langs->trans("WhichIamLinkedTo"), 'im_project_contact' => $langs->trans("WhichIamLinkedToProject")); - $boxcontent.= $form->selectArray($cookie_name, $selectArray, $filterValue); - $boxcontent.= ''; - $boxcontent.= ''."\n"; - $boxcontent.= '
'."\n"; - $boxcontent.= ''."\n"; + $out .= ''."\n"; + $out .= ''."\n"; if (count($listofpaths)) { - foreach($listofpaths as $key => $val) + foreach ($listofpaths as $key => $val) { - $out.= '
'; - $out.= img_mime($listofnames[$key]).' '.$listofnames[$key]; - if (! $this->withfilereadonly) + $out .= '
'; + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; + if (!$this->withfilereadonly) { - $out.= ' '; + $out .= ' '; //$out.= ' '.img_delete($langs->trans("Delete").''; } - $out.= '
'; + $out .= '
'; } } elseif (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox { - $out.= $langs->trans("NoAttachedFiles").'
'; + $out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) // Can add other files { - if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out.= ''; - else $out.= ''; - $out.= ' '; - $out.= ''; + if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out .= ''; + else $out .= ''; + $out .= ' '; + $out .= ''; } } else { - $out.=$this->withfile; + $out .= $this->withfile; } - $out.= "
'; - $out.=$form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); - $out.=''; + $out .= '
'; + $out .= $form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); + $out .= ''; if ($this->withbodyreadonly) { - $out.= nl2br($defaultmessage); - $out.= ''; + $out .= nl2br($defaultmessage); + $out .= ''; } else { - if (! isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + if (!isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; if ($this->withfckeditor == -1) { - if (! empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor=1; - else $this->withfckeditor=0; + if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor = 1; + else $this->withfckeditor = 0; } - $doleditor=new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, '95%'); - $out.= $doleditor->Create(1); + $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, '95%'); + $out .= $doleditor->Create(1); } - $out.= "
'."\n"; + $out .= '
'."\n"; if ($this->withform == 1 || $this->withform == -1) { - $out.= '
'; - $out.= 'trans("SendMail").'"'; // Add a javascript test to avoid to forget to submit file before sending email if ($this->withfile == 2 && $conf->use_javascript_ajax) { - $out.= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; + $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; } - $out.= ' />'; + $out .= ' />'; if ($this->withcancel) { - $out.= '     '; - $out.= ''; + $out .= '     '; + $out .= ''; } - $out.= '
'."\n"; + $out .= ''."\n"; } - if ($this->withform == 1) $out.= ''."\n"; + if ($this->withform == 1) $out .= ''."\n"; // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set - if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) + if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) { - $out.= ''; + $out .= ' })'; + $out .= ''; } - $out.= "\n"; + $out .= "\n"; return $out; } @@ -1053,34 +1053,34 @@ class FormMail extends Form { global $conf, $langs, $form; $out = '
'; - $out.= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); - $out.= ''; - if (! empty($this->withtocccreadonly)) { - $out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:""; + $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); + $out .= ''; + if (!empty($this->withtocccreadonly)) { + $out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : ""; } else { - $out.= 'withtoccc) && ! is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; - if (! empty($this->withtoccc) && is_array($this->withtoccc)) { - $out.= " ".$langs->trans("and")."/".$langs->trans("or")." "; + $out .= 'withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />'; + if (!empty($this->withtoccc) && is_array($this->withtoccc)) { + $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtoccc; foreach ($tmparray as $key => $val) { - $tmparray[$key]=dol_htmlentities($tmparray[$key], null, 'UTF-8', true); + $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } - $withtocccselected=GETPOST("receiverccc"); // Array of selected value - $out.= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); + $withtocccselected = GETPOST("receiverccc"); // Array of selected value + $out .= $form->multiselectarray("receiverccc", $tmparray, $withtocccselected, null, null, null, null, "90%"); } } - $showinfobcc=''; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && ! empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && ! empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; - if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && ! empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc=$conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; - if ($showinfobcc) $out.=' + '.$showinfobcc; - $out.= "
'.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= $errorstomail; - $out.= "
'.$langs->trans("MailErrorsTo").''; + $out .= ''; + $out .= $errorstomail; + $out .= "
'.$langs->trans("MailErrorsTo").''; - $out.= ''; - $out.= "
'.$langs->trans("MailErrorsTo").''; + $out .= ''; + $out .= "
'.$langs->trans("DeliveryReceipt").''; - if (! empty($this->withdeliveryreceiptreadonly)) { - $out.= yn($this->withdeliveryreceipt); + if (!empty($this->withdeliveryreceiptreadonly)) { + $out .= yn($this->withdeliveryreceipt); } else { - $defaultvaluefordeliveryreceipt=0; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && ! empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && ! empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && ! empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt=1; - if (! empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && ! empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt=1; - $out.= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"])?$_POST["deliveryreceipt"]:$defaultvaluefordeliveryreceipt), 1); + $defaultvaluefordeliveryreceipt = 0; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $defaultvaluefordeliveryreceipt = 1; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_SUPPLIER_PROPOSAL) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $defaultvaluefordeliveryreceipt = 1; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $defaultvaluefordeliveryreceipt = 1; + if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $defaultvaluefordeliveryreceipt = 1; + $out .= $form->selectyesno('deliveryreceipt', (isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : $defaultvaluefordeliveryreceipt), 1); } - $out.= "
'; - $out.= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); - $out.= ''; + $out .= ''; + $out .= $form->textwithpicto($langs->trans('MailTopic'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfromtopic'); + $out .= ''; if ($this->withtopicreadonly) { - $out.= $defaulttopic; - $out.= ''; + $out .= $defaulttopic; + $out .= ''; } else { - $out.= ''; + $out .= ''; } - $out.= "
'; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= ''; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -206,7 +206,7 @@ class doc_generic_order_odt extends ModelePDFCommandes public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -215,28 +215,28 @@ class doc_generic_order_odt extends ModelePDFCommandes } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->commande->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Commande($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -246,14 +246,14 @@ class doc_generic_order_odt extends ModelePDFCommandes $dir = $conf->commande->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -261,25 +261,25 @@ class doc_generic_order_odt extends ModelePDFCommandes if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -289,20 +289,20 @@ class doc_generic_order_odt extends ModelePDFCommandes // If CUSTOMER contact defined on order, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -311,11 +311,11 @@ class doc_generic_order_odt extends ModelePDFCommandes } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -324,15 +324,15 @@ class doc_generic_order_odt extends ModelePDFCommandes ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='ORDER_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'ORDER_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -342,15 +342,15 @@ class doc_generic_order_odt extends ModelePDFCommandes $srctemplatepath, array( 'PATH_TO_TMP' => $conf->commande->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -365,31 +365,31 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -402,7 +402,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -414,7 +414,7 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -424,22 +424,22 @@ class doc_generic_order_odt extends ModelePDFCommandes { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -449,21 +449,21 @@ class doc_generic_order_odt extends ModelePDFCommandes $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -471,15 +471,15 @@ class doc_generic_order_odt extends ModelePDFCommandes // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); - }catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -488,27 +488,27 @@ class doc_generic_order_odt extends ModelePDFCommandes try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 62634ec07b8..12b8fc604f6 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -26,7 +26,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de commande Saphir */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/commande/modules_commande.php'; /** @@ -38,7 +38,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error message @@ -48,7 +48,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes /** * @var string name */ - public $name='Saphir'; + public $name = 'Saphir'; /** @@ -65,28 +65,28 @@ class mod_commande_saphir extends ModeleNumRefCommandes $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Order"), $langs->transnoentities("Order")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Order"), $langs->transnoentities("Order")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -98,17 +98,17 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -124,16 +124,16 @@ class mod_commande_saphir extends ModeleNumRefCommandes */ public function getNextValue($objsoc, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // We get cursor rule - $mask=$conf->global->COMMANDE_SAPHIR_MASK; + $mask = $conf->global->COMMANDE_SAPHIR_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } @@ -142,7 +142,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes $date = ($object->date_commande ? $object->date_commande : $object->date); - $numFinal=get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity); + $numFinal = get_next_value($db, $mask, 'commande', 'ref', '', $objsoc, $date, 'next', false, null, $entity); return $numFinal; } 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 54fd4ebff57..ca2146703bd 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 @@ -67,37 +67,37 @@ class doc_generic_contract_odt extends ModelePDFContract global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'CONTRACT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva CONTRACT_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -109,7 +109,7 @@ class doc_generic_contract_odt extends ModelePDFContract */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page $langs->loadLangs(array('companies', 'errors')); @@ -117,66 +117,66 @@ class doc_generic_contract_odt extends ModelePDFContract $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->CONTRACT_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; } // Add select to upload a new template file. TODO Copy this feature on other admin pages. - $texte.= '
'.$langs->trans("UploadNewTemplate").' '; - $texte.= ''; - $texte.= ''; - $texte.= '
'; + $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $texte.= '
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -196,7 +196,7 @@ class doc_generic_contract_odt extends ModelePDFContract public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -205,17 +205,17 @@ class doc_generic_contract_odt extends ModelePDFContract } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -223,11 +223,11 @@ class doc_generic_contract_odt extends ModelePDFContract if ($conf->contrat->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Contrat($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -237,14 +237,14 @@ class doc_generic_contract_odt extends ModelePDFContract $dir = $conf->contrat->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -252,26 +252,26 @@ class doc_generic_contract_odt extends ModelePDFContract if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -281,19 +281,19 @@ class doc_generic_contract_odt extends ModelePDFContract // If CUSTOMER contact defined on contract, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) { + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; @@ -303,7 +303,7 @@ class doc_generic_contract_odt extends ModelePDFContract } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } $object->fetch_optionals(); @@ -311,15 +311,15 @@ class doc_generic_contract_odt extends ModelePDFContract // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // complete with vars not set as properties by get_substitutionarray_each_var_object + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in order as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $substitutionarray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($substitutionarray, $outputlangs, $object); @@ -327,15 +327,15 @@ class doc_generic_contract_odt extends ModelePDFContract $tmparray = $substitutionarray; // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='CONTRACT_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'CONTRACT_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $tmparray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $tmparray); } @@ -346,15 +346,15 @@ class doc_generic_contract_odt extends ModelePDFContract $srctemplatepath, array( 'PATH_TO_TMP' => $conf->contrat->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -374,7 +374,7 @@ class doc_generic_contract_odt extends ModelePDFContract dol_syslog($e->getMessage(), LOG_INFO); } - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -400,7 +400,7 @@ class doc_generic_contract_odt extends ModelePDFContract try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -410,22 +410,22 @@ class doc_generic_contract_odt extends ModelePDFContract { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -435,36 +435,36 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } } @@ -472,25 +472,25 @@ class doc_generic_contract_odt extends ModelePDFContract try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index e441cc81365..b9bfa0a35d6 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -46,17 +46,17 @@ class mod_contract_magre extends ModelNumRefContracts * @deprecated * @see $name */ - public $nom='Magre'; + public $nom = 'Magre'; /** * @var string name */ - public $name='Magre'; + public $name = 'Magre'; /** * @var int Automatic numbering */ - public $code_auto=1; + public $code_auto = 1; /** * Return default description of numbering model @@ -65,31 +65,31 @@ class mod_contract_magre extends ModelNumRefContracts */ public function info() { - global $conf,$langs, $db; + global $conf, $langs, $db; $langs->load("bills"); $form = new Form($db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Contract"), $langs->transnoentities("Contract")); + $tooltip .= $langs->trans("GenericMaskCodes5"); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; - $texte.= '
'; + $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; + $texte .= ''; return $texte; } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 65b7f5011cc..0e9db902662 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -118,56 +118,56 @@ class pdf_rouget extends ModelePdfExpedition */ public function __construct($db = 0) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $this->db = $db; $this->name = "rouget"; $this->description = $langs->trans("DocumentModelStandardPDF"); $this->type = 'pdf'; - $formatarray=pdf_getFormat(); + $formatarray = pdf_getFormat(); $this->page_largeur = $formatarray['width']; $this->page_hauteur = $formatarray['height']; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; - $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; - $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; - $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; - $this->option_logo = 1; // Display logo + $this->option_logo = 1; // Display logo // Get source company - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined // Define position of columns - $this->posxdesc=$this->marge_gauche+1; - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 78; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 56; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 28; - $this->posxpuht=$this->page_largeur - $this->marge_droite; + $this->posxdesc = $this->marge_gauche + 1; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28; + $this->posxpuht = $this->page_largeur - $this->marge_droite; if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { // Show also the prices - $this->posxweightvol=$this->page_largeur - $this->marge_droite - 118; - $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 96; - $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 68; - $this->posxpuht=$this->page_largeur - $this->marge_droite - 40; - $this->posxtotalht=$this->page_largeur - $this->marge_droite - 20; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96; + $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68; + $this->posxpuht = $this->page_largeur - $this->marge_droite - 40; + $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; } - if(!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqtyordered; + if (!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqtyordered; - $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images // To work with US executive format if ($this->page_largeur < 210) { - $this->posxweightvol-=20; - $this->posxpicture-=20; - $this->posxqtyordered-=20; - $this->posxqtytoship-=20; + $this->posxweightvol -= 20; + $this->posxpicture -= 20; + $this->posxqtyordered -= 20; + $this->posxqtytoship -= 20; } - if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { + if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxqtyordered = $this->posxqtytoship; @@ -189,13 +189,13 @@ class pdf_rouget extends ModelePdfExpedition public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$conf,$langs,$hookmanager; + global $user, $conf, $langs, $hookmanager; $object->fetch_thirdparty(); - if (! is_object($outputlangs)) $outputlangs=$langs; + if (!is_object($outputlangs)) $outputlangs = $langs; // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); @@ -203,49 +203,49 @@ class pdf_rouget extends ModelePdfExpedition $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show - $realpatharray=array(); - if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) + $realpatharray = array(); + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - for ($i = 0 ; $i < $nblines ; $i++) + for ($i = 0; $i < $nblines; $i++) { if (empty($object->lines[$i]->fk_product)) continue; $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/"; + $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - $realpath=''; + $realpath = ''; foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo if ($obj['photo_vignette']) { - $filename= $obj['photo_vignette']; + $filename = $obj['photo_vignette']; } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } } else { - $filename=$obj['photo']; + $filename = $obj['photo']; } $realpath = $dir.$filename; break; } - if ($realpath) $realpatharray[$i]=$realpath; + if ($realpath) $realpatharray[$i] = $realpath; } } - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; + if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; if ($conf->expedition->dir_output) { @@ -253,20 +253,20 @@ class pdf_rouget extends ModelePdfExpedition if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; - $file = $dir . "/SPECIMEN.pdf"; + $file = $dir."/SPECIMEN.pdf"; } else { $expref = dol_sanitizeFileName($object->ref); - $dir = $conf->expedition->dir_output."/sending/" . $expref; - $file = $dir . "/" . $expref . ".pdf"; + $dir = $conf->expedition->dir_output."/sending/".$expref; + $file = $dir."/".$expref.".pdf"; } - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } @@ -274,25 +274,25 @@ class pdf_rouget extends ModelePdfExpedition if (file_exists($dir)) { // Add pdfgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook $nblines = count($object->lines); - $pdf=pdf_getInstance($this->format); + $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); - $heightforinfotot = 8; // Height reserved to output the info and total part - $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; + $heightforinfotot = 8; // Height reserved to output the info and total part + $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; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -302,14 +302,14 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); $tplidx = $pdf->importPage(1); } $pdf->Open(); - $pagenb=0; + $pagenb = 0; $pdf->SetDrawColor(128, 128, 128); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -319,21 +319,21 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Shipment")); - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); $tab_height = 130; $tab_height_newpage = 150; @@ -347,51 +347,51 @@ class pdf_rouget extends ModelePdfExpedition $tab_top = 88; $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); - $height_incoterms=$nexY-$tab_top; + $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1); - $tab_top = $nexY+6; + $tab_top = $nexY + 6; $height_incoterms += 4; } } - if (! empty($object->note_public) || ! empty($object->tracking_number)) + if (!empty($object->note_public) || !empty($object->tracking_number)) { $tab_top = 88 + $height_incoterms; $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); //$tab_top_alt += 1; // Tracking number - if (! empty($object->tracking_number)) + if (!empty($object->tracking_number)) { $object->getUrlTrackingStatus($object->tracking_number); - if (! empty($object->tracking_url)) + if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - $label=''; - if ($object->tracking_url != $object->tracking_number) $label.=$outputlangs->trans("LinkToTrackYourPackage")."
"; - $label.=$outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); + $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + $label = ''; + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; + $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); //var_dump($object->tracking_url != $object->tracking_number);exit; if ($object->tracking_url != $object->tracking_number) { - $label.=" : "; - $label.=$object->tracking_url; + $label .= " : "; + $label .= $object->tracking_url; } $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top_alt, $label, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); $tab_top_alt = $pdf->GetY(); } @@ -399,25 +399,25 @@ class pdf_rouget extends ModelePdfExpedition } // Notes - if (! empty($object->note_public)) + if (!empty($object->note_public)) { - $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $height_note = $nexY - $tab_top; // Rect takes a length in 3rd parameter $pdf->SetDrawColor(192, 192, 192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; + $tab_top = $nexY + 6; } else { - $height_note=0; + $height_note = 0; } $iniY = $tab_top + 7; @@ -428,87 +428,87 @@ class pdf_rouget extends ModelePdfExpedition for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0, 0, 0); // Define size of image if we need it - $imglinesize=array(); - if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $imglinesize = array(); + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore=$pdf->getPage(); + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); - $showpricebeforepagebreak=1; - $posYAfterImage=0; - $posYAfterDescription=0; + $showpricebeforepagebreak = 1; + $posYAfterImage = 0; + $posYAfterDescription = 0; // We start with Photo of product line - if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // If photo too high, we moved completely on new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore+1); + $pdf->setPage($pageposbefore + 1); $curY = $tab_top_newpage; - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } if (isset($imglinesize['width']) && isset($imglinesize['height'])) { - $curX = $this->posxpicture-1; - $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + $curX = $this->posxpicture - 1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage=$curY+$imglinesize['height']; + $posYAfterImage = $curY + $imglinesize['height']; } // Description of product line - $curX = $this->posxdesc-1; + $curX = $this->posxdesc - 1; $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter=$pageposbefore; + $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture-$curX, 3, $curX, $curY, $hideref, $hidedesc); + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); - $pageposafter=$pdf->getPage(); - $posyafter=$pdf->GetY(); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text { - if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page { $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); + $pdf->setPage($pageposafter + 1); } } else { // We found a page break - $showpricebeforepagebreak=0; + $showpricebeforepagebreak = 0; } } else // No pagebreak { $pdf->commitTransaction(); } - $posYAfterDescription=$pdf->GetY(); + $posYAfterDescription = $pdf->GetY(); $nexY = $pdf->GetY(); - $pageposafter=$pdf->getPage(); + $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. // We suppose that a too long description or photo were moved completely on next page if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { @@ -520,23 +520,23 @@ class pdf_rouget extends ModelePdfExpedition $pdf->setPage($pageposafter); $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetXY($this->posxweightvol, $curY); - $weighttxt=''; + $weighttxt = ''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { - $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); + $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units); } - $voltxt=''; + $voltxt = ''; if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { - $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0); + $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0); } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) { - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); } @@ -552,25 +552,25 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped, '', 'C'); } - if(!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) + if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); - $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); + $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); $pdf->SetXY($this->posxtotalht, $curY); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R'); } - $nexY+=3; - if ($weighttxt && $voltxt) $nexY+=2; + $nexY += 3; + if ($weighttxt && $voltxt) $nexY += 2; // Add line - if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); - $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); + $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY-1, $this->page_largeur - $this->marge_droite, $nexY-1); + $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); $pdf->SetLineStyle(array('dash'=>0)); } @@ -589,10 +589,10 @@ class pdf_rouget extends ModelePdfExpedition $this->_pagefoot($pdf, $object, $outputlangs, 1); $pagenb++; $pdf->setPage($pagenb); - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } - if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -605,7 +605,7 @@ class pdf_rouget extends ModelePdfExpedition $this->_pagefoot($pdf, $object, $outputlangs, 1); // New page $pdf->AddPage(); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); } @@ -615,16 +615,16 @@ class pdf_rouget extends ModelePdfExpedition if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); - $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); + $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pied de page $this->_pagefoot($pdf, $object, $outputlangs); @@ -636,31 +636,31 @@ class pdf_rouget extends ModelePdfExpedition // Add pdfgeneration hook $hookmanager->initHooks(array('pdfgeneration')); - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); global $action; - $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { $this->error = $hookmanager->error; $this->errors = $hookmanager->errors; } - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); $this->result = array('fullpath'=>$file); - return 1; // No error + return 1; // No error } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return 0; } } else { - $this->error=$langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); + $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); return 0; } } @@ -680,9 +680,9 @@ class pdf_rouget extends ModelePdfExpedition protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf,$mysoc; + global $conf, $mysoc; - $sign=1; + $sign = 1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -691,7 +691,7 @@ 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; @@ -699,33 +699,33 @@ class pdf_rouget extends ModelePdfExpedition if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - $useborder=0; + $useborder = 0; $index = 0; - $totalWeighttoshow=''; - $totalVolumetoshow=''; + $totalWeighttoshow = ''; + $totalVolumetoshow = ''; // Load dim data - $tmparray=$object->getTotalWeightVolume(); - $totalWeight=$tmparray['weight']; - $totalVolume=$tmparray['volume']; - $totalOrdered=$tmparray['ordered']; - $totalToShip=$tmparray['toship']; + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + $totalOrdered = $tmparray['ordered']; + $totalToShip = $tmparray['toship']; // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); - $object->volume_units=$object->size_units * 3; + $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); + $object->volume_units = $object->size_units * 3; } - if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); - if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); - if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); - if ($object->trueVolume) $totalVolumetoshow=showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); + if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); + if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); $pdf->SetFillColor(255, 255, 255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { @@ -765,7 +765,7 @@ class pdf_rouget extends ModelePdfExpedition $index++; } - if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; + if (!$totalWeighttoshow && !$totalVolumetoshow) $index++; } $pdf->SetTextColor(0, 0, 0); @@ -791,8 +791,8 @@ class pdf_rouget extends ModelePdfExpedition global $conf; // Force to disable hidetop and hidebottom - $hidebottom=0; - if ($hidetop) $hidetop=-1; + $hidebottom = 0; + if ($hidetop) $hidetop = -1; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -801,61 +801,61 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('', '', $default_font_size - 2); // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); if (empty($hidetop)) { - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); - $pdf->SetXY($this->posxdesc-1, $tab_top+1); + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); } if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) { - $pdf->line($this->posxweightvol-1, $tab_top, $this->posxweightvol-1, $tab_top + $tab_height); + $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxweightvol-1, $tab_top+1); + $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C'); } } if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { - $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); + $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtyordered-1, $tab_top+1); + $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C'); } } if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) { - $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); + $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxqtytoship, $tab_top+1); + $pdf->SetXY($this->posxqtytoship, $tab_top + 1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C'); } } if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { - $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); + $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxpuht-1, $tab_top+1); + $pdf->SetXY($this->posxpuht - 1, $tab_top + 1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); } - $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); + $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height); if (empty($hidetop)) { - $pdf->SetXY($this->posxtotalht-1, $tab_top+1); + $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1); $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); } } @@ -873,7 +873,7 @@ class pdf_rouget extends ModelePdfExpedition */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; $langs->load("orders"); @@ -882,7 +882,7 @@ class pdf_rouget extends ModelePdfExpedition pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark - if($object->statut==0 && (! empty($conf->global->SHIPPING_DRAFT_WATERMARK)) ) + if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) { pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); } @@ -893,19 +893,19 @@ class pdf_rouget extends ModelePdfExpedition $w = 110; - $posy=$this->marge_haute; - $posx=$this->page_largeur-$this->marge_droite-$w; + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - $w; $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) { if (is_readable($logo)) { - $height=pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) } else { @@ -917,21 +917,21 @@ class pdf_rouget extends ModelePdfExpedition } else { - $text=$this->emetteur->name; + $text = $this->emetteur->name; $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } // Show barcode - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { - $posx=105; + $posx = 105; } else { - $posx=$this->marge_gauche+3; + $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition } $pdf->SetDrawColor(128, 128, 128); - if (! empty($conf->barcode->enabled)) + if (!empty($conf->barcode->enabled)) { // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); @@ -947,67 +947,67 @@ class pdf_rouget extends ModelePdfExpedition } - $posx=$this->page_largeur - $w - $this->marge_droite; - $posy=$this->marge_haute; + $posx = $this->page_largeur - $w - $this->marge_droite; + $posy = $this->marge_haute; $pdf->SetFont('', 'B', $default_font_size + 2); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $title=$outputlangs->transnoentities("SendingSheet"); + $title = $outputlangs->transnoentities("SendingSheet"); $pdf->MultiCell($w, 4, $title, '', 'R'); $pdf->SetFont('', '', $default_font_size + 1); - $posy+=5; + $posy += 5; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); + $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending")." : ".$object->ref, '', 'R'); // Date planned delivery - if (! empty($object->date_delivery)) + if (!empty($object->date_delivery)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R'); } - if (! empty($object->thirdparty->code_client)) + if (!empty($object->thirdparty->code_client)) { - $posy+=4; + $posy += 4; $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); + $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } $pdf->SetFont('', '', $default_font_size + 3); - $Yoff=25; + $Yoff = 25; // Add list of linked orders - $origin = $object->origin; - $origin_id = $object->origin_id; + $origin = $object->origin; + $origin_id = $object->origin_id; // TODO move to external function - if (! empty($conf->$origin->enabled)) // commonly $origin='commande' + if (!empty($conf->$origin->enabled)) // commonly $origin='commande' { $outputlangs->load('orders'); $classname = ucfirst($origin); $linkedobject = new $classname($this->db); - $result=$linkedobject->fetch($origin_id); + $result = $linkedobject->fetch($origin_id); if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects $pdf->SetFont('', '', $default_font_size - 2); - $text=$linkedobject->ref; - if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; - $Yoff = $Yoff+8; + $text = $linkedobject->ref; + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; + $Yoff = $Yoff + 8; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); - $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); - $Yoff = $Yoff+3; + $pdf->MultiCell($w, 2, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), 0, 'R'); + $Yoff = $Yoff + 3; $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff); $pdf->MultiCell($w, 2, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($linkedobject->date, "day", false, $outputlangs, true), 0, 'R'); } @@ -1016,30 +1016,30 @@ class pdf_rouget extends ModelePdfExpedition if ($showaddress) { // Sender properties - $carac_emetteur=''; + $carac_emetteur = ''; // Add internal contact of origin element if defined - $arrayidcontact=array(); - if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal', 'SALESREPFOLL'); + $arrayidcontact = array(); + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); if (count($arrayidcontact) > 0) { $object->fetch_user(reset($arrayidcontact)); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; + $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object); // Show sender - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->marge_gauche; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->marge_gauche; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80; - $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; + $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; // Show sender frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx, $posy-5); + $pdf->SetXY($posx, $posy - 5); $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); @@ -1048,24 +1048,24 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(255, 255, 255); // Show sender name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); - $pdf->MultiCell($widthrecbox-2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); - $posy=$pdf->getY(); + $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); + $posy = $pdf->getY(); // Show sender information - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->SetFont('', '', $default_font_size - 1); - $pdf->MultiCell($widthrecbox-2, 4, $carac_emetteur, 0, 'L'); + $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L'); // If SHIPPING contact defined, we use it - $usecontact=false; - $arrayidcontact=$object->$origin->getIdContact('external', 'SHIPPING'); + $usecontact = false; + $arrayidcontact = $object->$origin->getIdContact('external', 'SHIPPING'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } //Recipient name @@ -1076,26 +1076,26 @@ class pdf_rouget extends ModelePdfExpedition $thirdparty = $object->thirdparty; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact)?$object->contact:null), $usecontact, 'targetwithdetails', $object); + $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object); // Show recipient - $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format - $posy=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; - $posx=$this->page_largeur - $this->marge_droite - $widthrecbox; - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; + $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100; + if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; + $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; // Show recipient frame $pdf->SetTextColor(0, 0, 0); $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx+2, $posy-5); + $pdf->SetXY($posx + 2, $posy - 5); $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L'); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); // Show recipient name - $pdf->SetXY($posx+2, $posy+3); + $pdf->SetXY($posx + 2, $posy + 3); $pdf->SetFont('', 'B', $default_font_size); $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L'); @@ -1103,7 +1103,7 @@ class pdf_rouget extends ModelePdfExpedition // Show recipient information $pdf->SetFont('', '', $default_font_size - 1); - $pdf->SetXY($posx+2, $posy); + $pdf->SetXY($posx + 2, $posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } @@ -1123,7 +1123,7 @@ class pdf_rouget extends ModelePdfExpedition protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } } 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 c2fec907775..5e0cc4d4076 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 @@ -66,37 +66,37 @@ class doc_generic_product_odt extends ModelePDFProduct global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PRODUCT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva PRODUCT_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -111,60 +111,60 @@ class doc_generic_product_odt extends ModelePDFProduct global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PRODUCT_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories if (count($listofdir)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; /*if ($conf->global->MAIN_PRODUCT_CHOOSE_ODT_DOCUMENT > 0) { @@ -192,15 +192,15 @@ class doc_generic_product_odt extends ModelePDFProduct }*/ } - $texte.= '
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -220,7 +220,7 @@ class doc_generic_product_odt extends ModelePDFProduct public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $product,$langs,$conf,$mysoc,$hookmanager,$user; + global $product, $langs, $conf, $mysoc, $hookmanager, $user; if (empty($srctemplatepath)) { @@ -229,17 +229,17 @@ class doc_generic_product_odt extends ModelePDFProduct } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -247,11 +247,11 @@ class doc_generic_product_odt extends ModelePDFProduct if ($conf->product->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Product($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -264,14 +264,14 @@ class doc_generic_product_odt extends ModelePDFProduct $dir = $conf->product->dir_output; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -279,26 +279,26 @@ class doc_generic_product_odt extends ModelePDFProduct if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -308,20 +308,20 @@ class doc_generic_product_odt extends ModelePDFProduct // If CUSTOMER contact defined on product, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; @@ -331,10 +331,10 @@ class doc_generic_product_odt extends ModelePDFProduct } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -343,15 +343,15 @@ class doc_generic_product_odt extends ModelePDFProduct ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='product_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'product_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -361,7 +361,7 @@ class doc_generic_product_odt extends ModelePDFProduct $srctemplatepath, array( 'PATH_TO_TMP' => $conf->product->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) @@ -369,7 +369,7 @@ class doc_generic_product_odt extends ModelePDFProduct } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -394,22 +394,22 @@ class doc_generic_product_odt extends ModelePDFProduct $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); //$array_objet=$this->get_substitutionarray_object($object,$outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -431,15 +431,15 @@ class doc_generic_product_odt extends ModelePDFProduct try { $listlines = $odfHandler->setSegment('supplierprices'); - if(!empty($object->supplierprices)){ + if (!empty($object->supplierprices)) { foreach ($object->supplierprices as $supplierprice) { $array_lines = $this->get_substitutionarray_each_var_object($supplierprice, $outputlangs); complete_substitutions_array($array_lines, $outputlangs, $object, $supplierprice, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$array_lines,'line'=>$supplierprice); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($array_lines as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$array_lines, 'line'=>$supplierprice); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($array_lines as $key => $val) { try { @@ -461,34 +461,34 @@ class doc_generic_product_odt extends ModelePDFProduct } catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -497,26 +497,26 @@ class doc_generic_product_odt extends ModelePDFProduct try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index cb6a8411543..ba6329004e3 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -39,26 +39,26 @@ class mod_codeproduct_elephant extends ModeleProductCode * @deprecated * @see $name */ - public $nom='Elephant'; + public $nom = 'Elephant'; /** * @var string model name */ - public $name='Elephant'; + public $name = 'Elephant'; - public $code_modifiable; // Code modifiable + public $code_modifiable; // Code modifiable - public $code_modifiable_invalide; // Code modifiable si il est invalide + public $code_modifiable_invalide; // Code modifiable si il est invalide - public $code_modifiable_null; // Code modifiables si il est null + public $code_modifiable_null; // Code modifiables si il est null - public $code_null; // Code facultatif + public $code_null; // Code facultatif /** * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var int Automatic numbering @@ -99,36 +99,36 @@ class mod_codeproduct_elephant extends ModeleProductCode $langs->load("products"); - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product")); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4c"); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Product"), $langs->transnoentities("Product")); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4c"); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix customers - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; // Parametrage du prefix suppliers - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("ProductCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("ServiceCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -147,27 +147,27 @@ class mod_codeproduct_elephant extends ModeleProductCode if ($type == 0 || $type == -1) { $exampleproduct = $this->getNextValue($objproduct, 0); - if (! $exampleproduct) + if (!$exampleproduct) { $exampleproduct = $langs->trans('NotConfigured'); } - if($exampleproduct=="ErrorBadMask") + if ($exampleproduct == "ErrorBadMask") { $langs->load("errors"); - $exampleproduct=$langs->trans($exampleproduct); + $exampleproduct = $langs->trans($exampleproduct); } } if ($type == 1 || $type == -1) { $exampleservice = $this->getNextValue($objproduct, 1); - if (! $exampleservice) + if (!$exampleservice) { $exampleservice = $langs->trans('NotConfigured'); } - if($exampleservice=="ErrorBadMask") + if ($exampleservice == "ErrorBadMask") { $langs->load("errors"); - $exampleservice=$langs->trans($exampleservice); + $exampleservice = $langs->trans($exampleservice); } } @@ -185,24 +185,24 @@ class mod_codeproduct_elephant extends ModeleProductCode */ public function getNextValue($objproduct = 0, $type = -1) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Get Mask value $mask = ''; - if ($type == 0 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) + if ($type == 0 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)) $mask = $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; - elseif ($type == 1 && ! empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) + elseif ($type == 1 && !empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)) $mask = $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; if (empty($mask)) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return ''; } - $field='';$where=''; + $field = ''; $where = ''; if ($type == 0) { $field = 'ref'; @@ -215,14 +215,14 @@ class mod_codeproduct_elephant extends ModeleProductCode } else return -1; - $now=dol_now(); + $now = dol_now(); - if (! empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE)) + if (!empty($conf->global->PRODUCT_ELEPHANT_ADD_WHERE)) { $where = ' AND ('.dol_string_nospecial(dol_string_unaccent($conf->global->PRODUCT_ELEPHANT_ADD_WHERE), '_', array(',', '@', '"', "|", ";", ":")).')'; } - $numFinal=get_next_value($db, $mask, 'product', $field, $where, '', $now); + $numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now); return $numFinal; } @@ -267,32 +267,32 @@ class mod_codeproduct_elephant extends ModeleProductCode { global $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result=0; + $result = 0; $code = strtoupper(trim($code)); if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { - $result=0; + $result = 0; } - elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) + elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { - $result=-2; + $result = -2; } else { // Get Mask value $mask = ''; - if ($type==0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT)?'':$conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; - if ($type==1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE)?'':$conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; - if (! $mask) + if ($type == 0) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_PRODUCT; + if ($type == 1) $mask = empty($conf->global->PRODUCT_ELEPHANT_MASK_SERVICE) ? '' : $conf->global->PRODUCT_ELEPHANT_MASK_SERVICE; + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return -5; } - $result=check_value($mask, $code); + $result = check_value($mask, $code); if (is_string($result)) { $this->error = $result; @@ -318,10 +318,10 @@ class mod_codeproduct_elephant extends ModeleProductCode { // phpcs:enable $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE ref = '".$code."'"; - if ($product->id > 0) $sql.= " AND rowid <> ".$product->id; + $sql .= " WHERE ref = '".$code."'"; + if ($product->id > 0) $sql .= " AND rowid <> ".$product->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 4219d8100cb..9bf0d313ae8 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -22,7 +22,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php'; /** @@ -34,7 +34,7 @@ class mod_project_universal extends ModeleNumRefProjects * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -46,12 +46,12 @@ class mod_project_universal extends ModeleNumRefProjects * @deprecated * @see name */ - public $nom='Universal'; + public $nom = 'Universal'; /** * @var string model name */ - public $name='Universal'; + public $name = 'Universal'; /** @@ -64,33 +64,33 @@ class mod_project_universal extends ModeleNumRefProjects global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("projects","admin")); + $langs->loadLangs(array("projects", "admin")); $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Project"), $langs->transnoentities("Project")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Project"), $langs->transnoentities("Project")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -102,14 +102,14 @@ class mod_project_universal extends ModeleNumRefProjects */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $mysoc->code_client='CCCCCCCCCC'; + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; + $mysoc->code_client = $old_code_client; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -125,21 +125,21 @@ class mod_project_universal extends ModeleNumRefProjects */ public function getNextValue($objsoc, $project) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask=$conf->global->PROJECT_UNIVERSAL_MASK; + $mask = $conf->global->PROJECT_UNIVERSAL_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } - $date=empty($project->date_c)?dol_now():$project->date_c; - $numFinal=get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); + $date = empty($project->date_c) ?dol_now() : $project->date_c; + $numFinal = get_next_value($db, $mask, 'projet', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); return $numFinal; } 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 98158e4cf05..a53e7647711 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 @@ -38,16 +38,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; /** @@ -84,37 +84,37 @@ class doc_generic_task_odt extends ModelePDFTask global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PROJECT_TASK_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 0; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -132,7 +132,7 @@ class doc_generic_task_odt extends ModelePDFTask // phpcs:enable global $conf; - $resarray=array( + $resarray = array( $array_key.'_id'=>$object->id, $array_key.'_ref'=>$object->ref, $array_key.'_title'=>$object->title, @@ -150,7 +150,7 @@ class doc_generic_task_odt extends ModelePDFTask // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) { - $extrafieldkey=$object->element; + $extrafieldkey = $object->element; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); @@ -341,83 +341,83 @@ class doc_generic_task_odt extends ModelePDFTask */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->PROJECT_TASK_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=$nbofiles; + $texte .= $nbofiles; //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -434,7 +434,7 @@ class doc_generic_task_odt extends ModelePDFTask public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -442,9 +442,9 @@ class doc_generic_task_odt extends ModelePDFTask return -1; } - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); @@ -452,32 +452,32 @@ class doc_generic_task_odt extends ModelePDFTask if ($conf->projet->dir_output) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Task($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); return -1; } } - $project= new Project($this->db); + $project = new Project($this->db); $project->fetch($object->fk_project); $project->fetch_thirdparty(); - $dir = $conf->projet->dir_output. "/" . $project->ref. "/"; + $dir = $conf->projet->dir_output."/".$project->ref."/"; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { print '$dir'.$dir; if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -486,13 +486,13 @@ class doc_generic_task_odt extends ModelePDFTask if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.(ods|odt)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.(ods|odt)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref.'_'.$newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; - $file=$dir.'/'.$newfiletmp.'.odt'; + $file = $dir.'/'.$newfiletmp.'.odt'; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -500,17 +500,17 @@ class doc_generic_task_odt extends ModelePDFTask dol_mkdir($conf->projet->dir_temp); - $socobject=$project->thirdparty; + $socobject = $project->thirdparty; // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Open and load template require_once ODTPHP_PATH.'odf.php'; @@ -519,15 +519,15 @@ class doc_generic_task_odt extends ModelePDFTask $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); return -1; } // After construction $odfHandler->contentXml contains content and @@ -540,16 +540,16 @@ class doc_generic_task_odt extends ModelePDFTask // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($project, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_objet = $this->get_substitutionarray_object($project, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -570,30 +570,30 @@ class doc_generic_task_odt extends ModelePDFTask try { // Security check - $socid=0; + $socid = 0; if (!empty($project->fk_soc)) $socid = $project->fk_soc; - $tmparray=$this->get_substitutionarray_tasks($object, $outputlangs); + $tmparray = $this->get_substitutionarray_tasks($object, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $odfHandler->setVars($key, $val, true, 'UTF-8'); } catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); - } catch(SegmentException $e) { + } catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } } // Replace tags of lines for contacts task - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$object->liste_contact(-1, $source); + $contact_temp = $object->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -602,23 +602,23 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_tasksressource($contact, $outputlangs); + $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestaskres->setVars($key, $val, true, 'UTF-8'); @@ -636,7 +636,7 @@ class doc_generic_task_odt extends ModelePDFTask // Time ressources $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; - $sql.= ", u.lastname, u.firstname"; + $sql .= ", u.lastname, u.firstname"; $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE t.fk_task =".$object->id; @@ -654,27 +654,27 @@ class doc_generic_task_odt extends ModelePDFTask { $row = $this->db->fetch_array($resql); if (!empty($row['fk_user'])) { - $objectdetail=new User($this->db); + $objectdetail = new User($this->db); $objectdetail->fetch($row['fk_user']); // TODO Use a cache to aoid fetch for same user - $row['fullcivname']=$objectdetail->getFullName($outputlangs, 1); + $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1); } else { - $row['fullcivname']=''; + $row['fullcivname'] = ''; } - $tmparray=$this->get_substitutionarray_taskstime($row, $outputlangs); + $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlinestasktime->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -692,24 +692,24 @@ class doc_generic_task_odt extends ModelePDFTask $listtasksfiles = $odfHandler->setSegment('tasksfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref).'/'.dol_sanitizeFileName($object->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { - $tmparray=$this->get_substitutionarray_task_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs); //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true)); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listtasksfiles->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -720,9 +720,9 @@ class doc_generic_task_odt extends ModelePDFTask $odfHandler->mergeSegment($listtasksfiles); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -735,25 +735,25 @@ class doc_generic_task_odt extends ModelePDFTask $listlines = $odfHandler->setSegment('projectfiles'); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1); foreach ($filearray as $filedetail) { //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true)); - $tmparray=$this->get_substitutionarray_project_file($filedetail, $outputlangs); + $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -762,21 +762,21 @@ class doc_generic_task_odt extends ModelePDFTask } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace tags of lines for contacts - $sourcearray=array('internal','external'); - $contact_arrray=array(); + $sourcearray = array('internal', 'external'); + $contact_arrray = array(); foreach ($sourcearray as $source) { - $contact_temp=$project->liste_contact(-1, $source); + $contact_temp = $project->liste_contact(-1, $source); if ((is_array($contact_temp) && count($contact_temp) > 0)) { - $contact_arrray=array_merge($contact_arrray, $contact_temp); + $contact_arrray = array_merge($contact_arrray, $contact_temp); } } if ((is_array($contact_arrray) && count($contact_arrray) > 0)) @@ -787,33 +787,33 @@ class doc_generic_task_odt extends ModelePDFTask foreach ($contact_arrray as $contact) { - if ($contact['source']=='internal') { - $objectdetail=new User($this->db); + if ($contact['source'] == 'internal') { + $objectdetail = new User($this->db); $objectdetail->fetch($contact['id']); - $contact['socname']=$mysoc->name; - } elseif ($contact['source']=='external') { - $objectdetail=new Contact($this->db); + $contact['socname'] = $mysoc->name; + } elseif ($contact['source'] == 'external') { + $objectdetail = new Contact($this->db); $objectdetail->fetch($contact['id']); - $soc=new Societe($this->db); + $soc = new Societe($this->db); $soc->fetch($contact['socid']); - $contact['socname']=$soc->name; + $contact['socname'] = $soc->name; } - $contact['fullname']=$objectdetail->getFullName($outputlangs, 1); + $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1); - $tmparray=$this->get_substitutionarray_project_contacts($contact, $outputlangs); + $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs); - foreach($tmparray as $key => $val) + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -822,9 +822,9 @@ class doc_generic_task_odt extends ModelePDFTask } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } @@ -832,8 +832,8 @@ class doc_generic_task_odt extends ModelePDFTask // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file @@ -841,7 +841,7 @@ class doc_generic_task_odt extends ModelePDFTask try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -850,26 +850,26 @@ class doc_generic_task_odt extends ModelePDFTask try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index 2740f522ff2..1eecf94734b 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -22,7 +22,7 @@ * \brief Fichier contenant la classe du modele de numerotation de reference de projet Universal */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php'; /** @@ -34,7 +34,7 @@ class mod_task_universal extends ModeleNumRefTask * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -46,12 +46,12 @@ class mod_task_universal extends ModeleNumRefTask * @deprecated * @see name */ - public $nom='Universal'; + public $nom = 'Universal'; /** * @var string name */ - public $name='Universal'; + public $name = 'Universal'; /** @@ -61,36 +61,36 @@ class mod_task_universal extends ModeleNumRefTask */ public function info() { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("projects","admin")); + $langs->loadLangs(array("projects", "admin")); $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Task"), $langs->transnoentities("Task")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Task"), $langs->transnoentities("Task")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -102,14 +102,14 @@ class mod_task_universal extends ModeleNumRefTask */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $mysoc->code_client='CCCCCCCCCC'; + $old_code_client = $mysoc->code_client; + $mysoc->code_client = 'CCCCCCCCCC'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; + $mysoc->code_client = $old_code_client; - if (! $numExample) + if (!$numExample) { $numExample = $langs->trans('NotConfigured'); } @@ -125,21 +125,21 @@ class mod_task_universal extends ModeleNumRefTask */ public function getNextValue($objsoc, $object) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur - $mask=$conf->global->PROJECT_TASK_UNIVERSAL_MASK; + $mask = $conf->global->PROJECT_TASK_UNIVERSAL_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } - $date=empty($object->date_c)?dol_now():$object->date_c; - $numFinal=get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc)?$objsoc->code_client:''), $date); + $date = empty($object->date_c) ?dol_now() : $object->date_c; + $numFinal = get_next_value($db, $mask, 'projet_task', 'ref', '', (is_object($objsoc) ? $objsoc->code_client : ''), $date); return $numFinal; } 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 3404d450a9f..b3c26ffd0bb 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 @@ -65,37 +65,37 @@ class doc_generic_proposal_odt extends ModelePDFPropales global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION - $this->option_modereg = 0; // Affiche mode reglement - $this->option_condreg = 0; // Affiche conditions reglement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 1; // Dispo en plusieurs langues - $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 0; // Support credit notes - $this->option_freetext = 1; // Support add of a personalised text - $this->option_draft_watermark = 0; // Support add of a watermark on drafts + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte + $this->option_credit_note = 0; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text + $this->option_draft_watermark = 0; // Support add of a watermark on drafts // Recupere emetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined } @@ -107,114 +107,114 @@ class doc_generic_proposal_odt extends ModelePDFPropales */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors","companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0) { - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; } - $texte.= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= '"; + $texte .= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= '
'; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= '
'; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=count($listoffiles); + $texte .= count($listoffiles); //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'.$langs->trans("DefaultModelPropalClosed").''; + $texte .= $form->selectarray('value4', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED); + $texte .= "
'; } } - $texte.= '
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= ''; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -234,7 +234,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -243,17 +243,17 @@ class doc_generic_proposal_odt extends ModelePDFPropales } // Add odtgeneration hook - if (! is_object($hookmanager)) + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); @@ -261,11 +261,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales if ($conf->propal->multidir_output[$conf->entity]) { // If $object is id instead of object - if (! is_object($object)) + if (!is_object($object)) { $id = $object; $object = new Propal($this->db); - $result=$object->fetch($id); + $result = $object->fetch($id); if ($result < 0) { dol_print_error($this->db, $object->error); @@ -275,14 +275,14 @@ class doc_generic_proposal_odt extends ModelePDFPropales $dir = $conf->propal->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->ref); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; - $file = $dir . "/" . $objectref . ".odt"; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; + $file = $dir."/".$objectref.".odt"; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -290,26 +290,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(t|s)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); - $newfiletmp=$objectref.'_'.$newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; + $file = $dir.'/'.$filename; //print "newdir=".$dir; //print "newfile=".$newfile; //print "file=".$file; @@ -319,20 +319,20 @@ class doc_generic_proposal_odt extends ModelePDFPropales // If CUSTOMER contact defined on proposal, we use it - $usecontact=false; - $arrayidcontact=$object->getIdContact('external', 'CUSTOMER'); + $usecontact = false; + $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); + $usecontact = true; + $result = $object->fetch_contact($arrayidcontact[0]); } // Recipient name - $contactobject=null; - if (! empty($usecontact)) + $contactobject = null; + if (!empty($usecontact)) { // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use @@ -341,10 +341,10 @@ class doc_generic_proposal_odt extends ModelePDFPropales } else { - $socobject=$object->thirdparty; + $socobject = $object->thirdparty; } // Make substitution - $substitutionarray=array( + $substitutionarray = array( '__FROM_NAME__' => $this->emetteur->name, '__FROM_EMAIL__' => $this->emetteur->email, '__TOTAL_TTC__' => $object->total_ttc, @@ -353,15 +353,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales ); complete_substitutions_array($substitutionarray, $langs, $object); // Call the ODTSubstitution hook - $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Line of free text - $newfreetext=''; - $paramfreetext='PROPOSAL_FREE_TEXT'; - if (! empty($conf->global->$paramfreetext)) + $newfreetext = ''; + $paramfreetext = 'PROPOSAL_FREE_TEXT'; + if (!empty($conf->global->$paramfreetext)) { - $newfreetext=make_substitutions($conf->global->$paramfreetext, $substitutionarray); + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } // Open and load template @@ -371,15 +371,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales $srctemplatepath, array( 'PATH_TO_TMP' => $conf->propal->multidir_temp[$object->entity], - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -402,24 +402,24 @@ class doc_generic_proposal_odt extends ModelePDFPropales // Define substitution array $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - $array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs); - $array_objet=$this->get_substitutionarray_object($object, $outputlangs); - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs); + $array_objet = $this->get_substitutionarray_object($object, $outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); // retrieve contact information for use in object as contact_xxx tags $array_thirdparty_contact = array(); - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); + if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -432,7 +432,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler->setVars($key, $value, true, 'UTF-8'); } } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -444,7 +444,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales try { $listlines = $odfHandler->setSegment('lines'); } - catch(OdfException $e) + catch (OdfException $e) { // We may arrive here if tags for lines not present into template $foundtagforlines = 0; @@ -454,22 +454,22 @@ class doc_generic_proposal_odt extends ModelePDFPropales { foreach ($object->lines as $line) { - $tmparray=$this->get_substitutionarray_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line); - $reshook=$hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - foreach($tmparray as $key => $val) + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); + $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -479,16 +479,16 @@ class doc_generic_proposal_odt extends ModelePDFPropales $odfHandler->mergeSegment($listlines); } } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); return -1; } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -500,15 +500,15 @@ class doc_generic_proposal_odt extends ModelePDFPropales } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -517,26 +517,26 @@ class doc_generic_proposal_odt extends ModelePDFPropales try { $odfHandler->saveToDisk($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 3004a15d1ba..de5f8b33c03 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -25,7 +25,7 @@ * \brief File that contains the numbering module rules Saphir */ -require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; /** @@ -37,7 +37,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -49,12 +49,12 @@ class mod_propale_saphir extends ModeleNumRefPropales * @deprecated * @see name */ - public $nom='Saphir'; + public $nom = 'Saphir'; /** * @var string model name */ - public $name='Saphir'; + public $name = 'Saphir'; /** @@ -71,28 +71,28 @@ class mod_propale_saphir extends ModeleNumRefPropales $form = new Form($this->db); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); - $tooltip.=$langs->trans("GenericMaskCodes2"); - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); + $tooltip .= $langs->trans("GenericMaskCodes2"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Proposal"), $langs->transnoentities("Proposal")); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).'   
'; - $texte.= '
'; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -104,17 +104,17 @@ class mod_propale_saphir extends ModeleNumRefPropales */ public function getExample() { - global $conf,$langs,$mysoc; + global $conf, $langs, $mysoc; - $old_code_client=$mysoc->code_client; - $old_code_type=$mysoc->typent_code; - $mysoc->code_client='CCCCCCCCCC'; - $mysoc->typent_code='TTTTTTTTTT'; + $old_code_client = $mysoc->code_client; + $old_code_type = $mysoc->typent_code; + $mysoc->code_client = 'CCCCCCCCCC'; + $mysoc->typent_code = 'TTTTTTTTTT'; $numExample = $this->getNextValue($mysoc, ''); - $mysoc->code_client=$old_code_client; - $mysoc->typent_code=$old_code_type; + $mysoc->code_client = $old_code_client; + $mysoc->typent_code = $old_code_type; - if (! $numExample) + if (!$numExample) { $numExample = 'NotConfigured'; } @@ -130,16 +130,16 @@ class mod_propale_saphir extends ModeleNumRefPropales */ public function getNextValue($objsoc, $propal) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // On defini critere recherche compteur $mask = $conf->global->PROPALE_SAPHIR_MASK; - if (! $mask) + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return 0; } @@ -148,7 +148,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $date = $propal->date; - $numFinal=get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity); + $numFinal = get_next_value($db, $mask, 'propal', 'ref', '', $objsoc, $date, 'next', false, null, $entity); return $numFinal; } 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 59ca0a1a97e..a9b95c6035f 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -59,28 +59,28 @@ class doc_generic_odt extends ModeleThirdPartyDoc global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main","companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; $this->description = $langs->trans("DocumentModelOdt"); - $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan + $this->scandir = 'COMPANY_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan // Page size for A4 format $this->type = 'odt'; $this->page_largeur = 0; $this->page_hauteur = 0; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=0; - $this->marge_droite=0; - $this->marge_haute=0; - $this->marge_basse=0; + $this->format = array($this->page_largeur, $this->page_hauteur); + $this->marge_gauche = 0; + $this->marge_droite = 0; + $this->marge_haute = 0; + $this->marge_basse = 0; - $this->option_logo = 1; // Affiche logo + $this->option_logo = 1; // Affiche logo // Retrieves transmitter - $this->emetteur=$mysoc; - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini } @@ -92,7 +92,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc */ public function info($langs) { - global $conf,$langs; + global $conf, $langs; // Load traductions files required by page $langs->loadLangs(array("companies", "errors")); @@ -100,76 +100,76 @@ class doc_generic_odt extends ModeleThirdPartyDoc $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; // List of directories area - $texte.= ''; + $texte .= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'; - $texttitle=$langs->trans("ListOfDirectories"); - $listofdir=explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); - $listoffiles=array(); - foreach($listofdir as $key=>$tmpdir) + $texte .= '
'; + $texttitle = $langs->trans("ListOfDirectories"); + $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMPANY_ADDON_PDF_ODT_PATH))); + $listoffiles = array(); + foreach ($listofdir as $key=>$tmpdir) { - $tmpdir=trim($tmpdir); - $tmpdir=preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); - if (! $tmpdir) { unset($listofdir[$key]); continue; } - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + $tmpdir = trim($tmpdir); + $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir); + if (!$tmpdir) { unset($listofdir[$key]); continue; } + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); else { - $tmpfiles=dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles, $tmpfiles); + $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0, true); // Disable hook for the moment + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } } - $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); + $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT"); // Add list of substitution keys - $texthelp.='
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; - $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it + $texthelp .= '
'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'
'; + $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it - $texte.= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= '
'; - $texte.= ''; - $texte.= '  '; - $texte.= ''; - $texte.= '
'; + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; + $texte .= ''; + $texte .= '  '; + $texte .= ''; + $texte .= '
'; // Scan directories - $nbofiles=count($listoffiles); - if (! empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) + $nbofiles = count($listoffiles); + if (!empty($conf->global->COMPANY_ADDON_PDF_ODT_PATH)) { - $texte.=$langs->trans("NumberOfModelFilesFound").': '; + $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; - $texte.=$nbofiles; + $texte .= $nbofiles; //$texte.=$nbofiles?'':''; - $texte.=''; + $texte .= ''; } if ($nbofiles) { - $texte.='
'; - $texte.= $langs->trans("ExampleOfDirectoriesForModelGen"); - $texte.= '
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -189,7 +189,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user, $langs, $conf, $mysoc, $hookmanager; if (empty($srctemplatepath)) { @@ -198,16 +198,16 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Add odtgeneration hook - if (! is_object($hookmanager)) { + if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; - $hookmanager=new HookManager($this->db); + $hookmanager = new HookManager($this->db); } $hookmanager->initHooks(array('odtgeneration')); global $action; - if (! is_object($outputlangs)) $outputlangs=$langs; - $sav_charset_output=$outputlangs->charset_output; - $outputlangs->charset_output='UTF-8'; + if (!is_object($outputlangs)) $outputlangs = $langs; + $sav_charset_output = $outputlangs->charset_output; + $outputlangs->charset_output = 'UTF-8'; // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); @@ -216,13 +216,13 @@ class doc_generic_odt extends ModeleThirdPartyDoc { $dir = $conf->societe->multidir_output[$object->entity]; $objectref = dol_sanitizeFileName($object->id); - if (! preg_match('/specimen/i', $objectref)) $dir.= "/" . $objectref; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; - if (! file_exists($dir)) + if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } @@ -230,28 +230,28 @@ class doc_generic_odt extends ModeleThirdPartyDoc if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename - $newfile=basename($srctemplatepath); - $newfiletmp=preg_replace('/\.od(s|t)/i', '', $newfile); - $newfiletmp=preg_replace('/template_/i', '', $newfiletmp); - $newfiletmp=preg_replace('/modele_/i', '', $newfiletmp); + $newfile = basename($srctemplatepath); + $newfiletmp = preg_replace('/\.od(s|t)/i', '', $newfile); + $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); + $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); // Get extension (ods or odt) - $newfileformat=substr($newfile, strrpos($newfile, '.')+1); - if ( ! empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) + $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); + if (!empty($conf->global->MAIN_DOC_USE_OBJECT_THIRDPARTY_NAME)) { $newfiletmp = dol_sanitizeFileName(dol_string_nospecial($object->name)).'-'.$newfiletmp; } - if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format=$conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format='%Y%m%d%H%M%S'; - $filename=$newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; } else { - $filename=$newfiletmp.'.'.$newfileformat; + $filename = $newfiletmp.'.'.$newfileformat; } - $file=$dir.'/'.$filename; - $object->builddoc_filename=$filename; // For triggers + $file = $dir.'/'.$filename; + $object->builddoc_filename = $filename; // For triggers //print "newfileformat=".$newfileformat; //print "newdir=".$dir; //print "newfile=".$newfile; @@ -268,22 +268,22 @@ class doc_generic_odt extends ModeleThirdPartyDoc $srctemplatepath, array( 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. 'DELIMITER_LEFT' => '{', 'DELIMITER_RIGHT' => '}' ) ); } - catch(Exception $e) + catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } //print $odfHandler->__toString()."\n"; // Replace tags of lines for contacts - $contact_arrray=array(); + $contact_arrray = array(); $sql = "SELECT p.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; @@ -296,10 +296,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc { require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; - $i=0; + $i = 0; $contactstatic = new Contact($this->db); - while($i < $num) + while ($i < $num) { $obj = $this->db->fetch_object($result); @@ -307,27 +307,27 @@ class doc_generic_odt extends ModeleThirdPartyDoc $i++; } } - if((is_array($contact_arrray) && count($contact_arrray) > 0)) + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { try { $listlines = $odfHandler->setSegment('companycontacts'); - foreach($contact_arrray as $array_key => $contact_id) + foreach ($contact_arrray as $array_key => $contact_id) { $res_contact = $contactstatic->fetch($contact_id); - $tmparray=$this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); - foreach($tmparray as $key => $val) + $tmparray = $this->get_substitutionarray_contact($contactstatic, $outputlangs, 'contact'); + foreach ($tmparray as $key => $val) { try { $listlines->setVars($key, $val, true, 'UTF-8'); } - catch(OdfException $e) + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } - catch(SegmentException $e) + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -336,29 +336,29 @@ class doc_generic_odt extends ModeleThirdPartyDoc } $odfHandler->mergeSegment($listlines); } - catch(OdfException $e) + catch (OdfException $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); //return -1; } } // Make substitutions into odt - $array_user=$this->get_substitutionarray_user($user, $outputlangs); - $array_soc=$this->get_substitutionarray_mysoc($mysoc, $outputlangs); - $array_thirdparty=$this->get_substitutionarray_thirdparty($object, $outputlangs); - $array_other=$this->get_substitutionarray_other($outputlangs); + $array_user = $this->get_substitutionarray_user($user, $outputlangs); + $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs); + $array_thirdparty = $this->get_substitutionarray_thirdparty($object, $outputlangs); + $array_other = $this->get_substitutionarray_other($outputlangs); $tmparray = array_merge($array_user, $array_soc, $array_thirdparty, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); // Call the ODTSubstitution hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Replace variables into document - foreach($tmparray as $key=>$value) + foreach ($tmparray as $key=>$value) { try { if (preg_match('/logo$/', $key)) // Image @@ -379,8 +379,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Replace labels translated - $tmparray=$outputlangs->get_translations_for_substitutions(); - foreach($tmparray as $key=>$value) + $tmparray = $outputlangs->get_translations_for_substitutions(); + foreach ($tmparray as $key=>$value) { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); @@ -392,15 +392,15 @@ class doc_generic_odt extends ModeleThirdPartyDoc } // Call the beforeODTSave hook - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file if (!empty($conf->global->MAIN_ODT_AS_PDF)) { try { $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { - $this->error=$e->getMessage(); + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } @@ -411,38 +411,38 @@ class doc_generic_odt extends ModeleThirdPartyDoc $odfHandler->title = $object->builddoc_filename; $odfHandler->subject = $object->builddoc_filename; - if (! empty($conf->global->ODT_ADD_DOLIBARR_ID)) { + if (!empty($conf->global->ODT_ADD_DOLIBARR_ID)) { $odfHandler->userdefined['dol_id'] = $object->id; $odfHandler->userdefined['dol_element'] = $object->element; } $odfHandler->saveToDisk($file); - } catch (Exception $e){ - $this->error=$e->getMessage(); + } catch (Exception $e) { + $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; } } - $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); - $reshook=$hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if (! empty($conf->global->MAIN_UMASK)) + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); - $odfHandler=null; // Destroy object + $odfHandler = null; // Destroy object $this->result = array('fullpath'=>$file); - return 1; // Success + return 1; // Success } else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); + $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } } - $this->error='UnknownError'; + $this->error = 'UnknownError'; return -1; } } diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 49af977c0d1..22ec06c8aa6 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -37,21 +37,21 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * @var string model name */ - public $name='Elephant'; + public $name = 'Elephant'; - public $code_modifiable; // Code modifiable + public $code_modifiable; // Code modifiable - public $code_modifiable_invalide; // Code modifiable si il est invalide + public $code_modifiable_invalide; // Code modifiable si il est invalide - public $code_modifiable_null; // Code modifiables si il est null + public $code_modifiable_null; // Code modifiables si il est null - public $code_null; // Code facultatif + public $code_null; // Code facultatif /** * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var int Automatic numbering @@ -92,37 +92,37 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode $langs->load("companies"); - $disabled = ((! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); + $disabled = ((!empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? ' disabled' : ''); $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte.= '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= '
'; - $tooltip=$langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); + $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("ThirdParty"), $langs->transnoentities("ThirdParty")); //$tooltip.=$langs->trans("GenericMaskCodes2"); Not required for third party numbering - $tooltip.=$langs->trans("GenericMaskCodes3"); - $tooltip.=$langs->trans("GenericMaskCodes4b"); - $tooltip.=$langs->trans("GenericMaskCodes5"); + $tooltip .= $langs->trans("GenericMaskCodes3"); + $tooltip .= $langs->trans("GenericMaskCodes4b"); + $tooltip .= $langs->trans("GenericMaskCodes5"); // Parametrage du prefix customers - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; - $texte.= ''; + $texte .= ''; // Parametrage du prefix suppliers - $texte.= ''; - $texte.= ''; - $texte.= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; - $texte.= '
'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("CustomerCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'   
'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'.$langs->trans("Mask").' ('.$langs->trans("SupplierCodeModel").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'; - $texte.= '
'; + $texte .= ''; + $texte .= ''; return $texte; } @@ -141,47 +141,47 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode if ($type == 0 || $type == -1) { $examplecust = $this->getNextValue($objsoc, 0); - if (! $examplecust) + if (!$examplecust) { $examplecust = $langs->trans('NotConfigured'); } - if($examplecust=="ErrorBadMask") + if ($examplecust == "ErrorBadMask") { $langs->load("errors"); - $examplecust=$langs->trans($examplecust); + $examplecust = $langs->trans($examplecust); } - if($examplecust=="ErrorCantUseRazIfNoYearInMask") + if ($examplecust == "ErrorCantUseRazIfNoYearInMask") { $langs->load("errors"); - $examplecust=$langs->trans($examplecust); + $examplecust = $langs->trans($examplecust); } - if($examplecust=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") + if ($examplecust == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") { $langs->load("errors"); - $examplecust=$langs->trans($examplecust); + $examplecust = $langs->trans($examplecust); } } if ($type == 1 || $type == -1) { $examplesup = $this->getNextValue($objsoc, 1); - if (! $examplesup) + if (!$examplesup) { $examplesup = $langs->trans('NotConfigured'); } - if($examplesup=="ErrorBadMask") + if ($examplesup == "ErrorBadMask") { $langs->load("errors"); - $examplesup=$langs->trans($examplesup); + $examplesup = $langs->trans($examplesup); } - if($examplesup=="ErrorCantUseRazIfNoYearInMask") + if ($examplesup == "ErrorCantUseRazIfNoYearInMask") { $langs->load("errors"); - $examplesup=$langs->trans($examplesup); + $examplesup = $langs->trans($examplesup); } - if($examplesup=="ErrorCantUseRazInStartedYearIfNoYearMonthInMask") + if ($examplesup == "ErrorCantUseRazInStartedYearIfNoYearMonthInMask") { $langs->load("errors"); - $examplesup=$langs->trans($examplesup); + $examplesup = $langs->trans($examplesup); } } @@ -199,21 +199,21 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode */ public function getNextValue($objsoc = 0, $type = -1) { - global $db,$conf; + global $db, $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; // Get Mask value $mask = ''; - if ($type==0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; - if ($type==1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; - if (! $mask) + if ($type == 0) $mask = $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + if ($type == 1) $mask = $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return ''; } - $field='';$where=''; + $field = ''; $where = ''; if ($type == 0) { $field = 'code_client'; @@ -226,9 +226,9 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } else return -1; - $now=dol_now(); + $now = dol_now(); - $numFinal=get_next_value($db, $mask, 'societe', $field, $where, '', $now); + $numFinal = get_next_value($db, $mask, 'societe', $field, $where, '', $now); return $numFinal; } @@ -273,32 +273,32 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode { global $conf; - require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $result=0; + $result = 0; $code = strtoupper(trim($code)); if (empty($code) && $this->code_null && empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) { - $result=0; + $result = 0; } - elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) + elseif (empty($code) && (!$this->code_null || !empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { - $result=-2; + $result = -2; } else { // Get Mask value $mask = ''; - if ($type==0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER)?'':$conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; - if ($type==1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER)?'':$conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; - if (! $mask) + if ($type == 0) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_CUSTOMER; + if ($type == 1) $mask = empty($conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER) ? '' : $conf->global->COMPANY_ELEPHANT_MASK_SUPPLIER; + if (!$mask) { - $this->error='NotConfigured'; + $this->error = 'NotConfigured'; return -5; } - $result=check_value($mask, $code); + $result = check_value($mask, $code); if (is_string($result)) { $this->error = $result; @@ -325,11 +325,11 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; - if ($type == 1) $sql.= " WHERE code_fournisseur = '".$code."'"; - else $sql.= " WHERE code_client = '".$code."'"; - if ($soc->id > 0) $sql.= " AND rowid <> ".$soc->id; + if ($type == 1) $sql .= " WHERE code_fournisseur = '".$code."'"; + else $sql .= " WHERE code_client = '".$code."'"; + if ($soc->id > 0) $sql .= " AND rowid <> ".$soc->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index a38f27997c9..78b0e2fae8e 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -34,13 +34,13 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode /** * @var string model name */ - public $name='Aquarium'; + public $name = 'Aquarium'; /** * Dolibarr version of the loaded document * @var string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $prefixcustomeraccountancycode; @@ -55,10 +55,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode public function __construct() { global $conf; - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; - if (! isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER='401'; - $this->prefixcustomeraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode=$conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER = '411'; + if (!isset($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) || trim($conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER) == '') $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER = '401'; + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_AQUARIUM_MASK_SUPPLIER; } @@ -75,26 +75,26 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $langs->load("companies"); - $tooltip=''; + $tooltip = ''; $texte = '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $s1= $form->textwithpicto('', $tooltip, 1, 1); - $s2= $form->textwithpicto('', $tooltip, 1, 1); - $texte.= ''; + $texte .= ''; + $texte .= '
'; - $texte.=$langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."
\n"; - $texte.=$langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."
\n"; - $texte.="
\n"; - if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte.=$langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $s1 = $form->textwithpicto('', $tooltip, 1, 1); + $s2 = $form->textwithpicto('', $tooltip, 1, 1); + $texte .= ''; - $texte.= ''; - $texte.= '
'; + $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2)."
\n"; + $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1)."
\n"; + $texte .= "
\n"; + if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; //if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $texte.=$langs->trans('COMPANY_AQUARIUM_REMOVE_ALPHA').' = '.yn($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)."
\n"; - if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte.=$langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; - $texte.= '
'; - $texte.= ''; + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_AQUARIUM_CLEAN_REGEX').' = '.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX."
\n"; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -109,10 +109,10 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode */ public function getExample($langs, $objsoc = 0, $type = -1) { - $s=''; - $s.=$this->prefixcustomeraccountancycode.'CUSTCODE'; - $s.="
\n"; - $s.=$this->prefixsupplieraccountancycode.'SUPPCODE'; + $s = ''; + $s .= $this->prefixcustomeraccountancycode.'CUSTCODE'; + $s .= "
\n"; + $s .= $this->prefixsupplieraccountancycode.'SUPPCODE'; return $s; } @@ -134,17 +134,17 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode $i = 0; $this->db = $db; - dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(! empty($societe->name)?$societe->name:'')); + dol_syslog("mod_codecompta_aquarium::get_code search code for type=".$type." company=".(!empty($societe->name) ? $societe->name : '')); // Regle gestion compte compta if ($type == 'customer') { - $codetouse=(! empty($societe->code_client)?$societe->code_client:'CUSTCODE'); + $codetouse = (!empty($societe->code_client) ? $societe->code_client : 'CUSTCODE'); $prefix = $this->prefixcustomeraccountancycode; } elseif ($type == 'supplier') { - $codetouse=(! empty($societe->code_fournisseur)?$societe->code_fournisseur:'SUPPCODE'); + $codetouse = (!empty($societe->code_fournisseur) ? $societe->code_fournisseur : 'SUPPCODE'); $prefix = $this->prefixsupplieraccountancycode; } else @@ -156,26 +156,26 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode //$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; // Remove special char if COMPANY_AQUARIUM_REMOVE_SPECIAL is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i', '', $codetouse); + if (!isset($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_AQUARIUM_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); // Remove special alpha if COMPANY_AQUARIUM_REMOVE_ALPHA is set to 1 - if (! empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse=preg_replace('/([a-z])/i', '', $codetouse); + if (!empty($conf->global->COMPANY_AQUARIUM_REMOVE_ALPHA)) $codetouse = preg_replace('/([a-z])/i', '', $codetouse); // Apply a regex replacement pattern on code if COMPANY_AQUARIUM_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (! empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; + if (!empty($conf->global->COMPANY_AQUARIUM_CLEAN_REGEX)) // Example: $conf->global->COMPANY_AQUARIUM_CLEAN_REGEX='^..(..)..'; { - $codetouse=preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse); + $codetouse = preg_replace('/'.$conf->global->COMPANY_AQUARIUM_CLEAN_REGEX.'/', '\1\2\3', $codetouse); } - $codetouse=$prefix.strtoupper($codetouse); + $codetouse = $prefix.strtoupper($codetouse); $is_dispo = $this->verif($db, $codetouse, $societe, $type); - if (! $is_dispo) + if (!$is_dispo) { - $this->code=$codetouse; + $this->code = $codetouse; } else { // Pour retour - $this->code=$codetouse; + $this->code = $codetouse; } dol_syslog("mod_codecompta_aquarium::get_code found code=".$this->code); return $is_dispo; @@ -194,33 +194,33 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode public function verif($db, $code, $societe, $type) { $sql = "SELECT "; - if ($type == 'customer') $sql.= "code_compta"; - elseif ($type == 'supplier') $sql.= "code_compta_fournisseur"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE "; - if ($type == 'customer') $sql.= "code_compta"; - elseif ($type == 'supplier') $sql.= "code_compta_fournisseur"; - $sql.= " = '".$db->escape($code)."'"; - if (! empty($societe->id)) $sql.= " AND rowid <> ".$societe->id; + if ($type == 'customer') $sql .= "code_compta"; + elseif ($type == 'supplier') $sql .= "code_compta_fournisseur"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; + $sql .= " WHERE "; + if ($type == 'customer') $sql .= "code_compta"; + elseif ($type == 'supplier') $sql .= "code_compta_fournisseur"; + $sql .= " = '".$db->escape($code)."'"; + if (!empty($societe->id)) $sql .= " AND rowid <> ".$societe->id; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { dol_syslog("mod_codecompta_aquarium::verif code '".$code."' available"); - return 1; // Dispo + return 1; // Dispo } else { dol_syslog("mod_codecompta_aquarium::verif code '".$code."' not available"); - return 0; // Non dispo + return 0; // Non dispo } } else { - $this->error=$db->error()." sql=".$sql; - return -1; // Erreur + $this->error = $db->error()." sql=".$sql; + return -1; // Erreur } } } diff --git a/htdocs/core/modules/societe/mod_codecompta_digitaria.php b/htdocs/core/modules/societe/mod_codecompta_digitaria.php index bb7defa67e0..7dbf129b766 100644 --- a/htdocs/core/modules/societe/mod_codecompta_digitaria.php +++ b/htdocs/core/modules/societe/mod_codecompta_digitaria.php @@ -34,13 +34,13 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode /** * @var string model name */ - public $name='Digitaria'; + public $name = 'Digitaria'; /** * Dolibarr version of the loaded document * @var string */ - public $version='dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' public $prefixcustomeraccountancycode; @@ -55,15 +55,15 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode public function __construct() { global $conf, $langs; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER='411'; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER='401'; - $this->prefixcustomeraccountancycode=$conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER; - $this->prefixsupplieraccountancycode=$conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER = '411'; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER = '401'; + $this->prefixcustomeraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_CUSTOMER; + $this->prefixsupplieraccountancycode = $conf->global->COMPANY_DIGITARIA_MASK_SUPPLIER; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER='5'; - if (! isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER='5'; - $this->customeraccountancycodecharacternumber=$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER; - $this->supplieraccountancycodecharacternumber=$conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER = '5'; + if (!isset($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) || trim($conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER) == '') $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER = '5'; + $this->customeraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_CUSTOMER; + $this->supplieraccountancycodecharacternumber = $conf->global->COMPANY_DIGITARIA_MASK_NBCHARACTER_SUPPLIER; } /** @@ -76,33 +76,33 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode { global $conf, $form; - $tooltip=''; + $tooltip = ''; $texte = '
'; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $texte.= ''; - $s1= $form->textwithpicto('', $tooltip, 1, 1); - $s2= $form->textwithpicto('', $tooltip, 1, 1); - $s3= $form->textwithpicto('', $tooltip, 1, 1); - $s4= $form->textwithpicto('', $tooltip, 1, 1); - $texte.= ''; + $texte .= ''; + $texte .= '
'; - $texte.= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."
\n"; - $texte.= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."
\n"; - $texte.= "
\n"; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $texte .= ''; + $s1 = $form->textwithpicto('', $tooltip, 1, 1); + $s2 = $form->textwithpicto('', $tooltip, 1, 1); + $s3 = $form->textwithpicto('', $tooltip, 1, 1); + $s4 = $form->textwithpicto('', $tooltip, 1, 1); + $texte .= ''; - $texte.= ''; - $texte.= '
'; + $texte .= $langs->trans("ModuleCompanyCodeCustomer".$this->name, $s2, $s4)."
\n"; + $texte .= $langs->trans("ModuleCompanyCodeSupplier".$this->name, $s1, $s3)."
\n"; + $texte .= "
\n"; // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || ! empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte.= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->$conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $texte .= $langs->trans('RemoveSpecialChars').' = '.yn(1)."
\n"; // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (! empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte.= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."
\n"; + if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) $texte .= $langs->trans('COMPANY_DIGITARIA_CLEAN_REGEX').' = '.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX."
\n"; // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || ! empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte.= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
\n"; - $texte.= '
'; - $texte.= ''; + if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) $texte .= $langs->trans('COMPANY_DIGITARIA_UNIQUE_CODE').' = '.yn(1)."
\n"; + $texte .= '
'; + $texte .= ''; return $texte; } @@ -119,14 +119,14 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode { global $mysoc; - $s= $langs->trans("ThirdPartyName").": ".$mysoc->name; - $s.="
\n"; + $s = $langs->trans("ThirdPartyName").": ".$mysoc->name; + $s .= "
\n"; - if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name); - $s.="
\n"; - $s.=$this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber)); - $s.="
\n"; - $s.=$this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber)); + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $thirdpartylabelexample = preg_replace('/([^a-z0-9])/i', '', $mysoc->name); + $s .= "
\n"; + $s .= $this->prefixcustomeraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->customeraccountancycodecharacternumber)); + $s .= "
\n"; + $s .= $this->prefixsupplieraccountancycode.strtoupper(substr($thirdpartylabelexample, 0, $this->supplieraccountancycodecharacternumber)); return $s; } @@ -143,11 +143,11 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode { // phpcs:enable $i = 0; - $this->code=''; + $this->code = ''; if (is_object($societe)) { - dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(! empty($societe->name)?$societe->name:'')); + dol_syslog("mod_codecompta_digitaria::get_code search code for type=".$type." & company=".(!empty($societe->name) ? $societe->name : '')); if ($type == 'supplier') { $codetouse = $societe->name; @@ -167,18 +167,18 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode } // Remove special char if COMPANY_DIGITARIA_REMOVE_SPECIAL is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || ! empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse=preg_replace('/([^a-z0-9])/i', '', $codetouse); + if (!isset($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL) || !empty($conf->global->COMPANY_DIGITARIA_REMOVE_SPECIAL)) $codetouse = preg_replace('/([^a-z0-9])/i', '', $codetouse); // Apply a regex replacement pattern on code if COMPANY_DIGITARIA_CLEAN_REGEX is set. Value must be a regex with parenthesis. The part into parenthesis is kept, the rest removed. - if (! empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..'; + if (!empty($conf->global->COMPANY_DIGITARIA_CLEAN_REGEX)) // Example: $conf->global->COMPANY_DIGITARIA_CLEAN_REGEX='^..(..)..'; { - $codetouse=preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse); + $codetouse = preg_replace('/'.$conf->global->COMPANY_DIGITARIA_CLEAN_REGEX.'/', '\1\2\3', $codetouse); } $this->code = $prefix.strtoupper(substr($codetouse, 0, $width)); dol_syslog("mod_codecompta_digitaria::get_code search code proposed=".$this->code); // Unique index on code if COMPANY_DIGITARIA_UNIQUE_CODE is set to 1 or not set (default) - if (! isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || ! empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) + if (!isset($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE) || !empty($conf->global->COMPANY_DIGITARIA_UNIQUE_CODE)) { $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); @@ -194,9 +194,9 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode } if ($type == 'supplier') { - $this->code = $prefix . strtoupper(substr($codetouse, 0, $widthsupplier - $a)) . $i; + $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthsupplier - $a)).$i; } elseif ($type == 'customer') { - $this->code = $prefix . strtoupper(substr($codetouse, 0, $widthcustomer - $a)) . $i; + $this->code = $prefix.strtoupper(substr($codetouse, 0, $widthcustomer - $a)).$i; } $disponibility = $this->checkIfAccountancyCodeIsAlreadyUsed($db, $this->code, $type); @@ -242,26 +242,26 @@ class mod_codecompta_digitaria extends ModeleAccountancyCode } $sql = "SELECT ".$typethirdparty." FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE ".$typethirdparty." = '".$code."'"; + $sql .= " WHERE ".$typethirdparty." = '".$code."'"; - $resql=$db->query($sql); + $resql = $db->query($sql); if ($resql) { if ($db->num_rows($resql) == 0) { dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' available"); - return 0; // Available + return 0; // Available } else { dol_syslog("mod_codecompta_digitaria::checkIfAccountancyCodeIsAlreadyUsed '".$code."' not available"); - return -1; // Not available + return -1; // Not available } } else { - $this->error=$db->error()." sql=".$sql; - return -2; // Error + $this->error = $db->error()." sql=".$sql; + return -2; // Error } } } diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php index 72a6c140ee1..f8767a82163 100644 --- a/htdocs/core/tpl/extrafields_view.tpl.php +++ b/htdocs/core/tpl/extrafields_view.tpl.php @@ -72,19 +72,19 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] } //print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'
'."\n"; - if (empty($enabled)) continue; // 0 = Never visible field - if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list - if (empty($perms)) continue; // 0 = Not visible + if (empty($enabled)) continue; // 0 = Never visible field + if (abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + if (empty($perms)) continue; // 0 = Not visible // Load language if required - if (! empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); + if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); if ($action == 'edit_extras') { - $value = (isset($_POST["options_" . $key]) ? $_POST["options_" . $key] : $object->array_options["options_" . $key]); + $value = (isset($_POST["options_".$key]) ? $_POST["options_".$key] : $object->array_options["options_".$key]); } else { - $value = $object->array_options["options_" . $key]; + $value = $object->array_options["options_".$key]; //var_dump($key.' - '.$value); } if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') @@ -116,64 +116,64 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element] print ''; - if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['help'][$key])) print $form->textwithpicto($langs->trans($label), $langs->trans($extrafields->attributes[$object->table_element]['help'][$key])); else print $langs->trans($label); print ''; //TODO Improve element and rights detection //var_dump($user->rights); - $permok=false; - $keyforperm=$object->element; - if ($object->element == 'fichinter') $keyforperm='ficheinter'; - if (isset($user->rights->$keyforperm)) $permok=$user->rights->$keyforperm->creer||$user->rights->$keyforperm->create||$user->rights->$keyforperm->write; - if ($object->element=='order_supplier') $permok=$user->rights->fournisseur->commande->creer; - if ($object->element=='invoice_supplier') $permok=$user->rights->fournisseur->facture->creer; - if ($object->element=='shipping') $permok=$user->rights->expedition->creer; - if ($object->element=='delivery') $permok=$user->rights->expedition->livraison->creer; - if ($object->element=='productlot') $permok=$user->rights->stock->creer; - if ($object->element=='facturerec') $permok=$user->rights->facture->creer; - if (($object->statut == 0 || ! empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) + $permok = false; + $keyforperm = $object->element; + if ($object->element == 'fichinter') $keyforperm = 'ficheinter'; + if (isset($user->rights->$keyforperm)) $permok = $user->rights->$keyforperm->creer || $user->rights->$keyforperm->create || $user->rights->$keyforperm->write; + if ($object->element == 'order_supplier') $permok = $user->rights->fournisseur->commande->creer; + if ($object->element == 'invoice_supplier') $permok = $user->rights->fournisseur->facture->creer; + if ($object->element == 'shipping') $permok = $user->rights->expedition->creer; + if ($object->element == 'delivery') $permok = $user->rights->expedition->livraison->creer; + if ($object->element == 'productlot') $permok = $user->rights->stock->creer; + if ($object->element == 'facturerec') $permok = $user->rights->facture->creer; + if (($object->statut == 0 || !empty($extrafields->attributes[$object->table_element]['alwayseditable'][$key])) && $permok && ($action != 'edit_extras' || GETPOST('attribute') != $key) && empty($extrafields->attributes[$object->table_element]['computed'][$key])) { - $fieldid='id'; - if ($object->table_element == 'societe') $fieldid='socid'; - print '' . img_edit().''; + $fieldid = 'id'; + if ($object->table_element == 'societe') $fieldid = 'socid'; + print ''.img_edit().''; } print ''; print ''; $html_id = !empty($object->id) ? $object->element.'_extras_'.$key.'_'.$object->id : ''; - print ''; + print ''; // Convert date into timestamp format - if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date','datetime'))) + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], array('date', 'datetime'))) { - $datenotinstring = $object->array_options['options_' . $key]; + $datenotinstring = $object->array_options['options_'.$key]; // print 'X'.$object->array_options['options_' . $key].'-'.$datenotinstring.'x'; - if (! is_numeric($object->array_options['options_' . $key])) // For backward compatibility + if (!is_numeric($object->array_options['options_'.$key])) // For backward compatibility { $datenotinstring = $db->jdate($datenotinstring); } //print 'x'.$object->array_options['options_' . $key].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); - $value = isset($_POST["options_" . $key]) ? dol_mktime($_POST["options_" . $key . "hour"], $_POST["options_" . $key . "min"], 0, $_POST["options_" . $key . "month"], $_POST["options_" . $key . "day"], $_POST["options_" . $key . "year"]) : $datenotinstring; + $value = isset($_POST["options_".$key]) ? dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]) : $datenotinstring; } //TODO Improve element and rights detection if ($action == 'edit_extras' && $permok && GETPOST('attribute', 'none') == $key) { - $fieldid='id'; - if ($object->table_element == 'societe') $fieldid='socid'; - print '
'; + $fieldid = 'id'; + if ($object->table_element == 'societe') $fieldid = 'socid'; + print ''; print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id, $object->table_element); - print ''; + print ''; print '
'; } diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 656c93cca55..61536e1d154 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -84,11 +84,11 @@ if (!empty($extrafields)) } } print "\n"; -$nolinesbefore=(count($this->lines) == 0 || $forcetoshowtitlelines); +$nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines); if ($nolinesbefore) { ?> - - global->MAIN_VIEW_LINE_NUMBER)) { ?> + + global->MAIN_VIEW_LINE_NUMBER)) { ?> @@ -124,10 +124,10 @@ if ($nolinesbefore) { situation_cycle_ref) { - print '' . $langs->trans('Progress') . ''; + print ''.$langs->trans('Progress').''; print ''; } - if (! empty($usemargins)) + if (!empty($usemargins)) { if (empty($user->rights->margins->creer)) { $colspan++; @@ -139,8 +139,8 @@ if ($nolinesbefore) { else echo $langs->trans('CostPrice'); echo ''; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; - if (! empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''.$langs->trans('MarginRate').''; + if (!empty($conf->global->DISPLAY_MARK_RATES)) echo ''.$langs->trans('MarkRate').''; } } ?> @@ -149,11 +149,11 @@ if ($nolinesbefore) { - + global->MAIN_VIEW_LINE_NUMBER)) { + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { $coldisplay++; echo ''; } @@ -166,21 +166,21 @@ if ($nolinesbefore) { if (empty($conf->global->MAIN_DISABLE_FREE_LINES)) { $freelines = true; - $forceall=1; // We always force all type for free lines (module product or service means we use predefined product or service) + $forceall = 1; // We always force all type for free lines (module product or service means we use predefined product or service) if ($object->element == 'contrat') { - if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=-1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set - elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall=3; + if (empty($conf->product->enabled) && empty($conf->service->enabled) && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall = -1; // With contract, by default, no choice at all, except if CONTRACT_SUPPORT_PRODUCTS is set + elseif (empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $forceall = 3; } // Free line echo ''; // Show radio free line - if ($forceall >= 0 && (! empty($conf->product->enabled) || ! empty($conf->service->enabled))) + if ($forceall >= 0 && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { echo ''; } // Predefined product/service - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { if ($forceall >= 0 && $freelines) echo '
'; echo ''; echo ''; echo ' '; - $filtertype=''; - if (! empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype='1'; + $filtertype = ''; + if (!empty($object->element) && $object->element == 'contrat' && empty($conf->global->CONTRACT_SUPPORT_PRODUCTS)) $filtertype = '1'; if (empty($senderissupplier)) { $statustoshow = 1; - if (! empty($conf->global->ENTREPOT_EXTRA_STATUS)) + if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); @@ -236,7 +236,7 @@ if ($nolinesbefore) { { $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } - if (! empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) + if (!empty($conf->global->MAIN_AUTO_OPEN_SELECT2_ON_FOCUS_FOR_CUSTOMER_PRODUCTS)) { ?> diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 7dae554fd91..dcb15ea27db 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -30,15 +30,15 @@ $langs->loadLangs(array("companies", "bills", "products", "margins")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$action=GETPOST('action', 'alpha'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -if (! empty($user->socid)) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); -if(empty($user->rights->margins->liretous)) accessforbidden(); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +if (empty($user->rights->margins->liretous)) accessforbidden(); $object = new Product($db); @@ -51,19 +51,19 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="f.datef"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef"; /* * View */ -$invoicestatic=new Facture($db); +$invoicestatic = new Facture($db); $form = new Form($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); @@ -72,13 +72,13 @@ if ($id > 0 || ! empty($ref)) $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Card'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Card'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Card'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Card'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); @@ -88,14 +88,14 @@ if ($id > 0 || ! empty($ref)) */ if ($result > 0) { - $head=product_prepare_head($object); - $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($object); + $titre = $langs->trans("CardProduct".$object->type); + $picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'margin', $titre, -1, $picto); $linkback = ''.$langs->trans("BackToList").''; - dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref'); + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref'); print '
'; @@ -109,14 +109,14 @@ if ($id > 0 || ! empty($ref)) print ''; // Margin Rate - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) { + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) { print ''.$langs->trans("MarginRate").''; print ''; // set by jquery (see below) print ''; } // Mark Rate - if (! empty($conf->global->DISPLAY_MARK_RATES)) { + if (!empty($conf->global->DISPLAY_MARK_RATES)) { print ''.$langs->trans("MarkRate").''; print ''; // set by jquery (see below) print ''; @@ -132,29 +132,29 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client,"; - $sql.= " f.rowid as facid, f.ref, f.total as total_ht,"; - $sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,"; - $sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive - $sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note - $sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note - $sql.= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.fk_statut > 0"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND d.fk_facture = f.rowid"; - $sql.= " AND d.fk_product =".$object->id; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if (! empty($socid)) $sql.= " AND f.fk_soc = $socid"; + $sql .= " f.rowid as facid, f.ref, f.total as total_ht,"; + $sql .= " f.datef, f.paye, f.fk_statut as statut, f.type,"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,"; + $sql .= " sum(d.total_ht) as selling_price,"; // may be negative or positive + $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty) as qty,"; // not always positive in case of Credit note + $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note + $sql .= " ".$db->ifsql('f.type = 2', -1, 1)." * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge"; // not always positive in case of Credit note + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.fk_statut > 0"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND d.fk_facture = f.rowid"; + $sql .= " AND d.fk_product =".$object->id; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if (!empty($socid)) $sql .= " AND f.fk_soc = $socid"; $sql .= " AND d.buy_price_ht IS NOT NULL"; if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; - $sql.= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user"; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " GROUP BY s.nom, s.rowid, s.code_client, f.rowid, f.ref, f.total, f.datef, f.paye, f.fk_statut, f.type"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; + $sql .= $db->order($sortfield, $sortorder); // TODO: calculate total to display then restore pagination //$sql.= $db->plimit($conf->liste_limit +1, $offset); dol_syslog('margin:tabs:productMargins.php', LOG_DEBUG); @@ -178,9 +178,9 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("BuyingPrice", $_SERVER["PHP_SELF"], "buying_price", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); - if (! empty($conf->global->DISPLAY_MARK_RATES)) + if (!empty($conf->global->DISPLAY_MARK_RATES)) print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", "&id=".$object->id, '', $sortfield, $sortorder, 'right '); print "\n"; @@ -194,13 +194,13 @@ if ($id > 0 || ! empty($ref)) while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); - $marginRate = ($objp->buying_price != 0)?(100 * $objp->marge / $objp->buying_price):'' ; - $markRate = ($objp->selling_price != 0)?(100 * $objp->marge / $objp->selling_price):'' ; + $marginRate = ($objp->buying_price != 0) ? (100 * $objp->marge / $objp->buying_price) : ''; + $markRate = ($objp->selling_price != 0) ? (100 * $objp->marge / $objp->selling_price) : ''; print ''; print ''; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->ref; + $invoicestatic->id = $objp->facid; + $invoicestatic->ref = $objp->ref; print $invoicestatic->getNomUrl(1); print "\n"; print ''.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($objp->name, 44).''; @@ -211,10 +211,10 @@ if ($id > 0 || ! empty($ref)) print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; print "".price($objp->qty, null, null, null, null, $rounding)."\n"; print "".price($objp->marge, null, null, null, null, $rounding)."\n"; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + print "".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARK_RATES)) + print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; @@ -229,13 +229,13 @@ if ($id > 0 || ! empty($ref)) $totalMargin = $cumul_vente - $cumul_achat; if ($totalMargin < 0) { - $marginRate = ($cumul_achat != 0)?-1*(100 * $totalMargin / $cumul_achat):''; - $markRate = ($cumul_vente != 0)?-1*(100 * $totalMargin / $cumul_vente):''; + $marginRate = ($cumul_achat != 0) ?-1 * (100 * $totalMargin / $cumul_achat) : ''; + $markRate = ($cumul_vente != 0) ?-1 * (100 * $totalMargin / $cumul_vente) : ''; } else { - $marginRate = ($cumul_achat != 0)?(100 * $totalMargin / $cumul_achat):''; - $markRate = ($cumul_vente != 0)?(100 * $totalMargin / $cumul_vente):''; + $marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : ''; + $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : ''; } print ''; print ''.$langs->trans('TotalMargin').""; @@ -243,10 +243,10 @@ if ($id > 0 || ! empty($ref)) print ''.price($cumul_achat, null, null, null, null, $rounding)."\n"; print ''.price($cumul_qty, null, null, null, null, $rounding)."\n"; print ''.price($totalMargin, null, null, null, null, $rounding)."\n"; - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + if (!empty($conf->global->DISPLAY_MARK_RATES)) + print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; print ' '; print "\n"; print ""; @@ -265,8 +265,8 @@ print ' '; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 1b6d35e65a3..65eae44c2c0 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -37,12 +37,12 @@ class Opensurveysondage extends CommonObject /** * @var string ID to identify managed object */ - public $element='opensurvey_sondage'; + public $element = 'opensurvey_sondage'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='opensurvey_sondage'; + public $table_element = 'opensurvey_sondage'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -71,8 +71,8 @@ class Opensurveysondage extends CommonObject public $fk_user_creat; public $titre; - public $date_fin=''; - public $status=1; + public $date_fin = ''; + public $status = 1; public $format; public $mailsonde; @@ -126,60 +126,60 @@ class Opensurveysondage extends CommonObject */ public function create(User $user, $notrigger = 0) { - $error=0; + $error = 0; // Clean parameters $this->cleanParameters(); // Check parameters - if (! $this->date_fin > 0) + if (!$this->date_fin > 0) { - $this->error='BadValueForEndDate'; + $this->error = 'BadValueForEndDate'; dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); return -1; } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; - $sql.= "id_sondage,"; - $sql.= "commentaires,"; - $sql.= "fk_user_creat,"; - $sql.= "titre,"; - $sql.= "date_fin,"; - $sql.= "status,"; - $sql.= "format,"; - $sql.= "mailsonde,"; - $sql.= "allow_comments,"; - $sql.= "allow_spy,"; - $sql.= "sujet"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->id_sondage)."',"; - $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").","; - $sql.= " ".$user->id.","; - $sql.= " '".$this->db->escape($this->titre)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->status.","; - $sql.= " '".$this->db->escape($this->format)."',"; - $sql.= " ".$this->db->escape($this->mailsonde).","; - $sql.= " ".$this->db->escape($this->allow_comments).","; - $sql.= " ".$this->db->escape($this->allow_spy).","; - $sql.= " '".$this->db->escape($this->sujet)."'"; - $sql.= ")"; + $sql .= "id_sondage,"; + $sql .= "commentaires,"; + $sql .= "fk_user_creat,"; + $sql .= "titre,"; + $sql .= "date_fin,"; + $sql .= "status,"; + $sql .= "format,"; + $sql .= "mailsonde,"; + $sql .= "allow_comments,"; + $sql .= "allow_spy,"; + $sql .= "sujet"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->escape($this->id_sondage)."',"; + $sql .= " ".(empty($this->commentaires) ? 'NULL' : "'".$this->db->escape($this->commentaires)."'").","; + $sql .= " ".$user->id.","; + $sql .= " '".$this->db->escape($this->titre)."',"; + $sql .= " '".$this->db->idate($this->date_fin)."',"; + $sql .= " ".$this->status.","; + $sql .= " '".$this->db->escape($this->format)."',"; + $sql .= " ".$this->db->escape($this->mailsonde).","; + $sql .= " ".$this->db->escape($this->allow_comments).","; + $sql .= " ".$this->db->escape($this->allow_spy).","; + $sql .= " '".$this->db->escape($this->sujet)."'"; + $sql .= ")"; $this->db->begin(); dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { global $langs, $conf; // Call trigger - $result=$this->call_trigger('OPENSURVEY_CREATE', $user); + $result = $this->call_trigger('OPENSURVEY_CREATE', $user); if ($result < 0) $error++; // End call triggers } @@ -188,13 +188,13 @@ class Opensurveysondage extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -214,25 +214,25 @@ class Opensurveysondage extends CommonObject public function fetch($id, $numsurvey = '') { $sql = "SELECT"; - $sql.= " t.id_sondage,"; - $sql.= " t.commentaires as description,"; - $sql.= " t.mail_admin,"; - $sql.= " t.nom_admin,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.titre,"; - $sql.= " t.date_fin,"; - $sql.= " t.status,"; - $sql.= " t.format,"; - $sql.= " t.mailsonde,"; - $sql.= " t.allow_comments,"; - $sql.= " t.allow_spy,"; - $sql.= " t.sujet,"; - $sql.= " t.tms"; - $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; - $sql.= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; + $sql .= " t.id_sondage,"; + $sql .= " t.commentaires as description,"; + $sql .= " t.mail_admin,"; + $sql .= " t.nom_admin,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.titre,"; + $sql .= " t.date_fin,"; + $sql .= " t.status,"; + $sql .= " t.format,"; + $sql .= " t.mailsonde,"; + $sql .= " t.allow_comments,"; + $sql .= " t.allow_spy,"; + $sql .= " t.sujet,"; + $sql .= " t.tms"; + $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; + $sql .= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { if ($this->db->num_rows($resql)) @@ -240,9 +240,9 @@ class Opensurveysondage extends CommonObject $obj = $this->db->fetch_object($resql); $this->id_sondage = $obj->id_sondage; - $this->ref = $this->id_sondage; //For compatibility + $this->ref = $this->id_sondage; //For compatibility - $this->commentaires = $obj->description; // deprecated + $this->commentaires = $obj->description; // deprecated $this->description = $obj->description; $this->mail_admin = $obj->mail_admin; $this->nom_admin = $obj->nom_admin; @@ -257,12 +257,12 @@ class Opensurveysondage extends CommonObject $this->fk_user_creat = $obj->fk_user_creat; $this->date_m = $this->db->jdate($obj->tls); - $ret=1; + $ret = 1; } else { $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); - $this->error='Fetch no poll found for '.$sondage; + $this->error = 'Fetch no poll found for '.$sondage; dol_syslog($this->error, LOG_ERR); $ret = 0; } @@ -271,8 +271,8 @@ class Opensurveysondage extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); - $ret=-1; + $this->error = "Error ".$this->db->lasterror(); + $ret = -1; } return $ret; @@ -289,7 +289,7 @@ class Opensurveysondage extends CommonObject public function update(User $user, $notrigger = 0) { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->cleanParameters(); @@ -300,35 +300,35 @@ class Opensurveysondage extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET"; - $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").","; - $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").","; - $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").","; - $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; - $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; - $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; - $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; - $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; - $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; - $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; - $sql.= " allow_spy=".$this->db->escape($this->allow_spy); + $sql .= " id_sondage=".(isset($this->id_sondage) ? "'".$this->db->escape($this->id_sondage)."'" : "null").","; + $sql .= " commentaires=".(isset($this->commentaires) ? "'".$this->db->escape($this->commentaires)."'" : "null").","; + $sql .= " mail_admin=".(isset($this->mail_admin) ? "'".$this->db->escape($this->mail_admin)."'" : "null").","; + $sql .= " nom_admin=".(isset($this->nom_admin) ? "'".$this->db->escape($this->nom_admin)."'" : "null").","; + $sql .= " titre=".(isset($this->titre) ? "'".$this->db->escape($this->titre)."'" : "null").","; + $sql .= " date_fin=".(dol_strlen($this->date_fin) != 0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; + $sql .= " status=".(isset($this->status) ? "'".$this->db->escape($this->status)."'" : "null").","; + $sql .= " format=".(isset($this->format) ? "'".$this->db->escape($this->format)."'" : "null").","; + $sql .= " mailsonde=".(isset($this->mailsonde) ? $this->db->escape($this->mailsonde) : "null").","; + $sql .= " allow_comments=".$this->db->escape($this->allow_comments).","; + $sql .= " allow_spy=".$this->db->escape($this->allow_spy); - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; $this->db->begin(); dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; + $interface = new Interfaces($this->db); + $result = $interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors = $interface->errors; } // End call triggers } } @@ -336,13 +336,13 @@ class Opensurveysondage extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -362,7 +362,7 @@ class Opensurveysondage extends CommonObject public function delete(User $user, $notrigger = 0, $numsondage = '') { global $conf, $langs; - $error=0; + $error = 0; if (empty($numsondage)) { @@ -371,44 +371,44 @@ class Opensurveysondage extends CommonObject $this->db->begin(); - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('OPENSURVEY_DELETE', $user); + $result = $this->call_trigger('OPENSURVEY_DELETE', $user); if ($result < 0) $error++; // End call triggers } } - if (! $error) + if (!$error) { - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $resql = $this->db->query($sql); + $sql = 'DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $sql .= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } } // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -432,43 +432,43 @@ class Opensurveysondage extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips $result = ''; $companylink = ''; - $label = '' . $langs->trans("ShowSurvey") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('Title') . ': ' . $this->title.'
'; + $label = ''.$langs->trans("ShowSurvey").''; + $label .= '
'; + $label .= ''.$langs->trans('Ref').': '.$this->ref.'
'; + $label .= ''.$langs->trans('Title').': '.$this->title.'
'; $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; + if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; + if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + if ($withpicto != 2) $result .= $this->ref; $result .= $linkend; return $result; @@ -483,28 +483,28 @@ class Opensurveysondage extends CommonObject public function fetch_lines() { // phpcs:enable - $ret=array(); + $ret = array(); $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; - $resql=$this->db->query($sql); + $sql .= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; + $resql = $this->db->query($sql); if ($resql) { - $num=$this->db->num_rows($resql); - $i=0; + $num = $this->db->num_rows($resql); + $i = 0; while ($i < $num) { - $obj=$this->db->fetch_object($resql); - $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); + $obj = $this->db->fetch_object($resql); + $tmp = array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); - $ret[]=$tmp; + $ret[] = $tmp; $i++; } } else dol_print_error($this->db); - $this->lines=$ret; + $this->lines = $ret; return count($this->lines); } @@ -517,18 +517,18 @@ class Opensurveysondage extends CommonObject */ public function initAsSpecimen() { - $this->id=0; + $this->id = 0; - $this->id_sondage=''; - $this->commentaires='Comment of the specimen survey'; - $this->description='Comment of the specimen survey'; - $this->mail_admin=''; - $this->nom_admin=''; - $this->titre='This is a specimen survey'; - $this->date_fin=dol_now()+3600*24*10; - $this->status=1; - $this->format='classic'; - $this->mailsonde=''; + $this->id_sondage = ''; + $this->commentaires = 'Comment of the specimen survey'; + $this->description = 'Comment of the specimen survey'; + $this->mail_admin = ''; + $this->nom_admin = ''; + $this->titre = 'This is a specimen survey'; + $this->date_fin = dol_now() + 3600 * 24 * 10; + $this->status = 1; + $this->format = 'classic'; + $this->mailsonde = ''; } /** @@ -541,14 +541,14 @@ class Opensurveysondage extends CommonObject $comments = array(); $sql = 'SELECT id_comment, usercomment, comment'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $sql.= " ORDER BY id_comment"; + $sql .= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; + $sql .= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql .= " ORDER BY id_comment"; $resql = $this->db->query($sql); if ($resql) { - $num_rows=$this->db->num_rows($resql); + $num_rows = $this->db->num_rows($resql); if ($num_rows > 0) { @@ -572,7 +572,7 @@ class Opensurveysondage extends CommonObject public function addComment($comment, $comment_user) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; - $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; + $sql .= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index a1d218e4e3c..c8ab3d4fbee 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -60,37 +60,37 @@ $object = new Opensurveysondage($db); $opensurvey_static = new Opensurveysondage($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->opensurvey->dir_output . '/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array +$diroutputmassaction = $conf->opensurvey->dir_output.'/temp/massgeneration/'.$user->id; +$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (! $sortfield) $sortfield="p.date_fin"; -if (! $sortorder) $sortorder="DESC"; +if (!$sortfield) $sortfield = "p.date_fin"; +if (!$sortorder) $sortorder = "DESC"; // Security check if (!$user->rights->opensurvey->read) accessforbidden(); // Definition of fields for list -$arrayfields=array(); -foreach($arrayfields as $key => $val) +$arrayfields = array(); +foreach ($arrayfields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], - 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), + 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], - 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key]) + 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) ); } } @@ -120,23 +120,23 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') ||GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { - $search_status=''; - $search_title=''; - $search_ref=''; - $toselect=''; - $search_array_options=array(); + $search_status = ''; + $search_title = ''; + $search_ref = ''; + $toselect = ''; + $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } // Mass actions - $objectclass='Opensurveysondage'; - $objectlabel='Opensurveysondage'; + $objectclass = 'Opensurveysondage'; + $objectlabel = 'Opensurveysondage'; $uploaddir = $conf->opensurvey->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -220,25 +220,25 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ llxHeader('', $title, $help_url); -$arrayofselected=is_array($toselect)?$toselect:array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); -$param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); -$fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); +$fieldtosortuser = empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 'firstname' : 'lastname'; -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available -$arrayofmassactions = array( +$arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); -$massactionbutton=$form->selectMassAction('', $arrayofmassactions); +if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +$massactionbutton = $form->selectMassAction('', $arrayofmassactions); // List of surveys into database @@ -258,16 +258,16 @@ $newcardbutton = dolGetButtonTitle($langs->trans('NewSurvey'), '', 'fa fa-plus-c print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit); // Add code for pre mass action (confirmation or email presend form) -$topicmail="SendOpenSurveyRef"; -$modelmail="opensurvey"; -$objecttmp=new Opensurveysondage($db); -$trackid='surv'.$object->id; +$topicmail = "SendOpenSurveyRef"; +$modelmail = "opensurvey"; +$objecttmp = new Opensurveysondage($db); +$trackid = 'surv'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -304,18 +304,18 @@ print ''; print ''; print ''; print ''; -$arraystatus=array('-1'=>' ','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed")); -print ''. $form->selectarray('search_status', $arraystatus, $search_status).''; +$arraystatus = array('-1'=>' ', '0'=>$langs->trans("Draft"), '1'=>$langs->trans("Opened"), '2'=>$langs->trans("Closed")); +print ''.$form->selectarray('search_status', $arraystatus, $search_status).''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields); +$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; -$searchpicto=$form->showFilterButtons(); +$searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; print ''."\n"; @@ -374,19 +374,19 @@ while ($i < min($num, $limit)) print ''; print $opensurvey_static->getNomUrl(1); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Title print ''.dol_htmlentities($obj->titre).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Type print ''; - $type=($obj->format=='A')?'classic':'date'; - print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'), 1), 'width="16"', 1); - print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); + $type = ($obj->format == 'A') ? 'classic' : 'date'; + print img_picto('', dol_buildpath('/opensurvey/img/'.($type == 'classic' ? 'chart-32.png' : 'calendar-32.png'), 1), 'width="16"', 1); + print ' '.$langs->trans($type == 'classic' ? "TypeClassic" : "TypeDate"); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''; // Author @@ -402,36 +402,36 @@ while ($i < min($num, $limit)) print dol_htmlentities($obj->nom_admin); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Nb of voters print''.$nbuser.''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''.dol_print_date($db->jdate($obj->date_fin), 'day'); if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''.$opensurvey_static->getLibStatut(5).''."\n"; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; print ''."\n"; $i++; @@ -445,15 +445,15 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; if ($num == 0) { $colspan = 8; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } print ''.$langs->trans("NoRecordFound").''; } $db->free($resql); -$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''."\n"; @@ -463,19 +463,19 @@ print ''."\n"; if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty=1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty=0; + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&', '&', $param); + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); - $filedir=$diroutputmassaction; - $genallowed=$permissiontoread; - $delallowed=$permissiontoadd; + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e65a6975844..30032c927cc 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -70,7 +70,7 @@ $refalreadyexists = 0; $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); -$type = (GETPOST('type', 'int') !== '')? GETPOST('type', 'int'):Product::TYPE_PRODUCT; +$type = (GETPOST('type', 'int') !== '') ? GETPOST('type', 'int') : Product::TYPE_PRODUCT; $action = (GETPOST('action', 'alpha') ? GETPOST('action', 'alpha') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -1222,15 +1222,15 @@ else // Accountancy codes print ''; - if (! empty($conf->accounting->enabled)) + if (!empty($conf->accounting->enabled)) { // Accountancy_code_sell print ''; print ''; @@ -1240,10 +1240,10 @@ else { print ''; print ''; @@ -1252,11 +1252,11 @@ else // Accountancy_code_sell_export print ''; print ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 68675b3e9dd..7e906103080 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -47,22 +47,22 @@ class Product extends CommonObject /** * @var string ID to identify managed object */ - public $element='product'; + public $element = 'product'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='product'; + public $table_element = 'product'; /** * @var int Field with ID of parent key if this field has a parent */ - public $fk_element='fk_product'; + public $fk_element = 'fk_product'; /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet'); + protected $childtables = array('supplier_proposaldet', 'propaldet', 'commandedet', 'facturedet', 'contratdet', 'facture_fourn_det', 'commande_fournisseurdet'); /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe @@ -383,18 +383,18 @@ class Product extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1), - 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), - 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), - 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), - 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + 'ref' =>array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), + 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1), + 'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61), + 'note' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), - 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + 'fk_user_author'=>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510, 'foreignkey'=>'llx_user.rowid'), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), ); @@ -466,15 +466,15 @@ class Product extends CommonObject { global $conf, $langs; - $error=0; + $error = 0; // Clean parameters $this->ref = dol_sanitizeFileName(dol_string_nospecial(trim($this->ref))); $this->label = trim($this->label); - $this->price_ttc=price2num($this->price_ttc); - $this->price=price2num($this->price); - $this->price_min_ttc=price2num($this->price_min_ttc); - $this->price_min=price2num($this->price_min); + $this->price_ttc = price2num($this->price_ttc); + $this->price = price2num($this->price); + $this->price_min_ttc = price2num($this->price_min_ttc); + $this->price_min = price2num($this->price_min); if (empty($this->tva_tx)) { $this->tva_tx = 0; } @@ -959,117 +959,117 @@ class Product extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."product"; - $sql.= " SET label = '" . $this->db->escape($this->label) ."'"; + $sql .= " SET label = '".$this->db->escape($this->label)."'"; if ($updatetype && ($this->isProduct() || $this->isService())) { - $sql.= ", fk_product_type = " . $this->type; + $sql .= ", fk_product_type = ".$this->type; } - $sql.= ", ref = '" . $this->db->escape($this->ref) ."'"; - $sql.= ", ref_ext = ".(! empty($this->ref_ext)?"'".$this->db->escape($this->ref_ext)."'":"null"); - $sql.= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); - $sql.= ", tva_tx = " . $this->tva_tx; - $sql.= ", recuperableonly = " . $this->tva_npr; - $sql.= ", localtax1_tx = " . $this->localtax1_tx; - $sql.= ", localtax2_tx = " . $this->localtax2_tx; - $sql.= ", localtax1_type = " . ($this->localtax1_type!=''?"'".$this->db->escape($this->localtax1_type)."'":"'0'"); - $sql.= ", localtax2_type = " . ($this->localtax2_type!=''?"'".$this->db->escape($this->localtax2_type)."'":"'0'"); + $sql .= ", ref = '".$this->db->escape($this->ref)."'"; + $sql .= ", ref_ext = ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); + $sql .= ", default_vat_code = ".($this->default_vat_code ? "'".$this->db->escape($this->default_vat_code)."'" : "null"); + $sql .= ", tva_tx = ".$this->tva_tx; + $sql .= ", recuperableonly = ".$this->tva_npr; + $sql .= ", localtax1_tx = ".$this->localtax1_tx; + $sql .= ", localtax2_tx = ".$this->localtax2_tx; + $sql .= ", localtax1_type = ".($this->localtax1_type != '' ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'"); + $sql .= ", localtax2_type = ".($this->localtax2_type != '' ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'"); - $sql.= ", barcode = ". (empty($this->barcode)?"null":"'".$this->db->escape($this->barcode)."'"); - $sql.= ", fk_barcode_type = ". (empty($this->barcode_type)?"null":$this->db->escape($this->barcode_type)); + $sql .= ", barcode = ".(empty($this->barcode) ? "null" : "'".$this->db->escape($this->barcode)."'"); + $sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type)); - $sql.= ", tosell = " . (int) $this->status; - $sql.= ", tobuy = " . (int) $this->status_buy; - $sql.= ", tobatch = " . ((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); - $sql.= ", finished = " . ((! isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); - $sql.= ", net_measure = " . ($this->net_measure!='' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); - $sql.= ", net_measure_units = " . ($this->net_measure_units!='' ? "'".$this->db->escape($this->net_measure_units)."'": 'null'); - $sql.= ", weight = " . ($this->weight!='' ? "'".$this->db->escape($this->weight)."'" : 'null'); - $sql.= ", weight_units = " . ($this->weight_units!='' ? "'".$this->db->escape($this->weight_units)."'": 'null'); - $sql.= ", length = " . ($this->length!='' ? "'".$this->db->escape($this->length)."'" : 'null'); - $sql.= ", length_units = " . ($this->length_units!='' ? "'".$this->db->escape($this->length_units)."'" : 'null'); - $sql.= ", width= " . ($this->width!='' ? "'".$this->db->escape($this->width)."'" : 'null'); - $sql.= ", width_units = " . ($this->width_units!='' ? "'".$this->db->escape($this->width_units)."'" : 'null'); - $sql.= ", height = " . ($this->height!='' ? "'".$this->db->escape($this->height)."'" : 'null'); - $sql.= ", height_units = " . ($this->height_units!='' ? "'".$this->db->escape($this->height_units)."'" : 'null'); - $sql.= ", surface = " . ($this->surface!='' ? "'".$this->db->escape($this->surface)."'" : 'null'); - $sql.= ", surface_units = " . ($this->surface_units!='' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); - $sql.= ", volume = " . ($this->volume!='' ? "'".$this->db->escape($this->volume)."'" : 'null'); - $sql.= ", volume_units = " . ($this->volume_units!='' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); - $sql.= ", fk_default_warehouse = " . ($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); - $sql.= ", seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); - $sql.= ", description = '" . $this->db->escape($this->description) ."'"; - $sql.= ", url = " . ($this->url?"'".$this->db->escape($this->url)."'":'null'); - $sql.= ", customcode = '" . $this->db->escape($this->customcode) ."'"; - $sql.= ", fk_country = " . ($this->country_id > 0 ? (int) $this->country_id : 'null'); - $sql.= ", note = ".(isset($this->note) ? "'" .$this->db->escape($this->note)."'" : 'null'); - $sql.= ", duration = '" . $this->db->escape($this->duration_value . $this->duration_unit) ."'"; - $sql.= ", accountancy_code_buy = '" . $this->db->escape($this->accountancy_code_buy)."'"; - $sql.= ", accountancy_code_sell= '" . $this->db->escape($this->accountancy_code_sell)."'"; - $sql.= ", accountancy_code_sell_intra= '" . $this->db->escape($this->accountancy_code_sell_intra)."'"; - $sql.= ", accountancy_code_sell_export= '" . $this->db->escape($this->accountancy_code_sell_export)."'"; - $sql.= ", desiredstock = " . ((isset($this->desiredstock) && $this->desiredstock != '') ? (int) $this->desiredstock : "null"); - $sql.= ", cost_price = " . ($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); - $sql.= ", fk_unit= " . (!$this->fk_unit ? 'NULL' : (int) $this->fk_unit); - $sql.= ", price_autogen = " . (!$this->price_autogen ? 0 : 1); - $sql.= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); - $sql.= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); + $sql .= ", tosell = ".(int) $this->status; + $sql .= ", tobuy = ".(int) $this->status_buy; + $sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch); + $sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished); + $sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null'); + $sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null'); + $sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null'); + $sql .= ", weight_units = ".($this->weight_units != '' ? "'".$this->db->escape($this->weight_units)."'" : 'null'); + $sql .= ", length = ".($this->length != '' ? "'".$this->db->escape($this->length)."'" : 'null'); + $sql .= ", length_units = ".($this->length_units != '' ? "'".$this->db->escape($this->length_units)."'" : 'null'); + $sql .= ", width= ".($this->width != '' ? "'".$this->db->escape($this->width)."'" : 'null'); + $sql .= ", width_units = ".($this->width_units != '' ? "'".$this->db->escape($this->width_units)."'" : 'null'); + $sql .= ", height = ".($this->height != '' ? "'".$this->db->escape($this->height)."'" : 'null'); + $sql .= ", height_units = ".($this->height_units != '' ? "'".$this->db->escape($this->height_units)."'" : 'null'); + $sql .= ", surface = ".($this->surface != '' ? "'".$this->db->escape($this->surface)."'" : 'null'); + $sql .= ", surface_units = ".($this->surface_units != '' ? "'".$this->db->escape($this->surface_units)."'" : 'null'); + $sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null'); + $sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null'); + $sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? $this->db->escape($this->fk_default_warehouse) : 'null'); + $sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->db->escape($this->seuil_stock_alerte)."'" : "null"); + $sql .= ", description = '".$this->db->escape($this->description)."'"; + $sql .= ", url = ".($this->url ? "'".$this->db->escape($this->url)."'" : 'null'); + $sql .= ", customcode = '".$this->db->escape($this->customcode)."'"; + $sql .= ", fk_country = ".($this->country_id > 0 ? (int) $this->country_id : 'null'); + $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); + $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; + $sql .= ", accountancy_code_buy = '".$this->db->escape($this->accountancy_code_buy)."'"; + $sql .= ", accountancy_code_sell= '".$this->db->escape($this->accountancy_code_sell)."'"; + $sql .= ", accountancy_code_sell_intra= '".$this->db->escape($this->accountancy_code_sell_intra)."'"; + $sql .= ", accountancy_code_sell_export= '".$this->db->escape($this->accountancy_code_sell_export)."'"; + $sql .= ", desiredstock = ".((isset($this->desiredstock) && $this->desiredstock != '') ? (int) $this->desiredstock : "null"); + $sql .= ", cost_price = ".($this->cost_price != '' ? $this->db->escape($this->cost_price) : 'null'); + $sql .= ", fk_unit= ".(!$this->fk_unit ? 'NULL' : (int) $this->fk_unit); + $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); + $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); + $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); // stock field is not here because it is a denormalized value from product_stock. - $sql.= " WHERE rowid = " . $id; + $sql .= " WHERE rowid = ".$id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $this->id = $id; // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) { + if (!empty($conf->global->MAIN_MULTILANGS)) { if ($this->setMultiLangs($user) < 0) { - $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql; + $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql; return -2; } } - $action='update'; + $action = 'update'; // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - $result=$this->insertExtraFields(); + if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $result = $this->insertExtraFields(); if ($result < 0) { $error++; } } - if (! $error && ! $notrigger) { + if (!$error && !$notrigger) { // Call trigger - $result=$this->call_trigger('PRODUCT_MODIFY', $user); + $result = $this->call_trigger('PRODUCT_MODIFY', $user); if ($result < 0) { $error++; } // End call triggers } - if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { + if (!$error && (is_object($this->oldcopy) && $this->oldcopy->ref !== $this->ref)) { // We remove directory if ($conf->product->dir_output) { - $olddir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref); - $newdir = $conf->product->dir_output . "/" . dol_sanitizeFileName($this->ref); + $olddir = $conf->product->dir_output."/".dol_sanitizeFileName($this->oldcopy->ref); + $newdir = $conf->product->dir_output."/".dol_sanitizeFileName($this->ref); if (file_exists($olddir)) { //include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; //$res = dol_move($olddir, $newdir); // do not use dol_move with directory $res = @rename($olddir, $newdir); - if (! $res) { + if (!$res) { $langs->load("errors"); - $this->error=$langs->trans('ErrorFailToRenameDir', $olddir, $newdir); + $this->error = $langs->trans('ErrorFailToRenameDir', $olddir, $newdir); $error++; } } } } - if (! $error) { + if (!$error) { if ($conf->variants->enabled) { include_once DOL_DOCUMENT_ROOT.'/variants/class/ProductCombination.class.php'; @@ -1623,27 +1623,27 @@ class Product extends CommonObject $price_base_type = $this->price_base_type; // If price per segment - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($thirdparty_buyer->price_level)) + if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($thirdparty_buyer->price_level)) { $pu_ht = $this->multiprices[$thirdparty_buyer->price_level]; $pu_ttc = $this->multiprices_ttc[$thirdparty_buyer->price_level]; $price_min = $this->multiprices_min[$thirdparty_buyer->price_level]; $price_base_type = $this->multiprices_base_type[$thirdparty_buyer->price_level]; - if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility + if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility { - if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx=$this->multiprices_tva_tx[$thirdparty_buyer->price_level]; - if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr=$this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; - if (empty($tva_tx)) $tva_npr=0; + if (isset($this->multiprices_tva_tx[$thirdparty_buyer->price_level])) $tva_tx = $this->multiprices_tva_tx[$thirdparty_buyer->price_level]; + if (isset($this->multiprices_recuperableonly[$thirdparty_buyer->price_level])) $tva_npr = $this->multiprices_recuperableonly[$thirdparty_buyer->price_level]; + if (empty($tva_tx)) $tva_npr = 0; } } // If price per customer - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { - require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; $prodcustprice = new Productcustomerprice($db); - $filter = array('t.fk_product' => $this->id,'t.fk_soc' => $thirdparty_buyer->id); + $filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter); if ($result) { @@ -1652,19 +1652,19 @@ class Product extends CommonObject $pu_ttc = price($prodcustprice->lines[0]->price_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; $tva_tx = $prodcustprice->lines[0]->tva_tx; - if ($prodcustprice->lines[0]->default_vat_code && ! preg_match('/\(.*\)/', $tva_tx)) $tva_tx.= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; + if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_npr = $prodcustprice->lines[0]->recuperableonly; - if (empty($tva_tx)) $tva_npr=0; + if (empty($tva_tx)) $tva_npr = 0; } } } // If price per quantity - elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { if ($this->prices_by_qty[0]) // yes, this product has some prices per quantity { // Search price into product_price_by_qty from $this->id - foreach($this->prices_by_qty_list[0] as $priceforthequantityarray) + foreach ($this->prices_by_qty_list[0] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -1681,12 +1681,12 @@ class Product extends CommonObject } } // 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 ($this->prices_by_qty[$thirdparty_buyer->price_level]) // yes, this product has some prices per quantity { // Search price into product_price_by_qty from $this->id - foreach($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) + foreach ($this->prices_by_qty_list[$thirdparty_buyer->price_level] as $priceforthequantityarray) { if ($priceforthequantityarray['rowid'] != $pqp) continue; // We found the price @@ -2066,31 +2066,31 @@ class Product extends CommonObject dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref." ref_ext=".$ref_ext); // Check parameters - if (! $id && ! $ref && ! $ref_ext && ! $barcode) { - $this->error='ErrorWrongParameters'; + if (!$id && !$ref && !$ref_ext && !$barcode) { + $this->error = 'ErrorWrongParameters'; dol_syslog(get_class($this)."::fetch ".$this->error); return -1; } $sql = "SELECT rowid, ref, ref_ext, label, description, url, note as note_private, customcode, fk_country, price, price_ttc,"; - $sql.= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; - $sql.= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; - $sql.= " length, length_units, width, width_units, height, height_units,"; - $sql.= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; - $sql.= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; - $sql.= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; - $sql.= " fk_price_expression, price_autogen"; - $sql.= " FROM ".MAIN_DB_PREFIX."product"; + $sql .= " price_min, price_min_ttc, price_base_type, cost_price, default_vat_code, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, tosell,"; + $sql .= " tobuy, fk_product_type, duration, fk_default_warehouse, seuil_stock_alerte, canvas, net_measure, net_measure_units, weight, weight_units,"; + $sql .= " length, length_units, width, width_units, height, height_units,"; + $sql .= " surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished,"; + $sql .= " accountancy_code_buy, accountancy_code_sell, accountancy_code_sell_intra, accountancy_code_sell_export, stock, pmp,"; + $sql .= " datec, tms, import_key, entity, desiredstock, tobatch, fk_unit,"; + $sql .= " fk_price_expression, price_autogen"; + $sql .= " FROM ".MAIN_DB_PREFIX."product"; if ($id) { - $sql.= " WHERE rowid = ".(int) $id; + $sql .= " WHERE rowid = ".(int) $id; } else { - $sql.= " WHERE entity IN (".getEntity($this->element).")"; + $sql .= " WHERE entity IN (".getEntity($this->element).")"; if ($ref) { - $sql.= " AND ref = '".$this->db->escape($ref)."'"; + $sql .= " AND ref = '".$this->db->escape($ref)."'"; } elseif ($ref_ext) { - $sql.= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; + $sql .= " AND ref_ext = '".$this->db->escape($ref_ext)."'"; } elseif ($barcode) { - $sql.= " AND barcode = '".$this->db->escape($barcode)."'"; + $sql .= " AND barcode = '".$this->db->escape($barcode)."'"; } } @@ -2108,7 +2108,7 @@ class Product extends CommonObject $this->description = $obj->description; $this->url = $obj->url; $this->note_private = $obj->note_private; - $this->note = $obj->note_private; // deprecated + $this->note = $obj->note_private; // deprecated $this->type = $obj->fk_product_type; $this->status = $obj->tosell; @@ -2137,37 +2137,37 @@ class Product extends CommonObject $this->finished = $obj->finished; $this->duration = $obj->duration; - $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration)-1); - $this->duration_unit = substr($obj->duration, -1); + $this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1); + $this->duration_unit = substr($obj->duration, -1); $this->canvas = $obj->canvas; - $this->net_measure = $obj->net_measure; - $this->net_measure_units = $obj->net_measure_units; + $this->net_measure = $obj->net_measure; + $this->net_measure_units = $obj->net_measure_units; $this->weight = $obj->weight; $this->weight_units = $obj->weight_units; $this->length = $obj->length; $this->length_units = $obj->length_units; - $this->width = $obj->width; - $this->width_units = $obj->width_units; - $this->height = $obj->height; - $this->height_units = $obj->height_units; + $this->width = $obj->width; + $this->width_units = $obj->width_units; + $this->height = $obj->height; + $this->height_units = $obj->height_units; - $this->surface = $obj->surface; - $this->surface_units = $obj->surface_units; - $this->volume = $obj->volume; + $this->surface = $obj->surface; + $this->surface_units = $obj->surface_units; + $this->volume = $obj->volume; $this->volume_units = $obj->volume_units; - $this->barcode = $obj->barcode; + $this->barcode = $obj->barcode; $this->barcode_type = $obj->fk_barcode_type; $this->accountancy_code_buy = $obj->accountancy_code_buy; - $this->accountancy_code_sell = $obj->accountancy_code_sell; - $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $this->accountancy_code_sell = $obj->accountancy_code_sell; + $this->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $this->accountancy_code_sell_export = $obj->accountancy_code_sell_export; $this->fk_default_warehouse = $obj->fk_default_warehouse; $this->seuil_stock_alerte = $obj->seuil_stock_alerte; $this->desiredstock = $obj->desiredstock; $this->stock_reel = $obj->stock; - $this->pmp = $obj->pmp; + $this->pmp = $obj->pmp; $this->date_creation = $obj->datec; $this->date_modification = $obj->tms; @@ -2425,38 +2425,38 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT p.fk_soc) as nb_customers, COUNT(DISTINCT p.rowid) as nb,"; - $sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; - $sql.= ", ".MAIN_DB_PREFIX."propal as p"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd"; + $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE p.rowid = pd.fk_propal"; - $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND p.entity IN (".getEntity('propal').")"; - $sql.= " AND pd.fk_product = ".$this->id; + $sql .= " WHERE p.rowid = pd.fk_propal"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND p.entity IN (".getEntity('propal').")"; + $sql .= " AND pd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND pr.fk_statut != 0"; if ($socid > 0) { - $sql.= " AND p.fk_soc = ".$socid; + $sql .= " AND p.fk_soc = ".$socid; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_propale['customers']=$obj->nb_customers; - $this->stats_propale['nb']=$obj->nb; - $this->stats_propale['rows']=$obj->nb_rows; - $this->stats_propale['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_propale['customers'] = $obj->nb_customers; + $this->stats_propale['nb'] = $obj->nb; + $this->stats_propale['rows'] = $obj->nb_rows; + $this->stats_propale['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in proposal by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2464,10 +2464,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_propale($socid); - $this->stats_propale['customers']+=$pFather->stats_propale['customers']; - $this->stats_propale['nb']+=$pFather->stats_propale['nb']; - $this->stats_propale['rows']+=$pFather->stats_propale['rows']; - $this->stats_propale['qty']+=$pFather->stats_propale['qty'] * $qtyCoef; + $this->stats_propale['customers'] += $pFather->stats_propale['customers']; + $this->stats_propale['nb'] += $pFather->stats_propale['nb']; + $this->stats_propale['rows'] += $pFather->stats_propale['rows']; + $this->stats_propale['qty'] += $pFather->stats_propale['qty'] * $qtyCoef; } } } @@ -2477,7 +2477,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2542,43 +2542,43 @@ class Product extends CommonObject public function load_stats_commande($socid = 0, $filtrestatut = '', $forVirtualStock = 0) { // phpcs:enable - global $conf,$user; + global $conf, $user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = cd.fk_commande"; - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE c.rowid = cd.fk_commande"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } if ($filtrestatut <> '') { - $sql.= " AND c.fk_statut in (".$filtrestatut.")"; + $sql .= " AND c.fk_statut in (".$filtrestatut.")"; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_commande['customers']=$obj->nb_customers; - $this->stats_commande['nb']=$obj->nb; - $this->stats_commande['rows']=$obj->nb_rows; - $this->stats_commande['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_commande['customers'] = $obj->nb_customers; + $this->stats_commande['nb'] = $obj->nb; + $this->stats_commande['rows'] = $obj->nb_rows; + $this->stats_commande['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in order by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2694,48 +2694,48 @@ class Product extends CommonObject public function load_stats_sending($socid = 0, $filtrestatut = '', $forVirtualStock = 0, $filterShipmentStatus = '') { // phpcs:enable - global $conf,$user; + global $conf, $user; $sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,"; - $sql.= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql.= ", ".MAIN_DB_PREFIX."commandedet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(ed.rowid) as nb_rows, SUM(ed.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."commandedet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE e.rowid = ed.fk_expedition"; - $sql.= " AND c.rowid = cd.fk_commande"; - $sql.= " AND e.fk_soc = s.rowid"; - $sql.= " AND e.entity IN (".getEntity('expedition').")"; - $sql.= " AND ed.fk_origin_line = cd.rowid"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE e.rowid = ed.fk_expedition"; + $sql .= " AND c.rowid = cd.fk_commande"; + $sql .= " AND e.fk_soc = s.rowid"; + $sql .= " AND e.entity IN (".getEntity('expedition').")"; + $sql .= " AND ed.fk_origin_line = cd.rowid"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid && !$forVirtualStock) { - $sql.= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND e.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND e.fk_soc = ".$socid; + $sql .= " AND e.fk_soc = ".$socid; } if ($filtrestatut <> '') { - $sql.= " AND c.fk_statut in (".$filtrestatut.")"; + $sql .= " AND c.fk_statut in (".$filtrestatut.")"; } - if (!empty($filterShipmentStatus)) $sql.= " AND e.fk_statut IN (" . $filterShipmentStatus . ")"; + if (!empty($filterShipmentStatus)) $sql .= " AND e.fk_statut IN (".$filterShipmentStatus.")"; $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_expedition['customers']=$obj->nb_customers; - $this->stats_expedition['nb']=$obj->nb; - $this->stats_expedition['rows']=$obj->nb_rows; - $this->stats_expedition['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_expedition['customers'] = $obj->nb_customers; + $this->stats_expedition['nb'] = $obj->nb; + $this->stats_expedition['rows'] = $obj->nb_rows; + $this->stats_expedition['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in sending by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2743,10 +2743,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_sending($socid, $filtrestatut, $forVirtualStock); - $this->stats_expedition['customers']+=$pFather->stats_expedition['customers']; - $this->stats_expedition['nb']+=$pFather->stats_expedition['nb']; - $this->stats_expedition['rows']+=$pFather->stats_expedition['rows']; - $this->stats_expedition['qty']+=$pFather->stats_expedition['qty'] * $qtyCoef; + $this->stats_expedition['customers'] += $pFather->stats_expedition['customers']; + $this->stats_expedition['nb'] += $pFather->stats_expedition['nb']; + $this->stats_expedition['rows'] += $pFather->stats_expedition['rows']; + $this->stats_expedition['qty'] += $pFather->stats_expedition['qty'] * $qtyCoef; } } } @@ -2755,7 +2755,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -2822,38 +2822,38 @@ class Product extends CommonObject global $user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; - $sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; - $sql.= ", ".MAIN_DB_PREFIX."contrat as c"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd"; + $sql .= ", ".MAIN_DB_PREFIX."contrat as c"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.rowid = cd.fk_contrat"; - $sql.= " AND c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('contract').")"; - $sql.= " AND cd.fk_product = ".$this->id; + $sql .= " WHERE c.rowid = cd.fk_contrat"; + $sql .= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('contract').")"; + $sql .= " AND cd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND c.statut != 0"; if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_contrat['customers']=$obj->nb_customers; - $this->stats_contrat['nb']=$obj->nb; - $this->stats_contrat['rows']=$obj->nb_rows; - $this->stats_contrat['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_contrat['customers'] = $obj->nb_customers; + $this->stats_contrat['nb'] = $obj->nb; + $this->stats_contrat['rows'] = $obj->nb_rows; + $this->stats_contrat['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in contract by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2861,10 +2861,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_contrat($socid); - $this->stats_contrat['customers']+=$pFather->stats_contrat['customers']; - $this->stats_contrat['nb']+=$pFather->stats_contrat['nb']; - $this->stats_contrat['rows']+=$pFather->stats_contrat['rows']; - $this->stats_contrat['qty']+=$pFather->stats_contrat['qty'] * $qtyCoef; + $this->stats_contrat['customers'] += $pFather->stats_contrat['customers']; + $this->stats_contrat['nb'] += $pFather->stats_contrat['nb']; + $this->stats_contrat['rows'] += $pFather->stats_contrat['rows']; + $this->stats_contrat['qty'] += $pFather->stats_contrat['qty'] * $qtyCoef; } } } @@ -2873,7 +2873,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error().' sql='.$sql; + $this->error = $this->db->error().' sql='.$sql; return -1; } } @@ -2891,19 +2891,19 @@ class Product extends CommonObject global $db, $conf, $user; $sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,"; - $sql.= " COUNT(fd.rowid) as nb_rows, SUM(".$db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + $sql .= " COUNT(fd.rowid) as nb_rows, SUM(".$db->ifsql('f.type != 2', 'fd.qty', 'fd.qty * -1').") as qty"; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE f.rowid = fd.fk_facture"; - $sql.= " AND f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND fd.fk_product = ".$this->id; + $sql .= " WHERE f.rowid = fd.fk_facture"; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND fd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } //$sql.= " AND f.fk_statut != 0"; if ($socid > 0) { @@ -2911,18 +2911,18 @@ class Product extends CommonObject } $result = $this->db->query($sql); - if ($result ) { - $obj=$this->db->fetch_object($result); - $this->stats_facture['customers']=$obj->nb_customers; - $this->stats_facture['nb']=$obj->nb; - $this->stats_facture['rows']=$obj->nb_rows; - $this->stats_facture['qty']=$obj->qty?$obj->qty:0; + if ($result) { + $obj = $this->db->fetch_object($result); + $this->stats_facture['customers'] = $obj->nb_customers; + $this->stats_facture['nb'] = $obj->nb; + $this->stats_facture['rows'] = $obj->nb_rows; + $this->stats_facture['qty'] = $obj->qty ? $obj->qty : 0; // if it's a virtual product, maybe it is in invoice by extension - if (! empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { + if (!empty($conf->global->PRODUCT_STATS_WITH_PARENT_PROD_IF_INCDEC)) { $TFather = $this->getFather(); if (is_array($TFather) && !empty($TFather)) { - foreach($TFather as &$fatherData) { + foreach ($TFather as &$fatherData) { $pFather = new Product($this->db); $pFather->id = $fatherData['id']; $qtyCoef = $fatherData['qty']; @@ -2930,10 +2930,10 @@ class Product extends CommonObject if ($fatherData['incdec']) { $pFather->load_stats_facture($socid); - $this->stats_facture['customers']+=$pFather->stats_facture['customers']; - $this->stats_facture['nb']+=$pFather->stats_facture['nb']; - $this->stats_facture['rows']+=$pFather->stats_facture['rows']; - $this->stats_facture['qty']+=$pFather->stats_facture['qty'] * $qtyCoef; + $this->stats_facture['customers'] += $pFather->stats_facture['customers']; + $this->stats_facture['nb'] += $pFather->stats_facture['nb']; + $this->stats_facture['rows'] += $pFather->stats_facture['rows']; + $this->stats_facture['qty'] += $pFather->stats_facture['qty'] * $qtyCoef; } } } @@ -2942,7 +2942,7 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); return -1; } } @@ -3391,38 +3391,38 @@ class Product extends CommonObject $sql = "SELECT sum(d.qty), date_format(c.date_contrat, '%Y%m')"; if ($mode == 'bynumber') { - $sql.= ", count(DISTINCT c.rowid)"; + $sql .= ", count(DISTINCT c.rowid)"; } - $sql.= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d, ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; if ($filteronproducttype >= 0) { - $sql.=", ".MAIN_DB_PREFIX."product as p"; + $sql .= ", ".MAIN_DB_PREFIX."product as p"; } if (!$user->rights->societe->client->voir && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql.= " WHERE c.entity IN (".getEntity('contract').")"; - $sql.= " AND c.rowid = d.fk_contrat"; + $sql .= " WHERE c.entity IN (".getEntity('contract').")"; + $sql .= " AND c.rowid = d.fk_contrat"; if ($this->id > 0) { - $sql.= " AND d.fk_product =".$this->id; + $sql .= " AND d.fk_product =".$this->id; } else { - $sql.=" AND d.fk_product > 0"; + $sql .= " AND d.fk_product > 0"; } if ($filteronproducttype >= 0) { - $sql.= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; + $sql .= " AND p.rowid = d.fk_product AND p.fk_product_type =".$filteronproducttype; } - $sql.= " AND c.fk_soc = s.rowid"; + $sql .= " AND c.fk_soc = s.rowid"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($socid > 0) { - $sql.= " AND c.fk_soc = ".$socid; + $sql .= " AND c.fk_soc = ".$socid; } - $sql.=$morefilter; - $sql.= " GROUP BY date_format(c.date_contrat,'%Y%m')"; - $sql.= " ORDER BY date_format(c.date_contrat,'%Y%m') DESC"; + $sql .= $morefilter; + $sql .= " GROUP BY date_format(c.date_contrat,'%Y%m')"; + $sql .= " ORDER BY date_format(c.date_contrat,'%Y%m') DESC"; return $this->_get_stats($sql, $mode, $year); } @@ -3618,7 +3618,7 @@ class Product extends CommonObject // phpcs:enable global $conf; - $now=dol_now(); + $now = dol_now(); dol_syslog(get_class($this)."::add_fournisseur id_fourn = ".$id_fourn." ref_fourn=".$ref_fourn." quantity=".$quantity, LOG_DEBUG); @@ -3627,13 +3627,13 @@ class Product extends CommonObject if ($ref_fourn) { $sql = "SELECT rowid, fk_product"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_soc = ".$id_fourn; - $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; - $sql.= " AND fk_product != ".$this->id; - $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_soc = ".$id_fourn; + $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; + $sql .= " AND fk_product != ".$this->id; + $sql .= " AND entity IN (".getEntity('productsupplierprice').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj) { @@ -3646,40 +3646,40 @@ class Product extends CommonObject } $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; - $sql.= " WHERE fk_soc = ".$id_fourn; - if ($ref_fourn) { $sql.= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; - } else { $sql.= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price"; + $sql .= " WHERE fk_soc = ".$id_fourn; + if ($ref_fourn) { $sql .= " AND ref_fourn = '".$this->db->escape($ref_fourn)."'"; + } else { $sql .= " AND (ref_fourn = '' OR ref_fourn IS NULL)"; } - $sql.= " AND quantity = ".$quantity; - $sql.= " AND fk_product = ".$this->id; - $sql.= " AND entity IN (".getEntity('productsupplierprice').")"; + $sql .= " AND quantity = ".$quantity; + $sql .= " AND fk_product = ".$this->id; + $sql .= " AND entity IN (".getEntity('productsupplierprice').")"; - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); // The reference supplier does not exist, we create it for this product. - if (! $obj) { + if (!$obj) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_fournisseur_price("; - $sql.= "datec"; - $sql.= ", entity"; - $sql.= ", fk_product"; - $sql.= ", fk_soc"; - $sql.= ", ref_fourn"; - $sql.= ", quantity"; - $sql.= ", fk_user"; - $sql.= ", tva_tx"; - $sql.= ") VALUES ("; - $sql.= "'".$this->db->idate($now)."'"; - $sql.= ", ".$conf->entity; - $sql.= ", ".$this->id; - $sql.= ", ".$id_fourn; - $sql.= ", '".$this->db->escape($ref_fourn)."'"; - $sql.= ", ".$quantity; - $sql.= ", ".$user->id; - $sql.= ", 0"; - $sql.= ")"; + $sql .= "datec"; + $sql .= ", entity"; + $sql .= ", fk_product"; + $sql .= ", fk_soc"; + $sql .= ", ref_fourn"; + $sql .= ", quantity"; + $sql .= ", fk_user"; + $sql .= ", tva_tx"; + $sql .= ") VALUES ("; + $sql .= "'".$this->db->idate($now)."'"; + $sql .= ", ".$conf->entity; + $sql .= ", ".$this->id; + $sql .= ", ".$id_fourn; + $sql .= ", '".$this->db->escape($ref_fourn)."'"; + $sql .= ", ".$quantity; + $sql .= ", ".$user->id; + $sql .= ", 0"; + $sql .= ")"; if ($this->db->query($sql)) { $this->product_fourn_price_id = $this->db->last_insert_id(MAIN_DB_PREFIX."product_fournisseur_price"); @@ -3756,7 +3756,7 @@ class Product extends CommonObject $this->db->begin(); // prices - $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_price ("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."product_price ("; $sql .= " entity"; $sql .= ", fk_product"; $sql .= ", date_price"; @@ -3785,8 +3785,8 @@ class Product extends CommonObject $sql .= ")"; $sql .= " SELECT"; $sql .= " entity"; - $sql .= ", " . $toId; - $sql .= ", '" . $this->db->idate($now) . "'"; + $sql .= ", ".$toId; + $sql .= ", '".$this->db->idate($now)."'"; $sql .= ", price_level"; $sql .= ", price"; $sql .= ", price_ttc"; @@ -3800,7 +3800,7 @@ class Product extends CommonObject $sql .= ", localtax1_type"; $sql .= ", localtax2_tx"; $sql .= ", localtax2_type"; - $sql .= ", " . $user->id; + $sql .= ", ".$user->id; $sql .= ", tosell"; $sql .= ", price_by_qty"; $sql .= ", fk_price_expression"; @@ -3809,11 +3809,11 @@ class Product extends CommonObject $sql .= ", multicurrency_tx"; $sql .= ", multicurrency_price"; $sql .= ", multicurrency_price_ttc"; - $sql .= " FROM " . MAIN_DB_PREFIX . "product_price"; - $sql .= " WHERE fk_product = ". $fromId; + $sql .= " FROM ".MAIN_DB_PREFIX."product_price"; + $sql .= " WHERE fk_product = ".$fromId; $sql .= " ORDER BY date_price DESC"; - if ($conf->global->PRODUIT_MULTIPRICES_LIMIT>0) { - $sql .= " LIMIT " . $conf->global->PRODUIT_MULTIPRICES_LIMIT; + if ($conf->global->PRODUIT_MULTIPRICES_LIMIT > 0) { + $sql .= " LIMIT ".$conf->global->PRODUIT_MULTIPRICES_LIMIT; } dol_syslog(__METHOD__, LOG_DEBUG); @@ -3917,40 +3917,40 @@ class Product extends CommonObject public function fetch_prod_arbo($prod, $compl_path = "", $multiply = 1, $level = 1, $id_parent = 0) { // phpcs:enable - global $conf,$langs; + global $conf, $langs; $tmpproduct = null; //var_dump($prod); - foreach($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product + foreach ($prod as $id_product => $desc_pere) // $id_product is 0 (first call starting with root top) or an id of a sub_product { if (is_array($desc_pere)) // If desc_pere is an array, this means it's a child { - $id=(! empty($desc_pere[0]) ? $desc_pere[0] :''); - $nb=(! empty($desc_pere[1]) ? $desc_pere[1] :''); - $type=(! empty($desc_pere[2]) ? $desc_pere[2] :''); - $label=(! empty($desc_pere[3]) ? $desc_pere[3] :''); - $incdec=!empty($desc_pere[4]) ? $desc_pere[4] : 0; + $id = (!empty($desc_pere[0]) ? $desc_pere[0] : ''); + $nb = (!empty($desc_pere[1]) ? $desc_pere[1] : ''); + $type = (!empty($desc_pere[2]) ? $desc_pere[2] : ''); + $label = (!empty($desc_pere[3]) ? $desc_pere[3] : ''); + $incdec = !empty($desc_pere[4]) ? $desc_pere[4] : 0; - if ($multiply < 1) { $multiply=1; + if ($multiply < 1) { $multiply = 1; } //print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n"; - if (is_null($tmpproduct)) $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. - $tmpproduct->fetch($id); // Load product to get ->ref - $tmpproduct->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel + if (is_null($tmpproduct)) $tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop. + $tmpproduct->fetch($id); // Load product to get ->ref + $tmpproduct->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel //$this->fetch($id); // Load product to get ->ref //$this->load_stock('nobatch,novirtual'); // Load stock to get true ->stock_reel - $this->res[]= array( - 'id'=>$id, // Id product + $this->res[] = array( + 'id'=>$id, // Id product 'id_parent'=>$id_parent, - 'ref'=>$tmpproduct->ref, // Ref product - 'nb'=>$nb, // Nb of units that compose parent product - 'nb_total'=>$nb*$multiply, // Nb of units for all nb of product - 'stock'=>$tmpproduct->stock_reel, // Stock - 'stock_alert'=>$tmpproduct->seuil_stock_alerte, // Stock alert + 'ref'=>$tmpproduct->ref, // Ref product + 'nb'=>$nb, // Nb of units that compose parent product + 'nb_total'=>$nb * $multiply, // Nb of units for all nb of product + 'stock'=>$tmpproduct->stock_reel, // Stock + 'stock_alert'=>$tmpproduct->seuil_stock_alerte, // Stock alert 'label'=>$label, - 'fullpath'=>$compl_path.$label, // Label - 'type'=>$type, // Nb of units that compose parent product + 'fullpath'=>$compl_path.$label, // Label + 'type'=>$type, // Nb of units that compose parent product 'desiredstock'=>$tmpproduct->desiredstock, 'level'=>$level, 'incdec'=>$incdec, @@ -4202,81 +4202,81 @@ class Product extends CommonObject global $conf, $langs, $hookmanager; include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; - $result=''; - $newref=$this->ref; - if ($maxlength) { $newref=dol_trunc($newref, $maxlength, 'middle'); + $result = ''; + $newref = $this->ref; + if ($maxlength) { $newref = dol_trunc($newref, $maxlength, 'middle'); } - if ($this->type == Product::TYPE_PRODUCT) { $label = '' . $langs->trans("ShowProduct") . ''; + if ($this->type == Product::TYPE_PRODUCT) { $label = ''.$langs->trans("ShowProduct").''; } - if ($this->type == Product::TYPE_SERVICE) { $label = '' . $langs->trans("ShowService") . ''; + if ($this->type == Product::TYPE_SERVICE) { $label = ''.$langs->trans("ShowService").''; } - if (! empty($this->ref)) { - $label .= '
' . $langs->trans('ProductRef') . ': ' . $this->ref; + if (!empty($this->ref)) { + $label .= '
'.$langs->trans('ProductRef').': '.$this->ref; } - if (! empty($this->label)) { - $label .= '
' . $langs->trans('ProductLabel') . ': ' . $this->label; + if (!empty($this->label)) { + $label .= '
'.$langs->trans('ProductLabel').': '.$this->label; } if ($this->type == Product::TYPE_PRODUCT) { if ($this->weight) { - $label.="
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); + $label .= "
".$langs->trans("Weight").': '.$this->weight.' '.measuringUnitString(0, "weight", $this->weight_units); } if ($this->length) { - $label.="
".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); + $label .= "
".$langs->trans("Length").': '.$this->length.' '.measuringUnitString(0, 'size', $this->length_units); } if ($this->width) { - $label.="
".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); + $label .= "
".$langs->trans("Width").': '.$this->width.' '.measuringUnitString(0, 'size', $this->width_units); } if ($this->height) { - $label.="
".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); + $label .= "
".$langs->trans("Height").': '.$this->height.' '.measuringUnitString(0, 'size', $this->height_units); } if ($this->surface) { - $label.="
".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); + $label .= "
".$langs->trans("Surface").': '.$this->surface.' '.measuringUnitString(0, 'surface', $this->surface_units); } if ($this->volume) { - $label.="
".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); + $label .= "
".$langs->trans("Volume").': '.$this->volume.' '.measuringUnitString(0, 'volume', $this->volume_units); } } - if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - if (! empty($conf->productbatch->enabled)) { + if ($this->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { + if (!empty($conf->productbatch->enabled)) { $langs->load("productbatch"); - $label.="
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); + $label .= "
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); } } //if ($this->type == Product::TYPE_SERVICE) //{ // //} - if (! empty($conf->accounting->enabled) && $this->status) { + if (!empty($conf->accounting->enabled) && $this->status) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label.= '
' . $langs->trans('ProductAccountancySellCode') . ': '. length_accountg($this->accountancy_code_sell); - if(!empty($conf->global->MAIN_FEATURES_LEVEL)) { - $label.= '
' . $langs->trans('ProductAccountancySellIntraCode') . ': '. length_accountg($this->accountancy_code_sell_export); - $label.= '
' . $langs->trans('ProductAccountancySellExportCode') . ': '. length_accountg($this->accountancy_code_sell_intra); + $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { + $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_export); + $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_intra); } } - if (! empty($conf->accounting->enabled) && $this->status_buy) { + if (!empty($conf->accounting->enabled) && $this->status_buy) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; - $label.= '
' . $langs->trans('ProductAccountancyBuyCode') . ': '. length_accountg($this->accountancy_code_buy); + $label .= '
'.$langs->trans('ProductAccountancyBuyCode').': '.length_accountg($this->accountancy_code_buy); } - if (! empty($this->entity)) { + if (!empty($this->entity)) { $tmpphoto = $this->show_photos('product', $conf->product->multidir_output[$this->entity], 1, 1, 0, 0, 0, 80); - if ($this->nbphoto > 0) { $label .= '
' . $tmpphoto; + if ($this->nbphoto > 0) { $label .= '
'.$tmpphoto; } } - $linkclose=''; + $linkclose = ''; if (empty($notooltip)) { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $label=$langs->trans("ShowProduct"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowProduct"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; } - $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; - $linkclose.= ' class="nowraponall classfortooltip"'; + $linkclose .= ' title="'.dol_escape_htmltag($label, 1, 1).'"'; + $linkclose .= ' class="nowraponall classfortooltip"'; } else { @@ -4295,34 +4295,34 @@ class Product extends CommonObject if ($option !== 'nolink') { // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values=1; + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } - if ($add_save_lastsearch_values) { $url.='&save_lastsearch_values=1'; + if ($add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } } $linkstart = ''; - $linkend=''; + $linkstart .= $linkclose.'>'; + $linkend = ''; - $result.=$linkstart; + $result .= $linkstart; if ($withpicto) { if ($this->type == Product::TYPE_PRODUCT) { - $result.=(img_object(($notooltip?'':$label), 'product', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); + $result .= (img_object(($notooltip ? '' : $label), 'product', ($notooltip ? 'class="paddingright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } if ($this->type == Product::TYPE_SERVICE) { - $result.=(img_object(($notooltip?'':$label), 'service', ($notooltip?'class="paddinright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1)); + $result .= (img_object(($notooltip ? '' : $label), 'service', ($notooltip ? 'class="paddinright"' : 'class="paddingright classfortooltip"'), 0, 0, $notooltip ? 0 : 1)); } } - $result.= $newref; - $result.= $linkend; + $result .= $newref; + $result .= $linkend; global $action; $hookmanager->initHooks(array('productdao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { $result = $hookmanager->resPrint; } else { @@ -4430,26 +4430,26 @@ class Product extends CommonObject } } - $statuttrans=empty($status)?'status5':'status4'; + $statuttrans = empty($status) ? 'status5' : 'status4'; if ($status == 0) { // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - if($type==0) { + if ($type == 0) { $labelStatus = $langs->trans('ProductStatusNotOnSellShort'); $labelStatusShort = $langs->trans('ProductStatusNotOnSell'); } - elseif($type == 1) { + elseif ($type == 1) { $labelStatus = $langs->trans('ProductStatusNotOnBuyShort'); $labelStatusShort = $langs->trans('ProductStatusNotOnBuy'); } - elseif($type == 2) { + elseif ($type == 2) { $labelStatus = $langs->trans('ProductStatusNotOnBatch'); $labelStatusShort = $langs->trans('ProductStatusNotOnBatchShort'); } } elseif ($status == 1) { // $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" - if ($type==0) { + if ($type == 0) { $labelStatus = $langs->trans('ProductStatusOnSellShort'); $labelStatusShort = $langs->trans('ProductStatusOnSell'); } @@ -4685,10 +4685,10 @@ class Product extends CommonObject } if (!empty($conf->expedition->enabled)) { - require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $filterShipmentStatus = ''; if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)) { - $filterShipmentStatus = Expedition::STATUS_VALIDATED . ',' . Expedition::STATUS_CLOSED; + $filterShipmentStatus = Expedition::STATUS_VALIDATED.','.Expedition::STATUS_CLOSED; } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { $filterShipmentStatus = Expedition::STATUS_CLOSED; } diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index e2e7745fd0d..3e4bffc967b 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -20,7 +20,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) { +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -70,10 +70,10 @@ if ($object->element == 'product') { print ''; print ''; } @@ -81,10 +81,10 @@ if ($object->element == 'stock') { print ''; print ''; } @@ -96,7 +96,7 @@ if ($object->element == 'stock') print ''; print ''; print ''; -if (! empty($conf->projet->enabled)) +if (!empty($conf->projet->enabled)) { print ''; print ''; // Serial / Eat-by date -if (! empty($conf->productbatch->enabled) && +if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) || ($object->element == 'stock')) ) { print ''; - print 'element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print ''; print ''; print ''; print ''; } // Label of mouvement of id of inventory - $valformovementlabel=((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref)); + $valformovementlabel = ((GETPOST("label") && (GETPOST('label') != $langs->trans("MovementCorrectStock", ''))) ? GETPOST("label") : $langs->trans("MovementCorrectStock", $productref)); print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("ProductAccountancySellCode").''; - if($type = 0) { - $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell')?GETPOST('accountancy_code_sell', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); + if ($type = 0) { + $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ?GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT); } else { - $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell')?GETPOST('accountancy_code_sell', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); + $accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ?GETPOST('accountancy_code_sell', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT); } print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellIntraCode").''; - if($type = 0) { - $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra')?GETPOST('accountancy_code_sell_intra', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); + if ($type = 0) { + $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ?GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT); } else { - $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra')?GETPOST('accountancy_code_sell_intra', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); + $accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ?GETPOST('accountancy_code_sell_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT); } print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, null, 1, 1, ''); print '
'.$langs->trans("ProductAccountancySellExportCode").''; - if($type = 0) + if ($type = 0) { - $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export')?GETPOST('accountancy_code_sell_export', 'alpha'):$conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ?GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT); } else { - $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export')?GETPOST('accountancy_code_sell_export', 'alpha'):$conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); + $accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ?GETPOST('accountancy_code_sell_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT); } print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, null, 1, 1, ''); print '
'.$langs->trans("Warehouse").''; - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid", 'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot', 'int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); + print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'minwidth100'); print '   '; print ''.$langs->trans("Product").''; - $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); + $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print '   '; print '
'.$langs->trans("UnitPurchaseValue").''.$langs->trans('Project').''; @@ -106,36 +106,36 @@ if (! empty($conf->projet->enabled)) print '
'; + print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print '
'.$langs->trans("EatByDate").''; - $eatbyselected=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); + $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); print $form->selectDate($eatbyselected, 'eatby', '', '', 1, ""); print ''.$langs->trans("SellByDate").''; - $sellbyselected=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); print $form->selectDate($sellbyselected, 'sellby', '', '', 1, ""); print '
'.$langs->trans("MovementLabel").''; print ''; print ''.$langs->trans("InventoryCode").''.$langs->trans("InventoryCode").'
'; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index cb6976c4b75..854fc1e6b97 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -20,7 +20,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) { +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -29,23 +29,23 @@ if (empty($conf) || ! is_object($conf)) { element == 'product') $productref = $object->ref; $langs->load("productbatch"); if (empty($id)) $id = $object->id; - $pdluoid=GETPOST('pdluoid', 'int'); + $pdluoid = GETPOST('pdluoid', 'int'); $pdluo = new Productbatch($db); if ($pdluoid > 0) { - $result=$pdluo->fetch($pdluoid); + $result = $pdluo->fetch($pdluoid); if ($result > 0) { - $pdluoid=$pdluo->id; + $pdluoid = $pdluo->id; } else { @@ -74,14 +74,14 @@ if ($object->element == 'product') { print ''.$langs->trans("WarehouseSource").''; print ''; - print $formproduct->selectWarehouses((GETPOST("dwid")?GETPOST("dwid", 'int'):(GETPOST('id_entrepot')?GETPOST('id_entrepot', 'int'):($object->element=='product' && $object->fk_default_warehouse?$object->fk_default_warehouse:'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); + print $formproduct->selectWarehouses((GETPOST("dwid") ?GETPOST("dwid", 'int') : (GETPOST('id_entrepot') ?GETPOST('id_entrepot', 'int') : ($object->element == 'product' && $object->fk_default_warehouse ? $object->fk_default_warehouse : 'ifone'))), 'id_entrepot', 'warehouseopen,warehouseinternal', 1); print ''; } if ($object->element == 'stock') { print ''.$langs->trans("Product").''; print ''; - $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES)?'0':''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); + $form->select_produits(GETPOST('product_id', 'int'), 'product_id', (empty($conf->global->STOCK_SUPPORTS_SERVICES) ? '0' : ''), 0, 0, -1, 2, '', 0, null, 0, 1, 0, 'maxwidth500'); print ''; } @@ -92,44 +92,44 @@ if ($object->element == 'stock') print ''; // Serial / Eat-by date -if (! empty($conf->productbatch->enabled) && +if (!empty($conf->productbatch->enabled) && (($object->element == 'product' && $object->hasbatch()) || ($object->element == 'stock')) ) { print ''; - print 'element == 'stock'?'': ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; + print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; if ($pdluoid > 0) { // If form was opened for a specific pdluoid, field is disabled - print ''; - print ''; + print ''; + print ''; } else { - print ''; + print ''; } print ''; print ''; print ''; print ''.$langs->trans("EatByDate").''; - print $form->selectDate(($d_eatby?$d_eatby:$pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled print ''; print ''.$langs->trans("SellByDate").''; - print $form->selectDate(($d_sellby?$d_sellby:$pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled print ''; print ''; } // Label - $valformovementlabel=(GETPOST("label")?GETPOST("label"):$langs->trans("MovementTransferStock", $productref)); + $valformovementlabel = (GETPOST("label") ?GETPOST("label") : $langs->trans("MovementTransferStock", $productref)); print ''; print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; - print ''.$langs->trans("InventoryCode").''; + print ''.$langs->trans("InventoryCode").''; print ''; print ''; diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 36887b736af..c08abe24c07 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -32,8 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->loadLangs(array("admin", "companies", "other")); -$action=GETPOST('action', 'alpha'); -$value=GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$value = GETPOST('value', 'alpha'); if (!$user->admin) accessforbidden(); @@ -79,8 +79,8 @@ if ($action == 'updateoptions') { $companysearch = GETPOST('activate_COMPANY_USE_SEARCH_TO_SELECT', 'alpha'); $res = dolibarr_set_const($db, "COMPANY_USE_SEARCH_TO_SELECT", $companysearch, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -94,8 +94,8 @@ if ($action == 'updateoptions') { $contactsearch = GETPOST('activate_CONTACT_USE_SEARCH_TO_SELECT', 'alpha'); $res = dolibarr_set_const($db, "CONTACT_USE_SEARCH_TO_SELECT", $contactsearch, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -109,8 +109,8 @@ if ($action == 'updateoptions') { $customertypedefault = GETPOST('defaultcustomertype', 'int'); $res = dolibarr_set_const($db, "THIRDPARTY_CUSTOMERTYPE_BY_DEFAULT", $customertypedefault, 'chaine', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -127,25 +127,25 @@ if ($action == 'set') $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); - $type='company'; + $type = 'company'; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; + $sql .= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; + $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null"); + $sql .= ")"; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } // Disable a document generator module -if ($action== 'del') +if ($action == 'del') { - $type='company'; + $type = 'company'; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; - $resql=$db->query($sql); - if (! $resql) dol_print_error($db); + $sql .= " WHERE nom='".$db->escape($value)."' AND type='".$type."' AND entity=".$conf->entity; + $resql = $db->query($sql); + if (!$resql) dol_print_error($db); } // Define default generator @@ -159,21 +159,21 @@ if ($action == 'setdoc') dolibarr_set_const($db, "COMPANY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity); // On active le modele - $type='company'; + $type = 'company'; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'"; - $sql_del.= " AND type = '".$type."'"; - $sql_del.= " AND entity = ".$conf->entity; + $sql_del .= " WHERE nom = '".$db->escape(GETPOST('value', 'alpha'))."'"; + $sql_del .= " AND type = '".$type."'"; + $sql_del .= " AND entity = ".$conf->entity; dol_syslog("societe.php ".$sql); - $result1=$db->query($sql_del); + $result1 = $db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; + $sql .= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; + $sql .= ($label ? "'".$db->escape($label)."'" : 'null').", "; + $sql .= (!empty($scandir) ? "'".$db->escape($scandir)."'" : "null"); + $sql .= ")"; dol_syslog("societe.php", LOG_DEBUG); - $result2=$db->query($sql); + $result2 = $db->query($sql); if ($result1 && $result2) { $db->commit(); @@ -185,11 +185,11 @@ if ($action == 'setdoc') } //Activate Set ref in list -if ($action=="setaddrefinlist") { +if ($action == "setaddrefinlist") { $setaddrefinlist = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ADD_REF_IN_LIST", $setaddrefinlist, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -200,11 +200,11 @@ if ($action=="setaddrefinlist") { } //Activate Set adress in list -if ($action=="setaddadressinlist") { +if ($action == "setaddadressinlist") { $val = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "COMPANY_SHOW_ADDRESS_SELECTLIST", $val, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -215,11 +215,11 @@ if ($action=="setaddadressinlist") { } //Activate Ask For Preferred Shipping Method -if ($action=="setaskforshippingmet") { +if ($action == "setaskforshippingmet") { $setaskforshippingmet = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -230,11 +230,11 @@ if ($action=="setaskforshippingmet") { } //Activate "Disable prospect/customer type" -if ($action=="setdisableprospectcustomer") { +if ($action == "setdisableprospectcustomer") { $setdisableprospectcustomer = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_DISABLE_PROSPECTSCUSTOMERS", $setdisableprospectcustomer, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -249,7 +249,7 @@ if ($action == 'setprofid') { $status = GETPOST('status', 'alpha'); - $idprof="SOCIETE_".$value."_UNIQUE"; + $idprof = "SOCIETE_".$value."_UNIQUE"; if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { //header("Location: ".$_SERVER["PHP_SELF"]); @@ -266,7 +266,7 @@ if ($action == 'setprofidmandatory') { $status = GETPOST('status', 'alpha'); - $idprof="SOCIETE_".$value."_MANDATORY"; + $idprof = "SOCIETE_".$value."_MANDATORY"; if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { //header("Location: ".$_SERVER["PHP_SELF"]); @@ -283,7 +283,7 @@ if ($action == 'setprofidinvoicemandatory') { $status = GETPOST('status', 'alpha'); - $idprof="SOCIETE_".$value."_INVOICE_MANDATORY"; + $idprof = "SOCIETE_".$value."_INVOICE_MANDATORY"; if (dolibarr_set_const($db, $idprof, $status, 'chaine', 0, '', $conf->entity) > 0) { //header("Location: ".$_SERVER["PHP_SELF"]); @@ -310,11 +310,11 @@ if ($action == 'sethideinactivethirdparty') dol_print_error($db); } } -if($action=='setonsearchandlistgooncustomerorsuppliercard'){ +if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); - if (! $res > 0) $error++; - if (! $error) + if (!$res > 0) $error++; + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } @@ -330,12 +330,12 @@ if($action=='setonsearchandlistgooncustomerorsuppliercard'){ clearstatcache(); -$form=new Form($db); +$form = new Form($db); -$help_url='EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros'; +$help_url = 'EN:Module Third Parties setup|FR:Paramétrage_du_module_Tiers|ES:Configuración_del_módulo_terceros'; llxHeader('', $langs->trans("CompanySetup"), $help_url); -$linkback=''.$langs->trans("BackToModuleList").''; +$linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("CompanySetup"), $linkback, 'title_setup'); @@ -343,8 +343,8 @@ $head = societe_admin_prepare_head(); dol_fiche_head($head, 'general', $langs->trans("ThirdParties"), -1, 'company'); -$dirsociete=array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); -foreach ($conf->modules_parts['models'] as $mo) $dirsociete[]=$mo.'core/modules/societe/'; //Add more models +$dirsociete = array_merge(array('/core/modules/societe/'), $conf->modules_parts['societe']); +foreach ($conf->modules_parts['models'] as $mo) $dirsociete[] = $mo.'core/modules/societe/'; //Add more models // Module to manage customer/supplier code @@ -370,16 +370,16 @@ foreach ($dirsociete as $dirroot) if (is_resource($handle)) { // Loop on each module find in opened directory - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 15) == 'mod_codeclient_' && substr($file, -3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -387,7 +387,7 @@ foreach ($dirsociete as $dirroot) $modCodeTiers = new $file; // Show modules according to features level - if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($modCodeTiers->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; if ($modCodeTiers->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; $arrayofmodules[$file] = $modCodeTiers; @@ -399,7 +399,7 @@ foreach ($dirsociete as $dirroot) $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -foreach($arrayofmodules as $file => $modCodeTiers) +foreach ($arrayofmodules as $file => $modCodeTiers) { print ''."\n"; print ''.$modCodeTiers->name.''."\n"; @@ -414,16 +414,16 @@ foreach($arrayofmodules as $file => $modCodeTiers) } else { - $disabled = (! empty($conf->multicompany->enabled) && (is_object($mc) && ! empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); + $disabled = (!empty($conf->multicompany->enabled) && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); print ''; - if (! $disabled) print ''; + if (!$disabled) print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); - if (! $disabled) print ''; + if (!$disabled) print ''; print ''; } print ''; - $s=$modCodeTiers->getToolTip($langs, null, -1); + $s = $modCodeTiers->getToolTip($langs, null, -1); print $form->textwithpicto('', $s, 1); print ''; @@ -458,16 +458,16 @@ foreach ($dirsociete as $dirroot) $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (substr($file, 0, 15) == 'mod_codecompta_' && substr($file, -3) == 'php') { - $file = substr($file, 0, dol_strlen($file)-4); + $file = substr($file, 0, dol_strlen($file) - 4); try { dol_include_once($dirroot.$file.'.php'); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } @@ -484,7 +484,7 @@ foreach ($dirsociete as $dirroot) $arrayofmodules = dol_sort_array($arrayofmodules, 'position'); -foreach($arrayofmodules as $file => $modCodeCompta) +foreach ($arrayofmodules as $file => $modCodeCompta) { print ''; print ''.$modCodeCompta->name."\n"; @@ -505,7 +505,7 @@ foreach($arrayofmodules as $file => $modCodeCompta) print ''; } print ''; - $s=$modCodeCompta->getToolTip($langs, null, -1); + $s = $modCodeCompta->getToolTip($langs, null, -1); print $form->textwithpicto('', $s, 1); print ''; print "\n"; @@ -523,14 +523,14 @@ print load_fiche_titre($langs->trans("ModelModules"), '', ''); // Load array def with activated templates $def = array(); $sql = "SELECT nom"; -$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = 'company'"; -$sql.= " AND entity = ".$conf->entity; -$resql=$db->query($sql); +$sql .= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql .= " WHERE type = 'company'"; +$sql .= " AND entity = ".$conf->entity; +$resql = $db->query($sql); if ($resql) { $i = 0; - $num_rows=$db->num_rows($resql); + $num_rows = $db->num_rows($resql); while ($i < $num_rows) { $array = $db->fetch_array($resql); @@ -557,30 +557,30 @@ foreach ($dirsociete as $dirroot) { $dir = dol_buildpath($dirroot.'doc/', 0); - $handle=@opendir($dir); + $handle = @opendir($dir); if (is_resource($handle)) { - while (($file = readdir($handle))!==false) + while (($file = readdir($handle)) !== false) { if (preg_match('/\.modules\.php$/i', $file)) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); + $name = substr($file, 4, dol_strlen($file) - 16); + $classname = substr($file, 0, dol_strlen($file) - 12); try { dol_include_once($dirroot.'doc/'.$file); } - catch(Exception $e) + catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); } $module = new $classname($db); - $modulequalified=1; - if (! empty($module->version)) { - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; - elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + $modulequalified = 1; + if (!empty($module->version)) { + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; + elseif ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; } if ($modulequalified) @@ -625,14 +625,14 @@ foreach ($dirsociete as $dirroot) } // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); if ($module->type == 'pdf') { - $htmltooltip.='
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; + $htmltooltip .= '
'.$langs->trans("Height").'/'.$langs->trans("Width").': '.$module->page_hauteur.'/'.$module->page_largeur; } - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("WatermarkOnDraft").': '.yn((! empty($module->option_draft_watermark)?$module->option_draft_watermark:''), 1, 1); + $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip .= '
'.$langs->trans("WatermarkOnDraft").': '.yn((!empty($module->option_draft_watermark) ? $module->option_draft_watermark : ''), 1, 1); print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); @@ -642,11 +642,11 @@ foreach ($dirsociete as $dirroot) print ''; if ($module->type == 'pdf') { - $linkspec=''.img_object($langs->trans("Preview"), 'bill').''; + $linkspec = ''.img_object($langs->trans("Preview"), 'bill').''; } else { - $linkspec=img_object($langs->trans("PreviewNotAvailable"), 'generic'); + $linkspec = img_object($langs->trans("PreviewNotAvailable"), 'generic'); } print $linkspec; print ''; @@ -676,38 +676,38 @@ print ''.$langs->trans("MustBeMandatory").''; print ''.$langs->trans("MustBeInvoiceMandatory").''; print "\n"; -$profid['IDPROF1'][0]=$langs->trans("ProfId1"); -$profid['IDPROF1'][1]=$langs->transcountry('ProfId1', $mysoc->country_code); -$profid['IDPROF2'][0]=$langs->trans("ProfId2"); -$profid['IDPROF2'][1]=$langs->transcountry('ProfId2', $mysoc->country_code); -$profid['IDPROF3'][0]=$langs->trans("ProfId3"); -$profid['IDPROF3'][1]=$langs->transcountry('ProfId3', $mysoc->country_code); -$profid['IDPROF4'][0]=$langs->trans("ProfId4"); -$profid['IDPROF4'][1]=$langs->transcountry('ProfId4', $mysoc->country_code); -$profid['IDPROF5'][0]=$langs->trans("ProfId5"); -$profid['IDPROF5'][1]=$langs->transcountry('ProfId5', $mysoc->country_code); -$profid['IDPROF6'][0]=$langs->trans("ProfId6"); -$profid['IDPROF6'][1]=$langs->transcountry('ProfId6', $mysoc->country_code); -$profid['EMAIL'][0]=$langs->trans("EMail"); -$profid['EMAIL'][1]=$langs->trans('Email'); +$profid['IDPROF1'][0] = $langs->trans("ProfId1"); +$profid['IDPROF1'][1] = $langs->transcountry('ProfId1', $mysoc->country_code); +$profid['IDPROF2'][0] = $langs->trans("ProfId2"); +$profid['IDPROF2'][1] = $langs->transcountry('ProfId2', $mysoc->country_code); +$profid['IDPROF3'][0] = $langs->trans("ProfId3"); +$profid['IDPROF3'][1] = $langs->transcountry('ProfId3', $mysoc->country_code); +$profid['IDPROF4'][0] = $langs->trans("ProfId4"); +$profid['IDPROF4'][1] = $langs->transcountry('ProfId4', $mysoc->country_code); +$profid['IDPROF5'][0] = $langs->trans("ProfId5"); +$profid['IDPROF5'][1] = $langs->transcountry('ProfId5', $mysoc->country_code); +$profid['IDPROF6'][0] = $langs->trans("ProfId6"); +$profid['IDPROF6'][1] = $langs->transcountry('ProfId6', $mysoc->country_code); +$profid['EMAIL'][0] = $langs->trans("EMail"); +$profid['EMAIL'][1] = $langs->trans('Email'); -$nbofloop=count($profid); -foreach($profid as $key => $val) +$nbofloop = count($profid); +foreach ($profid as $key => $val) { - if ($profid[$key][1]!='-') + if ($profid[$key][1] != '-') { print ''; print ''.$profid[$key][0]."\n"; print $profid[$key][1]; print ''; - $idprof_unique ='SOCIETE_'.$key.'_UNIQUE'; - $idprof_mandatory ='SOCIETE_'.$key.'_MANDATORY'; - $idprof_invoice_mandatory ='SOCIETE_'.$key.'_INVOICE_MANDATORY'; + $idprof_unique = 'SOCIETE_'.$key.'_UNIQUE'; + $idprof_mandatory = 'SOCIETE_'.$key.'_MANDATORY'; + $idprof_invoice_mandatory = 'SOCIETE_'.$key.'_INVOICE_MANDATORY'; - $verif=(empty($conf->global->$idprof_unique)?false:true); - $mandatory=(empty($conf->global->$idprof_mandatory)?false:true); - $invoice_mandatory=(empty($conf->global->$idprof_invoice_mandatory)?false:true); + $verif = (empty($conf->global->$idprof_unique) ?false:true); + $mandatory = (empty($conf->global->$idprof_mandatory) ?false:true); + $invoice_mandatory = (empty($conf->global->$idprof_invoice_mandatory) ?false:true); if ($verif) { @@ -761,7 +761,7 @@ print "
\n"; print load_fiche_titre($langs->trans("Other"), '', ''); // Autres options -$form=new Form($db); +$form = new Form($db); print '
'; print ''; @@ -778,7 +778,7 @@ print ' '."\n"; print ''; print ''.$form->textwithpicto($langs->trans("DelaiedFullListToSelectCompany"), $langs->trans('UseSearchToSelectCompanyTooltip'), 1).' '; -if (! $conf->use_javascript_ajax) +if (!$conf->use_javascript_ajax) { print ''; print $langs->trans("NotAvailableWhenAjaxDisabled"); @@ -787,7 +787,7 @@ if (! $conf->use_javascript_ajax) else { print ''; - $arrval=array('0'=>$langs->trans("No"), + $arrval = array('0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', @@ -802,7 +802,7 @@ print ''; print ''; print ''.$form->textwithpicto($langs->trans("DelaiedFullListToSelectContact"), $langs->trans('UseSearchToSelectContactTooltip'), 1).''; -if (! $conf->use_javascript_ajax) +if (!$conf->use_javascript_ajax) { print ''; print $langs->trans("NotAvailableWhenAjaxDisabled"); @@ -811,7 +811,7 @@ if (! $conf->use_javascript_ajax) else { print ''; - $arrval=array('0'=>$langs->trans("No"), + $arrval = array('0'=>$langs->trans("No"), '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')', '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')', diff --git a/htdocs/societe/contact.php b/htdocs/societe/contact.php index 6e16e151593..c961b04d8ce 100644 --- a/htdocs/societe/contact.php +++ b/htdocs/societe/contact.php @@ -42,22 +42,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (! empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; +if (!empty($conf->adherent->enabled)) require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -$langs->loadLangs(array("companies","commercial","bills","banks","users")); -if (! empty($conf->categorie->enabled)) $langs->load("categories"); -if (! empty($conf->incoterm->enabled)) $langs->load("incoterm"); -if (! empty($conf->notification->enabled)) $langs->load("mails"); +$langs->loadLangs(array("companies", "commercial", "bills", "banks", "users")); +if (!empty($conf->categorie->enabled)) $langs->load("categories"); +if (!empty($conf->incoterm->enabled)) $langs->load("incoterm"); +if (!empty($conf->notification->enabled)) $langs->load("mails"); -$mesg=''; $error=0; $errors=array(); +$mesg = ''; $error = 0; $errors = array(); $action = (GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'); $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $confirm = GETPOST('confirm'); -$socid = GETPOST('socid', 'int')?GETPOST('socid', 'int'):GETPOST('id', 'int'); -if ($user->socid) $socid=$user->socid; -if (empty($socid) && $action == 'view') $action='create'; +$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); +if ($user->socid) $socid = $user->socid; +if (empty($socid) && $action == 'view') $action = 'create'; $object = new Societe($db); $extrafields = new ExtraFields($db); @@ -88,7 +88,7 @@ if (!empty($canvas)) // Security check $result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', $objcanvas); -if(empty($user->rights->societe->contact->lire)) accessforbidden(); +if (empty($user->rights->societe->contact->lire)) accessforbidden(); @@ -151,7 +151,7 @@ dol_fiche_head($head, 'contact', $langs->trans("ThirdParty"), 0, 'company'); $linkback = ''.$langs->trans("BackToList").''; -dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); +dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom'); dol_fiche_end(); diff --git a/htdocs/user/agenda_extsites.php b/htdocs/user/agenda_extsites.php index 669f1d58c1a..77d6acdaeed 100644 --- a/htdocs/user/agenda_extsites.php +++ b/htdocs/user/agenda_extsites.php @@ -37,15 +37,15 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; $langs->loadLangs(array('agenda', 'admin', 'other')); $def = array(); -$actiontest=GETPOST('test', 'alpha'); -$actionsave=GETPOST('save', 'alpha'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'useragenda'; // To manage different context of search +$actiontest = GETPOST('test', 'alpha'); +$actionsave = GETPOST('save', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'useragenda'; // To manage different context of search -if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; -$MAXAGENDA=$conf->global->AGENDA_EXT_NB; +if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; +$MAXAGENDA = $conf->global->AGENDA_EXT_NB; // List of available colors -$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); +$colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', 'A4A4A5'); // Security check $id = GETPOST('id', 'int'); @@ -54,25 +54,25 @@ $object->fetch($id, '', '', 1); $object->getrights(); // Security check -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; -$feature2 = (($socid && $user->rights->user->self->creer)?'':'user'); +$feature2 = (($socid && $user->rights->user->self->creer) ? '' : 'user'); $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); // If user is not user that read and no permission to read other users, we stop -if (($object->id != $user->id) && (! $user->rights->user->user->lire)) +if (($object->id != $user->id) && (!$user->rights->user->user->lire)) accessforbidden(); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('usercard','useragenda','globalcard')); +$hookmanager->initHooks(array('usercard', 'useragenda', 'globalcard')); /* * Actions */ -$parameters=array('id'=>$socid); -$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array('id'=>$socid); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { @@ -97,16 +97,16 @@ if (empty($reshook)) { if (!empty($src) && !dol_is_url($src)) { setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors'); - $error ++; - $errorsaved ++; + $error++; + $errorsaved++; break; } - $tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i]=$name; - $tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i]=$src; - $tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i]=$offsettz; - $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i]=$color; - $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i]=$enabled; + $tabparam['AGENDA_EXT_NAME_'.$id.'_'.$i] = $name; + $tabparam['AGENDA_EXT_SRC_'.$id.'_'.$i] = $src; + $tabparam['AGENDA_EXT_OFFSETTZ_'.$id.'_'.$i] = $offsettz; + $tabparam['AGENDA_EXT_COLOR_'.$id.'_'.$i] = $color; + $tabparam['AGENDA_EXT_ENABLED_'.$id.'_'.$i] = $enabled; $i++; } @@ -114,7 +114,7 @@ if (empty($reshook)) { if (!$error) { $result = dol_set_user_param($db, $conf, $object, $tabparam); if (!$result > 0) { - $error ++; + $error++; } } @@ -134,12 +134,12 @@ if (empty($reshook)) { * View */ -$form=new Form($db); -$formadmin=new FormAdmin($db); -$formother=new FormOther($db); +$form = new Form($db); +$formadmin = new FormAdmin($db); +$formother = new FormOther($db); -$arrayofjs=array(); -$arrayofcss=array(); +$arrayofjs = array(); +$arrayofcss = array(); llxHeader('', $langs->trans("UserSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss); @@ -148,7 +148,7 @@ print ''; print ''; -$head=user_prepare_head($object); +$head = user_prepare_head($object); dol_fiche_head($head, 'extsites', $langs->trans("User"), -1, 'user'); @@ -167,8 +167,8 @@ print '
'; print ''.$langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; -$selectedvalue=$conf->global->AGENDA_DISABLE_EXT; -if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; +$selectedvalue = $conf->global->AGENDA_DISABLE_EXT; +if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; print '
'; @@ -182,29 +182,29 @@ print "".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFix print ''.$langs->trans("Color").''; print ""; -$i=1; +$i = 1; while ($i <= $MAXAGENDA) { - $key=$i; - $name='AGENDA_EXT_NAME_'.$id.'_'.$key; - $src='AGENDA_EXT_SRC_'.$id.'_'.$key; - $offsettz='AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key; - $color='AGENDA_EXT_COLOR_'.$id.'_'.$key; + $key = $i; + $name = 'AGENDA_EXT_NAME_'.$id.'_'.$key; + $src = 'AGENDA_EXT_SRC_'.$id.'_'.$key; + $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$id.'_'.$key; + $color = 'AGENDA_EXT_COLOR_'.$id.'_'.$key; print ''; // Nb print ''.$langs->trans("AgendaExtNb", $key).""; // Name - print ''; + print ''; // URL - print ''; + print ''; // Offset TZ - print ''; + print ''; // Color (Possible colors are limited by Google) print ''; //print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist); - print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key)?GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key):$object->conf->$color), "AGENDA_EXT_COLOR_".$id.'_'.$key, 'extsitesconfig', 1, '', 'hideifnotset'); + print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) ?GETPOST("AGENDA_EXT_COLOR_".$id.'_'.$key) : $object->conf->$color), "AGENDA_EXT_COLOR_".$id.'_'.$key, 'extsitesconfig', 1, '', 'hideifnotset'); print ''; print ""; $i++; From 636da4518f877ef5c70fc5952032c749472e3bd9 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 3 Dec 2019 11:22:00 +0100 Subject: [PATCH 137/248] Fix title of transactions list --- htdocs/stripe/transaction.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/transaction.php b/htdocs/stripe/transaction.php index d1ab2ebe50d..8b06ca6ac90 100644 --- a/htdocs/stripe/transaction.php +++ b/htdocs/stripe/transaction.php @@ -106,7 +106,7 @@ if (! $rowid) { print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'left '); print_liste_field_titre("Paid", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right '); print_liste_field_titre("Fee", $_SERVER["PHP_SELF"], "", "", "", '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right_'); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", "", '', '', '', 'right '); print "\n"; print "\n"; From 2d95544abd768df1b2b0608275b8093f80a72c35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 13:46:12 +0100 Subject: [PATCH 138/248] Update filemanager.tpl.php --- htdocs/core/tpl/filemanager.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/filemanager.tpl.php b/htdocs/core/tpl/filemanager.tpl.php index 55acf28e3b7..3a3395432de 100644 --- a/htdocs/core/tpl/filemanager.tpl.php +++ b/htdocs/core/tpl/filemanager.tpl.php @@ -81,7 +81,7 @@ if ($permtoadd) else { print ''; - print ''; + print ''; print ''; } if ($module == 'ecm') From 78acf07e4c1ad74a321e49911c10b118e0737691 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 14:59:05 +0100 Subject: [PATCH 139/248] Fix bad side effect of debugbar with android --- htdocs/main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5fbc453583b..63b8eaa5561 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -253,7 +253,7 @@ require_once 'master.inc.php'; register_shutdown_function('dol_shutdown'); // Load debugbar -if (! empty($conf->debugbar->enabled)) +if (!empty($conf->debugbar->enabled) && ! GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) { global $debugbar; include_once DOL_DOCUMENT_ROOT.'/debugbar/class/DebugBar.php'; From d153918a10907328ee09c5f34e7c093ce810623a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 15:00:52 +0100 Subject: [PATCH 140/248] Fix trans --- htdocs/comm/action/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2ef4c74f765..dc00a4dd091 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -37,7 +37,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->loadLangs(array("users","companies","agenda","commercial")); +$langs->loadLangs(array("users","companies","agenda","commercial","other")); $action=GETPOST('action', 'alpha'); $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'actioncommlist'; // To manage different context of search From 474057de1f083358fe813c205a5aed11a6bd493f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 15:12:18 +0100 Subject: [PATCH 141/248] Fix reponsive --- htdocs/theme/eldy/global.inc.php | 7 +++++-- htdocs/theme/md/style.css.php | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index e076d6eb58a..975edc2787f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -529,8 +529,8 @@ body[class*="colorblind-"] .text-success{ .fa-toggle-on, .fa-toggle-off { font-size: 2em; } .websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off, -.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off { - font-size: 1.5em; vertical-align: text-bottom; +.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off { + font-size: 1.5em; vertical-align: text-bottom; } /* Themes for badges */ @@ -5958,6 +5958,9 @@ div.tabsElem a.tab { line-height: unset; } + .btnTitle-label { + display: none; + } } - -close(); From 85d8d2ff586d36855f0afa8ef440c30c397d991e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 3 Dec 2019 15:19:58 +0100 Subject: [PATCH 142/248] select_product_fourn_price returns void --- htdocs/product/stock/replenish.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 335881f7993..640a6eaa32e 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -723,7 +723,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) print ''; // Supplier - print ''.$form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier).''; + print ''; + $form->select_product_fourn_price($prod->id, 'fourn'.$i, $fk_supplier); + print ''; // Fields from hook $parameters = array('objp'=>$objp); From 2c86aab9ca3a3164a09c16047587e1634e1a0399 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 15:22:46 +0100 Subject: [PATCH 143/248] Fix responsive --- htdocs/societe/list.php | 2 +- htdocs/theme/eldy/global.inc.php | 1 + htdocs/theme/md/style.css.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 504ccb37a25..ba01b901f9f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -949,7 +949,7 @@ if (!empty($arrayfields['s.import_key']['checked'])) print ''; } // Action column -print ''; +print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 975edc2787f..73b0da9323c 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -372,6 +372,7 @@ th .button { } .maxwidthsearch { /* Max width of column with the search picto */ width: 54px; + min-width: 54px; } .valigntop { vertical-align: top; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 9557080020d..d450c939a49 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -594,6 +594,7 @@ th .button { } .maxwidthsearch { /* Max width of column with the search picto */ width: 54px; + min-width: 54px; } .valigntop { From cec54d6ce0e9b47db1e988c2a21a183fd64331b8 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 3 Dec 2019 16:40:35 +0100 Subject: [PATCH 144/248] FIX : when we need to bill several orders, order lines unit is not on bill lines --- htdocs/core/actions_massactions.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 2f5f03ee5a8..62d8e2466b0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -701,7 +701,10 @@ if ($massaction == 'confirm_createbills') $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $lines[$i]->label, - $array_options + $array_options, + 100, + 0, + $lines[$i]->fk_unit ); if ($result > 0) { From 650c9c2e572be3c6834181ab78590f319274ced1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 3 Dec 2019 16:46:50 +0100 Subject: [PATCH 145/248] Update product.class.php --- htdocs/product/class/product.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 40360c9bbd0..88a0fc30488 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1201,7 +1201,7 @@ class Product extends CommonObject } //We also check if it is a child product - if (!$error && ($prodcomb->fetchByFkProductChild($id) > 0) && ($prodcomb->delete($user) < 0)) { + if (!$error && ($prodcomb->fetchByFkProductChild($this->id) > 0) && ($prodcomb->delete($user) < 0)) { $error++; $this->errors[] = 'Error deleting child combination'; } From e46f654e9fc653818d6f89d8956f846f4a066694 Mon Sep 17 00:00:00 2001 From: John Botella Date: Tue, 3 Dec 2019 17:27:13 +0100 Subject: [PATCH 146/248] Fix deprecated image2wbmp function --- htdocs/core/lib/images.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 6204dd0dd9f..55a39a492c7 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -279,7 +279,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, imagepng($imgThumb, $imgThumbName, $newquality); break; case 4: // Bmp - image2wbmp($imgThumb, $imgThumbName); + imagewbmp($imgThumb, $imgThumbName); break; } @@ -379,7 +379,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) // Not supported by PHP GD break; case IMAGETYPE_WBMP: // 15 - $image = image2wbmp($img, $fileDest); + $image = imagewbmp($img, $fileDest); break; } @@ -696,7 +696,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Not supported by PHP GD break; case IMAGETYPE_WBMP: // 15 - image2wbmp($imgThumb, $imgThumbName); + imagewbmp($imgThumb, $imgThumbName); break; } From 5a17289e7579140d70e53b7e2a1fe0448be1df37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 18:04:58 +0100 Subject: [PATCH 147/248] Fix crop for proposal image --- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/photos_resize.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 3b2a7fcb872..0352700d91a 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1099,7 +1099,7 @@ class FormFile if ($disablecrop == -1) { $disablecrop = 1; - if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; + if (in_array($modulepart, array('bank', 'bom', 'expensereport', 'holiday', 'member', 'mrp', 'project', 'product', 'produit', 'propal', 'service', 'societe', 'tax', 'ticket', 'user'))) $disablecrop = 0; } // Define relative path used to store the file diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index eeff5007c55..cb57c81833d 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -119,9 +119,20 @@ elseif ($modulepart == 'project') { $result = $object->fetch($id); if ($result <= 0) dol_print_error($db, 'Failed to load object'); - $dir = $conf->projet->dir_output; // By default + $dir = $conf->project->multidir_output[$object->entity]; // By default } } +elseif ($modulepart == 'propal') +{ + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; + $object = new Propal($db); + if ($id > 0) + { + $result = $object->fetch($id); + if ($result <= 0) dol_print_error($db, 'Failed to load object'); + $dir = $conf->propal->multidir_output[$object->entity]; // By default + } +} elseif ($modulepart == 'holiday') { require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; @@ -243,6 +254,7 @@ if (empty($backtourl)) elseif (in_array($modulepart, array('holiday'))) $backtourl = DOL_URL_ROOT."/holiday/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('member'))) $backtourl = DOL_URL_ROOT."/adherents/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('project'))) $backtourl = DOL_URL_ROOT."/projet/document.php?id=".$id.'&file='.urldecode($_POST["file"]); + elseif (in_array($modulepart, array('propal'))) $backtourl = DOL_URL_ROOT."/comm/propal/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('societe'))) $backtourl = DOL_URL_ROOT."/societe/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('tax'))) $backtourl = DOL_URL_ROOT."/compta/sociales/document.php?id=".$id.'&file='.urldecode($_POST["file"]); elseif (in_array($modulepart, array('ticket'))) $backtourl = DOL_URL_ROOT."/ticket/document.php?id=".$id.'&file='.urldecode($_POST["file"]); From 0ce1e5c007d84e8931359c54ee8864a387cdba20 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Tue, 3 Dec 2019 19:39:32 +0100 Subject: [PATCH 148/248] Fix : Fatal error: Uncaught Error: Class Facture not found --- htdocs/core/lib/pdf.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index fea8e204aeb..c2705fdc556 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1231,7 +1231,8 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { global $db, $conf, $langs; - + include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); From 24b5b9bd7295211cfe1130e8c2da997a8f4ce4ac Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 3 Dec 2019 18:42:29 +0000 Subject: [PATCH 149/248] Fixing style errors. --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index c2705fdc556..edaac53a167 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1232,7 +1232,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, { global $db, $conf, $langs; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - + $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); $desc = (!empty($object->lines[$i]->desc) ? $object->lines[$i]->desc : (!empty($object->lines[$i]->description) ? $object->lines[$i]->description : '')); From 22b17190e8896b309f2d3774121bcae99ecd0a53 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 22:26:33 +0100 Subject: [PATCH 150/248] Update pdf.lib.php --- htdocs/core/lib/pdf.lib.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index edaac53a167..0749d0a7645 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1231,7 +1231,6 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { global $db, $conf, $langs; - include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $idprod = (!empty($object->lines[$i]->fk_product) ? $object->lines[$i]->fk_product : false); $label = (!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')); @@ -1283,8 +1282,10 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (!empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note = $prodser->multilangs[$outputlangs->defaultlang]["note"]; } } - elseif ($object->type == Facture::TYPE_DEPOSIT && $object->element == 'facture') { - $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + elseif ($object->element == 'facture' || $object->element == 'facturefourn') { + if ($object->type == $object::TYPE_DEPOSIT) { + $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + } } // Description short of product line From 558e0cb5f6a4bb71d01b2ea17f43e397ea32cd59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 22:34:49 +0100 Subject: [PATCH 151/248] Fix regression --- htdocs/core/lib/pdf.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ac407bd42a1..bb689d52519 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1263,8 +1263,10 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } - elseif ($object->type == Facture::TYPE_DEPOSIT && $object->element == 'facture') { - $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + elseif ($object->element == 'facture' || $object->element == 'facturefourn') { + if ($object->type == $object::TYPE_DEPOSIT) { + $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + } } // Description short of product line From 60d3bd0fe9379feca12dd3e9c6b87a64ba048953 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 22:36:26 +0100 Subject: [PATCH 152/248] Fix regression --- htdocs/core/lib/pdf.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 6c2fb96e76c..af1da161dc7 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1256,8 +1256,10 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } - elseif ($object->type == Facture::TYPE_DEPOSIT && $object->element == 'facture') { - $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + elseif ($object->element == 'facture' || $object->element == 'facturefourn') { + if ($object->type == $object::TYPE_DEPOSIT) { + $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + } } // Description short of product line From a75915a7a85823724ff77d34047d29a17ac517e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 22:37:58 +0100 Subject: [PATCH 153/248] Fix regression --- htdocs/core/lib/pdf.lib.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 8fa12241643..3d22733ee7f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -1238,8 +1238,10 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (! empty($prodser->multilangs[$outputlangs->defaultlang]["note"]) && ($textwasmodified || $translatealsoifmodified)) $note=$prodser->multilangs[$outputlangs->defaultlang]["note"]; } } - elseif ($object->type == Facture::TYPE_DEPOSIT && $object->element == 'facture') { - $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + elseif ($object->element == 'facture' || $object->element == 'facturefourn') { + if ($object->type == $object::TYPE_DEPOSIT) { + $desc = str_replace('(DEPOSIT)', $outputlangs->trans('Deposit'), $desc); + } } // Description short of product line From 9878eddd7507477ae54c79aa2dadca2c0dea3a4a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Dec 2019 22:52:20 +0100 Subject: [PATCH 154/248] Fix phpcs --- htdocs/core/lib/images.lib.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 532563216eb..fa68301a298 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -324,7 +324,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) { if (function_exists('exif_read_data') ) { $exif = exif_read_data($fileSource); - if($exif && isset($exif['Orientation'])) { + if ($exif && isset($exif['Orientation'])) { $infoImg = getimagesize($fileSource); // Get image infos @@ -438,12 +438,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING); return 'ErrorBadImageFormat'; } - elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1){ + elseif(!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) { // Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) dol_syslog('Wrong value for parameter maxWidth', LOG_ERR); return 'Error: Wrong value for parameter maxWidth'; } - elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1){ + elseif(!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) { // Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0) dol_syslog('Wrong value for parameter maxHeight', LOG_ERR); return 'Error: Wrong value for parameter maxHeight'; @@ -457,7 +457,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $exif = exif_read_data($filetoread); $ort= false; - if($exif && !empty($exif['Orientation'])){ + if ($exif && !empty($exif['Orientation'])) { $ort = $exif['Orientation']; } @@ -536,8 +536,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', return 0; } $exifAngle = false; - if($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)){ - + if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) { switch($ort) { case 3: // 180 rotate left From 23a4eaf68910e3c3b9e0114c1ba4d98cfeec56aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 4 Dec 2019 08:26:40 +0100 Subject: [PATCH 155/248] clean markdown --- README-FR.md | 54 +++++++++------------- htdocs/modulebuilder/README.md | 4 +- htdocs/modulebuilder/template/ChangeLog.md | 4 +- htdocs/modulebuilder/template/README.md | 23 ++++----- 4 files changed, 34 insertions(+), 51 deletions(-) diff --git a/README-FR.md b/README-FR.md index 4feb27893e0..0d610c29e3b 100644 --- a/README-FR.md +++ b/README-FR.md @@ -1,18 +1,14 @@ # DOLIBARR ERP & CRM -Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans). +Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans). Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...). - + ![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_640x480.png) - - ## LICENCE Dolibarr est distribué sous les termes de la licence GNU General Public License v3+ ou supérieure. - - ## INSTALLER DOLIBARR ### Configuration simple @@ -34,7 +30,7 @@ Vous pouvez aussi utiliser un serveur Web et une base de données prise en charg   git clone https://github.com/dolibarr/dolibarr -b x.y (où x.y est la version principale comme 3.6, 9.0, ...) - Configurez votre serveur Web pour qu'il utilise "*dolibarr/htdocs*" en tant que racine si votre serveur Web ne possède pas déjà de répertoire défini vers lequel pointer. -  + - Créez un fichier `htdocs/conf/conf.php` vide et définissez les autorisations d'*écrire* pour l'utilisateur de votre serveur Web (l'autorisation *écrire* sera supprimée une fois l'installation terminée) - Depuis votre navigateur, allez à la page "install/" de dolibarr @@ -53,28 +49,25 @@ Vous pouvez aussi utiliser un serveur Web et une base de données prise en charg     - Suivez les instructions de l'installateur - ## METTRE A JOUR DOLIBARR Pour mettre à jour Dolibarr depuis une vieille version vers celle ci: + - Ecrasez les vieux fichiers dans le vieux répertoire 'dolibarr' par les fichiers fournis dans ce nouveau package. - + - Au prochain accès, Dolibarr proposera la page de "mise à jour" des données (si nécessaire). - Si un fichier install.lock existe pour verrouiller le processus de mise à jour, il sera demandé de le supprimer manuellement (vous devriez trouver le fichier install.lock dans le répertoire utilisé pour stocker les documents générés ou transférés sur le serveur. Dans la plupart des cas, c'est le répertoire appelé "documents") - + Si un fichier install.lock existe pour verrouiller le processus de mise à jour, il sera demandé de le supprimer manuellement (vous devriez trouver le fichier install.lock dans le répertoire utilisé pour stocker les documents générés ou transférés sur le serveur. Dans la plupart des cas, c'est le répertoire appelé "documents") + *Note: Le processus de migration peut être lancé manuellement et plusieurs fois, sans risque, en appelant la page /install/* - ## CE QUI EST NOUVEAU Voir fichier ChangeLog. - - ## CE QUE DOLIBARR PEUT FAIRE -### Modules principaux (tous optionnels): +### Modules principaux (tous optionnels) - Annuaires des prospects et/ou client et/ou fournisseurs - Gestion de catalogue de produits et services @@ -83,7 +76,7 @@ Voir fichier ChangeLog. - Gestion des factures clients/fournisseurs et paiements - Gestion des virements bancaires SEPA - Gestion des comptes bancaires -- Calendrier/Agenda partagé (avec export ical, vcal) +- Calendrier/Agenda partagé (avec export ical, vcal) - Suivi des opportunités et/ou projets (suivi de rentabilité incluant les factures, notes de frais, temps consommé valorisé, ...) - Gestion de contrats de services - Gestion de stock @@ -96,7 +89,7 @@ Voir fichier ChangeLog. - Point de vente/Caisse enregistreuse - … -### Autres modules: +### Autres modules - Gestion de marque-pages - Gestion des promesses de dons @@ -111,7 +104,7 @@ Voir fichier ChangeLog. - Intégration de système de paiements (Paypal, Stripe, Paybox...) - … -### Divers: +### Divers - Multi-langue. - Multi-utilisateurs avec différents niveaux de permissions par module. @@ -119,41 +112,39 @@ Voir fichier ChangeLog. - Peux être multi-société par ajout du module externe multi-société. - Plusieurs thèmes visuels. - Application simple à utiliser. -- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur https://wiki.dolibarr.org/index.php/Prérequis). +- Requiert PHP et MariaDb, Mysql ou Postgresql (Voir versions exactes sur https://wiki.dolibarr.org/index.php/Prérequis). - Compatible avec toutes les offres Cloud du marché respectant les prérequis de base de données et PHP. - APIs. - Génération PDF et ODT des éléments (factures, propositions commerciales, commandes, bons expéditions, etc...) - Code simple et facilement personnalisable (pas de framework lourd; mécanisme de hook et triggers). - Support natif de nombreuses fonctions spécifiques aux pays comme: - - La tax espagnole TE et ISPF - - Gestion de la TVA NPR (non perçue récupérable - pour les utilisateurs français des DOM-TOM) - - La loi française Finance 2016 et logiciels de caisse - - La double taxe canadienne - - Le timbre fiscal tunisien - - Numérotation de facture de l'argentines (avec type A,B,C...) - - Compatible avec vos processus RGPD - - ... + - La tax espagnole TE et ISPF + - Gestion de la TVA NPR (non perçue récupérable - pour les utilisateurs français des DOM-TOM) + - La loi française Finance 2016 et logiciels de caisse + - La double taxe canadienne + - Le timbre fiscal tunisien + - Numérotation de facture de l'argentines (avec type A,B,C...) + - Compatible avec vos processus RGPD + - ... - … ### Extension Dolibarr peut aussi être étendu à volonté avec l'ajout de module/applications externes développées par des développeus tiers, disponible sur [DoliStore](https://www.dolistore.com). - ## CE QUE DOLIBARR NE PEUT PAS (ENCORE) FAIRE Voici un liste de fonctionnalités pas encore gérées par Dolibarr: + - Dolibarr ne contient pas de module de Gestion de la paie. - Les tâches du module de gestion de projets n'ont pas de dépendances entre elle. - Dolibarr n'embarque pas de Webmail intégré nativement. -- Dolibarr ne fait pas le café (pas encore). - +- Dolibarr ne fait pas le café (pas encore). ## DOCUMENTATION La documentation utilisateur, développeur et traducteur est disponible sous forme de ressources de la communauté via le site [Wiki](https://wiki.dolibarr.org). - ## CONTRIBUER Ce projet existe grâce à ses nombreux contributeurs [[Contribuer](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)]. @@ -166,7 +157,6 @@ Dolibarr est le résultat du travail de nombreux contributeurs depuis des année Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) - ## ACTUALITES ET RESEAUX SOCIAUX Suivez le projet Dolibarr project sur les réseaux francophones diff --git a/htdocs/modulebuilder/README.md b/htdocs/modulebuilder/README.md index e5d9e63d7a3..7bafab32ae3 100644 --- a/htdocs/modulebuilder/README.md +++ b/htdocs/modulebuilder/README.md @@ -7,9 +7,7 @@ has to offer for module development. If you don't need to develop your own module/application, you just don't need this. - -After enabling this module, you should find features to generate or edit modules/application from menu *Home - Admin tools - Module builder* - +After enabling this module, you should find features to generate or edit modules/application from menu *Home - Admin tools - Module builder* Documentation ------------- diff --git a/htdocs/modulebuilder/template/ChangeLog.md b/htdocs/modulebuilder/template/ChangeLog.md index 99f4f673c0c..6ac54265da4 100644 --- a/htdocs/modulebuilder/template/ChangeLog.md +++ b/htdocs/modulebuilder/template/ChangeLog.md @@ -1,5 +1,5 @@ -# CHANGELOG MYMODULE FOR DOLIBARR ERP CRM +# CHANGELOG MYMODULE FOR [DOLIBARR ERP CRM] ## 1.0 -Initial version +Initial version diff --git a/htdocs/modulebuilder/template/README.md b/htdocs/modulebuilder/template/README.md index 0fcd76f178e..29aba550022 100644 --- a/htdocs/modulebuilder/template/README.md +++ b/htdocs/modulebuilder/template/README.md @@ -1,29 +1,27 @@ -# MYMODULE FOR DOLIBARR ERP CRM +# MYMODULE FOR [DOLIBARR ERP CRM] ## Features + Description... -Other modules are available on Dolistore.com. - - +Other modules are available on [Dolistore.com]. ## Translations -Translations can be define manually by editing files into directories *langs*. +Translations can be define manually by editing files into directories *langs*. - - ## Licenses -**Main code** +### Main code GPLv3 or (at your option) any later version. See file COPYING for more information. -**Documentation** +### Documentation All texts and readmes are licensed under GFDL. From bde917d7fc7d557e66465a9ec2dce7b522706f32 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Dec 2019 15:09:20 +0100 Subject: [PATCH 156/248] Fix responsive --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/product/card.php | 17 ++++++++++++----- htdocs/product/list.php | 14 ++++++++------ htdocs/theme/eldy/global.inc.php | 8 -------- htdocs/theme/md/style.css.php | 4 ---- 6 files changed, 23 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cdb55c66049..43064277dca 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3550,7 +3550,7 @@ class Form $return = ''; - $return .= ''; $options = array( 'HT'=>$langs->trans("HT"), 'TTC'=>$langs->trans("TTC") diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c40daaca6c9..59037d18525 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8372,6 +8372,7 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u } $class = 'btnTitle'; + // hidden conf keep during button transition TODO: remove this block if (!empty($conf->global->MAIN_USE_OLD_TITLE_BUTTON)) { $class = 'butActionNew'; @@ -8446,10 +8447,9 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u $tag = (empty($attr['href']) ? 'span' : 'a'); - $button = '<'.$tag.' '.$compiledAttributes.' >'; $button .= ''; - $button .= ''.$label.''; + $button .= ''.$label.''; $button .= ''; // hidden conf keep during button transition TODO: remove this block diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 30032c927cc..48498ac82f7 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1023,7 +1023,9 @@ else require_once DOL_DOCUMENT_ROOT.'/core/class/html.formbarcode.class.php'; $formbarcode = new FormBarCode($db); print $formbarcode->selectBarcodeType($fk_barcode_type, 'fk_barcode_type', 1); - print ''.$langs->trans("BarcodeValue").''; + print ''; + if ($conf->browser->layout == 'phone') print ''; + print ''.$langs->trans("BarcodeValue").''; $tmpcode = isset($_POST['barcode']) ?GETPOST('barcode') : $object->barcode; if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type); print ''; @@ -1052,10 +1054,13 @@ else print ''; print ''; print ''; + print ''; + // Stock min level print ''.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).''; print ''; print ''; + if ($conf->browser->layout == 'phone') print ''; // Stock desired level print ''.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).''; print ''; @@ -1094,9 +1099,9 @@ else if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { print ''.$langs->trans("Length").' x '.$langs->trans("Width").' x '.$langs->trans("Height").''; - print ' x '; - print ' x '; - print ''; + print ' x '; + print ' x '; + print ''; print $formproduct->selectMeasuringUnits("size_units", "size", GETPOSTISSET('size_units') ?GETPOST('size_units', 'alpha') : '0', 0, 2); print ''; } @@ -1140,8 +1145,10 @@ else if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) { print ''.$langs->trans("CustomCode").''; + if ($conf->browser->layout == 'phone') print ''; // Origin country - print ''.$langs->trans("CountryOrigin").''; + print ''.$langs->trans("CountryOrigin").''; + print ''; print $form->select_country(GETPOST('country_id', 'int'), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 0e439e03052..05cc5752777 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -481,19 +481,21 @@ if ($resql) $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; - $rightskey = 'produit'; - if ($type == Product::TYPE_SERVICE) $rightskey = 'service'; - if ($user->rights->{$rightskey}->creer) + if ($type === "") $perm = ($user->rights->produit->creer || $user->rights->service->creer); + elseif ($type == Product::TYPE_SERVICE) $perm = $user->rights->service->creer; + elseif ($type == Product::TYPE_PRODUCT) $perm = $user->rights->produit->creer; + if ($perm) { $oldtype = $type; - + $params = array(); + if ($type === "") $params['forcenohideoftext']=1; if ($type === "") { - $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0'); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', 1, $params); $type = Product::TYPE_SERVICE; } $label = 'NewProduct'; if ($type == Product::TYPE_SERVICE) $label = 'NewService'; - $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type); + $newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type='.$type, '', 1, $params); $type = $oldtype; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 73b0da9323c..975c2a6a0e3 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -5951,17 +5951,9 @@ div.tabsElem a.tab { font-size: 12px; } - .text-plus-circle { - display: none; - } - table.table-fiche-title .col-title div.titre{ line-height: unset; } - - .btnTitle-label { - display: none; - } } Date: Wed, 4 Dec 2019 15:12:18 +0100 Subject: [PATCH 157/248] Fix responsive --- htdocs/takepos/admin/setup.php | 2 ++ htdocs/takepos/admin/terminal.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 770150ecc4e..a6b475508c9 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -128,6 +128,7 @@ print ''; print ''; print ''; +print '
'; print ''; print ''; @@ -290,6 +291,7 @@ print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, print "\n"; print '
'; +print '
'; print '
'; diff --git a/htdocs/takepos/admin/terminal.php b/htdocs/takepos/admin/terminal.php index 1902e522bdf..7e9d974f0a9 100644 --- a/htdocs/takepos/admin/terminal.php +++ b/htdocs/takepos/admin/terminal.php @@ -126,6 +126,7 @@ print ''; print ''; +print '
'; print ''; print ''; print ''; @@ -236,6 +237,7 @@ if (!empty($conf->stock->enabled)) } print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; +print '
'; if ($atleastonefound == 0 && !empty($conf->banque->enabled)) { From b78f3105082f8791608816406d926d87b7e1c5b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Dec 2019 15:49:22 +0100 Subject: [PATCH 158/248] Reponsive --- htdocs/core/class/doleditor.class.php | 2 ++ htdocs/product/card.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index fc148b94611..8dc99ae592f 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -192,6 +192,7 @@ class DolEditor $out.= ''."\n"; $out.= ''; } - print ' '.$langs->trans("AddThirdParty").''; + print ' '; print ''; } print ''."\n"; @@ -1734,7 +1734,7 @@ if ($action == 'create' && $usercancreate) print ''; print ''.$langs->trans("Project").''; $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0); - print '   id).'">'.$langs->trans("AddProject").''; + print ' id).'">'; print ''; print ''; } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 14a4f4bae9b..9751f667b46 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2801,7 +2801,7 @@ if ($action == 'create') }); '; } - if (!GETPOST('fac_rec', 'int')) print ' '.$langs->trans("AddThirdParty").''; + if (!GETPOST('fac_rec', 'int')) print ' '; print ''; print ''."\n"; } @@ -3008,7 +3008,7 @@ if ($action == 'create') print '
'; $tmp = ' '; $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -3016,7 +3016,7 @@ if ($action == 'create') print '
'; $tmp = ' '; $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -3025,7 +3025,7 @@ if ($action == 'create') print '
'; $tmp = ' '; $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceReplacementDesc"), 1, 'help', '', 0, 3); print $desc; print '
'; @@ -3114,7 +3114,7 @@ if ($action == 'create') if (empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp = ' '; else $tmp = ' '; $text = ' '; - $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; + $text .= '('.$langs->trans("YouMustCreateInvoiceFromThird").') '; $desc = $form->textwithpicto($text, $langs->transnoentities("InvoiceAvoirDesc"), 1, 'help', '', 0, 3); print $desc; print '
'."\n"; @@ -3211,7 +3211,6 @@ if ($action == 'create') $rwStyle = ''; } - $retained_warranty = GETPOST('retained_warranty', 'int'); $retained_warranty = !empty($retained_warranty) ? $retained_warranty : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT; print ''.$langs->trans('RetainedWarranty').''; @@ -3260,7 +3259,7 @@ if ($action == 'create') $langs->load('projects'); print ''.$langs->trans('Project').''; $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'.$langs->trans("AddProject").''; + print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'; print ''; } diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index 39cbe6ce6a9..79b152e0bdc 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -250,6 +250,8 @@ OneLinePerUser=One line per user ServiceToUseOnLines=Service to use on lines InvoiceGeneratedFromTimeSpent=Invoice %s has been generated from time spent on project ProjectBillTimeDescription=Check if you enter timesheet on tasks of project AND you plan to generate invoice(s) from the timesheet to bill the customer of the project (do not check if you plan to create invoice that is not based on entered timesheets). +ProjectFollowOpportunity=Follow opportunity +ProjectFollowTasks=Follow tasks UsageOpportunity=Usage: Opportunity UsageTasks=Usage: Tasks UsageBillTimeShort=Usage: Bill time \ No newline at end of file diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 455a5742a68..19bedc123ff 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -554,21 +554,21 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowOpportunity"); print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); print '
'; } if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectFollowTasks"); print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); print '
'; } if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print ' '; + print ' '; $htmltext = $langs->trans("ProjectBillTimeDescription"); print $form->textwithpicto($langs->trans("BillTime"), $htmltext); print '
'; @@ -597,7 +597,7 @@ if ($action == 'create' && $user->rights->projet->creer) print $form->textwithtooltip($text.' '.img_help(), $texthelp, 1); } else print $text; - if (!GETPOSTISSET('backtopage')) print ' '.$langs->trans("AddThirdParty").''; + if (!GETPOSTISSET('backtopage')) print ' '; print ''; } @@ -712,6 +712,20 @@ if ($action == 'create' && $user->rights->projet->creer) jQuery("#opp_status").change(function() { change_percent(); }); + + jQuery("#usage_task").change(function() { + console.log("We click on usage task "+jQuery("#usage_task").is(":checked")); + if (! jQuery("#usage_task").is(":checked")) { + jQuery("#usage_bill_time").prop("checked", false); + } + }); + + jQuery("#usage_bill_time").change(function() { + console.log("We click on usage to bill time"); + if (jQuery("#usage_bill_time").is(":checked")) { + jQuery("#usage_task").prop("checked", true); + } + }); }); '; } From cb497cb08e8acc4cf1eb190fc1958af115d1921e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 08:58:16 +0100 Subject: [PATCH 186/248] Translation --- htdocs/adherents/card.php | 2 +- htdocs/core/lib/payments.lib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 0689672ba7c..f012ce3a571 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1763,7 +1763,7 @@ else /* - * Hotbar + * Action bar */ print '
'; diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index 66b39809b29..e7a9bd51034 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -134,7 +134,7 @@ function showOnlinePaymentUrl($type, $ref) global $langs; // Load translation files required by the page - $langs->loadLangs(array('payment', 'paybox')); + $langs->loadLangs(array('payment', 'stripe')); $servicename = $langs->transnoentitiesnoconv('Online'); From a4272ab947b03145b3d9298c606d4ebba23682ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 09:20:45 +0100 Subject: [PATCH 187/248] Debug v11 --- htdocs/adherents/subscription.php | 45 ++++++++++++++++++++----------- htdocs/comm/action/card.php | 2 +- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 2e26e3709ed..3d1885799c3 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -71,7 +71,6 @@ $adht = new AdherentType($db); $extrafields->fetch_name_optionals_label($object->table_element); $errmsg = ''; -$errmsgs = array(); $defaultdelay = 1; $defaultdelayunit = 'y'; @@ -687,20 +686,19 @@ if ($rowid > 0) $subscriptionstatic = new Subscription($db); $num = $db->num_rows($result); - $i = 0; print ''."\n"; print ''; print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); - print ''; - print ''; - print ''; - print ''; - print ''; + print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); + print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); if (!empty($conf->banque->enabled)) { - print ''; + print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); } print "\n"; @@ -708,6 +706,7 @@ if ($rowid > 0) $adh = new Adherent($db); $adht = new AdherentType($db); + $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); @@ -766,6 +765,13 @@ if ($rowid > 0) print ""; $i++; } + + if (empty($num)) { + $colspan = 6; + if (!empty($conf->banque->enabled)) $colspan++; + print ''; + } + print "
'.$langs->trans("DateCreation").''.$langs->trans("Type").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("Amount").''.$langs->trans("Account").'
'.$langs->trans("None").'
"; } else @@ -1002,7 +1008,7 @@ if ($rowid > 0) print $langs->trans("CreateDolibarrThirdParty"); print ')'; } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0); + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); @@ -1027,7 +1033,7 @@ if ($rowid > 0) print $langs->trans("CreateDolibarrThirdParty"); print ')'; } - if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0); + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); @@ -1070,9 +1076,9 @@ if ($rowid > 0) } } - print ' '; + print ''; - print ''.$langs->trans("SendAcknowledgementByMail").''; + print ''.$langs->trans("SendAcknowledgementByMail").''; print ''; if (!$object->email) { @@ -1117,11 +1123,20 @@ if ($rowid > 0) $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; - $helpcontent .= $subjecttosend."\n"; + if ($subjecttosend) { + $helpcontent .= $subjecttosend."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } $helpcontent .= "
"; $helpcontent .= ''.$langs->trans("MailText").':
'; - $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; - + if ($texttosend) { + $helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; + } else { + $langs->load("errors"); + $helpcontent .= ''.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).''."\n"; + } print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); } print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 92144f50934..765502075c2 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1052,7 +1052,7 @@ if ($action == 'create') $numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1); - print '   '.$langs->trans("AddProject").''; + print ' '; $urloption = '?action=create'; $url = dol_buildpath('comm/action/card.php', 2).$urloption; From 4debd71281f5e3b8df2d160b20092a94353a515d Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Fri, 6 Dec 2019 08:26:49 +0000 Subject: [PATCH 188/248] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/compta/bank/card.php | 6 +- htdocs/core/class/doleditor.class.php | 156 ++++++++++---------- htdocs/core/class/html.formticket.class.php | 18 +-- htdocs/core/lib/images.lib.php | 140 +++++++++--------- htdocs/document.php | 88 +++++------ htdocs/product/list.php | 6 +- 6 files changed, 207 insertions(+), 207 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 2ba96a2cf8d..2897eb6e5c3 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -492,11 +492,11 @@ if ($action == 'create') $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; - $sizecss = 'minwidth200'; + $sizecss = 'minwidth200'; $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; - $sizecss = 'minwidth50'; + $sizecss = 'minwidth50'; $content = $object->cle_rib; } @@ -923,7 +923,7 @@ else $cats = $c->containing($object->id, Categorie::TYPE_ACCOUNT); if (is_array($cats)) { - foreach($cats as $cat) { + foreach ($cats as $cat) { $arrayselected[] = $cat->id; } } diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index d449e7a8424..29bb1c24dce 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,7 +28,7 @@ */ class DolEditor { - public $tool; // Store the selected tool + public $tool; // Store the selected tool // If using fckeditor public $editor; @@ -66,55 +66,55 @@ class DolEditor */ public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) { - global $conf,$langs; + global $conf, $langs; dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); - if (! $rows) $rows=round($height/20); - if (! $cols) $cols=($width?round($width/6):80); - $shorttoolbarname=preg_replace('/_encoded$/', '', $toolbarname); + if (!$rows) $rows = round($height / 20); + if (!$cols) $cols = ($width ?round($width / 6) : 80); + $shorttoolbarname = preg_replace('/_encoded$/', '', $toolbarname); // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') - $defaulteditor='ckeditor'; - $this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?$defaulteditor:$conf->global->FCKEDITOR_EDITORNAME; - $this->uselocalbrowser=$uselocalbrowser; - $this->readonly=$readonly; + $defaulteditor = 'ckeditor'; + $this->tool = empty($conf->global->FCKEDITOR_EDITORNAME) ? $defaulteditor : $conf->global->FCKEDITOR_EDITORNAME; + $this->uselocalbrowser = $uselocalbrowser; + $this->readonly = $readonly; // Check if extended editor is ok. If not we force textarea if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; - if ($okforextendededitor === 'ace') $this->tool='ace'; + if ($okforextendededitor === 'ace') $this->tool = 'ace'; //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile // Define content and some properties if ($this->tool == 'ckeditor') { - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. } if ($this->tool == 'fckeditor') { require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; - $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. + $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. $this->editor = new FCKeditor($htmlname); - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; - $this->editor->Value = $content; + $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/'; + $this->editor->Value = $content; $this->editor->Height = $height; - if (! empty($width)) $this->editor->Width = $width; - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) + if (!empty($width)) $this->editor->Width = $width; + $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js + $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? - $modulepart='fckeditor'; + $modulepart = 'fckeditor'; $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/' ; + $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/'; - $this->editor->Config['LinkBrowser']=($uselocalbrowser?'true':'false'); - $this->editor->Config['ImageBrowser']=($uselocalbrowser?'true':'false'); + $this->editor->Config['LinkBrowser'] = ($uselocalbrowser ? 'true' : 'false'); + $this->editor->Config['ImageBrowser'] = ($uselocalbrowser ? 'true' : 'false'); if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) { @@ -124,15 +124,15 @@ class DolEditor } // Define some properties - if (in_array($this->tool, array('textarea','ckeditor','ace'))) + if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) { - $this->content = $content; + $this->content = $content; $this->htmlname = $htmlname; - $this->toolbarname = $shorttoolbarname; + $this->toolbarname = $shorttoolbarname; $this->toolbarstartexpanded = $toolbarstartexpanded; $this->rows = max(ROWS_3, $rows); - $this->cols = (preg_match('/%/', $cols)?$cols:max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max - $this->height = $height; + $this->cols = (preg_match('/%/', $cols) ? $cols : max(40, $cols)); // If $cols is a percent, we keep it, otherwise, we take max + $this->height = $height; $this->width = $width; } } @@ -152,45 +152,45 @@ class DolEditor public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') { // phpcs:enable - global $conf,$langs; + global $conf, $langs; - $fullpage=false; + $fullpage = false; if (isset($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT)) { - $disallowAnyContent=empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all + $disallowAnyContent = empty($conf->global->FCKEDITOR_ALLOW_ANY_CONTENT); // Only predefined list of html tags are allowed or all } - $found=0; - $out=''; + $found = 0; + $out = ''; if ($this->tool == 'fckeditor') // not used anymore { - $found=1; + $found = 1; $this->editor->Create(); } - if (in_array($this->tool, array('textarea','ckeditor'))) + if (in_array($this->tool, array('textarea', 'ckeditor'))) { - $found=1; + $found = 1; //$out.= ''; + $out .= ''; - if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax) && ! empty($conf->fckeditor->enabled)) + if ($this->tool == 'ckeditor' && !empty($conf->use_javascript_ajax) && !empty($conf->fckeditor->enabled)) { - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); + if (!defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR', '1'); - if (! empty($conf->global->FCKEDITOR_SKIN)) { + if (!empty($conf->global->FCKEDITOR_SKIN)) { $skin = $conf->global->FCKEDITOR_SKIN; } else { $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa } - $htmlencode_force=preg_match('/_encoded$/', $this->toolbarname)?'true':'false'; + $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out.= ''."\n"; - $out.= ''."\n"; + $out .= ' })'.$morejs; + $out .= '});'."\n"; + $out .= ''."\n"; } } @@ -259,19 +259,19 @@ class DolEditor // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. if (preg_match('/^ace/', $this->tool)) { - $found=1; - $format=$option; + $found = 1; + $format = $option; - $out.= "\n".''."\n"; + $out .= "\n".''."\n"; if ($titlecontent) { - $out.= '
'.$titlecontent; - $out.= '   -   '.dol_escape_htmltag($langs->trans("ShowMoreLines")).'     '; - $out.= '
'; - $out.= ''."\n"; + $out .= ''."\n"; } - $out.= '
htmlname.'aceeditorid" style="'.($this->width ? 'width: '.$this->width.'px; ' : '');
+            $out .= ($this->height ? ' height: '.$this->height.'px; ' : '');
             //$out.=" min-height: 100px;";
-            $out.= '">';
-        	$out.= htmlspecialchars($this->content);
-        	$out.= '
'; - $out.= ''; + $out .= '">'; + $out .= htmlspecialchars($this->content); + $out .= ''; + $out .= ''; - $out.= ''."\n"; + $out .= ''."\n"; } if (empty($found)) { - $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; + $out .= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; } if ($noprint) return $out; diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cdea1c17e01..117af9e8f19 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -376,33 +376,33 @@ class FormTicket } $out = ''; - $out .= '' . $langs->trans("MailFile") . ''; + $out .= ''.$langs->trans("MailFile").''; $out .= ''; // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out .= '' . "\n"; + $out .= ''."\n"; $out .= '' . "\n"; + $out .= ''."\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { - $out .= '
'; - $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; + $out .= '
'; + $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; if (!$this->withfilereadonly) { - $out .= ' '; + $out .= ' '; } $out .= '
'; } } else { - $out .= $langs->trans("NoAttachedFiles") . '
'; + $out .= $langs->trans("NoAttachedFiles").'
'; } if ($this->withfile == 2) { // Can add other files - $out .= ''; + $out .= ''; $out .= ' '; - $out .= ''; + $out .= ''; } $out .= "\n"; diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 93174a7c390..69b907036c1 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -23,8 +23,8 @@ */ // Define size of logo small and mini -$maxwidthsmall=270;$maxheightsmall=150; -$maxwidthmini=128;$maxheightmini=72; +$maxwidthsmall = 270; $maxheightsmall = 150; +$maxwidthmini = 128; $maxheightmini = 72; $quality = 80; @@ -37,14 +37,14 @@ $quality = 80; */ function image_format_supported($file) { - $regeximgext='\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php + $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.xpm|\.xbm|\.svg'; // See also into product.class.php // Case filename is not a format image $reg = array(); - if (! preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; + if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1; // Case filename is a format image but not supported by this PHP - $imgfonction=''; + $imgfonction = ''; if (strtolower($reg[1]) == '.gif') $imgfonction = 'imagecreatefromgif'; if (strtolower($reg[1]) == '.png') $imgfonction = 'imagecreatefrompng'; if (strtolower($reg[1]) == '.jpg') $imgfonction = 'imagecreatefromjpeg'; @@ -52,10 +52,10 @@ function image_format_supported($file) if (strtolower($reg[1]) == '.bmp') $imgfonction = 'imagecreatefromwbmp'; if (strtolower($reg[1]) == '.xpm') $imgfonction = 'imagecreatefromxpm'; if (strtolower($reg[1]) == '.xbm') $imgfonction = 'imagecreatefromxbm'; - if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available + if (strtolower($reg[1]) == '.svg') $imgfonction = 'imagecreatefromsvg'; // Never available if ($imgfonction) { - if (! function_exists($imgfonction)) + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 0; @@ -76,21 +76,21 @@ function image_format_supported($file) */ function dol_getImageSize($file, $url = false) { - $ret=array(); + $ret = array(); if (image_format_supported($file) < 0) return $ret; $filetoread = $file; if (!$url) { - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image } if ($filetoread) { $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image - $ret['width']=$infoImg[0]; // Largeur de l'image - $ret['height']=$infoImg[1]; // Hauteur de l'image + $ret['width'] = $infoImg[0]; // Largeur de l'image + $ret['height'] = $infoImg[1]; // Hauteur de l'image } return $ret; @@ -112,29 +112,29 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, { require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - global $conf,$langs; + global $conf, $langs; dol_syslog("dol_imageResizeOrCrop file=".$file." mode=".$mode." newWidth=".$newWidth." newHeight=".$newHeight." src_x=".$src_x." src_y=".$src_y); // Clean parameters - $file=trim($file); + $file = trim($file); // Check parameters - if (! $file) + if (!$file) { // Si le fichier n'a pas ete indique return 'Bad parameter file'; } - elseif (! file_exists($file)) + elseif (!file_exists($file)) { // Si le fichier passe en parametre n'existe pas return $langs->trans("ErrorFileNotFound", $file); } - elseif(image_format_supported($file) < 0) + elseif (image_format_supported($file) < 0) { return 'This filename '.$file.' does not seem to be an image filename.'; } - elseif(!is_numeric($newWidth) && !is_numeric($newHeight)) + elseif (!is_numeric($newWidth) && !is_numeric($newHeight)) { return 'Wrong value for parameter newWidth or newHeight'; } @@ -147,7 +147,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, return 'Both newHeight or newWidth must be defined for croping'; } - $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image + $filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image $infoImg = getimagesize($filetoread); // Recuperation des infos de l'image $imgWidth = $infoImg[0]; // Largeur de l'image @@ -155,18 +155,18 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, if ($mode == 0) // If resize, we check parameters { - if ($newWidth <= 0) + if ($newWidth <= 0) { - $newWidth=intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio + $newWidth = intval(($newHeight / $imgHeight) * $imgWidth); // Keep ratio } if ($newHeight <= 0) { - $newHeight=intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio + $newHeight = intval(($newWidth / $imgWidth) * $imgHeight); // Keep ratio } } - $imgfonction=''; - switch($infoImg[2]) + $imgfonction = ''; + switch ($infoImg[2]) { case 1: // IMG_GIF $imgfonction = 'imagecreatefromgif'; @@ -183,7 +183,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } if ($imgfonction) { - if (! function_exists($imgfonction)) + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 'Resize not possible. This PHP does not support GD functions '.$imgfonction; @@ -191,27 +191,27 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Initialisation des variables selon l'extension de l'image - switch($infoImg[2]) + switch ($infoImg[2]) { case 1: // Gif $img = imagecreatefromgif($filetoread); - $extImg = '.gif'; // File name extension of image - $newquality='NU'; // Quality is not used for this format + $extImg = '.gif'; // File name extension of image + $newquality = 'NU'; // Quality is not used for this format break; case 2: // Jpg $img = imagecreatefromjpeg($filetoread); $extImg = '.jpg'; - $newquality=100; // % quality maximum + $newquality = 100; // % quality maximum break; case 3: // Png $img = imagecreatefrompng($filetoread); $extImg = '.png'; - $newquality=0; // No compression (0-9) + $newquality = 0; // No compression (0-9) break; case 4: // Bmp $img = imagecreatefromwbmp($filetoread); $extImg = '.bmp'; - $newquality='NU'; // Quality is not used for this format + $newquality = 'NU'; // Quality is not used for this format break; } @@ -239,7 +239,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Initialisation des variables selon l'extension de l'image - switch($infoImg[2]) + switch ($infoImg[2]) { case 1: // Gif $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF @@ -250,7 +250,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, break; case 3: // Png imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel break; case 4: // Bmp $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); @@ -260,7 +260,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, dol_syslog("dol_imageResizeOrCrop: convert image from ($imgWidth x $imgHeight) at position ($src_x x $src_y) to ($newWidth x $newHeight) as $extImg, newquality=$newquality"); //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee - imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode==0?$imgWidth:$newWidth), ($mode==0?$imgHeight:$newHeight)); // Insere l'image de base redimensionnee + imagecopyresampled($imgThumb, $img, 0, 0, $src_x, $src_y, $newWidth, $newHeight, ($mode == 0 ? $imgWidth : $newWidth), ($mode == 0 ? $imgHeight : $newHeight)); // Insere l'image de base redimensionnee $imgThumbName = $file; @@ -269,7 +269,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, //fclose($fp); // Create image on disk - switch($infoImg[2]) + switch ($infoImg[2]) { case 1: // Gif imagegif($imgThumb, $imgThumbName); @@ -286,13 +286,13 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } // Set permissions on file - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); // Free memory. This does not delete image. imagedestroy($img); imagedestroy($imgThumb); - clearstatcache(); // File was replaced by a modified one, so we clear file caches. + clearstatcache(); // File was replaced by a modified one, so we clear file caches. return $imgThumbName; } @@ -343,7 +343,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) break; } if ($deg) { - if($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case + if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case { imagealphablending($img, false); imagesavealpha($img, true); @@ -351,12 +351,12 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) imagealphablending($img, false); imagesavealpha($img, true); } - else{ + else { $img = imagerotate($img, $deg, 0); } } // then rewrite the rotated image back to the disk as $fileDest - if($fileDest === false){ + if ($fileDest === false) { return $img; } else @@ -365,7 +365,7 @@ function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) // Create image on disk $image = false; - switch($infoImg[2]) + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $image = imagegif($img, $fileDest); @@ -473,8 +473,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //return 'Le fichier '.$file.' ne necessite pas de creation de vignette'; } - $imgfonction=''; - switch($infoImg[2]) + $imgfonction = ''; + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $imgfonction = 'imagecreatefromgif'; @@ -494,7 +494,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } if ($imgfonction) { - if (! function_exists($imgfonction)) + if (!function_exists($imgfonction)) { // Fonctions de conversion non presente dans ce PHP return 'Error: Creation of thumbs not possible. This PHP does not support GD function '.$imgfonction; @@ -502,12 +502,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // On cree le repertoire contenant les vignettes - $dirthumb = dirname($file).($outdir?'/'.$outdir:''); // Chemin du dossier contenant les vignettes + $dirthumb = dirname($file).($outdir ? '/'.$outdir : ''); // Chemin du dossier contenant les vignettes dol_mkdir($dirthumb); // Initialisation des variables selon l'extension de l'image - $img=null; - switch($infoImg[2]) + $img = null; + switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $img = imagecreatefromgif($filetoread); @@ -515,7 +515,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', break; case IMAGETYPE_JPEG: // 2 $img = imagecreatefromjpeg($filetoread); - $extImg = (preg_match('/\.jpeg$/', $file)?'.jpeg':'.jpg'); // Extension de l'image + $extImg = (preg_match('/\.jpeg$/', $file) ? '.jpeg' : '.jpg'); // Extension de l'image break; case IMAGETYPE_PNG: // 3 $img = imagecreatefrompng($filetoread); @@ -571,12 +571,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', imagealphablending($rotated, false); imagesavealpha($rotated, true); } - else{ + else { $rotated = imagerotate($img, $exifAngle, 0); } // replace image with good orientation - if(!empty($rotated)){ + if (!empty($rotated)) { $img = $rotated; $imgWidth = $trueImgWidth; $imgHeight = $trueImgHeight; @@ -584,14 +584,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Initialisation des dimensions de la vignette si elles sont superieures a l'original - if($maxWidth > $imgWidth){ $maxWidth = $imgWidth; } - if($maxHeight > $imgHeight){ $maxHeight = $imgHeight; } + if ($maxWidth > $imgWidth) { $maxWidth = $imgWidth; } + if ($maxHeight > $imgHeight) { $maxHeight = $imgHeight; } - $whFact = $maxWidth/$maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette - $imgWhFact = $imgWidth/$imgHeight; // Facteur largeur/hauteur de l'original + $whFact = $maxWidth / $maxHeight; // Facteur largeur/hauteur des dimensions max de la vignette + $imgWhFact = $imgWidth / $imgHeight; // Facteur largeur/hauteur de l'original // Fixe les dimensions de la vignette - if($whFact < $imgWhFact) + if ($whFact < $imgWhFact) { // Si largeur determinante $thumbWidth = $maxWidth; @@ -603,11 +603,11 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $thumbHeight = $maxHeight; $thumbWidth = $thumbHeight * $imgWhFact; } - $thumbHeight=round($thumbHeight); - $thumbWidth=round($thumbWidth); + $thumbHeight = round($thumbHeight); + $thumbWidth = round($thumbWidth); // Define target format - if (empty($targetformat)) $targetformat=$infoImg[2]; + if (empty($targetformat)) $targetformat = $infoImg[2]; // Create empty image if ($targetformat == IMAGETYPE_GIF) @@ -634,35 +634,35 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Initialisation des variables selon l'extension de l'image // $targetformat is 0 by default, in such case, we keep original extension - switch($targetformat) + switch ($targetformat) { case IMAGETYPE_GIF: // 1 $trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF imagecolortransparent($imgThumb, $trans_colour); $extImgTarget = '.gif'; - $newquality='NU'; + $newquality = 'NU'; break; case IMAGETYPE_JPEG: // 2 $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); - $extImgTarget = (preg_match('/\.jpeg$/i', $file)?'.jpeg':'.jpg'); - $newquality=$quality; + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg'); + $newquality = $quality; break; case IMAGETYPE_PNG: // 3 imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme - $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel + $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel $extImgTarget = '.png'; - $newquality=$quality-100; - $newquality=round(abs($quality-100)*9/100); + $newquality = $quality - 100; + $newquality = round(abs($quality - 100) * 9 / 100); break; case IMAGETYPE_BMP: // 6 // Not supported by PHP GD $extImgTarget = '.bmp'; - $newquality='NU'; + $newquality = 'NU'; break; case IMAGETYPE_WBMP: // 15 $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0); $extImgTarget = '.bmp'; - $newquality='NU'; + $newquality = 'NU'; break; } if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour); @@ -671,10 +671,10 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //imagecopyresized($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee imagecopyresampled($imgThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $imgWidth, $imgHeight); // Insere l'image de base redimensionnee - $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse + $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // On enleve extension quelquesoit la casse $fileName = basename($fileName); //$imgThumbName = $dirthumb.'/'.getImageFileNameForSize(basename($file), $extName, $extImgTarget); // Full path of thumb file - $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file + $imgThumbName = getImageFileNameForSize($file, $extName, $extImgTarget); // Full path of thumb file // Check if permission are ok @@ -682,7 +682,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', //fclose($fp); // Create image on disk - switch($targetformat) + switch ($targetformat) { case IMAGETYPE_GIF: // 1 imagegif($imgThumb, $imgThumbName); @@ -702,7 +702,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', } // Set permissions on file - if (! empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); + if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK)); // Free memory. This does not delete image. imagedestroy($img); diff --git a/htdocs/document.php b/htdocs/document.php index f196cb9eda9..c1ed149649e 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -32,24 +32,24 @@ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled cause need to load personalized language -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // For direct external download link, we don't need to load/check we are into a login session -if (isset($_GET["hashp"]) && ! defined("NOLOGIN")) +if (isset($_GET["hashp"]) && !defined("NOLOGIN")) { - if (! defined("NOLOGIN")) define("NOLOGIN", 1); - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - if (! defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip + if (!defined("NOLOGIN")) define("NOLOGIN", 1); + if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. + if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } // Some value of modulepart can be used to get resources that are public so no login are required. if ((isset($_GET["modulepart"]) && $_GET["modulepart"] == 'medias')) { - if (! defined("NOLOGIN")) define("NOLOGIN", 1); - if (! defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. - if (! defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip + if (!defined("NOLOGIN")) define("NOLOGIN", 1); + if (!defined("NOCSRFCHECK")) define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. + if (!defined("NOIPCHECK")) define("NOIPCHECK", 1); // Do not check IP defined into conf $dolibarr_main_restrict_ip } /** @@ -71,30 +71,30 @@ function llxFooter() { } -require 'main.inc.php'; // Load $user and permissions +require 'main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; $encoding = ''; -$action=GETPOST('action', 'alpha'); -$original_file=GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). -$hashp=GETPOST('hashp', 'aZ09'); -$modulepart=GETPOST('modulepart', 'alpha'); -$urlsource=GETPOST('urlsource', 'alpha'); -$entity=GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; +$action = GETPOST('action', 'alpha'); +$original_file = GETPOST('file', 'alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). +$hashp = GETPOST('hashp', 'aZ09'); +$modulepart = GETPOST('modulepart', 'alpha'); +$urlsource = GETPOST('urlsource', 'alpha'); +$entity = GETPOST('entity', 'int') ?GETPOST('entity', 'int') : $conf->entity; // Security check if (empty($modulepart) && empty($hashp)) accessforbidden('Bad link. Bad value for parameter modulepart', 0, 0, 1); if (empty($original_file) && empty($hashp)) accessforbidden('Bad link. Missing identification to find file (original_file or hashp)', 0, 0, 1); -if ($modulepart == 'fckeditor') $modulepart='medias'; // For backward compatibility +if ($modulepart == 'fckeditor') $modulepart = 'medias'; // For backward compatibility -$socid=0; +$socid = 0; if ($user->socid > 0) $socid = $user->socid; // For some module part, dir may be privates -if (in_array($modulepart, array('facture_paiement','unpaid'))) +if (in_array($modulepart, array('facture_paiement', 'unpaid'))) { - if (! $user->rights->societe->client->voir || $socid) $original_file='private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user + if (!$user->rights->societe->client->voir || $socid) $original_file = 'private/'.$user->id.'/'.$original_file; // If user has no permission to see all, output dir is specific to user } @@ -111,27 +111,27 @@ if (in_array($modulepart, array('facture_paiement','unpaid'))) */ // If we have a hash public (hashp), we guess the original_file. -if (! empty($hashp)) +if (!empty($hashp)) { include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php'; - $ecmfile=new EcmFiles($db); + $ecmfile = new EcmFiles($db); $result = $ecmfile->fetch(0, '', '', '', $hashp); if ($result > 0) { - $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory + $tmp = explode('/', $ecmfile->filepath, 2); // $ecmfile->filepath is relative to document directory // filepath can be 'users/X' or 'X/propale/PR11111' if (is_numeric($tmp[0])) // If first tmp is numeric, it is subdir of company for multicompany, we take next part. { $tmp = explode('/', $tmp[1], 2); } - $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path + $moduleparttocheck = $tmp[0]; // moduleparttocheck is first part of path if ($modulepart) // Not required, so often not defined, for link using public hashp parameter. { if ($moduleparttocheck == $modulepart) { // We remove first level of directory - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir + $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir //var_dump($original_file); exit; } else @@ -142,7 +142,7 @@ if (! empty($hashp)) else { $modulepart = $moduleparttocheck; - $original_file = (($tmp[1]?$tmp[1].'/':'').$ecmfile->filename); // this is relative to module dir + $original_file = (($tmp[1] ? $tmp[1].'/' : '').$ecmfile->filename); // this is relative to module dir } } else @@ -155,13 +155,13 @@ if (! empty($hashp)) // Define attachment (attachment=true to force choice popup 'open'/'save as') $attachment = true; if (preg_match('/\.(html|htm)$/i', $original_file)) $attachment = false; -if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha')?true:false; -if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false; +if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha') ?true:false; +if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false; // Define mime type $type = 'application/octet-stream'; -if (GETPOST('type', 'alpha')) $type=GETPOST('type', 'alpha'); -else $type=dol_mimetype($original_file); +if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha'); +else $type = dol_mimetype($original_file); // Security: Force to octet-stream if file is a dangerous file if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream'; @@ -169,7 +169,7 @@ if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream $original_file = str_replace("../", "/", $original_file); // Find the subdirectory name as the reference -$refname=basename(dirname($original_file)."/"); +$refname = basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); @@ -178,11 +178,11 @@ if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart'); $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; -$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name +$fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name -if (! empty($hashp)) +if (!empty($hashp)) { - $accessallowed = 1; // When using hashp, link is public so we force $accessallowed + $accessallowed = 1; // When using hashp, link is public so we force $accessallowed $sqlprotectagainstexternals = ''; } else @@ -195,14 +195,14 @@ else $resql = $db->query($sqlprotectagainstexternals); if ($resql) { - $num=$db->num_rows($resql); - $i=0; + $num = $db->num_rows($resql); + $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); if ($user->socid != $obj->fk_soc) { - $accessallowed=0; + $accessallowed = 0; break; } $i++; @@ -214,7 +214,7 @@ else // Security: // Limit access if permissions are wrong -if (! $accessallowed) +if (!$accessallowed) { accessforbidden(); } @@ -236,10 +236,10 @@ $filename = preg_replace('/\.noexe$/i', '', $filename); // Output file on browser dol_syslog("document.php download $fullpath_original_file filename=$filename content-type=$type"); -$fullpath_original_file_osencoded=dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset +$fullpath_original_file_osencoded = dol_osencode($fullpath_original_file); // New file name encoded in OS encoding charset // This test if file exists should be useless. We keep it to find bug more easily -if (! file_exists($fullpath_original_file_osencoded)) +if (!file_exists($fullpath_original_file_osencoded)) { dol_syslog("ErrorFileDoesNotExists: ".$fullpath_original_file); print "ErrorFileDoesNotExists: ".$original_file; @@ -264,8 +264,8 @@ if (!$attachment && !empty($conf->global->MAIN_USE_EXIF_ROTATION) && image_forma $readfile = !$imgres; } -if($readfile){ - header('Content-Length: ' . dol_filesize($fullpath_original_file)); +if ($readfile) { + header('Content-Length: '.dol_filesize($fullpath_original_file)); readfile($fullpath_original_file_osencoded); } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 05cc5752777..9a17a754dc1 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -488,7 +488,7 @@ if ($resql) { $oldtype = $type; $params = array(); - if ($type === "") $params['forcenohideoftext']=1; + if ($type === "") $params['forcenohideoftext'] = 1; if ($type === "") { $newcardbutton .= dolGetButtonTitle($langs->trans('NewProduct'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', 1, $params); $type = Product::TYPE_SERVICE; @@ -853,7 +853,7 @@ if ($resql) $product_static->id = $obj->rowid; $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; // deprecated + $product_static->ref_fourn = $obj->ref_supplier; // deprecated $product_static->ref_supplier = $obj->ref_supplier; $product_static->label = $obj->label; $product_static->type = $obj->fk_product_type; @@ -886,7 +886,7 @@ if ($resql) { $option = 'nobatch'; if (empty($arrayfields['stock_virtual']['checked'])) $option .= ',novirtual'; - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } } From 69990d96a6afafd9b40444c9e4b0be049aa1c1bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 09:53:42 +0100 Subject: [PATCH 189/248] CSS --- htdocs/theme/eldy/theme_vars.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index 372c4aaba90..e59d8e3f81a 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -67,7 +67,7 @@ $colorbacklinepairhover = '230,237,244'; // line hover $colorbacklinepairchecked = '230,237,244'; // line checked $colorbacklinebreak = '233,228,230'; // line break $colorbackbody = '255,255,255'; -$colortexttitlenotab = '140,80,10'; // 140,80,10 or 10,140,80 +$colortexttitlenotab = '0,103,111'; // 140,80,10 or 10,140,80 $colortexttitle = '0,0,0'; $colortext = '0,0,0'; $colortextlink = '10, 20, 100'; @@ -108,7 +108,7 @@ $badgeStatus0 = '#cbd3d3'; $badgeStatus1 = '#bc9526'; $badgeStatus2 = '#e6f0f0'; $badgeStatus3 = '#bca52b'; -$badgeStatus4 = '#277d1e'; +$badgeStatus4 = '#759580'; $badgeStatus5 = '#cad2d2'; $badgeStatus6 = '#cad2d2'; $badgeStatus7 = '#baa32b'; From 02e2b721909ddb5fb037ae07ec20539fcbbe1e05 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 10:46:14 +0100 Subject: [PATCH 190/248] Use , as separator instead of / for type of third party. This reduce space used. --- htdocs/societe/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ba01b901f9f..828cb4c703b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1030,7 +1030,7 @@ while ($i < min($num, $limit)) print ' 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + $place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Bar or Restaurant print ' onclick="location.href=\'list.php?action=change&contextpage=poslist&idcustomer='.$obj->rowid.'&place='.$place.'\'"'; } print '>'; @@ -1220,14 +1220,14 @@ while ($i < min($num, $limit)) } if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { - if ($s) $s .= " / "; + if ($s) $s .= ", "; $companystatic->name = $langs->trans("Prospect"); $companystatic->name_alias = ''; $s .= $companystatic->getNomUrl(0, 'prospect', 0, 1); } if ((!empty($conf->fournisseur->enabled) || !empty($conf->supplier_proposal->enabled)) && $obj->fournisseur) { - if ($s) $s .= " / "; + if ($s) $s .= ", "; $companystatic->name = $langs->trans("Supplier"); $companystatic->name_alias = ''; $s .= $companystatic->getNomUrl(0, 'supplier', 0, 1); From eae021cd6bd26faf3530b66d768dbe0085b1f775 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 12:42:05 +0100 Subject: [PATCH 191/248] CSS --- htdocs/theme/eldy/global.inc.php | 5 +++++ htdocs/theme/md/style.css.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 91cedc4b172..d6c4d30496e 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -4017,6 +4017,11 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; } .calendarviewcontainertr { height: 100px; } +td.cal_other_month { + opacity: 0.8; +} + + /* ============================================================================== */ /* Ajax - Liste deroulante de l'autocompletion */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 02e819496c4..08baeb664a2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4156,6 +4156,11 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; } background-size: 24px auto; } +td.cal_other_month { + opacity: 0.8; +} + + /* ============================================================================== */ /* Ajax - Liste deroulante de l'autocompletion */ /* ============================================================================== */ From 6227d14cf3e501f4784e30b6e5ac23cf220465db Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Fri, 6 Dec 2019 13:48:24 +0100 Subject: [PATCH 192/248] NEW 10.0: link to template of origin in bill cards for bills created from a template --- htdocs/compta/facture/card.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9cb76a2f292..d320105ae2a 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3817,9 +3817,14 @@ elseif ($id > 0 || ! empty($ref)) if ($object->fk_fac_rec_source > 0) { - $tmptemplate = new FactureRec($db); - $result = $tmptemplate->fetch($object->fk_fac_rec_source); - if ($result > 0) print '. '.$langs->trans("GeneratedFromTemplate", $tmptemplate->ref); + $tmptemplate = new FactureRec($db); + $result = $tmptemplate->fetch($object->fk_fac_rec_source); + if ($result > 0) { + print '. '.$langs->trans( + "GeneratedFromTemplate", + ''.$tmptemplate->ref.'' + ); + } } print ''; From 796f34628dda99fbb757f141e34966555a549593 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 17:40:22 +0100 Subject: [PATCH 193/248] Debug v11 --- htdocs/comm/remx.php | 56 ++++++++++++++++----------- htdocs/core/class/html.form.class.php | 4 +- htdocs/core/lib/functions.lib.php | 2 +- htdocs/theme/eldy/theme_vars.inc.php | 2 +- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index e5f84bbec77..59c28cfb4ea 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -252,7 +252,7 @@ if ($socid > 0) print ''; print ''; - dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'absolutediscount', $langs->trans("ThirdParty"), -1, 'company'); dol_banner_tab($object, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); @@ -273,7 +273,7 @@ if ($socid > 0) } - print ''; + print '
'; if ($isCustomer) { // Calcul avoirs client en cours $remise_all = $remise_user = 0; @@ -342,13 +342,15 @@ if ($socid > 0) print ''; + dol_fiche_end(); + + if ($user->rights->societe->creer) { print '
'; print load_fiche_titre($langs->trans("NewGlobalDiscount"), '', ''); - print '
'; if ($isCustomer && !$isSupplier) { print ''; @@ -358,6 +360,8 @@ if ($socid > 0) print ''; } + dol_fiche_head(); + print '
'; if ($isCustomer && $isSupplier) { print ''; @@ -376,9 +380,9 @@ if ($socid > 0) print ''; print "
'.$langs->trans('DiscountType').'
"; - } - dol_fiche_end(); + dol_fiche_end(); + } if ($user->rights->societe->creer) { @@ -404,7 +408,7 @@ if ($socid > 0) /* - * Liste remises fixes client restant en cours (= liees a aucune facture ni ligne de facture) + * List remises fixes client restant en cours (= liees a aucune facture ni ligne de facture) */ print load_fiche_titre($langs->trans("DiscountStillRemaining")); @@ -511,15 +515,14 @@ if ($socid > 0) { print ''.price($obj->multicurrency_amount_ttc).''; } - print ''; + print ''; print ''.img_object($langs->trans("ShowUser"), 'user').' '.$obj->login.''; print ''; if ($user->rights->societe->creer || $user->rights->facture->creer) { - print ''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; - //print '   '; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print ''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ''; } else print ' '; @@ -535,7 +538,9 @@ if ($socid > 0) } else { - print ''.$langs->trans("None").''; + $colspan = 8; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; + print ''.$langs->trans("None").''; } $db->free($resql); print ""; @@ -551,7 +556,7 @@ if ($socid > 0) array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, '', 0); } } else @@ -672,9 +677,8 @@ if ($socid > 0) if ($user->rights->societe->creer || $user->rights->facture->creer) { print ''; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; - //print '   '; - print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_split($langs->trans("SplitDiscount")).''; + print 'rowid.($backtopage ? '&backtopage='.urlencode($backtopage) : '').'">'.img_delete($langs->trans("RemoveDiscount")).''; print ''; } else print ' '; @@ -690,7 +694,9 @@ if ($socid > 0) } else { - print ''.$langs->trans("None").''; + $colspan = 8; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; + print ''.$langs->trans("None").''; } $db->free($resql); print ""; @@ -701,9 +707,9 @@ if ($socid > 0) $amount1 = price2num($showconfirminfo['amount_ttc'] / 2, 'MT'); $amount2 = ($showconfirminfo['amount_ttc'] - $amount1); $formquestion = array( - 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), - array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), - array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') + 'text' => $langs->trans('TypeAmountOfEachNewDiscount'), + array('type' => 'text', 'name' => 'amount_ttc_1', 'label' => $langs->trans("AmountTTC").' 1', 'value' => $amount1, 'size' => '5'), + array('type' => 'text', 'name' => 'amount_ttc_2', 'label' => $langs->trans("AmountTTC").' 2', 'value' => $amount2, 'size' => '5') ); $langs->load("dict"); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&remid='.$showconfirminfo['rowid'].($backtopage ? '&backtopage='.urlencode($backtopage) : ''), $langs->trans('SplitDiscount'), $langs->trans('ConfirmSplitDiscount', price($showconfirminfo['amount_ttc']), $langs->transnoentities("Currency".$conf->currency)), 'confirm_split', $formquestion, 0, 0); @@ -738,7 +744,7 @@ if ($socid > 0) // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql .= " rc.fk_facture_source,"; + $sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,"; $sql .= " u.login, u.rowid as user_id,"; $sql .= " f.rowid as invoiceid, f.ref,"; $sql .= " fa.ref as invoice_source_ref, fa.type as type"; @@ -890,7 +896,9 @@ if ($socid > 0) } else { - print ''.$langs->trans("None").''; + $colspan = 8; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; + print ''.$langs->trans("None").''; } print ""; @@ -1064,7 +1072,9 @@ if ($socid > 0) } else { - print ''.$langs->trans("None").''; + $colspan = 8; + if (!empty($conf->multicurrency->enabled)) $colspan+=2; + print ''.$langs->trans("None").''; } print ""; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 23d7e88b45b..57b29e78647 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4117,7 +4117,9 @@ class Form // Now add questions $more .= '
'."\n"; - if (!empty($formquestion['text'])) $more .= ''.$formquestion['text'].''."\n"; + if (!empty($formquestion['text'])) { + $more .= '
'.$formquestion['text'].'
'."\n"; + } foreach ($formquestion as $key => $input) { if (is_array($input) && !empty($input)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 59037d18525..6306162af34 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3081,7 +3081,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'address'=> 'address-book', 'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins', 'accountancy'=>'money-check-alt', 'project'=>'sitemap', 'hrm'=>'umbrella-beach', 'members'=>'users', 'ticket'=>'ticket-alt', 'generic'=>'folder-open', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'object_bookmark'=>'star', 'bookmark'=>'star', 'stats' => 'chart-bar', - 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-fork', + 'bank'=>'university', 'close_title'=>'window-close', 'delete'=>'trash', 'edit'=>'pencil', 'filter'=>'filter', 'split'=>'code-branch', 'object_list'=>'list-alt', 'object_calendar'=>'calendar-alt', 'object_calendarweek'=>'calendar-week', 'object_calendarmonth'=>'calendar-alt', 'object_calendarday'=>'calendar-day', 'object_calendarperuser'=>'table', 'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach', 'title_agenda'=>'calendar-alt' diff --git a/htdocs/theme/eldy/theme_vars.inc.php b/htdocs/theme/eldy/theme_vars.inc.php index e59d8e3f81a..5f7c8f60233 100644 --- a/htdocs/theme/eldy/theme_vars.inc.php +++ b/htdocs/theme/eldy/theme_vars.inc.php @@ -108,7 +108,7 @@ $badgeStatus0 = '#cbd3d3'; $badgeStatus1 = '#bc9526'; $badgeStatus2 = '#e6f0f0'; $badgeStatus3 = '#bca52b'; -$badgeStatus4 = '#759580'; +$badgeStatus4 = '#55a590'; $badgeStatus5 = '#cad2d2'; $badgeStatus6 = '#cad2d2'; $badgeStatus7 = '#baa32b'; From 4d489f64b0999c5dff91ae9772d6f5d5ad7a4a96 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 17:42:09 +0100 Subject: [PATCH 194/248] Fix getpost --- htdocs/comm/remx.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 59c28cfb4ea..70f9846bd6b 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -61,9 +61,9 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ttc_1 = GETPOST('amount_ttc_1'); + $amount_ttc_1 = GETPOST('amount_ttc_1', 'alpha'); $amount_ttc_1 = price2num($amount_ttc_1); - $amount_ttc_2 = GETPOST('amount_ttc_2'); + $amount_ttc_2 = GETPOST('amount_ttc_2', 'alpha'); $amount_ttc_2 = price2num($amount_ttc_2); $error = 0; From 6366a2a60656b16bbbd508af41d2a68f11906d24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 6 Dec 2019 18:05:16 +0100 Subject: [PATCH 195/248] doxygen --- htdocs/user/class/user.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index f2f6bc00d1f..ffb8c15e3c3 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1800,10 +1800,10 @@ class User extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Mise a jour en base de la date de derniere connexion d'un utilisateur - * Fonction appelee lors d'une nouvelle connexion + * Mise a jour en base de la date de derniere connexion d'un utilisateur + * Fonction appelee lors d'une nouvelle connexion * - * @return <0 si echec, >=0 si ok + * @return int <0 si echec, >=0 si ok */ public function update_last_login_date() { @@ -2267,7 +2267,6 @@ class User extends CommonObject } else { - $this->error = $interface->error; dol_syslog(get_class($this)."::RemoveFromGroup ".$this->error, LOG_ERR); $this->db->rollback(); return -2; From ed4f04f90a8dab5371e1aa2c656e9457c8d4bcff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Dec 2019 18:41:22 +0100 Subject: [PATCH 196/248] Fix a supplier ref is mandatory for import --- htdocs/core/modules/modProduct.class.php | 2 +- htdocs/core/modules/modService.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index b15bd41f9bb..db20bf3b2ff 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -594,7 +594,7 @@ class modProduct extends DolibarrModules $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", - 'sp.ref_fourn' => 'SupplierRef', + 'sp.ref_fourn' => 'SupplierRef*', 'sp.quantity' => "QtyMin*", 'sp.tva_tx' => 'VATRate', 'sp.default_vat_code' => 'VATCode', diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 379799a0ac6..4fb5cb175b0 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -563,7 +563,7 @@ class modService extends DolibarrModules $this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields 'sp.fk_product'=>"ProductOrService*", 'sp.fk_soc' => "Supplier*", - 'sp.ref_fourn' => 'SupplierRef', + 'sp.ref_fourn' => 'SupplierRef*', 'sp.quantity' => "QtyMin*", 'sp.tva_tx' => 'VATRate', 'sp.default_vat_code' => 'VATCode', From 8138fa978070fef67d817054b04ef2a99de5382f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 11:51:21 +0100 Subject: [PATCH 197/248] Missing X-Content-Type-Options: nosniff on header of website pages --- htdocs/core/lib/website.lib.php | 9 +++++++-- htdocs/core/website.inc.php | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 02c5cf8dcf7..f97c6efed1c 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -384,12 +384,13 @@ function dolWebsiteSaveContent($content) /** * Make a redirect to another container. * - * @param string $containerref Ref of container to redirect to (must be a page from website root. Example: 'mypage.php' means 'mywebsite/mypage.php'). + * @param string $containerref Ref of container to redirect to (Example: 'mypage' or 'mypage.php'). * @param string $containeraliasalt Ref of alternative aliases to redirect to. * @param int $containerid Id of container. + * @param int $permanent 0=Use temporary redirect 302, 1=Use permanent redirect 301 * @return void */ -function redirectToContainer($containerref, $containeraliasalt = '', $containerid = 0) +function redirectToContainer($containerref, $containeraliasalt = '', $containerid = 0, $permanent = 0) { global $db, $website; @@ -436,6 +437,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri if ($result > 0) { $currenturi = $_SERVER["REQUEST_URI"]; + $regtmp = array(); if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) { if ($regtmp[0] == $containerref) @@ -461,6 +463,9 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri if ($newurl) { + if ($permanent) { + header("Status: 301 Moved Permanently", false, 301); + } header("Location: ".$newurl); exit; } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 34c011c34ca..2cc046ac818 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -61,6 +61,10 @@ if ($pageid > 0) } } +if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { + header("X-Content-Type-Options: nosniff"); +} + // A lang was forced, so we change weblangs init if (GETPOST('l', 'aZ09')) $weblangs->setDefaultLang(GETPOST('l', 'aZ09')); // A lang was forced, so we check to find if we must make a redirect on translation page From 3030a9fa2a3c68ab666d33204cfdf21ef193c196 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 13:09:55 +0100 Subject: [PATCH 198/248] Fix manifest file was saved but not enabled. --- htdocs/core/lib/website2.lib.php | 14 +++++++++++++- htdocs/install/mysql/migration/10.0.0-11.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_website.sql | 3 ++- htdocs/website/class/website.class.php | 8 ++++++++ htdocs/website/class/websitepage.class.php | 4 ++++ htdocs/website/index.php | 4 ++-- 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index ff83d9136aa..2b3e20f1895 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -86,7 +86,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) * @param WebsitePage $objectpage Object websitepage * @return boolean True if OK */ -function dolSavePageContent($filetpl, $object, $objectpage) +function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) { global $conf; @@ -122,7 +122,19 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; + // Add translation reference (main language) + $translationof = $objectpage->fk_page; + if ($translationof) { + $tmppage = new WebsitePage($db); + $tmppage->fetch($translationof); + if ($tmppage->id > 0) { + $tplcontent .= ''."\n"; + } + } + // Add canonical reference $tplcontent .= ''."\n"; + // Add manifest.json on homepage + $tplcontent .= 'use_manifest) { print \'\'."\n"; } ?>'."\n"; $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 340b3720dd7..b4d956129a7 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -539,3 +539,5 @@ ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement F ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo); ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_ref(ref, entity); + +ALTER TABLE llx_website ADD COLUMN use_manifest integer; diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index b5764565a34..645343544a4 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -27,7 +27,8 @@ CREATE TABLE llx_website maincolor varchar(16), maincolorbis varchar(16), status integer DEFAULT 1, - fk_default_home integer, + fk_default_home integer, + use_manifest integer, virtualhost varchar(255), fk_user_creat integer, fk_user_modif integer, diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index de8c947512d..f45298e082a 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -96,6 +96,11 @@ class Website extends CommonObject */ public $virtualhost; + /** + * @var int + */ + public $use_manifest; + /** * List of containers * @@ -237,6 +242,7 @@ class Website extends CommonObject $sql .= " t.description,"; $sql .= " t.status,"; $sql .= " t.fk_default_home,"; + $sql .= " t.use_manifest,"; $sql .= " t.virtualhost,"; $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; @@ -264,6 +270,7 @@ class Website extends CommonObject $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; + $this->use_manifest = $obj->use_manifest; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -425,6 +432,7 @@ class Website extends CommonObject $sql .= ' description = '.(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").','; $sql .= ' status = '.(isset($this->status) ? $this->status : "null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0) ? $this->fk_default_home : "null").','; + $sql .= ' use_manifest = '.((int) $this->use_manifest).','; $sql .= ' virtualhost = '.(($this->virtualhost != '') ? "'".$this->db->escape($this->virtualhost)."'" : "null").','; $sql .= ' fk_user_modif = '.(!isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; $sql .= ' date_creation = '.(!isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index b6371c14df7..abdb8d323eb 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -74,6 +74,10 @@ class WebsitePage extends CommonObject * @var string keywords */ public $keywords; + /** + * @var string language code ('en', 'fr', 'en-gb', ..) + */ + public $lang; public $htmlheader; public $content; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1d94eadf626..df479f0cd36 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1059,6 +1059,7 @@ if ($action == 'updatecss') if (!$error) { $object->virtualhost = GETPOST('virtualhost', 'alpha'); + $object->use_manifest = GETPOST('use_manifest', 'alpha'); $result = $object->update($user); if ($result < 0) @@ -2738,10 +2739,9 @@ if ($action == 'editcss') $htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); print $form->textwithpicto($langs->trans('WEBSITE_MANIFEST_JSON'), $htmlhelp, 1, 'help', '', 0, 2, 'manifestjsontooltip'); print ''; - + print $langs->trans("UseManifest").': '.$form->selectyesno('use_manifest', $website->use_manifest, 1).'
'; $doleditor = new DolEditor('WEBSITE_MANIFEST_JSON', $manifestjsoncontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); print $doleditor->Create(1, '', true, $langs->trans("File").' manifest.json', 'text'); - print ''; // README.md From a2da98c08ae528591cbaf838771b423096167d51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 13:19:12 +0100 Subject: [PATCH 199/248] Fix $db not defined --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 2b3e20f1895..25159253e19 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -88,7 +88,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) */ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) { - global $conf; + global $conf, $db; // Now create the .tpl file (duplicate code with actions updatesource or updatecontent but we need this to save new header) dol_syslog("We regenerate the tpl page filetpl=".$filetpl); From 7f23c5f74eb3aabbea3aa7dab193c39e18037ca0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 13:21:11 +0100 Subject: [PATCH 200/248] Fix link for alternate language --- htdocs/core/lib/website2.lib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 25159253e19..7ff7c405bec 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -128,7 +128,9 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) $tmppage = new WebsitePage($db); $tmppage->fetch($translationof); if ($tmppage->id > 0) { - $tplcontent .= ''."\n"; + $tmpshortlangcode = ''; + if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en + $tplcontent .= ''."\n"; } } // Add canonical reference From ff05150f7eaa1b837fea80daf813e3a36ba9aa2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 13:25:59 +0100 Subject: [PATCH 201/248] Fix link for alternate language --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 7ff7c405bec..5b482e01bfd 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -130,7 +130,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) if ($tmppage->id > 0) { $tmpshortlangcode = ''; if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; } } // Add canonical reference From 3f0fd9b82ad1ec3cebe174adfb0d2ca0aa212f5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 13:36:37 +0100 Subject: [PATCH 202/248] Fix url --- htdocs/core/lib/website2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 5b482e01bfd..bb7217c8df5 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -130,7 +130,7 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) if ($tmppage->id > 0) { $tmpshortlangcode = ''; if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en - $tplcontent .= ''."\n"; + $tplcontent .= ''."\n"; } } // Add canonical reference From f93e11468861363787a33bd22a6539daaf36904c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 7 Dec 2019 15:37:15 +0100 Subject: [PATCH 203/248] do not trim int --- htdocs/don/class/paymentdonation.class.php | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index d38e19e62f5..5e7a2fdad6f 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -121,14 +121,14 @@ class PaymentDonation extends CommonObject } // Clean parameters - if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation); + if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation; if (isset($this->amount)) $this->amount=trim($this->amount); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); - if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); - if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; $totalamount = 0; foreach ($this->amounts as $key => $value) // How payment is dispatch @@ -275,14 +275,14 @@ class PaymentDonation extends CommonObject // Clean parameters - if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation); + if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation; if (isset($this->amount)) $this->amount=trim($this->amount); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->note_public)) $this->note_public=trim($this->note_public); - if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); - if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat); - if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; // Check parameters // Put here code to add control on parameters values @@ -306,7 +306,10 @@ class PaymentDonation extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } if (! $error) { @@ -609,7 +612,7 @@ class PaymentDonation extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".(int) $this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); From f379f510fa797f53684a7001f87bbcbfa7c116d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 7 Dec 2019 15:44:13 +0100 Subject: [PATCH 204/248] Update paymentdonation.class.php --- htdocs/don/class/paymentdonation.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 5e7a2fdad6f..22b75cd777b 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -300,7 +300,7 @@ class PaymentDonation extends CommonObject $sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").","; $sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").","; $sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null").""; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid=".(int) $this->id; $this->db->begin(); @@ -361,7 +361,7 @@ class PaymentDonation extends CommonObject if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_donation' AND url_id=".$this->id; + $sql.= " WHERE type='payment_donation' AND url_id=".(int) $this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); @@ -375,7 +375,10 @@ class PaymentDonation extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } } if (! $error) @@ -612,7 +615,7 @@ class PaymentDonation extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".(int) $this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".(int) $id_bank." WHERE rowid = ".(int) $this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); From 0e063a3bb328ac86907f3cac15bac318a920e83c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 15:46:14 +0100 Subject: [PATCH 205/248] Fix hreflang tag (must include itself) --- htdocs/core/lib/website2.lib.php | 19 +++++++++++-------- htdocs/core/website.inc.php | 5 +++++ htdocs/main.inc.php | 2 +- htdocs/website/class/website.class.php | 12 ++++++++++++ htdocs/website/index.php | 2 +- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index bb7217c8df5..48ef724e4dc 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -123,14 +123,17 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; // Add translation reference (main language) - $translationof = $objectpage->fk_page; - if ($translationof) { - $tmppage = new WebsitePage($db); - $tmppage->fetch($translationof); - if ($tmppage->id > 0) { - $tmpshortlangcode = ''; - if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en - $tplcontent .= ''."\n"; + if ($object->isMultiLang()) { + $tplcontent .= ''."\n"; + $translationof = $objectpage->fk_page; + if ($translationof) { + $tmppage = new WebsitePage($db); + $tmppage->fetch($translationof); + if ($tmppage->id > 0) { + $tmpshortlangcode = ''; + if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en + $tplcontent .= ''."\n"; + } } } // Add canonical reference diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 2cc046ac818..fc6fa02cbec 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -63,6 +63,11 @@ if ($pageid > 0) if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { header("X-Content-Type-Options: nosniff"); + /* TODO Manage allow_frames flag on websitepage. + if (empty($websitepage->allow_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) { + header("X-Frame-Options: SAMEORIGIN"); + } + */ } // A lang was forced, so we change weblangs init diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index eae61993dd6..4824ced47db 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1137,7 +1137,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on) if (!defined('XFRAMEOPTIONS_ALLOWALL')) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks) else header("X-Frame-Options: ALLOWALL"); - //header("X-XSS-Protection: 1"); // XSS protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated. + //header("X-XSS-Protection: 1"); // XSS filtering protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated. if (!defined('FORCECSP')) { //if (! isset($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY)) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index f45298e082a..5c2bf40aa03 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1161,6 +1161,18 @@ class Website extends CommonObject } } + /** + * Return if web site is a multilanguage web site. Return false if there is only 0 or 1 language. + * + * @return boolean True if web site is a multilanguage web site + */ + public function isMultiLang() + { + // TODO Can edit list of languages of web site. Return false if there is only 0 or 1 language. + + return true; + } + /** * Component to select language inside a container (Full CSS Only) * diff --git a/htdocs/website/index.php b/htdocs/website/index.php index df479f0cd36..3d0d7f25871 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -25,7 +25,7 @@ define('NOSCANPOSTFORINJECTION', 1); define('NOSTYLECHECK', 1); define('USEDOLIBARREDITOR', 1); -header('X-XSS-Protection:0'); +//header('X-XSS-Protection:0'); // Disable XSS filtering protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated. require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; From d58a6a7d9a5f31bd6397955645ba47d89e487a4e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 16:59:35 +0100 Subject: [PATCH 206/248] Fix hreflang is more complete --- htdocs/core/lib/website2.lib.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 48ef724e4dc..2ef48e94bda 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -124,7 +124,9 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) $tplcontent .= ''."\n"; // Add translation reference (main language) if ($object->isMultiLang()) { + // Add myself $tplcontent .= ''."\n"; + // Add page "translation of" $translationof = $objectpage->fk_page; if ($translationof) { $tmppage = new WebsitePage($db); @@ -132,9 +134,30 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) if ($tmppage->id > 0) { $tmpshortlangcode = ''; if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en - $tplcontent .= ''."\n"; + if ($tmpshortlangcode != $shortlangcode) { + $tplcontent .= ''."\n"; + } } } + // Add "has translation pages" + $sql = 'SELECT rowid as id, lang, pageurl from '.MAIN_DB_PREFIX.'website_page where fk_page IN ('.$objectpage->id.($translationof ? ", ".$translationof : "").")"; + $resql = $db->query($sql); + if ($resql) + { + $num_rows = $db->num_rows($resql); + if ($num_rows > 0) + { + while ($obj = $db->fetch_object($resql)) + { + $tmpshortlangcode = ''; + if ($obj->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $obj->lang); // en_US or en-US -> en + if ($tmpshortlangcode != $shortlangcode) { + $tplcontent .= ''."\n"; + } + } + } + } + else dol_print_error($db); } // Add canonical reference $tplcontent .= ''."\n"; From 4d3ed4ffd39ef5aa75e854ebe563908eef5ff848 Mon Sep 17 00:00:00 2001 From: ATM John BOTELLA Date: Sat, 7 Dec 2019 17:41:13 +0100 Subject: [PATCH 207/248] Fix dolGetBadge class --- htdocs/core/lib/functions.lib.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6306162af34..7530b9a7fc5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -8132,7 +8132,7 @@ function roundUpToNextMultiple($n, $x = 5) function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array()) { $attr = array( - 'class'=>'badge badge-status'.(!empty($mode) ? ' badge-'.$mode : '').(!empty($type) ? ' badge-'.$type : '').(empty($params['css']) ? '' : ' '.$params['css']) + 'class'=>'badge '.(!empty($mode) ? ' badge-'.$mode : '').(!empty($type) ? ' badge-'.$type : '').(empty($params['css']) ? '' : ' '.$params['css']) ); if (empty($html)) { @@ -8153,7 +8153,15 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = ' // Override attr if (!empty($params['attr']) && is_array($params['attr'])) { foreach ($params['attr']as $key => $value) { - $attr[$key] = $value; + if ($key == 'class') { + $attr['class'] .= ' '.$value; + } + elseif ($key == 'classOverride') { + $attr['class'] = $value; + } + else { + $attr[$key] = $value; + } } } @@ -8260,6 +8268,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st elseif (empty($conf->global->MAIN_STATUS_USES_IMAGES) && !empty($displayMode)) { $statusLabelShort = !empty($statusLabelShort) ? $statusLabelShort : $statusLabel; + $dolGetBadgeParams['attr']['class'] = 'badge-status'; + if ($displayMode == 3) { $return = dolGetBadge($statusLabel, '', $statusType, 'dot', $url, $dolGetBadgeParams); } From f35577d79245c4fd96651506a40af3aaeefb8215 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 19:08:40 +0100 Subject: [PATCH 208/248] Fix backtopage link --- htdocs/website/index.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 3d0d7f25871..a175d6f48fd 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2445,7 +2445,7 @@ if (!GETPOST('hide_websitemenu')) { if (preg_match('/^create/', $action)) print ''; if (preg_match('/^edit/', $action)) print ''; - if ($action != 'preview') print ''; + if ($action != 'preview') print ''; } print ''; // end websitetools @@ -3343,6 +3343,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''.$langs->trans("Type").''; print ''.$langs->trans("Link").''; print ''.$langs->trans("Description").''; + print ''; print ''; foreach ($listofpages['list'] as $answerrecord) @@ -3357,7 +3358,20 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print $answerrecord->getNomUrl(1); print ' ('.($answerrecord->title ? $answerrecord->title : $langs->trans("NoTitle")).')'; print ''; - print ''.$answerrecord->description; + print ''.$answerrecord->description.''; + print ''; + $param = '?action=replacesiteconfirm'; + $param .= '&optioncontent='.GETPOST('optioncontent'); + $param .= '&optionmeta='.GETPOST('optionmeta'); + $param .= '&optionsitefiles='.GETPOST('optionsitefiles'); + $param .= '&searchstring='.$searchkey; + $disabled = ''; + $urltoedithtmlsource = $_SERVER["PHP_SELF"].'?action=editsource&websiteid='.$website->id.'&pageid='.$answerrecord->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].$param); + if (empty($user->rights->website->write)) { + $disabled = ' disabled'; + $urltoedithtmlsource = ''; + } + print ''.$langs->trans("EditHTMLSource").''; print ''; print ''; } @@ -3387,6 +3401,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') print ''; print ''; print ''; + print ''; print ''; } } From dbbe40ca3d5c3c9ae4b9a4047096ab416bb3e246 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 7 Dec 2019 19:09:45 +0100 Subject: [PATCH 209/248] Fix link --- 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 a175d6f48fd..105b332dd63 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -3371,7 +3371,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') $disabled = ' disabled'; $urltoedithtmlsource = ''; } - print ''.$langs->trans("EditHTMLSource").''; + print ''.$langs->trans("EditHTMLSource").''; print ''; print ''; } From 72c30c4101f95dde8636d7c7be4146a2889217b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 7 Dec 2019 23:39:09 +0100 Subject: [PATCH 210/248] Update server_order.php --- htdocs/webservices/server_order.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 4f1a2bf64e2..59ccbc29df0 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -444,10 +444,10 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') 'total' => $order->total_ttc, 'project_id' => $order->fk_project, - 'date' => $order->date_commande ?dol_print_date($order->date_commande, 'dayrfc') : '', - 'date_creation' => $invoice->date_creation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '', - 'date_validation' => $invoice->date_validation ?dol_print_date($invoice->date_creation, 'dayhourrfc') : '', - 'date_modification' => $invoice->datem ?dol_print_date($invoice->datem, 'dayhourrfc') : '', + 'date' => $order->date ?dol_print_date($order->date, 'dayrfc') : '', + 'date_creation' => $order->date_creation ?dol_print_date($order->date_creation, 'dayhourrfc') : '', + 'date_validation' => $order->date_validation ?dol_print_date($order->date_creation, 'dayhourrfc') : '', + 'date_modification' => $order->datem ?dol_print_date($order->datem, 'dayhourrfc') : '', 'remise' => $order->remise, 'remise_percent' => $order->remise_percent, @@ -476,13 +476,15 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') else { $error++; - $errorcode = 'NOT_FOUND'; $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; + $errorcode = 'NOT_FOUND'; + $errorlabel = 'Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext; } } else { $error++; - $errorcode = 'PERMISSION_DENIED'; $errorlabel = 'User does not have permission for this request'; + $errorcode = 'PERMISSION_DENIED'; + $errorlabel = 'User does not have permission for this request'; } } @@ -552,7 +554,8 @@ function getOrdersForThirdParty($authentication, $idthirdparty) if( $socid && ( $socid != $order->socid) ) { $error++; - $errorcode='PERMISSION_DENIED'; $errorlabel=$order->socid.' User does not have permission for this request'; + $errorcode='PERMISSION_DENIED'; + $errorlabel=$order->socid.' User does not have permission for this request'; } if(!$error) From 394104291a430cf3e7eda6ad99ba66f3e98f25c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Dec 2019 04:22:09 +0100 Subject: [PATCH 211/248] Fix function not found when creating a payment of an expense report --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index cff0ef2b8ef..6bc3fcd0866 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1251,6 +1251,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r { if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experience trouble with pdf thumb generation and imagick, you can disable here. { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $ret = dol_convert_file($file, 'png', $fileimage); if ($ret < 0) $error++; } From ab33bb1d3b9beedfd18083945e86a24ca874917d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 13:37:50 +0100 Subject: [PATCH 212/248] The property datem does not exist on Societe --- htdocs/societe/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index a56762ce447..f0206175d0d 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -239,7 +239,7 @@ $sql = "SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur"; $sql .= ", s.code_client"; $sql .= ", s.code_fournisseur"; $sql .= ", s.logo"; -$sql .= ", s.canvas, s.tms as datem, s.status as status"; +$sql .= ", s.canvas, s.tms as date_modification, s.status as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= ' WHERE s.entity IN ('.getEntity('societe').')'; @@ -279,7 +279,7 @@ if ($result) $thirdparty_static->client = $objp->client; $thirdparty_static->fournisseur = $objp->fournisseur; $thirdparty_static->logo = $objp->logo; - $thirdparty_static->datem = $db->jdate($objp->datem); + $thirdparty_static->date_modification = $db->jdate($objp->date_modification); $thirdparty_static->status = $objp->status; $thirdparty_static->code_client = $objp->code_client; $thirdparty_static->code_fournisseur = $objp->code_fournisseur; @@ -313,7 +313,7 @@ if ($result) print ''; // Last modified date print ''; - print dol_print_date($thirdparty_static->datem, 'day'); + print dol_print_date($thirdparty_static->date_modification, 'day'); print ""; print ''; print $thirdparty_static->getLibStatut(3); From f0af4504940d175312aa2b80c946f16f596f8069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 13:40:55 +0100 Subject: [PATCH 213/248] The variable $db seems to be never defined The variable $db seems to be never defined on line 154 --- htdocs/societe/canvas/actions_card_common.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index aafcd8ffc69..a76e9aa34cb 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -82,7 +82,7 @@ abstract class ActionsCardCommon public function assign_values(&$action, $id = 0, $ref = '') { // phpcs:enable - global $conf, $langs, $user, $mysoc, $canvas; + global $conf, $langs, $db, $user, $mysoc, $canvas; global $form, $formadmin, $formcompany; if ($action == 'add' || $action == 'update') $this->assign_post($action); From 48564ea760adef644fb2a353308d162a54f779a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 14:26:59 +0100 Subject: [PATCH 214/248] doxygen societe class --- htdocs/install/mysql/tables/llx_societe.sql | 18 +-- htdocs/societe/class/societe.class.php | 157 +++++++++++++++++--- 2 files changed, 148 insertions(+), 27 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index fc3100b823d..a98be7912f7 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -52,15 +52,15 @@ create table llx_societe email varchar(128), -- socialnetworks text DEFAULT NULL, -- json with socialnetworks - skype varchar(255), -- - twitter varchar(255), -- - facebook varchar(255), -- - linkedin varchar(255), -- - instagram varchar(255), -- - snapchat varchar(255), -- - googleplus varchar(255), -- - youtube varchar(255), -- - whatsapp varchar(255), -- + skype varchar(255), -- deprecated + twitter varchar(255), -- deprecated + facebook varchar(255), -- deprecated + linkedin varchar(255), -- deprecated + instagram varchar(255), -- deprecated + snapchat varchar(255), -- deprecated + googleplus varchar(255), -- deprecated + youtube varchar(255), -- deprecated + whatsapp varchar(255), -- deprecated fk_effectif integer DEFAULT 0, -- fk_typent integer DEFAULT 0, -- diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 788fc45ee7e..c2017c894c0 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -59,16 +59,51 @@ class Societe extends CommonObject */ public $fk_element = 'fk_soc'; + /** + * @var string Fields for combobox + */ public $fieldsforcombobox = 'nom,name_alias'; /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables = array("supplier_proposal"=>'SupplierProposal', "propal"=>'Proposal', "commande"=>'Order', "facture"=>'Invoice', "facture_rec"=>'RecurringInvoiceTemplate', "contrat"=>'Contract', "fichinter"=>'Fichinter', "facture_fourn"=>'SupplierInvoice', "commande_fournisseur"=>'SupplierOrder', "projet"=>'Project', "expedition"=>'Shipment', "prelevement_lignes"=>'DirectDebitRecord'); + protected $childtables = array( + "supplier_proposal" => 'SupplierProposal', + "propal" => 'Proposal', + "commande" => 'Order', + "facture" => 'Invoice', + "facture_rec" => 'RecurringInvoiceTemplate', + "contrat" => 'Contract', + "fichinter" => 'Fichinter', + "facture_fourn" => 'SupplierInvoice', + "commande_fournisseur" => 'SupplierOrder', + "projet" => 'Project', + "expedition" => 'Shipment', + "prelevement_lignes" => 'DirectDebitRecord', + ); + /** * @var array List of child tables. To know object to delete on cascade. */ - protected $childtablesoncascade = array("societe_prices", "societe_log", "societe_address", "product_fournisseur_price", "product_customer_price_log", "product_customer_price", "socpeople", "adherent", "societe_account", "societe_rib", "societe_remise", "societe_remise_except", "societe_commerciaux", "categorie", "notify", "notify_def", "actioncomm"); + protected $childtablesoncascade = array( + "societe_prices", + "societe_log", + "societe_address", + "product_fournisseur_price", + "product_customer_price_log", + "product_customer_price", + "socpeople", + "adherent", + "societe_account", + "societe_rib", + "societe_remise", + "societe_remise_except", + "societe_commerciaux", + "categorie", + "notify", + "notify_def", + "actioncomm", + ); /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -87,8 +122,6 @@ class Societe extends CommonObject */ public $restrictiononfksoc = 1; - - // 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. */ @@ -123,7 +156,7 @@ class Societe extends CommonObject public $nom; /** - * @var string name + * @var string Thirdparty name */ public $name; @@ -133,6 +166,9 @@ class Societe extends CommonObject */ public $name_alias; + /** + * @var int Physical thirdparty not a company + */ public $particulier; /** @@ -140,7 +176,14 @@ class Societe extends CommonObject */ public $address; + /** + * @var string Zip code of thirdparty + */ public $zip; + + /** + * @var string Town of thirdparty + */ public $town; /** @@ -154,7 +197,15 @@ class Societe extends CommonObject * @var int */ public $state_id; + + /** + * @var string State code + */ public $state_code; + + /** + * @var string State name + */ public $state; /** @@ -162,11 +213,14 @@ class Societe extends CommonObject * @var int */ public $region_code; + + /** + * @var string Region name + */ public $region; /** - * State code - * @var string + * @var string State code * @deprecated Use state_code instead * @see $state_code */ @@ -220,25 +274,27 @@ class Societe extends CommonObject * @deprecated */ public $twitter; + /** * Facebook username * @var string * @deprecated */ public $facebook; + /** * LinkedIn username * @var string * @deprecated */ - public $linkedin; + public $linkedin; + /** * Webpage * @var string */ public $url; - //! barcode /** * Barcode value * @var string @@ -283,9 +339,16 @@ class Societe extends CommonObject */ public $idprof6; + /** + * @var string Prefix comm + */ public $prefix_comm; + /** + * @var int Vat concerned + */ public $tva_assuj = 1; + /** * Intracommunitary VAT ID * @var string @@ -298,8 +361,19 @@ class Societe extends CommonObject public $localtax2_assuj; public $localtax2_value; + /** + * @var string Manager + */ public $managers; + + /** + * @var float Capital + */ public $capital; + + /** + * @var int Type thirdparty + */ public $typent_id = 0; public $typent_code; public $effectif; @@ -317,6 +391,9 @@ class Societe extends CommonObject */ public $fk_prospectlevel; + /** + * @var string second name + */ public $name_bis; //Log data @@ -326,6 +403,7 @@ class Societe extends CommonObject * @var string */ public $date_modification; + /** * User that made last update * @var string @@ -351,11 +429,13 @@ class Societe extends CommonObject * @var int */ public $client = 0; + /** * 0=no prospect, 1=prospect * @var int */ public $prospect = 0; + /** * 0=no supplier, 1=supplier * @var int @@ -416,6 +496,7 @@ class Societe extends CommonObject * @var int */ public $stcomm_id; + /** * Status prospect label * @var int @@ -427,12 +508,20 @@ class Societe extends CommonObject * @var int */ public $price_level; + + /** + * @var string outstanding limit + */ public $outstanding_limit; /** - * Min order amounts + * @var string Min order amount */ public $order_min_amount; + + /** + * @var string Supplier min order amount + */ public $supplier_order_min_amount; /** @@ -440,11 +529,13 @@ class Societe extends CommonObject * @var int */ public $commercial_id; + /** * Id of parent thirdparty (if one) * @var int */ public $parent; + /** * Default language code of thirdparty (en_US, ...) * @var string @@ -456,7 +547,11 @@ class Societe extends CommonObject */ public $ref; + /** + * @var string Internal ref + */ public $ref_int; + /** * External user reference. * This is to allow external systems to store their id and make self-developed synchronizing functions easier to @@ -485,22 +580,49 @@ class Societe extends CommonObject */ public $webservices_key; + /** + * @var string Logo + */ public $logo; + + /** + * @var string logo small + */ public $logo_small; + + /** + * @var string Logo mini + */ public $logo_mini; + + /** + * @var string Logo squarred + */ public $logo_squarred; + + /** + * @var string Logo squarred small + */ public $logo_squarred_small; + + /** + * @var string Logo squarred mini + */ public $logo_squarred_mini; - public $array_options; - - // Incoterms /** - * @var int ID + * @var int ID Incoterms */ public $fk_incoterms; + /** + * @var string Incoterms Location + */ public $location_incoterms; + + /** + * @var string Incoterm label + */ public $label_incoterms; //Used into tooltip // Multicurrency @@ -509,12 +631,11 @@ class Societe extends CommonObject */ public $fk_multicurrency; + /** + * @var string Multicurrency code + */ public $multicurrency_code; - - // END MODULEBUILDER PROPERTIES - - /** * Constructor * From a6ca56a7e1eb5ae2d51d6823c9db595f68b264bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Dec 2019 15:57:51 +0100 Subject: [PATCH 215/248] Fix navigation backtopage and "save and stay" --- htdocs/website/index.php | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 105b332dd63..72fd6d0b70e 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1505,17 +1505,25 @@ if ($action == 'updatemeta') if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); - //exit; + + if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we do not make the redirect + { + //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); + //exit; + $action = 'preview'; + } + else + { + $action = 'editmeta'; + } } else { setEventMessages('Failed to write file '.$filetpl, null, 'errors'); //header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); //exit; + $action = 'preview'; } - - $action = 'preview'; } } @@ -1742,8 +1750,22 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf if ($result) { setEventMessages($langs->trans("Saved"), null, 'mesgs'); - header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); - exit; + + if (!GETPOSTISSET('updateandstay')) // If we click on "Save And Stay", we do not make the redirect + { + if ($backtopage) { + header("Location: ".$backtopage); + exit; + } else { + header("Location: ".$_SERVER["PHP_SELF"].'?website='.$websitekey.'&pageid='.$pageid); + exit; + } + } + else + { + if ($action == 'updatesource') $action = 'editsource'; + if ($action == 'updatecontent') $action = 'editcontent'; + } } else { @@ -2154,7 +2176,7 @@ if (!GETPOST('hide_websitemenu')) if (in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm'))) { - if ($action == 'editcss' && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print ''; + if ($action == 'editcss') print ''; if (preg_match('/^create/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print ''; if (preg_match('/^edit/', $action) && $action != 'file_manager' && $action != 'replacesite' && $action != 'replacesiteconfirm') print ''; if ($action != 'preview') print ''; @@ -2443,6 +2465,7 @@ if (!GETPOST('hide_websitemenu')) } if (!in_array($action, array('editcss', 'editmenu', 'file_manager', 'replacesite', 'replacesiteconfirm', 'createsite', 'createcontainer', 'createfromclone', 'createpagefromclone', 'deletesite'))) { + if ($action == 'editsource' || $action == 'editmeta') print ''; if (preg_match('/^create/', $action)) print ''; if (preg_match('/^edit/', $action)) print ''; if ($action != 'preview') print ''; @@ -3371,7 +3394,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm') $disabled = ' disabled'; $urltoedithtmlsource = ''; } - print ''.$langs->trans("EditHTMLSource").''; + print ''.img_picto($langs->trans("EditHTMLSource"), 'edit').''; print ''; print ''; } From 49f22faceffe66655f5f1d2e16b5cfa4dead2793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 22:37:19 +0100 Subject: [PATCH 216/248] doxygen --- htdocs/compta/deplacement/class/deplacement.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 0601c62fd80..5d6221e5135 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin * Copyright (C) 2013 Florian Henry + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,8 +83,16 @@ class Deplacement extends CommonObject public $fk_user; public $km; + + /** + * @var int Thirdparty id + */ public $socid; - public $statut; // 0=draft, 1=validated + + /** + * @var int Status 0=draft, 1=validated, 2=Refunded + */ + public $statut; public $extraparams=array(); public $statuts=array(); From 6c5629b5a53998e62eea297c72dfd9a40c217700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 22:39:33 +0100 Subject: [PATCH 217/248] Update deplacement.class.php --- htdocs/compta/deplacement/class/deplacement.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 5d6221e5135..242ae5f6211 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -82,7 +82,10 @@ class Deplacement extends CommonObject */ public $fk_user; - public $km; + /** + * @var string km value formatted + */ + public $km; /** * @var int Thirdparty id From 3db84df60e8654d8621dc44888b8fce1cdea3260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 22:45:10 +0100 Subject: [PATCH 218/248] Update card.php --- htdocs/compta/deplacement/card.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 5f469a2cef6..c121ee7836d 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,7 +63,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, if ($action == 'validate' && $user->rights->deplacement->creer) { $object->fetch($id); - if ($object->statut == 0) + if ($object->statut == Deplacement::STATUS_DRAFT) { $result = $object->setStatut(1); if ($result > 0) @@ -81,9 +81,9 @@ if ($action == 'validate' && $user->rights->deplacement->creer) elseif ($action == 'classifyrefunded' && $user->rights->deplacement->creer) { $object->fetch($id); - if ($object->statut == 1) + if ($object->statut == Deplacement::STATUS_VALIDATED) { - $result = $object->setStatut(2); + $result = $object->setStatut(Deplacement::STATUS_REFUNDED); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); @@ -116,14 +116,14 @@ elseif ($action == 'add' && $user->rights->deplacement->creer) { $error = 0; - $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount - $object->type = GETPOST('type', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->fk_user = GETPOST('fk_user', 'int'); + $object->type = GETPOST('type', 'alpha'); + $object->socid = (int) GETPOST('socid', 'int'); + $object->fk_user = (int) GETPOST('fk_user', 'int'); $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); - $object->statut = 0; + $object->statut = Deplacement::STATUS_DRAFT; if (!$object->date) { @@ -178,8 +178,8 @@ elseif ($action == 'update' && $user->rights->deplacement->creer) $object->date = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $object->km = price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formated amount $object->type = GETPOST('type', 'alpha'); - $object->socid = GETPOST('socid', 'int'); - $object->fk_user = GETPOST('fk_user', 'int'); + $object->socid = (int) GETPOST('socid', 'int'); + $object->fk_user = (int) GETPOST('fk_user', 'int'); $object->note_private = GETPOST('note_private', 'alpha'); $object->note_public = GETPOST('note_public', 'alpha'); @@ -523,7 +523,7 @@ elseif ($id) print '
'; - if ($object->statut < 2) // if not refunded + if ($object->statut < Deplacement::STATUS_REFUNDED) // if not refunded { if ($user->rights->deplacement->creer) { @@ -535,7 +535,7 @@ elseif ($id) } } - if ($object->statut == 0) // if draft + if ($object->statut == Deplacement::STATUS_DRAFT) // if draft { if ($user->rights->deplacement->creer) { @@ -547,7 +547,7 @@ elseif ($id) } } - if ($object->statut == 1) // if validated + if ($object->statut == Deplacement::STATUS_VALIDATED) // if validated { if ($user->rights->deplacement->creer) { From c05ba624ce153471b974950baecdd3d8f2459ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 22:46:22 +0100 Subject: [PATCH 219/248] Update deplacement.class.php --- .../deplacement/class/deplacement.class.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 242ae5f6211..be46e1dfd14 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -101,6 +101,21 @@ class Deplacement extends CommonObject public $statuts=array(); public $statuts_short=array(); + /** + * Draft status + */ + const STATUS_DRAFT = 0; + + /** + * Validated status + */ + const STATUS_VALIDATED = 1; + + /** + * Refunded status + */ + const STATUS_REFUNDED = 2; + /** * Constructor * From fbb5fbae139029dacde9a0775427791b204a81b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 8 Dec 2019 23:02:34 +0100 Subject: [PATCH 220/248] Update new.php --- htdocs/public/members/new.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index a6e06dfb5ff..72c49b6e9fd 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -4,7 +4,7 @@ * Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2012 J. Fernando Lagrange - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -567,7 +567,7 @@ $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''.$langs->trans('Nature').' *'."\n"; + print ''.$langs->trans('MemberNature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); print ''."\n"; } From 2b5866aca2e6883971aa1a603c48d185c853858c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 8 Dec 2019 23:45:06 +0100 Subject: [PATCH 221/248] WIP Complete module MRP --- htdocs/core/actions_addupdatedelete.inc.php | 1 + htdocs/core/class/commonobject.class.php | 4 +- .../install/mysql/migration/10.0.0-11.0.0.sql | 4 + .../mysql/tables/llx_mrp_production.sql | 2 + htdocs/langs/en_US/mrp.lang | 1 + htdocs/mrp/class/mo.class.php | 197 +++++++++++++++++- htdocs/mrp/mo_card.php | 13 +- 7 files changed, 212 insertions(+), 10 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 0d718c2abc2..f5f0f822108 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -44,6 +44,7 @@ if ($cancel) $action = ''; } + // Action to add record if ($action == 'add' && !empty($permissiontoadd)) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a6084a49f7e..1508575ba37 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7317,7 +7317,7 @@ abstract class CommonObject global $conf; $queryarray = array(); - foreach ($this->fields as $field=>$info) // Loop on definition of fields + foreach ($this->fields as $field => $info) // Loop on definition of fields { // Depending on field type ('datetime', ...) if ($this->isDate($info)) @@ -7553,6 +7553,8 @@ abstract class CommonObject { $error++; $this->errors[] = $this->db->lasterror(); + } else { + $this->ref = '(PROV'.$this->id.')'; } } } diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index b4d956129a7..4bacfa9b765 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -521,6 +521,8 @@ CREATE TABLE llx_mrp_production( fk_product integer NOT NULL, fk_warehouse integer, qty integer NOT NULL DEFAULT 1, + qty_frozen smallint DEFAULT 0, + disable_stock_change smallint DEFAULT 0, batch varchar(30), role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation) fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce' @@ -532,6 +534,8 @@ CREATE TABLE llx_mrp_production( import_key varchar(14) ) ENGINE=innodb; +ALTER TABLE llx_mrp_production ADD COLUMN qty_frozen smallint DEFAULT 0; +ALTER TABLE llx_mrp_production ADD COLUMN disable_stock_change smallint DEFAULT 0; ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_mo FOREIGN KEY (fk_mo) REFERENCES llx_mrp_mo (rowid); ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_product FOREIGN KEY (fk_product) REFERENCES llx_product (rowid); ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement FOREIGN KEY (fk_stock_movement) REFERENCES llx_stock_mouvement (rowid); diff --git a/htdocs/install/mysql/tables/llx_mrp_production.sql b/htdocs/install/mysql/tables/llx_mrp_production.sql index 275acde6aef..b05e261c65b 100644 --- a/htdocs/install/mysql/tables/llx_mrp_production.sql +++ b/htdocs/install/mysql/tables/llx_mrp_production.sql @@ -21,6 +21,8 @@ CREATE TABLE llx_mrp_production( fk_product integer NOT NULL, fk_warehouse integer, qty integer NOT NULL DEFAULT 1, + qty_frozen smallint DEFAULT 0, + disable_stock_change smallint DEFAULT 0, batch varchar(30), role varchar(10), -- 'toconsume' or 'toproduce' (initialized at MO creation), 'consumed' or 'produced' (added after MO validation) fk_mrp_production integer, -- if role = 'consumed', id of line with role 'toconsume', if role = 'produced' id of line with role 'toproduce' diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 2eb28366a55..4bed22df445 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -53,3 +53,4 @@ CreateMO=Create MO ToConsume=A consommer Manufactured=Fabriqué TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce. +ForAQuantityOf1=For a quantity to produce of 1 \ No newline at end of file diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index cf8e45b5901..982bff9d9ae 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -231,13 +231,57 @@ class Mo extends CommonObject */ public function create(User $user, $notrigger = false) { + global $conf; + + $error = 0; + $this->db->begin(); $result = $this->createCommon($user, $notrigger); + if ($result <= 0) { + $error++; + } // Insert lines in mrp_production table + if (! $error && $this->fk_bom > 0) + { + include_once DOL_DOCULENT_ROOT.'/bom/class/bom.class.php'; + $bom = new Bom($this->db); + $bom->fetch($this->fk_bom); + if ($bom->id > 0) + { + foreach($bom->lines as $line) + { + $moline = new MOLine($this->db); - if ($result > 0) { + $moline->fk_mo = $this->id; + $moline->qty = $line->qty * $this->qty * $bom->efficiency; + if ($moline->qty <= 0) { + $error++; + $this->error = "BadValueForquantityToConsume"; + break; + } + else { + $moline->fk_product = $line->fk_product; + $moline->role = 'toconsume'; + $moline->position = $line->position; + $moline->qty_frozen = $line->qty_frozen; + $moline->disable_stock_change = $line->disable_stock_change; + + $resultline = $moline->create($user); + if ($resultline <= 0) { + $error++; + $this->error = $moline->error; + $this->errors = $moline->errors; + dol_print_error($this->db, $moline->error, $moline->errors); + break; + } + } + } + } + } + + if (! $error) { $this->db->commit(); } else { $this->db->rollback(); @@ -838,8 +882,153 @@ class Mo extends CommonObject /** * Class MoLine. You can also remove this and generate a CRUD class for lines objects. */ -class MoLine +class MoLine extends CommonObjectLine { - // To complete with content of an object MoLine - // We should have a field rowid, fk_mo and position + /** + * @var string ID to identify managed object + */ + public $element = 'mrp_production'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'mrp_production'; + + /** + * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; + + /** + * @var int Does moline support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; + + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'fk_mo' =>array('type'=>'integer', 'label'=>'Fk mo', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'position' =>array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'fk_product' =>array('type'=>'integer', 'label'=>'Fk product', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'fk_warehouse' =>array('type'=>'integer', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>30), + 'qty' =>array('type'=>'integer', 'label'=>'Qty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), + 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), + 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), + 'batch' =>array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>-1, 'position'=>140), + 'role' =>array('type'=>'varchar(10)', 'label'=>'Role', 'enabled'=>1, 'visible'=>-1, 'position'=>145), + 'fk_mrp_production' =>array('type'=>'integer', 'label'=>'Fk mrp production', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'fk_stock_movement' =>array('type'=>'integer', 'label'=>'Fk stock movement', 'enabled'=>1, 'visible'=>-1, 'position'=>155), + 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>160), + 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>165), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'Fk user creat', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>170), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'Fk user modif', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportKey', 'enabled'=>1, 'visible'=>-1, 'position'=>180), + ); + + public $rowid; + public $fk_mo; + public $position; + public $fk_product; + public $fk_warehouse; + public $qty; + public $qty_frozen; + public $disable_stock_change; + public $batch; + public $role; + public $fk_mrp_production; + public $fk_stock_movement; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $import_key; + + /** + * 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 (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); + } + + /** + * 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); + if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * 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); + //return $this->deleteCommon($user, $notrigger, 1); + } } diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index baa4c09725f..9534e643e0d 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -93,10 +93,13 @@ if (GETPOST('fk_bom', 'int')) { $objectbom->fetch(GETPOST('fk_bom', 'int')); - $_POST['fk_product'] = $objectbom->fk_product; - $_POST['qty'] = $objectbom->qty; - $_POST['fk_warehouse'] = $objectbom->fk_warehouse; - $_POST['note_private'] = $objectbom->note_private; + if ($action != 'add') { + // We force calling parameters if we are not in the submit of creation of MO + $_POST['fk_product'] = $objectbom->fk_product; + $_POST['qty'] = $objectbom->qty; + $_POST['fk_warehouse'] = $objectbom->fk_warehouse; + $_POST['note_private'] = $objectbom->note_private; + } } // Security check - Protection if external user @@ -279,7 +282,7 @@ if ($action == 'create') print '
'; if (GETPOST('fk_bom', 'int') > 0) { - print load_fiche_titre($langs->trans("ToConsume")); + print load_fiche_titre($langs->trans("ToConsume").' ('.$langs->trans("ForAQuantityOf1").')'); print '
'; print ''; From 9e479afff1c3a89400a7c66e21f34f0fb0edc6fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 00:06:51 +0100 Subject: [PATCH 222/248] WIP Complete module MRP --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/mrp/class/mo.class.php | 93 ++++++++++++++++++++++-- htdocs/mrp/mo_card.php | 7 +- htdocs/mrp/mo_production.php | 13 +++- 4 files changed, 102 insertions(+), 13 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1508575ba37..aba487ab4a0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4118,7 +4118,7 @@ abstract class CommonObject $i = 0; - print "\n"; + print "\n"; foreach ($this->lines as $line) { //Line extrafield diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 982bff9d9ae..1dced508aec 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -157,32 +157,32 @@ class Mo extends CommonObject /** * @var int Name of subtable line */ - //public $table_element_line = 'mrp_moline'; + public $table_element_line = 'mo_production'; /** * @var int Field with ID of parent key if this field has a parent */ - //public $fk_element = 'fk_mo'; + public $fk_element = 'fk_mo'; /** * @var int Name of subtable class that manage subtable lines */ - //public $class_element_line = 'Moline'; + public $class_element_line = 'MoLine'; /** * @var array List of child tables. To test if we can delete object. */ - //protected $childtables=array(); + protected $childtables=array('mrp_production'); /** * @var array List of child tables. To know object to delete on cascade. */ - //protected $childtablesoncascade=array('mrp_modet'); + protected $childtablesoncascade=array('mrp_production'); /** * @var MoLine[] Array of subtable lines */ - //public $lines = array(); + public $lines = array(); @@ -252,7 +252,7 @@ class Mo extends CommonObject { foreach($bom->lines as $line) { - $moline = new MOLine($this->db); + $moline = new MoLine($this->db); $moline->fk_mo = $this->id; $moline->qty = $line->qty * $this->qty * $bom->efficiency; @@ -1007,6 +1007,85 @@ class MoLine extends CommonObjectLine 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 (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key == 'customsql') { + $sqlwhere[] = $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 < min($limit, $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 * diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 9534e643e0d..f22c42140f5 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -504,9 +504,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { print '
'; + + print ''; } - if (!empty($object->lines)) + /*if (!empty($object->lines)) { $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl'); } @@ -522,7 +524,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } - } + } */ if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { @@ -530,6 +532,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; + print "\n"; } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 28800d23bd2..931a6253510 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -326,13 +326,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } + $object->fetchLines(); + print '
'; if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
TODO...
'; + print '
'; + + print ''; + + //var_dump($object->lines); + } - if (!empty($object->lines)) + /*if (!empty($object->lines)) { $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/mrp/tpl'); } @@ -348,7 +355,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $parameters = array(); $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook } - } + }*/ if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { From d0f90de33cb7c2e35a8134ad6fea758295b6f24b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 00:27:54 +0100 Subject: [PATCH 223/248] css --- htdocs/theme/eldy/global.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d6c4d30496e..129e3dee727 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1521,6 +1521,7 @@ div#id-top { display:none; background: rgb(); + background-image: linear-gradient(-45deg, , rgb()); } From 2ca5a4378b46ab786ec1762d2fea642195e97b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 00:54:42 +0100 Subject: [PATCH 224/248] Fix empty div when no address Fix deletion of MO --- htdocs/core/class/commonobject.class.php | 30 ++++++++++++++---------- htdocs/core/lib/functions.lib.php | 9 ++++--- htdocs/mrp/class/mo.class.php | 2 +- htdocs/mrp/mo_agenda.php | 7 +++--- htdocs/mrp/mo_note.php | 7 +++--- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aba487ab4a0..544063bc4c8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -621,7 +621,7 @@ abstract class CommonObject $thirdpartyid = $object->fk_soc; } - $out = ''; + $out = ''; $outdone = 0; $coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT); @@ -682,7 +682,7 @@ abstract class CommonObject $out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', ' ', 'fax', $langs->trans("Fax")); $outdone++; } - $out .= '
'; + if ($out) $out .= '
'; $outdone = 0; if (!empty($this->email)) { @@ -695,32 +695,36 @@ abstract class CommonObject $out .= dol_print_url($this->url, '_blank', 0, 1); $outdone++; } - $out .= '
'; + if (!empty($conf->socialnetworks->enabled)) { + $outsocialnetwork = ''; + if (is_array($this->socialnetworks) && count($this->socialnetworks) > 0) { foreach ($this->socialnetworks as $key => $value) { - $out .= dol_print_socialnetworks($value, $this->id, $object->id, $key); + $outsocialnetwork .= dol_print_socialnetworks($value, $this->id, $object->id, $key); $outdone++; } } else { - if ($this->skype) $out .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); + if ($this->skype) $outsocialnetwork .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); $outdone++; - if ($this->jabberid) $out .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); + if ($this->jabberid) $outsocialnetwork .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); $outdone++; - if ($this->twitter) $out .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); + if ($this->twitter) $outsocialnetwork .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); $outdone++; - if ($this->facebook) $out .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); + if ($this->facebook) $outsocialnetwork .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); $outdone++; - if ($this->linkedin) $out .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); + if ($this->linkedin) $outsocialnetwork .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); $outdone++; } + + if ($outsocialnetwork) { + $out .= '
'.$outsocialnetwork.'
'; + } } - $out .= '
'; - $out .= ''; - - return $out; + if ($out) return ''."\n".$out.''."\n"; + else return ''; } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6306162af34..1d275e0f512 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1582,9 +1582,12 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') { - $morehtmlref .= '
'; - $morehtmlref .= $object->getBannerAddress('refaddress', $object); - $morehtmlref .= '
'; + $moreaddress = $object->getBannerAddress('refaddress', $object); + if ($moreaddress) { + $morehtmlref .= '
'; + $morehtmlref .= $moreaddress; + $morehtmlref .= '
'; + } } if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) { diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 1dced508aec..0536ee41b8d 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -172,7 +172,7 @@ class Mo extends CommonObject /** * @var array List of child tables. To test if we can delete object. */ - protected $childtables=array('mrp_production'); + protected $childtables=array(); /** * @var array List of child tables. To know object to delete on cascade. diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index 5822ce0d170..669102487d5 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -136,8 +136,9 @@ if ($object->id > 0) // ------------------------------------------------------------ $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; + $morehtmlref = ''; /* + $morehtmlref = '
'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); @@ -175,9 +176,9 @@ if ($object->id > 0) $morehtmlref.=''; } } - }*/ + } $morehtmlref .= '
'; - + */ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 1a9fbe278a9..c177012a201 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -89,8 +89,9 @@ if ($id > 0 || ! empty($ref)) // ------------------------------------------------------------ $linkback = '' . $langs->trans("BackToList") . ''; - $morehtmlref='
'; + $morehtmlref = ''; /* + $morehtmlref='
'; // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); @@ -128,9 +129,9 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.=''; } } - }*/ + } $morehtmlref.='
'; - + */ dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); From 39afe39016f1dcd7aa9e129233462fdd49cda644 Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Sun, 8 Dec 2019 19:29:46 -0600 Subject: [PATCH 225/248] Bugfix: Module builder missing table prefix The function rebuildObjectSql from the module builder module is missing the table prefix when adding a constraint --- htdocs/core/lib/modulebuilder.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index deac3de6157..b18618d4dfa 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -321,7 +321,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $tmp = explode('.', $val['foreignkey']); if (!empty($tmp[0]) && !empty($tmp[1])) { - $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".$tmp[0]."(".$tmp[1].");"; + $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".MAIN_DB_PREFIX.$tmp[0]."(".$tmp[1].");"; $texttoinsert .= "\n"; } } From 76cf54e6e7d5e18892ca731d468104bcc4e81800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 9 Dec 2019 08:07:59 +0100 Subject: [PATCH 226/248] typo + doxygen --- htdocs/mrp/class/mo.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 0536ee41b8d..195a3805c32 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -120,7 +120,15 @@ class Mo extends CommonObject public $qty; public $fk_warehouse; public $fk_soc; + + /** + * @var string public note + */ public $note_public; + + /** + * @var string private note + */ public $note_private; /** @@ -245,7 +253,7 @@ class Mo extends CommonObject // Insert lines in mrp_production table if (! $error && $this->fk_bom > 0) { - include_once DOL_DOCULENT_ROOT.'/bom/class/bom.class.php'; + include_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; $bom = new Bom($this->db); $bom->fetch($this->fk_bom); if ($bom->id > 0) From eb0d20b77e872156e90cff3bc90eb103365fcb8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 09:16:59 +0100 Subject: [PATCH 227/248] Fix label of country Fix div empty --- htdocs/compta/stats/byratecountry.php | 13 +++++++++---- htdocs/core/lib/functions.lib.php | 9 ++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index 3416cd553a0..acd58f90217 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -257,7 +257,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql = "SELECT fd.tva_tx AS vatrate,"; $sql .= " fd.product_type AS product_type,"; - $sql .= " cc.label AS country,"; + $sql .= " cc.code, cc.label AS country,"; for ($i = 1; $i <= 12; $i++) { $sql .= " SUM(".$db->ifsql('MONTH(f.datef)='.$i, 'fd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; } @@ -289,7 +289,10 @@ if ($modecompta == 'CREANCES-DETTES') { } else { print '
'; } - print ''; + // Country + print ''; for ($i = 0; $i < 12; $i++) { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; @@ -335,7 +338,7 @@ if ($modecompta == 'CREANCES-DETTES') { $sql2 = "SELECT ffd.tva_tx AS vatrate,"; $sql2 .= " ffd.product_type AS product_type,"; - $sql2 .= " cc.label AS country,"; + $sql2 .= " cc.code, cc.label AS country,"; for ($i = 1; $i <= 12; $i++) { $sql2 .= " SUM(".$db->ifsql('MONTH(ff.datef)='.$i, 'ffd.total_ht', '0').") AS month".str_pad($i, 2, '0', STR_PAD_LEFT).","; } @@ -368,7 +371,9 @@ if ($modecompta == 'CREANCES-DETTES') { } else { print ''; } - print ''; + print ''; for ($i = 0; $i < 12; $i++) { $j = $i + (empty($conf->global->SOCIETE_FISCAL_MONTH_START) ? 1 : $conf->global->SOCIETE_FISCAL_MONTH_START); if ($j > 12) $j -= 12; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6306162af34..1d275e0f512 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1582,9 +1582,12 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') { - $morehtmlref .= '
'; - $morehtmlref .= $object->getBannerAddress('refaddress', $object); - $morehtmlref .= '
'; + $moreaddress = $object->getBannerAddress('refaddress', $object); + if ($moreaddress) { + $morehtmlref .= '
'; + $morehtmlref .= $moreaddress; + $morehtmlref .= '
'; + } } if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) { From 652e99600a69652ae72c1e084c4fc9d86ed9d6cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 09:43:38 +0100 Subject: [PATCH 228/248] Look and feel v11 --- htdocs/admin/events.php | 2 +- htdocs/admin/perms.php | 3 +-- htdocs/admin/proxy.php | 2 +- htdocs/admin/security.php | 3 ++- htdocs/admin/security_file.php | 2 +- htdocs/conf/conf.php.example | 4 ++-- htdocs/main.inc.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index ca569b66b76..0109538f71f 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -74,7 +74,7 @@ llxHeader('', $langs->trans("Audit"), $wikihelp); //$linkback=''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); -print $langs->trans("LogEventDesc", $langs->transnoentitiesnoconv("AdminTools"), $langs->transnoentitiesnoconv("Audit"))."
\n"; +print ''.$langs->trans("LogEventDesc", $langs->transnoentitiesnoconv("AdminTools"), $langs->transnoentitiesnoconv("Audit"))."
\n"; print "
\n"; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index 23fa06887a9..a9c581733a4 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -66,8 +66,7 @@ llxHeader('', $langs->trans("DefaultRights"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); -print $langs->trans("DefaultRightsDesc"); -print " ".$langs->trans("OnlyActiveElementsAreShown")."

\n"; +print ''.$langs->trans("DefaultRightsDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."

\n"; $db->begin(); diff --git a/htdocs/admin/proxy.php b/htdocs/admin/proxy.php index 9974e58a1f6..670e6e43b54 100644 --- a/htdocs/admin/proxy.php +++ b/htdocs/admin/proxy.php @@ -82,7 +82,7 @@ llxHeader('', $langs->trans("Proxy"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); -print $langs->trans("ProxyDesc")."
\n"; +print ''.$langs->trans("ProxyDesc")."
\n"; print "
\n"; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 1760651b693..7a1f5c04dd2 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -194,6 +194,7 @@ if ($action == 'maj_pattern') /* * View */ + $form = new Form($db); $wikihelp = 'EN:Setup_Security|FR:Paramétrage_Sécurité|ES:Configuración_Seguridad'; @@ -201,7 +202,7 @@ llxHeader('', $langs->trans("Passwords"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); -print $langs->trans("GeneratedPasswordDesc")."
\n"; +print ''.$langs->trans("GeneratedPasswordDesc")."
\n"; print "
\n"; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index aeb2ee0fe19..7b11aa3570e 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -90,7 +90,7 @@ llxHeader('', $langs->trans("Files"), $wikihelp); print load_fiche_titre($langs->trans("SecuritySetup"), '', 'title_setup'); -print $langs->trans("SecurityFilesDesc")."
\n"; +print ''.$langs->trans("SecurityFilesDesc")."
\n"; print "
\n"; diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index 84fc87d35f8..a742c5c45fd 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -250,11 +250,11 @@ $dolibarr_main_prod='0'; $dolibarr_main_restrict_os_commands='mysqldump, mysql, pg_dump, pgrestore'; // $dolibarr_main_restrict_ip -// To restrict access to backoffice to some ip addresses only. +// To restrict access to backoffice to some ip addresses only. Use a comma to separate values. // Note: Pages that does not need login (like public pages, web site) are not protected with this. // Default value: '' // Examples: -// $dolibarr_main_restrict_ip='127.0.0.1, 192.168.0.1'; +// $dolibarr_main_restrict_ip='127.0.0.1, ::1, 192.168.0.1'; // $dolibarr_main_restrict_ip=''; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4824ced47db..6eeb1cb8cb7 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -309,7 +309,7 @@ if (!defined('NOLOGIN') && !defined('NOIPCHECK') && !empty($dolibarr_main_restri } if (!$found) { - print 'Access refused by IP protection'; + print 'Access refused by IP protection. Your detected IP is '.$_SERVER['REMOTE_ADDR']; exit; } } From 54ca37dc65845e4561fd6aa1db6b103a2816ce2f Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 9 Dec 2019 09:35:58 +0000 Subject: [PATCH 229/248] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- htdocs/comm/remx.php | 8 ++++---- htdocs/core/website.inc.php | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 70f9846bd6b..272e0173980 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -539,7 +539,7 @@ if ($socid > 0) else { $colspan = 8; - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan += 2; print '
'; } $db->free($resql); @@ -695,7 +695,7 @@ if ($socid > 0) else { $colspan = 8; - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''; } $db->free($resql); @@ -897,7 +897,7 @@ if ($socid > 0) else { $colspan = 8; - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''; } @@ -1073,7 +1073,7 @@ if ($socid > 0) else { $colspan = 8; - if (!empty($conf->multicurrency->enabled)) $colspan+=2; + if (!empty($conf->multicurrency->enabled)) $colspan += 2; print ''; } diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index fc6fa02cbec..b90da632fac 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -28,31 +28,31 @@ include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; // Define $website -if (! is_object($website)) +if (!is_object($website)) { - $website=new Website($db); + $website = new Website($db); $website->fetch(0, $websitekey); } // Define $weblangs -if (! is_object($weblangs)) +if (!is_object($weblangs)) { - $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice + $weblangs = dol_clone($langs); // TODO Use an object lang from a language set into $website object instead of backoffice } // Define $websitepage if we have $websitepagefile defined -if (! $pageid && ! empty($websitepagefile)) +if (!$pageid && !empty($websitepagefile)) { $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); if ($pageid == 'index.php') $pageid = $website->fk_default_home; } -if (! is_object($websitepage)) +if (!is_object($websitepage)) { - $websitepage=new WebsitePage($db); + $websitepage = new WebsitePage($db); } if ($pageid > 0) { $websitepage->fetch($pageid); - if (! defined('USEDOLIBARREDITOR') && in_array($websitepage->type_container, array('menu', 'other'))) + if (!defined('USEDOLIBARREDITOR') && in_array($websitepage->type_container, array('menu', 'other'))) { $weblangs->load("website"); http_response_code(404); @@ -61,7 +61,7 @@ if ($pageid > 0) } } -if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { +if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { header("X-Content-Type-Options: nosniff"); /* TODO Manage allow_frames flag on websitepage. if (empty($websitepage->allow_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) { @@ -78,13 +78,13 @@ if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing //print_r(get_defined_constants(true));exit; if (GETPOST('l', 'aZ09')) { - $sql ="SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; - $sql.=" FROM ".MAIN_DB_PREFIX."website_page as wp"; - $sql.=" WHERE wp.fk_website = ".$website->id; - $sql.=" AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; - if (is_object($websitepage) && $websitepage->fk_page > 0) $sql.=" OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; - $sql.=")"; - $sql.= " AND wp.lang = '".$db->escape(GETPOST('l', 'aZ09'))."'"; + $sql = "SELECT wp.rowid, wp.lang, wp.pageurl, wp.fk_page"; + $sql .= " FROM ".MAIN_DB_PREFIX."website_page as wp"; + $sql .= " WHERE wp.fk_website = ".$website->id; + $sql .= " AND (wp.fk_page = ".$pageid." OR wp.rowid = ".$pageid; + if (is_object($websitepage) && $websitepage->fk_page > 0) $sql .= " OR wp.fk_page = ".$websitepage->fk_page." OR wp.rowid = ".$websitepage->fk_page; + $sql .= ")"; + $sql .= " AND wp.lang = '".$db->escape(GETPOST('l', 'aZ09'))."'"; $resql = $db->query($sql); if ($resql) @@ -112,7 +112,7 @@ if ($_SERVER['PHP_SELF'] != DOL_URL_ROOT.'/website/index.php') // If we browsing } // Show off line message -if (! defined('USEDOLIBARREDITOR') && empty($website->status)) +if (!defined('USEDOLIBARREDITOR') && empty($website->status)) { $weblangs->load("website"); http_response_code(503); From 655574262b51e622874aeb568bdca154c710c8ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 14:01:55 +0100 Subject: [PATCH 230/248] Fix google plus --- README-FR.md | 2 -- README.md | 1 - 2 files changed, 3 deletions(-) diff --git a/README-FR.md b/README-FR.md index 382f2a670ac..3d5473b14cc 100644 --- a/README-FR.md +++ b/README-FR.md @@ -161,13 +161,11 @@ Voir le fichier [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/CO Suivez le projet Dolibarr project sur les réseaux francophones - [Facebook](https://www.facebook.com/dolibarr.fr) -- [Google+](https://plus.google.com/+DolibarrFrance) - [Twitter](https://www.twitter.com/dolibarr_france) ou sur les réseaux anglophones - [Facebook](https://www.facebook.com/dolibarr) -- [Google+](https://plus.google.com/+DolibarrOrg) - [Twitter](https://www.twitter.com/dolibarr) - [LinkedIn](https://www.linkedin.com/company/association-dolibarr) - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) diff --git a/README.md b/README.md index eb1b7955b67..e7f1535d1e5 100644 --- a/README.md +++ b/README.md @@ -187,7 +187,6 @@ See [COPYRIGHT](https://github.com/Dolibarr/dolibarr/blob/develop/COPYRIGHT) fil Follow Dolibarr project on: - [Facebook](https://www.facebook.com/dolibarr) -- [Google+](https://plus.google.com/+DolibarrOrg) - [Twitter](https://www.twitter.com/dolibarr) - [LinkedIn](https://www.linkedin.com/company/association-dolibarr) - [YouTube](https://www.youtube.com/user/DolibarrERPCRM) From e1cf93d9a9c4a381fa90ddef4f679a7045384f83 Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 9 Dec 2019 14:44:37 +0100 Subject: [PATCH 231/248] Fix exif_read_data fatal error --- htdocs/core/lib/images.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 69b907036c1..1d1a6b8c7b9 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -323,7 +323,7 @@ function dolRotateImage($file_path) function correctExifImageOrientation($fileSource, $fileDest, $quality = 95) { if (function_exists('exif_read_data')) { - $exif = exif_read_data($fileSource); + $exif = @exif_read_data($fileSource); if ($exif && isset($exif['Orientation'])) { $infoImg = getimagesize($fileSource); // Get image infos @@ -456,7 +456,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', $ort = false; if (function_exists('exif_read_data')) { - $exif = exif_read_data($filetoread); + $exif = @exif_read_data($filetoread); if ($exif && !empty($exif['Orientation'])) { $ort = $exif['Orientation']; } From a12b2fea803b7de37fa99c03783744503ebd6bbc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 15:54:14 +0100 Subject: [PATCH 232/248] Update modulebuilder.lib.php --- htdocs/core/lib/modulebuilder.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index b18618d4dfa..f0438cc3198 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -321,7 +321,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $tmp = explode('.', $val['foreignkey']); if (!empty($tmp[0]) && !empty($tmp[1])) { - $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES ".MAIN_DB_PREFIX.$tmp[0]."(".$tmp[1].");"; + $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".$tmp[0]."(".$tmp[1].");"; $texttoinsert .= "\n"; } } From 8c50097012f0c3b9e4c2f0ce9478e80b0e7710d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 15:55:25 +0100 Subject: [PATCH 233/248] Update modulebuilder.lib.php --- htdocs/core/lib/modulebuilder.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index f0438cc3198..fe5d707b10a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -321,7 +321,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' $tmp = explode('.', $val['foreignkey']); if (!empty($tmp[0]) && !empty($tmp[1])) { - $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".$tmp[0]."(".$tmp[1].");"; + $texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");"; $texttoinsert .= "\n"; } } From 89c5407e461d459143f3998ea37e7846a5bc75d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 16:18:29 +0100 Subject: [PATCH 234/248] Fix phpcs --- htdocs/mrp/mo_production.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 931a6253510..0fc427ebea1 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -336,7 +336,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; //var_dump($object->lines); - } /*if (!empty($object->lines)) From dfeca5fae82411fbc9b138e2af6c1d29d229407d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Dec 2019 17:42:38 +0100 Subject: [PATCH 235/248] Fix phpcs --- htdocs/core/modules/propale/doc/pdf_azur.modules.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index ae878e0f85d..4391c52d482 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -259,10 +259,8 @@ class pdf_azur extends ModelePDFPropales if (!$arephoto) { if ($conf->product->entity != $objphoto->entity) { - $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities - }else{ - + } else { $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product } From 39da0bef9ec7b48b4930171f967cc8ac8b11f443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 9 Dec 2019 23:56:46 +0100 Subject: [PATCH 236/248] Update server_order.php --- htdocs/webservices/server_order.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 59ccbc29df0..157d34652c1 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -447,7 +447,7 @@ function getOrder($authentication, $id = '', $ref = '', $ref_ext = '') 'date' => $order->date ?dol_print_date($order->date, 'dayrfc') : '', 'date_creation' => $order->date_creation ?dol_print_date($order->date_creation, 'dayhourrfc') : '', 'date_validation' => $order->date_validation ?dol_print_date($order->date_creation, 'dayhourrfc') : '', - 'date_modification' => $order->datem ?dol_print_date($order->datem, 'dayhourrfc') : '', + 'date_modification' => $order->date_modification ?dol_print_date($order->date_modification, 'dayhourrfc') : '', 'remise' => $order->remise, 'remise_percent' => $order->remise_percent, @@ -531,10 +531,10 @@ function getOrdersForThirdParty($authentication, $idthirdparty) { $linesorders=array(); - $sql.='SELECT c.rowid as orderid'; - $sql.=' FROM '.MAIN_DB_PREFIX.'commande as c'; - $sql.=" WHERE c.entity = ".$conf->entity; - if ($idthirdparty != 'all' ) $sql.=" AND c.fk_soc = ".$db->escape($idthirdparty); + $sql = 'SELECT c.rowid as orderid'; + $sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c'; + $sql .= " WHERE c.entity = ".$conf->entity; + if ($idthirdparty != 'all' ) $sql .= " AND c.fk_soc = ".$db->escape($idthirdparty); $resql=$db->query($sql); @@ -677,7 +677,8 @@ function createOrder($authentication, $order) // Init and check authentication $objectresp = array(); - $errorcode = ''; $errorlabel = ''; + $errorcode = ''; + $errorlabel = ''; $error = 0; $fuser = check_authentication($authentication, $error, $errorcode, $errorlabel); @@ -820,7 +821,8 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) // Init and check authentication $objectresp=array(); - $errorcode='';$errorlabel=''; + $errorcode=''; + $errorlabel=''; $error=0; if ($authentication['entity']) $conf->entity=$authentication['entity']; $fuser=check_authentication($authentication, $error, $errorcode, $errorlabel); @@ -851,7 +853,7 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) $db->rollback(); $error++; $errorcode = 'KO'; - $errorlabel = $newobject->error; + $errorlabel = $order->error; } } else @@ -859,7 +861,7 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) $db->rollback(); $error++; $errorcode = 'KO'; - $errorlabel = $newobject->error; + $errorlabel = $order->error; } } else @@ -867,7 +869,7 @@ function validOrder($authentication, $id = '', $id_warehouse = 0) $db->rollback(); $error++; $errorcode = 'KO'; - $errorlabel = $newobject->error; + $errorlabel = $order->error; } } From 5572102ae57fdc0e05528edecb429edcd3663b35 Mon Sep 17 00:00:00 2001 From: Arunas Ruksnaitis Date: Tue, 10 Dec 2019 00:30:47 +0000 Subject: [PATCH 237/248] Docker corrections --- build/docker/Dockerfile | 18 ++++++++++++------ build/docker/docker-compose.yml | 2 +- build/docker/docker-run.sh | 3 ++- build/docker/mariadb/Dockerfile | 3 +++ 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 build/docker/mariadb/Dockerfile diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 0d5918c3f4c..507170c7368 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -1,31 +1,37 @@ -FROM php:7.0-apache +FROM php:7.2-apache ENV HOST_USER_ID 33 ENV PHP_INI_DATE_TIMEZONE 'UTC' -RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev \ +RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libldap2-dev zlib1g-dev libicu-dev g++\ && rm -rf /var/lib/apt/lists/* \ && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-install gd \ && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ && docker-php-ext-install ldap \ && docker-php-ext-install mysqli \ - && apt-get purge -y libjpeg-dev libldap2-dev + && docker-php-ext-install calendar \ + && docker-php-ext-configure intl \ + && docker-php-ext-install intl \ + && apt-get autoremove --purge -y libjpeg-dev libldap2-dev zlib1g-dev libicu-dev g++ + +RUN mkdir /var/documents +RUN chown www-data /var/documents COPY docker-run.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-run.sh -RUN pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug +RUN pecl install xdebug && docker-php-ext-enable xdebug RUN echo 'zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_autostart=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_enable=1' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.default_enable=0' >> /usr/local/etc/php/php.ini -RUN echo 'xdebug.remote_host=docker.for.mac.host.internal' >> /usr/local/etc/php/php.ini +RUN echo 'xdebug.remote_host=docker.host' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_port=9000' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_connect_back=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.profiler_enable=0' >> /usr/local/etc/php/php.ini RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> /usr/local/etc/php/php.ini - +RUN echo '172.17.0.1 docker.host' >> /etc/hosts EXPOSE 80 diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index a2017335197..3fe6125a874 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -1,5 +1,5 @@ mariadb: - image: mariadb:latest + build: mariadb environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: dolibarr diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh index c151e1c3cab..df7272c317d 100644 --- a/build/docker/docker-run.sh +++ b/build/docker/docker-run.sh @@ -3,7 +3,8 @@ usermod -u $HOST_USER_ID www-data groupmod -g $HOST_USER_ID www-data -chown -hR www-data:www-data /var/www +chgrp -hR www-data /var/www/html +chmod g+rwx /var/www/html/conf if [ ! -f /usr/local/etc/php/php.ini ]; then cat < /usr/local/etc/php/php.ini diff --git a/build/docker/mariadb/Dockerfile b/build/docker/mariadb/Dockerfile new file mode 100644 index 00000000000..a4db0f42065 --- /dev/null +++ b/build/docker/mariadb/Dockerfile @@ -0,0 +1,3 @@ +FROM mariadb:latest +# Enable comented out UTF8 charset/collation options +RUN sed '/utf8/ s/^#//' /etc/mysql/mariadb.cnf >/tmp/t && mv /tmp/t /etc/mysql/mariadb.cnf From e078bc6f83ac57e938bb47db971142ee1d7a9ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 10 Dec 2019 08:08:56 +0100 Subject: [PATCH 238/248] doxygen --- .../fourn/class/fournisseur.facture.class.php | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7ec271c84ec..dba7392a9e4 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2804,15 +2804,70 @@ class SupplierInvoiceLine extends CommonObjectLine */ public $fk_prev_id; + /** + * VAT code + * @var string + */ + public $vat_src_code; + + /** + * VAT % + * @var float + */ public $tva_tx; + + /** + * Local tax 1 % + * @var float + */ public $localtax1_tx; + + /** + * Local tax 2 % + * @var float + */ public $localtax2_tx; + + /** + * Quantity + * @var double + */ public $qty; + + /** + * Percent of discount + * @var float + */ public $remise_percent; + + /** + * Total amount without taxes + * @var float + */ public $total_ht; + + /** + * Total amount with taxes + * @var float + */ public $total_ttc; + + /** + * Total amount of taxes + * @var float + */ public $total_tva; + + /** + * Total local tax 1 amount + * @var float + */ public $total_localtax1; + + /** + * Total local tax 2 amount + * @var float + */ public $total_localtax2; /** @@ -2820,8 +2875,24 @@ class SupplierInvoiceLine extends CommonObjectLine */ public $fk_product; + /** + * Type of the product. 0 for product 1 for service + * @var int + */ public $product_type; + + /** + * Label of the product + * @var string + */ public $product_label; + + /** + * List of cumulative options: + * Bit 0: 0 si TVA normal - 1 si TVA NPR + * Bit 1: 0 si ligne normal - 1 si bit discount (link to line into llx_remise_except) + * @var int + */ public $info_bits; /** @@ -2830,8 +2901,22 @@ class SupplierInvoiceLine extends CommonObjectLine public $fk_parent_line; public $special_code; + + /** + * @var int rank of line + */ public $rang; + + /** + * Total local tax 1 amount + * @var float + */ public $localtax1_type; + + /** + * Total local tax 2 amount + * @var float + */ public $localtax2_type; // Multicurrency From 2d97c0bb7964b14dc2ae64a693d4087b54ff5339 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Dec 2019 13:55:45 +0100 Subject: [PATCH 239/248] Try better fix for #12674 --- htdocs/compta/tva/clients.php | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index d1c0897d1e0..2c5c1dc3745 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -43,11 +43,16 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); + +$now = dol_now(); +$current_date = dol_getdate($now); +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; + // Date range $year = GETPOST("year", "int"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = $current_date['year']; $year_start = $year_current; } else { $year_current = $year; @@ -64,10 +69,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end 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); } 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) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + 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'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $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; + } + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } } } else From fe44d3a4fa6cf8a35f20e4f4354b3c30343562b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Dec 2019 14:02:03 +0100 Subject: [PATCH 240/248] FIX #12674 --- htdocs/compta/tva/clients.php | 4 ++-- htdocs/compta/tva/index.php | 31 +++++++++++++++++++++++---- htdocs/compta/tva/quadri_detail.php | 33 +++++++++++++++++++++++------ 3 files changed, 56 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index 2c5c1dc3745..fc91c6b9877 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -60,10 +60,10 @@ if (empty($year)) } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); -// Quarter +// Set default period if not defined if (empty($date_start) || empty($date_end)) // We define date_start and date_end { - $q = GETPOST("q"); + $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); } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 55a340d7682..8fbf5b1b0fa 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -35,12 +35,15 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); +$now = dol_now(); +$current_date = dol_getdate($now); +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; + // Date range $year = GETPOST("year", "int"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); - if ($conf->global->SOCIETE_FISCAL_MONTH_START > date('m')) $year_current--; + $year_current = $current_date['year']; $year_start = $year_current; } else { $year_current = $year; @@ -48,6 +51,7 @@ if (empty($year)) } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +// Set default period if not defined if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q = GETPOST("q", "int"); @@ -56,8 +60,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end 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); } 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; + 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'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $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; + } + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } } } else diff --git a/htdocs/compta/tva/quadri_detail.php b/htdocs/compta/tva/quadri_detail.php index db461c4e790..0309139d3d5 100644 --- a/htdocs/compta/tva/quadri_detail.php +++ b/htdocs/compta/tva/quadri_detail.php @@ -44,11 +44,15 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class. // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); +$now = dol_now(); +$current_date = dol_getdate($now); +if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; + // Date range $year = GETPOST("year", "int"); if (empty($year)) { - $year_current = strftime("%Y", dol_now()); + $year_current = $current_date['year']; $year_start = $year_current; } else { $year_current = $year; @@ -56,7 +60,7 @@ if (empty($year)) } $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); -// Quarter +// Set default period if not defined if (empty($date_start) || empty($date_end)) // We define date_start and date_end { $q = GETPOST("q", "int"); @@ -65,10 +69,27 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end 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); } 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) $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) $date_end = dol_time_plus_duree($date_start, 1, 'y') - 1; - elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + 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'); + $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; + } + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 3) { // yearly vat + if ($current_date['mon'] < $conf->global->SOCIETE_FISCAL_MONTH_START) { + if (($conf->global->SOCIETE_FISCAL_MONTH_START - $current_date['mon']) > 6) { // If period started from less than 6 years, we show past year + $year_start--; + } + } else { + if (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) < 6) { // If perdio started from less than 6 years, we show past year + $year_start--; + } + } + $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; + } + elseif ($conf->global->MAIN_INFO_VAT_RETURN == 1) { // monthly vat, we take last past complete month + $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -1, 'm'); + $date_end = dol_time_plus_duree($date_start, 1, 'm') - 1; + } } } else From 738526e77e84cb863e1f6c07ef8f78da69ef1f0d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Dec 2019 14:04:50 +0100 Subject: [PATCH 241/248] Fix br --- htdocs/compta/tva/clients.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/clients.php b/htdocs/compta/tva/clients.php index fc91c6b9877..d6ed2bf054a 100644 --- a/htdocs/compta/tva/clients.php +++ b/htdocs/compta/tva/clients.php @@ -188,7 +188,7 @@ if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) { if (!empty($conf->global->MAIN_MODULE_ACCOUNTING)) $description .= '
'.$langs->trans("ThisIsAnEstimatedValue"); //$periodlink=($year_start?"".img_previous()." ".img_next()."":""); -$description .= $fsearch; +$description .= ($description ? '
' : '').$fsearch; if (!empty($conf->global->TAX_REPORT_EXTRA_REPORT)) { $description .= '
' From 4c463cdbb52e303cfba0e6beb579d18421b851ba Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2019 16:16:33 +0100 Subject: [PATCH 242/248] FIX: propal update Update fields 'date' and 'fin_validite' --- htdocs/comm/propal/class/propal.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index f654ed932b7..139b88d5dda 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1544,6 +1544,7 @@ class Propal extends CommonObject if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); if (isset($this->import_key)) $this->import_key = trim($this->import_key); + if (isset($this->duree_validite)) $this->fin_validite=$this->date + ($this->duree_validite * 24 * 3600); // Check parameters // Put here code to add control on parameters values @@ -1555,7 +1556,8 @@ class Propal extends CommonObject $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; - $sql .= " datep=".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " datep=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').","; + $sql .= " fin_validite=".(strval($this->fin_validite)!='' ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; From 452976850f202612e88cddb4e714fb4899420e3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Dec 2019 19:18:45 +0100 Subject: [PATCH 243/248] Update propal.class.php --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 139b88d5dda..17fcbfb18cd 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1544,7 +1544,7 @@ class Propal extends CommonObject if (isset($this->note_public)) $this->note_public = trim($this->note_public); if (isset($this->modelpdf)) $this->modelpdf = trim($this->modelpdf); if (isset($this->import_key)) $this->import_key = trim($this->import_key); - if (isset($this->duree_validite)) $this->fin_validite=$this->date + ($this->duree_validite * 24 * 3600); + if (! empty($this->duree_validite)) $this->fin_validite=$this->date + ($this->duree_validite * 24 * 3600); // Check parameters // Put here code to add control on parameters values From f98713efdd8ffad6564fd6761e799bd11219f8d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Dec 2019 19:20:23 +0100 Subject: [PATCH 244/248] Update propal.class.php --- htdocs/comm/propal/class/propal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 17fcbfb18cd..d421e7bc344 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1557,7 +1557,7 @@ class Propal extends CommonObject $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; $sql .= " fk_soc=".(isset($this->socid) ? $this->socid : "null").","; $sql .= " datep=".(strval($this->date) != '' ? "'".$this->db->idate($this->date)."'" : 'null').","; - $sql .= " fin_validite=".(strval($this->fin_validite)!='' ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; + if (! empty($this->fin_validite)) $sql .= " fin_validite=".(strval($this->fin_validite)!='' ? "'".$this->db->idate($this->fin_validite)."'" : 'null').","; $sql .= " date_valid=".(strval($this->date_validation) != '' ? "'".$this->db->idate($this->date_validation)."'" : 'null').","; $sql .= " tva=".(isset($this->total_tva) ? $this->total_tva : "null").","; $sql .= " localtax1=".(isset($this->total_localtax1) ? $this->total_localtax1 : "null").","; From 63b965646864a778083145e1891d767ef531b9ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Dec 2019 17:05:42 +0100 Subject: [PATCH 245/248] Fix use of currency accuracy --- htdocs/margin/agentMargins.php | 12 +++++------- htdocs/margin/customerMargins.php | 12 +++++------- htdocs/margin/productMargins.php | 27 +++++++++++++-------------- htdocs/product/price.php | 3 ++- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index a47acb63eec..f65acb2eeda 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -223,8 +223,6 @@ if ($result) print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); print "\n"; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - if ($num > 0) { $group_list = array(); @@ -291,13 +289,13 @@ if ($result) print '
'; print "\n"; - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; } } diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 149464ceb2f..d54eee43056 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -277,8 +277,6 @@ if ($result) $cumul_achat = 0; $cumul_vente = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - if ($num > 0) { while ($i < $num /*&& $i < $conf->liste_limit*/) @@ -317,13 +315,13 @@ if ($result) print "\n"; } - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; $i++; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 66f42475548..cc6f7fe0ed9 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -252,7 +252,6 @@ if ($result) $cumul_achat = 0; $cumul_vente = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) { @@ -303,13 +302,13 @@ if ($result) print "\n"; //print "\n"; } - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; $i++; @@ -331,13 +330,13 @@ if ($result) else print '"; - print "\n"; - print "\n"; - print "\n"; + print "\n"; + print "\n"; + print "\n"; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "\n"; + print "\n"; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "\n"; + print "\n"; print "\n"; print "
TODO...
'.$langs->trans("Service").''.$obj->country.''; + print $langs->trans("Country".$obj->code) != "Country".$obj->code ? $langs->trans("Country".$obj->code) : $obj->country; + print ''.$langs->trans("Service").''.$obj->country.''; + print $langs->trans("Country".$obj->code) != "Country".$obj->code ? $langs->trans("Country".$obj->code) : $obj->country; + print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'.$langs->trans("None").'
'.$langs->trans("None").'
TODO...
".$group_array['htmlname']."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".price(price2num($pv, 'MT'))."".price(price2num($pa, 'MT'))."".price(price2num($marge, 'MT'))."".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '')?'n/a':price(price2num($marginRate, 'MT'))."%")."".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '')?'n/a':price(price2num($markRate, 'MT'))."%")."
".$companystatic->getNomUrl(1, 'margin')."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".price(price2num($pv, 'MT'))."".price(price2num($pa, 'MT'))."".price(price2num($marge, 'MT'))."".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."
".$product_static->getNomUrl(1)."".price($pv, null, null, null, null, $rounding)."".price($pa, null, null, null, null, $rounding)."".price($marge, null, null, null, null, $rounding)."".price(price2num($pv, 'MT'))."".price(price2num($pa, 'MT'))."".price(price2num($marge, 'MT'))."".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."
'; print $langs->trans('TotalMargin')."".price($cumul_vente, null, null, null, null, $rounding)."".price($cumul_achat, null, null, null, null, $rounding)."".price($totalMargin, null, null, null, null, $rounding)."".price(price2num($cumul_vente, 'MT'))."".price(price2num($cumul_achat, 'MT'))."".price(price2num($totalMargin, 'MT'))."".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."
"; @@ -358,9 +357,9 @@ $(document).ready(function() { $("div.fiche form").submit(); }); - $("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'"); - $("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%").'"); - $("#markRate").html("'.(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%").'"); + $("#totalMargin").html("'.price(price2num($totalMargin, 'MT')).'"); + $("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'"); + $("#markRate").html("'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'"); }); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index c02f2149de0..c102e89898c 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1350,7 +1350,8 @@ if ($action == 'edit_price' && $object->getRights()->creer) { print ''; print ''; - print $form->textwithpicto($langs->trans('SellingPrice').' '.$i, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); + $text = $langs->trans('SellingPrice').' '.$i; + print $form->textwithpicto($text, $langs->trans("PrecisionUnitIsLimitedToXDecimals", $conf->global->MAIN_MAX_DECIMALS_UNIT), 1, 1); print ''; // VAT From 0b73cdb7ccb8a4d9b4860cd00b9dac5cc5426d63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Dec 2019 17:14:32 +0100 Subject: [PATCH 246/248] Fix use of currency accuracy --- htdocs/core/tpl/objectline_view.tpl.php | 6 ++--- htdocs/margin/tabs/productMargins.php | 31 ++++++++++++------------ htdocs/margin/tabs/thirdpartyMargins.php | 28 ++++++++++----------- 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 5b85887fc20..2c1b5085e89 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -243,8 +243,6 @@ if (!empty($line->remise_percent) && $line->special_code != 3) { $coldisplay++; } -$rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - // Fields for situation invoices if ($this->situation_cycle_ref) { @@ -263,10 +261,10 @@ if ($usemargins && ! empty($conf->margin->enabled) && empty($user->socid)) pa_ht); ?> global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> - pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?> + pa_ht == 0)?'n/a':price(price2num($line->marge_tx, 'MT')).'%'); ?> global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> - marque_tx, null, null, null, null, $rounding).'%'; ?> + marque_tx, 'MT')).'%'; ?> special_code == 3) { ?> diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index dcb15ea27db..3b53cea29d2 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -188,7 +188,6 @@ if ($id > 0 || !empty($ref)) $cumul_achat = 0; $cumul_vente = 0; $cumul_qty = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); if ($num > 0) { while ($i < $num /*&& $i < $conf->liste_limit*/) { @@ -207,14 +206,14 @@ if ($id > 0 || !empty($ref)) print "".$objp->code_client."\n"; print ""; print dol_print_date($db->jdate($objp->datef), 'day').""; - print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; - print "".price($objp->buying_price, null, null, null, null, $rounding)."\n"; - print "".price($objp->qty, null, null, null, null, $rounding)."\n"; - print "".price($objp->marge, null, null, null, null, $rounding)."\n"; + print "".price(price2num($objp->selling_price, 'MT'))."\n"; + print "".price(price2num($objp->buying_price, 'MT'))."\n"; + print "".price(price2num($objp->qty, 'MT'))."\n"; + print "".price(price2num($objp->marge, 'MT'))."\n"; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; @@ -239,14 +238,14 @@ if ($id > 0 || !empty($ref)) } print ''; print ''.$langs->trans('TotalMargin').""; - print ''.price($cumul_vente, null, null, null, null, $rounding)."\n"; - print ''.price($cumul_achat, null, null, null, null, $rounding)."\n"; - print ''.price($cumul_qty, null, null, null, null, $rounding)."\n"; - print ''.price($totalMargin, null, null, null, null, $rounding)."\n"; + print ''.price(price2num($cumul_vente, 'MT'))."\n"; + print ''.price(price2num($cumul_achat, 'MT'))."\n"; + print ''.price(price2num($cumul_qty, 'MT'))."\n"; + print ''.price(price2num($totalMargin, 'MT'))."\n"; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print ''.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."\n"; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; print ' '; print "\n"; print ""; @@ -264,9 +263,9 @@ if ($id > 0 || !empty($ref)) print ' '; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index 1edd5349467..0b4ab1b2da2 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -192,8 +192,6 @@ if ($socid > 0) $cumul_achat = 0; $cumul_vente = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); - if ($num > 0) { while ($i < $num /*&& $i < $conf->liste_limit*/) @@ -216,13 +214,13 @@ if ($socid > 0) print "\n"; print ""; print dol_print_date($db->jdate($objp->datef), 'day').""; - print "".price($objp->selling_price, null, null, null, null, $rounding)."\n"; - print "".price(($objp->type == 2 ? -1 : 1) * $objp->buying_price, null, null, null, null, $rounding)."\n"; - print "".$sign.price($objp->marge, null, null, null, null, $rounding)."\n"; + print "".price(price2num($objp->selling_price, 'MT'))."\n"; + print "".price(price2num(($objp->type == 2 ? -1 : 1) * $objp->buying_price, 'MT'))."\n"; + print "".$sign.price(price2num($objp->marge, 'MT'))."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':$sign.price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':$sign.price(price2num($marginRate, 'MT'))."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($markRate === '')?'n/a':price(price2num($markRate, 'MT'))."%")."\n"; print ''.$invoicestatic->LibStatut($objp->paye, $objp->statut, 5).''; print "\n"; $i++; @@ -248,13 +246,13 @@ if ($socid > 0) // Total print ''; print ''.$langs->trans('TotalMargin').""; - print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; - print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; - print "".price($totalMargin, null, null, null, null, $rounding)."\n"; + print "".price(price2num($cumul_vente, 'MT'))."\n"; + print "".price(price2num($cumul_achat, 'MT'))."\n"; + print "".price(price2num($totalMargin, 'MT'))."\n"; if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '')?'n/a':price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($marginRate === '')?'n/a':price(price2num($marginRate, 'MT'))."%")."\n"; if (! empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '')?'n/a':price($markRate, null, null, null, null, $rounding)."%")."\n"; + print "".(($markRate === '')?'n/a':price(price2num($markRate, 'MT'))."%")."\n"; print ' '; print "\n"; } @@ -277,9 +275,9 @@ else print ' '; From 6f4e2e7e611cca0df6770e9018ae10ad9889e5f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Dec 2019 17:58:14 +0100 Subject: [PATCH 247/248] Fix rounding with multicurrency --- htdocs/core/lib/price.lib.php | 36 ++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index f4efd0c0ee9..d95acc75718 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -51,6 +51,7 @@ * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param double $multicurrency_tx Currency rate (1 by default) * @param double $pu_devise Amount in currency + * @param string $multicurrency_code Value of the foreign currency if multicurrency is used ('EUR', 'USD', ...). It will be used for rounding according to currency. * @return array [ * 0=total_ht, * 1=total_vat, (main vat only) @@ -82,7 +83,7 @@ * 25=multicurrency_total_tax1 for total_ht * 26=multicurrency_total_tax2 for total_ht */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = '', $progress = 100, $multicurrency_tx = 1, $pu_devise = 0) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array = '', $progress = 100, $multicurrency_tx = 1, $pu_devise = 0, $multicurrency_code = '') { global $conf,$mysoc,$db; @@ -185,7 +186,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // if there's some localtax including vat, we calculate localtaxes (we will add later) - //If input unit price is 'HT', we need to have the totals with main VAT for a correct calculation + // if input unit price is 'HT', we need to have the totals with main VAT for a correct calculation if ($price_base_type != 'TTC') { $tot_sans_remise_wt = price2num($tot_sans_remise * (1 + ($txtva / 100)), 'MU'); @@ -367,8 +368,31 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt // Multicurrency if ($multicurrency_tx != 1) { + if ($multicurrency_code) { + $savMAIN_MAX_DECIMALS_UNIT = $conf->global->MAIN_MAX_DECIMALS_UNIT; + $savMAIN_MAX_DECIMALS_TOT = $conf->global->MAIN_MAX_DECIMALS_TOT; + $savMAIN_ROUNDING_RULE_TOT = $conf->global->MAIN_ROUNDING_RULE_TOT; + + // Set parameter for currency accurency according to the value of $multicurrency_code (this is because a foreign currency may have different rounding rules) + $keyforforeignMAIN_MAX_DECIMALS_UNIT = 'MAIN_MAX_DECIMALS_UNIT_'.$multicurrency_code; + $keyforforeignMAIN_MAX_DECIMALS_TOT = 'MAIN_MAX_DECIMALS_TOT_'.$multicurrency_code; + $keyforforeignMAIN_ROUNDING_RULE_TOT = 'MAIN_ROUNDING_RULE_TOT_'.$multicurrency_code; + if (! empty($conf->global->$keyforforeignMAIN_ROUNDING_RULE_TOT)) { + $conf->global->MAIN_MAX_DECIMALS_UNIT = $keyforforeignMAIN_MAX_DECIMALS_UNIT; + $conf->global->MAIN_MAX_DECIMALS_TOT = $keyforforeignMAIN_MAX_DECIMALS_TOT; + $conf->global->MAIN_ROUNDING_RULE_TOT = $keyforforeignMAIN_ROUNDING_RULE_TOT; + } + } + // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. - $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0, ''); + + if ($multicurrency_code) { + // Restore setup of currency accurency + $conf->global->MAIN_MAX_DECIMALS_UNIT = $savMAIN_MAX_DECIMALS_UNIT; + $conf->global->MAIN_MAX_DECIMALS_TOT = $savMAIN_MAX_DECIMALS_TOT; + $conf->global->MAIN_ROUNDING_RULE_TOT = $savMAIN_ROUNDING_RULE_TOT; + } $result[16] = $newresult[0]; $result[17] = $newresult[1]; @@ -381,12 +405,6 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[24] = $newresult[8]; $result[25] = $newresult[9]; $result[26] = $newresult[10]; - /* - $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); - $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); - $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); - $result[19] = price2num($pu_devise, 'MU'); - */ } else { From 54543808348950edf2627af37760735ae8ec1d75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 11 Dec 2019 19:14:41 +0100 Subject: [PATCH 248/248] CSS --- htdocs/compta/bank/bankentries_list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index eeb662c6168..59a602fa706 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -93,7 +93,6 @@ $search_req_nb = GETPOST("req_nb", 'alpha'); $search_num_releve = GETPOST("search_num_releve", 'alpha'); $search_conciliated = GETPOST("search_conciliated", 'int'); $num_releve = GETPOST("num_releve", "alpha"); -$cat = GETPOST("cat"); if (empty($dateop)) $dateop = -1; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -420,6 +419,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $options = array(); $buttonreconcile = ''; +$morehtmlref = ''; if ($id > 0 || !empty($ref)) { @@ -458,9 +458,9 @@ if ($id > 0 || !empty($ref)) if ($user->rights->banque->consolidate) { $newparam = $param; $newparam = preg_replace('/search_conciliated=\d+/i', '', $newparam); - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $buttonreconcile = ''.$langs->trans("Conciliate").''; } else { - $buttonreconcile = ''.$langs->trans("Conciliate").''; + $buttonreconcile = ''.$langs->trans("Conciliate").''; } } }