Passed
Push — master ( 7e4a07...284492 )
by Alxarafe
19:58
created
Helpers/AlixarDispatcher.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
          * Copyright (C) 2018 Alxarafe <[email protected]>
36 36
          */
37 37
 
38
-        define('DOL_BASE_PATH', BASE_PATH . '/dolibarr/htdocs');
39
-        define('DOL_BASE_URI', BASE_URI . '/dolibarr/htdocs');
38
+        define('DOL_BASE_PATH', BASE_PATH.'/dolibarr/htdocs');
39
+        define('DOL_BASE_URI', BASE_URI.'/dolibarr/htdocs');
40 40
         define('DOL_DOCUMENT_ROOT', DOL_BASE_PATH);
41 41
 
42 42
         define('CORE_FOLDER', '/core');
@@ -50,15 +50,15 @@  discard block
 block discarded – undo
50 50
         define('CACHE_FOLDER', '/../cache');
51 51
         //define('VENDOR_FOLDER', BASE_URI . '/vendor');
52 52
 
53
-        define('CORE_PATH', BASE_PATH . CORE_FOLDER);
54
-        define('CONFIG_PATH', BASE_PATH . CONFIG_FOLDER);
55
-        define('CONTROLLERS_PATH', BASE_PATH . CONTROLLERS_FOLDER);
56
-        define('HELPERS_PATH', BASE_PATH . HELPERS_FOLDER);
57
-        define('MODELS_PATH', BASE_PATH . MODELS_FOLDER);
58
-        define('SKINS_PATH', BASE_PATH . SKINS_FOLDER);
59
-        define('TEMPLATES_PATH', BASE_PATH . TEMPLATES_FOLDER);
60
-        define('PLUGINS_PATH', BASE_PATH . PLUGINS_FOLDER);
61
-        define('CACHE_PATH', BASE_PATH . CACHE_FOLDER);
53
+        define('CORE_PATH', BASE_PATH.CORE_FOLDER);
54
+        define('CONFIG_PATH', BASE_PATH.CONFIG_FOLDER);
55
+        define('CONTROLLERS_PATH', BASE_PATH.CONTROLLERS_FOLDER);
56
+        define('HELPERS_PATH', BASE_PATH.HELPERS_FOLDER);
57
+        define('MODELS_PATH', BASE_PATH.MODELS_FOLDER);
58
+        define('SKINS_PATH', BASE_PATH.SKINS_FOLDER);
59
+        define('TEMPLATES_PATH', BASE_PATH.TEMPLATES_FOLDER);
60
+        define('PLUGINS_PATH', BASE_PATH.PLUGINS_FOLDER);
61
+        define('CACHE_PATH', BASE_PATH.CACHE_FOLDER);
62 62
         //define('VENDOR_PATH', BASE_PATH . VENDOR_FOLDER);
63 63
 
64 64
         /**
Please login to merge, or discard this patch.
Helpers/Request.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@  discard block
 block discarded – undo
25 25
 {
26 26
 
27 27
     // Filters
28
-    const NO_CHECK = 0;             // 'none'=no check (only for param that should have very rich content)
29
-    const NUMERIC = 1;              // 'int'=check it's numeric (integer or float)
30
-    const NUMBER_COMMA = 2;         // 'intcomma'=check it's integer+comma ('1,2,3,4...')
31
-    const ALPHA = 3;                // 'alpha'=check it's text and sign
32
-    const LETTERS_ONLY = 4;         // 'aZ'=check it's a-z only
33
-    const LETTERS_AND_NUMBERS = 5;  // 'aZ09'=check it's simple alpha string (recommended for keys)
34
-    const AN_ARRAY = 6;             // 'array'=check it's array
35
-    const SANITIZE = 7;             // 'san_alpha' = Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string)
36
-    const NO_HTML = 8;              // 'nohtml', 'alphanohtml' = check there is no html content
37
-    const ALPHA_NO_HTML = 9;              // 'nohtml', 'alphanohtml' = check there is no html content
38
-    const CUSTOM = 10;               // 'custom' = custom filter specify $filter and $options)
28
+    const NO_CHECK = 0; // 'none'=no check (only for param that should have very rich content)
29
+    const NUMERIC = 1; // 'int'=check it's numeric (integer or float)
30
+    const NUMBER_COMMA = 2; // 'intcomma'=check it's integer+comma ('1,2,3,4...')
31
+    const ALPHA = 3; // 'alpha'=check it's text and sign
32
+    const LETTERS_ONLY = 4; // 'aZ'=check it's a-z only
33
+    const LETTERS_AND_NUMBERS = 5; // 'aZ09'=check it's simple alpha string (recommended for keys)
34
+    const AN_ARRAY = 6; // 'array'=check it's array
35
+    const SANITIZE = 7; // 'san_alpha' = Use filter_var with FILTER_SANITIZE_STRING (do not use this for free text string)
36
+    const NO_HTML = 8; // 'nohtml', 'alphanohtml' = check there is no html content
37
+    const ALPHA_NO_HTML = 9; // 'nohtml', 'alphanohtml' = check there is no html content
38
+    const CUSTOM = 10; // 'custom' = custom filter specify $filter and $options)
39 39
 
40 40
     public static function get(string $variable, array $methods = [INPUT_GET, INPUT_POST], int $filter = NO_CHECK): string
41 41
     {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         if (empty($paramname))
178 178
             return 'BadFirstParameterForGETPOST';
179 179
         if (empty($check)) {
180
-            dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
180
+            dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
181 181
 // Enable this line to know who call the GETPOST with '' $check parameter.
182 182
 //var_dump(debug_backtrace()[0]);
183 183
         }
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             $relativepathstring = $_SERVER["PHP_SELF"];
200 200
 // Clean $relativepathstring
201 201
             if (constant('DOL_URL_ROOT'))
202
-                $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
202
+                $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
203 203
             $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
204 204
             $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
205 205
 //var_dump($relativepathstring);
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 // Code for search criteria persistence.
208 208
 // Retrieve values if restore_lastsearch_values
209 209
             if (!empty($_GET['restore_lastsearch_values'])) {        // Use $_GET here and not GETPOST
210
-                if (!empty($_SESSION['lastsearch_values_' . $relativepathstring])) { // If there is saved values
211
-                    $tmp = json_decode($_SESSION['lastsearch_values_' . $relativepathstring], true);
210
+                if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) { // If there is saved values
211
+                    $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
212 212
                     if (is_array($tmp)) {
213 213
                         foreach ($tmp as $key => $val) {
214 214
                             if ($key == $paramname) { // We are on the requested parameter
@@ -219,12 +219,12 @@  discard block
 block discarded – undo
219 219
                     }
220 220
                 }
221 221
 // If there is saved contextpage, page or limit
222
-                if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_' . $relativepathstring])) {
223
-                    $out = $_SESSION['lastsearch_contextpage_' . $relativepathstring];
224
-                } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_' . $relativepathstring])) {
225
-                    $out = $_SESSION['lastsearch_page_' . $relativepathstring];
226
-                } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_' . $relativepathstring])) {
227
-                    $out = $_SESSION['lastsearch_limit_' . $relativepathstring];
222
+                if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) {
223
+                    $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
224
+                } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) {
225
+                    $out = $_SESSION['lastsearch_page_'.$relativepathstring];
226
+                } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) {
227
+                    $out = $_SESSION['lastsearch_limit_'.$relativepathstring];
228 228
                 }
229 229
             }
230 230
 // Else, retreive default values if we are not doing a sort
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                                             $qualified = 1;
293 293
 
294 294
                                         if ($qualified) {
295
-                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
295
+                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
296 296
                                             foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
297 297
                                                 if ($out)
298 298
                                                     $out .= ', ';
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
                                         if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
329 329
 // We made a search from quick search menu, do we still use default filter ?
330 330
                                             if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
331
-                                                $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
331
+                                                $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
332 332
                                                 $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
333 333
                                             }
334 334
                                         } else {
335
-                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
335
+                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
336 336
                                             $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
337 337
                                         }
338 338
                                         break;
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
351 351
         if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
352 352
             $maxloop = 20;
353
-            $loopnb = 0;    // Protection against infinite loop
353
+            $loopnb = 0; // Protection against infinite loop
354 354
             while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {    // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
355 355
                 $loopnb++;
356 356
                 $newout = '';
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
                 } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
396 396
                     $newout = $conf->entity;
397 397
                 } else
398
-                    $newout = '';     // Key not found, we replace with empty string
398
+                    $newout = ''; // Key not found, we replace with empty string
399 399
 //var_dump('__'.$reg[1].'__ -> '.$newout);
400
-                $out = preg_replace('/__' . preg_quote($reg[1], '/') . '__/', $newout, $out);
400
+                $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out);
401 401
             }
402 402
         }
403 403
 
Please login to merge, or discard this patch.
dolibarr/htdocs/comm/action/index.php 2 patches
Spacing   +200 added lines, -200 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
  *  \ingroup    agenda
33 33
  *  \brief      Home page of calendar events
34 34
  */
35
-require DOL_BASE_PATH . '/main.inc.php';
35
+require DOL_BASE_PATH.'/main.inc.php';
36 36
 
37
-require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
38
-require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
39
-require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
40
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
41
-require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php';
37
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
38
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
39
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
40
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
41
+require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
42 42
 if (!empty($conf->projet->enabled)) {
43
-    require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
43
+    require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
44 44
 }
45 45
 
46 46
 if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW))
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 $week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W");
98 98
 $day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d");
99 99
 $pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3);
100
-$status = GETPOST("search_status", 'aZ09') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09');  // status may be 0, 50, 100, 'todo'
100
+$status = GETPOST("search_status", 'aZ09') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo'
101 101
 $type = GETPOST("search_type", 'az09') ? GETPOST("search_type", 'az09') : GETPOST("type", 'az09');
102 102
 $maxprint = (isset($_GET["maxprint"]) ? GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
103 103
 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
         foreach ($_POST as $key => $val) {
153 153
             if ($key == 'token')
154 154
                 continue;
155
-            $param .= '&' . $key . '=' . urlencode($val);
155
+            $param .= '&'.$key.'='.urlencode($val);
156 156
         }
157 157
     }
158 158
     //print $param;
159
-    header("Location: " . BASE_URI . '?controller=comm/action&method=list' . $param);
159
+    header("Location: ".BASE_URI.'?controller=comm/action&method=list'.$param);
160 160
     exit;
161 161
 }
162 162
 
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
         foreach ($_POST as $key => $val) {
167 167
             if ($key == 'token')
168 168
                 continue;
169
-            $param .= '&' . $key . '=' . urlencode($val);
169
+            $param .= '&'.$key.'='.urlencode($val);
170 170
         }
171 171
     }
172 172
     //print $param;
173
-    header("Location: " . BASE_URI . '?controller=comm/action&method=peruser' . $param);
173
+    header("Location: ".BASE_URI.'?controller=comm/action&method=peruser'.$param);
174 174
     exit;
175 175
 }
176 176
 
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
     $i = 0;
206 206
     while ($i < $MAXAGENDA) {
207 207
         $i++;
208
-        $source = 'AGENDA_EXT_SRC' . $i;
209
-        $name = 'AGENDA_EXT_NAME' . $i;
210
-        $offsettz = 'AGENDA_EXT_OFFSETTZ' . $i;
211
-        $color = 'AGENDA_EXT_COLOR' . $i;
212
-        $buggedfile = 'AGENDA_EXT_BUGGEDFILE' . $i;
208
+        $source = 'AGENDA_EXT_SRC'.$i;
209
+        $name = 'AGENDA_EXT_NAME'.$i;
210
+        $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
211
+        $color = 'AGENDA_EXT_COLOR'.$i;
212
+        $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
213 213
         if (!empty($conf->global->$source) && !empty($conf->global->$name)) {
214 214
             // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
215 215
             $listofextcals[] = array('src' => $conf->global->$source, 'name' => $conf->global->$name, 'offsettz' => $conf->global->$offsettz, 'color' => $conf->global->$color, 'buggedfile' => (isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
     $i = 0;
222 222
     while ($i < $MAXAGENDA) {
223 223
         $i++;
224
-        $source = 'AGENDA_EXT_SRC_' . $user->id . '_' . $i;
225
-        $name = 'AGENDA_EXT_NAME_' . $user->id . '_' . $i;
226
-        $offsettz = 'AGENDA_EXT_OFFSETTZ_' . $user->id . '_' . $i;
227
-        $color = 'AGENDA_EXT_COLOR_' . $user->id . '_' . $i;
228
-        $enabled = 'AGENDA_EXT_ENABLED_' . $user->id . '_' . $i;
229
-        $buggedfile = 'AGENDA_EXT_BUGGEDFILE_' . $user->id . '_' . $i;
224
+        $source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i;
225
+        $name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i;
226
+        $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
227
+        $color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i;
228
+        $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i;
229
+        $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i;
230 230
         if (!empty($user->conf->$source) && !empty($user->conf->$name)) {
231 231
             // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
232 232
             $listofextcals[] = array('src' => $user->conf->$source, 'name' => $user->conf->$name, 'offsettz' => $user->conf->$offsettz, 'color' => $user->conf->$color, 'buggedfile' => (isset($user->conf->buggedfile) ? $user->conf->buggedfile : 0));
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
     $next_year = $next['year'];
243 243
     $next_month = $next['month'];
244 244
 
245
-    $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year));  // Nb of days in previous month
246
-    $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));                 // Nb of days in next month
245
+    $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month
246
+    $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
247 247
     // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
248
-    $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2;  // date('w') is 0 fo sunday
248
+    $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday
249 249
     $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
250 250
     if ($tmpday >= 1)
251 251
         $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
@@ -312,60 +312,60 @@  discard block
 block discarded – undo
312 312
 if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) {
313 313
     if (is_array($actioncode)) {
314 314
         foreach ($actioncode as $str_action)
315
-            $param .= "&search_actioncode[]=" . urlencode($str_action);
315
+            $param .= "&search_actioncode[]=".urlencode($str_action);
316 316
     } else
317
-        $param .= "&search_actioncode=" . urlencode($actioncode);
317
+        $param .= "&search_actioncode=".urlencode($actioncode);
318 318
 }
319 319
 if ($resourceid > 0)
320
-    $param .= "&search_resourceid=" . urlencode($resourceid);
320
+    $param .= "&search_resourceid=".urlencode($resourceid);
321 321
 if ($status || isset($_GET['status']) || isset($_POST['status']))
322
-    $param .= "&search_status=" . urlencode($status);
322
+    $param .= "&search_status=".urlencode($status);
323 323
 if ($filter)
324
-    $param .= "&search_filter=" . urlencode($filter);
324
+    $param .= "&search_filter=".urlencode($filter);
325 325
 if ($filtert)
326
-    $param .= "&search_filtert=" . urlencode($filtert);
326
+    $param .= "&search_filtert=".urlencode($filtert);
327 327
 if ($usergroup)
328
-    $param .= "&search_usergroup=" . urlencode($usergroup);
328
+    $param .= "&search_usergroup=".urlencode($usergroup);
329 329
 if ($socid)
330
-    $param .= "&search_socid=" . urlencode($socid);
330
+    $param .= "&search_socid=".urlencode($socid);
331 331
 if ($showbirthday)
332 332
     $param .= "&search_showbirthday=1";
333 333
 if ($pid)
334
-    $param .= "&search_projectid=" . urlencode($pid);
334
+    $param .= "&search_projectid=".urlencode($pid);
335 335
 if ($type)
336
-    $param .= "&search_type=" . urlencode($type);
336
+    $param .= "&search_type=".urlencode($type);
337 337
 if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month')
338
-    $param .= '&action=' . urlencode($action);
339
-$param .= "&maxprint=" . urlencode($maxprint);
338
+    $param .= '&action='.urlencode($action);
339
+$param .= "&maxprint=".urlencode($maxprint);
340 340
 
341 341
 // Show navigation bar
342 342
 if (empty($action) || $action == 'show_month') {
343
-    $nav = "<a href=\"?year=" . $prev_year . "&amp;month=" . $prev_month . $param . "\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
344
-    $nav .= " <span id=\"month_name\">" . dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
343
+    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
344
+    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
345 345
     $nav .= " </span>\n";
346
-    $nav .= " &nbsp; <a href=\"?year=" . $next_year . "&amp;month=" . $next_month . $param . "\"><i class=\"fa fa-chevron-right\"></i></a>\n";
347
-    $nav .= " &nbsp; (<a href=\"?year=" . $nowyear . "&amp;month=" . $nowmonth . $param . "\">" . $langs->trans("Today") . "</a>)";
346
+    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
347
+    $nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a>)";
348 348
     $picto = 'calendar';
349 349
 }
350 350
 if ($action == 'show_week') {
351
-    $nav = "<a href=\"?year=" . $prev_year . "&amp;month=" . $prev_month . "&amp;day=" . $prev_day . $param . "\"><i class=\"fa fa-chevron-left\" title=\"" . dol_escape_htmltag($langs->trans("Previous")) . "\"></i></a> &nbsp;\n";
352
-    $nav .= " <span id=\"month_name\">" . dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y") . ", " . $langs->trans("Week") . " " . $week;
351
+    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n";
352
+    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
353 353
     $nav .= " </span>\n";
354
-    $nav .= " &nbsp; <a href=\"?year=" . $next_year . "&amp;month=" . $next_month . "&amp;day=" . $next_day . $param . "\"><i class=\"fa fa-chevron-right\" title=\"" . dol_escape_htmltag($langs->trans("Next")) . "\"></i></a>\n";
355
-    $nav .= " &nbsp; (<a href=\"?year=" . $nowyear . "&amp;month=" . $nowmonth . "&amp;day=" . $nowday . $param . "\">" . $langs->trans("Today") . "</a>)";
354
+    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
355
+    $nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
356 356
     $picto = 'calendarweek';
357 357
 }
358 358
 if ($action == 'show_day') {
359
-    $nav = "<a href=\"?year=" . $prev_year . "&amp;month=" . $prev_month . "&amp;day=" . $prev_day . $param . "\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
360
-    $nav .= " <span id=\"month_name\">" . dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
359
+    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
360
+    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
361 361
     $nav .= " </span>\n";
362
-    $nav .= " &nbsp; <a href=\"?year=" . $next_year . "&amp;month=" . $next_month . "&amp;day=" . $next_day . $param . "\"><i class=\"fa fa-chevron-right\"></i></a>\n";
363
-    $nav .= " &nbsp; (<a href=\"?year=" . $nowyear . "&amp;month=" . $nowmonth . "&amp;day=" . $nowday . $param . "\">" . $langs->trans("Today") . "</a>)";
362
+    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
363
+    $nav .= " &nbsp; (<a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a>)";
364 364
     $picto = 'calendarday';
365 365
 }
366 366
 
367 367
 // Must be after the nav definition
368
-$param .= '&year=' . $year . '&month=' . $month . ($day ? '&day=' . $day : '');
368
+$param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : '');
369 369
 //print 'x'.$param;
370 370
 
371 371
 
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 
386 386
 $head = calendars_prepare_head($paramnoaction);
387 387
 
388
-print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
388
+print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
389 389
 if ($optioncss != '')
390
-    print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
391
-print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
390
+    print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
391
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
392 392
 
393 393
 dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
394 394
 print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
@@ -402,50 +402,50 @@  discard block
 block discarded – undo
402 402
 $showextcals = $listofextcals;
403 403
 
404 404
 if (!empty($conf->use_javascript_ajax)) { // If javascript on
405
-    $s .= "\n" . '<!-- Div to calendars selectors -->' . "\n";
406
-    $s .= '<script type="text/javascript">' . "\n";
407
-    $s .= 'jQuery(document).ready(function () {' . "\n";
408
-    $s .= 'jQuery("#check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });' . "\n";
409
-    $s .= 'jQuery(".family_birthday").toggle();' . "\n";
405
+    $s .= "\n".'<!-- Div to calendars selectors -->'."\n";
406
+    $s .= '<script type="text/javascript">'."\n";
407
+    $s .= 'jQuery(document).ready(function () {'."\n";
408
+    $s .= 'jQuery("#check_birthday").click(function() { console.log("Toggle birthday"); jQuery(".family_birthday").toggle(); });'."\n";
409
+    $s .= 'jQuery(".family_birthday").toggle();'."\n";
410 410
     if ($action == "show_week" || $action == "show_month" || empty($action)) {
411 411
         // Code to enable drag and drop
412
-        $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {' . "\n";
412
+        $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
413 413
         // Code to submit form
414
-        $s .= 'console.log("submit form to record new event");' . "\n";
414
+        $s .= 'console.log("submit form to record new event");'."\n";
415 415
         //$s.='console.log(event.target);';
416
-        $s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");' . "\n";
417
-        $s .= 'console.log("found parent div.dayevent with id = "+newval);' . "\n";
418
-        $s .= 'var frm=jQuery("#searchFormList");' . "\n";
419
-        $s .= 'var newurl = ui.item.find("a.cal_event").attr("href");' . "\n";
420
-        $s .= 'console.log(newurl);' . "\n";
421
-        $s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}' . "\n";
422
-        $s .= '});' . "\n";
416
+        $s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
417
+        $s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n";
418
+        $s .= 'var frm=jQuery("#searchFormList");'."\n";
419
+        $s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
420
+        $s .= 'console.log(newurl);'."\n";
421
+        $s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
422
+        $s .= '});'."\n";
423 423
     }
424
-    $s .= '});' . "\n";
425
-    $s .= '</script>' . "\n";
424
+    $s .= '});'."\n";
425
+    $s .= '</script>'."\n";
426 426
 
427 427
     // Local calendar
428
-    $s .= '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda") . ' &nbsp; </div>';
428
+    $s .= '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
429 429
 
430 430
     // External calendars
431 431
     if (is_array($showextcals) && count($showextcals) > 0) {
432
-        $s .= '<script type="text/javascript">' . "\n";
432
+        $s .= '<script type="text/javascript">'."\n";
433 433
         $s .= 'jQuery(document).ready(function () {
434 434
 				jQuery("table input[name^=\"check_ext\"]").click(function() {
435 435
 					var name = $(this).attr("name");
436 436
 					jQuery(".family_ext" + name.replace("check_ext", "")).toggle();
437 437
 				});
438 438
 			});' . "\n";
439
-        $s .= '</script>' . "\n";
439
+        $s .= '</script>'."\n";
440 440
 
441 441
         foreach ($showextcals as $val) {
442 442
             $htmlname = md5($val['name']);
443
-            $s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_ext' . $htmlname . '" name="check_ext' . $htmlname . '" checked> ' . $val['name'] . ' &nbsp; </div>';
443
+            $s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_ext'.$htmlname.'" name="check_ext'.$htmlname.'" checked> '.$val['name'].' &nbsp; </div>';
444 444
         }
445 445
     }
446 446
 
447 447
     // Birthdays
448
-    $s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday"> ' . $langs->trans("AgendaShowBirthdayEvents") . ' &nbsp; </div>';
448
+    $s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday"> '.$langs->trans("AgendaShowBirthdayEvents").' &nbsp; </div>';
449 449
 
450 450
     // Calendars from hooks
451 451
     $parameters = array();
@@ -457,12 +457,12 @@  discard block
 block discarded – undo
457 457
         $s = $hookmanager->resPrint;
458 458
     }
459 459
 } else {          // If javascript off
460
-    $newparam = $param;   // newparam is for birthday links
461
-    $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday=' . (empty($showbirthday) ? 1 : 0), $newparam);
460
+    $newparam = $param; // newparam is for birthday links
461
+    $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
462 462
     if (!preg_match('/showbirthday=/i', $newparam))
463 463
         $newparam .= '&showbirthday=1';
464
-    $link = '<a href="' . dol_escape_htmltag($_SERVER['PHP_SELF']);
465
-    $link .= '?' . dol_escape_htmltag($newparam);
464
+    $link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
465
+    $link .= '?'.dol_escape_htmltag($newparam);
466 466
     $link .= '">';
467 467
     if (empty($showbirthday))
468 468
         $link .= $langs->trans("AgendaShowBirthdayEvents");
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
     $link .= '</a>';
472 472
 }
473 473
 
474
-print load_fiche_titre($s, $link . ' &nbsp; &nbsp; ' . $nav, '', 0, 0, 'tablelistofcalendars');
474
+print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav, '', 0, 0, 'tablelistofcalendars');
475 475
 
476 476
 
477 477
 // Load events from database into $eventarray
@@ -489,19 +489,19 @@  discard block
 block discarded – undo
489 489
 $sql .= ' a.fk_soc, a.fk_contact,';
490 490
 $sql .= ' a.fk_element, a.elementtype,';
491 491
 $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color';
492
-$sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_actioncomm as ca, ' . MAIN_DB_PREFIX . "actioncomm as a";
492
+$sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a";
493 493
 if (!$user->rights->societe->client->voir && !$socid)
494
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
494
+    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
495 495
 // We must filter on resource table
496 496
 if ($resourceid > 0)
497
-    $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r";
497
+    $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
498 498
 // We must filter on assignement table
499 499
 if ($filtert > 0 || $usergroup > 0)
500
-    $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar";
500
+    $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
501 501
 if ($usergroup > 0)
502
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
502
+    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
503 503
 $sql .= ' WHERE a.fk_action = ca.id';
504
-$sql .= ' AND a.entity IN (' . getEntity('agenda') . ')';
504
+$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
505 505
 // Condition on actioncode
506 506
 if (!empty($actioncode)) {
507 507
     if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
@@ -523,50 +523,50 @@  discard block
 block discarded – undo
523 523
             $sql .= " AND ca.type = 'systemauto'";
524 524
         else {
525 525
             if (is_array($actioncode)) {
526
-                $sql .= " AND ca.code IN ('" . implode("','", $actioncode) . "')";
526
+                $sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
527 527
             } else {
528
-                $sql .= " AND ca.code IN ('" . implode("','", explode(',', $actioncode)) . "')";
528
+                $sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
529 529
             }
530 530
         }
531 531
     }
532 532
 }
533 533
 if ($resourceid > 0)
534
-    $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid);
534
+    $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
535 535
 if ($pid)
536
-    $sql .= " AND a.fk_project=" . $db->escape($pid);
536
+    $sql .= " AND a.fk_project=".$db->escape($pid);
537 537
 if (!$user->rights->societe->client->voir && !$socid)
538
-    $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")";
538
+    $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
539 539
 if ($socid > 0)
540
-    $sql .= ' AND a.fk_soc = ' . $socid;
540
+    $sql .= ' AND a.fk_soc = '.$socid;
541 541
 // We must filter on assignement table
542 542
 if ($filtert > 0 || $usergroup > 0)
543 543
     $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
544 544
 if ($action == 'show_day') {
545 545
     $sql .= " AND (";
546
-    $sql .= " (a.datep BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "'";
547
-    $sql .= " AND '" . $db->idate(dol_mktime(23, 59, 59, $month, $day, $year)) . "')";
546
+    $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
547
+    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
548 548
     $sql .= " OR ";
549
-    $sql .= " (a.datep2 BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "'";
550
-    $sql .= " AND '" . $db->idate(dol_mktime(23, 59, 59, $month, $day, $year)) . "')";
549
+    $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
550
+    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
551 551
     $sql .= " OR ";
552
-    $sql .= " (a.datep < '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "'";
553
-    $sql .= " AND a.datep2 > '" . $db->idate(dol_mktime(23, 59, 59, $month, $day, $year)) . "')";
552
+    $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
553
+    $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
554 554
     $sql .= ')';
555 555
 } else {
556 556
     // To limit array
557 557
     $sql .= " AND (";
558
-    $sql .= " (a.datep BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)) . "'";   // Start 7 days before
559
-    $sql .= " AND '" . $db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)) . "')";            // End 7 days after + 3 to go from 28 to 31
558
+    $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
559
+    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
560 560
     $sql .= " OR ";
561
-    $sql .= " (a.datep2 BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)) . "'";
562
-    $sql .= " AND '" . $db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)) . "')";
561
+    $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
562
+    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
563 563
     $sql .= " OR ";
564
-    $sql .= " (a.datep < '" . $db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7)) . "'";
565
-    $sql .= " AND a.datep2 > '" . $db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)) . "')";
564
+    $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
565
+    $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
566 566
     $sql .= ')';
567 567
 }
568 568
 if ($type)
569
-    $sql .= " AND ca.id = " . $type;
569
+    $sql .= " AND ca.id = ".$type;
570 570
 if ($status == '0') {
571 571
     $sql .= " AND a.percent = 0";
572 572
 }
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 if ($filtert > 0 || $usergroup > 0) {
587 587
     $sql .= " AND (";
588 588
     if ($filtert > 0)
589
-        $sql .= "ar.fk_element = " . $filtert;
589
+        $sql .= "ar.fk_element = ".$filtert;
590 590
     if ($usergroup > 0)
591
-        $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
591
+        $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
592 592
     $sql .= ")";
593 593
 }
594 594
 // Sort on date
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 if ($resql) {
602 602
     $num = $db->num_rows($resql);
603 603
 
604
-    $MAXONSAMEPAGE = 10000;   // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import)
604
+    $MAXONSAMEPAGE = 10000; // Useless to have more. Protection to avoid memory overload when high number of event (for example after a mass import)
605 605
     $i = 0;
606 606
     while ($i < $num && $i < $MAXONSAMEPAGE) {
607 607
         $obj = $db->fetch_object($resql);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         $event = new ActionComm($db);
617 617
         $event->id = $obj->id;
618 618
 
619
-        $event->datep = $db->jdate($obj->datep);      // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin
619
+        $event->datep = $db->jdate($obj->datep); // datep and datef are GMT date. Example: 1970-01-01 01:00:00, jdate will return 0 if TZ of PHP server is Europe/Berlin
620 620
         $event->datef = $db->jdate($obj->datep2);
621 621
         //var_dump($obj->datep);
622 622
         //var_dump($event->datep);
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
         $event->libelle = $obj->label;
629 629
         $event->label = $obj->label;
630 630
         $event->percentage = $obj->percent;
631
-        $event->authorid = $obj->fk_user_author;  // user id of creator
631
+        $event->authorid = $obj->fk_user_author; // user id of creator
632 632
         $event->userownerid = $obj->fk_user_action; // user id of owner
633
-        $event->fetch_userassigned();    // This load $event->userassigned
633
+        $event->fetch_userassigned(); // This load $event->userassigned
634 634
         $event->priority = $obj->priority;
635 635
         $event->fulldayevent = $obj->fulldayevent;
636 636
         $event->location = $obj->location;
@@ -710,14 +710,14 @@  discard block
 block discarded – undo
710 710
 if ($showbirthday) {
711 711
     // Add events in array
712 712
     $sql = 'SELECT sp.rowid, sp.lastname, sp.firstname, sp.birthday';
713
-    $sql .= ' FROM ' . MAIN_DB_PREFIX . 'socpeople as sp';
714
-    $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat=' . $user->id . '))';
715
-    $sql .= " AND sp.entity IN (" . getEntity('socpeople') . ")";
713
+    $sql .= ' FROM '.MAIN_DB_PREFIX.'socpeople as sp';
714
+    $sql .= ' WHERE (priv=0 OR (priv=1 AND fk_user_creat='.$user->id.'))';
715
+    $sql .= " AND sp.entity IN (".getEntity('socpeople').")";
716 716
     if ($action == 'show_day') {
717
-        $sql .= ' AND MONTH(birthday) = ' . $month;
718
-        $sql .= ' AND DAY(birthday) = ' . $day;
717
+        $sql .= ' AND MONTH(birthday) = '.$month;
718
+        $sql .= ' AND DAY(birthday) = '.$day;
719 719
     } else {
720
-        $sql .= ' AND MONTH(birthday) = ' . $month;
720
+        $sql .= ' AND MONTH(birthday) = '.$month;
721 721
     }
722 722
     $sql .= ' ORDER BY birthday';
723 723
 
@@ -733,10 +733,10 @@  discard block
 block discarded – undo
733 733
             $datebirth = dol_stringtotime($obj->birthday, 1);
734 734
             //print 'ee'.$obj->birthday.'-'.$datebirth;
735 735
             $datearray = dol_getdate($datebirth, true);
736
-            $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true);    // For full day events, date are also GMT but they wont but converted during output
736
+            $event->datep = dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true); // For full day events, date are also GMT but they wont but converted during output
737 737
             $event->datef = $event->datep;
738 738
             $event->type_code = 'BIRTHDAY';
739
-            $event->libelle = $langs->trans("Birthday") . ' ' . dolGetFirstLastname($obj->firstname, $obj->lastname);
739
+            $event->libelle = $langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname);
740 740
             $event->percentage = 100;
741 741
             $event->fulldayevent = 1;
742 742
 
@@ -769,9 +769,9 @@  discard block
 block discarded – undo
769 769
 
770 770
 // Complete $eventarray with external import Ical
771 771
 if (count($listofextcals)) {
772
-    require_once DOL_DOCUMENT_ROOT . '/comm/action/class/ical.class.php';
772
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/ical.class.php';
773 773
     foreach ($listofextcals as $extcal) {
774
-        $url = $extcal['src'];    // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics
774
+        $url = $extcal['src']; // Example: https://www.google.com/calendar/ical/eldy10%40gmail.com/private-cde92aa7d7e0ef6110010a821a2aaeb/basic.ics
775 775
         $namecal = $extcal['name'];
776 776
         $offsettz = $extcal['offsettz'];
777 777
         $colorcal = $extcal['color'];
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
         //var_dump($ical->cal); exit;
785 785
         $icalevents = array();
786 786
         if (is_array($ical->get_event_list()))
787
-            $icalevents = array_merge($icalevents, $ical->get_event_list());        // Add $ical->cal['VEVENT']
787
+            $icalevents = array_merge($icalevents, $ical->get_event_list()); // Add $ical->cal['VEVENT']
788 788
         if (is_array($ical->get_freebusy_list()))
789
-            $icalevents = array_merge($icalevents, $ical->get_freebusy_list());  // Add $ical->cal['VFREEBUSY']
789
+            $icalevents = array_merge($icalevents, $ical->get_freebusy_list()); // Add $ical->cal['VFREEBUSY']
790 790
 
791 791
         if (count($icalevents) > 0) {
792 792
             // Duplicate all repeatable events into new entries
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
                     //if ($event->date_end_in_calendar > $lastdaytoshow) $event->date_end_in_calendar=($lastdaytoshow-1);
798 798
                     if ($icalevent['DTSTART;VALUE=DATE']) { //fullday event
799 799
                         $datecurstart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1);
800
-                        $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1;  // We remove one second to get last second of day
800
+                        $datecurend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day
801 801
                     } else if (is_array($icalevent['DTSTART']) && !empty($icalevent['DTSTART']['unixtime'])) {
802 802
                         $datecurstart = $icalevent['DTSTART']['unixtime'];
803 803
                         $datecurend = $icalevent['DTEND']['unixtime'];
@@ -832,9 +832,9 @@  discard block
 block discarded – undo
832 832
                     $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1);
833 833
                     $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT'];
834 834
                     if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow)
835
-                        continue;  // We discard repeatable event that end before start date to show
835
+                        continue; // We discard repeatable event that end before start date to show
836 836
                     if ($datecurstart >= $lastdaytoshow)
837
-                        continue;                                   // We discard repeatable event that start after end date to show
837
+                        continue; // We discard repeatable event that start after end date to show
838 838
 
839 839
                     $numofevent = 0;
840 840
                     while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
                         }
870 870
                         // Test to avoid infinite loop ($datecurstart must increase)
871 871
                         if ($savdatecurstart >= $datecurstart) {
872
-                            dol_syslog("Found a rule freq " . $icalevent['RRULE']['FREQ'] . " not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
872
+                            dol_syslog("Found a rule freq ".$icalevent['RRULE']['FREQ']." not managed by dolibarr code. Assume 1 week frequency.", LOG_ERR);
873 873
                             $datecurstart += 3600 * 24 * 7;
874 874
                             $datecurend += 3600 * 24 * 7;
875 875
                         }
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
                 //var_dump($icalevent);
884 884
                 //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'<br>';exit;
885 885
                 if (!empty($icalevent['RRULE']))
886
-                    continue;    // We found a repeatable event. It was already split into unitary events, so we discard general rule.
886
+                    continue; // We found a repeatable event. It was already split into unitary events, so we discard general rule.
887 887
 
888 888
 
889 889
                     
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
                 if (isset($icalevent['DTSTART;VALUE=DATE'])) { // fullday event
894 894
                     // For full day events, date are also GMT but they wont but converted using tz during output
895 895
                     $datestart = dol_stringtotime($icalevent['DTSTART;VALUE=DATE'], 1);
896
-                    $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1;  // We remove one second to get last second of day
896
+                    $dateend = dol_stringtotime($icalevent['DTEND;VALUE=DATE'], 1) - 1; // We remove one second to get last second of day
897 897
                     //print 'x'.$datestart.'-'.$dateend;exit;
898 898
                     //print dol_print_date($dateend,'dayhour','gmt');
899 899
                     $event->fulldayevent = 1;
@@ -938,7 +938,7 @@  discard block
 block discarded – undo
938 938
                     $event->id = $icalevent['UID'];
939 939
                     $event->icalname = $namecal;
940 940
                     $event->icalcolor = $colorcal;
941
-                    $usertime = 0;    // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
941
+                    $usertime = 0; // We dont modify date because we want to have date into memory datep and datef stored as GMT date. Compensation will be done during output.
942 942
                     $event->datep = $datestart + $usertime;
943 943
                     $event->datef = $dateend + $usertime;
944 944
                     $event->type_code = "ICALEVENT";
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
                             //if ($event->fulldayevent) print dol_print_date($daykeygmt,'dayhour','gmt').'-'.dol_print_date($daykey,'dayhour','gmt').'-'.dol_print_date($event->date_end_in_calendar,'dayhour','gmt').' ';
992 992
                             $eventarray[$daykey][] = $event;
993 993
                             $daykey += 60 * 60 * 24;
994
-                            $daykeygmt += 60 * 60 * 24;   // Add one day
994
+                            $daykeygmt += 60 * 60 * 24; // Add one day
995 995
                             if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar)
996 996
                                 $loop = false;
997 997
                         }
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
 $cacheusers = array();
1027 1027
 
1028 1028
 // Define theme_datacolor array
1029
-$color_file = DOL_DOCUMENT_ROOT . "/theme/" . $conf->theme . "/graph-color.php";
1029
+$color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/graph-color.php";
1030 1030
 if (is_readable($color_file)) {
1031 1031
     include_once $color_file;
1032 1032
 }
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
 
1037 1037
 if (empty($action) || $action == 'show_month') {      // View by month
1038
-    $newparam = $param;   // newparam is for birthday links
1038
+    $newparam = $param; // newparam is for birthday links
1039 1039
     $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
1040 1040
     $newparam = preg_replace('/action=show_month&?/i', '', $newparam);
1041 1041
     $newparam = preg_replace('/action=show_week&?/i', '', $newparam);
@@ -1058,11 +1058,11 @@  discard block
 block discarded – undo
1058 1058
             $labelshort = array(0 => 'SundayMin', 1 => 'MondayMin', 2 => 'TuesdayMin', 3 => 'WednesdayMin', 4 => 'ThursdayMin', 5 => 'FridayMin', 6 => 'SaturdayMin');
1059 1059
             print $langs->trans($labelshort[$numdayinweek]);
1060 1060
         } else
1061
-            print $langs->trans("Day" . $numdayinweek);
1062
-        print '  </td>' . "\n";
1061
+            print $langs->trans("Day".$numdayinweek);
1062
+        print '  </td>'."\n";
1063 1063
         $i++;
1064 1064
     }
1065
-    echo ' </tr>' . "\n";
1065
+    echo ' </tr>'."\n";
1066 1066
 
1067 1067
     $todayarray = dol_getdate($now, 'fast');
1068 1068
     $todaytms = dol_mktime(0, 0, 0, $todayarray['mon'], $todayarray['mday'], $todayarray['year']);
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
                 $style = 'cal_other_month cal_past';
1078 1078
                 if ($iter_day == 6)
1079 1079
                     $style .= ' cal_other_month_right';
1080
-                echo '  <td class="' . $style . ' nowrap" width="14%" valign="top">';
1080
+                echo '  <td class="'.$style.' nowrap" width="14%" valign="top">';
1081 1081
                 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1082 1082
                 echo "  </td>\n";
1083 1083
             }
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
                 if ($curtime < $todaytms)
1096 1096
                     $style .= ' cal_past';
1097 1097
                 //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style);
1098
-                echo '  <td class="' . $style . ' nowrap" width="14%" valign="top">';
1098
+                echo '  <td class="'.$style.' nowrap" width="14%" valign="top">';
1099 1099
                 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1100 1100
                 echo "  </td>\n";
1101 1101
             }
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
                 $style = 'cal_other_month';
1105 1105
                 if ($iter_day == 6)
1106 1106
                     $style .= ' cal_other_month_right';
1107
-                echo '  <td class="' . $style . ' nowrap" width="14%" valign="top">';
1107
+                echo '  <td class="'.$style.' nowrap" width="14%" valign="top">';
1108 1108
                 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1109 1109
                 echo "</td>\n";
1110 1110
             }
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
     print '</div>';
1117 1117
 
1118 1118
     print '<input type="hidden" name="actionmove" value="mupdate">';
1119
-    print '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag($_SERVER['PHP_SELF']) . '?' . dol_escape_htmltag($_SERVER['QUERY_STRING']) . '">';
1119
+    print '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
1120 1120
     print '<input type="hidden" name="newdate" id="newdate">';
1121 1121
 }
1122 1122
 elseif ($action == 'show_week') { // View by week
1123
-    $newparam = $param;   // newparam is for birthday links
1123
+    $newparam = $param; // newparam is for birthday links
1124 1124
     $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
1125 1125
     $newparam = preg_replace('/action=show_month&?/i', '', $newparam);
1126 1126
     $newparam = preg_replace('/action=show_week&?/i', '', $newparam);
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
     print ' <tr class="liste_titre">';
1137 1137
     $i = 0;
1138 1138
     while ($i < 7) {
1139
-        echo '  <td align="center">' . $langs->trans("Day" . (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)) . "</td>\n";
1139
+        echo '  <td align="center">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."</td>\n";
1140 1140
         $i++;
1141 1141
     }
1142 1142
     echo " </tr>\n";
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
         if ($today)
1162 1162
             $style = 'cal_today';
1163 1163
 
1164
-        echo '  <td class="' . $style . '" width="14%" valign="top">';
1164
+        echo '  <td class="'.$style.'" width="14%" valign="top">';
1165 1165
         show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
1166 1166
         echo "  </td>\n";
1167 1167
     }
@@ -1171,11 +1171,11 @@  discard block
 block discarded – undo
1171 1171
     print '</div>';
1172 1172
 
1173 1173
     echo '<input type="hidden" name="actionmove" value="mupdate">';
1174
-    echo '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag($_SERVER['PHP_SELF']) . '?' . dol_escape_htmltag($_SERVER['QUERY_STRING']) . '">';
1174
+    echo '<input type="hidden" name="backtopage" value="'.dol_escape_htmltag($_SERVER['PHP_SELF']).'?'.dol_escape_htmltag($_SERVER['QUERY_STRING']).'">';
1175 1175
     echo '<input type="hidden" name="newdate" id="newdate">';
1176 1176
 }
1177 1177
 else {    // View by day
1178
-    $newparam = $param;   // newparam is for birthday links
1178
+    $newparam = $param; // newparam is for birthday links
1179 1179
     $newparam = preg_replace('/action=show_month&?/i', '', $newparam);
1180 1180
     $newparam = preg_replace('/action=show_week&?/i', '', $newparam);
1181 1181
     $newparam = preg_replace('/viewday=[0-9]+&?/i', '', $newparam);
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 
1197 1197
     echo ' <tr class="tagtr liste_titre">';
1198 1198
     echo '  <td class="tagtd width100"></td>';
1199
-    echo '  <td class="tagtd center">' . $langs->trans("Day" . $arraytimestamp['wday']) . "</td>\n";
1199
+    echo '  <td class="tagtd center">'.$langs->trans("Day".$arraytimestamp['wday'])."</td>\n";
1200 1200
     echo " </td>\n";
1201 1201
 
1202 1202
     /*
@@ -1213,11 +1213,11 @@  discard block
 block discarded – undo
1213 1213
     /* WIP View per hour */
1214 1214
     $useviewhour = 0;
1215 1215
     if ($useviewhour) {
1216
-        print '<div class="div-table-responsive-no-min borderbottom">';  // You can use div-table-responsive-no-min if you dont need reserved height for your table
1216
+        print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1217 1217
 
1218 1218
         $maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
1219 1219
 
1220
-        echo '<div style="max-height: ' . $maxheightwin . 'px;">';
1220
+        echo '<div style="max-height: '.$maxheightwin.'px;">';
1221 1221
         echo '<div class="tagtable centpercent calendarviewcontainer">';
1222 1222
 
1223 1223
         $maxnbofchar = 80;
@@ -1236,9 +1236,9 @@  discard block
 block discarded – undo
1236 1236
         $i = 0;
1237 1237
         $j = 0;
1238 1238
         while ($i < 24) {
1239
-            echo ' <div class="tagtr calendarviewcontainertr">' . "\n";
1240
-            echo '  <div class="tagtd width100 tdtop">' . dol_print_date($i * 3600, 'hour', 'gmt') . '</div>';
1241
-            echo '  <div class="tagtd ' . $style . ' tdtop">';
1239
+            echo ' <div class="tagtr calendarviewcontainertr">'."\n";
1240
+            echo '  <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
1241
+            echo '  <div class="tagtd '.$style.' tdtop">';
1242 1242
             echo "  </div>\n";
1243 1243
             echo " </div>\n";
1244 1244
             $i++;
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 
1252 1252
         print '</div>';
1253 1253
     } else {
1254
-        print '<div class="div-table-responsive-no-min">';  // You can use div-table-responsive-no-min if you dont need reserved height for your table
1254
+        print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
1255 1255
 
1256 1256
         show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
1257 1257
 
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
     }
1260 1260
 }
1261 1261
 
1262
-print "\n" . '</form>';
1262
+print "\n".'</form>';
1263 1263
 
1264 1264
 // End of page
1265 1265
 llxFooter();
@@ -1290,18 +1290,18 @@  discard block
 block discarded – undo
1290 1290
     global $theme_datacolor;
1291 1291
     global $cachethirdparties, $cachecontacts, $cacheusers, $colorindexused;
1292 1292
 
1293
-    $dateint = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day);
1293
+    $dateint = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
1294 1294
 
1295 1295
     print "\n";
1296 1296
 
1297 1297
     // Line with title of day
1298 1298
     $curtime = dol_mktime(0, 0, 0, $month, $day, $year);
1299
-    print '<div id="dayevent_' . $dateint . '" class="dayevent tagtable centpercent nobordernopadding">' . "\n";
1299
+    print '<div id="dayevent_'.$dateint.'" class="dayevent tagtable centpercent nobordernopadding">'."\n";
1300 1300
 
1301 1301
     if ($nonew <= 0) {
1302 1302
         print '<div class="tagtr"><div class="nowrap float">';
1303
-        print '<a style="color: #666" href="' . BASE_URI . '?controller=comm/action&method=index';
1304
-        print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
1303
+        print '<a style="color: #666" href="'.BASE_URI.'?controller=comm/action&method=index';
1304
+        print 'action=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
1305 1305
         print $newparam;
1306 1306
         print '">';
1307 1307
         if ($showinfo)
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
         print '</a>';
1312 1312
         print '</div><div class="floatright nowrap">';
1313 1313
         if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
1314
-            $newparam .= '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
1314
+            $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year;
1315 1315
 
1316 1316
             //$param='month='.$monthshown.'&year='.$year;
1317 1317
             $hourminsec = '100000';
1318
-            print '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&datep=' . sprintf("%04d%02d%02d", $year, $month, $day) . $hourminsec . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . ($newparam ? '?' . $newparam : '')) . '">';
1318
+            print '<a href="'.BASE_URI.'?controller=comm/action&method=card&action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')).'">';
1319 1319
             print img_picto($langs->trans("NewAction"), 'edit_add.png');
1320 1320
             print '</a>';
1321 1321
         }
1322
-        print '</div></div>' . "\n";
1322
+        print '</div></div>'."\n";
1323 1323
     }
1324 1324
 
1325 1325
     if ($nonew < 0) {
@@ -1337,9 +1337,9 @@  discard block
 block discarded – undo
1337 1337
     $numbirthday = 0;
1338 1338
     $numical = 0;
1339 1339
     $numicals = array();
1340
-    $ymd = sprintf("%04d", $year) . sprintf("%02d", $month) . sprintf("%02d", $day);
1340
+    $ymd = sprintf("%04d", $year).sprintf("%02d", $month).sprintf("%02d", $day);
1341 1341
 
1342
-    $colorindexused[$user->id] = 0;   // Color index for current user (user->id) is always 0
1342
+    $colorindexused[$user->id] = 0; // Color index for current user (user->id) is always 0
1343 1343
     $nextindextouse = is_array($colorindexused) ? count($colorindexused) : 0; // At first run this is 0, so fist user has 0, next 1, ...
1344 1344
     //var_dump($colorindexused);
1345 1345
 
@@ -1376,11 +1376,11 @@  discard block
 block discarded – undo
1376 1376
                             if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
1377 1377
                                 $numicals[dol_string_nospecial($event->icalname)] = 0;
1378 1378
                             }
1379
-                            $numicals[dol_string_nospecial($event->icalname)] ++;
1379
+                            $numicals[dol_string_nospecial($event->icalname)]++;
1380 1380
                         }
1381 1381
 
1382 1382
                         $color = ($event->icalcolor ? $event->icalcolor : -1);
1383
-                        $cssclass = (!empty($event->icalname) ? 'family_ext' . md5($event->icalname) : 'family_other');
1383
+                        $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1384 1384
                     } else if ($event->type_code == 'BIRTHDAY') {
1385 1385
                         $numbirthday++;
1386 1386
                         $colorindex = 2;
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
                     } else {
1390 1390
                         $numother++;
1391 1391
                         $color = ($event->icalcolor ? $event->icalcolor : -1);
1392
-                        $cssclass = (!empty($event->icalname) ? 'family_ext' . md5($event->icalname) : 'family_other');
1392
+                        $cssclass = (!empty($event->icalname) ? 'family_ext'.md5($event->icalname) : 'family_other');
1393 1393
 
1394 1394
                         if (empty($cacheusers[$event->userownerid])) {
1395 1395
                             $newuser = new User($db);
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
                         // Define color
1418 1418
                         $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]);
1419 1419
                     }
1420
-                    $cssclass = $cssclass . ' ' . $cssclass . '_day_' . $ymd;
1420
+                    $cssclass = $cssclass.' '.$cssclass.'_day_'.$ymd;
1421 1421
 
1422 1422
                     // Defined style to disable drag and drop feature
1423 1423
                     if ($event->type_code == 'AC_OTH_AUTO') {
@@ -1453,8 +1453,8 @@  discard block
 block discarded – undo
1453 1453
 
1454 1454
                     // Show rect of event
1455 1455
                     print "\n";
1456
-                    print '<!-- start event ' . $i . ' -->' . "\n";
1457
-                    print '<div id="event_' . $ymd . '_' . $i . '" class="event ' . $cssclass . '"';
1456
+                    print '<!-- start event '.$i.' -->'."\n";
1457
+                    print '<div id="event_'.$ymd.'_'.$i.'" class="event '.$cssclass.'"';
1458 1458
                     //print ' style="height: 100px;';
1459 1459
                     //print ' position: absolute; top: 40px; width: 50%;';
1460 1460
                     //print '"';
@@ -1462,12 +1462,12 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
                     //var_dump($event->userassigned);
1464 1464
                     //var_dump($event->transparency);
1465
-                    print '<table class="centpercent cal_event' . (empty($event->transparency) ? ' cal_event_notbusy' : ' cal_event_busy') . '" style="' . $h;
1465
+                    print '<table class="centpercent cal_event'.(empty($event->transparency) ? ' cal_event_notbusy' : ' cal_event_busy').'" style="'.$h;
1466 1466
                     if (empty($event->transparency) && empty($conf->global->AGENDA_NO_TRANSPARENT_ON_NOT_BUSY)) {
1467
-                        print 'border: 2px solid #' . $color . ';';
1467
+                        print 'border: 2px solid #'.$color.';';
1468 1468
                     } else {
1469
-                        print 'background: #' . $color . ';';
1470
-                        print 'background: -webkit-gradient(linear, left top, left bottom, from(#' . dol_color_minus($color, -3) . '), to(#' . dol_color_minus($color, -1) . '));';
1469
+                        print 'background: #'.$color.';';
1470
+                        print 'background: -webkit-gradient(linear, left top, left bottom, from(#'.dol_color_minus($color, -3).'), to(#'.dol_color_minus($color, -1).'));';
1471 1471
                     }
1472 1472
                     //if (! empty($event->transparency)) print 'background: #'.$color.'; background: -webkit-gradient(linear, left top, left bottom, from(#'.$color.'), to(#'.dol_color_minus($color,1).'));';
1473 1473
                     //else print 'background-color: transparent !important; background: none; border: 1px solid #bbb;';
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
                     //print 'border: 1px solid #ccc" width="100%"';
1476 1476
                     print '">';
1477 1477
                     print '<tr>';
1478
-                    print '<td class="tdoverflow nobottom centpercent ' . ($nowrapontd ? 'nowrap ' : '') . 'cal_event' . ($event->type_code == 'BIRTHDAY' ? ' cal_event_birthday' : '') . '">';
1478
+                    print '<td class="tdoverflow nobottom centpercent '.($nowrapontd ? 'nowrap ' : '').'cal_event'.($event->type_code == 'BIRTHDAY' ? ' cal_event_birthday' : '').'">';
1479 1479
 
1480 1480
                     $daterange = '';
1481 1481
 
@@ -1520,13 +1520,13 @@  discard block
 block discarded – undo
1520 1520
                         }
1521 1521
                         else {
1522 1522
                             if ($showinfo) {
1523
-                                print $langs->trans("EventOnFullDay") . "<br>\n";
1523
+                                print $langs->trans("EventOnFullDay")."<br>\n";
1524 1524
                             }
1525 1525
                         }
1526 1526
 
1527 1527
                         // Show title
1528 1528
                         $titletoshow = $daterange;
1529
-                        $titletoshow .= ($titletoshow ? ' ' : '') . $event->libelle;
1529
+                        $titletoshow .= ($titletoshow ? ' ' : '').$event->libelle;
1530 1530
 
1531 1531
                         if ($event->type_code == 'ICALEVENT')
1532 1532
                             print $titletoshow;
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
                         print $listofusertoshow;
1558 1558
 
1559 1559
                         if ($event->type_code == 'ICALEVENT')
1560
-                            print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')';
1560
+                            print '<br>('.dol_trunc($event->icalname, $maxnbofchar).')';
1561 1561
 
1562 1562
                         // If action related to company / contact
1563 1563
                         $linerelatedto = '';
@@ -1584,20 +1584,20 @@  discard block
 block discarded – undo
1584 1584
                                 $linerelatedto .= $contact->getNomUrl(1, '', 0);
1585 1585
                         }
1586 1586
                         if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) {
1587
-                            include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
1587
+                            include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
1588 1588
                             if ($linerelatedto)
1589 1589
                                 $linerelatedto .= '<br>';
1590 1590
                             $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
1591 1591
                         }
1592 1592
                         if ($linerelatedto)
1593
-                            print '<br>' . $linerelatedto;
1593
+                            print '<br>'.$linerelatedto;
1594 1594
                     }
1595 1595
 
1596 1596
                     // Show location
1597 1597
                     if ($showinfo) {
1598 1598
                         if ($event->location) {
1599 1599
                             print '<br>';
1600
-                            print $langs->trans("Location") . ': ' . $event->location;
1600
+                            print $langs->trans("Location").': '.$event->location;
1601 1601
                         }
1602 1602
                     }
1603 1603
 
@@ -1609,23 +1609,23 @@  discard block
 block discarded – undo
1609 1609
                         if ($event->percentage >= 0)
1610 1610
                             $withstatus = 2;
1611 1611
                     }
1612
-                    print '<td class="nobottom right nowrap cal_event_right' . ($withstatus >= 2 ? ' cal_event_right_status' : '') . '">';
1612
+                    print '<td class="nobottom right nowrap cal_event_right'.($withstatus >= 2 ? ' cal_event_right_status' : '').'">';
1613 1613
                     if ($withstatus)
1614 1614
                         print $event->getLibStatut(3, 1);
1615 1615
                     else
1616 1616
                         print '&nbsp;';
1617 1617
                     print '</td></tr></table>';
1618
-                    print '</div><!-- end event ' . $i . ' -->' . "\n";
1618
+                    print '</div><!-- end event '.$i.' -->'."\n";
1619 1619
                     $i++;
1620 1620
                 }
1621 1621
                 else {
1622
-                    print '<a href="' . BASE_URI . '?controller=comm/action&method=index&action=' . $action . '&maxprint=0&month=' . $monthshown . '&year=' . $year;
1623
-                    print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : '');
1624
-                    print ($filtert ? '&filtert=' . $filtert : '');
1625
-                    print ($usergroup ? '&usergroup=' . $usergroup : '');
1626
-                    print ($actioncode != '' ? '&actioncode=' . $actioncode : '');
1627
-                    print '">' . img_picto("all", "1downarrow_selected.png") . ' ...';
1628
-                    print ' +' . (count($eventarray[$daykey]) - $maxprint);
1622
+                    print '<a href="'.BASE_URI.'?controller=comm/action&method=index&action='.$action.'&maxprint=0&month='.$monthshown.'&year='.$year;
1623
+                    print ($status ? '&status='.$status : '').($filter ? '&filter='.$filter : '');
1624
+                    print ($filtert ? '&filtert='.$filtert : '');
1625
+                    print ($usergroup ? '&usergroup='.$usergroup : '');
1626
+                    print ($actioncode != '' ? '&actioncode='.$actioncode : '');
1627
+                    print '">'.img_picto("all", "1downarrow_selected.png").' ...';
1628
+                    print ' +'.(count($eventarray[$daykey]) - $maxprint);
1629 1629
                     print '</a>';
1630 1630
                     break;
1631 1631
                     //$ok=false;        // To avoid to show twice the link
@@ -1639,26 +1639,26 @@  discard block
 block discarded – undo
1639 1639
         print '&nbsp;';
1640 1640
 
1641 1641
     if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) {
1642
-        print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>';
1642
+        print '<div id="more_'.$ymd.'">'.img_picto("all", "1downarrow_selected.png").' +'.$langs->trans("More").'...</div>';
1643 1643
         //print ' +'.(count($eventarray[$daykey])-$maxprint);
1644
-        print '<script type="text/javascript">' . "\n";
1645
-        print 'jQuery(document).ready(function () {' . "\n";
1646
-        print 'jQuery("#more_' . $ymd . '").click(function() { reinit_day_' . $ymd . '(); });' . "\n";
1644
+        print '<script type="text/javascript">'."\n";
1645
+        print 'jQuery(document).ready(function () {'."\n";
1646
+        print 'jQuery("#more_'.$ymd.'").click(function() { reinit_day_'.$ymd.'(); });'."\n";
1647 1647
 
1648
-        print 'function reinit_day_' . $ymd . '() {' . "\n";
1649
-        print 'var nb=0;' . "\n";
1648
+        print 'function reinit_day_'.$ymd.'() {'."\n";
1649
+        print 'var nb=0;'."\n";
1650 1650
         // TODO Loop on each element of day $ymd and start to toggle once $maxprint has been reached
1651
-        print 'jQuery(".family_mytasks_day_' . $ymd . '").toggle();';
1652
-        print '}' . "\n";
1651
+        print 'jQuery(".family_mytasks_day_'.$ymd.'").toggle();';
1652
+        print '}'."\n";
1653 1653
 
1654
-        print '});' . "\n";
1654
+        print '});'."\n";
1655 1655
 
1656
-        print '</script>' . "\n";
1656
+        print '</script>'."\n";
1657 1657
     }
1658 1658
 
1659
-    print '</div></div>';       // td tr
1659
+    print '</div></div>'; // td tr
1660 1660
 
1661
-    print '</div>';             // table
1661
+    print '</div>'; // table
1662 1662
     print "\n";
1663 1663
 }
1664 1664
 
Please login to merge, or discard this patch.
Braces   +319 added lines, -220 removed lines patch added patch discarded remove patch
@@ -43,11 +43,13 @@  discard block
 block discarded – undo
43 43
     require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
44 44
 }
45 45
 
46
-if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW))
46
+if (!isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) {
47 47
     $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW = 3;
48
+}
48 49
 
49
-if (empty($conf->global->AGENDA_EXT_NB))
50
+if (empty($conf->global->AGENDA_EXT_NB)) {
50 51
     $conf->global->AGENDA_EXT_NB = 5;
52
+}
51 53
 $MAXAGENDA = $conf->global->AGENDA_EXT_NB;
52 54
 
53 55
 $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha', 3) : GETPOST("filter", 'alpha', 3);
@@ -68,24 +70,30 @@  discard block
 block discarded – undo
68 70
 }     // If $page is not defined, or '' or -1
69 71
 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
70 72
 $offset = $limit * $page;
71
-if (!$sortorder)
73
+if (!$sortorder) {
72 74
     $sortorder = "ASC";
73
-if (!$sortfield)
75
+}
76
+if (!$sortfield) {
74 77
     $sortfield = "a.datec";
78
+}
75 79
 
76 80
 // Security check
77 81
 $socid = GETPOST("search_socid", "int") ? GETPOST("search_socid", "int") : GETPOST("socid", "int");
78
-if ($user->societe_id)
82
+if ($user->societe_id) {
79 83
     $socid = $user->societe_id;
84
+}
80 85
 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
81
-if ($socid < 0)
86
+if ($socid < 0) {
82 87
     $socid = '';
88
+}
83 89
 
84 90
 $canedit = 1;
85
-if (!$user->rights->agenda->myactions->read)
91
+if (!$user->rights->agenda->myactions->read) {
86 92
     accessforbidden();
87
-if (!$user->rights->agenda->allactions->read)
93
+}
94
+if (!$user->rights->agenda->allactions->read) {
88 95
     $canedit = 0;
96
+}
89 97
 if (!$user->rights->agenda->allactions->read || $filter == 'mine') {  // If no permission to see all, we show only affected to me
90 98
     $filtert = $user->id;
91 99
 }
@@ -103,22 +111,25 @@  discard block
 block discarded – undo
103 111
 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
104 112
 if (GETPOST('search_actioncode', 'array')) {
105 113
     $actioncode = GETPOST('search_actioncode', 'array', 3);
106
-    if (!count($actioncode))
107
-        $actioncode = '0';
108
-}
109
-else {
114
+    if (!count($actioncode)) {
115
+            $actioncode = '0';
116
+    }
117
+    } else {
110 118
     $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
111 119
 }
112
-if ($actioncode == '' && empty($actioncodearray))
120
+if ($actioncode == '' && empty($actioncodearray)) {
113 121
     $actioncode = (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE);
122
+}
114 123
 
115
-if ($status == '' && !GETPOSTISSET('search_status'))
124
+if ($status == '' && !GETPOSTISSET('search_status')) {
116 125
     $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS);
126
+}
117 127
 
118 128
 $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW);
119 129
 $defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW);
120
-if (empty($action) && !GETPOSTISSET('action'))
130
+if (empty($action) && !GETPOSTISSET('action')) {
121 131
     $action = $defaultview;
132
+}
122 133
 if ($action == 'default') { // When action is default, we want a calendar view and not the list
123 134
     $action = (($defaultview != 'show_list') ? $defaultview : 'show_month');
124 135
 }
@@ -150,8 +161,9 @@  discard block
 block discarded – undo
150 161
     $param = '';
151 162
     if (is_array($_POST)) {
152 163
         foreach ($_POST as $key => $val) {
153
-            if ($key == 'token')
154
-                continue;
164
+            if ($key == 'token') {
165
+                            continue;
166
+            }
155 167
             $param .= '&' . $key . '=' . urlencode($val);
156 168
         }
157 169
     }
@@ -164,8 +176,9 @@  discard block
 block discarded – undo
164 176
     $param = '';
165 177
     if (is_array($_POST)) {
166 178
         foreach ($_POST as $key => $val) {
167
-            if ($key == 'token')
168
-                continue;
179
+            if ($key == 'token') {
180
+                            continue;
181
+            }
169 182
             $param .= '&' . $key . '=' . urlencode($val);
170 183
         }
171 184
     }
@@ -247,15 +260,18 @@  discard block
 block discarded – undo
247 260
     // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
248 261
     $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2;  // date('w') is 0 fo sunday
249 262
     $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
250
-    if ($tmpday >= 1)
251
-        $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
263
+    if ($tmpday >= 1) {
264
+            $tmpday -= 7;
265
+    }
266
+    // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
252 267
 
253 268
         
254 269
 // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
255 270
     $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year);
256 271
     $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
257
-    if ($next_day < 6)
258
-        $next_day += 7;
272
+    if ($next_day < 6) {
273
+            $next_day += 7;
274
+    }
259 275
     $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
260 276
 }
261 277
 if ($action == 'show_week') {
@@ -303,39 +319,53 @@  discard block
 block discarded – undo
303 319
 //print dol_print_date($lastdaytoshow,'day');
304 320
 
305 321
 $title = $langs->trans("DoneAndToDoActions");
306
-if ($status == 'done')
322
+if ($status == 'done') {
307 323
     $title = $langs->trans("DoneActions");
308
-if ($status == 'todo')
324
+}
325
+if ($status == 'todo') {
309 326
     $title = $langs->trans("ToDoActions");
327
+}
310 328
 
311 329
 $param = '';
312 330
 if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) {
313 331
     if (is_array($actioncode)) {
314
-        foreach ($actioncode as $str_action)
315
-            $param .= "&search_actioncode[]=" . urlencode($str_action);
316
-    } else
317
-        $param .= "&search_actioncode=" . urlencode($actioncode);
318
-}
319
-if ($resourceid > 0)
332
+        foreach ($actioncode as $str_action) {
333
+                    $param .= "&search_actioncode[]=" . urlencode($str_action);
334
+        }
335
+    } else {
336
+            $param .= "&search_actioncode=" . urlencode($actioncode);
337
+    }
338
+    }
339
+if ($resourceid > 0) {
320 340
     $param .= "&search_resourceid=" . urlencode($resourceid);
321
-if ($status || isset($_GET['status']) || isset($_POST['status']))
341
+}
342
+if ($status || isset($_GET['status']) || isset($_POST['status'])) {
322 343
     $param .= "&search_status=" . urlencode($status);
323
-if ($filter)
344
+}
345
+if ($filter) {
324 346
     $param .= "&search_filter=" . urlencode($filter);
325
-if ($filtert)
347
+}
348
+if ($filtert) {
326 349
     $param .= "&search_filtert=" . urlencode($filtert);
327
-if ($usergroup)
350
+}
351
+if ($usergroup) {
328 352
     $param .= "&search_usergroup=" . urlencode($usergroup);
329
-if ($socid)
353
+}
354
+if ($socid) {
330 355
     $param .= "&search_socid=" . urlencode($socid);
331
-if ($showbirthday)
356
+}
357
+if ($showbirthday) {
332 358
     $param .= "&search_showbirthday=1";
333
-if ($pid)
359
+}
360
+if ($pid) {
334 361
     $param .= "&search_projectid=" . urlencode($pid);
335
-if ($type)
362
+}
363
+if ($type) {
336 364
     $param .= "&search_type=" . urlencode($type);
337
-if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month')
365
+}
366
+if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') {
338 367
     $param .= '&action=' . urlencode($action);
368
+}
339 369
 $param .= "&maxprint=" . urlencode($maxprint);
340 370
 
341 371
 // Show navigation bar
@@ -372,22 +402,27 @@  discard block
 block discarded – undo
372 402
 
373 403
 
374 404
 $tabactive = '';
375
-if ($action == 'show_month')
405
+if ($action == 'show_month') {
376 406
     $tabactive = 'cardmonth';
377
-if ($action == 'show_week')
407
+}
408
+if ($action == 'show_week') {
378 409
     $tabactive = 'cardweek';
379
-if ($action == 'show_day')
410
+}
411
+if ($action == 'show_day') {
380 412
     $tabactive = 'cardday';
381
-if ($action == 'show_list')
413
+}
414
+if ($action == 'show_list') {
382 415
     $tabactive = 'cardlist';
416
+}
383 417
 
384 418
 $paramnoaction = preg_replace('/action=[a-z_]+/', '', $param);
385 419
 
386 420
 $head = calendars_prepare_head($paramnoaction);
387 421
 
388 422
 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
389
-if ($optioncss != '')
423
+if ($optioncss != '') {
390 424
     print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
425
+}
391 426
 print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
392 427
 
393 428
 dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
@@ -459,15 +494,17 @@  discard block
 block discarded – undo
459 494
 } else {          // If javascript off
460 495
     $newparam = $param;   // newparam is for birthday links
461 496
     $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday=' . (empty($showbirthday) ? 1 : 0), $newparam);
462
-    if (!preg_match('/showbirthday=/i', $newparam))
463
-        $newparam .= '&showbirthday=1';
497
+    if (!preg_match('/showbirthday=/i', $newparam)) {
498
+            $newparam .= '&showbirthday=1';
499
+    }
464 500
     $link = '<a href="' . dol_escape_htmltag($_SERVER['PHP_SELF']);
465 501
     $link .= '?' . dol_escape_htmltag($newparam);
466 502
     $link .= '">';
467
-    if (empty($showbirthday))
468
-        $link .= $langs->trans("AgendaShowBirthdayEvents");
469
-    else
470
-        $link .= $langs->trans("AgendaHideBirthdayEvents");
503
+    if (empty($showbirthday)) {
504
+            $link .= $langs->trans("AgendaShowBirthdayEvents");
505
+    } else {
506
+            $link .= $langs->trans("AgendaHideBirthdayEvents");
507
+    }
471 508
     $link .= '</a>';
472 509
 }
473 510
 
@@ -478,8 +515,9 @@  discard block
 block discarded – undo
478 515
 $eventarray = array();
479 516
 
480 517
 $sql = 'SELECT ';
481
-if ($usergroup > 0)
518
+if ($usergroup > 0) {
482 519
     $sql .= " DISTINCT";
520
+}
483 521
 $sql .= ' a.id, a.label,';
484 522
 $sql .= ' a.datep,';
485 523
 $sql .= ' a.datep2,';
@@ -490,38 +528,43 @@  discard block
 block discarded – undo
490 528
 $sql .= ' a.fk_element, a.elementtype,';
491 529
 $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color';
492 530
 $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_actioncomm as ca, ' . MAIN_DB_PREFIX . "actioncomm as a";
493
-if (!$user->rights->societe->client->voir && !$socid)
531
+if (!$user->rights->societe->client->voir && !$socid) {
494 532
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
533
+}
495 534
 // We must filter on resource table
496
-if ($resourceid > 0)
535
+if ($resourceid > 0) {
497 536
     $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r";
537
+}
498 538
 // We must filter on assignement table
499
-if ($filtert > 0 || $usergroup > 0)
539
+if ($filtert > 0 || $usergroup > 0) {
500 540
     $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar";
501
-if ($usergroup > 0)
541
+}
542
+if ($usergroup > 0) {
502 543
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
544
+}
503 545
 $sql .= ' WHERE a.fk_action = ca.id';
504 546
 $sql .= ' AND a.entity IN (' . getEntity('agenda') . ')';
505 547
 // Condition on actioncode
506 548
 if (!empty($actioncode)) {
507 549
     if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
508
-        if ($actioncode == 'AC_NON_AUTO')
509
-            $sql .= " AND ca.type != 'systemauto'";
510
-        elseif ($actioncode == 'AC_ALL_AUTO')
511
-            $sql .= " AND ca.type = 'systemauto'";
512
-        else {
513
-            if ($actioncode == 'AC_OTH')
514
-                $sql .= " AND ca.type != 'systemauto'";
515
-            if ($actioncode == 'AC_OTH_AUTO')
516
-                $sql .= " AND ca.type = 'systemauto'";
550
+        if ($actioncode == 'AC_NON_AUTO') {
551
+                    $sql .= " AND ca.type != 'systemauto'";
552
+        } elseif ($actioncode == 'AC_ALL_AUTO') {
553
+                    $sql .= " AND ca.type = 'systemauto'";
554
+        } else {
555
+            if ($actioncode == 'AC_OTH') {
556
+                            $sql .= " AND ca.type != 'systemauto'";
557
+            }
558
+            if ($actioncode == 'AC_OTH_AUTO') {
559
+                            $sql .= " AND ca.type = 'systemauto'";
560
+            }
517 561
         }
518
-    }
519
-    else {
520
-        if ($actioncode == 'AC_NON_AUTO')
521
-            $sql .= " AND ca.type != 'systemauto'";
522
-        elseif ($actioncode == 'AC_ALL_AUTO')
523
-            $sql .= " AND ca.type = 'systemauto'";
524
-        else {
562
+    } else {
563
+        if ($actioncode == 'AC_NON_AUTO') {
564
+                    $sql .= " AND ca.type != 'systemauto'";
565
+        } elseif ($actioncode == 'AC_ALL_AUTO') {
566
+                    $sql .= " AND ca.type = 'systemauto'";
567
+        } else {
525 568
             if (is_array($actioncode)) {
526 569
                 $sql .= " AND ca.code IN ('" . implode("','", $actioncode) . "')";
527 570
             } else {
@@ -530,17 +573,22 @@  discard block
 block discarded – undo
530 573
         }
531 574
     }
532 575
 }
533
-if ($resourceid > 0)
576
+if ($resourceid > 0) {
534 577
     $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid);
535
-if ($pid)
578
+}
579
+if ($pid) {
536 580
     $sql .= " AND a.fk_project=" . $db->escape($pid);
537
-if (!$user->rights->societe->client->voir && !$socid)
581
+}
582
+if (!$user->rights->societe->client->voir && !$socid) {
538 583
     $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")";
539
-if ($socid > 0)
584
+}
585
+if ($socid > 0) {
540 586
     $sql .= ' AND a.fk_soc = ' . $socid;
587
+}
541 588
 // We must filter on assignement table
542
-if ($filtert > 0 || $usergroup > 0)
589
+if ($filtert > 0 || $usergroup > 0) {
543 590
     $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
591
+}
544 592
 if ($action == 'show_day') {
545 593
     $sql .= " AND (";
546 594
     $sql .= " (a.datep BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month, $day, $year)) . "'";
@@ -565,8 +613,9 @@  discard block
 block discarded – undo
565 613
     $sql .= " AND a.datep2 > '" . $db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10)) . "')";
566 614
     $sql .= ')';
567 615
 }
568
-if ($type)
616
+if ($type) {
569 617
     $sql .= " AND ca.id = " . $type;
618
+}
570 619
 if ($status == '0') {
571 620
     $sql .= " AND a.percent = 0";
572 621
 }
@@ -585,10 +634,12 @@  discard block
 block discarded – undo
585 634
 // We must filter on assignement table
586 635
 if ($filtert > 0 || $usergroup > 0) {
587 636
     $sql .= " AND (";
588
-    if ($filtert > 0)
589
-        $sql .= "ar.fk_element = " . $filtert;
590
-    if ($usergroup > 0)
591
-        $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
637
+    if ($filtert > 0) {
638
+            $sql .= "ar.fk_element = " . $filtert;
639
+    }
640
+    if ($usergroup > 0) {
641
+            $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
642
+    }
592 643
     $sql .= ")";
593 644
 }
594 645
 // Sort on date
@@ -647,17 +698,18 @@  discard block
 block discarded – undo
647 698
         // They are date start and end of action but modified to not be outside calendar view.
648 699
         if ($event->percentage <= 0) {
649 700
             $event->date_start_in_calendar = $event->datep;
650
-            if ($event->datef != '' && $event->datef >= $event->datep)
651
-                $event->date_end_in_calendar = $event->datef;
652
-            else
653
-                $event->date_end_in_calendar = $event->datep;
654
-        }
655
-        else {
701
+            if ($event->datef != '' && $event->datef >= $event->datep) {
702
+                            $event->date_end_in_calendar = $event->datef;
703
+            } else {
704
+                            $event->date_end_in_calendar = $event->datep;
705
+            }
706
+        } else {
656 707
             $event->date_start_in_calendar = $event->datep;
657
-            if ($event->datef != '' && $event->datef >= $event->datep)
658
-                $event->date_end_in_calendar = $event->datef;
659
-            else
660
-                $event->date_end_in_calendar = $event->datep;
708
+            if ($event->datef != '' && $event->datef >= $event->datep) {
709
+                            $event->date_end_in_calendar = $event->datef;
710
+            } else {
711
+                            $event->date_end_in_calendar = $event->datep;
712
+            }
661 713
         }
662 714
         // Define ponctual property
663 715
         if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
@@ -669,10 +721,12 @@  discard block
 block discarded – undo
669 721
             $event->date_start_in_calendar >= $lastdaytoshow) {
670 722
             // This record is out of visible range
671 723
         } else {
672
-            if ($event->date_start_in_calendar < $firstdaytoshow)
673
-                $event->date_start_in_calendar = $firstdaytoshow;
674
-            if ($event->date_end_in_calendar >= $lastdaytoshow)
675
-                $event->date_end_in_calendar = ($lastdaytoshow - 1);
724
+            if ($event->date_start_in_calendar < $firstdaytoshow) {
725
+                            $event->date_start_in_calendar = $firstdaytoshow;
726
+            }
727
+            if ($event->date_end_in_calendar >= $lastdaytoshow) {
728
+                            $event->date_end_in_calendar = ($lastdaytoshow - 1);
729
+            }
676 730
 
677 731
             // Add an entry in actionarray for each day
678 732
             $daycursor = $event->date_start_in_calendar;
@@ -691,8 +745,9 @@  discard block
 block discarded – undo
691 745
                 $j++;
692 746
 
693 747
                 $daykey += 60 * 60 * 24;
694
-                if ($daykey > $event->date_end_in_calendar)
695
-                    $loop = false;
748
+                if ($daykey > $event->date_end_in_calendar) {
749
+                                    $loop = false;
750
+                }
696 751
             }
697 752
             while ($loop);
698 753
 
@@ -701,8 +756,7 @@  discard block
 block discarded – undo
701 756
         }
702 757
         $i++;
703 758
     }
704
-}
705
-else {
759
+} else {
706 760
     dol_print_error($db);
707 761
 }
708 762
 
@@ -755,14 +809,14 @@  discard block
 block discarded – undo
755 809
             do {
756 810
                 $eventarray[$daykey][] = $event;
757 811
                 $daykey += 60 * 60 * 24;
758
-                if ($daykey > $event->date_end_in_calendar)
759
-                    $loop = false;
812
+                if ($daykey > $event->date_end_in_calendar) {
813
+                                    $loop = false;
814
+                }
760 815
             }
761 816
             while ($loop);
762 817
             $i++;
763 818
         }
764
-    }
765
-    else {
819
+    } else {
766 820
         dol_print_error($db);
767 821
     }
768 822
 }
@@ -783,10 +837,14 @@  discard block
 block discarded – undo
783 837
         // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ...
784 838
         //var_dump($ical->cal); exit;
785 839
         $icalevents = array();
786
-        if (is_array($ical->get_event_list()))
787
-            $icalevents = array_merge($icalevents, $ical->get_event_list());        // Add $ical->cal['VEVENT']
788
-        if (is_array($ical->get_freebusy_list()))
789
-            $icalevents = array_merge($icalevents, $ical->get_freebusy_list());  // Add $ical->cal['VFREEBUSY']
840
+        if (is_array($ical->get_event_list())) {
841
+                    $icalevents = array_merge($icalevents, $ical->get_event_list());
842
+        }
843
+        // Add $ical->cal['VEVENT']
844
+        if (is_array($ical->get_freebusy_list())) {
845
+                    $icalevents = array_merge($icalevents, $ical->get_freebusy_list());
846
+        }
847
+        // Add $ical->cal['VFREEBUSY']
790 848
 
791 849
         if (count($icalevents) > 0) {
792 850
             // Duplicate all repeatable events into new entries
@@ -809,19 +867,20 @@  discard block
 block discarded – undo
809 867
                             $tmpdaylightend = dol_mktime(0, 0, 0, 1, 1, 1970, 1) + (int) $ical->cal['STANDARD']['DTSTART'];
810 868
                             //var_dump($tmpcurstart);var_dump($tmpcurend); var_dump($ical->cal['DAYLIGHT']['DTSTART']);var_dump($ical->cal['STANDARD']['DTSTART']);
811 869
                             // Edit datecurstart and datecurend
812
-                            if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend)
813
-                                $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36;
814
-                            else
815
-                                $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36;
816
-                            if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend)
817
-                                $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36;
818
-                            else
819
-                                $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36;
870
+                            if ($tmpcurstart >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
871
+                                                            $datecurstart -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36;
872
+                            } else {
873
+                                                            $datecurstart -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36;
874
+                            }
875
+                            if ($tmpcurend >= $tmpdaylightstart && $tmpcurstart < $tmpdaylightend) {
876
+                                                            $datecurend -= ((int) $ical->cal['DAYLIGHT']['TZOFFSETTO']) * 36;
877
+                            } else {
878
+                                                            $datecurend -= ((int) $ical->cal['STANDARD']['TZOFFSETTO']) * 36;
879
+                            }
820 880
                         }
821 881
                         // datecurstart and datecurend are now GMT date
822 882
                         //var_dump($datecurstart); var_dump($datecurend); exit;
823
-                    }
824
-                    else {
883
+                    } else {
825 884
                         // Not a recongized record
826 885
                         dol_syslog("Found a not recognized repeatable record with unknown date start", LOG_ERR);
827 886
                         continue;
@@ -831,10 +890,14 @@  discard block
 block discarded – undo
831 890
                     $interval = (empty($icalevent['RRULE']['INTERVAL']) ? 1 : $icalevent['RRULE']['INTERVAL']);
832 891
                     $until = empty($icalevent['RRULE']['UNTIL']) ? 0 : dol_stringtotime($icalevent['RRULE']['UNTIL'], 1);
833 892
                     $maxrepeat = empty($icalevent['RRULE']['COUNT']) ? 0 : $icalevent['RRULE']['COUNT'];
834
-                    if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow)
835
-                        continue;  // We discard repeatable event that end before start date to show
836
-                    if ($datecurstart >= $lastdaytoshow)
837
-                        continue;                                   // We discard repeatable event that start after end date to show
893
+                    if ($until && ($until + ($datecurend - $datecurstart)) < $firstdaytoshow) {
894
+                                            continue;
895
+                    }
896
+                    // We discard repeatable event that end before start date to show
897
+                    if ($datecurstart >= $lastdaytoshow) {
898
+                                            continue;
899
+                    }
900
+                    // We discard repeatable event that start after end date to show
838 901
 
839 902
                     $numofevent = 0;
840 903
                     while (($datecurstart < $lastdaytoshow) && (empty($maxrepeat) || ($numofevent < $maxrepeat))) {
@@ -882,8 +945,10 @@  discard block
 block discarded – undo
882 945
             foreach ($icalevents as $icalevent) {
883 946
                 //var_dump($icalevent);
884 947
                 //print $icalevent['SUMMARY'].'->'.var_dump($icalevent).'<br>';exit;
885
-                if (!empty($icalevent['RRULE']))
886
-                    continue;    // We found a repeatable event. It was already split into unitary events, so we discard general rule.
948
+                if (!empty($icalevent['RRULE'])) {
949
+                                    continue;
950
+                }
951
+                // We found a repeatable event. It was already split into unitary events, so we discard general rule.
887 952
 
888 953
 
889 954
                     
@@ -943,19 +1008,21 @@  discard block
 block discarded – undo
943 1008
                     $event->datef = $dateend + $usertime;
944 1009
                     $event->type_code = "ICALEVENT";
945 1010
 
946
-                    if ($icalevent['SUMMARY'])
947
-                        $event->libelle = $icalevent['SUMMARY'];
948
-                    elseif ($icalevent['DESCRIPTION'])
949
-                        $event->libelle = dol_nl2br($icalevent['DESCRIPTION'], 1);
950
-                    else
951
-                        $event->libelle = $langs->trans("ExtSiteNoLabel");
1011
+                    if ($icalevent['SUMMARY']) {
1012
+                                            $event->libelle = $icalevent['SUMMARY'];
1013
+                    } elseif ($icalevent['DESCRIPTION']) {
1014
+                                            $event->libelle = dol_nl2br($icalevent['DESCRIPTION'], 1);
1015
+                    } else {
1016
+                                            $event->libelle = $langs->trans("ExtSiteNoLabel");
1017
+                    }
952 1018
 
953 1019
                     $event->date_start_in_calendar = $event->datep;
954 1020
 
955
-                    if ($event->datef != '' && $event->datef >= $event->datep)
956
-                        $event->date_end_in_calendar = $event->datef;
957
-                    else
958
-                        $event->date_end_in_calendar = $event->datep;
1021
+                    if ($event->datef != '' && $event->datef >= $event->datep) {
1022
+                                            $event->date_end_in_calendar = $event->datef;
1023
+                    } else {
1024
+                                            $event->date_end_in_calendar = $event->datep;
1025
+                    }
959 1026
 
960 1027
                     // Define ponctual property
961 1028
                     if ($event->date_start_in_calendar == $event->date_end_in_calendar) {
@@ -970,10 +1037,12 @@  discard block
 block discarded – undo
970 1037
                         //print 'x'.$datestart.'-'.$dateend;exit;
971 1038
                         // This record is out of visible range
972 1039
                     } else {
973
-                        if ($event->date_start_in_calendar < $firstdaytoshow)
974
-                            $event->date_start_in_calendar = $firstdaytoshow;
975
-                        if ($event->date_end_in_calendar >= $lastdaytoshow)
976
-                            $event->date_end_in_calendar = ($lastdaytoshow - 1);
1040
+                        if ($event->date_start_in_calendar < $firstdaytoshow) {
1041
+                                                    $event->date_start_in_calendar = $firstdaytoshow;
1042
+                        }
1043
+                        if ($event->date_end_in_calendar >= $lastdaytoshow) {
1044
+                                                    $event->date_end_in_calendar = ($lastdaytoshow - 1);
1045
+                        }
977 1046
 
978 1047
                         // Add an entry in actionarray for each day
979 1048
                         $daycursor = $event->date_start_in_calendar;
@@ -992,8 +1061,9 @@  discard block
 block discarded – undo
992 1061
                             $eventarray[$daykey][] = $event;
993 1062
                             $daykey += 60 * 60 * 24;
994 1063
                             $daykeygmt += 60 * 60 * 24;   // Add one day
995
-                            if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar)
996
-                                $loop = false;
1064
+                            if (($event->fulldayevent ? $daykeygmt : $daykey) > $event->date_end_in_calendar) {
1065
+                                                            $loop = false;
1066
+                            }
997 1067
                         }
998 1068
                         while ($loop);
999 1069
                     }
@@ -1030,8 +1100,9 @@  discard block
 block discarded – undo
1030 1100
 if (is_readable($color_file)) {
1031 1101
     include_once $color_file;
1032 1102
 }
1033
-if (!is_array($theme_datacolor))
1103
+if (!is_array($theme_datacolor)) {
1034 1104
     $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
1105
+}
1035 1106
 
1036 1107
 
1037 1108
 if (empty($action) || $action == 'show_month') {      // View by month
@@ -1057,8 +1128,9 @@  discard block
 block discarded – undo
1057 1128
         if (!empty($conf->dol_optimize_smallscreen)) {
1058 1129
             $labelshort = array(0 => 'SundayMin', 1 => 'MondayMin', 2 => 'TuesdayMin', 3 => 'WednesdayMin', 4 => 'ThursdayMin', 5 => 'FridayMin', 6 => 'SaturdayMin');
1059 1130
             print $langs->trans($labelshort[$numdayinweek]);
1060
-        } else
1061
-            print $langs->trans("Day" . $numdayinweek);
1131
+        } else {
1132
+                    print $langs->trans("Day" . $numdayinweek);
1133
+        }
1062 1134
         print '  </td>' . "\n";
1063 1135
         $i++;
1064 1136
     }
@@ -1075,8 +1147,9 @@  discard block
 block discarded – undo
1075 1147
             /* Show days before the beginning of the current month (previous month)  */
1076 1148
             if ($tmpday <= 0) {
1077 1149
                 $style = 'cal_other_month cal_past';
1078
-                if ($iter_day == 6)
1079
-                    $style .= ' cal_other_month_right';
1150
+                if ($iter_day == 6) {
1151
+                                    $style .= ' cal_other_month_right';
1152
+                }
1080 1153
                 echo '  <td class="' . $style . ' nowrap" width="14%" valign="top">';
1081 1154
                 show_day_events($db, $max_day_in_prev_month + $tmpday, $prev_month, $prev_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1082 1155
                 echo "  </td>\n";
@@ -1085,15 +1158,19 @@  discard block
 block discarded – undo
1085 1158
             elseif ($tmpday <= $max_day_in_month) {
1086 1159
                 $curtime = dol_mktime(0, 0, 0, $month, $tmpday, $year);
1087 1160
                 $style = 'cal_current_month';
1088
-                if ($iter_day == 6)
1089
-                    $style .= ' cal_current_month_right';
1161
+                if ($iter_day == 6) {
1162
+                                    $style .= ' cal_current_month_right';
1163
+                }
1090 1164
                 $today = 0;
1091
-                if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year)
1092
-                    $today = 1;
1093
-                if ($today)
1094
-                    $style = 'cal_today';
1095
-                if ($curtime < $todaytms)
1096
-                    $style .= ' cal_past';
1165
+                if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $month && $todayarray['year'] == $year) {
1166
+                                    $today = 1;
1167
+                }
1168
+                if ($today) {
1169
+                                    $style = 'cal_today';
1170
+                }
1171
+                if ($curtime < $todaytms) {
1172
+                                    $style .= ' cal_past';
1173
+                }
1097 1174
                 //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style);
1098 1175
                 echo '  <td class="' . $style . ' nowrap" width="14%" valign="top">';
1099 1176
                 show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
@@ -1102,8 +1179,9 @@  discard block
 block discarded – undo
1102 1179
             /* Show days after the current month (next month) */
1103 1180
             else {
1104 1181
                 $style = 'cal_other_month';
1105
-                if ($iter_day == 6)
1106
-                    $style .= ' cal_other_month_right';
1182
+                if ($iter_day == 6) {
1183
+                                    $style .= ' cal_other_month_right';
1184
+                }
1107 1185
                 echo '  <td class="' . $style . ' nowrap" width="14%" valign="top">';
1108 1186
                 show_day_events($db, $tmpday - $max_day_in_month, $next_month, $next_year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam);
1109 1187
                 echo "</td>\n";
@@ -1118,8 +1196,7 @@  discard block
 block discarded – undo
1118 1196
     print '<input type="hidden" name="actionmove" value="mupdate">';
1119 1197
     print '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag($_SERVER['PHP_SELF']) . '?' . dol_escape_htmltag($_SERVER['QUERY_STRING']) . '">';
1120 1198
     print '<input type="hidden" name="newdate" id="newdate">';
1121
-}
1122
-elseif ($action == 'show_week') { // View by week
1199
+} elseif ($action == 'show_week') { // View by week
1123 1200
     $newparam = $param;   // newparam is for birthday links
1124 1201
     $newparam = preg_replace('/showbirthday=/i', 'showbirthday_=', $newparam); // To avoid replacement when replace day= is done
1125 1202
     $newparam = preg_replace('/action=show_month&?/i', '', $newparam);
@@ -1152,14 +1229,17 @@  discard block
 block discarded – undo
1152 1229
         $tmpyear = $tmparray['year'];
1153 1230
 
1154 1231
         $style = 'cal_current_month';
1155
-        if ($iter_day == 6)
1156
-            $style .= ' cal_other_month_right';
1232
+        if ($iter_day == 6) {
1233
+                    $style .= ' cal_other_month_right';
1234
+        }
1157 1235
         $today = 0;
1158 1236
         $todayarray = dol_getdate($now, 'fast');
1159
-        if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear)
1160
-            $today = 1;
1161
-        if ($today)
1162
-            $style = 'cal_today';
1237
+        if ($todayarray['mday'] == $tmpday && $todayarray['mon'] == $tmpmonth && $todayarray['year'] == $tmpyear) {
1238
+                    $today = 1;
1239
+        }
1240
+        if ($today) {
1241
+                    $style = 'cal_today';
1242
+        }
1163 1243
 
1164 1244
         echo '  <td class="' . $style . '" width="14%" valign="top">';
1165 1245
         show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300);
@@ -1173,8 +1253,7 @@  discard block
 block discarded – undo
1173 1253
     echo '<input type="hidden" name="actionmove" value="mupdate">';
1174 1254
     echo '<input type="hidden" name="backtopage" value="' . dol_escape_htmltag($_SERVER['PHP_SELF']) . '?' . dol_escape_htmltag($_SERVER['QUERY_STRING']) . '">';
1175 1255
     echo '<input type="hidden" name="newdate" id="newdate">';
1176
-}
1177
-else {    // View by day
1256
+} else {    // View by day
1178 1257
     $newparam = $param;   // newparam is for birthday links
1179 1258
     $newparam = preg_replace('/action=show_month&?/i', '', $newparam);
1180 1259
     $newparam = preg_replace('/action=show_week&?/i', '', $newparam);
@@ -1184,8 +1263,9 @@  discard block
 block discarded – undo
1184 1263
     $style = 'cal_current_month cal_current_month_oneday';
1185 1264
     $today = 0;
1186 1265
     $todayarray = dol_getdate($now, 'fast');
1187
-    if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year)
1188
-        $today = 1;
1266
+    if ($todayarray['mday'] == $day && $todayarray['mon'] == $month && $todayarray['year'] == $year) {
1267
+            $today = 1;
1268
+    }
1189 1269
     //if ($today) $style='cal_today';
1190 1270
 
1191 1271
     $timestamp = dol_mktime(12, 0, 0, $month, $day, $year);
@@ -1225,10 +1305,12 @@  discard block
 block discarded – undo
1225 1305
         $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
1226 1306
         $minhour = round($tmp[0], 0);
1227 1307
         $maxhour = round($tmp[1], 0);
1228
-        if ($minhour > 23)
1229
-            $minhour = 23;
1230
-        if ($maxhour < 1)
1231
-            $maxhour = 1;
1308
+        if ($minhour > 23) {
1309
+                    $minhour = 23;
1310
+        }
1311
+        if ($maxhour < 1) {
1312
+                    $maxhour = 1;
1313
+        }
1232 1314
         if ($maxhour <= $minhour) {
1233 1315
             $maxhour = $minhour + 1;
1234 1316
         }
@@ -1304,10 +1386,11 @@  discard block
 block discarded – undo
1304 1386
         print 'action=show_day&day=' . str_pad($day, 2, "0", STR_PAD_LEFT) . '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $year;
1305 1387
         print $newparam;
1306 1388
         print '">';
1307
-        if ($showinfo)
1308
-            print dol_print_date($curtime, 'daytextshort');
1309
-        else
1310
-            print dol_print_date($curtime, '%d');
1389
+        if ($showinfo) {
1390
+                    print dol_print_date($curtime, 'daytextshort');
1391
+        } else {
1392
+                    print dol_print_date($curtime, '%d');
1393
+        }
1311 1394
         print '</a>';
1312 1395
         print '</div><div class="floatright nowrap">';
1313 1396
         if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
@@ -1367,10 +1450,10 @@  discard block
 block discarded – undo
1367 1450
                         }
1368 1451
                         //var_dump($cacheusers[$event->userownerid]->color);
1369 1452
                         // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1370
-                        if (!empty($cacheusers[$event->userownerid]->color))
1371
-                            $color = $cacheusers[$event->userownerid]->color;
1372
-                    }
1373
-                    else if ($event->type_code == 'ICALEVENT') {      // Event come from external ical file
1453
+                        if (!empty($cacheusers[$event->userownerid]->color)) {
1454
+                                                    $color = $cacheusers[$event->userownerid]->color;
1455
+                        }
1456
+                    } else if ($event->type_code == 'ICALEVENT') {      // Event come from external ical file
1374 1457
                         $numical++;
1375 1458
                         if (!empty($event->icalname)) {
1376 1459
                             if (!isset($numicals[dol_string_nospecial($event->icalname)])) {
@@ -1398,8 +1481,9 @@  discard block
 block discarded – undo
1398 1481
                         }
1399 1482
                         //var_dump($cacheusers[$event->userownerid]->color);
1400 1483
                         // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event)
1401
-                        if (!empty($cacheusers[$event->userownerid]->color))
1402
-                            $color = $cacheusers[$event->userownerid]->color;
1484
+                        if (!empty($cacheusers[$event->userownerid]->color)) {
1485
+                                                    $color = $cacheusers[$event->userownerid]->color;
1486
+                        }
1403 1487
                     }
1404 1488
 
1405 1489
                     if ($color < 0) { // Color was not set on user card. Set color according to color index.
@@ -1410,8 +1494,10 @@  discard block
 block discarded – undo
1410 1494
                         } else {
1411 1495
                             $colorindex = $nextindextouse;
1412 1496
                             $colorindexused[$idusertouse] = $colorindex;
1413
-                            if (!empty($theme_datacolor[$nextindextouse + 1]))
1414
-                                $nextindextouse++; // Prepare to use next color
1497
+                            if (!empty($theme_datacolor[$nextindextouse + 1])) {
1498
+                                                            $nextindextouse++;
1499
+                            }
1500
+                            // Prepare to use next color
1415 1501
                         }
1416 1502
                         //print '|'.($color).'='.($idusertouse?$idusertouse:0).'='.$colorindex.'<br>';
1417 1503
                         // Define color
@@ -1501,8 +1587,9 @@  discard block
 block discarded – undo
1501 1587
                             if ($tmpyearstart == $annee && $tmpmonthstart == $mois && $tmpdaystart == $jour) {
1502 1588
                                 $daterange .= dol_print_date($event->date_start_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user
1503 1589
                                 if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1504
-                                    if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend)
1505
-                                        $daterange .= '-';
1590
+                                    if ($tmpyearstart == $tmpyearend && $tmpmonthstart == $tmpmonthend && $tmpdaystart == $tmpdayend) {
1591
+                                                                            $daterange .= '-';
1592
+                                    }
1506 1593
                                     //else
1507 1594
                                     //print '...';
1508 1595
                                 }
@@ -1514,11 +1601,12 @@  discard block
 block discarded – undo
1514 1601
                             }
1515 1602
                             // Hour end
1516 1603
                             if ($event->date_end_in_calendar && $event->date_start_in_calendar != $event->date_end_in_calendar) {
1517
-                                if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour)
1518
-                                    $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M'); // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user
1604
+                                if ($tmpyearend == $annee && $tmpmonthend == $mois && $tmpdayend == $jour) {
1605
+                                                                    $daterange .= dol_print_date($event->date_end_in_calendar, '%H:%M');
1606
+                                }
1607
+                                // Il faudrait utiliser ici tzuser, mais si on ne peut pas car qd on rentre un date dans fiche action, en input la conversion local->gmt se base sur le TZ server et non user
1519 1608
                             }
1520
-                        }
1521
-                        else {
1609
+                        } else {
1522 1610
                             if ($showinfo) {
1523 1611
                                 print $langs->trans("EventOnFullDay") . "<br>\n";
1524 1612
                             }
@@ -1528,9 +1616,9 @@  discard block
 block discarded – undo
1528 1616
                         $titletoshow = $daterange;
1529 1617
                         $titletoshow .= ($titletoshow ? ' ' : '') . $event->libelle;
1530 1618
 
1531
-                        if ($event->type_code == 'ICALEVENT')
1532
-                            print $titletoshow;
1533
-                        else {
1619
+                        if ($event->type_code == 'ICALEVENT') {
1620
+                                                    print $titletoshow;
1621
+                        } else {
1534 1622
                             $savlabel = $event->label ? $event->label : $event->libelle;
1535 1623
                             $event->label = $titletoshow;
1536 1624
                             $event->libelle = $titletoshow;
@@ -1543,8 +1631,9 @@  discard block
 block discarded – undo
1543 1631
                         $listofusertoshow = '';
1544 1632
                         $posuserassigned = 0;
1545 1633
                         foreach ($event->userassigned as $tmpid => $tmpdata) {
1546
-                            if (!$posuserassigned && $titletoshow)
1547
-                                $listofusertoshow .= '<br>';
1634
+                            if (!$posuserassigned && $titletoshow) {
1635
+                                                            $listofusertoshow .= '<br>';
1636
+                            }
1548 1637
                             $posuserassigned++;
1549 1638
                             if (empty($cacheusers[$tmpid])) {
1550 1639
                                 $newuser = new User($db);
@@ -1556,8 +1645,9 @@  discard block
 block discarded – undo
1556 1645
                         }
1557 1646
                         print $listofusertoshow;
1558 1647
 
1559
-                        if ($event->type_code == 'ICALEVENT')
1560
-                            print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')';
1648
+                        if ($event->type_code == 'ICALEVENT') {
1649
+                                                    print '<br>(' . dol_trunc($event->icalname, $maxnbofchar) . ')';
1650
+                        }
1561 1651
 
1562 1652
                         // If action related to company / contact
1563 1653
                         $linerelatedto = '';
@@ -1566,31 +1656,38 @@  discard block
 block discarded – undo
1566 1656
                                 $thirdparty = new Societe($db);
1567 1657
                                 $thirdparty->fetch($event->societe->id);
1568 1658
                                 $cachethirdparties[$event->societe->id] = $thirdparty;
1569
-                            } else
1570
-                                $thirdparty = $cachethirdparties[$event->societe->id];
1571
-                            if (!empty($thirdparty->id))
1572
-                                $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
1659
+                            } else {
1660
+                                                            $thirdparty = $cachethirdparties[$event->societe->id];
1661
+                            }
1662
+                            if (!empty($thirdparty->id)) {
1663
+                                                            $linerelatedto .= $thirdparty->getNomUrl(1, '', 0);
1664
+                            }
1573 1665
                         }
1574 1666
                         if (!empty($event->contact->id) && $event->contact->id > 0) {
1575 1667
                             if (!is_object($cachecontacts[$event->contact->id])) {
1576 1668
                                 $contact = new Contact($db);
1577 1669
                                 $contact->fetch($event->contact->id);
1578 1670
                                 $cachecontacts[$event->contact->id] = $contact;
1579
-                            } else
1580
-                                $contact = $cachecontacts[$event->contact->id];
1581
-                            if ($linerelatedto)
1582
-                                $linerelatedto .= '&nbsp;';
1583
-                            if (!empty($contact->id))
1584
-                                $linerelatedto .= $contact->getNomUrl(1, '', 0);
1671
+                            } else {
1672
+                                                            $contact = $cachecontacts[$event->contact->id];
1673
+                            }
1674
+                            if ($linerelatedto) {
1675
+                                                            $linerelatedto .= '&nbsp;';
1676
+                            }
1677
+                            if (!empty($contact->id)) {
1678
+                                                            $linerelatedto .= $contact->getNomUrl(1, '', 0);
1679
+                            }
1585 1680
                         }
1586 1681
                         if (!empty($event->fk_element) && $event->fk_element > 0 && !empty($event->elementtype) && !empty($conf->global->AGENDA_SHOW_LINKED_OBJECT)) {
1587 1682
                             include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
1588
-                            if ($linerelatedto)
1589
-                                $linerelatedto .= '<br>';
1683
+                            if ($linerelatedto) {
1684
+                                                            $linerelatedto .= '<br>';
1685
+                            }
1590 1686
                             $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1);
1591 1687
                         }
1592
-                        if ($linerelatedto)
1593
-                            print '<br>' . $linerelatedto;
1688
+                        if ($linerelatedto) {
1689
+                                                    print '<br>' . $linerelatedto;
1690
+                        }
1594 1691
                     }
1595 1692
 
1596 1693
                     // Show location
@@ -1606,19 +1703,20 @@  discard block
 block discarded – undo
1606 1703
                     $withstatus = 0;
1607 1704
                     if ($event->type_code != 'BIRTHDAY' && $event->type_code != 'ICALEVENT') {
1608 1705
                         $withstatus = 1;
1609
-                        if ($event->percentage >= 0)
1610
-                            $withstatus = 2;
1706
+                        if ($event->percentage >= 0) {
1707
+                                                    $withstatus = 2;
1708
+                        }
1611 1709
                     }
1612 1710
                     print '<td class="nobottom right nowrap cal_event_right' . ($withstatus >= 2 ? ' cal_event_right_status' : '') . '">';
1613
-                    if ($withstatus)
1614
-                        print $event->getLibStatut(3, 1);
1615
-                    else
1616
-                        print '&nbsp;';
1711
+                    if ($withstatus) {
1712
+                                            print $event->getLibStatut(3, 1);
1713
+                    } else {
1714
+                                            print '&nbsp;';
1715
+                    }
1617 1716
                     print '</td></tr></table>';
1618 1717
                     print '</div><!-- end event ' . $i . ' -->' . "\n";
1619 1718
                     $i++;
1620
-                }
1621
-                else {
1719
+                } else {
1622 1720
                     print '<a href="' . BASE_URI . '?controller=comm/action&method=index&action=' . $action . '&maxprint=0&month=' . $monthshown . '&year=' . $year;
1623 1721
                     print ($status ? '&status=' . $status : '') . ($filter ? '&filter=' . $filter : '');
1624 1722
                     print ($filtert ? '&filtert=' . $filtert : '');
@@ -1635,8 +1733,9 @@  discard block
 block discarded – undo
1635 1733
             break;
1636 1734
         }
1637 1735
     }
1638
-    if (!$i)
1639
-        print '&nbsp;';
1736
+    if (!$i) {
1737
+            print '&nbsp;';
1738
+    }
1640 1739
 
1641 1740
     if (!empty($conf->global->MAIN_JS_SWITCH_AGENDA) && $i > $maxprint && $maxprint) {
1642 1741
         print '<div id="more_' . $ymd . '">' . img_picto("all", "1downarrow_selected.png") . ' +' . $langs->trans("More") . '...</div>';
Please login to merge, or discard this patch.
dolibarr/htdocs/comm/action/list.php 2 patches
Spacing   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -33,19 +33,19 @@  discard block
 block discarded – undo
33 33
     define('NOREDIRECTBYMAINTOLOGIN', 1);
34 34
 }
35 35
 
36
-require DOL_BASE_PATH . '/main.inc.php';
37
-require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
38
-require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
39
-require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
40
-require_once DOL_DOCUMENT_ROOT . '/core/lib/agenda.lib.php';
41
-include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
42
-require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
36
+require DOL_BASE_PATH.'/main.inc.php';
37
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
38
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
39
+require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40
+require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
41
+include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
42
+require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
43 43
 
44 44
 // Load translation files required by the page
45 45
 $langs->loadLangs(array("users", "companies", "agenda", "commercial"));
46 46
 
47 47
 $action = Request::getAlpha('action');
48
-$contextpage = Request::getAz('contextpage') ?? 'actioncommlist';   // To manage different context of search
48
+$contextpage = Request::getAz('contextpage') ?? 'actioncommlist'; // To manage different context of search
49 49
 $resourceid = Request::getNumber("search_resourceid") ?? Request::getNumber("resourceid");
50 50
 $pid = Request::getNumber("search_projectid", [INPUT_POST, INPUT_GET]) ?? Request::getNumber("projectid", [INPUT_POST, INPUT_GET]);
51 51
 $status = Request::getAlpha("search_status") ?? Request::getAlpha("status");
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
155 155
     foreach ($extrafields->attribute_label as $key => $val) {
156 156
         if (!empty($extrafields->attribute_list[$key]))
157
-            $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]);
157
+            $arrayfields["ef.".$key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]);
158 158
     }
159 159
 }
160 160
 
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
     $param = '';
168 168
     if (is_array($_POST)) {
169 169
         foreach ($_POST as $key => $val) {
170
-            $param .= '&' . $key . '=' . urlencode($val);
170
+            $param .= '&'.$key.'='.urlencode($val);
171 171
         }
172 172
     }
173 173
     //print $param;
174
-    header("Location: " . DOL_URL_ROOT . '/comm/action/index.php?' . $param);
174
+    header("Location: ".DOL_URL_ROOT.'/comm/action/index.php?'.$param);
175 175
     exit;
176 176
 }
177 177
 
178 178
 $parameters = array('id' => $socid);
179
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
179
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
180 180
 if ($reshook < 0)
181 181
     setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
182 182
 
183 183
 // Selection of new fields
184
-include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
184
+include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
185 185
 // Purge search criteria
186 186
 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
187 187
     //$actioncode='';
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
 $nav = '';
206 206
 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
207
-$nav .= ' <input type="submit" name="submitdateselect" class="button" value="' . $langs->trans("Refresh") . '">';
207
+$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
208 208
 
209 209
 $now = dol_now();
210 210
 
@@ -216,54 +216,54 @@  discard block
 block discarded – undo
216 216
 
217 217
 $param = '';
218 218
 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"])
219
-    $param .= '&contextpage=' . urlencode($contextpage);
219
+    $param .= '&contextpage='.urlencode($contextpage);
220 220
 if ($limit > 0 && $limit != $conf->liste_limit)
221
-    $param .= '&limit=' . urlencode($limit);
221
+    $param .= '&limit='.urlencode($limit);
222 222
 if ($actioncode != '') {
223 223
     if (is_array($actioncode)) {
224 224
         foreach ($actioncode as $str_action)
225
-            $param .= "&search_actioncode[]=" . urlencode($str_action);
225
+            $param .= "&search_actioncode[]=".urlencode($str_action);
226 226
     } else
227
-        $param .= "&search_actioncode=" . urlencode($actioncode);
227
+        $param .= "&search_actioncode=".urlencode($actioncode);
228 228
 }
229 229
 if ($resourceid > 0)
230
-    $param .= "&search_resourceid=" . urlencode($resourceid);
230
+    $param .= "&search_resourceid=".urlencode($resourceid);
231 231
 if ($status != '' && $status > -1)
232
-    $param .= "&search_status=" . urlencode($status);
232
+    $param .= "&search_status=".urlencode($status);
233 233
 if ($filter)
234
-    $param .= "&search_filter=" . urlencode($filter);
234
+    $param .= "&search_filter=".urlencode($filter);
235 235
 if ($filtert)
236
-    $param .= "&search_filtert=" . urlencode($filtert);
236
+    $param .= "&search_filtert=".urlencode($filtert);
237 237
 if ($socid)
238
-    $param .= "&search_socid=" . urlencode($socid);
238
+    $param .= "&search_socid=".urlencode($socid);
239 239
 if ($showbirthday)
240 240
     $param .= "&search_showbirthday=1";
241 241
 if ($pid)
242
-    $param .= "&search_projectid=" . urlencode($pid);
242
+    $param .= "&search_projectid=".urlencode($pid);
243 243
 if ($type)
244
-    $param .= "&search_type=" . urlencode($type);
244
+    $param .= "&search_type=".urlencode($type);
245 245
 if ($usergroup)
246
-    $param .= "&search_usergroup=" . urlencode($usergroup);
246
+    $param .= "&search_usergroup=".urlencode($usergroup);
247 247
 if ($search_id != '')
248
-    $param .= '&search_title=' . urlencode($search_id);
248
+    $param .= '&search_title='.urlencode($search_id);
249 249
 if ($search_title != '')
250
-    $param .= '&search_title=' . urlencode($search_title);
250
+    $param .= '&search_title='.urlencode($search_title);
251 251
 if (GETPOST('datestartday', 'int'))
252
-    $param .= '&datestartday=' . GETPOST('datestartday', 'int');
252
+    $param .= '&datestartday='.GETPOST('datestartday', 'int');
253 253
 if (GETPOST('datestartmonth', 'int'))
254
-    $param .= '&datestartmonth=' . GETPOST('datestartmonth', 'int');
254
+    $param .= '&datestartmonth='.GETPOST('datestartmonth', 'int');
255 255
 if (GETPOST('datestartyear', 'int'))
256
-    $param .= '&datestartyear=' . GETPOST('datestartyear', 'int');
256
+    $param .= '&datestartyear='.GETPOST('datestartyear', 'int');
257 257
 if (GETPOST('dateendday', 'int'))
258
-    $param .= '&dateendday=' . GETPOST('dateendday', 'int');
258
+    $param .= '&dateendday='.GETPOST('dateendday', 'int');
259 259
 if (GETPOST('dateendmonth', 'int'))
260
-    $param .= '&dateendmonth=' . GETPOST('dateendmonth', 'int');
260
+    $param .= '&dateendmonth='.GETPOST('dateendmonth', 'int');
261 261
 if (GETPOST('dateendyear', 'int'))
262
-    $param .= '&dateendyear=' . GETPOST('dateendyear', 'int');
262
+    $param .= '&dateendyear='.GETPOST('dateendyear', 'int');
263 263
 if ($optioncss != '')
264
-    $param .= '&optioncss=' . urlencode($optioncss);
264
+    $param .= '&optioncss='.urlencode($optioncss);
265 265
 // Add $param from extra fields
266
-include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
266
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
267 267
 
268 268
 $sql = "SELECT";
269 269
 if ($usergroup > 0)
@@ -277,24 +277,24 @@  discard block
 block discarded – undo
277 277
 $sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id";
278 278
 // Add fields from extrafields
279 279
 foreach ($extrafields->attribute_label as $key => $val)
280
-    $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : '');
281
-$sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a";
282
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
280
+    $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
281
+$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
282
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
283 283
 if (!$user->rights->societe->client->voir && !$socid)
284
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
285
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid";
286
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
287
-$sql .= " ," . MAIN_DB_PREFIX . "c_actioncomm as c";
284
+    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
285
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
286
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
287
+$sql .= " ,".MAIN_DB_PREFIX."c_actioncomm as c";
288 288
 // We must filter on resource table
289 289
 if ($resourceid > 0)
290
-    $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r";
290
+    $sql .= ", ".MAIN_DB_PREFIX."element_resources as r";
291 291
 // We must filter on assignement table
292 292
 if ($filtert > 0 || $usergroup > 0)
293
-    $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar";
293
+    $sql .= ", ".MAIN_DB_PREFIX."actioncomm_resources as ar";
294 294
 if ($usergroup > 0)
295
-    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
295
+    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
296 296
 $sql .= " WHERE c.id = a.fk_action";
297
-$sql .= ' AND a.entity IN (' . getEntity('agenda') . ')';
297
+$sql .= ' AND a.entity IN ('.getEntity('agenda').')';
298 298
 // Condition on actioncode
299 299
 if (!empty($actioncode)) {
300 300
     if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
             $sql .= " AND c.type = 'systemauto'";
317 317
         else {
318 318
             if (is_array($actioncode)) {
319
-                $sql .= " AND c.code IN ('" . implode("','", $actioncode) . "')";
319
+                $sql .= " AND c.code IN ('".implode("','", $actioncode)."')";
320 320
             } else {
321
-                $sql .= " AND c.code IN ('" . implode("','", explode(',', $actioncode)) . "')";
321
+                $sql .= " AND c.code IN ('".implode("','", explode(',', $actioncode))."')";
322 322
             }
323 323
         }
324 324
     }
325 325
 }
326 326
 if ($resourceid > 0)
327
-    $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid);
327
+    $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
328 328
 if ($pid)
329
-    $sql .= " AND a.fk_project=" . $db->escape($pid);
329
+    $sql .= " AND a.fk_project=".$db->escape($pid);
330 330
 if (!$user->rights->societe->client->voir && !$socid)
331
-    $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")";
331
+    $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = ".$user->id.")";
332 332
 if ($socid > 0)
333
-    $sql .= " AND s.rowid = " . $socid;
333
+    $sql .= " AND s.rowid = ".$socid;
334 334
 // We must filter on assignement table
335 335
 if ($filtert > 0 || $usergroup > 0)
336 336
     $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
337 337
 if ($type)
338
-    $sql .= " AND c.id = " . $type;
338
+    $sql .= " AND c.id = ".$type;
339 339
 if ($status == '0') {
340 340
     $sql .= " AND a.percent = 0";
341 341
 }
@@ -362,21 +362,21 @@  discard block
 block discarded – undo
362 362
 if ($filtert > 0 || $usergroup > 0) {
363 363
     $sql .= " AND (";
364 364
     if ($filtert > 0)
365
-        $sql .= "(ar.fk_element = " . $filtert . " OR (ar.fk_element IS NULL AND a.fk_user_action=" . $filtert . "))"; // The OR is for backward compatibility
365
+        $sql .= "(ar.fk_element = ".$filtert." OR (ar.fk_element IS NULL AND a.fk_user_action=".$filtert."))"; // The OR is for backward compatibility
366 366
     if ($usergroup > 0)
367
-        $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
367
+        $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
368 368
     $sql .= ")";
369 369
 }
370 370
 
371 371
 // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
372 372
 if ($dateselect > 0)
373
-    $sql .= " AND ((a.datep2 >= '" . $db->idate($dateselect) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "') OR (a.datep2 IS NULL AND a.datep > '" . $db->idate($dateselect - 3600) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "'))";
373
+    $sql .= " AND ((a.datep2 >= '".$db->idate($dateselect)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."') OR (a.datep2 IS NULL AND a.datep > '".$db->idate($dateselect - 3600)."' AND a.datep <= '".$db->idate($dateselect + 3600 * 24 - 1)."'))";
374 374
 if ($datestart > 0)
375
-    $sql .= " AND a.datep BETWEEN '" . $db->idate($datestart) . "' AND '" . $db->idate($datestart + 3600 * 24 - 1) . "'";
375
+    $sql .= " AND a.datep BETWEEN '".$db->idate($datestart)."' AND '".$db->idate($datestart + 3600 * 24 - 1)."'";
376 376
 if ($dateend > 0)
377
-    $sql .= " AND a.datep2 BETWEEN '" . $db->idate($dateend) . "' AND '" . $db->idate($dateend + 3600 * 24 - 1) . "'";
377
+    $sql .= " AND a.datep2 BETWEEN '".$db->idate($dateend)."' AND '".$db->idate($dateend + 3600 * 24 - 1)."'";
378 378
 // Add where from extra fields
379
-include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
379
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
380 380
 
381 381
 $sql .= $db->order($sortfield, $sortorder);
382 382
 
@@ -402,30 +402,30 @@  discard block
 block discarded – undo
402 402
     $num = $db->num_rows($resql);
403 403
 
404 404
     // Local calendar
405
-    $newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> ' . $langs->trans("LocalAgenda") . ' &nbsp; </div>';
405
+    $newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
406 406
     //$newtitle=$langs->trans($title);
407 407
 
408 408
     $tabactive = 'cardlist';
409 409
 
410 410
     $head = calendars_prepare_head($param);
411 411
 
412
-    print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
412
+    print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
413 413
 
414 414
     if ($optioncss != '')
415
-        print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
416
-    print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
415
+        print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
416
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
417 417
     print '<input type="hidden" name="action" value="list">';
418 418
     print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
419
-    print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
420
-    print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
421
-    print '<input type="hidden" name="page" value="' . $page . '">';
422
-    print '<input type="hidden" name="type" value="' . $type . '">';
419
+    print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
420
+    print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
421
+    print '<input type="hidden" name="page" value="'.$page.'">';
422
+    print '<input type="hidden" name="type" value="'.$type.'">';
423 423
     $nav = '';
424 424
 
425 425
     //if ($actioncode)    $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
426 426
     //if ($resourceid)      $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
427 427
     if ($filter)
428
-        $nav .= '<input type="hidden" name="search_filter" value="' . $filter . '">';
428
+        $nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
429 429
     //if ($filtert)         $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
430 430
     //if ($socid)           $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
431 431
     if ($showbirthday)
@@ -471,16 +471,16 @@  discard block
 block discarded – undo
471 471
     if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) {
472 472
         $tmpforcreatebutton = dol_getdate(dol_now(), true);
473 473
 
474
-        $newparam .= '&month=' . str_pad($month, 2, "0", STR_PAD_LEFT) . '&year=' . $tmpforcreatebutton['year'];
474
+        $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
475 475
 
476 476
         //$param='month='.$monthshown.'&year='.$year;
477 477
         $hourminsec = '100000';
478
-        $newcardbutton = '<a class="butActionNew" href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&datep=' . sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']) . $hourminsec . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . ($newparam ? '?' . $newparam : '')) . '"><span class="valignmiddle">' . $langs->trans("AddAction") . '</span>';
478
+        $newcardbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')).'"><span class="valignmiddle">'.$langs->trans("AddAction").'</span>';
479 479
         $newcardbutton .= '<span class="fa fa-plus-circle valignmiddle"></span>';
480 480
         $newcardbutton .= '</a>';
481 481
     }
482 482
 
483
-    print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav . $newcardbutton, '', $limit);
483
+    print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit);
484 484
 
485 485
     $moreforfilter = '';
486 486
 
@@ -490,17 +490,17 @@  discard block
 block discarded – undo
490 490
         $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
491 491
     $i = 0;
492 492
     print '<div class="div-table-responsive">';
493
-    print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
493
+    print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
494 494
 
495 495
     print '<tr class="liste_titre_filter">';
496 496
     if (!empty($arrayfields['a.id']['checked']))
497
-        print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="' . $search_id . '"></td>';
497
+        print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
498 498
     if (!empty($arrayfields['owner']['checked']))
499 499
         print '<td class="liste_titre"></td>';
500 500
     if (!empty($arrayfields['c.libelle']['checked']))
501 501
         print '<td class="liste_titre"></td>';
502 502
     if (!empty($arrayfields['a.label']['checked']))
503
-        print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="' . $search_title . '"></td>';
503
+        print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
504 504
     if (!empty($arrayfields['a.datep']['checked'])) {
505 505
         print '<td class="liste_titre nowraponall" align="center">';
506 506
         print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0);
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
         print '<td class="liste_titre"></td>';
521 521
 
522 522
     // Extra fields
523
-    include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
523
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
524 524
 
525 525
     // Fields from hook
526 526
     $parameters = array('arrayfields' => $arrayfields);
527
-    $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters);    // Note that $action and $object may have been modified by hook
527
+    $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
528 528
     print $hookmanager->resPrint;
529 529
 
530 530
     if (!empty($arrayfields['a.datec']['checked']))
@@ -566,11 +566,11 @@  discard block
 block discarded – undo
566 566
         print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "a.fk_element", $param, "", "", $sortfield, $sortorder);
567 567
 
568 568
     // Extra fields
569
-    include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
569
+    include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
570 570
 
571 571
     // Hook fields
572 572
     $parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder);
573
-    $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters);    // Note that $action and $object may have been modified by hook
573
+    $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
574 574
     print $hookmanager->resPrint;
575 575
 
576 576
     if (!empty($arrayfields['a.datec']['checked']))
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
     $now = dol_now();
588 588
     $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
589 589
 
590
-    require_once DOL_DOCUMENT_ROOT . '/comm/action/class/cactioncomm.class.php';
590
+    require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
591 591
     $caction = new CActionComm($db);
592 592
     $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
593 593
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 
619 619
         // User owner
620 620
         if (!empty($arrayfields['owner']['checked'])) {
621
-            print '<td class="' . ($conf->browser->name != 'chrome' ? '' : 'tdoverflowmax100') . '">'; // With edge and chrom the td overflow is not supported correctly when content is not full text.
621
+            print '<td class="'.($conf->browser->name != 'chrome' ? '' : 'tdoverflowmax100').'">'; // With edge and chrom the td overflow is not supported correctly when content is not full text.
622 622
             if ($obj->fk_user_action > 0) {
623 623
                 $userstatic->fetch($obj->fk_user_action);
624 624
                 print $userstatic->getNomUrl(-1);
@@ -635,17 +635,17 @@  discard block
 block discarded – undo
635 635
                     print img_picto('', $actionstatic->type_picto);
636 636
                 else {
637 637
                     if ($actionstatic->type_code == 'AC_RDV')
638
-                        print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright') . ' ';
638
+                        print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' ';
639 639
                     elseif ($actionstatic->type_code == 'AC_TEL')
640
-                        print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright') . ' ';
640
+                        print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' ';
641 641
                     elseif ($actionstatic->type_code == 'AC_FAX')
642
-                        print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright') . ' ';
642
+                        print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' ';
643 643
                     elseif ($actionstatic->type_code == 'AC_EMAIL')
644
-                        print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright') . ' ';
644
+                        print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' ';
645 645
                     elseif ($actionstatic->type_code == 'AC_INT')
646
-                        print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright') . ' ';
646
+                        print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' ';
647 647
                     elseif (!preg_match('/_AUTO/', $actionstatic->type_code))
648
-                        print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright') . ' ';
648
+                        print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright').' ';
649 649
                 }
650 650
             }
651 651
             $labeltype = $obj->type_code;
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
             if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning))
679 679
                 $late = 1;
680 680
             if ($late)
681
-                print img_warning($langs->trans("Late")) . ' ';
681
+                print img_warning($langs->trans("Late")).' ';
682 682
             print '</td>';
683 683
         }
684 684
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
             print '<td>';
729 729
             //var_dump($obj->fkelement.' '.$obj->elementtype);
730 730
             if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
731
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
731
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
732 732
                 print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1);
733 733
             } else {
734 734
                 print "&nbsp;";
@@ -737,25 +737,25 @@  discard block
 block discarded – undo
737 737
         }
738 738
 
739 739
         // Extra fields
740
-        include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_print_fields.tpl.php';
740
+        include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
741 741
         // Fields from hook
742 742
         $parameters = array('arrayfields' => $arrayfields, 'obj' => $obj);
743
-        $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters);    // Note that $action and $object may have been modified by hook
743
+        $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
744 744
         print $hookmanager->resPrint;
745 745
 
746 746
         // Date creation
747 747
         if (!empty($arrayfields['a.datec']['checked'])) {
748 748
             // Status/Percent
749
-            print '<td align="center" class="nowrap">' . dol_print_date($obj->datec, 'dayhour') . '</td>';
749
+            print '<td align="center" class="nowrap">'.dol_print_date($obj->datec, 'dayhour').'</td>';
750 750
         }
751 751
         // Date update
752 752
         if (!empty($arrayfields['a.tms']['checked'])) {
753
-            print '<td align="center" class="nowrap">' . dol_print_date($obj->datem, 'dayhour') . '</td>';
753
+            print '<td align="center" class="nowrap">'.dol_print_date($obj->datem, 'dayhour').'</td>';
754 754
         }
755 755
         if (!empty($arrayfields['a.percent']['checked'])) {
756 756
             // Status/Percent
757 757
             $datep = $db->jdate($obj->datep);
758
-            print '<td align="center" class="nowrap">' . $actionstatic->LibStatut($obj->percent, 3, 0, $datep) . '</td>';
758
+            print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 3, 0, $datep).'</td>';
759 759
         }
760 760
         print '<td></td>';
761 761
 
Please login to merge, or discard this patch.
Braces   +243 added lines, -158 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
59 59
 if (GETPOST('search_actioncode', 'array')) {
60 60
     $actioncode = GETPOST('search_actioncode', 'array', 3);
61
-    if (!count($actioncode))
62
-        $actioncode = '0';
63
-}
64
-else {
61
+    if (!count($actioncode)) {
62
+            $actioncode = '0';
63
+    }
64
+    } else {
65 65
     $actioncode = GETPOST("search_actioncode", "alpha", 3) ? GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
66 66
 }
67 67
 if ($actioncode == '' && empty($actioncodearray)) {
@@ -108,30 +108,36 @@  discard block
 block discarded – undo
108 108
 $offset = $limit * $page;
109 109
 if (!$sortorder) {
110 110
     $sortorder = "DESC";
111
-    if ($status == 'todo')
112
-        $sortorder = "DESC";
111
+    if ($status == 'todo') {
112
+            $sortorder = "DESC";
113
+    }
113 114
     //if ($status == 'done') $sortorder="DESC";
114 115
 }
115 116
 if (!$sortfield) {
116 117
     $sortfield = "a.datep";
117
-    if ($status == 'todo')
118
-        $sortfield = "a.datep";
118
+    if ($status == 'todo') {
119
+            $sortfield = "a.datep";
120
+    }
119 121
     //if ($status == 'done') $sortfield="a.datep2";
120 122
 }
121 123
 
122 124
 // Security check
123 125
 $socid = GETPOST("search_socid", 'int') ? GETPOST("search_socid", 'int') : GETPOST("socid", 'int');
124
-if ($user->societe_id)
126
+if ($user->societe_id) {
125 127
     $socid = $user->societe_id;
128
+}
126 129
 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
127
-if ($socid < 0)
130
+if ($socid < 0) {
128 131
     $socid = '';
132
+}
129 133
 
130 134
 $canedit = 1;
131
-if (!$user->rights->agenda->myactions->read)
135
+if (!$user->rights->agenda->myactions->read) {
132 136
     accessforbidden();
133
-if (!$user->rights->agenda->allactions->read)
137
+}
138
+if (!$user->rights->agenda->allactions->read) {
134 139
     $canedit = 0;
140
+}
135 141
 if (!$user->rights->agenda->allactions->read || $filter == 'mine') { // If no permission to see all, we show only affected to me
136 142
     $filtert = $user->id;
137 143
 }
@@ -153,8 +159,9 @@  discard block
 block discarded – undo
153 159
 // Extra fields
154 160
 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
155 161
     foreach ($extrafields->attribute_label as $key => $val) {
156
-        if (!empty($extrafields->attribute_list[$key]))
157
-            $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]);
162
+        if (!empty($extrafields->attribute_list[$key])) {
163
+                    $arrayfields["ef." . $key] = array('label' => $extrafields->attribute_label[$key], 'checked' => $extrafields->attribute_list[$key], 'position' => $extrafields->attribute_pos[$key], 'enabled' => $extrafields->attribute_perms[$key]);
164
+        }
158 165
     }
159 166
 }
160 167
 
@@ -177,8 +184,9 @@  discard block
 block discarded – undo
177 184
 
178 185
 $parameters = array('id' => $socid);
179 186
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
180
-if ($reshook < 0)
187
+if ($reshook < 0) {
181 188
     setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
189
+}
182 190
 
183 191
 // Selection of new fields
184 192
 include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
@@ -215,59 +223,82 @@  discard block
 block discarded – undo
215 223
 $listofextcals = array();
216 224
 
217 225
 $param = '';
218
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"])
226
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
219 227
     $param .= '&contextpage=' . urlencode($contextpage);
220
-if ($limit > 0 && $limit != $conf->liste_limit)
228
+}
229
+if ($limit > 0 && $limit != $conf->liste_limit) {
221 230
     $param .= '&limit=' . urlencode($limit);
231
+}
222 232
 if ($actioncode != '') {
223 233
     if (is_array($actioncode)) {
224
-        foreach ($actioncode as $str_action)
225
-            $param .= "&search_actioncode[]=" . urlencode($str_action);
226
-    } else
227
-        $param .= "&search_actioncode=" . urlencode($actioncode);
228
-}
229
-if ($resourceid > 0)
234
+        foreach ($actioncode as $str_action) {
235
+                    $param .= "&search_actioncode[]=" . urlencode($str_action);
236
+        }
237
+    } else {
238
+            $param .= "&search_actioncode=" . urlencode($actioncode);
239
+    }
240
+    }
241
+if ($resourceid > 0) {
230 242
     $param .= "&search_resourceid=" . urlencode($resourceid);
231
-if ($status != '' && $status > -1)
243
+}
244
+if ($status != '' && $status > -1) {
232 245
     $param .= "&search_status=" . urlencode($status);
233
-if ($filter)
246
+}
247
+if ($filter) {
234 248
     $param .= "&search_filter=" . urlencode($filter);
235
-if ($filtert)
249
+}
250
+if ($filtert) {
236 251
     $param .= "&search_filtert=" . urlencode($filtert);
237
-if ($socid)
252
+}
253
+if ($socid) {
238 254
     $param .= "&search_socid=" . urlencode($socid);
239
-if ($showbirthday)
255
+}
256
+if ($showbirthday) {
240 257
     $param .= "&search_showbirthday=1";
241
-if ($pid)
258
+}
259
+if ($pid) {
242 260
     $param .= "&search_projectid=" . urlencode($pid);
243
-if ($type)
261
+}
262
+if ($type) {
244 263
     $param .= "&search_type=" . urlencode($type);
245
-if ($usergroup)
264
+}
265
+if ($usergroup) {
246 266
     $param .= "&search_usergroup=" . urlencode($usergroup);
247
-if ($search_id != '')
267
+}
268
+if ($search_id != '') {
248 269
     $param .= '&search_title=' . urlencode($search_id);
249
-if ($search_title != '')
270
+}
271
+if ($search_title != '') {
250 272
     $param .= '&search_title=' . urlencode($search_title);
251
-if (GETPOST('datestartday', 'int'))
273
+}
274
+if (GETPOST('datestartday', 'int')) {
252 275
     $param .= '&datestartday=' . GETPOST('datestartday', 'int');
253
-if (GETPOST('datestartmonth', 'int'))
276
+}
277
+if (GETPOST('datestartmonth', 'int')) {
254 278
     $param .= '&datestartmonth=' . GETPOST('datestartmonth', 'int');
255
-if (GETPOST('datestartyear', 'int'))
279
+}
280
+if (GETPOST('datestartyear', 'int')) {
256 281
     $param .= '&datestartyear=' . GETPOST('datestartyear', 'int');
257
-if (GETPOST('dateendday', 'int'))
282
+}
283
+if (GETPOST('dateendday', 'int')) {
258 284
     $param .= '&dateendday=' . GETPOST('dateendday', 'int');
259
-if (GETPOST('dateendmonth', 'int'))
285
+}
286
+if (GETPOST('dateendmonth', 'int')) {
260 287
     $param .= '&dateendmonth=' . GETPOST('dateendmonth', 'int');
261
-if (GETPOST('dateendyear', 'int'))
288
+}
289
+if (GETPOST('dateendyear', 'int')) {
262 290
     $param .= '&dateendyear=' . GETPOST('dateendyear', 'int');
263
-if ($optioncss != '')
291
+}
292
+if ($optioncss != '') {
264 293
     $param .= '&optioncss=' . urlencode($optioncss);
294
+}
265 295
 // Add $param from extra fields
266 296
 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_param.tpl.php';
267 297
 
268 298
 $sql = "SELECT";
269
-if ($usergroup > 0)
299
+if ($usergroup > 0) {
270 300
     $sql .= " DISTINCT";
301
+}
271 302
 $sql .= " s.nom as societe, s.rowid as socid, s.client, s.email as socemail,";
272 303
 $sql .= " a.id, a.label, a.datep as dp, a.datep2 as dp2,";
273 304
 $sql .= ' a.fk_user_author,a.fk_user_action,';
@@ -276,45 +307,51 @@  discard block
 block discarded – undo
276 307
 $sql .= " c.code as type_code, c.libelle as type_label,";
277 308
 $sql .= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id";
278 309
 // Add fields from extrafields
279
-foreach ($extrafields->attribute_label as $key => $val)
310
+foreach ($extrafields->attribute_label as $key => $val) {
280 311
     $sql .= ($extrafields->attribute_type[$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : '');
312
+}
281 313
 $sql .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a";
282 314
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_extrafields as ef ON (a.id = ef.fk_object) ";
283
-if (!$user->rights->societe->client->voir && !$socid)
315
+if (!$user->rights->societe->client->voir && !$socid) {
284 316
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
317
+}
285 318
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON a.fk_soc = s.rowid";
286 319
 $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
287 320
 $sql .= " ," . MAIN_DB_PREFIX . "c_actioncomm as c";
288 321
 // We must filter on resource table
289
-if ($resourceid > 0)
322
+if ($resourceid > 0) {
290 323
     $sql .= ", " . MAIN_DB_PREFIX . "element_resources as r";
324
+}
291 325
 // We must filter on assignement table
292
-if ($filtert > 0 || $usergroup > 0)
326
+if ($filtert > 0 || $usergroup > 0) {
293 327
     $sql .= ", " . MAIN_DB_PREFIX . "actioncomm_resources as ar";
294
-if ($usergroup > 0)
328
+}
329
+if ($usergroup > 0) {
295 330
     $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
331
+}
296 332
 $sql .= " WHERE c.id = a.fk_action";
297 333
 $sql .= ' AND a.entity IN (' . getEntity('agenda') . ')';
298 334
 // Condition on actioncode
299 335
 if (!empty($actioncode)) {
300 336
     if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
301
-        if ($actioncode == 'AC_NON_AUTO')
302
-            $sql .= " AND c.type != 'systemauto'";
303
-        elseif ($actioncode == 'AC_ALL_AUTO')
304
-            $sql .= " AND c.type = 'systemauto'";
305
-        else {
306
-            if ($actioncode == 'AC_OTH')
307
-                $sql .= " AND c.type != 'systemauto'";
308
-            if ($actioncode == 'AC_OTH_AUTO')
309
-                $sql .= " AND c.type = 'systemauto'";
337
+        if ($actioncode == 'AC_NON_AUTO') {
338
+                    $sql .= " AND c.type != 'systemauto'";
339
+        } elseif ($actioncode == 'AC_ALL_AUTO') {
340
+                    $sql .= " AND c.type = 'systemauto'";
341
+        } else {
342
+            if ($actioncode == 'AC_OTH') {
343
+                            $sql .= " AND c.type != 'systemauto'";
344
+            }
345
+            if ($actioncode == 'AC_OTH_AUTO') {
346
+                            $sql .= " AND c.type = 'systemauto'";
347
+            }
310 348
         }
311
-    }
312
-    else {
313
-        if ($actioncode == 'AC_NON_AUTO')
314
-            $sql .= " AND c.type != 'systemauto'";
315
-        elseif ($actioncode == 'AC_ALL_AUTO')
316
-            $sql .= " AND c.type = 'systemauto'";
317
-        else {
349
+    } else {
350
+        if ($actioncode == 'AC_NON_AUTO') {
351
+                    $sql .= " AND c.type != 'systemauto'";
352
+        } elseif ($actioncode == 'AC_ALL_AUTO') {
353
+                    $sql .= " AND c.type = 'systemauto'";
354
+        } else {
318 355
             if (is_array($actioncode)) {
319 356
                 $sql .= " AND c.code IN ('" . implode("','", $actioncode) . "')";
320 357
             } else {
@@ -323,19 +360,25 @@  discard block
 block discarded – undo
323 360
         }
324 361
     }
325 362
 }
326
-if ($resourceid > 0)
363
+if ($resourceid > 0) {
327 364
     $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = " . $db->escape($resourceid);
328
-if ($pid)
365
+}
366
+if ($pid) {
329 367
     $sql .= " AND a.fk_project=" . $db->escape($pid);
330
-if (!$user->rights->societe->client->voir && !$socid)
368
+}
369
+if (!$user->rights->societe->client->voir && !$socid) {
331 370
     $sql .= " AND (a.fk_soc IS NULL OR sc.fk_user = " . $user->id . ")";
332
-if ($socid > 0)
371
+}
372
+if ($socid > 0) {
333 373
     $sql .= " AND s.rowid = " . $socid;
374
+}
334 375
 // We must filter on assignement table
335
-if ($filtert > 0 || $usergroup > 0)
376
+if ($filtert > 0 || $usergroup > 0) {
336 377
     $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
337
-if ($type)
378
+}
379
+if ($type) {
338 380
     $sql .= " AND c.id = " . $type;
381
+}
339 382
 if ($status == '0') {
340 383
     $sql .= " AND a.percent = 0";
341 384
 }
@@ -354,27 +397,35 @@  discard block
 block discarded – undo
354 397
 if ($status == 'todo') {
355 398
     $sql .= " AND (a.percent >= 0 AND a.percent < 100)";
356 399
 }
357
-if ($search_id)
400
+if ($search_id) {
358 401
     $sql .= natural_search("a.id", $search_id, 1);
359
-if ($search_title)
402
+}
403
+if ($search_title) {
360 404
     $sql .= natural_search("a.label", $search_title);
405
+}
361 406
 // We must filter on assignement table
362 407
 if ($filtert > 0 || $usergroup > 0) {
363 408
     $sql .= " AND (";
364
-    if ($filtert > 0)
365
-        $sql .= "(ar.fk_element = " . $filtert . " OR (ar.fk_element IS NULL AND a.fk_user_action=" . $filtert . "))"; // The OR is for backward compatibility
366
-    if ($usergroup > 0)
367
-        $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
409
+    if ($filtert > 0) {
410
+            $sql .= "(ar.fk_element = " . $filtert . " OR (ar.fk_element IS NULL AND a.fk_user_action=" . $filtert . "))";
411
+    }
412
+    // The OR is for backward compatibility
413
+    if ($usergroup > 0) {
414
+            $sql .= ($filtert > 0 ? " OR " : "") . " ugu.fk_usergroup = " . $usergroup;
415
+    }
368 416
     $sql .= ")";
369 417
 }
370 418
 
371 419
 // The second or of next test is to take event with no end date (we suppose duration is 1 hour in such case)
372
-if ($dateselect > 0)
420
+if ($dateselect > 0) {
373 421
     $sql .= " AND ((a.datep2 >= '" . $db->idate($dateselect) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "') OR (a.datep2 IS NULL AND a.datep > '" . $db->idate($dateselect - 3600) . "' AND a.datep <= '" . $db->idate($dateselect + 3600 * 24 - 1) . "'))";
374
-if ($datestart > 0)
422
+}
423
+if ($datestart > 0) {
375 424
     $sql .= " AND a.datep BETWEEN '" . $db->idate($datestart) . "' AND '" . $db->idate($datestart + 3600 * 24 - 1) . "'";
376
-if ($dateend > 0)
425
+}
426
+if ($dateend > 0) {
377 427
     $sql .= " AND a.datep2 BETWEEN '" . $db->idate($dateend) . "' AND '" . $db->idate($dateend + 3600 * 24 - 1) . "'";
428
+}
378 429
 // Add where from extra fields
379 430
 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_sql.tpl.php';
380 431
 
@@ -411,8 +462,9 @@  discard block
 block discarded – undo
411 462
 
412 463
     print '<form method="POST" id="searchFormList" class="listactionsfilter" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
413 464
 
414
-    if ($optioncss != '')
415
-        print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
465
+    if ($optioncss != '') {
466
+            print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
467
+    }
416 468
     print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
417 469
     print '<input type="hidden" name="action" value="list">';
418 470
     print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@@ -424,12 +476,14 @@  discard block
 block discarded – undo
424 476
 
425 477
     //if ($actioncode)    $nav.='<input type="hidden" name="actioncode" value="'.$actioncode.'">';
426 478
     //if ($resourceid)      $nav.='<input type="hidden" name="resourceid" value="'.$resourceid.'">';
427
-    if ($filter)
428
-        $nav .= '<input type="hidden" name="search_filter" value="' . $filter . '">';
479
+    if ($filter) {
480
+            $nav .= '<input type="hidden" name="search_filter" value="' . $filter . '">';
481
+    }
429 482
     //if ($filtert)         $nav.='<input type="hidden" name="filtert" value="'.$filtert.'">';
430 483
     //if ($socid)           $nav.='<input type="hidden" name="socid" value="'.$socid.'">';
431
-    if ($showbirthday)
432
-        $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
484
+    if ($showbirthday) {
485
+            $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
486
+    }
433 487
     //if ($pid)             $nav.='<input type="hidden" name="projectid" value="'.$pid.'">';
434 488
     //if ($usergroup)       $nav.='<input type="hidden" name="usergroup" value="'.$usergroup.'">';
435 489
     print $nav;
@@ -486,21 +540,26 @@  discard block
 block discarded – undo
486 540
 
487 541
     $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
488 542
     $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
489
-    if ($massactionbutton)
490
-        $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
543
+    if ($massactionbutton) {
544
+            $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
545
+    }
491 546
     $i = 0;
492 547
     print '<div class="div-table-responsive">';
493 548
     print '<table class="tagtable liste' . ($moreforfilter ? " listwithfilterbefore" : "") . '">' . "\n";
494 549
 
495 550
     print '<tr class="liste_titre_filter">';
496
-    if (!empty($arrayfields['a.id']['checked']))
497
-        print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="' . $search_id . '"></td>';
498
-    if (!empty($arrayfields['owner']['checked']))
499
-        print '<td class="liste_titre"></td>';
500
-    if (!empty($arrayfields['c.libelle']['checked']))
501
-        print '<td class="liste_titre"></td>';
502
-    if (!empty($arrayfields['a.label']['checked']))
503
-        print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="' . $search_title . '"></td>';
551
+    if (!empty($arrayfields['a.id']['checked'])) {
552
+            print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="' . $search_id . '"></td>';
553
+    }
554
+    if (!empty($arrayfields['owner']['checked'])) {
555
+            print '<td class="liste_titre"></td>';
556
+    }
557
+    if (!empty($arrayfields['c.libelle']['checked'])) {
558
+            print '<td class="liste_titre"></td>';
559
+    }
560
+    if (!empty($arrayfields['a.label']['checked'])) {
561
+            print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="' . $search_title . '"></td>';
562
+    }
504 563
     if (!empty($arrayfields['a.datep']['checked'])) {
505 564
         print '<td class="liste_titre nowraponall" align="center">';
506 565
         print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0);
@@ -514,10 +573,12 @@  discard block
 block discarded – undo
514 573
     if (!empty($arrayfields['s.nom']['checked'])) {
515 574
         print '<td class="liste_titre"></td>';
516 575
     }
517
-    if (!empty($arrayfields['a.fk_contact']['checked']))
518
-        print '<td class="liste_titre"></td>';
519
-    if (!empty($arrayfields['a.fk_element']['checked']))
520
-        print '<td class="liste_titre"></td>';
576
+    if (!empty($arrayfields['a.fk_contact']['checked'])) {
577
+            print '<td class="liste_titre"></td>';
578
+    }
579
+    if (!empty($arrayfields['a.fk_element']['checked'])) {
580
+            print '<td class="liste_titre"></td>';
581
+    }
521 582
 
522 583
     // Extra fields
523 584
     include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_input.tpl.php';
@@ -527,10 +588,12 @@  discard block
 block discarded – undo
527 588
     $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters);    // Note that $action and $object may have been modified by hook
528 589
     print $hookmanager->resPrint;
529 590
 
530
-    if (!empty($arrayfields['a.datec']['checked']))
531
-        print '<td class="liste_titre"></td>';
532
-    if (!empty($arrayfields['a.tms']['checked']))
533
-        print '<td class="liste_titre"></td>';
591
+    if (!empty($arrayfields['a.datec']['checked'])) {
592
+            print '<td class="liste_titre"></td>';
593
+    }
594
+    if (!empty($arrayfields['a.tms']['checked'])) {
595
+            print '<td class="liste_titre"></td>';
596
+    }
534 597
     if (!empty($arrayfields['a.percent']['checked'])) {
535 598
         print '<td class="liste_titre center">';
536 599
         print $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2);
@@ -545,25 +608,34 @@  discard block
 block discarded – undo
545 608
     print "</tr>\n";
546 609
 
547 610
     print '<tr class="liste_titre">';
548
-    if (!empty($arrayfields['a.id']['checked']))
549
-        print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
550
-    if (!empty($arrayfields['owner']['checked']))
551
-        print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
552
-    if (!empty($arrayfields['c.libelle']['checked']))
553
-        print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
554
-    if (!empty($arrayfields['a.label']['checked']))
555
-        print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
611
+    if (!empty($arrayfields['a.id']['checked'])) {
612
+            print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
613
+    }
614
+    if (!empty($arrayfields['owner']['checked'])) {
615
+            print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
616
+    }
617
+    if (!empty($arrayfields['c.libelle']['checked'])) {
618
+            print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
619
+    }
620
+    if (!empty($arrayfields['a.label']['checked'])) {
621
+            print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
622
+    }
556 623
     //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
557
-    if (!empty($arrayfields['a.datep']['checked']))
558
-        print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep", $param, '', 'align="center"', $sortfield, $sortorder);
559
-    if (!empty($arrayfields['a.datep2']['checked']))
560
-        print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
561
-    if (!empty($arrayfields['s.nom']['checked']))
562
-        print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
563
-    if (!empty($arrayfields['a.fk_contact']['checked']))
564
-        print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "a.fk_contact", $param, "", "", $sortfield, $sortorder);
565
-    if (!empty($arrayfields['a.fk_element']['checked']))
566
-        print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "a.fk_element", $param, "", "", $sortfield, $sortorder);
624
+    if (!empty($arrayfields['a.datep']['checked'])) {
625
+            print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep", $param, '', 'align="center"', $sortfield, $sortorder);
626
+    }
627
+    if (!empty($arrayfields['a.datep2']['checked'])) {
628
+            print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
629
+    }
630
+    if (!empty($arrayfields['s.nom']['checked'])) {
631
+            print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
632
+    }
633
+    if (!empty($arrayfields['a.fk_contact']['checked'])) {
634
+            print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "a.fk_contact", $param, "", "", $sortfield, $sortorder);
635
+    }
636
+    if (!empty($arrayfields['a.fk_element']['checked'])) {
637
+            print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "a.fk_element", $param, "", "", $sortfield, $sortorder);
638
+    }
567 639
 
568 640
     // Extra fields
569 641
     include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_list_search_title.tpl.php';
@@ -573,13 +645,16 @@  discard block
 block discarded – undo
573 645
     $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters);    // Note that $action and $object may have been modified by hook
574 646
     print $hookmanager->resPrint;
575 647
 
576
-    if (!empty($arrayfields['a.datec']['checked']))
577
-        print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
578
-    if (!empty($arrayfields['a.tms']['checked']))
579
-        print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
648
+    if (!empty($arrayfields['a.datec']['checked'])) {
649
+            print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
650
+    }
651
+    if (!empty($arrayfields['a.tms']['checked'])) {
652
+            print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
653
+    }
580 654
 
581
-    if (!empty($arrayfields['a.percent']['checked']))
582
-        print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
655
+    if (!empty($arrayfields['a.percent']['checked'])) {
656
+            print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
657
+    }
583 658
     print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
584 659
     print "</tr>\n";
585 660
 
@@ -622,8 +697,9 @@  discard block
 block discarded – undo
622 697
             if ($obj->fk_user_action > 0) {
623 698
                 $userstatic->fetch($obj->fk_user_action);
624 699
                 print $userstatic->getNomUrl(-1);
625
-            } else
626
-                print '&nbsp;';
700
+            } else {
701
+                            print '&nbsp;';
702
+            }
627 703
             print '</td>';
628 704
         }
629 705
 
@@ -631,28 +707,31 @@  discard block
 block discarded – undo
631 707
         if (!empty($arrayfields['c.libelle']['checked'])) {
632 708
             print '<td>';
633 709
             if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) {
634
-                if ($actionstatic->type_picto)
635
-                    print img_picto('', $actionstatic->type_picto);
636
-                else {
637
-                    if ($actionstatic->type_code == 'AC_RDV')
638
-                        print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright') . ' ';
639
-                    elseif ($actionstatic->type_code == 'AC_TEL')
640
-                        print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright') . ' ';
641
-                    elseif ($actionstatic->type_code == 'AC_FAX')
642
-                        print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright') . ' ';
643
-                    elseif ($actionstatic->type_code == 'AC_EMAIL')
644
-                        print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright') . ' ';
645
-                    elseif ($actionstatic->type_code == 'AC_INT')
646
-                        print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright') . ' ';
647
-                    elseif (!preg_match('/_AUTO/', $actionstatic->type_code))
648
-                        print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright') . ' ';
710
+                if ($actionstatic->type_picto) {
711
+                                    print img_picto('', $actionstatic->type_picto);
712
+                } else {
713
+                    if ($actionstatic->type_code == 'AC_RDV') {
714
+                                            print img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright') . ' ';
715
+                    } elseif ($actionstatic->type_code == 'AC_TEL') {
716
+                                            print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright') . ' ';
717
+                    } elseif ($actionstatic->type_code == 'AC_FAX') {
718
+                                            print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright') . ' ';
719
+                    } elseif ($actionstatic->type_code == 'AC_EMAIL') {
720
+                                            print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright') . ' ';
721
+                    } elseif ($actionstatic->type_code == 'AC_INT') {
722
+                                            print img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright') . ' ';
723
+                    } elseif (!preg_match('/_AUTO/', $actionstatic->type_code)) {
724
+                                            print img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright') . ' ';
725
+                    }
649 726
                 }
650 727
             }
651 728
             $labeltype = $obj->type_code;
652
-            if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype]))
653
-                $labeltype = 'AC_OTH';
654
-            if (!empty($arraylist[$labeltype]))
655
-                $labeltype = $arraylist[$labeltype];
729
+            if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
730
+                            $labeltype = 'AC_OTH';
731
+            }
732
+            if (!empty($arraylist[$labeltype])) {
733
+                            $labeltype = $arraylist[$labeltype];
734
+            }
656 735
             print dol_trunc($labeltype, 28);
657 736
             print '</td>';
658 737
         }
@@ -669,16 +748,21 @@  discard block
 block discarded – undo
669 748
             print '<td align="center">';
670 749
             print dol_print_date($db->jdate($obj->dp), "dayhour");
671 750
             $late = 0;
672
-            if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning))
673
-                $late = 1;
674
-            if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning))
675
-                $late = 1;
676
-            if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning))
677
-                $late = 1;
678
-            if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning))
679
-                $late = 1;
680
-            if ($late)
681
-                print img_warning($langs->trans("Late")) . ' ';
751
+            if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
752
+                            $late = 1;
753
+            }
754
+            if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) {
755
+                            $late = 1;
756
+            }
757
+            if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) {
758
+                            $late = 1;
759
+            }
760
+            if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
761
+                            $late = 1;
762
+            }
763
+            if ($late) {
764
+                            print img_warning($langs->trans("Late")) . ' ';
765
+            }
682 766
             print '</td>';
683 767
         }
684 768
 
@@ -699,8 +783,9 @@  discard block
 block discarded – undo
699 783
                 $societestatic->email = $obj->socemail;
700 784
 
701 785
                 print $societestatic->getNomUrl(1, '', 28);
702
-            } else
703
-                print '&nbsp;';
786
+            } else {
787
+                            print '&nbsp;';
788
+            }
704 789
             print '</td>';
705 790
         }
706 791
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/lib/functions.lib.php 2 patches
Spacing   +547 added lines, -547 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
  * 	\brief			A set of functions for Dolibarr
42 42
  * 					This file contains all frequently used functions.
43 43
  */
44
-include_once DOL_BASE_PATH . '/core/lib/json.lib.php';
44
+include_once DOL_BASE_PATH.'/core/lib/json.lib.php';
45 45
 
46 46
 /**
47 47
  * Function to return value of a static property when class
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function getStaticMember($class, $member)
58 58
 {
59
-    dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
59
+    dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
60 60
 
61 61
     // This part is deprecated. Uncomment if for php 5.2.*, and comment next isset class::member
62 62
     /* if (version_compare(phpversion(), '5.3.0', '<'))
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
     if (isset($class::$member))
83 83
         return $class::$member;
84
-    dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
84
+    dol_print_error('', 'Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
85 85
     return null;
86 86
 }
87 87
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
  */
99 99
 function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
100 100
 {
101
-    require_once DOL_BASE_PATH . "/core/db/" . $type . '.class.php';
101
+    require_once DOL_BASE_PATH."/core/db/".$type.'.class.php';
102 102
 
103
-    $class = 'DoliDB' . ucfirst($type);
103
+    $class = 'DoliDB'.ucfirst($type);
104 104
     $dolidb = new $class($type, $host, $user, $pass, $name, $port);
105 105
     return $dolidb;
106 106
 }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
  */
157 157
 function getBrowserInfo($user_agent)
158 158
 {
159
-    include_once BASE_PATH . '/vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';
159
+    include_once BASE_PATH.'/vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php';
160 160
 
161 161
     $name = 'unknown';
162 162
     $version = '';
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
         $depth = $db->transaction_opened;
270 270
         $disconnectdone = $db->close();
271 271
     }
272
-    dol_syslog("--- End access to " . $_SERVER["PHP_SELF"] . (($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was ' . $depth . ')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
272
+    dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
273 273
 }
274 274
 
275 275
 /**
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
     if (empty($paramname))
317 317
         return 'BadFirstParameterForGETPOST';
318 318
     if (empty($check)) {
319
-        dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
319
+        dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
320 320
         // Enable this line to know who call the GETPOST with '' $check parameter.
321 321
         //var_dump(debug_backtrace()[0]);
322 322
     }
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         $relativepathstring = $_SERVER["PHP_SELF"];
339 339
         // Clean $relativepathstring
340 340
         if (constant('DOL_URL_ROOT'))
341
-            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
341
+            $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
342 342
         $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
343 343
         $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
344 344
         //var_dump($relativepathstring);
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
         // Code for search criteria persistence.
347 347
         // Retrieve values if restore_lastsearch_values
348 348
         if (!empty($_GET['restore_lastsearch_values'])) {        // Use $_GET here and not GETPOST
349
-            if (!empty($_SESSION['lastsearch_values_' . $relativepathstring])) { // If there is saved values
350
-                $tmp = json_decode($_SESSION['lastsearch_values_' . $relativepathstring], true);
349
+            if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) { // If there is saved values
350
+                $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
351 351
                 if (is_array($tmp)) {
352 352
                     foreach ($tmp as $key => $val) {
353 353
                         if ($key == $paramname) { // We are on the requested parameter
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
                 }
359 359
             }
360 360
             // If there is saved contextpage, page or limit
361
-            if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_' . $relativepathstring])) {
362
-                $out = $_SESSION['lastsearch_contextpage_' . $relativepathstring];
363
-            } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_' . $relativepathstring])) {
364
-                $out = $_SESSION['lastsearch_page_' . $relativepathstring];
365
-            } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_' . $relativepathstring])) {
366
-                $out = $_SESSION['lastsearch_limit_' . $relativepathstring];
361
+            if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) {
362
+                $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
363
+            } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) {
364
+                $out = $_SESSION['lastsearch_page_'.$relativepathstring];
365
+            } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) {
366
+                $out = $_SESSION['lastsearch_limit_'.$relativepathstring];
367 367
             }
368 368
         }
369 369
         // Else, retreive default values if we are not doing a sort
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                                         $qualified = 1;
432 432
 
433 433
                                     if ($qualified) {
434
-                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
434
+                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
435 435
                                         foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
436 436
                                             if ($out)
437 437
                                                 $out .= ', ';
@@ -467,11 +467,11 @@  discard block
 block discarded – undo
467 467
                                     if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
468 468
                                         // We made a search from quick search menu, do we still use default filter ?
469 469
                                         if (empty($conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
470
-                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
470
+                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
471 471
                                             $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
472 472
                                         }
473 473
                                     } else {
474
-                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
474
+                                        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
475 475
                                         $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
476 476
                                     }
477 477
                                     break;
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
490 490
     if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
491 491
         $maxloop = 20;
492
-        $loopnb = 0;    // Protection against infinite loop
492
+        $loopnb = 0; // Protection against infinite loop
493 493
         while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {    // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
494 494
             $loopnb++;
495 495
             $newout = '';
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
535 535
                 $newout = $conf->entity;
536 536
             } else
537
-                $newout = '';     // Key not found, we replace with empty string
537
+                $newout = ''; // Key not found, we replace with empty string
538 538
 
539 539
 
540 540
 
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 
562 562
                 
563 563
 //var_dump('__'.$reg[1].'__ -> '.$newout);
564
-            $out = preg_replace('/__' . preg_quote($reg[1], '/') . '__/', $newout, $out);
564
+            $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out);
565 565
         }
566 566
     }
567 567
 
@@ -679,15 +679,15 @@  discard block
 block discarded – undo
679 679
                 else if (isset($_SERVER["SERVER_NAME"]))
680 680
                     return $_SERVER["SERVER_NAME"];
681 681
             }
682
-            return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
682
+            return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
683 683
         }
684 684
 
685 685
         if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) {
686
-            return dol_hash($_SERVER["SERVER_NAME"] . $_SERVER["DOCUMENT_ROOT"] . DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
686
+            return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
687 687
             // Use this for a "readable" cookie name
688 688
             //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
689 689
         }
690
-        return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
690
+        return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
691 691
     }
692 692
 }
693 693
 
@@ -703,12 +703,12 @@  discard block
 block discarded – undo
703 703
  */
704 704
 function dol_include_once($relpath, $classname = '')
705 705
 {
706
-    global $conf, $langs, $user, $mysoc;   // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var']
706
+    global $conf, $langs, $user, $mysoc; // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var']
707 707
 
708 708
     $fullpath = dol_buildpath($relpath);
709 709
 
710 710
     if (!file_exists($fullpath)) {
711
-        dol_syslog('functions::dol_include_once Tried to load unexisting file: ' . $relpath, LOG_ERR);
711
+        dol_syslog('functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_ERR);
712 712
         return false;
713 713
     }
714 714
 
@@ -737,14 +737,14 @@  discard block
 block discarded – undo
737 737
 
738 738
     if ($type == 0 /* empty($type) */) { // For a filesystem path
739 739
         //$res = DOL_BASE_PATH . '' . $path;  // Standard default path
740
-        $res = DOL_BASE_PATH . '/' . $path;  // Standard default path
740
+        $res = DOL_BASE_PATH.'/'.$path; // Standard default path
741 741
         if (isset($conf->file->dol_document_root)) {
742 742
             foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
743 743
                 if ($key == 'main') {
744 744
                     continue;
745 745
                 }
746
-                if (file_exists($dirroot . '/' . $path)) {
747
-                    $res = $dirroot . '/' . $path;
746
+                if (file_exists($dirroot.'/'.$path)) {
747
+                    $res = $dirroot.'/'.$path;
748 748
                     return $res;
749 749
                 }
750 750
             }
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
         // using proxy, rewriting, virtual path, etc...
762 762
         $res = '';
763 763
         if ($type == 1)
764
-            $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path;   // Standard value
764
+            $res = /* DOL_URL_ROOT */ DOL_BASE_URI.'/'.$path; // Standard value
765 765
         if ($type == 2)
766
-            $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path;  // Standard value
766
+            $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH.'/'.$path; // Standard value
767 767
         if ($type == 3)
768
-            $res = DOL_URL_ROOT . '/' . $path;
768
+            $res = DOL_URL_ROOT.'/'.$path;
769 769
 
770 770
         foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
771 771
             if ($key == 'main') {
@@ -773,33 +773,33 @@  discard block
 block discarded – undo
773 773
                     global $dolibarr_main_url_root;
774 774
 
775 775
                     // Define $urlwithroot
776
-                    $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
777
-                    $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;  // This is to use external domain name found into config file
776
+                    $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
777
+                    $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
778 778
                     //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
779 779
 
780
-                    $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot) . '/' . $path;     // Test on start with http is for old conf syntax
780
+                    $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).'/'.$path; // Test on start with http is for old conf syntax
781 781
                 }
782 782
                 continue;
783 783
             }
784
-            preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);    // Take part before '?'
784
+            preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?'
785 785
             if (!empty($regs[1])) {
786 786
                 //print $key.'-'.$dirroot.'/'.$path.'-'.$conf->file->dol_url_root[$type].'<br>'."\n";
787
-                if (file_exists($dirroot . '/' . $regs[1])) {
787
+                if (file_exists($dirroot.'/'.$regs[1])) {
788 788
                     if ($type == 1) {
789
-                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT) . $conf->file->dol_url_root[$key] . '/' . $path;
789
+                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
790 790
                     }
791 791
                     if ($type == 2) {
792
-                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT) . $conf->file->dol_url_root[$key] . '/' . $path;
792
+                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).$conf->file->dol_url_root[$key].'/'.$path;
793 793
                     }
794 794
                     if ($type == 3) {
795 795
                         global $dolibarr_main_url_root;
796 796
 
797 797
                         // Define $urlwithroot
798
-                        $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
799
-                        $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;  // This is to use external domain name found into config file
798
+                        $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
799
+                        $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
800 800
                         //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
801 801
 
802
-                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot) . $conf->file->dol_url_root[$key] . '/' . $path;     // Test on start with http is for old conf syntax
802
+                        $res = (preg_match('/^http/i', $conf->file->dol_url_root[$key]) ? '' : $urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax
803 803
                     }
804 804
                     break;
805 805
                 }
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
     if (empty($native)) {
828 828
         $myclone = unserialize(serialize($object));
829 829
     } else {
830
-        $myclone = clone $object;     // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable)
830
+        $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable)
831 831
     }
832 832
 
833 833
     return $myclone;
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  */
949 949
 function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '')
950 950
 {
951
-    $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°');  // more complete than dol_sanitizeFileName
951
+    $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName
952 952
     $forbidden_chars_to_remove = array();
953 953
     if (is_array($badcharstoreplace))
954 954
         $forbidden_chars_to_replace = $badcharstoreplace;
@@ -1011,12 +1011,12 @@  discard block
 block discarded – undo
1011 1011
 function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0)
1012 1012
 {
1013 1013
     // escape quotes and backslashes, newlines, etc.
1014
-    $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8');  // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1014
+    $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1015 1015
     if (!$keepb)
1016 1016
         $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1017 1017
     if (!$keepn)
1018 1018
         $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1019
-    return htmlentities($tmp, ENT_COMPAT, 'UTF-8');      // TODO Use htmlspecialchars instead, that make only required change for html tags
1019
+    return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags
1020 1020
 }
1021 1021
 
1022 1022
 /**
@@ -1087,14 +1087,14 @@  discard block
 block discarded – undo
1087 1087
         $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
1088 1088
         // If adding log inside HTML page is required
1089 1089
         if (!empty($_REQUEST['logtohtml']) && (!empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || !empty($conf->global->MAIN_LOGTOHTML))) {   // MAIN_LOGTOHTML kept for backward compatibility
1090
-            $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S") . " " . $message;
1090
+            $conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$message;
1091 1091
         }
1092 1092
 
1093 1093
         //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
1094 1094
         // If html log tag enabled and url parameter log defined, we show output log on HTML comments
1095 1095
         if (!empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) {
1096 1096
             print "\n\n<!-- Log start\n";
1097
-            print $message . "\n";
1097
+            print $message."\n";
1098 1098
             print "Log end -->\n";
1099 1099
         }
1100 1100
 
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 
1109 1109
         // This is when server run behind a reverse proxy
1110 1110
         if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
1111
-            $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1111
+            $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"]) ? '' : '->'.$_SERVER['REMOTE_ADDR']);
1112 1112
         // This is when server run normally on a server
1113 1113
         else if (!empty($_SERVER["REMOTE_ADDR"]))
1114 1114
             $data['ip'] = $_SERVER['REMOTE_ADDR'];
@@ -1117,10 +1117,10 @@  discard block
 block discarded – undo
1117 1117
             $data['ip'] = $_SERVER['SERVER_ADDR'];
1118 1118
         // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
1119 1119
         else if (!empty($_SERVER['COMPUTERNAME']))
1120
-            $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1120
+            $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME']) ? '' : '@'.$_SERVER['USERNAME']);
1121 1121
         // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
1122 1122
         else if (!empty($_SERVER['LOGNAME']))
1123
-            $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1123
+            $data['ip'] = '???@'.$_SERVER['LOGNAME'];
1124 1124
         // Loop on each log handler and send output
1125 1125
         foreach ($conf->loghandlers as $loghandlerinstance) {
1126 1126
             if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler)
@@ -1172,10 +1172,10 @@  discard block
 block discarded – undo
1172 1172
 {
1173 1173
     global $conf, $langs, $hookmanager;
1174 1174
 
1175
-    $out = "\n" . '<div class="tabs" data-role="controlgroup" data-type="horizontal">' . "\n";
1175
+    $out = "\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
1176 1176
 
1177 1177
     if ($morehtmlright) {
1178
-        $out .= '<div class="inline-block floatright tabsElem">' . $morehtmlright . '</div>'; // Output right area first so when space is missing, text is in front of tabs and not under.
1178
+        $out .= '<div class="inline-block floatright tabsElem">'.$morehtmlright.'</div>'; // Output right area first so when space is missing, text is in front of tabs and not under.
1179 1179
     }
1180 1180
 
1181 1181
     // Show title
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
         $limittitle = 30;
1187 1187
         $out .= '<a class="tabTitle">';
1188 1188
         if ($picto)
1189
-            $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1190
-        $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>';
1189
+            $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath).' ';
1190
+        $out .= '<span class="tabTitleText">'.dol_trunc($title, $limittitle).'</span>';
1191 1191
         $out .= '</a>';
1192 1192
     }
1193 1193
 
@@ -1227,23 +1227,23 @@  discard block
 block discarded – undo
1227 1227
         }
1228 1228
 
1229 1229
         if ($i < $limittoshow || $isactive) {
1230
-            $out .= '<div class="inline-block tabsElem' . ($isactive ? ' tabsElemActive' : '') . ((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ? ' hideonprint' : '') . '"><!-- id tab = ' . (empty($links[$i][2]) ? '' : $links[$i][2]) . ' -->';
1230
+            $out .= '<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((!$isactive && !empty($conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ? ' hideonprint' : '').'"><!-- id tab = '.(empty($links[$i][2]) ? '' : $links[$i][2]).' -->';
1231 1231
             if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1232 1232
                 if (!empty($links[$i][0])) {
1233
-                    $out .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1233
+                    $out .= '<a class="tabimage'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
1234 1234
                 } else {
1235
-                    $out .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1235
+                    $out .= '<span class="tabspan">'.$links[$i][1].'</span>'."\n";
1236 1236
                 }
1237 1237
             } else if (!empty($links[$i][1])) {
1238 1238
                 //print "x $i $active ".$links[$i][2]." z";
1239 1239
                 if ($isactive) {
1240
-                    $out .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="tabactive tab inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1240
+                    $out .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="tabactive tab inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
1241 1241
                     $out .= $links[$i][1];
1242
-                    $out .= '</a>' . "\n";
1242
+                    $out .= '</a>'."\n";
1243 1243
                 } else {
1244
-                    $out .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="tabunactive tab inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1244
+                    $out .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="tabunactive tab inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
1245 1245
                     $out .= $links[$i][1];
1246
-                    $out .= '</a>' . "\n";
1246
+                    $out .= '</a>'."\n";
1247 1247
                 }
1248 1248
             }
1249 1249
             $out .= '</div>';
@@ -1256,14 +1256,14 @@  discard block
 block discarded – undo
1256 1256
             $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">';
1257 1257
             if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1258 1258
                 if (!empty($links[$i][0]))
1259
-                    $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1259
+                    $outmore .= '<a class="tabimage'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
1260 1260
                 else
1261
-                    $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1261
+                    $outmore .= '<span class="tabspan">'.$links[$i][1].'</span>'."\n";
1262 1262
             }
1263 1263
             else if (!empty($links[$i][1])) {
1264
-                $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1264
+                $outmore .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="wordwrap inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
1265 1265
                 $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
1266
-                $outmore .= '</a>' . "\n";
1266
+                $outmore .= '</a>'."\n";
1267 1267
             }
1268 1268
             $outmore .= '</div>';
1269 1269
 
@@ -1279,24 +1279,24 @@  discard block
 block discarded – undo
1279 1279
         $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
1280 1280
 
1281 1281
         $tabsname = str_replace("@", "", $picto);
1282
-        $out .= '<div id="moretabs' . $tabsname . '" class="inline-block tabsElem">';
1283
-        $out .= '<a href="#" class="tab moretab inline-block tabunactive reposition">' . $langs->trans("More") . '... (' . $nbintab . ')</a>';
1284
-        $out .= '<div id="moretabsList' . $tabsname . '" style="position: absolute; ' . $left . ': -999em; text-align: ' . $left . '; margin:0px; padding:2px">';
1282
+        $out .= '<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">';
1283
+        $out .= '<a href="#" class="tab moretab inline-block tabunactive reposition">'.$langs->trans("More").'... ('.$nbintab.')</a>';
1284
+        $out .= '<div id="moretabsList'.$tabsname.'" style="position: absolute; '.$left.': -999em; text-align: '.$left.'; margin:0px; padding:2px">';
1285 1285
         $out .= $outmore;
1286 1286
         $out .= '</div>';
1287 1287
         $out .= '<div></div>';
1288 1288
         $out .= "</div>\n";
1289 1289
 
1290 1290
         $out .= "<script>";
1291
-        $out .= "$('#moretabs" . $tabsname . "').mouseenter( function() { console.log('mouseenter " . $left . "'); $('#moretabsList" . $tabsname . "').css('" . $left . "','auto');});";
1292
-        $out .= "$('#moretabs" . $tabsname . "').mouseleave( function() { console.log('mouseleave " . $left . "'); $('#moretabsList" . $tabsname . "').css('" . $left . "','-999em');});";
1291
+        $out .= "$('#moretabs".$tabsname."').mouseenter( function() { console.log('mouseenter ".$left."'); $('#moretabsList".$tabsname."').css('".$left."','auto');});";
1292
+        $out .= "$('#moretabs".$tabsname."').mouseleave( function() { console.log('mouseleave ".$left."'); $('#moretabsList".$tabsname."').css('".$left."','-999em');});";
1293 1293
         $out .= "</script>";
1294 1294
     }
1295 1295
 
1296 1296
     $out .= "</div>\n";
1297 1297
 
1298 1298
     if (!$notab || $notab == -1)
1299
-        $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1299
+        $out .= "\n".'<div class="tabBar'.($notab == -1 ? '' : ' tabBarWithBottom').'">'."\n";
1300 1300
 
1301 1301
     $parameters = array('tabname' => $active, 'out' => $out);
1302 1302
     $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
         if ($conf->browser->layout == 'phone')
1406 1406
             $maxvisiblephotos = 1;
1407 1407
         if ($showimage)
1408
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1408
+            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'</div>';
1409 1409
         else {
1410 1410
             if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
1411 1411
                 $nophoto = '';
@@ -1414,18 +1414,18 @@  discard block
 block discarded – undo
1414 1414
             //elseif ($conf->browser->layout != 'phone') {    // Show no photo link
1415 1415
             $nophoto = '/public/theme/common/nophoto.png';
1416 1416
             // $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '"></div>';
1417
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>';
1417
+            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'"></div>';
1418 1418
             //}
1419 1419
         }
1420 1420
     } elseif ($object->element == 'ticket') {
1421 1421
         $width = 80;
1422 1422
         $cssclass = 'photoref';
1423
-        $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity] . '/' . $object->track_id);
1423
+        $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity].'/'.$object->track_id);
1424 1424
         $maxvisiblephotos = (isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? $conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2);
1425 1425
         if ($conf->browser->layout == 'phone')
1426 1426
             $maxvisiblephotos = 1;
1427 1427
         if ($showimage)
1428
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1428
+            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'</div>';
1429 1429
         else {
1430 1430
             if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
1431 1431
                 $nophoto = '';
@@ -1434,7 +1434,7 @@  discard block
 block discarded – undo
1434 1434
             //elseif ($conf->browser->layout != 'phone') {    // Show no photo link
1435 1435
             $nophoto = '/public/theme/common/nophoto.png';
1436 1436
             //$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '"></div>';
1437
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>';
1437
+            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'"></div>';
1438 1438
             //}
1439 1439
         }
1440 1440
     } else {
@@ -1444,25 +1444,25 @@  discard block
 block discarded – undo
1444 1444
                 // Check if a preview file is available
1445 1445
                 if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) {
1446 1446
                     $objectref = dol_sanitizeFileName($object->ref);
1447
-                    $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity]) . "/";
1447
+                    $dir_output = (empty($conf->$modulepart->multidir_output[$entity]) ? $conf->$modulepart->dir_output : $conf->$modulepart->multidir_output[$entity])."/";
1448 1448
                     if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) {
1449 1449
                         $subdir = get_exdir($object->id, 2, 0, 1, $object, $modulepart);
1450
-                        $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '') . $objectref;  // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
1450
+                        $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
1451 1451
                     } else {
1452 1452
                         $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart);
1453 1453
                     }
1454 1454
                     if (empty($subdir))
1455 1455
                         $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path
1456 1456
 
1457
-                    $filepath = $dir_output . $subdir . "/";
1457
+                    $filepath = $dir_output.$subdir."/";
1458 1458
 
1459
-                    $file = $filepath . $objectref . ".pdf";
1460
-                    $relativepath = $subdir . '/' . $objectref . '.pdf';
1459
+                    $file = $filepath.$objectref.".pdf";
1460
+                    $relativepath = $subdir.'/'.$objectref.'.pdf';
1461 1461
 
1462 1462
                     // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png")
1463
-                    $fileimage = $file . '_preview.png';              // If PDF has 1 page
1464
-                    $fileimagebis = $file . '_preview-0.png';         // If PDF has more than one page
1465
-                    $relativepathimage = $relativepath . '_preview.png';
1463
+                    $fileimage = $file.'_preview.png'; // If PDF has 1 page
1464
+                    $fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page
1465
+                    $relativepathimage = $relativepath.'_preview.png';
1466 1466
 
1467 1467
                     // Si fichier PDF existe
1468 1468
                     if (file_exists($file)) {
@@ -1471,7 +1471,7 @@  discard block
 block discarded – undo
1471 1471
                         if ((!file_exists($fileimage) || (filemtime($fileimage) < filemtime($file))) && (!file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file)))
1472 1472
                         ) {
1473 1473
                             if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {  // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
1474
-                                include_once DOL_BASE_PATH . '/core/lib/files.lib.php';
1474
+                                include_once DOL_BASE_PATH.'/core/lib/files.lib.php';
1475 1475
                                 $ret = dol_convert_file($file, 'png', $fileimage);
1476 1476
                                 if ($ret < 0)
1477 1477
                                     $error++;
@@ -1484,14 +1484,14 @@  discard block
 block discarded – undo
1484 1484
                         // Si fichier png PDF d'1 page trouve
1485 1485
                         if (file_exists($fileimage)) {
1486 1486
                             $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
1487
-                            $phototoshow .= '<img height="' . $heightforphotref . '" class="photo photowithmargin photowithborder" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=apercu' . $modulepart . '&amp;file=' . urlencode($relativepathimage) . '">';
1487
+                            $phototoshow .= '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
1488 1488
                             $phototoshow .= '</div></div>';
1489 1489
                         }
1490 1490
                         // Si fichier png PDF de plus d'1 page trouve
1491 1491
                         elseif (file_exists($fileimagebis)) {
1492
-                            $preview = preg_replace('/\.png/', '', $relativepathimage) . "-0.png";
1492
+                            $preview = preg_replace('/\.png/', '', $relativepathimage)."-0.png";
1493 1493
                             $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
1494
-                            $phototoshow .= '<img height="' . $heightforphotref . '" class="photo photowithmargin photowithborder" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=apercu' . $modulepart . '&amp;file=' . urlencode($preview) . '"><p>';
1494
+                            $phototoshow .= '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($preview).'"><p>';
1495 1495
                             $phototoshow .= '</div></div>';
1496 1496
                         }
1497 1497
                     }
@@ -1518,10 +1518,10 @@  discard block
 block discarded – undo
1518 1518
                     $picto = $object->picto;
1519 1519
                     if ($object->element == 'project' && !$object->public)
1520 1520
                         $picto = 'project'; // instead of projectpub
1521
-                    $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
1521
+                    $nophoto = img_picto('', 'object_'.$picto, '', false, 1);
1522 1522
                 }
1523 1523
                 $morehtmlleft .= '<!-- No photo to show -->';
1524
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . $nophoto . '"></div></div>';
1524
+                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.$nophoto.'"></div></div>';
1525 1525
 
1526 1526
                 $morehtmlleft .= '</div>';
1527 1527
             }
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
     }
1530 1530
 
1531 1531
     if ($showbarcode)
1532
-        $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1532
+        $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
1533 1533
 
1534 1534
     if ($object->element == 'societe') {
1535 1535
         if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
@@ -1542,14 +1542,14 @@  discard block
 block discarded – undo
1542 1542
         if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1543 1543
             $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
1544 1544
         } else {
1545
-            $morehtmlstatus .= '<span class="statusrefsell">' . $object->getLibStatut(5, 0) . '</span>';
1545
+            $morehtmlstatus .= '<span class="statusrefsell">'.$object->getLibStatut(5, 0).'</span>';
1546 1546
         }
1547 1547
         $morehtmlstatus .= ' &nbsp; ';
1548 1548
         //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') ';
1549 1549
         if (!empty($conf->use_javascript_ajax) && $user->rights->produit->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1550 1550
             $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
1551 1551
         } else {
1552
-            $morehtmlstatus .= '<span class="statusrefbuy">' . $object->getLibStatut(5, 1) . '</span>';
1552
+            $morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(5, 1).'</span>';
1553 1553
         }
1554 1554
     } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
1555 1555
         $tmptxt = $object->getLibStatut(6, $object->totalpaye);
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
         if ($object->progress >= 100)
1577 1577
             $object->fk_statut = 3;
1578 1578
         $tmptxt = $object->getLibStatut(5);
1579
-        $morehtmlstatus .= $tmptxt;  // No status on task
1579
+        $morehtmlstatus .= $tmptxt; // No status on task
1580 1580
     }
1581 1581
     else { // Generic case
1582 1582
         $tmptxt = $object->getLibStatut(6);
@@ -1590,18 +1590,18 @@  discard block
 block discarded – undo
1590 1590
         if (method_exists($object, 'getVentilExportCompta')) {
1591 1591
             $accounted = $object->getVentilExportCompta();
1592 1592
             $langs->load("accountancy");
1593
-            $morehtmlstatus .= '</div><div class="statusref statusrefbis">' . ($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
1593
+            $morehtmlstatus .= '</div><div class="statusref statusrefbis">'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
1594 1594
         }
1595 1595
     }
1596 1596
 
1597 1597
     // Add alias for thirdparty
1598 1598
     if (!empty($object->name_alias))
1599
-        $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1599
+        $morehtmlref .= '<div class="refidno">'.$object->name_alias.'</div>';
1600 1600
 
1601 1601
     // Add label
1602 1602
     if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
1603 1603
         if (!empty($object->label))
1604
-            $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1604
+            $morehtmlref .= '<div class="refidno">'.$object->label.'</div>';
1605 1605
     }
1606 1606
 
1607 1607
     if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
@@ -1611,11 +1611,11 @@  discard block
 block discarded – undo
1611 1611
     }
1612 1612
     if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) {
1613 1613
         $morehtmlref .= '<div style="clear: both;"></div><div class="refidno">';
1614
-        $morehtmlref .= $langs->trans("TechnicalID") . ': ' . $object->id;
1614
+        $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id;
1615 1615
         $morehtmlref .= '</div>';
1616 1616
     }
1617 1617
 
1618
-    print '<div class="' . ($onlybanner ? 'arearefnobottom ' : 'arearef ') . 'heightref valignmiddle" width="100%">';
1618
+    print '<div class="'.($onlybanner ? 'arearefnobottom ' : 'arearef ').'heightref valignmiddle" width="100%">';
1619 1619
     print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
1620 1620
     print '</div>';
1621 1621
     print '<div class="underrefbanner clearboth"></div>';
@@ -1637,7 +1637,7 @@  discard block
 block discarded – undo
1637 1637
     if ($fieldrequired)
1638 1638
         $ret .= '<span class="fieldrequired">';
1639 1639
     if (($conf->dol_use_jmobile != 4))
1640
-        $ret .= '<label for="' . $fieldkey . '">';
1640
+        $ret .= '<label for="'.$fieldkey.'">';
1641 1641
     $ret .= $langs->trans($langkey);
1642 1642
     if (($conf->dol_use_jmobile != 4))
1643 1643
         $ret .= '</label>';
@@ -1656,9 +1656,9 @@  discard block
 block discarded – undo
1656 1656
 function dol_bc($var, $moreclass = '')
1657 1657
 {
1658 1658
     global $bc;
1659
-    $ret = ' ' . $bc[$var];
1659
+    $ret = ' '.$bc[$var];
1660 1660
     if ($moreclass)
1661
-        $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1661
+        $ret = preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret);
1662 1662
     return $ret;
1663 1663
 }
1664 1664
 
@@ -1678,50 +1678,50 @@  discard block
 block discarded – undo
1678 1678
     global $conf, $langs;
1679 1679
 
1680 1680
     $ret = '';
1681
-    $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR');    // See also MAIN_FORCE_STATE_INTO_ADDRESS
1681
+    $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
1682 1682
     // Address
1683 1683
     if (empty($mode)) {
1684 1684
         $ret .= $object->address;
1685 1685
     }
1686 1686
     // Zip/Town/State
1687 1687
     if (in_array($object->country_code, array('AU', 'CA', 'US')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {    // US: title firstname name \n address lines \n town, state, zip \n country
1688
-        $ret .= ($ret ? $sep : '' ) . $object->town;
1688
+        $ret .= ($ret ? $sep : '').$object->town;
1689 1689
         if ($object->state) {
1690
-            $ret .= ($ret ? ", " : '') . $object->state;
1690
+            $ret .= ($ret ? ", " : '').$object->state;
1691 1691
         }
1692 1692
         if ($object->zip)
1693
-            $ret .= ($ret ? ", " : '') . $object->zip;
1693
+            $ret .= ($ret ? ", " : '').$object->zip;
1694 1694
     }
1695 1695
     else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1696
-        $ret .= ($ret ? $sep : '' ) . $object->town;
1696
+        $ret .= ($ret ? $sep : '').$object->town;
1697 1697
         if ($object->state) {
1698
-            $ret .= ($ret ? ", " : '') . $object->state;
1698
+            $ret .= ($ret ? ", " : '').$object->state;
1699 1699
         }
1700 1700
         if ($object->zip)
1701
-            $ret .= ($ret ? $sep : '' ) . $object->zip;
1701
+            $ret .= ($ret ? $sep : '').$object->zip;
1702 1702
     }
1703 1703
     else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1704
-        $ret .= ($ret ? $sep : '' ) . $object->zip;
1705
-        $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1704
+        $ret .= ($ret ? $sep : '').$object->zip;
1705
+        $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : '');
1706 1706
         if ($object->state) {
1707
-            $ret .= "\n" . $object->state;
1707
+            $ret .= "\n".$object->state;
1708 1708
         }
1709 1709
     } else if (in_array($object->country_code, array('IT'))) { // IT: tile firstname name\n address lines \n zip (Code Departement) \n country
1710
-        $ret .= ($ret ? $sep : '' ) . $object->zip;
1711
-        $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1712
-        $ret .= ($object->departement_id ? (' (' . ($object->departement_id) . ')') : '');
1710
+        $ret .= ($ret ? $sep : '').$object->zip;
1711
+        $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : '');
1712
+        $ret .= ($object->departement_id ? (' ('.($object->departement_id).')') : '');
1713 1713
     } else {                                          // Other: title firstname name \n address lines \n zip town \n country
1714
-        $ret .= $object->zip ? (($ret ? $sep : '' ) . $object->zip) : '';
1715
-        $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '' )) . $object->town) : '');
1714
+        $ret .= $object->zip ? (($ret ? $sep : '').$object->zip) : '';
1715
+        $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$object->town) : '');
1716 1716
         if ($object->state && in_array($object->country_code, $countriesusingstate)) {
1717
-            $ret .= ($ret ? ", " : '') . $object->state;
1717
+            $ret .= ($ret ? ", " : '').$object->state;
1718 1718
         }
1719 1719
     }
1720 1720
     if (!is_object($outputlangs))
1721 1721
         $outputlangs = $langs;
1722 1722
     if ($withcountry) {
1723 1723
         $langs->load("dict");
1724
-        $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
1724
+        $ret .= ($object->country_code ? ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)) : '');
1725 1725
     }
1726 1726
 
1727 1727
     return $ret;
@@ -1776,13 +1776,13 @@  discard block
 block discarded – undo
1776 1776
         if (is_string($tzoutput)) {
1777 1777
             if ($tzoutput == 'tzserver') {
1778 1778
                 $to_gmt = false;
1779
-                $offsettzstring = @date_default_timezone_get();  // Example 'Europe/Berlin' or 'Indian/Reunion'
1779
+                $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion'
1780 1780
                 $offsettz = 0;
1781 1781
                 $offsetdst = 0;
1782 1782
             } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
1783 1783
                 $to_gmt = true;
1784 1784
                 $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion'
1785
-                $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;  // Will not be used anymore
1785
+                $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore
1786 1786
                 $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore
1787 1787
             }
1788 1788
         }
@@ -1828,9 +1828,9 @@  discard block
 block discarded – undo
1828 1828
     else if ($format == 'dayxcard')
1829 1829
         $format = '%Y%m%d';
1830 1830
     else if ($format == 'dayrfc')
1831
-        $format = '%Y-%m-%d';             // DATE_RFC3339
1831
+        $format = '%Y-%m-%d'; // DATE_RFC3339
1832 1832
     else if ($format == 'dayhourrfc')
1833
-        $format = '%Y-%m-%dT%H:%M:%SZ';   // DATETIME RFC3339
1833
+        $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339
1834 1834
     else if ($format == 'standard')
1835 1835
         $format = '%Y-%m-%d %H:%M:%S';
1836 1836
 
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
 
1842 1842
     // If date undefined or "", we return ""
1843 1843
     if (dol_strlen($time) == 0)
1844
-        return '';  // $time=0 allowed (it means 01/01/1970 00:00:00)
1844
+        return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
1845 1845
 
1846 1846
 
1847 1847
 
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
     if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg) || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
1885 1885
         // TODO Remove this.
1886 1886
         // This part of code should not be used.
1887
-        dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page " . $_SERVER["PHP_SELF"], LOG_ERR);
1887
+        dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_ERR);
1888 1888
         // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS'
1889 1889
         $syear = (!empty($reg[1]) ? $reg[1] : '');
1890 1890
         $smonth = (!empty($reg[2]) ? $reg[2] : '');
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
 
1903 1903
             $ret = adodb_strftime($format, $timetouse, $to_gmt);
1904 1904
         } else
1905
-            $ret = 'Bad value ' . $time . ' for date';
1905
+            $ret = 'Bad value '.$time.' for date';
1906 1906
     }
1907 1907
 
1908 1908
     if (preg_match('/__b__/i', $format)) {
@@ -1911,11 +1911,11 @@  discard block
 block discarded – undo
1911 1911
         $month = adodb_strftime('%m', $timetouse);
1912 1912
         $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
1913 1913
         if ($encodetooutput) {
1914
-            $monthtext = $outputlangs->transnoentities('Month' . $month);
1915
-            $monthtextshort = $outputlangs->transnoentities('MonthShort' . $month);
1914
+            $monthtext = $outputlangs->transnoentities('Month'.$month);
1915
+            $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month);
1916 1916
         } else {
1917
-            $monthtext = $outputlangs->transnoentitiesnoconv('Month' . $month);
1918
-            $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort' . $month);
1917
+            $monthtext = $outputlangs->transnoentitiesnoconv('Month'.$month);
1918
+            $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort'.$month);
1919 1919
         }
1920 1920
         //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort;
1921 1921
         $ret = str_replace('__b__', $monthtextshort, $ret);
@@ -1926,8 +1926,8 @@  discard block
 block discarded – undo
1926 1926
     if (preg_match('/__a__/i', $format)) {
1927 1927
         $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1928 1928
 
1929
-        $w = adodb_strftime('%w', $timetouse);      // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1930
-        $dayweek = $outputlangs->transnoentitiesnoconv('Day' . $w);
1929
+        $w = adodb_strftime('%w', $timetouse); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1930
+        $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w);
1931 1931
         $ret = str_replace('__A__', $dayweek, $ret);
1932 1932
         $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret);
1933 1933
     }
@@ -1974,9 +1974,9 @@  discard block
 block discarded – undo
1974 1974
 
1975 1975
     $usealternatemethod = false;
1976 1976
     if ($timestamp <= 0)
1977
-        $usealternatemethod = true;    // <= 1970
1977
+        $usealternatemethod = true; // <= 1970
1978 1978
     if ($timestamp >= 2145913200)
1979
-        $usealternatemethod = true;  // >= 2038
1979
+        $usealternatemethod = true; // >= 2038
1980 1980
 
1981 1981
     if ($usealternatemethod) {
1982 1982
         $arrayinfo = adodb_getdate($timestamp, $fast);
@@ -2036,23 +2036,23 @@  discard block
 block discarded – undo
2036 2036
 
2037 2037
     if (method_exists('DateTime', 'getTimestamp')) {
2038 2038
         if (empty($gm) || $gm === 'server') {
2039
-            $default_timezone = @date_default_timezone_get();  // Example 'Europe/Berlin'
2039
+            $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin'
2040 2040
             $localtz = new DateTimeZone($default_timezone);
2041 2041
         } else if ($gm === 'user') {
2042 2042
             // We use dol_tz_string first because it is more reliable.
2043
-            $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]);  // Example 'Europe/Berlin'
2043
+            $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin'
2044 2044
             try {
2045 2045
                 $localtz = new DateTimeZone($default_timezone);
2046 2046
             } catch (Exception $e) {
2047
-                dol_syslog("Warning dol_tz_string contains an invalid value " . $_SESSION["dol_tz_string"], LOG_WARNING);
2047
+                dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING);
2048 2048
                 $default_timezone = @date_default_timezone_get();
2049 2049
             }
2050 2050
         } else if (strrpos($gm, "tz,") !== false) {
2051
-            $timezone = str_replace("tz,", "", $gm);  // Example 'tz,Europe/Berlin'
2051
+            $timezone = str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin'
2052 2052
             try {
2053 2053
                 $localtz = new DateTimeZone($timezone);
2054 2054
             } catch (Exception $e) {
2055
-                dol_syslog("Warning passed timezone contains an invalid value " . $timezone, LOG_WARNING);
2055
+                dol_syslog("Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
2056 2056
             }
2057 2057
         }
2058 2058
 
@@ -2091,8 +2091,8 @@  discard block
 block discarded – undo
2091 2091
     if ($mode == 'gmt')
2092 2092
         $ret = time(); // Time for now at greenwich.
2093 2093
     else if ($mode == 'tzserver') {  // Time for now with PHP server timezone added
2094
-        require_once DOL_BASE_PATH . '/core/lib/date.lib.php';
2095
-        $tzsecond = getServerTimeZoneInt('now');    // Contains tz+dayling saving time
2094
+        require_once DOL_BASE_PATH.'/core/lib/date.lib.php';
2095
+        $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
2096 2096
         $ret = (int) (dol_now('gmt') + ($tzsecond * 3600));
2097 2097
     }
2098 2098
     /* else if ($mode == 'tzref')				// Time for now with parent company timezone is added
@@ -2138,9 +2138,9 @@  discard block
 block discarded – undo
2138 2138
     }
2139 2139
     // Use long or short text unit
2140 2140
     if (empty($shortunit)) {
2141
-        $ret .= ' ' . $textunitlong;
2141
+        $ret .= ' '.$textunitlong;
2142 2142
     } else {
2143
-        $ret .= ' ' . $textunitshort;
2143
+        $ret .= ' '.$textunitshort;
2144 2144
     }
2145 2145
 
2146 2146
     return $ret;
@@ -2168,13 +2168,13 @@  discard block
 block discarded – undo
2168 2168
     $link .= $url;
2169 2169
     $link .= '"';
2170 2170
     if ($target)
2171
-        $link .= ' target="' . $target . '"';
2171
+        $link .= ' target="'.$target.'"';
2172 2172
     $link .= '>';
2173 2173
     if (!preg_match('/^http/i', $url))
2174 2174
         $link .= 'http://';
2175 2175
     $link .= dol_trunc($url, $max);
2176 2176
     $link .= '</a>';
2177
-    return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
2177
+    return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png').' ' : '').$link.'</div>';
2178 2178
 }
2179 2179
 
2180 2180
 /**
@@ -2215,9 +2215,9 @@  discard block
 block discarded – undo
2215 2215
             $type = 'AC_EMAIL';
2216 2216
             $link = '';
2217 2217
             if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL))
2218
-                $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2218
+                $link = '<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$type.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
2219 2219
             if ($link)
2220
-                $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2220
+                $newemail = '<div>'.$newemail.' '.$link.'</div>';
2221 2221
         }
2222 2222
     }
2223 2223
     else {
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
         }
2228 2228
     }
2229 2229
 
2230
-    $rep = '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("EMail"), 'object_email.png') . ' ' : '') . $newemail . '</div>';
2230
+    $rep = '<div class="nospan float" style="margin-right: 10px">'.($withpicto ? img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'</div>';
2231 2231
     if ($hookmanager) {
2232 2232
         $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto);
2233 2233
         $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email);
@@ -2257,26 +2257,26 @@  discard block
 block discarded – undo
2257 2257
 
2258 2258
     if (!empty($type)) {
2259 2259
         $newskype = '<div class="divsocialnetwork inline-block valignmiddle">';
2260
-        $newskype .= img_picto($langs->trans(strtoupper($type)), $type . '.png', '', false, 0, 0, '', 'paddingright');
2260
+        $newskype .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright');
2261 2261
         $newskype .= $value;
2262 2262
         if ($type == 'skype') {
2263 2263
             $newskype .= '&nbsp;';
2264 2264
             $newskype .= '<a href="skype:';
2265 2265
             $newskype .= $value;
2266
-            $newskype .= '?call" alt="' . $langs->trans("Call") . '&nbsp;' . $value . '" title="' . $langs->trans("Call") . '&nbsp;' . $value . '">';
2267
-            $newskype .= '<img src="' . DOL_URL_ROOT . '/theme/common/skype_callbutton.png" border="0">';
2266
+            $newskype .= '?call" alt="'.$langs->trans("Call").'&nbsp;'.$value.'" title="'.$langs->trans("Call").'&nbsp;'.$value.'">';
2267
+            $newskype .= '<img src="'.DOL_URL_ROOT.'/theme/common/skype_callbutton.png" border="0">';
2268 2268
             $newskype .= '</a><a href="skype:';
2269 2269
             $newskype .= $value;
2270
-            $newskype .= '?chat" alt="' . $langs->trans("Chat") . '&nbsp;' . $value . '" title="' . $langs->trans("Chat") . '&nbsp;' . $value . '">';
2271
-            $newskype .= '<img class="paddingleft" src="' . DOL_URL_ROOT . '/theme/common/skype_chatbutton.png" border="0">';
2270
+            $newskype .= '?chat" alt="'.$langs->trans("Chat").'&nbsp;'.$value.'" title="'.$langs->trans("Chat").'&nbsp;'.$value.'">';
2271
+            $newskype .= '<img class="paddingleft" src="'.DOL_URL_ROOT.'/theme/common/skype_chatbutton.png" border="0">';
2272 2272
             $newskype .= '</a>';
2273 2273
         }
2274 2274
         if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
2275 2275
             $addlink = 'AC_SKYPE';
2276 2276
             $link = '';
2277 2277
             if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE))
2278
-                $link = '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode=' . $addlink . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2279
-            $newskype .= ($link ? ' ' . $link : '');
2278
+                $link = '<a href="'.BASE_URI.'?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode='.$addlink.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
2279
+            $newskype .= ($link ? ' '.$link : '');
2280 2280
         }
2281 2281
         $newskype .= '</div>';
2282 2282
     }
@@ -2321,165 +2321,165 @@  discard block
 block discarded – undo
2321 2321
     if (strtoupper($countrycode) == "FR") {
2322 2322
         // France
2323 2323
         if (dol_strlen($phone) == 10) {
2324
-            $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 2) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2);
2324
+            $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
2325 2325
         } elseif (dol_strlen($phone) == 7) {
2326
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2);
2326
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
2327 2327
         } elseif (dol_strlen($phone) == 9) {
2328
-            $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 3) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2);
2328
+            $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
2329 2329
         } elseif (dol_strlen($phone) == 11) {
2330
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2330
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2331 2331
         } elseif (dol_strlen($phone) == 12) {
2332
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2332
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2333 2333
         }
2334 2334
     } elseif (strtoupper($countrycode) == "CA") {
2335 2335
         if (dol_strlen($phone) == 10) {
2336
-            $newphone = ($separ != '' ? '(' : '') . substr($newphone, 0, 3) . ($separ != '' ? ')' : '') . $separ . substr($newphone, 3, 3) . ($separ != '' ? '-' : '') . substr($newphone, 6, 4);
2336
+            $newphone = ($separ != '' ? '(' : '').substr($newphone, 0, 3).($separ != '' ? ')' : '').$separ.substr($newphone, 3, 3).($separ != '' ? '-' : '').substr($newphone, 6, 4);
2337 2337
         }
2338 2338
     } elseif (strtoupper($countrycode) == "PT") {//Portugal
2339 2339
         if (dol_strlen($phone) == 13) {//ex: +351_ABC_DEF_GHI
2340
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2340
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2341 2341
         }
2342 2342
     } elseif (strtoupper($countrycode) == "SR") {//Suriname
2343 2343
         if (dol_strlen($phone) == 10) {//ex: +597_ABC_DEF
2344
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3);
2344
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
2345 2345
         } elseif (dol_strlen($phone) == 11) {//ex: +597_ABC_DEFG
2346
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 4);
2346
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
2347 2347
         }
2348 2348
     } elseif (strtoupper($countrycode) == "DE") {//Allemagne
2349 2349
         if (dol_strlen($phone) == 14) {//ex:  +49_ABCD_EFGH_IJK
2350
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 4) . $separ . substr($newphone, 11, 3);
2350
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
2351 2351
         } elseif (dol_strlen($phone) == 13) {//ex: +49_ABC_DEFG_HIJ
2352
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 4) . $separ . substr($newphone, 10, 3);
2352
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
2353 2353
         }
2354 2354
     } elseif (strtoupper($countrycode) == "ES") {//Espagne
2355 2355
         if (dol_strlen($phone) == 12) {//ex:  +34_ABC_DEF_GHI
2356
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2356
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2357 2357
         }
2358 2358
     } elseif (strtoupper($countrycode) == "BF") {// Burkina Faso
2359 2359
         if (dol_strlen($phone) == 12) {//ex :  +22 A BC_DE_FG_HI
2360
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2360
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2361 2361
         }
2362 2362
     } elseif (strtoupper($countrycode) == "RO") {// Roumanie
2363 2363
         if (dol_strlen($phone) == 12) {//ex :  +40 AB_CDE_FG_HI
2364
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2364
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2365 2365
         }
2366 2366
     } elseif (strtoupper($countrycode) == "TR") {//Turquie
2367 2367
         if (dol_strlen($phone) == 13) {//ex :  +90 ABC_DEF_GHIJ
2368
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 4);
2368
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
2369 2369
         }
2370 2370
     } elseif (strtoupper($countrycode) == "US") {//Etat-Unis
2371 2371
         if (dol_strlen($phone) == 12) {//ex: +1 ABC_DEF_GHIJ
2372
-            $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 3) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 4);
2372
+            $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
2373 2373
         }
2374 2374
     } elseif (strtoupper($countrycode) == "MX") {//Mexique
2375 2375
         if (dol_strlen($phone) == 12) {//ex: +52 ABCD_EFG_HI
2376
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 2);
2376
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
2377 2377
         } elseif (dol_strlen($phone) == 11) {//ex: +52 AB_CD_EF_GH
2378
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2378
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2379 2379
         } elseif (dol_strlen($phone) == 13) {//ex: +52 ABC_DEF_GHIJ
2380
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 4);
2380
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
2381 2381
         }
2382 2382
     } elseif (strtoupper($countrycode) == "ML") {//Mali
2383 2383
         if (dol_strlen($phone) == 12) {//ex: +223 AB_CD_EF_GH
2384
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2384
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2385 2385
         }
2386 2386
     } elseif (strtoupper($countrycode) == "TH") {//Thaïlande
2387 2387
         if (dol_strlen($phone) == 11) {//ex: +66_ABC_DE_FGH
2388
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 3);
2388
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
2389 2389
         } elseif (dol_strlen($phone) == 12) {//ex: +66_A_BCD_EF_GHI
2390
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 3);
2390
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 3);
2391 2391
         }
2392 2392
     } elseif (strtoupper($countrycode) == "MU") {//Maurice
2393 2393
         if (dol_strlen($phone) == 11) {//ex: +230_ABC_DE_FG
2394
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2394
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2395 2395
         } elseif (dol_strlen($phone) == 12) {//ex: +230_ABCD_EF_GH
2396
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 4) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2396
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2397 2397
         }
2398 2398
     } elseif (strtoupper($countrycode) == "ZA") {//Afrique du sud
2399 2399
         if (dol_strlen($phone) == 12) {//ex: +27_AB_CDE_FG_HI
2400
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2400
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2401 2401
         }
2402 2402
     } elseif (strtoupper($countrycode) == "SY") {//Syrie
2403 2403
         if (dol_strlen($phone) == 12) {//ex: +963_AB_CD_EF_GH
2404
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2404
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2405 2405
         } elseif (dol_strlen($phone) == 13) {//ex: +963_AB_CD_EF_GHI
2406
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 3);
2406
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
2407 2407
         }
2408 2408
     } elseif (strtoupper($countrycode) == "AE") {//Emirats Arabes Unis
2409 2409
         if (dol_strlen($phone) == 12) {//ex: +971_ABC_DEF_GH
2410
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 2);
2410
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
2411 2411
         } elseif (dol_strlen($phone) == 13) {//ex: +971_ABC_DEF_GHI
2412
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2412
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2413 2413
         } elseif (dol_strlen($phone) == 14) {//ex: +971_ABC_DEF_GHIK
2414
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 4);
2414
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
2415 2415
         }
2416 2416
     } elseif (strtoupper($countrycode) == "DZ") {//Algérie
2417 2417
         if (dol_strlen($phone) == 13) {//ex: +213_ABC_DEF_GHI
2418
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2418
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2419 2419
         }
2420 2420
     } elseif (strtoupper($countrycode) == "BE") {//Belgique
2421 2421
         if (dol_strlen($phone) == 11) {//ex: +32_ABC_DE_FGH
2422
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 3);
2422
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
2423 2423
         } elseif (dol_strlen($phone) == 12) {//ex: +32_ABC_DEF_GHI
2424
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2424
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2425 2425
         }
2426 2426
     } elseif (strtoupper($countrycode) == "PF") {//Polynésie française
2427 2427
         if (dol_strlen($phone) == 12) {//ex: +689_AB_CD_EF_GH
2428
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2428
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2429 2429
         }
2430 2430
     } elseif (strtoupper($countrycode) == "CO") {//Colombie
2431 2431
         if (dol_strlen($phone) == 13) {//ex: +57_ABC_DEF_GH_IJ
2432
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2432
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2433 2433
         }
2434 2434
     } elseif (strtoupper($countrycode) == "JO") {//Jordanie
2435 2435
         if (dol_strlen($phone) == 12) {//ex: +962_A_BCD_EF_GH
2436
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 1) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2436
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2437 2437
         }
2438 2438
     } elseif (strtoupper($countrycode) == "MG") {//Madagascar
2439 2439
         if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI
2440
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 3);
2440
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
2441 2441
         }
2442 2442
     } elseif (strtoupper($countrycode) == "GB") {//Royaume uni
2443 2443
         if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ
2444
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2444
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2445 2445
         }
2446 2446
     } elseif (strtoupper($countrycode) == "CH") {//Suisse
2447 2447
         if (dol_strlen($phone) == 12) {//ex: +41_AB_CDE_FG_HI
2448
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2448
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2449 2449
         } elseif (dol_strlen($phone) == 15) {// +41_AB_CDE_FGH_IJKL
2450
-            $newphone = $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 3) . $separ . substr($newphone, 11, 4);
2450
+            $newphone = $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4);
2451 2451
         }
2452 2452
     } elseif (strtoupper($countrycode) == "TN") {//Tunisie
2453 2453
         if (dol_strlen($phone) == 12) {//ex: +216_AB_CDE_FGH
2454
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2454
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2455 2455
         }
2456 2456
     } elseif (strtoupper($countrycode) == "GF") {//Guyane francaise
2457 2457
         if (dol_strlen($phone) == 13) {//ex: +594_ABC_DE_FG_HI  (ABC=594 de nouveau)
2458
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2458
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2459 2459
         }
2460 2460
     } elseif (strtoupper($countrycode) == "GP") {//Guadeloupe
2461 2461
         if (dol_strlen($phone) == 13) {//ex: +590_ABC_DE_FG_HI  (ABC=590 de nouveau)
2462
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2462
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2463 2463
         }
2464 2464
     } elseif (strtoupper($countrycode) == "MQ") {//Martinique
2465 2465
         if (dol_strlen($phone) == 13) {//ex: +596_ABC_DE_FG_HI  (ABC=596 de nouveau)
2466
-            $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2466
+            $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2467 2467
         }
2468 2468
     } elseif (strtoupper($countrycode) == "IT") {//Italie
2469 2469
         if (dol_strlen($phone) == 12) {//ex: +39_ABC_DEF_GHI
2470
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2470
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2471 2471
         } elseif (dol_strlen($phone) == 13) {//ex: +39_ABC_DEF_GH_IJ
2472
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2472
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2473 2473
         }
2474 2474
     } elseif (strtoupper($countrycode) == "AU") {//Australie
2475 2475
         if (dol_strlen($phone) == 12) {//ex: +61_A_BCDE_FGHI
2476
-            $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 4) . $separ . substr($newphone, 8, 4);
2476
+            $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
2477 2477
         }
2478 2478
     }
2479 2479
     if (!empty($addlink)) { // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set)
2480 2480
         if ($conf->browser->layout == 'phone' || (!empty($conf->clicktodial->enabled) && !empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) { // If phone or option for, we use link of phone
2481
-            $newphone = '<a href="tel:' . $phone . '"';
2482
-            $newphone .= '>' . $phone . '</a>';
2481
+            $newphone = '<a href="tel:'.$phone.'"';
2482
+            $newphone .= '>'.$phone.'</a>';
2483 2483
         } else if (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') {  // If click to dial, we use click to dial url
2484 2484
             if (empty($user->clicktodial_loaded))
2485 2485
                 $user->fetch_clicktodial();
@@ -2503,10 +2503,10 @@  discard block
 block discarded – undo
2503 2503
                 '__PASS__' => $clicktodial_password);
2504 2504
             $url = make_substitutions($url, $substitarray);
2505 2505
             $newphonesav = $newphone;
2506
-            $newphone = '<a href="' . $url . '"';
2506
+            $newphone = '<a href="'.$url.'"';
2507 2507
             if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET))
2508 2508
                 $newphone .= ' target="_blank"';
2509
-            $newphone .= '>' . $newphonesav . '</a>';
2509
+            $newphone .= '>'.$newphonesav.'</a>';
2510 2510
         }
2511 2511
 
2512 2512
         //if (($cid || $socid) && ! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create)
@@ -2516,9 +2516,9 @@  discard block
 block discarded – undo
2516 2516
             if ($addlink == 'AC_FAX')
2517 2517
                 $type = 'AC_FAX';
2518 2518
             if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE))
2519
-                $link = '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode=' . $type . ($cid ? '&amp;contactid=' . $cid : '') . ($socid ? '&amp;socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2519
+                $link = '<a href="'.BASE_URI.'?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode='.$type.($cid ? '&amp;contactid='.$cid : '').($socid ? '&amp;socid='.$socid : '').'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
2520 2520
             if ($link)
2521
-                $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2521
+                $newphone = '<div>'.$newphone.' '.$link.'</div>';
2522 2522
         }
2523 2523
     }
2524 2524
 
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
             $rep .= '<div class="nospan float" style="margin-right: 10px">';
2550 2550
         else
2551 2551
             $rep .= '<span style="margin-right: 10px;">';
2552
-        $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone;
2552
+        $rep .= ($withpicto ? img_picto($titlealt, 'object_'.$picto.'.png').' ' : '').$newphone;
2553 2553
         if ($adddivfloat)
2554 2554
             $rep .= '</div>';
2555 2555
         else
@@ -2576,15 +2576,15 @@  discard block
 block discarded – undo
2576 2576
         $ret .= $ip;
2577 2577
     }
2578 2578
 
2579
-    echo ('<p>DOL_BASE_PATH: ' . DOL_BASE_PATH . '/DOL_BASE_URI: ' . DOL_BASE_URI . '</p>');
2579
+    echo ('<p>DOL_BASE_PATH: '.DOL_BASE_PATH.'/DOL_BASE_URI: '.DOL_BASE_URI.'</p>');
2580 2580
 
2581 2581
     if ($mode != 2) {
2582 2582
         $countrycode = dolGetCountryCodeFromIp($ip);
2583 2583
         if ($countrycode) { // If success, countrycode is us, fr, ...
2584
-            if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
2585
-                $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
2584
+            if (file_exists(DOL_BASE_PATH.'/theme/common/flags/'.$countrycode.'.png')) {
2585
+                $ret .= ' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI.'/theme/common/flags/'.$countrycode.'.png', '', 1);
2586 2586
             } else
2587
-                $ret .= ' (' . $countrycode . ')';
2587
+                $ret .= ' ('.$countrycode.')';
2588 2588
         }
2589 2589
     }
2590 2590
 
@@ -2622,7 +2622,7 @@  discard block
 block discarded – undo
2622 2622
         //$ip='24.24.24.24';
2623 2623
         //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat';    Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages)
2624 2624
 
2625
-        include_once DOL_BASE_PATH . '/core/class/dolgeoip.class.php';
2625
+        include_once DOL_BASE_PATH.'/core/class/dolgeoip.class.php';
2626 2626
         $geoip = new DolGeoIP('country', $datafile);
2627 2627
         //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n";
2628 2628
         //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n";
@@ -2649,7 +2649,7 @@  discard block
 block discarded – undo
2649 2649
         $datafile = $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE;
2650 2650
         //$ip='24.24.24.24';
2651 2651
         //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat';
2652
-        include_once DOL_BASE_PATH . '/core/class/dolgeoip.class.php';
2652
+        include_once DOL_BASE_PATH.'/core/class/dolgeoip.class.php';
2653 2653
         $geoip = new DolGeoIP('country', $datafile);
2654 2654
         $countrycode = $geoip->getCountryCodeFromIP($ip);
2655 2655
         $ret = $countrycode;
@@ -2704,12 +2704,12 @@  discard block
 block discarded – undo
2704 2704
                 $showomap = 1;
2705 2705
 
2706 2706
             if ($showgmap) {
2707
-                $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
2708
-                $out .= ' <a href="' . $url . '" target="_gmaps"><img id="' . $htmlid . '" class="valigntextbottom" src="' . DOL_URL_ROOT . '/theme/common/gmap.png"></a>';
2707
+                $url = dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1);
2708
+                $out .= ' <a href="'.$url.'" target="_gmaps"><img id="'.$htmlid.'" class="valigntextbottom" src="'.DOL_URL_ROOT.'/theme/common/gmap.png"></a>';
2709 2709
             }
2710 2710
             if ($showomap) {
2711
-                $url = dol_buildpath('/openstreetmap/maps.php?mode=' . $mode . '&id=' . $id, 1);
2712
-                $out .= ' <a href="' . $url . '" target="_gmaps"><img id="' . $htmlid . '_openstreetmap" class="valigntextbottom" src="' . DOL_URL_ROOT . '/theme/common/gmap.png"></a>';
2711
+                $url = dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1);
2712
+                $out .= ' <a href="'.$url.'" target="_gmaps"><img id="'.$htmlid.'_openstreetmap" class="valigntextbottom" src="'.DOL_URL_ROOT.'/theme/common/gmap.png"></a>';
2713 2713
             }
2714 2714
         }
2715 2715
     }
@@ -2855,7 +2855,7 @@  discard block
 block discarded – undo
2855 2855
     if ($trunc == 'right') {
2856 2856
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2857 2857
         if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2858
-            return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
2858
+            return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...');
2859 2859
         else
2860 2860
         //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
2861 2861
             return $string;
@@ -2865,21 +2865,21 @@  discard block
 block discarded – undo
2865 2865
         if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
2866 2866
             $size1 = round($size / 2);
2867 2867
             $size2 = round($size / 2);
2868
-            return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2868
+            return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2869 2869
         } else
2870 2870
             return $string;
2871 2871
     }
2872 2872
     elseif ($trunc == 'left') {
2873 2873
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2874 2874
         if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2875
-            return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2875
+            return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2876 2876
         else
2877 2877
             return $string;
2878 2878
     }
2879 2879
     elseif ($trunc == 'wrap') {
2880 2880
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2881 2881
         if (dol_strlen($newstring, $stringencoding) > ($size + 1))
2882
-            return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2882
+            return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2883 2883
         else
2884 2884
             return $string;
2885 2885
     } else
@@ -2914,7 +2914,7 @@  discard block
 block discarded – undo
2914 2914
     $url = DOL_BASE_URI;
2915 2915
 
2916 2916
     $theme = $conf->theme;
2917
-    $path = 'theme/' . $theme;
2917
+    $path = 'theme/'.$theme;
2918 2918
 
2919 2919
     // Define fullpathpicto to use into src
2920 2920
     if ($pictoisfullpath) {
@@ -2963,7 +2963,7 @@  discard block
 block discarded – undo
2963 2963
                 $fakey = 'fa-pencil';
2964 2964
                 $facolor = '#444';
2965 2965
             } elseif ($pictowithoutext == 'filter') {
2966
-                $fakey = 'fa-' . $pictowithoutext;
2966
+                $fakey = 'fa-'.$pictowithoutext;
2967 2967
             } elseif ($pictowithoutext == 'grip_title' || $pictowithoutext == 'grip') {
2968 2968
                 $fakey = 'fa-arrows';
2969 2969
             } elseif ($pictowithoutext == 'listlight') {
@@ -3002,15 +3002,15 @@  discard block
 block discarded – undo
3002 3002
             } elseif ($pictowithoutext == 'jabber') {
3003 3003
                 $fakey = 'fa-comment-o';
3004 3004
             } else {
3005
-                $fakey = 'fa-' . $pictowithoutext;
3005
+                $fakey = 'fa-'.$pictowithoutext;
3006 3006
                 $facolor = '#444';
3007 3007
                 $marginleftonlyshort = 0;
3008 3008
             }
3009 3009
 
3010 3010
             if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) {
3011
-                $morecss .= ($morecss ? ' ' : '') . $reg[1];
3011
+                $morecss .= ($morecss ? ' ' : '').$reg[1];
3012 3012
             }
3013
-            $enabledisablehtml = '<span class="fa ' . $fakey . ' ' . ($marginleftonlyshort ? ($marginleftonlyshort == 1 ? 'marginleftonlyshort' : 'marginleftonly') : '') . ' valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" style="' . ($fasize ? ('font-size: ' . $fasize . ';') : '') . ($facolor ? (' color: ' . $facolor . ';') : '') . '" alt="' . dol_escape_htmltag($titlealt) . '"' . (($notitle || empty($title)) ? '' : ' title="' . dol_escape_htmltag($title) . '"') . ($moreatt ? ' ' . $moreatt : '') . '>';
3013
+            $enabledisablehtml = '<span class="fa '.$fakey.' '.($marginleftonlyshort ? ($marginleftonlyshort == 1 ? 'marginleftonlyshort' : 'marginleftonly') : '').' valignmiddle'.($morecss ? ' '.$morecss : '').'" style="'.($fasize ? ('font-size: '.$fasize.';') : '').($facolor ? (' color: '.$facolor.';') : '').'" alt="'.dol_escape_htmltag($titlealt).'"'.(($notitle || empty($title)) ? '' : ' title="'.dol_escape_htmltag($title).'"').($moreatt ? ' '.$moreatt : '').'>';
3014 3014
             if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
3015 3015
                 $enabledisablehtml .= $titlealt;
3016 3016
             }
@@ -3020,11 +3020,11 @@  discard block
 block discarded – undo
3020 3020
         }
3021 3021
 
3022 3022
         if (!empty($conf->global->MAIN_OVERWRITE_THEME_PATH)) {
3023
-            $path = $conf->global->MAIN_OVERWRITE_THEME_PATH . '/theme/' . $theme; // If the theme does not have the same name as the module
3023
+            $path = $conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module
3024 3024
         } else if (!empty($conf->global->MAIN_OVERWRITE_THEME_RES)) {
3025
-            $path = $conf->global->MAIN_OVERWRITE_THEME_RES . '/theme/' . $conf->global->MAIN_OVERWRITE_THEME_RES;  // To allow an external module to overwrite image resources whatever is activated theme
3025
+            $path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme
3026 3026
         } else if (!empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) {
3027
-            $path = $theme . '/theme/' . $theme; // If the theme have the same name as the module
3027
+            $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module
3028 3028
         }
3029 3029
 
3030 3030
         // If we ask an image into $url/$mymodule/img (instead of default path)
@@ -3044,15 +3044,15 @@  discard block
 block discarded – undo
3044 3044
                 continue;
3045 3045
             }
3046 3046
             // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded
3047
-            if (file_exists($dirroot . '/' . $path . '/img/' . $picto)) {
3047
+            if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) {
3048 3048
                 // $url = DOL_URL_ROOT . $conf->file->dol_url_root[$type];
3049
-                $url = DOL_BASE_URI . $conf->file->dol_url_root[$type];
3049
+                $url = DOL_BASE_URI.$conf->file->dol_url_root[$type];
3050 3050
                 break;
3051 3051
             }
3052 3052
         }
3053 3053
 
3054 3054
         // $url is '' or '/custom', $path is current theme or
3055
-        $fullpathpicto = $url . '/' . $path . '/img/' . $picto;
3055
+        $fullpathpicto = $url.'/'.$path.'/img/'.$picto;
3056 3056
     }
3057 3057
 
3058 3058
     if ($srconly) {
@@ -3060,7 +3060,7 @@  discard block
 block discarded – undo
3060 3060
     }
3061 3061
 
3062 3062
     // tag title is used for tooltip on <a>, tag alt can be used with very simple text on image for bind people
3063
-    return '<img src="' . $fullpathpicto . '" alt="' . dol_escape_htmltag($alt) . '"' . (($notitle || empty($titlealt)) ? '' : ' title="' . dol_escape_htmltag($titlealt) . '"') . ($moreatt ? ' ' . $moreatt : ' class="inline-block' . ($morecss ? ' ' . $morecss : '') . '"') . '>'; // Alt is used for accessibility, title for popup
3063
+    return '<img src="'.$fullpathpicto.'" alt="'.dol_escape_htmltag($alt).'"'.(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt : ' class="inline-block'.($morecss ? ' '.$morecss : '').'"').'>'; // Alt is used for accessibility, title for popup
3064 3064
 }
3065 3065
 
3066 3066
 /**
@@ -3078,7 +3078,7 @@  discard block
 block discarded – undo
3078 3078
  */
3079 3079
 function img_object($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0)
3080 3080
 {
3081
-    return img_picto($titlealt, 'object_' . $picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
3081
+    return img_picto($titlealt, 'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
3082 3082
 }
3083 3083
 
3084 3084
 /**
@@ -3099,7 +3099,7 @@  discard block
 block discarded – undo
3099 3099
         $picto .= '.png';
3100 3100
 
3101 3101
     //$path = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/weather/' . $picto;
3102
-    $path = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/weather/' . $picto;
3102
+    $path = DOL_BASE_URI.'/theme/'.$conf->theme.'/img/weather/'.$picto;
3103 3103
 
3104 3104
     return img_picto($titlealt, $path, $moreatt, 1);
3105 3105
 }
@@ -3125,10 +3125,10 @@  discard block
 block discarded – undo
3125 3125
         $path = $picto;
3126 3126
     else {
3127 3127
         //$path = DOL_URL_ROOT . '/theme/common/' . $picto;
3128
-        $path = DOL_BASE_URI . '/theme/common/' . $picto;
3128
+        $path = DOL_BASE_URI.'/theme/common/'.$picto;
3129 3129
 
3130 3130
         if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
3131
-            $themepath = DOL_BASE_PATH . 'theme/' . $conf->theme . '/img/' . $picto;
3131
+            $themepath = DOL_BASE_PATH.'theme/'.$conf->theme.'/img/'.$picto;
3132 3132
 
3133 3133
             if (file_exists($themepath))
3134 3134
                 $path = $themepath;
@@ -3166,14 +3166,14 @@  discard block
 block discarded – undo
3166 3166
             $numaction = 3;
3167 3167
             $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone');
3168 3168
         } else {
3169
-            $titlealt = $langs->transnoentitiesnoconv('ChangeStatus ' . $numaction);
3169
+            $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction);
3170 3170
             $numaction = 0;
3171 3171
         }
3172 3172
     }
3173 3173
     if (!is_numeric($numaction))
3174 3174
         $numaction = 0;
3175 3175
 
3176
-    return img_picto($titlealt, 'stcomm' . $numaction . '.png');
3176
+    return img_picto($titlealt, 'stcomm'.$numaction.'.png');
3177 3177
 }
3178 3178
 
3179 3179
 /**
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
     if ($titlealt == 'default')
3191 3191
         $titlealt = $langs->trans('Show');
3192 3192
 
3193
-    return img_picto($titlealt, 'pdf' . $size . '.png');
3193
+    return img_picto($titlealt, 'pdf'.$size.'.png');
3194 3194
 }
3195 3195
 
3196 3196
 /**
@@ -3242,7 +3242,7 @@  discard block
 block discarded – undo
3242 3242
     if ($titlealt == 'default')
3243 3243
         $titlealt = $langs->trans('Modify');
3244 3244
 
3245
-    return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : ''));
3245
+    return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right').'"' : "").($other ? ' '.$other : ''));
3246 3246
 }
3247 3247
 
3248 3248
 /**
@@ -3260,7 +3260,7 @@  discard block
 block discarded – undo
3260 3260
     if ($titlealt == 'default')
3261 3261
         $titlealt = $langs->trans('View');
3262 3262
 
3263
-    $moreatt = ($float ? 'style="float: right" ' : '') . $other;
3263
+    $moreatt = ($float ? 'style="float: right" ' : '').$other;
3264 3264
 
3265 3265
     return img_picto($titlealt, 'view.png', $moreatt);
3266 3266
 }
@@ -3333,7 +3333,7 @@  discard block
 block discarded – undo
3333 3333
             $usealttitle = $langs->trans('Info');
3334 3334
     }
3335 3335
 
3336
-    return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"');
3336
+    return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')).'"');
3337 3337
 }
3338 3338
 
3339 3339
 /**
@@ -3367,7 +3367,7 @@  discard block
 block discarded – undo
3367 3367
         $titlealt = $langs->trans('Warning');
3368 3368
 
3369 3369
     //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>';
3370
-    return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : ''));
3370
+    return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt) : ''));
3371 3371
 }
3372 3372
 
3373 3373
 /**
@@ -3401,7 +3401,7 @@  discard block
 block discarded – undo
3401 3401
         $titlealt = $langs->trans('Next');
3402 3402
 
3403 3403
     //return img_picto($titlealt, 'next.png', $moreatt);
3404
-    return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
3404
+    return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>';
3405 3405
 }
3406 3406
 
3407 3407
 /**
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
         $titlealt = $langs->trans('Previous');
3420 3420
 
3421 3421
     //return img_picto($titlealt, 'previous.png', $moreatt);
3422
-    return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
3422
+    return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>';
3423 3423
 }
3424 3424
 
3425 3425
 /**
@@ -3437,7 +3437,7 @@  discard block
 block discarded – undo
3437 3437
     if ($titlealt == 'default')
3438 3438
         $titlealt = $langs->trans('Down');
3439 3439
 
3440
-    return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"');
3440
+    return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass ? " ".$moreclass : "").'"');
3441 3441
 }
3442 3442
 
3443 3443
 /**
@@ -3455,7 +3455,7 @@  discard block
 block discarded – undo
3455 3455
     if ($titlealt == 'default')
3456 3456
         $titlealt = $langs->trans('Up');
3457 3457
 
3458
-    return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"');
3458
+    return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass ? " ".$moreclass : "").'"');
3459 3459
 }
3460 3460
 
3461 3461
 /**
@@ -3538,7 +3538,7 @@  discard block
 block discarded – undo
3538 3538
         $brand = 'credit-card';
3539 3539
     }
3540 3540
 
3541
-    return '<span class="fa fa-' . $brand . ' fa-2x fa-fw"></span>';
3541
+    return '<span class="fa fa-'.$brand.' fa-2x fa-fw"></span>';
3542 3542
 }
3543 3543
 
3544 3544
 /**
@@ -3551,17 +3551,17 @@  discard block
 block discarded – undo
3551 3551
  */
3552 3552
 function img_mime($file, $titlealt = '', $morecss = '')
3553 3553
 {
3554
-    require_once DOL_BASE_PATH . '/core/lib/files.lib.php';
3554
+    require_once DOL_BASE_PATH.'/core/lib/files.lib.php';
3555 3555
 
3556 3556
     $mimetype = dol_mimetype($file, '', 1);
3557 3557
     $mimeimg = dol_mimetype($file, '', 2);
3558 3558
     $mimefa = dol_mimetype($file, '', 4);
3559 3559
 
3560 3560
     if (empty($titlealt))
3561
-        $titlealt = 'Mime type: ' . $mimetype;
3561
+        $titlealt = 'Mime type: '.$mimetype;
3562 3562
 
3563 3563
     //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"');
3564
-    return '<i class="fa fa-' . $mimefa . ' paddingright"></i>';
3564
+    return '<i class="fa fa-'.$mimefa.' paddingright"></i>';
3565 3565
 }
3566 3566
 
3567 3567
 /**
@@ -3576,7 +3576,7 @@  discard block
 block discarded – undo
3576 3576
  */
3577 3577
 function img_phone($titlealt = 'default', $option = 0)
3578 3578
 {
3579
-    dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
3579
+    dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
3580 3580
 
3581 3581
     global $conf, $langs;
3582 3582
 
@@ -3607,8 +3607,8 @@  discard block
 block discarded – undo
3607 3607
 
3608 3608
     $img = img_picto($titlealt, 'search.png', $other, false, 1);
3609 3609
 
3610
-    $input = '<input type="image" class="liste_titre" name="button_search" src="' . $img . '" ';
3611
-    $input .= 'value="' . dol_escape_htmltag($titlealt) . '" title="' . dol_escape_htmltag($titlealt) . '" >';
3610
+    $input = '<input type="image" class="liste_titre" name="button_search" src="'.$img.'" ';
3611
+    $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >';
3612 3612
 
3613 3613
     return $input;
3614 3614
 }
@@ -3629,8 +3629,8 @@  discard block
 block discarded – undo
3629 3629
 
3630 3630
     $img = img_picto($titlealt, 'searchclear.png', $other, false, 1);
3631 3631
 
3632
-    $input = '<input type="image" class="liste_titre" name="button_removefilter" src="' . $img . '" ';
3633
-    $input .= 'value="' . dol_escape_htmltag($titlealt) . '" title="' . dol_escape_htmltag($titlealt) . '" >';
3632
+    $input = '<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.'" ';
3633
+    $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >';
3634 3634
 
3635 3635
     return $input;
3636 3636
 }
@@ -3650,10 +3650,10 @@  discard block
 block discarded – undo
3650 3650
     global $conf, $langs;
3651 3651
 
3652 3652
     if ($infoonimgalt) {
3653
-        return img_picto($text, 'info', 'class="hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '"');
3653
+        return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss ? ' '.$morecss : '').'"');
3654 3654
     }
3655 3655
 
3656
-    return ($nodiv ? '' : '<div class="' . (empty($admin) ? '' : ($admin == '1' ? 'info' : $admin)) . ' hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '">') . '<span class="fa fa-info-circle" title="' . dol_escape_htmltag($admin ? $langs->trans('InfoAdmin') : $langs->trans('Note')) . '"></span> ' . $text . ($nodiv ? '' : '</div>');
3656
+    return ($nodiv ? '' : '<div class="'.(empty($admin) ? '' : ($admin == '1' ? 'info' : $admin)).' hideonsmartphone'.($morecss ? ' '.$morecss : '').'">').'<span class="fa fa-info-circle" title="'.dol_escape_htmltag($admin ? $langs->trans('InfoAdmin') : $langs->trans('Note')).'"></span> '.$text.($nodiv ? '' : '</div>');
3657 3657
 }
3658 3658
 
3659 3659
 /**
@@ -3678,7 +3678,7 @@  discard block
 block discarded – undo
3678 3678
 
3679 3679
     // Si erreur intervenue avant chargement langue
3680 3680
     if (!$langs) {
3681
-        require_once DOL_BASE_PATH . '/core/class/translate.class.php';
3681
+        require_once DOL_BASE_PATH.'/core/class/translate.class.php';
3682 3682
         $langs = new Translate('', $conf);
3683 3683
         $langs->load("main");
3684 3684
     }
@@ -3686,51 +3686,51 @@  discard block
 block discarded – undo
3686 3686
     $langs->loadLangs(array('main', 'errors'));
3687 3687
 
3688 3688
     if ($_SERVER['DOCUMENT_ROOT']) {    // Mode web
3689
-        $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
3689
+        $out .= $langs->trans("DolibarrHasDetectedError").".<br>\n";
3690 3690
         if (!empty($conf->global->MAIN_FEATURES_LEVEL))
3691 3691
             $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
3692
-        $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
3692
+        $out .= $langs->trans("InformationToHelpDiagnose").":<br>\n";
3693 3693
 
3694
-        $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
3695
-        $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
3694
+        $out .= "<b>".$langs->trans("Date").":</b> ".dol_print_date(time(), 'dayhourlog')."<br>\n";
3695
+        $out .= "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";
3696 3696
         if (isset($conf->global->MAIN_FEATURES_LEVEL))
3697
-            $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
3697
+            $out .= "<b>".$langs->trans("LevelOfFeature").":</b> ".$conf->global->MAIN_FEATURES_LEVEL."<br>\n";
3698 3698
         if (function_exists("phpversion")) {
3699
-            $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
3699
+            $out .= "<b>".$langs->trans("PHP").":</b> ".phpversion()."<br>\n";
3700 3700
         }
3701
-        $out .= "<b>" . $langs->trans("Server") . ":</b> " . $_SERVER["SERVER_SOFTWARE"] . "<br>\n";
3701
+        $out .= "<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
3702 3702
         if (function_exists("php_uname")) {
3703
-            $out .= "<b>" . $langs->trans("OS") . ":</b> " . php_uname() . "<br>\n";
3703
+            $out .= "<b>".$langs->trans("OS").":</b> ".php_uname()."<br>\n";
3704 3704
         }
3705
-        $out .= "<b>" . $langs->trans("UserAgent") . ":</b> " . $_SERVER["HTTP_USER_AGENT"] . "<br>\n";
3705
+        $out .= "<b>".$langs->trans("UserAgent").":</b> ".$_SERVER["HTTP_USER_AGENT"]."<br>\n";
3706 3706
         $out .= "<br>\n";
3707
-        $out .= "<b>" . $langs->trans("RequestedUrl") . ":</b> " . dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8') . "<br>\n";
3708
-        $out .= "<b>" . $langs->trans("Referer") . ":</b> " . (isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '') . "<br>\n";
3709
-        $out .= "<b>" . $langs->trans("MenuManager") . ":</b> " . (isset($conf->standard_menu) ? $conf->standard_menu : '') . "<br>\n";
3707
+        $out .= "<b>".$langs->trans("RequestedUrl").":</b> ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."<br>\n";
3708
+        $out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '')."<br>\n";
3709
+        $out .= "<b>".$langs->trans("MenuManager").":</b> ".(isset($conf->standard_menu) ? $conf->standard_menu : '')."<br>\n";
3710 3710
         $out .= "<br>\n";
3711
-        $syslog .= "url=" . dol_escape_htmltag($_SERVER["REQUEST_URI"]);
3712
-        $syslog .= ", query_string=" . dol_escape_htmltag($_SERVER["QUERY_STRING"]);
3711
+        $syslog .= "url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]);
3712
+        $syslog .= ", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]);
3713 3713
     } else {                              // Mode CLI
3714
-        $out .= '> ' . $langs->transnoentities("ErrorInternalErrorDetected") . ":\n" . $argv[0] . "\n";
3715
-        $syslog .= "pid=" . dol_getmypid();
3714
+        $out .= '> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n";
3715
+        $syslog .= "pid=".dol_getmypid();
3716 3716
     }
3717 3717
 
3718 3718
     if (is_object($db)) {
3719 3719
         if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
3720
-            $out .= "<b>" . $langs->trans("DatabaseTypeManager") . ":</b> " . $db->type . "<br>\n";
3721
-            $out .= "<b>" . $langs->trans("RequestLastAccessInError") . ":</b> " . ($db->lastqueryerror() ? dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
3722
-            $out .= "<b>" . $langs->trans("ReturnCodeLastAccessInError") . ":</b> " . ($db->lasterrno() ? dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
3723
-            $out .= "<b>" . $langs->trans("InformationLastAccessInError") . ":</b> " . ($db->lasterror() ? dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
3720
+            $out .= "<b>".$langs->trans("DatabaseTypeManager").":</b> ".$db->type."<br>\n";
3721
+            $out .= "<b>".$langs->trans("RequestLastAccessInError").":</b> ".($db->lastqueryerror() ? dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
3722
+            $out .= "<b>".$langs->trans("ReturnCodeLastAccessInError").":</b> ".($db->lasterrno() ? dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
3723
+            $out .= "<b>".$langs->trans("InformationLastAccessInError").":</b> ".($db->lasterror() ? dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
3724 3724
             $out .= "<br>\n";
3725 3725
         } else {                            // Mode CLI
3726 3726
             // No dol_escape_htmltag for output, we are in CLI mode
3727
-            $out .= '> ' . $langs->transnoentities("DatabaseTypeManager") . ":\n" . $db->type . "\n";
3728
-            $out .= '> ' . $langs->transnoentities("RequestLastAccessInError") . ":\n" . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
3729
-            $out .= '> ' . $langs->transnoentities("ReturnCodeLastAccessInError") . ":\n" . ($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
3730
-            $out .= '> ' . $langs->transnoentities("InformationLastAccessInError") . ":\n" . ($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
3727
+            $out .= '> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n";
3728
+            $out .= '> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
3729
+            $out .= '> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
3730
+            $out .= '> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
3731 3731
         }
3732
-        $syslog .= ", sql=" . $db->lastquery();
3733
-        $syslog .= ", db_error=" . $db->lasterror();
3732
+        $syslog .= ", sql=".$db->lastquery();
3733
+        $syslog .= ", db_error=".$db->lasterror();
3734 3734
     }
3735 3735
 
3736 3736
     if ($error || $errors) {
@@ -3750,31 +3750,31 @@  discard block
 block discarded – undo
3750 3750
             if (empty($msg))
3751 3751
                 continue;
3752 3752
             if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
3753
-                $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
3753
+                $out .= "<b>".$langs->trans("Message").":</b> ".dol_escape_htmltag($msg)."<br>\n";
3754 3754
             } else {                        // Mode CLI
3755
-                $out .= '> ' . $langs->transnoentities("Message") . ":\n" . $msg . "\n";
3755
+                $out .= '> '.$langs->transnoentities("Message").":\n".$msg."\n";
3756 3756
             }
3757
-            $syslog .= ", msg=" . $msg;
3757
+            $syslog .= ", msg=".$msg;
3758 3758
         }
3759 3759
     }
3760 3760
     if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) {
3761 3761
         xdebug_print_function_stack();
3762
-        $out .= '<b>XDebug informations:</b>' . "<br>\n";
3763
-        $out .= 'File: ' . xdebug_call_file() . "<br>\n";
3764
-        $out .= 'Line: ' . xdebug_call_line() . "<br>\n";
3765
-        $out .= 'Function: ' . xdebug_call_function() . "<br>\n";
3762
+        $out .= '<b>XDebug informations:</b>'."<br>\n";
3763
+        $out .= 'File: '.xdebug_call_file()."<br>\n";
3764
+        $out .= 'Line: '.xdebug_call_line()."<br>\n";
3765
+        $out .= 'Function: '.xdebug_call_function()."<br>\n";
3766 3766
         $out .= "<br>\n";
3767 3767
     }
3768 3768
 
3769 3769
     if (empty($dolibarr_main_prod))
3770 3770
         print $out;
3771 3771
     else {
3772
-        print $langs->trans("DolibarrHasDetectedError") . '. ';
3772
+        print $langs->trans("DolibarrHasDetectedError").'. ';
3773 3773
         print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
3774 3774
         define("MAIN_CORE_ERROR", 1);
3775 3775
     }
3776 3776
     //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.';
3777
-    dol_syslog("Error " . $syslog, LOG_ERR);
3777
+    dol_syslog("Error ".$syslog, LOG_ERR);
3778 3778
 }
3779 3779
 
3780 3780
 /**
@@ -3797,13 +3797,13 @@  discard block
 block discarded – undo
3797 3797
     $langs->load("errors");
3798 3798
     $now = dol_now();
3799 3799
 
3800
-    print '<br><div class="center login_main_message"><div class="' . $morecss . '">';
3801
-    print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
3800
+    print '<br><div class="center login_main_message"><div class="'.$morecss.'">';
3801
+    print $langs->trans("ErrorContactEMail", $email, $prefixcode.dol_print_date($now, '%Y%m%d'));
3802 3802
     if ($errormessage)
3803
-        print '<br><br>' . $errormessage;
3803
+        print '<br><br>'.$errormessage;
3804 3804
     if (is_array($errormessages) && count($errormessages)) {
3805 3805
         foreach ($errormessages as $mesgtoshow) {
3806
-            print '<br><br>' . $mesgtoshow;
3806
+            print '<br><br>'.$mesgtoshow;
3807 3807
         }
3808 3808
     }
3809 3809
     print '</div></div>';
@@ -3861,16 +3861,16 @@  discard block
 block discarded – undo
3861 3861
     }
3862 3862
 
3863 3863
     $tmpsortfield = explode(',', $sortfield);
3864
-    $sortfield1 = trim($tmpsortfield[0]);    // If $sortfield is 'd.datep,d.id', it becomes 'd.datep'
3864
+    $sortfield1 = trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep'
3865 3865
     $tmpfield = explode(',', $field);
3866
-    $field1 = trim($tmpfield[0]);            // If $field is 'd.datep,d.id', it becomes 'd.datep'
3866
+    $field1 = trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep'
3867 3867
     //var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1);
3868 3868
     // If field is used as sort criteria we use a specific css class liste_titre_sel
3869 3869
     // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom")
3870 3870
     if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) {
3871
-        $out .= '<' . $tag . ' class="' . $prefix . 'liste_titre_sel" ' . $moreattrib . '>';
3871
+        $out .= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '.$moreattrib.'>';
3872 3872
     } else {
3873
-        $out .= '<' . $tag . ' class="' . $prefix . 'liste_titre" ' . $moreattrib . '>';
3873
+        $out .= '<'.$tag.' class="'.$prefix.'liste_titre" '.$moreattrib.'>';
3874 3874
     }
3875 3875
 
3876 3876
     if (empty($thead) && $field && empty($disablesortlink)) {    // If this is a sort field
@@ -3878,7 +3878,7 @@  discard block
 block discarded – undo
3878 3878
         $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options);
3879 3879
         $options = preg_replace('/&+/i', '&', $options);
3880 3880
         if (!preg_match('/^&/', $options)) {
3881
-            $options = '&' . $options;
3881
+            $options = '&'.$options;
3882 3882
         }
3883 3883
 
3884 3884
         $sortordertouseinlink = '';
@@ -3896,7 +3896,7 @@  discard block
 block discarded – undo
3896 3896
             }
3897 3897
         }
3898 3898
         $sortordertouseinlink = preg_replace('/,$/', '', $sortordertouseinlink);
3899
-        $out .= '<a class="reposition" href="' . $file . '?sortfield=' . $field . '&sortorder=' . $sortordertouseinlink . '&begin=' . $begin . $options . '">';
3899
+        $out .= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder='.$sortordertouseinlink.'&begin='.$begin.$options.'">';
3900 3900
     }
3901 3901
 
3902 3902
     if ($tooltip) {
@@ -3914,7 +3914,7 @@  discard block
 block discarded – undo
3914 3914
         $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options);
3915 3915
         $options = preg_replace('/&+/i', '&', $options);
3916 3916
         if (!preg_match('/^&/', $options)) {
3917
-            $options = '&' . $options;
3917
+            $options = '&'.$options;
3918 3918
         }
3919 3919
 
3920 3920
         if (!$sortorder || $field1 != $sortfield1) {
@@ -3924,19 +3924,19 @@  discard block
 block discarded – undo
3924 3924
             if (preg_match('/^DESC/', $sortorder)) {
3925 3925
                 //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
3926 3926
                 //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
3927
-                $sortimg .= '<span class="nowrap">' . img_up("Z-A", 0) . '</span>';
3927
+                $sortimg .= '<span class="nowrap">'.img_up("Z-A", 0).'</span>';
3928 3928
             }
3929 3929
             if (preg_match('/^ASC/', $sortorder)) {
3930 3930
                 //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
3931 3931
                 //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
3932
-                $sortimg .= '<span class="nowrap">' . img_down("A-Z", 0) . '</span>';
3932
+                $sortimg .= '<span class="nowrap">'.img_down("A-Z", 0).'</span>';
3933 3933
             }
3934 3934
         }
3935 3935
     }
3936 3936
 
3937 3937
     $out .= $sortimg;
3938 3938
 
3939
-    $out .= '</' . $tag . '>';
3939
+    $out .= '</'.$tag.'>';
3940 3940
 
3941 3941
     return $out;
3942 3942
 }
@@ -3951,9 +3951,9 @@  discard block
 block discarded – undo
3951 3951
  */
3952 3952
 function print_titre($title)
3953 3953
 {
3954
-    dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
3954
+    dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
3955 3955
 
3956
-    print '<div class="titre">' . $title . '</div>';
3956
+    print '<div class="titre">'.$title.'</div>';
3957 3957
 }
3958 3958
 
3959 3959
 /**
@@ -3996,20 +3996,20 @@  discard block
 block discarded – undo
3996 3996
     }
3997 3997
 
3998 3998
     $return .= "\n";
3999
-    $return .= '<table ' . ($id ? 'id="' . $id . '" ' : '') . 'summary="" class="centpercent notopnoleftnoright' . ($morecssontable ? ' ' . $morecssontable : '') . '" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into print_barre_list
3999
+    $return .= '<table '.($id ? 'id="'.$id.'" ' : '').'summary="" class="centpercent notopnoleftnoright'.($morecssontable ? ' '.$morecssontable : '').'" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into print_barre_list
4000 4000
     if ($picto) {
4001
-        $return .= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">' . img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath) . '</td>';
4001
+        $return .= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).'</td>';
4002 4002
     }
4003 4003
     $return .= '<td class="nobordernopadding valignmiddle">';
4004
-    $return .= '<div class="titre inline-block">' . $titre . '</div>';
4004
+    $return .= '<div class="titre inline-block">'.$titre.'</div>';
4005 4005
     $return .= '</td>';
4006 4006
     if (dol_strlen($morehtmlcenter)) {
4007
-        $return .= '<td class="nobordernopadding" align="center" valign="middle">' . $morehtmlcenter . '</td>';
4007
+        $return .= '<td class="nobordernopadding" align="center" valign="middle">'.$morehtmlcenter.'</td>';
4008 4008
     }
4009 4009
     if (dol_strlen($morehtmlright)) {
4010
-        $return .= '<td class="nobordernopadding titre_right wordbreak" align="right" valign="middle">' . $morehtmlright . '</td>';
4010
+        $return .= '<td class="nobordernopadding titre_right wordbreak" align="right" valign="middle">'.$morehtmlright.'</td>';
4011 4011
     }
4012
-    $return .= '</tr></table>' . "\n";
4012
+    $return .= '</tr></table>'."\n";
4013 4013
 
4014 4014
     return $return;
4015 4015
 }
@@ -4057,29 +4057,29 @@  discard block
 block discarded – undo
4057 4057
     //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage;
4058 4058
 
4059 4059
     print "\n";
4060
-    print "<!-- Begin title '" . $titre . "' -->\n";
4061
-    print '<table border="0" class="centpercent notopnoleftnoright' . ($morecss ? ' ' . $morecss : '') . '" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into load_fiche_tire
4060
+    print "<!-- Begin title '".$titre."' -->\n";
4061
+    print '<table border="0" class="centpercent notopnoleftnoright'.($morecss ? ' '.$morecss : '').'" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into load_fiche_tire
4062 4062
     // Left
4063 4063
     //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
4064 4064
     print '<td class="nobordernopadding valignmiddle">';
4065 4065
     if ($picto && $titre)
4066 4066
         print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4067
-    print '<div class="titre inline-block">' . $titre;
4067
+    print '<div class="titre inline-block">'.$titre;
4068 4068
     if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '')
4069
-        print ' (' . $totalnboflines . ')';
4069
+        print ' ('.$totalnboflines.')';
4070 4070
     print '</div></td>';
4071 4071
 
4072 4072
     // Center
4073 4073
     if ($morehtmlcenter) {
4074
-        print '<td class="nobordernopadding center valignmiddle">' . $morehtmlcenter . '</td>';
4074
+        print '<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.'</td>';
4075 4075
     }
4076 4076
 
4077 4077
     // Right
4078 4078
     print '<td class="nobordernopadding valignmiddle" align="right">';
4079 4079
     if ($sortfield)
4080
-        $options .= "&sortfield=" . urlencode($sortfield);
4080
+        $options .= "&sortfield=".urlencode($sortfield);
4081 4081
     if ($sortorder)
4082
-        $options .= "&sortorder=" . urlencode($sortorder);
4082
+        $options .= "&sortorder=".urlencode($sortorder);
4083 4083
     // Show navigation bar
4084 4084
     $pagelist = '';
4085 4085
     if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
@@ -4097,40 +4097,40 @@  discard block
 block discarded – undo
4097 4097
             }
4098 4098
 
4099 4099
             if ($cpt >= 1) {
4100
-                $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>';
4100
+                $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page=0'.$options.'">1</a></li>';
4101 4101
                 if ($cpt > 2)
4102
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4102
+                    $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '').'>...</span></li>';
4103 4103
                 else if ($cpt == 2)
4104
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4104
+                    $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page=1'.$options.'">2</a></li>';
4105 4105
             }
4106 4106
 
4107 4107
             do {
4108 4108
                 if ($cpt == $page) {
4109
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . '</span></li>';
4109
+                    $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="active"' : '').'>'.($page + 1).'</span></li>';
4110 4110
                 } else {
4111
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . $cpt . $options . '">' . ($cpt + 1) . '</a></li>';
4111
+                    $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.$cpt.$options.'">'.($cpt + 1).'</a></li>';
4112 4112
                 }
4113 4113
                 $cpt++;
4114 4114
             } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage);
4115 4115
 
4116 4116
             if ($cpt < $nbpages) {
4117 4117
                 if ($cpt < $nbpages - 2)
4118
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4118
+                    $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '').'>...</span></li>';
4119 4119
                 else if ($cpt == $nbpages - 2)
4120
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4121
-                $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>';
4120
+                    $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.($nbpages - 2).$options.'">'.($nbpages - 1).'</a></li>';
4121
+                $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.($nbpages - 1).$options.'">'.$nbpages.'</a></li>';
4122 4122
             }
4123 4123
         }
4124 4124
         else {
4125
-            $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>";
4125
+            $pagelist .= '<li'.(($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.(($conf->dol_use_jmobile != 4) ? 'class="active"' : '').'>'.($page + 1)."</li>";
4126 4126
         }
4127 4127
     }
4128 4128
 
4129
-    print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit);  // output the div and ul for previous/last completed with page numbers into $pagelist
4129
+    print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist
4130 4130
 
4131 4131
     print '</td>';
4132 4132
 
4133
-    print '</tr></table>' . "\n";
4133
+    print '</tr></table>'."\n";
4134 4134
     print "<!-- End title -->\n\n";
4135 4135
 }
4136 4136
 
@@ -4161,12 +4161,12 @@  discard block
 block discarded – undo
4161 4161
             $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
4162 4162
 
4163 4163
         print '<li class="pagination">';
4164
-        print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">';
4164
+        print '<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")).'">';
4165 4165
         $tmpchoice = explode(',', $pagesizechoices);
4166
-        $tmpkey = $limit . ':' . $limit;
4166
+        $tmpkey = $limit.':'.$limit;
4167 4167
         if (!in_array($tmpkey, $tmpchoice))
4168 4168
             $tmpchoice[] = $tmpkey;
4169
-        $tmpkey = $conf->liste_limit . ':' . $conf->liste_limit;
4169
+        $tmpkey = $conf->liste_limit.':'.$conf->liste_limit;
4170 4170
         if (!in_array($tmpkey, $tmpchoice))
4171 4171
             $tmpchoice[] = $tmpkey;
4172 4172
         asort($tmpchoice, SORT_NUMERIC);
@@ -4181,7 +4181,7 @@  discard block
 block discarded – undo
4181 4181
                     $selected = ' selected="selected"';
4182 4182
                     $found = true;
4183 4183
                 }
4184
-                print '<option name="' . $key . '"' . $selected . '>' . dol_escape_htmltag($val) . '</option>' . "\n";
4184
+                print '<option name="'.$key.'"'.$selected.'>'.dol_escape_htmltag($val).'</option>'."\n";
4185 4185
             }
4186 4186
         }
4187 4187
         print '</select>';
@@ -4200,20 +4200,20 @@  discard block
 block discarded – undo
4200 4200
         print '</li>';
4201 4201
     }
4202 4202
     if ($page > 0) {
4203
-        print '<li class="pagination"><a class="paginationprevious" href="' . $file . '?page=' . ($page - 1) . $options . '"><i class="fa fa-chevron-left" title="' . dol_escape_htmltag($langs->trans("Previous")) . '"></i></a></li>';
4203
+        print '<li class="pagination"><a class="paginationprevious" href="'.$file.'?page='.($page - 1).$options.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
4204 4204
     }
4205 4205
     if ($betweenarrows) {
4206 4206
         print $betweenarrows;
4207 4207
     }
4208 4208
     if ($nextpage > 0) {
4209
-        print '<li class="pagination"><a class="paginationnext" href="' . $file . '?page=' . ($page + 1) . $options . '"><i class="fa fa-chevron-right" title="' . dol_escape_htmltag($langs->trans("Next")) . '"></i></a></li>';
4209
+        print '<li class="pagination"><a class="paginationnext" href="'.$file.'?page='.($page + 1).$options.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
4210 4210
     }
4211 4211
     if ($afterarrows) {
4212 4212
         print '<li class="paginationafterarrows">';
4213 4213
         print $afterarrows;
4214 4214
         print '</li>';
4215 4215
     }
4216
-    print '</ul></div>' . "\n";
4216
+    print '</ul></div>'."\n";
4217 4217
 }
4218 4218
 
4219 4219
 /**
@@ -4235,8 +4235,8 @@  discard block
 block discarded – undo
4235 4235
         $addpercent = true;
4236 4236
     }
4237 4237
     if (preg_match('/\((.*)\)/', $rate, $reg)) {
4238
-        $morelabel = ' (' . $reg[1] . ')';
4239
-        $rate = preg_replace('/\s*' . preg_quote($morelabel, '/') . '/', '', $rate);
4238
+        $morelabel = ' ('.$reg[1].')';
4239
+        $rate = preg_replace('/\s*'.preg_quote($morelabel, '/').'/', '', $rate);
4240 4240
     }
4241 4241
     if (preg_match('/\*/', $rate)) {
4242 4242
         $rate = str_replace('*', '', $rate);
@@ -4245,10 +4245,10 @@  discard block
 block discarded – undo
4245 4245
 
4246 4246
     // If rate is '9/9/9' we don't change it.  If rate is '9.000' we apply price()
4247 4247
     if (!preg_match('/\//', $rate))
4248
-        $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4248
+        $ret = price($rate, 0, '', 0, 0).($addpercent ? '%' : '');
4249 4249
     else {
4250 4250
         // TODO Split on / and output with a price2num to have clean numbers without ton of 000.
4251
-        $ret = $rate . ($addpercent ? '%' : '');
4251
+        $ret = $rate.($addpercent ? '%' : '');
4252 4252
     }
4253 4253
     if (($info_bits & 1) && $usestarfornpr >= 0)
4254 4254
         $ret .= ' *';
@@ -4342,10 +4342,10 @@  discard block
 block discarded – undo
4342 4342
             $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4343 4343
         else {
4344 4344
             $tmpcur = $outlangs->getCurrencySymbol($currency_code);
4345
-            $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur);
4345
+            $cursymbolafter .= ($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur);
4346 4346
         }
4347 4347
     }
4348
-    $output = $cursymbolbefore . $output . $end . ($cursymbolafter ? ' ' : '') . $cursymbolafter;
4348
+    $output = $cursymbolbefore.$output.$end.($cursymbolafter ? ' ' : '').$cursymbolafter;
4349 4349
 
4350 4350
     return $output;
4351 4351
 }
@@ -4399,7 +4399,7 @@  discard block
 block discarded – undo
4399 4399
         // Now make replace (the main goal of function)
4400 4400
         if ($thousand != ',' && $thousand != '.')
4401 4401
             $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4402
-        $amount = str_replace(' ', '', $amount);  // To avoid spaces
4402
+        $amount = str_replace(' ', '', $amount); // To avoid spaces
4403 4403
         $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4404 4404
         $amount = str_replace($dec, '.', $amount);
4405 4405
     }
@@ -4428,14 +4428,14 @@  discard block
 block discarded – undo
4428 4428
             $temps = sprintf("%0.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
4429 4429
             $temps = preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1
4430 4430
             $nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0."
4431
-            $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);  // Convert amount to format with dolibarr dec and thousand
4431
+            $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand); // Convert amount to format with dolibarr dec and thousand
4432 4432
         }
4433 4433
         //print "TT".$amount.'<br>';
4434 4434
         // Always make replace because each math function (like round) replace
4435 4435
         // with local values and we want a number that has a SQL string format x.y
4436 4436
         if ($thousand != ',' && $thousand != '.')
4437 4437
             $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4438
-        $amount = str_replace(' ', '', $amount);  // To avoid spaces
4438
+        $amount = str_replace(' ', '', $amount); // To avoid spaces
4439 4439
         $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4440 4440
         $amount = str_replace($dec, '.', $amount);
4441 4441
     }
@@ -4456,7 +4456,7 @@  discard block
 block discarded – undo
4456 4456
  */
4457 4457
 function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no')
4458 4458
 {
4459
-    require_once DOL_BASE_PATH . '/core/lib/product.lib.php';
4459
+    require_once DOL_BASE_PATH.'/core/lib/product.lib.php';
4460 4460
 
4461 4461
     if (($forceunitoutput == 'no' && $dimension < 1 / 10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
4462 4462
         $dimension = $dimension * 1000000;
@@ -4472,7 +4472,7 @@  discard block
 block discarded – undo
4472 4472
         $unit = $unit + 3;
4473 4473
     }
4474 4474
 
4475
-    $ret = price($dimension, 0, $outputlangs, 0, 0, $round) . ' ' . measuring_units_string($unit, $type);
4475
+    $ret = price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type);
4476 4476
 
4477 4477
     return $ret;
4478 4478
 }
@@ -4496,7 +4496,7 @@  discard block
 block discarded – undo
4496 4496
     if (empty($thirdparty_seller) || !is_object($thirdparty_seller))
4497 4497
         $thirdparty_seller = $mysoc;
4498 4498
 
4499
-    dol_syslog("get_localtax tva=" . $vatrate . " local=" . $local . " thirdparty_buyer id=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '') . "/country_code=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '') . " thirdparty_seller id=" . $thirdparty_seller->id . "/country_code=" . $thirdparty_seller->country_code . " thirdparty_seller localtax1_assuj=" . $thirdparty_seller->localtax1_assuj . "  thirdparty_seller localtax2_assuj=" . $thirdparty_seller->localtax2_assuj);
4499
+    dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj."  thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
4500 4500
 
4501 4501
     $vatratecleaned = $vatrate;
4502 4502
     if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "xx (yy)"
@@ -4527,7 +4527,7 @@  discard block
 block discarded – undo
4527 4527
         if ($local == 2) {
4528 4528
             //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0;
4529 4529
             if (!$mysoc->localtax2_assuj)
4530
-                return 0;  // If main vat is 0, IRPF may be different than 0.
4530
+                return 0; // If main vat is 0, IRPF may be different than 0.
4531 4531
             if ($thirdparty_seller->id == $mysoc->id) {
4532 4532
                 if (!$thirdparty_buyer->localtax2_assuj)
4533 4533
                     return 0;
@@ -4581,13 +4581,13 @@  discard block
 block discarded – undo
4581 4581
 
4582 4582
     // By default, search value of local tax on line of common tax
4583 4583
     $sql = "SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
4584
-    $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4585
-    $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'";
4586
-    $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4584
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4585
+    $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'";
4586
+    $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
4587 4587
     if ($vatratecode)
4588
-        $sql .= " AND t.code ='" . $vatratecode . "'";  // If we have the code, we use it in priority
4588
+        $sql .= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority
4589 4589
     else
4590
-        $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4590
+        $sql .= " AND t.recuperableonly ='".$vatnpr."'";
4591 4591
     dol_syslog("get_localtax", LOG_DEBUG);
4592 4592
     $resql = $db->query($sql);
4593 4593
 
@@ -4633,10 +4633,10 @@  discard block
 block discarded – undo
4633 4633
 {
4634 4634
     global $db, $mysoc;
4635 4635
     $sql = "SELECT t.localtax1, t.localtax2 ";
4636
-    $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=t.fk_pays";
4637
-    $sql .= " WHERE c.code = '" . $mysoc->country_code . "' AND t.active = 1 AND t.taux=(";
4638
-    $sql .= "  SELECT max(tt.taux) FROM " . MAIN_DB_PREFIX . "c_tva as tt inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=tt.fk_pays";
4639
-    $sql .= "  WHERE c.code = '" . $mysoc->country_code . "' AND tt.active = 1";
4636
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays";
4637
+    $sql .= " WHERE c.code = '".$mysoc->country_code."' AND t.active = 1 AND t.taux=(";
4638
+    $sql .= "  SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays";
4639
+    $sql .= "  WHERE c.code = '".$mysoc->country_code."' AND tt.active = 1";
4640 4640
     $sql .= "  )";
4641 4641
 
4642 4642
     $resql = $db->query($sql);
@@ -4666,13 +4666,13 @@  discard block
 block discarded – undo
4666 4666
 {
4667 4667
     global $db, $mysoc;
4668 4668
 
4669
-    dol_syslog("getTaxesFromId vat id or rate = " . $vatrate);
4669
+    dol_syslog("getTaxesFromId vat id or rate = ".$vatrate);
4670 4670
 
4671 4671
     // Search local taxes
4672 4672
     $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy";
4673
-    $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4673
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
4674 4674
     if ($firstparamisid)
4675
-        $sql .= " WHERE t.rowid = " . (int) $vatrate;
4675
+        $sql .= " WHERE t.rowid = ".(int) $vatrate;
4676 4676
     else {
4677 4677
         $vatratecleaned = $vatrate;
4678 4678
         $vatratecode = '';
@@ -4681,13 +4681,13 @@  discard block
 block discarded – undo
4681 4681
             $vatratecode = $reg[2];
4682 4682
         }
4683 4683
 
4684
-        $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4684
+        $sql .= ", ".MAIN_DB_PREFIX."c_country as c";
4685 4685
         /* if ($mysoc->country_code == 'ES') $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'";    // vat in spain use the buyer country ??
4686 4686
           else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */
4687
-        $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4688
-        $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4687
+        $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
4688
+        $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
4689 4689
         if ($vatratecode)
4690
-            $sql .= " AND t.code = '" . $vatratecode . "'";
4690
+            $sql .= " AND t.code = '".$vatratecode."'";
4691 4691
     }
4692 4692
 
4693 4693
     $resql = $db->query($sql);
@@ -4723,13 +4723,13 @@  discard block
 block discarded – undo
4723 4723
 {
4724 4724
     global $db, $mysoc;
4725 4725
 
4726
-    dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
4726
+    dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local);
4727 4727
 
4728 4728
     // Search local taxes
4729 4729
     $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
4730
-    $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4730
+    $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
4731 4731
     if ($firstparamisid)
4732
-        $sql .= " WHERE t.rowid = " . (int) $vatrate;
4732
+        $sql .= " WHERE t.rowid = ".(int) $vatrate;
4733 4733
     else {
4734 4734
         $vatratecleaned = $vatrate;
4735 4735
         $vatratecode = '';
@@ -4738,14 +4738,14 @@  discard block
 block discarded – undo
4738 4738
             $vatratecode = $reg[2];
4739 4739
         }
4740 4740
 
4741
-        $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4741
+        $sql .= ", ".MAIN_DB_PREFIX."c_country as c";
4742 4742
         if ($mysoc->country_code == 'ES')
4743
-            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";    // local tax in spain use the buyer country ??
4743
+            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ??
4744 4744
         else
4745
-            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4746
-        $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4745
+            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
4746
+        $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
4747 4747
         if ($vatratecode)
4748
-            $sql .= " AND t.code = '" . $vatratecode . "'";
4748
+            $sql .= " AND t.code = '".$vatratecode."'";
4749 4749
     }
4750 4750
 
4751 4751
     $resql = $db->query($sql);
@@ -4777,7 +4777,7 @@  discard block
 block discarded – undo
4777 4777
 {
4778 4778
     global $db, $conf, $mysoc;
4779 4779
 
4780
-    require_once DOL_BASE_PATH . '/product/class/product.class.php';
4780
+    require_once DOL_BASE_PATH.'/product/class/product.class.php';
4781 4781
 
4782 4782
     $ret = 0;
4783 4783
     $found = 0;
@@ -4792,12 +4792,12 @@  discard block
 block discarded – undo
4792 4792
                 $product->get_buyprice($idprodfournprice, 0, 0, 0);
4793 4793
                 $ret = $product->vatrate_supplier;
4794 4794
                 if ($product->default_vat_code)
4795
-                    $ret .= ' (' . $product->default_vat_code . ')';
4795
+                    $ret .= ' ('.$product->default_vat_code.')';
4796 4796
             }
4797 4797
             else {
4798
-                $ret = $product->tva_tx;    // Default vat of product we defined
4798
+                $ret = $product->tva_tx; // Default vat of product we defined
4799 4799
                 if ($product->default_vat_code)
4800
-                    $ret .= ' (' . $product->default_vat_code . ')';
4800
+                    $ret .= ' ('.$product->default_vat_code.')';
4801 4801
             }
4802 4802
             $found = 1;
4803 4803
         }
@@ -4811,8 +4811,8 @@  discard block
 block discarded – undo
4811 4811
         if (empty($conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
4812 4812
             // If vat of product for the country not found or not defined, we return the first higher vat of country.
4813 4813
             $sql = "SELECT t.taux as vat_rate, t.code as default_vat_code";
4814
-            $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4815
-            $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='" . $thirdparty_seller->country_code . "'";
4814
+            $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4815
+            $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'";
4816 4816
             $sql .= " ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC";
4817 4817
             $sql .= $db->plimit(1);
4818 4818
 
@@ -4822,16 +4822,16 @@  discard block
 block discarded – undo
4822 4822
                 if ($obj) {
4823 4823
                     $ret = $obj->vat_rate;
4824 4824
                     if ($obj->default_vat_code)
4825
-                        $ret .= ' (' . $obj->default_vat_code . ')';
4825
+                        $ret .= ' ('.$obj->default_vat_code.')';
4826 4826
                 }
4827 4827
                 $db->free($sql);
4828 4828
             } else
4829 4829
                 dol_print_error($db);
4830 4830
         } else
4831
-            $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;    // Forced value if autodetect fails
4831
+            $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails
4832 4832
     }
4833 4833
 
4834
-    dol_syslog("get_product_vat_for_country: ret=" . $ret);
4834
+    dol_syslog("get_product_vat_for_country: ret=".$ret);
4835 4835
     return $ret;
4836 4836
 }
4837 4837
 
@@ -4849,7 +4849,7 @@  discard block
 block discarded – undo
4849 4849
     global $db, $mysoc;
4850 4850
 
4851 4851
     if (!class_exists('Product')) {
4852
-        require_once DOL_BASE_PATH . 'product/class/product.class.php';
4852
+        require_once DOL_BASE_PATH.'product/class/product.class.php';
4853 4853
     }
4854 4854
 
4855 4855
     $ret = 0;
@@ -4874,8 +4874,8 @@  discard block
 block discarded – undo
4874 4874
     if (!$found) {
4875 4875
         // If vat of product for the country not found or not defined, we return higher vat of country.
4876 4876
         $sql = "SELECT taux as vat_rate, localtax1, localtax2";
4877
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4878
-        $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='" . $thirdparty_seller->country_code . "'";
4877
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4878
+        $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'";
4879 4879
         $sql .= " ORDER BY t.taux DESC, t.recuperableonly ASC";
4880 4880
         $sql .= $db->plimit(1);
4881 4881
 
@@ -4892,7 +4892,7 @@  discard block
 block discarded – undo
4892 4892
             dol_print_error($db);
4893 4893
     }
4894 4894
 
4895
-    dol_syslog("get_product_localtax_for_country: ret=" . $ret);
4895
+    dol_syslog("get_product_localtax_for_country: ret=".$ret);
4896 4896
     return $ret;
4897 4897
 }
4898 4898
 
@@ -4916,7 +4916,7 @@  discard block
 block discarded – undo
4916 4916
 {
4917 4917
     global $conf;
4918 4918
 
4919
-    require_once DOL_BASE_PATH . '/core/lib/company.lib.php';
4919
+    require_once DOL_BASE_PATH.'/core/lib/company.lib.php';
4920 4920
 
4921 4921
     // Note: possible values for tva_assuj are 0/1 or franchise/reel
4922 4922
     $seller_use_vat = ((is_numeric($thirdparty_seller->tva_assuj) && !$thirdparty_seller->tva_assuj) || (!is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj == 'franchise')) ? 0 : 1;
@@ -4927,7 +4927,7 @@  discard block
 block discarded – undo
4927 4927
     $buyer_country_code = $thirdparty_buyer->country_code;
4928 4928
     $buyer_in_cee = isInEEC($thirdparty_buyer);
4929 4929
 
4930
-    dol_syslog("get_default_tva: seller use vat=" . $seller_use_vat . ", seller country=" . $seller_country_code . ", seller in cee=" . $seller_in_cee . ", buyer vat number=" . $thirdparty_buyer->tva_intra . " buyer country=" . $buyer_country_code . ", buyer in cee=" . $buyer_in_cee . ", idprod=" . $idprod . ", idprodfournprice=" . $idprodfournprice . ", SERVICE_ARE_ECOMMERCE_200238EC=" . (!empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC : ''));
4930
+    dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer vat number=".$thirdparty_buyer->tva_intra." buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(!empty($conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? $conf->global->SERVICES_ARE_ECOMMERCE_200238EC : ''));
4931 4931
 
4932 4932
     // If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm)
4933 4933
     // we use the buyer VAT.
@@ -4993,14 +4993,14 @@  discard block
 block discarded – undo
4993 4993
 
4994 4994
     if ($idprodfournprice > 0) {
4995 4995
         if (!class_exists('ProductFournisseur'))
4996
-            require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
4996
+            require_once DOL_BASE_PATH.'/fourn/class/fournisseur.product.class.php';
4997 4997
         $prodprice = new ProductFournisseur($db);
4998 4998
         $prodprice->fetch_product_fournisseur_price($idprodfournprice);
4999 4999
         return $prodprice->fourn_tva_npr;
5000 5000
     }
5001 5001
     elseif ($idprod > 0) {
5002 5002
         if (!class_exists('Product'))
5003
-            require_once DOL_BASE_PATH . 'product/class/product.class.php';
5003
+            require_once DOL_BASE_PATH.'product/class/product.class.php';
5004 5004
         $prod = new Product($db);
5005 5005
         $prod->fetch($idprod);
5006 5006
         return $prod->tva_npr;
@@ -5079,7 +5079,7 @@  discard block
 block discarded – undo
5079 5079
         if ($case == 2)
5080 5080
             $result = '<input type="checkbox" value="1" checked disabled>';
5081 5081
         if ($case == 3)
5082
-            $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5082
+            $result = '<input type="checkbox" value="1" checked disabled> '.$result;
5083 5083
 
5084 5084
         $classname = 'ok';
5085 5085
     }
@@ -5090,7 +5090,7 @@  discard block
 block discarded – undo
5090 5090
         if ($case == 2)
5091 5091
             $result = '<input type="checkbox" value="0" disabled>';
5092 5092
         if ($case == 3)
5093
-            $result = '<input type="checkbox" value="0" disabled> ' . $result;
5093
+            $result = '<input type="checkbox" value="0" disabled> '.$result;
5094 5094
 
5095 5095
         if ($color == 2)
5096 5096
             $classname = 'ok';
@@ -5098,7 +5098,7 @@  discard block
 block discarded – undo
5098 5098
             $classname = 'error';
5099 5099
     }
5100 5100
     if ($color)
5101
-        return '<font class="' . $classname . '">' . $result . '</font>';
5101
+        return '<font class="'.$classname.'">'.$result.'</font>';
5102 5102
     return $result;
5103 5103
 }
5104 5104
 
@@ -5132,13 +5132,13 @@  discard block
 block discarded – undo
5132 5132
             $num = preg_replace('/([^0-9])/i', '', $num);
5133 5133
         else
5134 5134
             $num = preg_replace('/^.*\-/i', '', $num);
5135
-        $num = substr("000" . $num, -$level);
5135
+        $num = substr("000".$num, -$level);
5136 5136
         if ($level == 1)
5137 5137
             $path = substr($num, 0, 1);
5138 5138
         if ($level == 2)
5139
-            $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5139
+            $path = substr($num, 1, 1).'/'.substr($num, 0, 1);
5140 5140
         if ($level == 3)
5141
-            $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5141
+            $path = substr($num, 2, 1).'/'.substr($num, 1, 1).'/'.substr($num, 0, 1);
5142 5142
     }
5143 5143
     else {
5144 5144
         // TODO
@@ -5169,7 +5169,7 @@  discard block
 block discarded – undo
5169 5169
 {
5170 5170
     global $conf;
5171 5171
 
5172
-    dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
5172
+    dol_syslog("functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
5173 5173
 
5174 5174
     $dir_osencoded = dol_osencode($dir);
5175 5175
     if (@is_dir($dir_osencoded))
@@ -5181,15 +5181,15 @@  discard block
 block discarded – undo
5181 5181
     $ccdir = '';
5182 5182
     if (!empty($dataroot)) {
5183 5183
         // Remove data root from loop
5184
-        $dir = str_replace($dataroot . '/', '', $dir);
5185
-        $ccdir = $dataroot . '/';
5184
+        $dir = str_replace($dataroot.'/', '', $dir);
5185
+        $ccdir = $dataroot.'/';
5186 5186
     }
5187 5187
 
5188 5188
     $cdir = explode("/", $dir);
5189 5189
     $num = count($cdir);
5190 5190
     for ($i = 0; $i < $num; $i++) {
5191 5191
         if ($i > 0)
5192
-            $ccdir .= '/' . $cdir[$i];
5192
+            $ccdir .= '/'.$cdir[$i];
5193 5193
         else
5194 5194
             $ccdir .= $cdir[$i];
5195 5195
         if (preg_match("/^.:$/", $ccdir, $regs))
@@ -5225,20 +5225,20 @@  discard block
 block discarded – undo
5225 5225
         if ($ccdir) {
5226 5226
             $ccdir_osencoded = dol_osencode($ccdir);
5227 5227
             if (!@is_dir($ccdir_osencoded)) {
5228
-                dol_syslog("functions.lib::dol_mkdir: Directory '" . $ccdir . "' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
5228
+                dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
5229 5229
 
5230 5230
                 umask(0);
5231 5231
                 $dirmaskdec = octdec($newmask);
5232 5232
                 if (empty($newmask)) {
5233 5233
                     $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec('0755') : octdec($conf->global->MAIN_UMASK);
5234 5234
                 }
5235
-                $dirmaskdec |= octdec('0111');  // Set x bit required for directories
5235
+                $dirmaskdec |= octdec('0111'); // Set x bit required for directories
5236 5236
                 if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
5237 5237
                     // Si le is_dir a renvoye une fausse info, alors on passe ici.
5238
-                    dol_syslog("functions.lib::dol_mkdir: Fails to create directory '" . $ccdir . "' or directory already exists.", LOG_WARNING);
5238
+                    dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.", LOG_WARNING);
5239 5239
                     $nberr++;
5240 5240
                 } else {
5241
-                    dol_syslog("functions.lib::dol_mkdir: Directory '" . $ccdir . "' created", LOG_DEBUG);
5241
+                    dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created", LOG_DEBUG);
5242 5242
                     $nberr = 0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore
5243 5243
                     $nbcreated++;
5244 5244
                 }
@@ -5286,9 +5286,9 @@  discard block
 block discarded – undo
5286 5286
     } else {
5287 5287
         $pattern = "/<[^<>]+>/";
5288 5288
         // Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
5289
-        $temp = preg_replace($pattern, "", $temp);    // pass 1
5289
+        $temp = preg_replace($pattern, "", $temp); // pass 1
5290 5290
         // $temp after pass 1: <a href="/myurl" title="A title">0000-021
5291
-        $temp = preg_replace($pattern, "", $temp);    // pass 2
5291
+        $temp = preg_replace($pattern, "", $temp); // pass 2
5292 5292
         // $temp after pass 2: 0000-021
5293 5293
     }
5294 5294
 
@@ -5344,8 +5344,8 @@  discard block
 block discarded – undo
5344 5344
 {
5345 5345
     $temp = $stringtoclean;
5346 5346
     foreach ($disallowed_tags as $tagtoremove) {
5347
-        $temp = preg_replace('/<\/?' . $tagtoremove . '>/', '', $temp);
5348
-        $temp = preg_replace('/<\/?' . $tagtoremove . '\s+[^>]*>/', '', $temp);
5347
+        $temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp);
5348
+        $temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp);
5349 5349
     }
5350 5350
     return $temp;
5351 5351
 }
@@ -5362,12 +5362,12 @@  discard block
 block discarded – undo
5362 5362
 {
5363 5363
     if ($nboflines == 1) {
5364 5364
         if (dol_textishtml($text)) {
5365
-            $firstline = preg_replace('/<br[^>]*>.*$/s', '', $text);  // The s pattern modifier means the . can match newline characters
5365
+            $firstline = preg_replace('/<br[^>]*>.*$/s', '', $text); // The s pattern modifier means the . can match newline characters
5366 5366
             $firstline = preg_replace('/<div[^>]*>.*$/s', '', $firstline); // The s pattern modifier means the . can match newline characters
5367 5367
         } else {
5368 5368
             $firstline = preg_replace('/[\n\r].*/', '', $text);
5369 5369
         }
5370
-        return $firstline . ((strlen($firstline) != strlen($text)) ? '...' : '');
5370
+        return $firstline.((strlen($firstline) != strlen($text)) ? '...' : '');
5371 5371
     } else {
5372 5372
         $ishtml = 0;
5373 5373
         if (dol_textishtml($text)) {
@@ -5383,7 +5383,7 @@  discard block
 block discarded – undo
5383 5383
             $pattern = '/(<br[^>]*>)/Uu';
5384 5384
         } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5385 5385
         else
5386
-            $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5386
+            $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
5387 5387
         $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5388 5388
 
5389 5389
         $firstline = '';
@@ -5397,7 +5397,7 @@  discard block
 block discarded – undo
5397 5397
             $i++;
5398 5398
         }
5399 5399
         unset($a);
5400
-        return $firstline . (($i < $nba) ? '...' : '');
5400
+        return $firstline.(($i < $nba) ? '...' : '');
5401 5401
     }
5402 5402
 }
5403 5403
 
@@ -5468,9 +5468,9 @@  discard block
 block discarded – undo
5468 5468
 function dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto = 'UTF-8')
5469 5469
 {
5470 5470
     $ret = dol_html_entity_decode($stringtodecode, ENT_COMPAT, $pagecodeto);
5471
-    $ret = preg_replace('/' . "\r\n" . '<br(\s[\sa-zA-Z_="]*)?\/?>/i', "<br>", $ret);
5472
-    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>' . "\r\n" . '/i', "\r\n", $ret);
5473
-    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>' . "\n" . '/i', "\n", $ret);
5471
+    $ret = preg_replace('/'."\r\n".'<br(\s[\sa-zA-Z_="]*)?\/?>/i', "<br>", $ret);
5472
+    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\r\n".'/i', "\r\n", $ret);
5473
+    $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\n".'/i', "\n", $ret);
5474 5474
     $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', "\n", $ret);
5475 5475
     return $ret;
5476 5476
 }
@@ -5483,7 +5483,7 @@  discard block
 block discarded – undo
5483 5483
  */
5484 5484
 function dol_htmlcleanlastbr($stringtodecode)
5485 5485
 {
5486
-    $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|' . "\n" . '|' . "\r" . ')+$/i', "", $stringtodecode);
5486
+    $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'."\n".'|'."\r".')+$/i', "", $stringtodecode);
5487 5487
     return $ret;
5488 5488
 }
5489 5489
 
@@ -5580,7 +5580,7 @@  discard block
 block discarded – undo
5580 5580
         $pattern = '/(<br[^>]*>)/Uu';
5581 5581
     } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5582 5582
     else
5583
-        $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5583
+        $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
5584 5584
     $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5585 5585
 
5586 5586
     $nblines = (int) floor((count($a) + 1) / 2);
@@ -5611,7 +5611,7 @@  discard block
 block discarded – undo
5611 5611
  */
5612 5612
 function dol_microtime_float()
5613 5613
 {
5614
-    dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
5614
+    dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
5615 5615
 
5616 5616
     return microtime(true);
5617 5617
 }
@@ -5657,9 +5657,9 @@  discard block
 block discarded – undo
5657 5657
         elseif (preg_match('/<h[0-9]>/i', $msg))
5658 5658
             return true;
5659 5659
         elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
5660
-            return true;    // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5660
+            return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5661 5661
         elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
5662
-            return true;    // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5662
+            return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5663 5663
 
5664 5664
         return false;
5665 5665
     }
@@ -5884,7 +5884,7 @@  discard block
 block discarded – undo
5884 5884
                 if ($object->fetch_optionals() > 0) {
5885 5885
                     if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
5886 5886
                         foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
5887
-                            $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
5887
+                            $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key];
5888 5888
                         }
5889 5889
                     }
5890 5890
                 }
@@ -5896,7 +5896,7 @@  discard block
 block discarded – undo
5896 5896
                 $paymenturl = '';
5897 5897
             } else {
5898 5898
                 // Set the online payment url link into __ONLINE_PAYMENT_URL__ key
5899
-                require_once DOL_BASE_PATH . '/core/lib/payments.lib.php';
5899
+                require_once DOL_BASE_PATH.'/core/lib/payments.lib.php';
5900 5900
                 $outputlangs->loadLangs(array('paypal', 'other'));
5901 5901
                 $typeforonlinepayment = 'free';
5902 5902
                 if (is_object($object) && $object->element == 'commande')
@@ -5957,7 +5957,7 @@  discard block
 block discarded – undo
5957 5957
 
5958 5958
     //var_dump($substitutionarray['__AMOUNT_FORMATED__']);
5959 5959
     if (empty($exclude) || !in_array('date', $exclude)) {
5960
-        include_once DOL_BASE_PATH . '/core/lib/date.lib.php';
5960
+        include_once DOL_BASE_PATH.'/core/lib/date.lib.php';
5961 5961
 
5962 5962
         $tmp = dol_getdate(dol_now(), true);
5963 5963
         $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
@@ -5967,13 +5967,13 @@  discard block
 block discarded – undo
5967 5967
 
5968 5968
         $substitutionarray = array_merge($substitutionarray, array(
5969 5969
             '__DAY__' => (string) $tmp['mday'],
5970
-            '__DAY_TEXT__' => $outputlangs->trans('Day' . $tmp['wday']), // Monday
5971
-            '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'] . 'Min'), // Mon
5972
-            '__DAY_TEXT_MIN__' => $outputlangs->trans('Short' . $tmp['weekday']), // M
5970
+            '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday
5971
+            '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon
5972
+            '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M
5973 5973
             '__MONTH__' => (string) $tmp['mon'],
5974
-            '__MONTH_TEXT__' => $outputlangs->trans('Month' . sprintf("%02d", $tmp['mon'])),
5975
-            '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort' . sprintf("%02d", $tmp['mon'])),
5976
-            '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort' . sprintf("%02d", $tmp['mon'])),
5974
+            '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])),
5975
+            '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])),
5976
+            '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort'.sprintf("%02d", $tmp['mon'])),
5977 5977
             '__YEAR__' => (string) $tmp['year'],
5978 5978
             '__PREVIOUS_DAY__' => (string) $tmp2['day'],
5979 5979
             '__PREVIOUS_MONTH__' => (string) $tmp3['month'],
@@ -6032,7 +6032,7 @@  discard block
 block discarded – undo
6032 6032
             if (!empty($tmp[1]))
6033 6033
                 $outputlangs->load($tmp[1]);
6034 6034
 
6035
-            $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6035
+            $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6036 6036
         }
6037 6037
     }
6038 6038
 
@@ -6048,13 +6048,13 @@  discard block
 block discarded – undo
6048 6048
             $newval = '*****forbidden*****';
6049 6049
         else
6050 6050
             $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound;
6051
-        $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
6051
+        $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
6052 6052
     }
6053 6053
 
6054 6054
     // Make substitition for array $substitutionarray
6055 6055
     foreach ($substitutionarray as $key => $value) {
6056 6056
         if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6057
-            $value = '';  // Protection
6057
+            $value = ''; // Protection
6058 6058
         if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6059 6059
             $value = ''; // Protection
6060 6060
 
@@ -6080,7 +6080,7 @@  discard block
 block discarded – undo
6080 6080
 {
6081 6081
     global $conf, $user;
6082 6082
 
6083
-    require_once DOL_BASE_PATH . '/core/lib/files.lib.php';
6083
+    require_once DOL_BASE_PATH.'/core/lib/files.lib.php';
6084 6084
 
6085 6085
     // Add a substitution key for each extrafields, using key __EXTRA_XXX__
6086 6086
     // TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array.
@@ -6110,11 +6110,11 @@  discard block
 block discarded – undo
6110 6110
             if (preg_match('/functions_(.*)\.lib\.php/i', $substitfile['name'], $reg)) {
6111 6111
                 $module = $reg[1];
6112 6112
 
6113
-                dol_syslog("Library " . $substitfile['name'] . " found into " . $dir);
6113
+                dol_syslog("Library ".$substitfile['name']." found into ".$dir);
6114 6114
                 // Include the user's functions file
6115
-                require_once $dir . $substitfile['name'];
6115
+                require_once $dir.$substitfile['name'];
6116 6116
                 // Call the user's function, and only if it is defined
6117
-                $function_name = $module . "_" . $callfunc;
6117
+                $function_name = $module."_".$callfunc;
6118 6118
                 if (function_exists($function_name))
6119 6119
                     $function_name($substitutionarray, $outputlangs, $object, $parameters);
6120 6120
             }
@@ -6156,13 +6156,13 @@  discard block
 block discarded – undo
6156 6156
         $outputlangs = $langs;
6157 6157
 
6158 6158
     if ($date_start && $date_end) {
6159
-        $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
6159
+        $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
6160 6160
     }
6161 6161
     if ($date_start && !$date_end) {
6162
-        $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
6162
+        $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
6163 6163
     }
6164 6164
     if (!$date_start && $date_end) {
6165
-        $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
6165
+        $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
6166 6166
     }
6167 6167
 
6168 6168
     return $out;
@@ -6242,7 +6242,7 @@  discard block
 block discarded – undo
6242 6242
         dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
6243 6243
     } else {
6244 6244
         if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
6245
-            dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6245
+            dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages');
6246 6246
         if (empty($mesgs))
6247 6247
             setEventMessage($mesg, $style);
6248 6248
         else {
@@ -6311,7 +6311,7 @@  discard block
 block discarded – undo
6311 6311
 
6312 6312
     // If inline message with no format, we add it.
6313 6313
     if ((empty($conf->use_javascript_ajax) || !empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match('/<div class=".*">/i', $out)) {
6314
-        $divstart = '<div class="' . $style . ' clearboth">';
6314
+        $divstart = '<div class="'.$style.' clearboth">';
6315 6315
         $divend = '</div>';
6316 6316
     }
6317 6317
 
@@ -6338,14 +6338,14 @@  discard block
 block discarded – undo
6338 6338
         if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
6339 6339
             $return = '<script type="text/javascript">
6340 6340
 					$(document).ready(function() {
6341
-						var block = ' . (!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ? "true" : "false") . '
6341
+						var block = ' . (!empty($conf->global->MAIN_USE_JQUERY_BLOCKUI) ? "true" : "false").'
6342 6342
 						if (block) {
6343
-							$.dolEventValid("","' . dol_escape_js($out) . '");
6343
+							$.dolEventValid("","' . dol_escape_js($out).'");
6344 6344
 						} else {
6345 6345
 							/* jnotify(message, preset of message type, keepmessage) */
6346
-							$.jnotify("' . dol_escape_js($out) . '",
6347
-							"' . ($style == "ok" ? 3000 : $style) . '",
6348
-							' . ($style == "ok" ? "false" : "true") . ',
6346
+							$.jnotify("' . dol_escape_js($out).'",
6347
+							"' . ($style == "ok" ? 3000 : $style).'",
6348
+							' . ($style == "ok" ? "false" : "true").',
6349 6349
 							{ remove: function (){} } );
6350 6350
 						}
6351 6351
 					});
@@ -6540,11 +6540,11 @@  discard block
 block discarded – undo
6540 6540
 {
6541 6541
     global $conf;
6542 6542
 
6543
-    $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
6543
+    $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
6544 6544
     if (empty($tmp) && !empty($_SERVER["WINDIR"]))
6545 6545
         $tmp = 'iso-8859-1'; // By default for windows
6546 6546
     if (empty($tmp))
6547
-        $tmp = 'utf-8';          // By default for other
6547
+        $tmp = 'utf-8'; // By default for other
6548 6548
     if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING))
6549 6549
         $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
6550 6550
 
@@ -6576,16 +6576,16 @@  discard block
 block discarded – undo
6576 6576
 
6577 6577
     // Check in cache
6578 6578
     if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
6579
-        return $cache_codes[$tablename][$key][$fieldid];   // Found in cache
6579
+        return $cache_codes[$tablename][$key][$fieldid]; // Found in cache
6580 6580
     }
6581 6581
 
6582 6582
     dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG);
6583 6583
 
6584
-    $sql = "SELECT " . $fieldid . " as valuetoget";
6585
-    $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
6586
-    $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'";
6584
+    $sql = "SELECT ".$fieldid." as valuetoget";
6585
+    $sql .= " FROM ".MAIN_DB_PREFIX.$tablename;
6586
+    $sql .= " WHERE ".$fieldkey." = '".$db->escape($key)."'";
6587 6587
     if (!empty($entityfilter))
6588
-        $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6588
+        $sql .= " AND entity IN (".getEntity($tablename).")";
6589 6589
 
6590 6590
     $resql = $db->query($sql);
6591 6591
     if ($resql) {
@@ -6612,12 +6612,12 @@  discard block
 block discarded – undo
6612 6612
 {
6613 6613
     global $user, $conf, $langs;
6614 6614
     global $leftmenu;
6615
-    global $rights;    // To export to dol_eval function
6615
+    global $rights; // To export to dol_eval function
6616 6616
     //print $strRights."<br>\n";
6617 6617
     $rights = true;
6618 6618
     if ($strRights != '') {
6619
-        $str = 'if(!(' . $strRights . ')) { $rights = false; }';
6620
-        dol_eval($str);  // The dol_eval must contains all the global $xxx used into a condition
6619
+        $str = 'if(!('.$strRights.')) { $rights = false; }';
6620
+        dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition
6621 6621
     }
6622 6622
     return $rights;
6623 6623
 }
@@ -6640,14 +6640,14 @@  discard block
 block discarded – undo
6640 6640
     global $object;
6641 6641
     global $mysoc;
6642 6642
 
6643
-    global $obj;       // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object
6644
-    global $soc;       // For backward compatibility
6643
+    global $obj; // To get $obj used into list when dol_eval is used for computed fields and $obj is not yet $object
6644
+    global $soc; // For backward compatibility
6645 6645
     //print $s."<br>\n";
6646 6646
     if ($returnvalue) {
6647 6647
         if ($hideerrors)
6648
-            return @eval('return ' . $s . ';');
6648
+            return @eval('return '.$s.';');
6649 6649
         else
6650
-            return eval('return ' . $s . ';');
6650
+            return eval('return '.$s.';');
6651 6651
     }
6652 6652
     else {
6653 6653
         if ($hideerrors)
@@ -6701,7 +6701,7 @@  discard block
 block discarded – undo
6701 6701
         $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
6702 6702
     }
6703 6703
 
6704
-    return img_picto_common($codelang, 'flags/' . strtolower($flagImage) . '.png', $moreatt);
6704
+    return img_picto_common($codelang, 'flags/'.strtolower($flagImage).'.png', $moreatt);
6705 6705
 }
6706 6706
 
6707 6707
 /**
@@ -6899,16 +6899,16 @@  discard block
 block discarded – undo
6899 6899
         'zu-ZA',
6900 6900
     );
6901 6901
 
6902
-    $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode);
6902
+    $buildprimarykeytotest = strtolower($countrycode).'-'.strtoupper($countrycode);
6903 6903
     if (in_array($buildprimarykeytotest, $locales))
6904
-        return strtolower($countrycode) . '_' . strtoupper($countrycode);
6904
+        return strtolower($countrycode).'_'.strtoupper($countrycode);
6905 6905
 
6906 6906
     foreach ($locales as $locale) {
6907 6907
         $locale_language = locale_get_primary_language($locale);
6908 6908
         $locale_region = locale_get_region($locale);
6909 6909
         if (strtoupper($countrycode) == $locale_region) {
6910 6910
             //var_dump($locale.'-'.$locale_language.'-'.$locale_region);
6911
-            return strtolower($locale_language) . '_' . strtoupper($locale_region);
6911
+            return strtolower($locale_language).'_'.strtoupper($locale_region);
6912 6912
         }
6913 6913
     }
6914 6914
 
@@ -6969,7 +6969,7 @@  discard block
 block discarded – undo
6969 6969
                             $label = $langs->trans($values[2]);
6970 6970
 
6971 6971
                         //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
6972
-                        $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
6972
+                        $head[$h][0] = BASE_URI.preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
6973 6973
                         $head[$h][1] = $label;
6974 6974
                         $head[$h][2] = str_replace('+', '', $values[1]);
6975 6975
                         $h++;
@@ -7040,43 +7040,43 @@  discard block
 block discarded – undo
7040 7040
     global $micro_start_time;
7041 7041
 
7042 7042
     if ($zone == 'private')
7043
-        print "\n" . '<!-- Common footer for private page -->' . "\n";
7043
+        print "\n".'<!-- Common footer for private page -->'."\n";
7044 7044
     else
7045
-        print "\n" . '<!-- Common footer for public page -->' . "\n";
7045
+        print "\n".'<!-- Common footer for public page -->'."\n";
7046 7046
 
7047 7047
     // A div to store page_y POST parameter so we can read it using javascript
7048 7048
     print "\n<!-- A div to store page_y POST paramater -->\n";
7049
-    print '<div id="page_y" style="display: none;">' . $_POST['page_y'] . '</div>' . "\n";
7049
+    print '<div id="page_y" style="display: none;">'.$_POST['page_y'].'</div>'."\n";
7050 7050
 
7051 7051
     $parameters = array();
7052
-    $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);    // Note that $action and $object may have been modified by some hooks
7052
+    $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
7053 7053
     if (empty($reshook)) {
7054 7054
         if (!empty($conf->global->MAIN_HTML_FOOTER))
7055
-            print $conf->global->MAIN_HTML_FOOTER . "\n";
7055
+            print $conf->global->MAIN_HTML_FOOTER."\n";
7056 7056
 
7057 7057
         print "\n";
7058 7058
         if (!empty($conf->use_javascript_ajax)) {
7059
-            print '<script type="text/javascript" language="javascript">' . "\n";
7060
-            print 'jQuery(document).ready(function() {' . "\n";
7059
+            print '<script type="text/javascript" language="javascript">'."\n";
7060
+            print 'jQuery(document).ready(function() {'."\n";
7061 7061
 
7062 7062
             if ($zone == 'private' && empty($conf->dol_use_jmobile)) {
7063 7063
                 print "\n";
7064
-                print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */' . "\n";
7064
+                print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n";
7065 7065
                 print 'jQuery(".menuhider").click(function() {';
7066
-                print '  console.log("We click on .menuhider");' . "\n";
7066
+                print '  console.log("We click on .menuhider");'."\n";
7067 7067
                 //print "  $('.side-nav').animate({width:'toggle'},200);\n";     // OK with eldy theme but not with md
7068 7068
                 print "  $('.side-nav').toggle()\n";
7069 7069
                 print "  $('.login_block').toggle()\n";
7070
-                print '});' . "\n";
7070
+                print '});'."\n";
7071 7071
             }
7072 7072
 
7073 7073
             // Management of focus and mandatory for fields
7074 7074
             if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"])))) {
7075
-                print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n";
7075
+                print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n";
7076 7076
                 $relativepathstring = $_SERVER["PHP_SELF"];
7077 7077
                 // Clean $relativepathstring
7078 7078
                 if (constant('DOL_URL_ROOT'))
7079
-                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
7079
+                    $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'), '/').'/', '', $relativepathstring);
7080 7080
                 $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
7081 7081
                 $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
7082 7082
                 $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
@@ -7099,9 +7099,9 @@  discard block
 block discarded – undo
7099 7099
                         if ($qualified) {
7100 7100
                             foreach ($defval as $paramkey => $paramval) {
7101 7101
                                 // Set focus on field
7102
-                                print 'jQuery("input[name=\'' . $paramkey . '\']").focus();' . "\n";
7103
-                                print 'jQuery("textarea[name=\'' . $paramkey . '\']").focus();' . "\n";
7104
-                                print 'jQuery("select[name=\'' . $paramkey . '\']").focus();' . "\n";  // Not really usefull, but we keep it in case of.
7102
+                                print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n";
7103
+                                print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n";
7104
+                                print 'jQuery("select[name=\''.$paramkey.'\']").focus();'."\n"; // Not really usefull, but we keep it in case of.
7105 7105
                             }
7106 7106
                         }
7107 7107
                     }
@@ -7125,16 +7125,16 @@  discard block
 block discarded – undo
7125 7125
                         if ($qualified) {
7126 7126
                             foreach ($defval as $paramkey => $paramval) {
7127 7127
                                 // Add property 'required' on input
7128
-                                print 'jQuery("input[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";
7129
-                                print 'jQuery("textarea[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";
7130
-                                print 'jQuery("select[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";  // required on a select works only if key is "", this does not happen in Dolibarr
7128
+                                print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
7129
+                                print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
7130
+                                print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr
7131 7131
                             }
7132 7132
                         }
7133 7133
                     }
7134 7134
                 }
7135 7135
             }
7136 7136
 
7137
-            print '});' . "\n";
7137
+            print '});'."\n";
7138 7138
 
7139 7139
             // Google Analytics
7140 7140
             // TODO Add a hook here
@@ -7142,15 +7142,15 @@  discard block
 block discarded – undo
7142 7142
                 if (($conf->dol_use_jmobile != 4)) {
7143 7143
                     print "\n";
7144 7144
                     print "/* JS CODE TO ENABLE for google analtics tag */\n";
7145
-                    print '  var _gaq = _gaq || [];' . "\n";
7146
-                    print '  _gaq.push([\'_setAccount\', \'' . $conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n";
7147
-                    print '  _gaq.push([\'_trackPageview\']);' . "\n";
7148
-                    print '' . "\n";
7149
-                    print '  (function() {' . "\n";
7150
-                    print '    var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n";
7151
-                    print '    ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n";
7152
-                    print '    var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n";
7153
-                    print '  })();' . "\n";
7145
+                    print '  var _gaq = _gaq || [];'."\n";
7146
+                    print '  _gaq.push([\'_setAccount\', \''.$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n";
7147
+                    print '  _gaq.push([\'_trackPageview\']);'."\n";
7148
+                    print ''."\n";
7149
+                    print '  (function() {'."\n";
7150
+                    print '    var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n";
7151
+                    print '    ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n";
7152
+                    print '    var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n";
7153
+                    print '  })();'."\n";
7154 7154
                 }
7155 7155
             }
7156 7156
 
@@ -7160,27 +7160,27 @@  discard block
 block discarded – undo
7160 7160
                 print "/* JS CODE TO ENABLE to add memory info */\n";
7161 7161
                 print 'window.console && console.log("';
7162 7162
                 if (!empty($conf->global->MEMCACHED_SERVER))
7163
-                    print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
7164
-                print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7163
+                    print 'MEMCACHED_SERVER='.$conf->global->MEMCACHED_SERVER.' - ';
7164
+                print 'MAIN_OPTIMIZE_SPEED='.(isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7165 7165
                 if (!empty($micro_start_time)) {   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
7166 7166
                     $micro_end_time = microtime(true);
7167
-                    print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
7167
+                    print ' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms';
7168 7168
                 }
7169 7169
                 if (function_exists("memory_get_usage")) {
7170
-                    print ' - Mem: ' . memory_get_usage();
7170
+                    print ' - Mem: '.memory_get_usage();
7171 7171
                 }
7172 7172
                 if (function_exists("xdebug_memory_usage")) {
7173
-                    print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
7174
-                    print ' - XDebug mem: ' . xdebug_memory_usage();
7175
-                    print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
7173
+                    print ' - XDebug time: '.ceil(1000 * xdebug_time_index()).' ms';
7174
+                    print ' - XDebug mem: '.xdebug_memory_usage();
7175
+                    print ' - XDebug mem peak: '.xdebug_peak_memory_usage();
7176 7176
                 }
7177 7177
                 if (function_exists("zend_loader_file_encoded")) {
7178
-                    print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
7178
+                    print ' - Zend encoded file: '.(zend_loader_file_encoded() ? 'yes' : 'no');
7179 7179
                 }
7180
-                print '");' . "\n";
7180
+                print '");'."\n";
7181 7181
             }
7182 7182
 
7183
-            print "\n" . '</script>' . "\n";
7183
+            print "\n".'</script>'."\n";
7184 7184
         }
7185 7185
 
7186 7186
         // Add Xdebug coverage of code
@@ -7194,7 +7194,7 @@  discard block
 block discarded – undo
7194 7194
             print "<!-- Start of log output\n";
7195 7195
             //print '<div class="hidden">'."\n";
7196 7196
             foreach ($conf->logbuffer as $logline) {
7197
-                print $logline . "<br>\n";
7197
+                print $logline."<br>\n";
7198 7198
             }
7199 7199
             //print '</div>'."\n";
7200 7200
             print "End of log output -->\n";
@@ -7237,8 +7237,8 @@  discard block
 block discarded – undo
7237 7237
  */
7238 7238
 function dol_set_focus($selector)
7239 7239
 {
7240
-    print "\n" . '<!-- Set focus onto a specific field -->' . "\n";
7241
-    print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("' . dol_escape_js($selector) . '").focus(); });</script>' . "\n";
7240
+    print "\n".'<!-- Set focus onto a specific field -->'."\n";
7241
+    print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n";
7242 7242
 }
7243 7243
 
7244 7244
 /**
@@ -7283,7 +7283,7 @@  discard block
 block discarded – undo
7283 7283
         $value = preg_replace('/\*/', '%', $value); // Replace * with %
7284 7284
     }
7285 7285
     if ($mode == 1) {
7286
-        $value = preg_replace('/([<>=]+)\s+([0-9' . preg_quote($langs->trans("DecimalSeparator"), '/') . '\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
7286
+        $value = preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
7287 7287
     }
7288 7288
 
7289 7289
     $value = preg_replace('/\s*\|\s*/', '|', $value);
@@ -7312,14 +7312,14 @@  discard block
 block discarded – undo
7312 7312
                 if ($newcrit != '') {
7313 7313
                     $numnewcrit = price2num($newcrit);
7314 7314
                     if (is_numeric($numnewcrit)) {
7315
-                        $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' ' . $operator . ' ' . $numnewcrit;
7315
+                        $newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.$numnewcrit;
7316 7316
                     } else {
7317
-                        $newres .= ($i2 > 0 ? ' OR ' : '') . '1 = 2'; // force false
7317
+                        $newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false
7318 7318
                     }
7319 7319
                     $i2++; // a criteria was added to string
7320 7320
                 }
7321 7321
             } else if ($mode == 2) {
7322
-                $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")";
7322
+                $newres .= ($i2 > 0 ? ' OR ' : '').$field." IN (".$db->escape(trim($crit)).")";
7323 7323
                 $i2++; // a criteria was added to string
7324 7324
             } else if ($mode == 3) {
7325 7325
                 $tmparray = explode(',', trim($crit));
@@ -7328,10 +7328,10 @@  discard block
 block discarded – undo
7328 7328
                     foreach ($tmparray as $val) {
7329 7329
                         if ($val) {
7330 7330
                             $listofcodes .= ($listofcodes ? ',' : '');
7331
-                            $listofcodes .= "'" . $db->escape(trim($val)) . "'";
7331
+                            $listofcodes .= "'".$db->escape(trim($val))."'";
7332 7332
                         }
7333 7333
                     }
7334
-                    $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")";
7334
+                    $newres .= ($i2 > 0 ? ' OR ' : '').$field." IN (".$listofcodes.")";
7335 7335
                     $i2++; // a criteria was added to string
7336 7336
                 }
7337 7337
             } else if ($mode == 4) {
@@ -7340,10 +7340,10 @@  discard block
 block discarded – undo
7340 7340
                     $listofcodes = '';
7341 7341
                     foreach ($tmparray as $val) {
7342 7342
                         if ($val) {
7343
-                            $newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\'';
7344
-                            $newres .= ' OR ' . $field . ' = \'' . $db->escape(trim($val)) . '\'';
7345
-                            $newres .= ' OR ' . $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\'';
7346
-                            $newres .= ' OR ' . $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\'';
7343
+                            $newres .= ($i2 > 0 ? ' OR (' : '(').$field.' LIKE \''.$db->escape(trim($val)).',%\'';
7344
+                            $newres .= ' OR '.$field.' = \''.$db->escape(trim($val)).'\'';
7345
+                            $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).'\'';
7346
+                            $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).',%\'';
7347 7347
                             $newres .= ')';
7348 7348
                             $i2++;
7349 7349
                         }
@@ -7360,9 +7360,9 @@  discard block
 block discarded – undo
7360 7360
                     $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
7361 7361
 
7362 7362
                     if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
7363
-                        $newres .= $field . " = " . (is_numeric(trim($tmpcrit)) ? trim($tmpcrit) : '0');
7363
+                        $newres .= $field." = ".(is_numeric(trim($tmpcrit)) ? trim($tmpcrit) : '0');
7364 7364
                     } else {
7365
-                        $newres .= $field . " LIKE '";
7365
+                        $newres .= $field." LIKE '";
7366 7366
 
7367 7367
                         $tmpcrit = trim($tmpcrit);
7368 7368
                         $tmpcrit2 = $tmpcrit;
@@ -7381,7 +7381,7 @@  discard block
 block discarded – undo
7381 7381
                         $newres .= $tmpafter;
7382 7382
                         $newres .= "'";
7383 7383
                         if ($tmpcrit2 == '') {
7384
-                            $newres .= ' OR ' . $field . " IS NULL";
7384
+                            $newres .= ' OR '.$field." IS NULL";
7385 7385
                         }
7386 7386
                     }
7387 7387
 
@@ -7392,10 +7392,10 @@  discard block
 block discarded – undo
7392 7392
             $i++;
7393 7393
         }
7394 7394
         if ($newres)
7395
-            $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7395
+            $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : '');
7396 7396
         $j++;
7397 7397
     }
7398
-    $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
7398
+    $res = ($nofirstand ? "" : " AND ")."(".$res.")";
7399 7399
     //print 'xx'.$res.'yy';
7400 7400
     return $res;
7401 7401
 }
@@ -7414,8 +7414,8 @@  discard block
 block discarded – undo
7414 7414
     $url = $object->getLastMainDocLink($object->element);
7415 7415
 
7416 7416
     if ($url) {
7417
-        $out .= img_picto('', 'object_globe.png') . ' ' . $langs->trans("DirectDownloadLink") . '<br>';
7418
-        $out .= '<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="' . $url . '">';
7417
+        $out .= img_picto('', 'object_globe.png').' '.$langs->trans("DirectDownloadLink").'<br>';
7418
+        $out .= '<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.'">';
7419 7419
         $out .= ajax_autoselect("directdownloadlink", 0);
7420 7420
     }
7421 7421
     return $out;
@@ -7456,7 +7456,7 @@  discard block
 block discarded – undo
7456 7456
     if ($extName)
7457 7457
         $subdir = 'thumbs/';
7458 7458
 
7459
-    return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb
7459
+    return ($dirName ? $dirName.'/' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
7460 7460
 }
7461 7461
 
7462 7462
 /**
@@ -7482,14 +7482,14 @@  discard block
 block discarded – undo
7482 7482
 
7483 7483
     if ($alldata == 1) {
7484 7484
         if ($num_mime !== false)
7485
-            return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
7485
+            return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime' => dol_mimetype($relativepath),);
7486 7486
         else
7487 7487
             return array();
7488 7488
     }
7489 7489
 
7490 7490
     // old behavior
7491 7491
     if ($num_mime !== false)
7492
-        return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
7492
+        return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')';
7493 7493
     else
7494 7494
         return '';
7495 7495
 }
@@ -7506,11 +7506,11 @@  discard block
 block discarded – undo
7506 7506
     global $langs;
7507 7507
     $out = '<script type="text/javascript">
7508 7508
                jQuery(document).ready(function () {
7509
-				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
7509
+				    jQuery("#' . $htmlname.'").click(function() { jQuery(this).select(); } );
7510 7510
 				});
7511 7511
 		    </script>';
7512 7512
     if ($addlink)
7513
-        $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
7513
+        $out .= ' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
7514 7514
     return $out;
7515 7515
 }
7516 7516
 
@@ -7891,9 +7891,9 @@  discard block
 block discarded – undo
7891 7891
 
7892 7892
     if (!isset($dictvalues[$tablename])) {
7893 7893
         $dictvalues[$tablename] = array();
7894
-        $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1';
7894
+        $sql = 'SELECT * FROM '.$tablename.' WHERE 1';
7895 7895
         if ($checkentity)
7896
-            $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
7896
+            $sql .= ' AND entity IN (0,'.getEntity($tablename).')';
7897 7897
 
7898 7898
         $resql = $db->query($sql);
7899 7899
         if ($resql) {
@@ -7931,14 +7931,14 @@  discard block
 block discarded – undo
7931 7931
             $g = $tmp[1];
7932 7932
             $b = $tmp[2];
7933 7933
         } else {
7934
-            $hexr = $stringcolor[0] . $stringcolor[1];
7935
-            $hexg = $stringcolor[2] . $stringcolor[3];
7936
-            $hexb = $stringcolor[4] . $stringcolor[5];
7934
+            $hexr = $stringcolor[0].$stringcolor[1];
7935
+            $hexg = $stringcolor[2].$stringcolor[3];
7936
+            $hexb = $stringcolor[4].$stringcolor[5];
7937 7937
             $r = hexdec($hexr);
7938 7938
             $g = hexdec($hexg);
7939 7939
             $b = hexdec($hexb);
7940 7940
         }
7941
-        $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;    // HSL algorithm
7941
+        $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
7942 7942
         if ($bright > 0.6)
7943 7943
             $res = 1;
7944 7944
     }
@@ -7974,11 +7974,11 @@  discard block
 block discarded – undo
7974 7974
             return 0; // Entry is for menus all excluded to external users
7975 7975
     }
7976 7976
     if (!$menuentry['perms'] && $type_user)
7977
-        return 0;            // No permissions and user is external
7977
+        return 0; // No permissions and user is external
7978 7978
     if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
7979 7979
         return 0; // No permissions and option to hide when not allowed, even for internal user, is on
7980 7980
     if (!$menuentry['perms'])
7981
-        return 2;               // No permissions and user is external
7981
+        return 2; // No permissions and user is external
7982 7982
     return 1;
7983 7983
 }
7984 7984
 
Please login to merge, or discard this patch.
Braces   +1455 added lines, -1043 removed lines patch added patch discarded remove patch
@@ -79,8 +79,9 @@  discard block
 block discarded – undo
79 79
       if ($found) return $result;
80 80
       } */
81 81
 
82
-    if (isset($class::$member))
83
-        return $class::$member;
82
+    if (isset($class::$member)) {
83
+            return $class::$member;
84
+    }
84 85
     dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
85 86
     return null;
86 87
 }
@@ -131,8 +132,9 @@  discard block
 block discarded – undo
131 132
     } else {
132 133
         $out = '';
133 134
         $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values');
134
-        if (in_array($element, $addzero))
135
-            $out .= '0,';
135
+        if (in_array($element, $addzero)) {
136
+                    $out .= '0,';
137
+        }
136 138
         $out .= $conf->entity;
137 139
         return $out;
138 140
     }
@@ -313,32 +315,35 @@  discard block
 block discarded – undo
313 315
 
314 316
     Debug::addMessage('Deprecated', 'Using GETPOST of functions.lib.php instead of Request library');
315 317
 
316
-    if (empty($paramname))
317
-        return 'BadFirstParameterForGETPOST';
318
+    if (empty($paramname)) {
319
+            return 'BadFirstParameterForGETPOST';
320
+    }
318 321
     if (empty($check)) {
319 322
         dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
320 323
         // Enable this line to know who call the GETPOST with '' $check parameter.
321 324
         //var_dump(debug_backtrace()[0]);
322 325
     }
323 326
 
324
-    if (empty($method))
325
-        $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : '');
326
-    elseif ($method == 1)
327
-        $out = isset($_GET[$paramname]) ? $_GET[$paramname] : '';
328
-    elseif ($method == 2)
329
-        $out = isset($_POST[$paramname]) ? $_POST[$paramname] : '';
330
-    elseif ($method == 3)
331
-        $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : '');
332
-    elseif ($method == 4)
333
-        $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : ''));
334
-    else
335
-        return 'BadThirdParameterForGETPOST';
327
+    if (empty($method)) {
328
+            $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : '');
329
+    } elseif ($method == 1) {
330
+            $out = isset($_GET[$paramname]) ? $_GET[$paramname] : '';
331
+    } elseif ($method == 2) {
332
+            $out = isset($_POST[$paramname]) ? $_POST[$paramname] : '';
333
+    } elseif ($method == 3) {
334
+            $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : '');
335
+    } elseif ($method == 4) {
336
+            $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : ''));
337
+    } else {
338
+            return 'BadThirdParameterForGETPOST';
339
+    }
336 340
 
337 341
     if (empty($method) || $method == 3 || $method == 4) {
338 342
         $relativepathstring = $_SERVER["PHP_SELF"];
339 343
         // Clean $relativepathstring
340
-        if (constant('DOL_URL_ROOT'))
341
-            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
344
+        if (constant('DOL_URL_ROOT')) {
345
+                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
346
+        }
342 347
         $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
343 348
         $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
344 349
         //var_dump($relativepathstring);
@@ -387,14 +392,17 @@  discard block
 block discarded – undo
387 392
                                     $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
388 393
                                     $foundintru = 0;
389 394
                                     foreach ($tmpqueryarraytohave as $tmpquerytohave) {
390
-                                        if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
391
-                                            $foundintru = 1;
395
+                                        if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
396
+                                                                                    $foundintru = 1;
397
+                                        }
398
+                                    }
399
+                                    if (!$foundintru) {
400
+                                                                            $qualified = 1;
392 401
                                     }
393
-                                    if (!$foundintru)
394
-                                        $qualified = 1;
395 402
                                     //var_dump($defkey.'-'.$qualified);
396
-                                } else
397
-                                    $qualified = 1;
403
+                                } else {
404
+                                                                    $qualified = 1;
405
+                                }
398 406
 
399 407
                                 if ($qualified) {
400 408
                                     //var_dump($user->default_values[$relativepathstring][$defkey]['createform']);
@@ -421,20 +429,24 @@  discard block
 block discarded – undo
421 429
                                         $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
422 430
                                         $foundintru = 0;
423 431
                                         foreach ($tmpqueryarraytohave as $tmpquerytohave) {
424
-                                            if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
425
-                                                $foundintru = 1;
432
+                                            if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
433
+                                                                                            $foundintru = 1;
434
+                                            }
435
+                                        }
436
+                                        if (!$foundintru) {
437
+                                                                                    $qualified = 1;
426 438
                                         }
427
-                                        if (!$foundintru)
428
-                                            $qualified = 1;
429 439
                                         //var_dump($defkey.'-'.$qualified);
430
-                                    } else
431
-                                        $qualified = 1;
440
+                                    } else {
441
+                                                                            $qualified = 1;
442
+                                    }
432 443
 
433 444
                                     if ($qualified) {
434 445
                                         $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
435 446
                                         foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
436
-                                            if ($out)
437
-                                                $out .= ', ';
447
+                                            if ($out) {
448
+                                                                                            $out .= ', ';
449
+                                            }
438 450
                                             if ($paramname == 'sortfield') {
439 451
                                                 $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace);
440 452
                                             }
@@ -454,14 +466,17 @@  discard block
 block discarded – undo
454 466
                                     $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
455 467
                                     $foundintru = 0;
456 468
                                     foreach ($tmpqueryarraytohave as $tmpquerytohave) {
457
-                                        if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
458
-                                            $foundintru = 1;
469
+                                        if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
470
+                                                                                    $foundintru = 1;
471
+                                        }
472
+                                    }
473
+                                    if (!$foundintru) {
474
+                                                                            $qualified = 1;
459 475
                                     }
460
-                                    if (!$foundintru)
461
-                                        $qualified = 1;
462 476
                                     //var_dump($defkey.'-'.$qualified);
463
-                                } else
464
-                                    $qualified = 1;
477
+                                } else {
478
+                                                                    $qualified = 1;
479
+                                }
465 480
 
466 481
                                 if ($qualified) {
467 482
                                     if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
@@ -533,8 +548,10 @@  discard block
 block discarded – undo
533 548
                 $newout = $user->fk_user;
534 549
             } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
535 550
                 $newout = $conf->entity;
536
-            } else
537
-                $newout = '';     // Key not found, we replace with empty string
551
+            } else {
552
+                            $newout = '';
553
+            }
554
+            // Key not found, we replace with empty string
538 555
 
539 556
 
540 557
 
@@ -575,18 +592,20 @@  discard block
 block discarded – undo
575 592
             }
576 593
             break;
577 594
         case 'intcomma':
578
-            if (preg_match('/[^0-9,-]+/i', $out))
579
-                $out = '';
595
+            if (preg_match('/[^0-9,-]+/i', $out)) {
596
+                            $out = '';
597
+            }
580 598
             break;
581 599
         case 'alpha':
582 600
             if (!is_array($out)) {
583 601
                 $out = trim($out);
584 602
                 // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
585 603
                 // '../' is dangerous because it allows dir transversals
586
-                if (preg_match('/"/', $out))
587
-                    $out = '';
588
-                else if (preg_match('/\.\.\//', $out))
589
-                    $out = '';
604
+                if (preg_match('/"/', $out)) {
605
+                                    $out = '';
606
+                } else if (preg_match('/\.\.\//', $out)) {
607
+                                    $out = '';
608
+                }
590 609
             }
591 610
             break;
592 611
         case 'san_alpha':
@@ -595,27 +614,31 @@  discard block
 block discarded – undo
595 614
         case 'aZ':
596 615
             if (!is_array($out)) {
597 616
                 $out = trim($out);
598
-                if (preg_match('/[^a-z]+/i', $out))
599
-                    $out = '';
617
+                if (preg_match('/[^a-z]+/i', $out)) {
618
+                                    $out = '';
619
+                }
600 620
             }
601 621
             break;
602 622
         case 'aZ09':
603 623
             if (!is_array($out)) {
604 624
                 $out = trim($out);
605
-                if (preg_match('/[^a-z0-9_\-\.]+/i', $out))
606
-                    $out = '';
625
+                if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) {
626
+                                    $out = '';
627
+                }
607 628
             }
608 629
             break;
609 630
         case 'aZ09comma':  // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh
610 631
             if (!is_array($out)) {
611 632
                 $out = trim($out);
612
-                if (preg_match('/[^a-z0-9_\-\.,]+/i', $out))
613
-                    $out = '';
633
+                if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) {
634
+                                    $out = '';
635
+                }
614 636
             }
615 637
             break;
616 638
         case 'array':
617
-            if (!is_array($out) || empty($out))
618
-                $out = array();
639
+            if (!is_array($out) || empty($out)) {
640
+                            $out = array();
641
+            }
619 642
             break;
620 643
         case 'nohtml':  // Recommended for most scalar parameters
621 644
             $out = dol_string_nohtmltag($out, 0);
@@ -625,16 +648,18 @@  discard block
 block discarded – undo
625 648
                 $out = trim($out);
626 649
                 // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
627 650
                 // '../' is dangerous because it allows dir transversals
628
-                if (preg_match('/"/', $out))
629
-                    $out = '';
630
-                else if (preg_match('/\.\.\//', $out))
631
-                    $out = '';
651
+                if (preg_match('/"/', $out)) {
652
+                                    $out = '';
653
+                } else if (preg_match('/\.\.\//', $out)) {
654
+                                    $out = '';
655
+                }
632 656
                 $out = dol_string_nohtmltag($out);
633 657
             }
634 658
             break;
635 659
         case 'custom':
636
-            if (empty($filter))
637
-                return 'BadFourthParameterForGETPOST';
660
+            if (empty($filter)) {
661
+                            return 'BadFourthParameterForGETPOST';
662
+            }
638 663
             $out = filter_var($out, $filter, $options);
639 664
             break;
640 665
     }
@@ -674,10 +699,11 @@  discard block
 block discarded – undo
674 699
         // If prefix is for email
675 700
         if ($mode == 'email') {
676 701
             if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended)
677
-                if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME')
678
-                    return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
679
-                else if (isset($_SERVER["SERVER_NAME"]))
680
-                    return $_SERVER["SERVER_NAME"];
702
+                if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') {
703
+                                    return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
704
+                } else if (isset($_SERVER["SERVER_NAME"])) {
705
+                                    return $_SERVER["SERVER_NAME"];
706
+                }
681 707
             }
682 708
             return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT);
683 709
         }
@@ -750,22 +776,27 @@  discard block
 block discarded – undo
750 776
             }
751 777
         }
752 778
         if ($returnemptyifnotfound) {        // Not found into alternate dir
753
-            if ($returnemptyifnotfound == 1 || !file_exists($res))
754
-                return '';
779
+            if ($returnemptyifnotfound == 1 || !file_exists($res)) {
780
+                            return '';
781
+            }
755 782
         }
756
-    }
757
-    else {    // For an url path
783
+    } else {    // For an url path
758 784
         // We try to get local path of file on filesystem from url
759 785
         // Note that trying to know if a file on disk exist by forging path on disk from url
760 786
         // works only for some web server and some setup. This is bugged when
761 787
         // using proxy, rewriting, virtual path, etc...
762 788
         $res = '';
763
-        if ($type == 1)
764
-            $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path;   // Standard value
765
-        if ($type == 2)
766
-            $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path;  // Standard value
767
-        if ($type == 3)
768
-            $res = DOL_URL_ROOT . '/' . $path;
789
+        if ($type == 1) {
790
+                    $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path;
791
+        }
792
+        // Standard value
793
+        if ($type == 2) {
794
+                    $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path;
795
+        }
796
+        // Standard value
797
+        if ($type == 3) {
798
+                    $res = DOL_URL_ROOT . '/' . $path;
799
+        }
769 800
 
770 801
         foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
771 802
             if ($key == 'main') {
@@ -845,13 +876,15 @@  discard block
 block discarded – undo
845 876
 function dol_size($size, $type = '')
846 877
 {
847 878
     global $conf;
848
-    if (empty($conf->dol_optimize_smallscreen))
849
-        return $size;
850
-    if ($type == 'width' && $size > 250)
851
-        return 250;
852
-    else
853
-        return 10;
854
-}
879
+    if (empty($conf->dol_optimize_smallscreen)) {
880
+            return $size;
881
+    }
882
+    if ($type == 'width' && $size > 250) {
883
+            return 250;
884
+    } else {
885
+            return 10;
886
+    }
887
+    }
855 888
 
856 889
 /**
857 890
  * 	Clean a string to use it as a file name
@@ -950,8 +983,9 @@  discard block
 block discarded – undo
950 983
 {
951 984
     $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°');  // more complete than dol_sanitizeFileName
952 985
     $forbidden_chars_to_remove = array();
953
-    if (is_array($badcharstoreplace))
954
-        $forbidden_chars_to_replace = $badcharstoreplace;
986
+    if (is_array($badcharstoreplace)) {
987
+            $forbidden_chars_to_replace = $badcharstoreplace;
988
+    }
955 989
     //$forbidden_chars_to_remove=array("(",")");
956 990
 
957 991
     return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str));
@@ -988,9 +1022,9 @@  discard block
 block discarded – undo
988 1022
     if (empty($mode)) {
989 1023
         $substitjs["'"] = "\\'";
990 1024
         $substitjs['"'] = "\\'";
991
-    } else if ($mode == 1)
992
-        $substitjs["'"] = "\\'";
993
-    else if ($mode == 2) {
1025
+    } else if ($mode == 1) {
1026
+            $substitjs["'"] = "\\'";
1027
+    } else if ($mode == 2) {
994 1028
         $substitjs['"'] = '\\"';
995 1029
     } else if ($mode == 3) {
996 1030
         $substitjs["'"] = "\\'";
@@ -1012,10 +1046,12 @@  discard block
 block discarded – undo
1012 1046
 {
1013 1047
     // escape quotes and backslashes, newlines, etc.
1014 1048
     $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8');  // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1015
-    if (!$keepb)
1016
-        $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1017
-    if (!$keepn)
1018
-        $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1049
+    if (!$keepb) {
1050
+            $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1051
+    }
1052
+    if (!$keepn) {
1053
+            $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1054
+    }
1019 1055
     return htmlentities($tmp, ENT_COMPAT, 'UTF-8');      // TODO Use htmlspecialchars instead, that make only required change for html tags
1020 1056
 }
1021 1057
 
@@ -1066,8 +1102,9 @@  discard block
 block discarded – undo
1066 1102
     global $conf, $user;
1067 1103
 
1068 1104
     // If syslog module enabled
1069
-    if (empty($conf->syslog->enabled))
1070
-        return;
1105
+    if (empty($conf->syslog->enabled)) {
1106
+            return;
1107
+    }
1071 1108
 
1072 1109
     if ($ident < 0) {
1073 1110
         foreach ($conf->loghandlers as $loghandlerinstance) {
@@ -1081,8 +1118,9 @@  discard block
 block discarded – undo
1081 1118
         if (!in_array($level, $logLevels, true)) {
1082 1119
             throw new Exception('Incorrect log level');
1083 1120
         }
1084
-        if ($level > $conf->global->SYSLOG_LEVEL)
1085
-            return;
1121
+        if ($level > $conf->global->SYSLOG_LEVEL) {
1122
+                    return;
1123
+        }
1086 1124
 
1087 1125
         $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
1088 1126
         // If adding log inside HTML page is required
@@ -1107,24 +1145,30 @@  discard block
 block discarded – undo
1107 1145
         );
1108 1146
 
1109 1147
         // This is when server run behind a reverse proxy
1110
-        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
1111
-            $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1148
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
1149
+                    $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1150
+        }
1112 1151
         // This is when server run normally on a server
1113
-        else if (!empty($_SERVER["REMOTE_ADDR"]))
1114
-            $data['ip'] = $_SERVER['REMOTE_ADDR'];
1152
+        else if (!empty($_SERVER["REMOTE_ADDR"])) {
1153
+                    $data['ip'] = $_SERVER['REMOTE_ADDR'];
1154
+        }
1115 1155
         // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
1116
-        else if (!empty($_SERVER['SERVER_ADDR']))
1117
-            $data['ip'] = $_SERVER['SERVER_ADDR'];
1156
+        else if (!empty($_SERVER['SERVER_ADDR'])) {
1157
+                    $data['ip'] = $_SERVER['SERVER_ADDR'];
1158
+        }
1118 1159
         // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
1119
-        else if (!empty($_SERVER['COMPUTERNAME']))
1120
-            $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1160
+        else if (!empty($_SERVER['COMPUTERNAME'])) {
1161
+                    $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1162
+        }
1121 1163
         // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
1122
-        else if (!empty($_SERVER['LOGNAME']))
1123
-            $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1164
+        else if (!empty($_SERVER['LOGNAME'])) {
1165
+                    $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1166
+        }
1124 1167
         // Loop on each log handler and send output
1125 1168
         foreach ($conf->loghandlers as $loghandlerinstance) {
1126
-            if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler)
1127
-                continue;
1169
+            if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1170
+                            continue;
1171
+            }
1128 1172
             $loghandlerinstance->export($data, $suffixinfilename);
1129 1173
         }
1130 1174
         unset($data);
@@ -1180,13 +1224,15 @@  discard block
 block discarded – undo
1180 1224
 
1181 1225
     // Show title
1182 1226
     $showtitle = 1;
1183
-    if (!empty($conf->dol_optimize_smallscreen))
1184
-        $showtitle = 0;
1227
+    if (!empty($conf->dol_optimize_smallscreen)) {
1228
+            $showtitle = 0;
1229
+    }
1185 1230
     if (!empty($title) && $showtitle) {
1186 1231
         $limittitle = 30;
1187 1232
         $out .= '<a class="tabTitle">';
1188
-        if ($picto)
1189
-            $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1233
+        if ($picto) {
1234
+                    $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1235
+        }
1190 1236
         $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>';
1191 1237
         $out .= '</a>';
1192 1238
     }
@@ -1195,12 +1241,14 @@  discard block
 block discarded – undo
1195 1241
     $maxkey = -1;
1196 1242
     if (is_array($links) && !empty($links)) {
1197 1243
         $keys = array_keys($links);
1198
-        if (count($keys))
1199
-            $maxkey = max($keys);
1244
+        if (count($keys)) {
1245
+                    $maxkey = max($keys);
1246
+        }
1200 1247
     }
1201 1248
 
1202
-    if (!empty($conf->dol_optimize_smallscreen))
1203
-        $conf->global->MAIN_MAXTABS_IN_CARD = 2;
1249
+    if (!empty($conf->dol_optimize_smallscreen)) {
1250
+            $conf->global->MAIN_MAXTABS_IN_CARD = 2;
1251
+    }
1204 1252
 
1205 1253
     // Show tabs
1206 1254
     $bactive = false;
@@ -1213,8 +1261,9 @@  discard block
 block discarded – undo
1213 1261
     for ($i = 0; $i <= $maxkey; $i++) {
1214 1262
         if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1215 1263
             // If active tab is already present
1216
-            if ($i >= $limittoshow)
1217
-                $limittoshow--;
1264
+            if ($i >= $limittoshow) {
1265
+                            $limittoshow--;
1266
+            }
1218 1267
         }
1219 1268
     }
1220 1269
 
@@ -1255,12 +1304,12 @@  discard block
 block discarded – undo
1255 1304
             }
1256 1305
             $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">';
1257 1306
             if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1258
-                if (!empty($links[$i][0]))
1259
-                    $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1260
-                else
1261
-                    $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1262
-            }
1263
-            else if (!empty($links[$i][1])) {
1307
+                if (!empty($links[$i][0])) {
1308
+                                    $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1309
+                } else {
1310
+                                    $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1311
+                }
1312
+            } else if (!empty($links[$i][1])) {
1264 1313
                 $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1265 1314
                 $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
1266 1315
                 $outmore .= '</a>' . "\n";
@@ -1271,8 +1320,9 @@  discard block
 block discarded – undo
1271 1320
         }
1272 1321
         $displaytab = $i;
1273 1322
     }
1274
-    if ($popuptab)
1275
-        $outmore .= '</div>';
1323
+    if ($popuptab) {
1324
+            $outmore .= '</div>';
1325
+    }
1276 1326
 
1277 1327
     if ($displaytab > $limittoshow) {
1278 1328
         $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
@@ -1295,8 +1345,9 @@  discard block
 block discarded – undo
1295 1345
 
1296 1346
     $out .= "</div>\n";
1297 1347
 
1298
-    if (!$notab || $notab == -1)
1299
-        $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1348
+    if (!$notab || $notab == -1) {
1349
+            $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1350
+    }
1300 1351
 
1301 1352
     $parameters = array('tabname' => $active, 'out' => $out);
1302 1353
     $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
@@ -1326,11 +1377,12 @@  discard block
 block discarded – undo
1326 1377
  */
1327 1378
 function dol_get_fiche_end($notab = 0)
1328 1379
 {
1329
-    if (!$notab || $notab == -1)
1330
-        return "\n</div>\n";
1331
-    else
1332
-        return '';
1333
-}
1380
+    if (!$notab || $notab == -1) {
1381
+            return "\n</div>\n";
1382
+    } else {
1383
+            return '';
1384
+    }
1385
+    }
1334 1386
 
1335 1387
 /**
1336 1388
  *  Show tab footer of a card.
@@ -1361,40 +1413,55 @@  discard block
 block discarded – undo
1361 1413
     $showimage = 1;
1362 1414
     $entity = (empty($object->entity) ? $conf->entity : $object->entity);
1363 1415
     $showbarcode = empty($conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0);
1364
-    if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance))
1365
-        $showbarcode = 0;
1416
+    if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1417
+            $showbarcode = 0;
1418
+    }
1366 1419
     $modulepart = 'unknown';
1367 1420
 
1368
-    if ($object->element == 'societe')
1369
-        $modulepart = 'societe';
1370
-    if ($object->element == 'contact')
1371
-        $modulepart = 'contact';
1372
-    if ($object->element == 'member')
1373
-        $modulepart = 'memberphoto';
1374
-    if ($object->element == 'user')
1375
-        $modulepart = 'userphoto';
1376
-    if ($object->element == 'product')
1377
-        $modulepart = 'product';
1421
+    if ($object->element == 'societe') {
1422
+            $modulepart = 'societe';
1423
+    }
1424
+    if ($object->element == 'contact') {
1425
+            $modulepart = 'contact';
1426
+    }
1427
+    if ($object->element == 'member') {
1428
+            $modulepart = 'memberphoto';
1429
+    }
1430
+    if ($object->element == 'user') {
1431
+            $modulepart = 'userphoto';
1432
+    }
1433
+    if ($object->element == 'product') {
1434
+            $modulepart = 'product';
1435
+    }
1378 1436
 
1379 1437
     if (class_exists("Imagick")) {
1380
-        if ($object->element == 'propal')
1381
-            $modulepart = 'propal';
1382
-        if ($object->element == 'commande')
1383
-            $modulepart = 'commande';
1384
-        if ($object->element == 'facture')
1385
-            $modulepart = 'facture';
1386
-        if ($object->element == 'fichinter')
1387
-            $modulepart = 'ficheinter';
1388
-        if ($object->element == 'contrat')
1389
-            $modulepart = 'contract';
1390
-        if ($object->element == 'supplier_proposal')
1391
-            $modulepart = 'supplier_proposal';
1392
-        if ($object->element == 'order_supplier')
1393
-            $modulepart = 'supplier_order';
1394
-        if ($object->element == 'invoice_supplier')
1395
-            $modulepart = 'supplier_invoice';
1396
-        if ($object->element == 'expensereport')
1397
-            $modulepart = 'expensereport';
1438
+        if ($object->element == 'propal') {
1439
+                    $modulepart = 'propal';
1440
+        }
1441
+        if ($object->element == 'commande') {
1442
+                    $modulepart = 'commande';
1443
+        }
1444
+        if ($object->element == 'facture') {
1445
+                    $modulepart = 'facture';
1446
+        }
1447
+        if ($object->element == 'fichinter') {
1448
+                    $modulepart = 'ficheinter';
1449
+        }
1450
+        if ($object->element == 'contrat') {
1451
+                    $modulepart = 'contract';
1452
+        }
1453
+        if ($object->element == 'supplier_proposal') {
1454
+                    $modulepart = 'supplier_proposal';
1455
+        }
1456
+        if ($object->element == 'order_supplier') {
1457
+                    $modulepart = 'supplier_order';
1458
+        }
1459
+        if ($object->element == 'invoice_supplier') {
1460
+                    $modulepart = 'supplier_invoice';
1461
+        }
1462
+        if ($object->element == 'expensereport') {
1463
+                    $modulepart = 'expensereport';
1464
+        }
1398 1465
     }
1399 1466
 
1400 1467
     if ($object->element == 'product') {
@@ -1402,11 +1469,12 @@  discard block
 block discarded – undo
1402 1469
         $cssclass = 'photoref';
1403 1470
         $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]);
1404 1471
         $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
1405
-        if ($conf->browser->layout == 'phone')
1406
-            $maxvisiblephotos = 1;
1407
-        if ($showimage)
1408
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1409
-        else {
1472
+        if ($conf->browser->layout == 'phone') {
1473
+                    $maxvisiblephotos = 1;
1474
+        }
1475
+        if ($showimage) {
1476
+                    $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1477
+        } else {
1410 1478
             if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
1411 1479
                 $nophoto = '';
1412 1480
                 $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>';
@@ -1422,11 +1490,12 @@  discard block
 block discarded – undo
1422 1490
         $cssclass = 'photoref';
1423 1491
         $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity] . '/' . $object->track_id);
1424 1492
         $maxvisiblephotos = (isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? $conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2);
1425
-        if ($conf->browser->layout == 'phone')
1426
-            $maxvisiblephotos = 1;
1427
-        if ($showimage)
1428
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1429
-        else {
1493
+        if ($conf->browser->layout == 'phone') {
1494
+                    $maxvisiblephotos = 1;
1495
+        }
1496
+        if ($showimage) {
1497
+                    $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1498
+        } else {
1430 1499
             if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
1431 1500
                 $nophoto = '';
1432 1501
                 $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>';
@@ -1451,8 +1520,10 @@  discard block
 block discarded – undo
1451 1520
                     } else {
1452 1521
                         $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart);
1453 1522
                     }
1454
-                    if (empty($subdir))
1455
-                        $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path
1523
+                    if (empty($subdir)) {
1524
+                                            $subdir = 'errorgettingsubdirofobject';
1525
+                    }
1526
+                    // Protection to avoid to return empty path
1456 1527
 
1457 1528
                     $filepath = $dir_output . $subdir . "/";
1458 1529
 
@@ -1473,14 +1544,16 @@  discard block
 block discarded – undo
1473 1544
                             if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) {  // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
1474 1545
                                 include_once DOL_BASE_PATH . '/core/lib/files.lib.php';
1475 1546
                                 $ret = dol_convert_file($file, 'png', $fileimage);
1476
-                                if ($ret < 0)
1477
-                                    $error++;
1547
+                                if ($ret < 0) {
1548
+                                                                    $error++;
1549
+                                }
1478 1550
                             }
1479 1551
                         }
1480 1552
 
1481 1553
                         $heightforphotref = 70;
1482
-                        if (!empty($conf->dol_optimize_smallscreen))
1483
-                            $heightforphotref = 60;
1554
+                        if (!empty($conf->dol_optimize_smallscreen)) {
1555
+                                                    $heightforphotref = 60;
1556
+                        }
1484 1557
                         // Si fichier png PDF d'1 page trouve
1485 1558
                         if (file_exists($fileimage)) {
1486 1559
                             $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
@@ -1516,8 +1589,10 @@  discard block
 block discarded – undo
1516 1589
                     $width = 14;
1517 1590
                     $cssclass = 'photorefcenter';
1518 1591
                     $picto = $object->picto;
1519
-                    if ($object->element == 'project' && !$object->public)
1520
-                        $picto = 'project'; // instead of projectpub
1592
+                    if ($object->element == 'project' && !$object->public) {
1593
+                                            $picto = 'project';
1594
+                    }
1595
+                    // instead of projectpub
1521 1596
                     $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
1522 1597
                 }
1523 1598
                 $morehtmlleft .= '<!-- No photo to show -->';
@@ -1528,8 +1603,9 @@  discard block
 block discarded – undo
1528 1603
         }
1529 1604
     }
1530 1605
 
1531
-    if ($showbarcode)
1532
-        $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1606
+    if ($showbarcode) {
1607
+            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1608
+    }
1533 1609
 
1534 1610
     if ($object->element == 'societe') {
1535 1611
         if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
@@ -1553,35 +1629,37 @@  discard block
 block discarded – undo
1553 1629
         }
1554 1630
     } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
1555 1631
         $tmptxt = $object->getLibStatut(6, $object->totalpaye);
1556
-        if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone')
1557
-            $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1632
+        if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') {
1633
+                    $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1634
+        }
1558 1635
         $morehtmlstatus .= $tmptxt;
1559
-    }
1560
-    elseif ($object->element == 'contrat' || $object->element == 'contract') {
1561
-        if ($object->statut == 0)
1562
-            $morehtmlstatus .= $object->getLibStatut(5);
1563
-        else
1564
-            $morehtmlstatus .= $object->getLibStatut(4);
1565
-    }
1566
-    elseif ($object->element == 'facturerec') {
1567
-        if ($object->frequency == 0)
1568
-            $morehtmlstatus .= $object->getLibStatut(2);
1569
-        else
1570
-            $morehtmlstatus .= $object->getLibStatut(5);
1571
-    }
1572
-    elseif ($object->element == 'project_task') {
1636
+    } elseif ($object->element == 'contrat' || $object->element == 'contract') {
1637
+        if ($object->statut == 0) {
1638
+                    $morehtmlstatus .= $object->getLibStatut(5);
1639
+        } else {
1640
+                    $morehtmlstatus .= $object->getLibStatut(4);
1641
+        }
1642
+    } elseif ($object->element == 'facturerec') {
1643
+        if ($object->frequency == 0) {
1644
+                    $morehtmlstatus .= $object->getLibStatut(2);
1645
+        } else {
1646
+                    $morehtmlstatus .= $object->getLibStatut(5);
1647
+        }
1648
+    } elseif ($object->element == 'project_task') {
1573 1649
         $object->fk_statut = 1;
1574
-        if ($object->progress > 0)
1575
-            $object->fk_statut = 2;
1576
-        if ($object->progress >= 100)
1577
-            $object->fk_statut = 3;
1650
+        if ($object->progress > 0) {
1651
+                    $object->fk_statut = 2;
1652
+        }
1653
+        if ($object->progress >= 100) {
1654
+                    $object->fk_statut = 3;
1655
+        }
1578 1656
         $tmptxt = $object->getLibStatut(5);
1579 1657
         $morehtmlstatus .= $tmptxt;  // No status on task
1580
-    }
1581
-    else { // Generic case
1658
+    } else { // Generic case
1582 1659
         $tmptxt = $object->getLibStatut(6);
1583
-        if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone')
1584
-            $tmptxt = $object->getLibStatut(5);
1660
+        if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') {
1661
+                    $tmptxt = $object->getLibStatut(5);
1662
+        }
1585 1663
         $morehtmlstatus .= $tmptxt;
1586 1664
     }
1587 1665
 
@@ -1595,13 +1673,15 @@  discard block
 block discarded – undo
1595 1673
     }
1596 1674
 
1597 1675
     // Add alias for thirdparty
1598
-    if (!empty($object->name_alias))
1599
-        $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1676
+    if (!empty($object->name_alias)) {
1677
+            $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1678
+    }
1600 1679
 
1601 1680
     // Add label
1602 1681
     if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
1603
-        if (!empty($object->label))
1604
-            $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1682
+        if (!empty($object->label)) {
1683
+                    $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1684
+        }
1605 1685
     }
1606 1686
 
1607 1687
     if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
@@ -1634,15 +1714,19 @@  discard block
 block discarded – undo
1634 1714
 {
1635 1715
     global $conf, $langs;
1636 1716
     $ret = '';
1637
-    if ($fieldrequired)
1638
-        $ret .= '<span class="fieldrequired">';
1639
-    if (($conf->dol_use_jmobile != 4))
1640
-        $ret .= '<label for="' . $fieldkey . '">';
1717
+    if ($fieldrequired) {
1718
+            $ret .= '<span class="fieldrequired">';
1719
+    }
1720
+    if (($conf->dol_use_jmobile != 4)) {
1721
+            $ret .= '<label for="' . $fieldkey . '">';
1722
+    }
1641 1723
     $ret .= $langs->trans($langkey);
1642
-    if (($conf->dol_use_jmobile != 4))
1643
-        $ret .= '</label>';
1644
-    if ($fieldrequired)
1645
-        $ret .= '</span>';
1724
+    if (($conf->dol_use_jmobile != 4)) {
1725
+            $ret .= '</label>';
1726
+    }
1727
+    if ($fieldrequired) {
1728
+            $ret .= '</span>';
1729
+    }
1646 1730
     return $ret;
1647 1731
 }
1648 1732
 
@@ -1657,8 +1741,9 @@  discard block
 block discarded – undo
1657 1741
 {
1658 1742
     global $bc;
1659 1743
     $ret = ' ' . $bc[$var];
1660
-    if ($moreclass)
1661
-        $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1744
+    if ($moreclass) {
1745
+            $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1746
+    }
1662 1747
     return $ret;
1663 1748
 }
1664 1749
 
@@ -1689,18 +1774,18 @@  discard block
 block discarded – undo
1689 1774
         if ($object->state) {
1690 1775
             $ret .= ($ret ? ", " : '') . $object->state;
1691 1776
         }
1692
-        if ($object->zip)
1693
-            $ret .= ($ret ? ", " : '') . $object->zip;
1694
-    }
1695
-    else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1777
+        if ($object->zip) {
1778
+                    $ret .= ($ret ? ", " : '') . $object->zip;
1779
+        }
1780
+    } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1696 1781
         $ret .= ($ret ? $sep : '' ) . $object->town;
1697 1782
         if ($object->state) {
1698 1783
             $ret .= ($ret ? ", " : '') . $object->state;
1699 1784
         }
1700
-        if ($object->zip)
1701
-            $ret .= ($ret ? $sep : '' ) . $object->zip;
1702
-    }
1703
-    else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1785
+        if ($object->zip) {
1786
+                    $ret .= ($ret ? $sep : '' ) . $object->zip;
1787
+        }
1788
+    } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1704 1789
         $ret .= ($ret ? $sep : '' ) . $object->zip;
1705 1790
         $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1706 1791
         if ($object->state) {
@@ -1717,8 +1802,9 @@  discard block
 block discarded – undo
1717 1802
             $ret .= ($ret ? ", " : '') . $object->state;
1718 1803
         }
1719 1804
     }
1720
-    if (!is_object($outputlangs))
1721
-        $outputlangs = $langs;
1805
+    if (!is_object($outputlangs)) {
1806
+            $outputlangs = $langs;
1807
+    }
1722 1808
     if ($withcountry) {
1723 1809
         $langs->load("dict");
1724 1810
         $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
@@ -1739,9 +1825,10 @@  discard block
 block discarded – undo
1739 1825
 {
1740 1826
     if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
1741 1827
         return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
1742
-    } else
1743
-        return 'Error date into a not supported range';
1744
-}
1828
+    } else {
1829
+            return 'Error date into a not supported range';
1830
+    }
1831
+    }
1745 1832
 
1746 1833
 /**
1747 1834
  * 	Output date in a string format according to outputlangs (or langs if not defined).
@@ -1787,10 +1874,12 @@  discard block
 block discarded – undo
1787 1874
             }
1788 1875
         }
1789 1876
     }
1790
-    if (!is_object($outputlangs))
1791
-        $outputlangs = $langs;
1792
-    if (!$format)
1793
-        $format = 'daytextshort';
1877
+    if (!is_object($outputlangs)) {
1878
+            $outputlangs = $langs;
1879
+    }
1880
+    if (!$format) {
1881
+            $format = 'daytextshort';
1882
+    }
1794 1883
     $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
1795 1884
     $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
1796 1885
     if ($formatwithoutreduce != $format) {
@@ -1799,40 +1888,46 @@  discard block
 block discarded – undo
1799 1888
     }  // so format 'dayreduceformat' is processed like day
1800 1889
     // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
1801 1890
     // TODO Add format daysmallyear and dayhoursmallyear
1802
-    if ($format == 'day')
1803
-        $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short);
1804
-    else if ($format == 'hour')
1805
-        $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short);
1806
-    else if ($format == 'hourduration')
1807
-        $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration);
1808
-    else if ($format == 'daytext')
1809
-        $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text);
1810
-    else if ($format == 'daytextshort')
1811
-    // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781
1891
+    if ($format == 'day') {
1892
+            $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short);
1893
+    } else if ($format == 'hour') {
1894
+            $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short);
1895
+    } else if ($format == 'hourduration') {
1896
+            $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration);
1897
+    } else if ($format == 'daytext') {
1898
+            $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text);
1899
+    } else if ($format == 'daytextshort') {
1900
+        // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781
1812 1901
         $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short);
1813
-    else if ($format == 'dayhour')
1814
-        $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short);
1815
-    else if ($format == 'dayhoursec')
1816
-        $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
1817
-    else if ($format == 'dayhourtext')
1818
-        $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text);
1819
-    else if ($format == 'dayhourtextshort')
1820
-        $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short);
1902
+    } else if ($format == 'dayhour') {
1903
+            $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short);
1904
+    } else if ($format == 'dayhoursec') {
1905
+            $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short);
1906
+    } else if ($format == 'dayhourtext') {
1907
+            $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text);
1908
+    } else if ($format == 'dayhourtextshort') {
1909
+            $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short);
1910
+    }
1821 1911
     // Format not sensitive to language
1822
-    else if ($format == 'dayhourlog')
1823
-        $format = '%Y%m%d%H%M%S';
1824
-    else if ($format == 'dayhourldap')
1825
-        $format = '%Y%m%d%H%M%SZ';
1826
-    else if ($format == 'dayhourxcard')
1827
-        $format = '%Y%m%dT%H%M%SZ';
1828
-    else if ($format == 'dayxcard')
1829
-        $format = '%Y%m%d';
1830
-    else if ($format == 'dayrfc')
1831
-        $format = '%Y-%m-%d';             // DATE_RFC3339
1832
-    else if ($format == 'dayhourrfc')
1833
-        $format = '%Y-%m-%dT%H:%M:%SZ';   // DATETIME RFC3339
1834
-    else if ($format == 'standard')
1835
-        $format = '%Y-%m-%d %H:%M:%S';
1912
+    else if ($format == 'dayhourlog') {
1913
+            $format = '%Y%m%d%H%M%S';
1914
+    } else if ($format == 'dayhourldap') {
1915
+            $format = '%Y%m%d%H%M%SZ';
1916
+    } else if ($format == 'dayhourxcard') {
1917
+            $format = '%Y%m%dT%H%M%SZ';
1918
+    } else if ($format == 'dayxcard') {
1919
+            $format = '%Y%m%d';
1920
+    } else if ($format == 'dayrfc') {
1921
+            $format = '%Y-%m-%d';
1922
+    }
1923
+    // DATE_RFC3339
1924
+    else if ($format == 'dayhourrfc') {
1925
+            $format = '%Y-%m-%dT%H:%M:%SZ';
1926
+    }
1927
+    // DATETIME RFC3339
1928
+    else if ($format == 'standard') {
1929
+            $format = '%Y-%m-%d %H:%M:%S';
1930
+    }
1836 1931
 
1837 1932
     if ($reduceformat) {
1838 1933
         $format = str_replace('%Y', '%y', $format);
@@ -1840,8 +1935,10 @@  discard block
 block discarded – undo
1840 1935
     }
1841 1936
 
1842 1937
     // If date undefined or "", we return ""
1843
-    if (dol_strlen($time) == 0)
1844
-        return '';  // $time=0 allowed (it means 01/01/1970 00:00:00)
1938
+    if (dol_strlen($time) == 0) {
1939
+            return '';
1940
+    }
1941
+    // $time=0 allowed (it means 01/01/1970 00:00:00)
1845 1942
 
1846 1943
 
1847 1944
 
@@ -1901,8 +1998,9 @@  discard block
 block discarded – undo
1901 1998
             $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1902 1999
 
1903 2000
             $ret = adodb_strftime($format, $timetouse, $to_gmt);
1904
-        } else
1905
-            $ret = 'Bad value ' . $time . ' for date';
2001
+        } else {
2002
+                    $ret = 'Bad value ' . $time . ' for date';
2003
+        }
1906 2004
     }
1907 2005
 
1908 2006
     if (preg_match('/__b__/i', $format)) {
@@ -1973,10 +2071,14 @@  discard block
 block discarded – undo
1973 2071
     global $conf;
1974 2072
 
1975 2073
     $usealternatemethod = false;
1976
-    if ($timestamp <= 0)
1977
-        $usealternatemethod = true;    // <= 1970
1978
-    if ($timestamp >= 2145913200)
1979
-        $usealternatemethod = true;  // >= 2038
2074
+    if ($timestamp <= 0) {
2075
+            $usealternatemethod = true;
2076
+    }
2077
+    // <= 1970
2078
+    if ($timestamp >= 2145913200) {
2079
+            $usealternatemethod = true;
2080
+    }
2081
+    // >= 2038
1980 2082
 
1981 2083
     if ($usealternatemethod) {
1982 2084
         $arrayinfo = adodb_getdate($timestamp, $fast);
@@ -2011,27 +2113,36 @@  discard block
 block discarded – undo
2011 2113
     global $conf;
2012 2114
     //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
2013 2115
     // Clean parameters
2014
-    if ($hour == -1 || empty($hour))
2015
-        $hour = 0;
2016
-    if ($minute == -1 || empty($minute))
2017
-        $minute = 0;
2018
-    if ($second == -1 || empty($second))
2019
-        $second = 0;
2116
+    if ($hour == -1 || empty($hour)) {
2117
+            $hour = 0;
2118
+    }
2119
+    if ($minute == -1 || empty($minute)) {
2120
+            $minute = 0;
2121
+    }
2122
+    if ($second == -1 || empty($second)) {
2123
+            $second = 0;
2124
+    }
2020 2125
 
2021 2126
     // Check parameters
2022 2127
     if ($check) {
2023
-        if (!$month || !$day)
2024
-            return '';
2025
-        if ($day > 31)
2026
-            return '';
2027
-        if ($month > 12)
2028
-            return '';
2029
-        if ($hour < 0 || $hour > 24)
2030
-            return '';
2031
-        if ($minute < 0 || $minute > 60)
2032
-            return '';
2033
-        if ($second < 0 || $second > 60)
2034
-            return '';
2128
+        if (!$month || !$day) {
2129
+                    return '';
2130
+        }
2131
+        if ($day > 31) {
2132
+                    return '';
2133
+        }
2134
+        if ($month > 12) {
2135
+                    return '';
2136
+        }
2137
+        if ($hour < 0 || $hour > 24) {
2138
+                    return '';
2139
+        }
2140
+        if ($minute < 0 || $minute > 60) {
2141
+                    return '';
2142
+        }
2143
+        if ($second < 0 || $second > 60) {
2144
+                    return '';
2145
+        }
2035 2146
     }
2036 2147
 
2037 2148
     if (method_exists('DateTime', 'getTimestamp')) {
@@ -2088,8 +2199,10 @@  discard block
 block discarded – undo
2088 2199
 
2089 2200
     // Note that gmmktime and mktime return same value (GMT) when used without parameters
2090 2201
     //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead
2091
-    if ($mode == 'gmt')
2092
-        $ret = time(); // Time for now at greenwich.
2202
+    if ($mode == 'gmt') {
2203
+            $ret = time();
2204
+    }
2205
+    // Time for now at greenwich.
2093 2206
     else if ($mode == 'tzserver') {  // Time for now with PHP server timezone added
2094 2207
         require_once DOL_BASE_PATH . '/core/lib/date.lib.php';
2095 2208
         $tzsecond = getServerTimeZoneInt('now');    // Contains tz+dayling saving time
@@ -2123,8 +2236,9 @@  discard block
 block discarded – undo
2123 2236
     global $conf, $langs;
2124 2237
     $level = 1024;
2125 2238
 
2126
-    if (!empty($conf->dol_optimize_smallscreen))
2127
-        $shortunit = 1;
2239
+    if (!empty($conf->dol_optimize_smallscreen)) {
2240
+            $shortunit = 1;
2241
+    }
2128 2242
 
2129 2243
     // Set value text
2130 2244
     if (empty($shortvalue) || $size < ($level * 10)) {
@@ -2159,19 +2273,23 @@  discard block
 block discarded – undo
2159 2273
 {
2160 2274
     global $langs;
2161 2275
 
2162
-    if (empty($url))
2163
-        return '';
2276
+    if (empty($url)) {
2277
+            return '';
2278
+    }
2164 2279
 
2165 2280
     $link = '<a href="';
2166
-    if (!preg_match('/^http/i', $url))
2167
-        $link .= 'http://';
2281
+    if (!preg_match('/^http/i', $url)) {
2282
+            $link .= 'http://';
2283
+    }
2168 2284
     $link .= $url;
2169 2285
     $link .= '"';
2170
-    if ($target)
2171
-        $link .= ' target="' . $target . '"';
2286
+    if ($target) {
2287
+            $link .= ' target="' . $target . '"';
2288
+    }
2172 2289
     $link .= '>';
2173
-    if (!preg_match('/^http/i', $url))
2174
-        $link .= 'http://';
2290
+    if (!preg_match('/^http/i', $url)) {
2291
+            $link .= 'http://';
2292
+    }
2175 2293
     $link .= dol_trunc($url, $max);
2176 2294
     $link .= '</a>';
2177 2295
     return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
@@ -2195,13 +2313,15 @@  discard block
 block discarded – undo
2195 2313
 
2196 2314
     $newemail = $email;
2197 2315
 
2198
-    if (empty($email))
2199
-        return '&nbsp;';
2316
+    if (empty($email)) {
2317
+            return '&nbsp;';
2318
+    }
2200 2319
 
2201 2320
     if (!empty($addlink)) {
2202 2321
         $newemail = '<a style="text-overflow: ellipsis;" href="';
2203
-        if (!preg_match('/^mailto:/i', $email))
2204
-            $newemail .= 'mailto:';
2322
+        if (!preg_match('/^mailto:/i', $email)) {
2323
+                    $newemail .= 'mailto:';
2324
+        }
2205 2325
         $newemail .= $email;
2206 2326
         $newemail .= '">';
2207 2327
         $newemail .= dol_trunc($email, $max);
@@ -2214,13 +2334,14 @@  discard block
 block discarded – undo
2214 2334
         if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2215 2335
             $type = 'AC_EMAIL';
2216 2336
             $link = '';
2217
-            if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL))
2218
-                $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2219
-            if ($link)
2220
-                $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2337
+            if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) {
2338
+                            $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2339
+            }
2340
+            if ($link) {
2341
+                            $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2342
+            }
2221 2343
         }
2222
-    }
2223
-    else {
2344
+    } else {
2224 2345
         if ($showinvalid && !isValidEmail($email)) {
2225 2346
             $langs->load("errors");
2226 2347
             $newemail .= img_warning($langs->trans("ErrorBadEMail", $email));
@@ -2252,8 +2373,9 @@  discard block
 block discarded – undo
2252 2373
 
2253 2374
     $newskype = $value;
2254 2375
 
2255
-    if (empty($value))
2256
-        return '&nbsp;';
2376
+    if (empty($value)) {
2377
+            return '&nbsp;';
2378
+    }
2257 2379
 
2258 2380
     if (!empty($type)) {
2259 2381
         $newskype = '<div class="divsocialnetwork inline-block valignmiddle">';
@@ -2274,13 +2396,13 @@  discard block
 block discarded – undo
2274 2396
         if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
2275 2397
             $addlink = 'AC_SKYPE';
2276 2398
             $link = '';
2277
-            if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE))
2278
-                $link = '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode=' . $addlink . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2399
+            if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) {
2400
+                            $link = '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode=' . $addlink . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2401
+            }
2279 2402
             $newskype .= ($link ? ' ' . $link : '');
2280 2403
         }
2281 2404
         $newskype .= '</div>';
2282
-    }
2283
-    else {
2405
+    } else {
2284 2406
         $langs->load("errors");
2285 2407
         $newskype .= img_warning($langs->trans("ErrorBadSocialNetworkValue", $value));
2286 2408
     }
@@ -2310,12 +2432,14 @@  discard block
 block discarded – undo
2310 2432
     if (empty($phone)) {
2311 2433
         return '';
2312 2434
     }
2313
-    if (empty($countrycode))
2314
-        $countrycode = $mysoc->country_code;
2435
+    if (empty($countrycode)) {
2436
+            $countrycode = $mysoc->country_code;
2437
+    }
2315 2438
 
2316 2439
     // Short format for small screens
2317
-    if ($conf->dol_optimize_smallscreen)
2318
-        $separ = '';
2440
+    if ($conf->dol_optimize_smallscreen) {
2441
+            $separ = '';
2442
+    }
2319 2443
 
2320 2444
     $newphone = $phone;
2321 2445
     if (strtoupper($countrycode) == "FR") {
@@ -2481,15 +2605,18 @@  discard block
 block discarded – undo
2481 2605
             $newphone = '<a href="tel:' . $phone . '"';
2482 2606
             $newphone .= '>' . $phone . '</a>';
2483 2607
         } else if (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') {  // If click to dial, we use click to dial url
2484
-            if (empty($user->clicktodial_loaded))
2485
-                $user->fetch_clicktodial();
2608
+            if (empty($user->clicktodial_loaded)) {
2609
+                            $user->fetch_clicktodial();
2610
+            }
2486 2611
 
2487 2612
             // Define urlmask
2488 2613
             $urlmask = 'ErrorClickToDialModuleNotConfigured';
2489
-            if (!empty($conf->global->CLICKTODIAL_URL))
2490
-                $urlmask = $conf->global->CLICKTODIAL_URL;
2491
-            if (!empty($user->clicktodial_url))
2492
-                $urlmask = $user->clicktodial_url;
2614
+            if (!empty($conf->global->CLICKTODIAL_URL)) {
2615
+                            $urlmask = $conf->global->CLICKTODIAL_URL;
2616
+            }
2617
+            if (!empty($user->clicktodial_url)) {
2618
+                            $urlmask = $user->clicktodial_url;
2619
+            }
2493 2620
 
2494 2621
             $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : '');
2495 2622
             $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : '');
@@ -2504,8 +2631,9 @@  discard block
 block discarded – undo
2504 2631
             $url = make_substitutions($url, $substitarray);
2505 2632
             $newphonesav = $newphone;
2506 2633
             $newphone = '<a href="' . $url . '"';
2507
-            if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET))
2508
-                $newphone .= ' target="_blank"';
2634
+            if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) {
2635
+                            $newphone .= ' target="_blank"';
2636
+            }
2509 2637
             $newphone .= '>' . $newphonesav . '</a>';
2510 2638
         }
2511 2639
 
@@ -2513,12 +2641,15 @@  discard block
 block discarded – undo
2513 2641
         if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2514 2642
             $type = 'AC_TEL';
2515 2643
             $link = '';
2516
-            if ($addlink == 'AC_FAX')
2517
-                $type = 'AC_FAX';
2518
-            if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE))
2519
-                $link = '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode=' . $type . ($cid ? '&amp;contactid=' . $cid : '') . ($socid ? '&amp;socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2520
-            if ($link)
2521
-                $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2644
+            if ($addlink == 'AC_FAX') {
2645
+                            $type = 'AC_FAX';
2646
+            }
2647
+            if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) {
2648
+                            $link = '<a href="' . BASE_URI . '?controller=comm/action&method=card&action=create&amp;backtopage=1&amp;actioncode=' . $type . ($cid ? '&amp;contactid=' . $cid : '') . ($socid ? '&amp;socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2649
+            }
2650
+            if ($link) {
2651
+                            $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2652
+            }
2522 2653
         }
2523 2654
     }
2524 2655
 
@@ -2545,15 +2676,17 @@  discard block
 block discarded – undo
2545 2676
                 $picto = '';
2546 2677
             }
2547 2678
         }
2548
-        if ($adddivfloat)
2549
-            $rep .= '<div class="nospan float" style="margin-right: 10px">';
2550
-        else
2551
-            $rep .= '<span style="margin-right: 10px;">';
2679
+        if ($adddivfloat) {
2680
+                    $rep .= '<div class="nospan float" style="margin-right: 10px">';
2681
+        } else {
2682
+                    $rep .= '<span style="margin-right: 10px;">';
2683
+        }
2552 2684
         $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone;
2553
-        if ($adddivfloat)
2554
-            $rep .= '</div>';
2555
-        else
2556
-            $rep .= '</span>';
2685
+        if ($adddivfloat) {
2686
+                    $rep .= '</div>';
2687
+        } else {
2688
+                    $rep .= '</span>';
2689
+        }
2557 2690
     }
2558 2691
 
2559 2692
     return $rep;
@@ -2583,8 +2716,9 @@  discard block
 block discarded – undo
2583 2716
         if ($countrycode) { // If success, countrycode is us, fr, ...
2584 2717
             if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
2585 2718
                 $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
2586
-            } else
2587
-                $ret .= ' (' . $countrycode . ')';
2719
+            } else {
2720
+                            $ret .= ' (' . $countrycode . ')';
2721
+            }
2588 2722
         }
2589 2723
     }
2590 2724
 
@@ -2682,26 +2816,33 @@  discard block
 block discarded – undo
2682 2816
             $out .= $hookmanager->resPrint;
2683 2817
         }
2684 2818
         if (empty($reshook)) {
2685
-            if (empty($charfornl))
2686
-                $out .= nl2br($address);
2687
-            else
2688
-                $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
2819
+            if (empty($charfornl)) {
2820
+                            $out .= nl2br($address);
2821
+            } else {
2822
+                            $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
2823
+            }
2689 2824
 
2690 2825
             $showgmap = $showomap = 0;
2691 2826
 
2692 2827
             // TODO Add a hook here
2693
-            if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS))
2694
-                $showgmap = 1;
2695
-            if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS))
2696
-                $showgmap = 1;
2697
-            if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS))
2698
-                $showgmap = 1;
2699
-            if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS))
2700
-                $showomap = 1;
2701
-            if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS))
2702
-                $showomap = 1;
2703
-            if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS))
2704
-                $showomap = 1;
2828
+            if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) {
2829
+                            $showgmap = 1;
2830
+            }
2831
+            if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
2832
+                            $showgmap = 1;
2833
+            }
2834
+            if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
2835
+                            $showgmap = 1;
2836
+            }
2837
+            if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
2838
+                            $showomap = 1;
2839
+            }
2840
+            if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
2841
+                            $showomap = 1;
2842
+            }
2843
+            if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
2844
+                            $showomap = 1;
2845
+            }
2705 2846
 
2706 2847
             if ($showgmap) {
2707 2848
                 $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
@@ -2713,11 +2854,12 @@  discard block
 block discarded – undo
2713 2854
             }
2714 2855
         }
2715 2856
     }
2716
-    if ($noprint)
2717
-        return $out;
2718
-    else
2719
-        print $out;
2720
-}
2857
+    if ($noprint) {
2858
+            return $out;
2859
+    } else {
2860
+            print $out;
2861
+    }
2862
+    }
2721 2863
 
2722 2864
 /**
2723 2865
  * 	Return true if email syntax is ok
@@ -2728,10 +2870,12 @@  discard block
 block discarded – undo
2728 2870
  */
2729 2871
 function isValidEmail($address, $acceptsupervisorkey = 0)
2730 2872
 {
2731
-    if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__')
2732
-        return true;
2733
-    if (filter_var($address, FILTER_VALIDATE_EMAIL))
2734
-        return true;
2873
+    if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') {
2874
+            return true;
2875
+    }
2876
+    if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
2877
+            return true;
2878
+    }
2735 2879
 
2736 2880
     return false;
2737 2881
 }
@@ -2753,10 +2897,12 @@  discard block
 block discarded – undo
2753 2897
             $mxhosts = array();
2754 2898
             $weight = array();
2755 2899
             getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
2756
-            if (count($mxhosts) > 1)
2757
-                return 1;
2758
-            if (count($mxhosts) == 1 && !empty($mxhosts[0]))
2759
-                return 1;
2900
+            if (count($mxhosts) > 1) {
2901
+                            return 1;
2902
+            }
2903
+            if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
2904
+                            return 1;
2905
+            }
2760 2906
 
2761 2907
             return 0;
2762 2908
         }
@@ -2785,11 +2931,12 @@  discard block
 block discarded – undo
2785 2931
  */
2786 2932
 function dol_strlen($string, $stringencoding = 'UTF-8')
2787 2933
 {
2788
-    if (function_exists('mb_strlen'))
2789
-        return mb_strlen($string, $stringencoding);
2790
-    else
2791
-        return strlen($string);
2792
-}
2934
+    if (function_exists('mb_strlen')) {
2935
+            return mb_strlen($string, $stringencoding);
2936
+    } else {
2937
+            return strlen($string);
2938
+    }
2939
+    }
2793 2940
 
2794 2941
 /**
2795 2942
  * Make a substring. Works even if mbstring module is not enabled for better compatibility.
@@ -2805,8 +2952,9 @@  discard block
 block discarded – undo
2805 2952
 {
2806 2953
     global $langs;
2807 2954
 
2808
-    if (empty($stringencoding))
2809
-        $stringencoding = $langs->charset_output;
2955
+    if (empty($stringencoding)) {
2956
+            $stringencoding = $langs->charset_output;
2957
+    }
2810 2958
 
2811 2959
     $ret = '';
2812 2960
     if (empty($trunconbytes)) {
@@ -2842,49 +2990,56 @@  discard block
 block discarded – undo
2842 2990
 {
2843 2991
     global $conf;
2844 2992
 
2845
-    if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC))
2846
-        return $string;
2993
+    if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) {
2994
+            return $string;
2995
+    }
2847 2996
 
2848
-    if (empty($stringencoding))
2849
-        $stringencoding = 'UTF-8';
2997
+    if (empty($stringencoding)) {
2998
+            $stringencoding = 'UTF-8';
2999
+    }
2850 3000
     // reduce for small screen
2851
-    if ($conf->dol_optimize_smallscreen == 1 && $display == 1)
2852
-        $size = round($size / 3);
3001
+    if ($conf->dol_optimize_smallscreen == 1 && $display == 1) {
3002
+            $size = round($size / 3);
3003
+    }
2853 3004
 
2854 3005
     // We go always here
2855 3006
     if ($trunc == 'right') {
2856 3007
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2857
-        if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
3008
+        if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
3009
+            // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2858 3010
             return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
2859
-        else
2860
-        //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
3011
+        } else {
3012
+                //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
2861 3013
             return $string;
2862
-    }
2863
-    elseif ($trunc == 'middle') {
3014
+        }
3015
+    } elseif ($trunc == 'middle') {
2864 3016
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2865 3017
         if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
2866 3018
             $size1 = round($size / 2);
2867 3019
             $size2 = round($size / 2);
2868 3020
             return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2869
-        } else
2870
-            return $string;
2871
-    }
2872
-    elseif ($trunc == 'left') {
3021
+        } else {
3022
+                    return $string;
3023
+        }
3024
+    } elseif ($trunc == 'left') {
2873 3025
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2874
-        if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
3026
+        if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
3027
+            // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2875 3028
             return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2876
-        else
2877
-            return $string;
2878
-    }
2879
-    elseif ($trunc == 'wrap') {
3029
+        } else {
3030
+                    return $string;
3031
+        }
3032
+    } elseif ($trunc == 'wrap') {
2880 3033
         $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2881
-        if (dol_strlen($newstring, $stringencoding) > ($size + 1))
2882
-            return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2883
-        else
2884
-            return $string;
2885
-    } else
2886
-        return 'BadParam3CallingDolTrunc';
2887
-}
3034
+        if (dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3035
+                    return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
3036
+        } else {
3037
+                    return $string;
3038
+        }
3039
+    } else {
3040
+            return 'BadParam3CallingDolTrunc';
3041
+    }
3042
+    }
2888 3043
 
2889 3044
 /**
2890 3045
  * 	Show picto whatever it's its name (generic function)
@@ -3095,8 +3250,9 @@  discard block
 block discarded – undo
3095 3250
 {
3096 3251
     global $conf;
3097 3252
 
3098
-    if (!preg_match('/(\.png|\.gif)$/i', $picto))
3099
-        $picto .= '.png';
3253
+    if (!preg_match('/(\.png|\.gif)$/i', $picto)) {
3254
+            $picto .= '.png';
3255
+    }
3100 3256
 
3101 3257
     //$path = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/weather/' . $picto;
3102 3258
     $path = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/weather/' . $picto;
@@ -3118,20 +3274,22 @@  discard block
 block discarded – undo
3118 3274
 {
3119 3275
     global $conf;
3120 3276
 
3121
-    if (!preg_match('/(\.png|\.gif)$/i', $picto))
3122
-        $picto .= '.png';
3277
+    if (!preg_match('/(\.png|\.gif)$/i', $picto)) {
3278
+            $picto .= '.png';
3279
+    }
3123 3280
 
3124
-    if ($pictoisfullpath)
3125
-        $path = $picto;
3126
-    else {
3281
+    if ($pictoisfullpath) {
3282
+            $path = $picto;
3283
+    } else {
3127 3284
         //$path = DOL_URL_ROOT . '/theme/common/' . $picto;
3128 3285
         $path = DOL_BASE_URI . '/theme/common/' . $picto;
3129 3286
 
3130 3287
         if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
3131 3288
             $themepath = DOL_BASE_PATH . 'theme/' . $conf->theme . '/img/' . $picto;
3132 3289
 
3133
-            if (file_exists($themepath))
3134
-                $path = $themepath;
3290
+            if (file_exists($themepath)) {
3291
+                            $path = $themepath;
3292
+            }
3135 3293
         }
3136 3294
     }
3137 3295
 
@@ -3170,8 +3328,9 @@  discard block
 block discarded – undo
3170 3328
             $numaction = 0;
3171 3329
         }
3172 3330
     }
3173
-    if (!is_numeric($numaction))
3174
-        $numaction = 0;
3331
+    if (!is_numeric($numaction)) {
3332
+            $numaction = 0;
3333
+    }
3175 3334
 
3176 3335
     return img_picto($titlealt, 'stcomm' . $numaction . '.png');
3177 3336
 }
@@ -3187,8 +3346,9 @@  discard block
 block discarded – undo
3187 3346
 {
3188 3347
     global $conf, $langs;
3189 3348
 
3190
-    if ($titlealt == 'default')
3191
-        $titlealt = $langs->trans('Show');
3349
+    if ($titlealt == 'default') {
3350
+            $titlealt = $langs->trans('Show');
3351
+    }
3192 3352
 
3193 3353
     return img_picto($titlealt, 'pdf' . $size . '.png');
3194 3354
 }
@@ -3204,8 +3364,9 @@  discard block
 block discarded – undo
3204 3364
 {
3205 3365
     global $conf, $langs;
3206 3366
 
3207
-    if ($titlealt == 'default')
3208
-        $titlealt = $langs->trans('Add');
3367
+    if ($titlealt == 'default') {
3368
+            $titlealt = $langs->trans('Add');
3369
+    }
3209 3370
 
3210 3371
     return img_picto($titlealt, 'edit_add.png', $other);
3211 3372
 }
@@ -3221,8 +3382,9 @@  discard block
 block discarded – undo
3221 3382
 {
3222 3383
     global $conf, $langs;
3223 3384
 
3224
-    if ($titlealt == 'default')
3225
-        $titlealt = $langs->trans('Remove');
3385
+    if ($titlealt == 'default') {
3386
+            $titlealt = $langs->trans('Remove');
3387
+    }
3226 3388
 
3227 3389
     return img_picto($titlealt, 'edit_remove.png', $other);
3228 3390
 }
@@ -3239,8 +3401,9 @@  discard block
 block discarded – undo
3239 3401
 {
3240 3402
     global $conf, $langs;
3241 3403
 
3242
-    if ($titlealt == 'default')
3243
-        $titlealt = $langs->trans('Modify');
3404
+    if ($titlealt == 'default') {
3405
+            $titlealt = $langs->trans('Modify');
3406
+    }
3244 3407
 
3245 3408
     return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : ''));
3246 3409
 }
@@ -3257,8 +3420,9 @@  discard block
 block discarded – undo
3257 3420
 {
3258 3421
     global $conf, $langs;
3259 3422
 
3260
-    if ($titlealt == 'default')
3261
-        $titlealt = $langs->trans('View');
3423
+    if ($titlealt == 'default') {
3424
+            $titlealt = $langs->trans('View');
3425
+    }
3262 3426
 
3263 3427
     $moreatt = ($float ? 'style="float: right" ' : '') . $other;
3264 3428
 
@@ -3276,8 +3440,9 @@  discard block
 block discarded – undo
3276 3440
 {
3277 3441
     global $conf, $langs;
3278 3442
 
3279
-    if ($titlealt == 'default')
3280
-        $titlealt = $langs->trans('Delete');
3443
+    if ($titlealt == 'default') {
3444
+            $titlealt = $langs->trans('Delete');
3445
+    }
3281 3446
 
3282 3447
     return img_picto($titlealt, 'delete.png', $other);
3283 3448
     //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>';
@@ -3293,8 +3458,9 @@  discard block
 block discarded – undo
3293 3458
 function img_printer($titlealt = "default", $other = '')
3294 3459
 {
3295 3460
     global $conf, $langs;
3296
-    if ($titlealt == "default")
3297
-        $titlealt = $langs->trans("Print");
3461
+    if ($titlealt == "default") {
3462
+            $titlealt = $langs->trans("Print");
3463
+    }
3298 3464
     return img_picto($titlealt, 'printer.png', $other);
3299 3465
 }
3300 3466
 
@@ -3309,8 +3475,9 @@  discard block
 block discarded – undo
3309 3475
 {
3310 3476
     global $conf, $langs;
3311 3477
 
3312
-    if ($titlealt == 'default')
3313
-        $titlealt = $langs->trans('Split');
3478
+    if ($titlealt == 'default') {
3479
+            $titlealt = $langs->trans('Split');
3480
+    }
3314 3481
 
3315 3482
     return img_picto($titlealt, 'split.png', $other);
3316 3483
 }
@@ -3327,10 +3494,11 @@  discard block
 block discarded – undo
3327 3494
     global $conf, $langs;
3328 3495
 
3329 3496
     if ($usealttitle) {
3330
-        if (is_string($usealttitle))
3331
-            $usealttitle = dol_escape_htmltag($usealttitle);
3332
-        else
3333
-            $usealttitle = $langs->trans('Info');
3497
+        if (is_string($usealttitle)) {
3498
+                    $usealttitle = dol_escape_htmltag($usealttitle);
3499
+        } else {
3500
+                    $usealttitle = $langs->trans('Info');
3501
+        }
3334 3502
     }
3335 3503
 
3336 3504
     return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"');
@@ -3346,8 +3514,9 @@  discard block
 block discarded – undo
3346 3514
 {
3347 3515
     global $conf, $langs;
3348 3516
 
3349
-    if ($titlealt == 'default')
3350
-        $titlealt = $langs->trans('Informations');
3517
+    if ($titlealt == 'default') {
3518
+            $titlealt = $langs->trans('Informations');
3519
+    }
3351 3520
 
3352 3521
     return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"');
3353 3522
 }
@@ -3363,8 +3532,9 @@  discard block
 block discarded – undo
3363 3532
 {
3364 3533
     global $conf, $langs;
3365 3534
 
3366
-    if ($titlealt == 'default')
3367
-        $titlealt = $langs->trans('Warning');
3535
+    if ($titlealt == 'default') {
3536
+            $titlealt = $langs->trans('Warning');
3537
+    }
3368 3538
 
3369 3539
     //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>';
3370 3540
     return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : ''));
@@ -3380,8 +3550,9 @@  discard block
 block discarded – undo
3380 3550
 {
3381 3551
     global $conf, $langs;
3382 3552
 
3383
-    if ($titlealt == 'default')
3384
-        $titlealt = $langs->trans('Error');
3553
+    if ($titlealt == 'default') {
3554
+            $titlealt = $langs->trans('Error');
3555
+    }
3385 3556
 
3386 3557
     return img_picto($titlealt, 'error.png', 'class="valigntextbottom"');
3387 3558
 }
@@ -3397,8 +3568,9 @@  discard block
 block discarded – undo
3397 3568
 {
3398 3569
     global $conf, $langs;
3399 3570
 
3400
-    if ($titlealt == 'default')
3401
-        $titlealt = $langs->trans('Next');
3571
+    if ($titlealt == 'default') {
3572
+            $titlealt = $langs->trans('Next');
3573
+    }
3402 3574
 
3403 3575
     //return img_picto($titlealt, 'next.png', $moreatt);
3404 3576
     return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
@@ -3415,8 +3587,9 @@  discard block
 block discarded – undo
3415 3587
 {
3416 3588
     global $conf, $langs;
3417 3589
 
3418
-    if ($titlealt == 'default')
3419
-        $titlealt = $langs->trans('Previous');
3590
+    if ($titlealt == 'default') {
3591
+            $titlealt = $langs->trans('Previous');
3592
+    }
3420 3593
 
3421 3594
     //return img_picto($titlealt, 'previous.png', $moreatt);
3422 3595
     return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
@@ -3434,8 +3607,9 @@  discard block
 block discarded – undo
3434 3607
 {
3435 3608
     global $conf, $langs;
3436 3609
 
3437
-    if ($titlealt == 'default')
3438
-        $titlealt = $langs->trans('Down');
3610
+    if ($titlealt == 'default') {
3611
+            $titlealt = $langs->trans('Down');
3612
+    }
3439 3613
 
3440 3614
     return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"');
3441 3615
 }
@@ -3452,8 +3626,9 @@  discard block
 block discarded – undo
3452 3626
 {
3453 3627
     global $conf, $langs;
3454 3628
 
3455
-    if ($titlealt == 'default')
3456
-        $titlealt = $langs->trans('Up');
3629
+    if ($titlealt == 'default') {
3630
+            $titlealt = $langs->trans('Up');
3631
+    }
3457 3632
 
3458 3633
     return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"');
3459 3634
 }
@@ -3470,8 +3645,9 @@  discard block
 block discarded – undo
3470 3645
 {
3471 3646
     global $conf, $langs;
3472 3647
 
3473
-    if ($titlealt == 'default')
3474
-        $titlealt = $langs->trans('Left');
3648
+    if ($titlealt == 'default') {
3649
+            $titlealt = $langs->trans('Left');
3650
+    }
3475 3651
 
3476 3652
     return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt);
3477 3653
 }
@@ -3488,8 +3664,9 @@  discard block
 block discarded – undo
3488 3664
 {
3489 3665
     global $conf, $langs;
3490 3666
 
3491
-    if ($titlealt == 'default')
3492
-        $titlealt = $langs->trans('Right');
3667
+    if ($titlealt == 'default') {
3668
+            $titlealt = $langs->trans('Right');
3669
+    }
3493 3670
 
3494 3671
     return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt);
3495 3672
 }
@@ -3505,11 +3682,13 @@  discard block
 block discarded – undo
3505 3682
 {
3506 3683
     global $conf, $langs;
3507 3684
 
3508
-    if ($titlealt == 'default')
3509
-        $titlealt = $langs->trans('Active');
3685
+    if ($titlealt == 'default') {
3686
+            $titlealt = $langs->trans('Active');
3687
+    }
3510 3688
 
3511
-    if ($allow == 1)
3512
-        return img_picto($titlealt, 'tick.png');
3689
+    if ($allow == 1) {
3690
+            return img_picto($titlealt, 'tick.png');
3691
+    }
3513 3692
 
3514 3693
     return '-';
3515 3694
 }
@@ -3557,8 +3736,9 @@  discard block
 block discarded – undo
3557 3736
     $mimeimg = dol_mimetype($file, '', 2);
3558 3737
     $mimefa = dol_mimetype($file, '', 4);
3559 3738
 
3560
-    if (empty($titlealt))
3561
-        $titlealt = 'Mime type: ' . $mimetype;
3739
+    if (empty($titlealt)) {
3740
+            $titlealt = 'Mime type: ' . $mimetype;
3741
+    }
3562 3742
 
3563 3743
     //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"');
3564 3744
     return '<i class="fa fa-' . $mimefa . ' paddingright"></i>';
@@ -3580,13 +3760,15 @@  discard block
 block discarded – undo
3580 3760
 
3581 3761
     global $conf, $langs;
3582 3762
 
3583
-    if ($titlealt == 'default')
3584
-        $titlealt = $langs->trans('Call');
3763
+    if ($titlealt == 'default') {
3764
+            $titlealt = $langs->trans('Call');
3765
+    }
3585 3766
 
3586
-    if ($option == 1)
3587
-        $img = 'call';
3588
-    else
3589
-        $img = 'call_out';
3767
+    if ($option == 1) {
3768
+            $img = 'call';
3769
+    } else {
3770
+            $img = 'call_out';
3771
+    }
3590 3772
 
3591 3773
     return img_picto($titlealt, $img);
3592 3774
 }
@@ -3602,8 +3784,9 @@  discard block
 block discarded – undo
3602 3784
 {
3603 3785
     global $conf, $langs;
3604 3786
 
3605
-    if ($titlealt == 'default')
3606
-        $titlealt = $langs->trans('Search');
3787
+    if ($titlealt == 'default') {
3788
+            $titlealt = $langs->trans('Search');
3789
+    }
3607 3790
 
3608 3791
     $img = img_picto($titlealt, 'search.png', $other, false, 1);
3609 3792
 
@@ -3624,8 +3807,9 @@  discard block
 block discarded – undo
3624 3807
 {
3625 3808
     global $conf, $langs;
3626 3809
 
3627
-    if ($titlealt == 'default')
3628
-        $titlealt = $langs->trans('Search');
3810
+    if ($titlealt == 'default') {
3811
+            $titlealt = $langs->trans('Search');
3812
+    }
3629 3813
 
3630 3814
     $img = img_picto($titlealt, 'searchclear.png', $other, false, 1);
3631 3815
 
@@ -3687,14 +3871,16 @@  discard block
 block discarded – undo
3687 3871
 
3688 3872
     if ($_SERVER['DOCUMENT_ROOT']) {    // Mode web
3689 3873
         $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
3690
-        if (!empty($conf->global->MAIN_FEATURES_LEVEL))
3691
-            $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
3874
+        if (!empty($conf->global->MAIN_FEATURES_LEVEL)) {
3875
+                    $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
3876
+        }
3692 3877
         $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
3693 3878
 
3694 3879
         $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
3695 3880
         $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
3696
-        if (isset($conf->global->MAIN_FEATURES_LEVEL))
3697
-            $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
3881
+        if (isset($conf->global->MAIN_FEATURES_LEVEL)) {
3882
+                    $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
3883
+        }
3698 3884
         if (function_exists("phpversion")) {
3699 3885
             $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
3700 3886
         }
@@ -3737,18 +3923,20 @@  discard block
 block discarded – undo
3737 3923
         $langs->load("errors");
3738 3924
 
3739 3925
         // Merge all into $errors array
3740
-        if (is_array($error) && is_array($errors))
3741
-            $errors = array_merge($error, $errors);
3742
-        elseif (is_array($error))
3743
-            $errors = $error;
3744
-        elseif (is_array($errors))
3745
-            $errors = array_merge(array($error), $errors);
3746
-        else
3747
-            $errors = array_merge(array($error));
3926
+        if (is_array($error) && is_array($errors)) {
3927
+                    $errors = array_merge($error, $errors);
3928
+        } elseif (is_array($error)) {
3929
+                    $errors = $error;
3930
+        } elseif (is_array($errors)) {
3931
+                    $errors = array_merge(array($error), $errors);
3932
+        } else {
3933
+                    $errors = array_merge(array($error));
3934
+        }
3748 3935
 
3749 3936
         foreach ($errors as $msg) {
3750
-            if (empty($msg))
3751
-                continue;
3937
+            if (empty($msg)) {
3938
+                            continue;
3939
+            }
3752 3940
             if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
3753 3941
                 $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
3754 3942
             } else {                        // Mode CLI
@@ -3766,9 +3954,9 @@  discard block
 block discarded – undo
3766 3954
         $out .= "<br>\n";
3767 3955
     }
3768 3956
 
3769
-    if (empty($dolibarr_main_prod))
3770
-        print $out;
3771
-    else {
3957
+    if (empty($dolibarr_main_prod)) {
3958
+            print $out;
3959
+    } else {
3772 3960
         print $langs->trans("DolibarrHasDetectedError") . '. ';
3773 3961
         print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
3774 3962
         define("MAIN_CORE_ERROR", 1);
@@ -3791,16 +3979,18 @@  discard block
 block discarded – undo
3791 3979
 {
3792 3980
     global $langs, $conf;
3793 3981
 
3794
-    if (empty($email))
3795
-        $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
3982
+    if (empty($email)) {
3983
+            $email = $conf->global->MAIN_INFO_SOCIETE_MAIL;
3984
+    }
3796 3985
 
3797 3986
     $langs->load("errors");
3798 3987
     $now = dol_now();
3799 3988
 
3800 3989
     print '<br><div class="center login_main_message"><div class="' . $morecss . '">';
3801 3990
     print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
3802
-    if ($errormessage)
3803
-        print '<br><br>' . $errormessage;
3991
+    if ($errormessage) {
3992
+            print '<br><br>' . $errormessage;
3993
+    }
3804 3994
     if (is_array($errormessages) && count($errormessages)) {
3805 3995
         foreach ($errormessages as $mesgtoshow) {
3806 3996
             print '<br><br>' . $mesgtoshow;
@@ -4043,12 +4233,15 @@  discard block
 block discarded – undo
4043 4233
     $savtotalnboflines = $totalnboflines;
4044 4234
     $totalnboflines = abs($totalnboflines);
4045 4235
 
4046
-    if ($picto == 'setup')
4047
-        $picto = 'title_setup.png';
4048
-    if (($conf->browser->name == 'ie') && $picto == 'title_generic.png')
4049
-        $picto = 'title.gif';
4050
-    if ($limit < 0)
4051
-        $limit = $conf->liste_limit;
4236
+    if ($picto == 'setup') {
4237
+            $picto = 'title_setup.png';
4238
+    }
4239
+    if (($conf->browser->name == 'ie') && $picto == 'title_generic.png') {
4240
+            $picto = 'title.gif';
4241
+    }
4242
+    if ($limit < 0) {
4243
+            $limit = $conf->liste_limit;
4244
+    }
4052 4245
     if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
4053 4246
         $nextpage = 1;
4054 4247
     } else {
@@ -4062,11 +4255,13 @@  discard block
 block discarded – undo
4062 4255
     // Left
4063 4256
     //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
4064 4257
     print '<td class="nobordernopadding valignmiddle">';
4065
-    if ($picto && $titre)
4066
-        print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4258
+    if ($picto && $titre) {
4259
+            print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4260
+    }
4067 4261
     print '<div class="titre inline-block">' . $titre;
4068
-    if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '')
4069
-        print ' (' . $totalnboflines . ')';
4262
+    if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') {
4263
+            print ' (' . $totalnboflines . ')';
4264
+    }
4070 4265
     print '</div></td>';
4071 4266
 
4072 4267
     // Center
@@ -4076,10 +4271,12 @@  discard block
 block discarded – undo
4076 4271
 
4077 4272
     // Right
4078 4273
     print '<td class="nobordernopadding valignmiddle" align="right">';
4079
-    if ($sortfield)
4080
-        $options .= "&sortfield=" . urlencode($sortfield);
4081
-    if ($sortorder)
4082
-        $options .= "&sortorder=" . urlencode($sortorder);
4274
+    if ($sortfield) {
4275
+            $options .= "&sortfield=" . urlencode($sortfield);
4276
+    }
4277
+    if ($sortorder) {
4278
+            $options .= "&sortorder=" . urlencode($sortorder);
4279
+    }
4083 4280
     // Show navigation bar
4084 4281
     $pagelist = '';
4085 4282
     if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
@@ -4087,10 +4284,11 @@  discard block
 block discarded – undo
4087 4284
             // Define nb of extra page links before and after selected page + ... + first or last
4088 4285
             $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 1);
4089 4286
 
4090
-            if ($limit > 0)
4091
-                $nbpages = ceil($totalnboflines / $limit);
4092
-            else
4093
-                $nbpages = 1;
4287
+            if ($limit > 0) {
4288
+                            $nbpages = ceil($totalnboflines / $limit);
4289
+            } else {
4290
+                            $nbpages = 1;
4291
+            }
4094 4292
             $cpt = ($page - $maxnbofpage);
4095 4293
             if ($cpt < 0) {
4096 4294
                 $cpt = 0;
@@ -4098,10 +4296,11 @@  discard block
 block discarded – undo
4098 4296
 
4099 4297
             if ($cpt >= 1) {
4100 4298
                 $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>';
4101
-                if ($cpt > 2)
4102
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4103
-                else if ($cpt == 2)
4104
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4299
+                if ($cpt > 2) {
4300
+                                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4301
+                } else if ($cpt == 2) {
4302
+                                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4303
+                }
4105 4304
             }
4106 4305
 
4107 4306
             do {
@@ -4114,14 +4313,14 @@  discard block
 block discarded – undo
4114 4313
             } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage);
4115 4314
 
4116 4315
             if ($cpt < $nbpages) {
4117
-                if ($cpt < $nbpages - 2)
4118
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4119
-                else if ($cpt == $nbpages - 2)
4120
-                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4316
+                if ($cpt < $nbpages - 2) {
4317
+                                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4318
+                } else if ($cpt == $nbpages - 2) {
4319
+                                    $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4320
+                }
4121 4321
                 $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>';
4122 4322
             }
4123
-        }
4124
-        else {
4323
+        } else {
4125 4324
             $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>";
4126 4325
         }
4127 4326
     }
@@ -4157,18 +4356,21 @@  discard block
 block discarded – undo
4157 4356
         $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
4158 4357
         //$pagesizechoices.=',0:'.$langs->trans("All");     // Not yet supported
4159 4358
         //$pagesizechoices.=',2:2';
4160
-        if (!empty($conf->global->MAIN_PAGESIZE_CHOICES))
4161
-            $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
4359
+        if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) {
4360
+                    $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
4361
+        }
4162 4362
 
4163 4363
         print '<li class="pagination">';
4164 4364
         print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">';
4165 4365
         $tmpchoice = explode(',', $pagesizechoices);
4166 4366
         $tmpkey = $limit . ':' . $limit;
4167
-        if (!in_array($tmpkey, $tmpchoice))
4168
-            $tmpchoice[] = $tmpkey;
4367
+        if (!in_array($tmpkey, $tmpchoice)) {
4368
+                    $tmpchoice[] = $tmpkey;
4369
+        }
4169 4370
         $tmpkey = $conf->liste_limit . ':' . $conf->liste_limit;
4170
-        if (!in_array($tmpkey, $tmpchoice))
4171
-            $tmpchoice[] = $tmpkey;
4371
+        if (!in_array($tmpkey, $tmpchoice)) {
4372
+                    $tmpchoice[] = $tmpkey;
4373
+        }
4172 4374
         asort($tmpchoice, SORT_NUMERIC);
4173 4375
         $found = false;
4174 4376
         foreach ($tmpchoice as $val) {
@@ -4244,14 +4446,15 @@  discard block
 block discarded – undo
4244 4446
     }
4245 4447
 
4246 4448
     // If rate is '9/9/9' we don't change it.  If rate is '9.000' we apply price()
4247
-    if (!preg_match('/\//', $rate))
4248
-        $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4249
-    else {
4449
+    if (!preg_match('/\//', $rate)) {
4450
+            $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4451
+    } else {
4250 4452
         // TODO Split on / and output with a price2num to have clean numbers without ton of 000.
4251 4453
         $ret = $rate . ($addpercent ? '%' : '');
4252 4454
     }
4253
-    if (($info_bits & 1) && $usestarfornpr >= 0)
4254
-        $ret .= ' *';
4455
+    if (($info_bits & 1) && $usestarfornpr >= 0) {
4456
+            $ret .= ' *';
4457
+    }
4255 4458
     $ret .= $morelabel;
4256 4459
     return $ret;
4257 4460
 }
@@ -4276,11 +4479,14 @@  discard block
 block discarded – undo
4276 4479
     global $langs, $conf;
4277 4480
 
4278 4481
     // Clean parameters
4279
-    if (empty($amount))
4280
-        $amount = 0; // To have a numeric value if amount not defined or = ''
4482
+    if (empty($amount)) {
4483
+            $amount = 0;
4484
+    }
4485
+    // To have a numeric value if amount not defined or = ''
4281 4486
     $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)
4282
-    if ($rounding < 0)
4283
-        $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
4487
+    if ($rounding < 0) {
4488
+            $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT);
4489
+    }
4284 4490
     $nbdecimal = $rounding;
4285 4491
 
4286 4492
     // Output separators by default (french)
@@ -4288,17 +4494,21 @@  discard block
 block discarded – undo
4288 4494
     $thousand = ' ';
4289 4495
 
4290 4496
     // If $outlangs not forced, we use use language
4291
-    if (!is_object($outlangs))
4292
-        $outlangs = $langs;
4293
-
4294
-    if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
4295
-        $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
4296
-    if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
4297
-        $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
4298
-    if ($thousand == 'None')
4299
-        $thousand = '';
4300
-    else if ($thousand == 'Space')
4301
-        $thousand = ' ';
4497
+    if (!is_object($outlangs)) {
4498
+            $outlangs = $langs;
4499
+    }
4500
+
4501
+    if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
4502
+            $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
4503
+    }
4504
+    if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
4505
+            $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
4506
+    }
4507
+    if ($thousand == 'None') {
4508
+            $thousand = '';
4509
+    } else if ($thousand == 'Space') {
4510
+            $thousand = ' ';
4511
+    }
4302 4512
     //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4303 4513
     //print "amount=".$amount."-";
4304 4514
     $amount = str_replace(',', '.', $amount); // should be useless
@@ -4310,8 +4520,9 @@  discard block
 block discarded – undo
4310 4520
     $end = '';
4311 4521
 
4312 4522
     // We increase nbdecimal if there is more decimal than asked (to not loose information)
4313
-    if (dol_strlen($decpart) > $nbdecimal)
4314
-        $nbdecimal = dol_strlen($decpart);
4523
+    if (dol_strlen($decpart) > $nbdecimal) {
4524
+            $nbdecimal = dol_strlen($decpart);
4525
+    }
4315 4526
     // Si on depasse max
4316 4527
     if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) {
4317 4528
         $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN;
@@ -4322,8 +4533,9 @@  discard block
 block discarded – undo
4322 4533
     }
4323 4534
 
4324 4535
     // If force rounding
4325
-    if ($forcerounding >= 0)
4326
-        $nbdecimal = $forcerounding;
4536
+    if ($forcerounding >= 0) {
4537
+            $nbdecimal = $forcerounding;
4538
+    }
4327 4539
 
4328 4540
     // Format number
4329 4541
     $output = number_format($amount, $nbdecimal, $dec, $thousand);
@@ -4334,13 +4546,14 @@  discard block
 block discarded – undo
4334 4546
     // Add symbol of currency if requested
4335 4547
     $cursymbolbefore = $cursymbolafter = '';
4336 4548
     if ($currency_code) {
4337
-        if ($currency_code == 'auto')
4338
-            $currency_code = $conf->currency;
4549
+        if ($currency_code == 'auto') {
4550
+                    $currency_code = $conf->currency;
4551
+        }
4339 4552
 
4340 4553
         $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY');
4341
-        if (in_array($currency_code, $listofcurrenciesbefore))
4342
-            $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4343
-        else {
4554
+        if (in_array($currency_code, $listofcurrenciesbefore)) {
4555
+                    $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4556
+        } else {
4344 4557
             $tmpcur = $outlangs->getCurrencySymbol($currency_code);
4345 4558
             $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur);
4346 4559
         }
@@ -4374,14 +4587,17 @@  discard block
 block discarded – undo
4374 4587
     // Decimal delimiter for PHP and database SQL requests must be '.'
4375 4588
     $dec = ',';
4376 4589
     $thousand = ' ';
4377
-    if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
4378
-        $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
4379
-    if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
4380
-        $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
4381
-    if ($thousand == 'None')
4382
-        $thousand = '';
4383
-    elseif ($thousand == 'Space')
4384
-        $thousand = ' ';
4590
+    if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
4591
+            $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
4592
+    }
4593
+    if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
4594
+            $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
4595
+    }
4596
+    if ($thousand == 'None') {
4597
+            $thousand = '';
4598
+    } elseif ($thousand == 'Space') {
4599
+            $thousand = ' ';
4600
+    }
4385 4601
     //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4386 4602
     // Convert value to universal number format (no thousand separator, '.' as decimal separator)
4387 4603
     if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format
@@ -4397,8 +4613,10 @@  discard block
 block discarded – undo
4397 4613
         }
4398 4614
         //print "QQ".$amount.'<br>';
4399 4615
         // Now make replace (the main goal of function)
4400
-        if ($thousand != ',' && $thousand != '.')
4401
-            $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4616
+        if ($thousand != ',' && $thousand != '.') {
4617
+                    $amount = str_replace(',', '.', $amount);
4618
+        }
4619
+        // To accept 2 notations for french users
4402 4620
         $amount = str_replace(' ', '', $amount);  // To avoid spaces
4403 4621
         $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4404 4622
         $amount = str_replace($dec, '.', $amount);
@@ -4407,19 +4625,23 @@  discard block
 block discarded – undo
4407 4625
     // Now, make a rounding if required
4408 4626
     if ($rounding) {
4409 4627
         $nbofdectoround = '';
4410
-        if ($rounding == 'MU')
4411
-            $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
4412
-        elseif ($rounding == 'MT')
4413
-            $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
4414
-        elseif ($rounding == 'MS')
4415
-            $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
4416
-        elseif (is_numeric($rounding))
4417
-            $nbofdectoround = $rounding;
4628
+        if ($rounding == 'MU') {
4629
+                    $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
4630
+        } elseif ($rounding == 'MT') {
4631
+                    $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
4632
+        } elseif ($rounding == 'MS') {
4633
+                    $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
4634
+        } elseif (is_numeric($rounding)) {
4635
+                    $nbofdectoround = $rounding;
4636
+        }
4418 4637
         //print "RR".$amount.' - '.$nbofdectoround.'<br>';
4419
-        if (dol_strlen($nbofdectoround))
4420
-            $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0.
4421
-        else
4422
-            return 'ErrorBadParameterProvidedToFunction';
4638
+        if (dol_strlen($nbofdectoround)) {
4639
+                    $amount = round($amount, $nbofdectoround);
4640
+        }
4641
+        // $nbofdectoround can be 0.
4642
+        else {
4643
+                    return 'ErrorBadParameterProvidedToFunction';
4644
+        }
4423 4645
         //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
4424 4646
         // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
4425 4647
         // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup.
@@ -4433,8 +4655,10 @@  discard block
 block discarded – undo
4433 4655
         //print "TT".$amount.'<br>';
4434 4656
         // Always make replace because each math function (like round) replace
4435 4657
         // with local values and we want a number that has a SQL string format x.y
4436
-        if ($thousand != ',' && $thousand != '.')
4437
-            $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4658
+        if ($thousand != ',' && $thousand != '.') {
4659
+                    $amount = str_replace(',', '.', $amount);
4660
+        }
4661
+        // To accept 2 notations for french users
4438 4662
         $amount = str_replace(' ', '', $amount);  // To avoid spaces
4439 4663
         $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4440 4664
         $amount = str_replace($dec, '.', $amount);
@@ -4493,8 +4717,9 @@  discard block
 block discarded – undo
4493 4717
 {
4494 4718
     global $db, $conf, $mysoc;
4495 4719
 
4496
-    if (empty($thirdparty_seller) || !is_object($thirdparty_seller))
4497
-        $thirdparty_seller = $mysoc;
4720
+    if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
4721
+            $thirdparty_seller = $mysoc;
4722
+    }
4498 4723
 
4499 4724
     dol_syslog("get_localtax tva=" . $vatrate . " local=" . $local . " thirdparty_buyer id=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '') . "/country_code=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '') . " thirdparty_seller id=" . $thirdparty_seller->id . "/country_code=" . $thirdparty_seller->country_code . " thirdparty_seller localtax1_assuj=" . $thirdparty_seller->localtax1_assuj . "  thirdparty_seller localtax2_assuj=" . $thirdparty_seller->localtax2_assuj);
4500 4725
 
@@ -4512,37 +4737,43 @@  discard block
 block discarded – undo
4512 4737
     // Some test to guess with no need to make database access
4513 4738
     if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax
4514 4739
         if ($local == 1) {
4515
-            if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0")
4516
-                return 0;
4517
-            if ($thirdparty_seller->id == $mysoc->id) {
4518
-                if (!$thirdparty_buyer->localtax1_assuj)
4519
-                    return 0;
4740
+            if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") {
4741
+                            return 0;
4520 4742
             }
4521
-            else {
4522
-                if (!$thirdparty_seller->localtax1_assuj)
4523
-                    return 0;
4743
+            if ($thirdparty_seller->id == $mysoc->id) {
4744
+                if (!$thirdparty_buyer->localtax1_assuj) {
4745
+                                    return 0;
4746
+                }
4747
+            } else {
4748
+                if (!$thirdparty_seller->localtax1_assuj) {
4749
+                                    return 0;
4750
+                }
4524 4751
             }
4525 4752
         }
4526 4753
 
4527 4754
         if ($local == 2) {
4528 4755
             //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0;
4529
-            if (!$mysoc->localtax2_assuj)
4530
-                return 0;  // If main vat is 0, IRPF may be different than 0.
4756
+            if (!$mysoc->localtax2_assuj) {
4757
+                            return 0;
4758
+            }
4759
+            // If main vat is 0, IRPF may be different than 0.
4531 4760
             if ($thirdparty_seller->id == $mysoc->id) {
4532
-                if (!$thirdparty_buyer->localtax2_assuj)
4533
-                    return 0;
4761
+                if (!$thirdparty_buyer->localtax2_assuj) {
4762
+                                    return 0;
4763
+                }
4764
+            } else {
4765
+                if (!$thirdparty_seller->localtax2_assuj) {
4766
+                                    return 0;
4767
+                }
4534 4768
             }
4535
-            else {
4536
-                if (!$thirdparty_seller->localtax2_assuj)
4769
+        }
4770
+    } else {
4771
+        if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
4772
+                    return 0;
4773
+        }
4774
+        if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
4537 4775
                     return 0;
4538
-            }
4539 4776
         }
4540
-    }
4541
-    else {
4542
-        if ($local == 1 && !$thirdparty_seller->localtax1_assuj)
4543
-            return 0;
4544
-        if ($local == 2 && !$thirdparty_seller->localtax2_assuj)
4545
-            return 0;
4546 4777
     }
4547 4778
 
4548 4779
     // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on.
@@ -4584,19 +4815,23 @@  discard block
 block discarded – undo
4584 4815
     $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4585 4816
     $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'";
4586 4817
     $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4587
-    if ($vatratecode)
4588
-        $sql .= " AND t.code ='" . $vatratecode . "'";  // If we have the code, we use it in priority
4589
-    else
4590
-        $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4818
+    if ($vatratecode) {
4819
+            $sql .= " AND t.code ='" . $vatratecode . "'";
4820
+    }
4821
+    // If we have the code, we use it in priority
4822
+    else {
4823
+            $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4824
+    }
4591 4825
     dol_syslog("get_localtax", LOG_DEBUG);
4592 4826
     $resql = $db->query($sql);
4593 4827
 
4594 4828
     if ($resql) {
4595 4829
         $obj = $db->fetch_object($resql);
4596
-        if ($local == 1)
4597
-            return $obj->localtax1;
4598
-        elseif ($local == 2)
4599
-            return $obj->localtax2;
4830
+        if ($local == 1) {
4831
+                    return $obj->localtax1;
4832
+        } elseif ($local == 2) {
4833
+                    return $obj->localtax2;
4834
+        }
4600 4835
     }
4601 4836
 
4602 4837
     return 0;
@@ -4642,10 +4877,11 @@  discard block
 block discarded – undo
4642 4877
     $resql = $db->query($sql);
4643 4878
     if ($resql) {
4644 4879
         $obj = $db->fetch_object($resql);
4645
-        if ($local == 1)
4646
-            return $obj->localtax1;
4647
-        elseif ($local == 2)
4648
-            return $obj->localtax2;
4880
+        if ($local == 1) {
4881
+                    return $obj->localtax1;
4882
+        } elseif ($local == 2) {
4883
+                    return $obj->localtax2;
4884
+        }
4649 4885
     }
4650 4886
 
4651 4887
     return 0;
@@ -4671,9 +4907,9 @@  discard block
 block discarded – undo
4671 4907
     // Search local taxes
4672 4908
     $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy";
4673 4909
     $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4674
-    if ($firstparamisid)
4675
-        $sql .= " WHERE t.rowid = " . (int) $vatrate;
4676
-    else {
4910
+    if ($firstparamisid) {
4911
+            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4912
+    } else {
4677 4913
         $vatratecleaned = $vatrate;
4678 4914
         $vatratecode = '';
4679 4915
         if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "xx (yy)"
@@ -4686,19 +4922,22 @@  discard block
 block discarded – undo
4686 4922
           else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */
4687 4923
         $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4688 4924
         $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4689
-        if ($vatratecode)
4690
-            $sql .= " AND t.code = '" . $vatratecode . "'";
4925
+        if ($vatratecode) {
4926
+                    $sql .= " AND t.code = '" . $vatratecode . "'";
4927
+        }
4691 4928
     }
4692 4929
 
4693 4930
     $resql = $db->query($sql);
4694 4931
     if ($resql) {
4695 4932
         $obj = $db->fetch_object($resql);
4696
-        if ($obj)
4697
-            return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy);
4698
-        else
4699
-            return array();
4700
-    } else
4701
-        dol_print_error($db);
4933
+        if ($obj) {
4934
+                    return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy);
4935
+        } else {
4936
+                    return array();
4937
+        }
4938
+    } else {
4939
+            dol_print_error($db);
4940
+    }
4702 4941
 
4703 4942
     return array();
4704 4943
 }
@@ -4728,9 +4967,9 @@  discard block
 block discarded – undo
4728 4967
     // Search local taxes
4729 4968
     $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
4730 4969
     $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4731
-    if ($firstparamisid)
4732
-        $sql .= " WHERE t.rowid = " . (int) $vatrate;
4733
-    else {
4970
+    if ($firstparamisid) {
4971
+            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4972
+    } else {
4734 4973
         $vatratecleaned = $vatrate;
4735 4974
         $vatratecode = '';
4736 4975
         if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "x.x (yy)"
@@ -4739,13 +4978,17 @@  discard block
 block discarded – undo
4739 4978
         }
4740 4979
 
4741 4980
         $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4742
-        if ($mysoc->country_code == 'ES')
4743
-            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";    // local tax in spain use the buyer country ??
4744
-        else
4745
-            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4981
+        if ($mysoc->country_code == 'ES') {
4982
+                    $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
4983
+        }
4984
+        // local tax in spain use the buyer country ??
4985
+        else {
4986
+                    $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4987
+        }
4746 4988
         $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4747
-        if ($vatratecode)
4748
-            $sql .= " AND t.code = '" . $vatratecode . "'";
4989
+        if ($vatratecode) {
4990
+                    $sql .= " AND t.code = '" . $vatratecode . "'";
4991
+        }
4749 4992
     }
4750 4993
 
4751 4994
     $resql = $db->query($sql);
@@ -4791,17 +5034,17 @@  discard block
 block discarded – undo
4791 5034
             if ($idprodfournprice > 0) {     // We want vat for product for a "supplier" object
4792 5035
                 $product->get_buyprice($idprodfournprice, 0, 0, 0);
4793 5036
                 $ret = $product->vatrate_supplier;
4794
-                if ($product->default_vat_code)
4795
-                    $ret .= ' (' . $product->default_vat_code . ')';
4796
-            }
4797
-            else {
5037
+                if ($product->default_vat_code) {
5038
+                                    $ret .= ' (' . $product->default_vat_code . ')';
5039
+                }
5040
+            } else {
4798 5041
                 $ret = $product->tva_tx;    // Default vat of product we defined
4799
-                if ($product->default_vat_code)
4800
-                    $ret .= ' (' . $product->default_vat_code . ')';
5042
+                if ($product->default_vat_code) {
5043
+                                    $ret .= ' (' . $product->default_vat_code . ')';
5044
+                }
4801 5045
             }
4802 5046
             $found = 1;
4803
-        }
4804
-        else {
5047
+        } else {
4805 5048
             // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
4806 5049
             // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on
4807 5050
         }
@@ -4821,14 +5064,18 @@  discard block
 block discarded – undo
4821 5064
                 $obj = $db->fetch_object($resql);
4822 5065
                 if ($obj) {
4823 5066
                     $ret = $obj->vat_rate;
4824
-                    if ($obj->default_vat_code)
4825
-                        $ret .= ' (' . $obj->default_vat_code . ')';
5067
+                    if ($obj->default_vat_code) {
5068
+                                            $ret .= ' (' . $obj->default_vat_code . ')';
5069
+                    }
4826 5070
                 }
4827 5071
                 $db->free($sql);
4828
-            } else
4829
-                dol_print_error($db);
4830
-        } else
4831
-            $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;    // Forced value if autodetect fails
5072
+            } else {
5073
+                            dol_print_error($db);
5074
+            }
5075
+        } else {
5076
+                    $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
5077
+        }
5078
+        // Forced value if autodetect fails
4832 5079
     }
4833 5080
 
4834 5081
     dol_syslog("get_product_vat_for_country: ret=" . $ret);
@@ -4883,13 +5130,15 @@  discard block
 block discarded – undo
4883 5130
         if ($resql) {
4884 5131
             $obj = $db->fetch_object($resql);
4885 5132
             if ($obj) {
4886
-                if ($local == 1)
4887
-                    $ret = $obj->localtax1;
4888
-                elseif ($local == 2)
4889
-                    $ret = $obj->localtax2;
5133
+                if ($local == 1) {
5134
+                                    $ret = $obj->localtax1;
5135
+                } elseif ($local == 2) {
5136
+                                    $ret = $obj->localtax2;
5137
+                }
4890 5138
             }
4891
-        } else
4892
-            dol_print_error($db);
5139
+        } else {
5140
+                    dol_print_error($db);
5141
+        }
4893 5142
     }
4894 5143
 
4895 5144
     dol_syslog("get_product_localtax_for_country: ret=" . $ret);
@@ -4992,15 +5241,16 @@  discard block
 block discarded – undo
4992 5241
     global $db;
4993 5242
 
4994 5243
     if ($idprodfournprice > 0) {
4995
-        if (!class_exists('ProductFournisseur'))
4996
-            require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5244
+        if (!class_exists('ProductFournisseur')) {
5245
+                    require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5246
+        }
4997 5247
         $prodprice = new ProductFournisseur($db);
4998 5248
         $prodprice->fetch_product_fournisseur_price($idprodfournprice);
4999 5249
         return $prodprice->fourn_tva_npr;
5000
-    }
5001
-    elseif ($idprod > 0) {
5002
-        if (!class_exists('Product'))
5003
-            require_once DOL_BASE_PATH . 'product/class/product.class.php';
5250
+    } elseif ($idprod > 0) {
5251
+        if (!class_exists('Product')) {
5252
+                    require_once DOL_BASE_PATH . 'product/class/product.class.php';
5253
+        }
5004 5254
         $prod = new Product($db);
5005 5255
         $prod->fetch($idprod);
5006 5256
         return $prod->tva_npr;
@@ -5026,30 +5276,35 @@  discard block
 block discarded – undo
5026 5276
 {
5027 5277
     global $mysoc;
5028 5278
 
5029
-    if (!is_object($thirdparty_seller))
5030
-        return -1;
5031
-    if (!is_object($thirdparty_buyer))
5032
-        return -1;
5279
+    if (!is_object($thirdparty_seller)) {
5280
+            return -1;
5281
+    }
5282
+    if (!is_object($thirdparty_buyer)) {
5283
+            return -1;
5284
+    }
5033 5285
 
5034 5286
     if ($local == 1) { // Localtax 1
5035 5287
         if ($mysoc->country_code == 'ES') {
5036
-            if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj)
5037
-                return 0;
5038
-        }
5039
-        else {
5288
+            if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
5289
+                            return 0;
5290
+            }
5291
+        } else {
5040 5292
             // Si vendeur non assujeti a Localtax1, localtax1 par default=0
5041
-            if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj)
5042
-                return 0;
5043
-            if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off')
5044
-                return 0;
5293
+            if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
5294
+                            return 0;
5295
+            }
5296
+            if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') {
5297
+                            return 0;
5298
+            }
5045 5299
         }
5046
-    }
5047
-    elseif ($local == 2) { //I Localtax 2
5300
+    } elseif ($local == 2) { //I Localtax 2
5048 5301
         // Si vendeur non assujeti a Localtax2, localtax2 par default=0
5049
-        if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj)
5050
-            return 0;
5051
-        if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off')
5052
-            return 0;
5302
+        if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
5303
+                    return 0;
5304
+        }
5305
+        if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') {
5306
+                    return 0;
5307
+        }
5053 5308
     }
5054 5309
 
5055 5310
     if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
@@ -5074,31 +5329,38 @@  discard block
 block discarded – undo
5074 5329
     $classname = '';
5075 5330
     if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') {  // A mettre avant test sur no a cause du == 0
5076 5331
         $result = $langs->trans('yes');
5077
-        if ($case == 1 || $case == 3)
5078
-            $result = $langs->trans("Yes");
5079
-        if ($case == 2)
5080
-            $result = '<input type="checkbox" value="1" checked disabled>';
5081
-        if ($case == 3)
5082
-            $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5332
+        if ($case == 1 || $case == 3) {
5333
+                    $result = $langs->trans("Yes");
5334
+        }
5335
+        if ($case == 2) {
5336
+                    $result = '<input type="checkbox" value="1" checked disabled>';
5337
+        }
5338
+        if ($case == 3) {
5339
+                    $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5340
+        }
5083 5341
 
5084 5342
         $classname = 'ok';
5085
-    }
5086
-    elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
5343
+    } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
5087 5344
         $result = $langs->trans("no");
5088
-        if ($case == 1 || $case == 3)
5089
-            $result = $langs->trans("No");
5090
-        if ($case == 2)
5091
-            $result = '<input type="checkbox" value="0" disabled>';
5092
-        if ($case == 3)
5093
-            $result = '<input type="checkbox" value="0" disabled> ' . $result;
5094
-
5095
-        if ($color == 2)
5096
-            $classname = 'ok';
5097
-        else
5098
-            $classname = 'error';
5099
-    }
5100
-    if ($color)
5101
-        return '<font class="' . $classname . '">' . $result . '</font>';
5345
+        if ($case == 1 || $case == 3) {
5346
+                    $result = $langs->trans("No");
5347
+        }
5348
+        if ($case == 2) {
5349
+                    $result = '<input type="checkbox" value="0" disabled>';
5350
+        }
5351
+        if ($case == 3) {
5352
+                    $result = '<input type="checkbox" value="0" disabled> ' . $result;
5353
+        }
5354
+
5355
+        if ($color == 2) {
5356
+                    $classname = 'ok';
5357
+        } else {
5358
+                    $classname = 'error';
5359
+        }
5360
+    }
5361
+    if ($color) {
5362
+            return '<font class="' . $classname . '">' . $result . '</font>';
5363
+    }
5102 5364
     return $result;
5103 5365
 }
5104 5366
 
@@ -5124,23 +5386,27 @@  discard block
 block discarded – undo
5124 5386
     $path = '';
5125 5387
 
5126 5388
     $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
5127
-    if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
5128
-        $arrayforoldpath[] = 'product';
5389
+    if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
5390
+            $arrayforoldpath[] = 'product';
5391
+    }
5129 5392
     if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
5130 5393
         // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided.
5131
-        if (empty($alpha))
5132
-            $num = preg_replace('/([^0-9])/i', '', $num);
5133
-        else
5134
-            $num = preg_replace('/^.*\-/i', '', $num);
5394
+        if (empty($alpha)) {
5395
+                    $num = preg_replace('/([^0-9])/i', '', $num);
5396
+        } else {
5397
+                    $num = preg_replace('/^.*\-/i', '', $num);
5398
+        }
5135 5399
         $num = substr("000" . $num, -$level);
5136
-        if ($level == 1)
5137
-            $path = substr($num, 0, 1);
5138
-        if ($level == 2)
5139
-            $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5140
-        if ($level == 3)
5141
-            $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5142
-    }
5143
-    else {
5400
+        if ($level == 1) {
5401
+                    $path = substr($num, 0, 1);
5402
+        }
5403
+        if ($level == 2) {
5404
+                    $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5405
+        }
5406
+        if ($level == 3) {
5407
+                    $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5408
+        }
5409
+    } else {
5144 5410
         // TODO
5145 5411
         // We will enhance here a common way of forging path for document storage
5146 5412
         // Here, object->id, object->ref and modulepart are required.
@@ -5151,8 +5417,9 @@  discard block
 block discarded – undo
5151 5417
         }
5152 5418
     }
5153 5419
 
5154
-    if (empty($withoutslash) && !empty($path))
5155
-        $path .= '/';
5420
+    if (empty($withoutslash) && !empty($path)) {
5421
+            $path .= '/';
5422
+    }
5156 5423
 
5157 5424
     return $path;
5158 5425
 }
@@ -5172,8 +5439,9 @@  discard block
 block discarded – undo
5172 5439
     dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
5173 5440
 
5174 5441
     $dir_osencoded = dol_osencode($dir);
5175
-    if (@is_dir($dir_osencoded))
5176
-        return 0;
5442
+    if (@is_dir($dir_osencoded)) {
5443
+            return 0;
5444
+    }
5177 5445
 
5178 5446
     $nberr = 0;
5179 5447
     $nbcreated = 0;
@@ -5188,12 +5456,15 @@  discard block
 block discarded – undo
5188 5456
     $cdir = explode("/", $dir);
5189 5457
     $num = count($cdir);
5190 5458
     for ($i = 0; $i < $num; $i++) {
5191
-        if ($i > 0)
5192
-            $ccdir .= '/' . $cdir[$i];
5193
-        else
5194
-            $ccdir .= $cdir[$i];
5195
-        if (preg_match("/^.:$/", $ccdir, $regs))
5196
-            continue; // Si chemin Windows incomplet, on poursuit par rep suivant
5459
+        if ($i > 0) {
5460
+                    $ccdir .= '/' . $cdir[$i];
5461
+        } else {
5462
+                    $ccdir .= $cdir[$i];
5463
+        }
5464
+        if (preg_match("/^.:$/", $ccdir, $regs)) {
5465
+                    continue;
5466
+        }
5467
+        // Si chemin Windows incomplet, on poursuit par rep suivant
5197 5468
 
5198 5469
 
5199 5470
 
@@ -5277,8 +5548,9 @@  discard block
 block discarded – undo
5277 5548
  */
5278 5549
 function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0)
5279 5550
 {
5280
-    if ($removelinefeed == 2)
5281
-        $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
5551
+    if ($removelinefeed == 2) {
5552
+            $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
5553
+    }
5282 5554
     $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
5283 5555
 
5284 5556
     if ($strip_tags) {
@@ -5295,8 +5567,9 @@  discard block
 block discarded – undo
5295 5567
     $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
5296 5568
 
5297 5569
     // Supprime aussi les retours
5298
-    if ($removelinefeed == 1)
5299
-        $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
5570
+    if ($removelinefeed == 1) {
5571
+            $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
5572
+    }
5300 5573
 
5301 5574
     // et les espaces doubles
5302 5575
     while (strpos($temp, "  ")) {
@@ -5382,18 +5655,21 @@  discard block
 block discarded – undo
5382 5655
         if ($charset == 'UTF-8') {
5383 5656
             $pattern = '/(<br[^>]*>)/Uu';
5384 5657
         } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5385
-        else
5386
-            $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5658
+        else {
5659
+                    $pattern = '/(<br[^>]*>)/U';
5660
+        }
5661
+        // /U is to have UNGREEDY regex to limit to one html tag.
5387 5662
         $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5388 5663
 
5389 5664
         $firstline = '';
5390 5665
         $i = 0;
5391 5666
         $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator
5392 5667
         while (($i < $nba) && ($i < ($nboflines * 2))) {
5393
-            if ($i % 2 == 0)
5394
-                $firstline .= $a[$i];
5395
-            elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1)))
5396
-                $firstline .= ($ishtml ? "<br>\n" : "\n");
5668
+            if ($i % 2 == 0) {
5669
+                            $firstline .= $a[$i];
5670
+            } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
5671
+                            $firstline .= ($ishtml ? "<br>\n" : "\n");
5672
+            }
5397 5673
             $i++;
5398 5674
         }
5399 5675
         unset($a);
@@ -5442,15 +5718,18 @@  discard block
 block discarded – undo
5442 5718
     $newstring = $stringtoencode;
5443 5719
     if (dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
5444 5720
         $newstring = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
5445
-        if ($removelasteolbr)
5446
-            $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
5721
+        if ($removelasteolbr) {
5722
+                    $newstring = preg_replace('/<br>$/i', '', $newstring);
5723
+        }
5724
+        // Remove last <br> (remove only last one)
5447 5725
         $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
5448 5726
         $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding
5449 5727
         $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
5450
-    }
5451
-    else {
5452
-        if ($removelasteolbr)
5453
-            $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
5728
+    } else {
5729
+        if ($removelasteolbr) {
5730
+                    $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring);
5731
+        }
5732
+        // Remove last \n (may remove several)
5454 5733
         $newstring = dol_nl2br(dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode);
5455 5734
     }
5456 5735
     // Other substitutions that htmlentities does not do
@@ -5552,8 +5831,9 @@  discard block
 block discarded – undo
5552 5831
  */
5553 5832
 function dol_nboflines($s, $maxchar = 0)
5554 5833
 {
5555
-    if ($s == '')
5556
-        return 0;
5834
+    if ($s == '') {
5835
+            return 0;
5836
+    }
5557 5837
     $arraystring = explode("\n", $s);
5558 5838
     $nb = count($arraystring);
5559 5839
 
@@ -5572,15 +5852,18 @@  discard block
 block discarded – undo
5572 5852
 function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8')
5573 5853
 {
5574 5854
     $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
5575
-    if (dol_textishtml($text))
5576
-        $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
5855
+    if (dol_textishtml($text)) {
5856
+            $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
5857
+    }
5577 5858
 
5578 5859
     $text = strtr($text, $repTable);
5579 5860
     if ($charset == 'UTF-8') {
5580 5861
         $pattern = '/(<br[^>]*>)/Uu';
5581 5862
     } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5582
-    else
5583
-        $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5863
+    else {
5864
+            $pattern = '/(<br[^>]*>)/U';
5865
+    }
5866
+    // /U is to have UNGREEDY regex to limit to one html tag.
5584 5867
     $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5585 5868
 
5586 5869
     $nblines = (int) floor((count($a) + 1) / 2);
@@ -5627,39 +5910,47 @@  discard block
 block discarded – undo
5627 5910
 function dol_textishtml($msg, $option = 0)
5628 5911
 {
5629 5912
     if ($option == 1) {
5630
-        if (preg_match('/<html/i', $msg))
5631
-            return true;
5632
-        elseif (preg_match('/<body/i', $msg))
5633
-            return true;
5634
-        elseif (preg_match('/<br/i', $msg))
5635
-            return true;
5913
+        if (preg_match('/<html/i', $msg)) {
5914
+                    return true;
5915
+        } elseif (preg_match('/<body/i', $msg)) {
5916
+                    return true;
5917
+        } elseif (preg_match('/<br/i', $msg)) {
5918
+                    return true;
5919
+        }
5636 5920
         return false;
5637
-    }
5638
-    else {
5639
-        if (preg_match('/<html/i', $msg))
5640
-            return true;
5641
-        elseif (preg_match('/<body/i', $msg))
5642
-            return true;
5643
-        elseif (preg_match('/<(b|em|i|u)>/i', $msg))
5644
-            return true;
5645
-        elseif (preg_match('/<br\/>/i', $msg))
5646
-            return true;
5647
-        elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg))
5648
-            return true;
5649
-        elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
5650
-            return true;
5651
-        elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
5652
-            return true;
5653
-        elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg))
5654
-            return true; // must accept <img src="http://example.com/aaa.png" />
5655
-        elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg))
5656
-            return true; // must accept <a href="http://example.com/aaa.png" />
5657
-        elseif (preg_match('/<h[0-9]>/i', $msg))
5658
-            return true;
5659
-        elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
5660
-            return true;    // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5661
-        elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
5662
-            return true;    // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5921
+    } else {
5922
+        if (preg_match('/<html/i', $msg)) {
5923
+                    return true;
5924
+        } elseif (preg_match('/<body/i', $msg)) {
5925
+                    return true;
5926
+        } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) {
5927
+                    return true;
5928
+        } elseif (preg_match('/<br\/>/i', $msg)) {
5929
+                    return true;
5930
+        } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) {
5931
+                    return true;
5932
+        } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) {
5933
+                    return true;
5934
+        } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) {
5935
+                    return true;
5936
+        } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
5937
+                    return true;
5938
+        }
5939
+        // must accept <img src="http://example.com/aaa.png" />
5940
+        elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
5941
+                    return true;
5942
+        }
5943
+        // must accept <a href="http://example.com/aaa.png" />
5944
+        elseif (preg_match('/<h[0-9]>/i', $msg)) {
5945
+                    return true;
5946
+        } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) {
5947
+                    return true;
5948
+        }
5949
+        // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5950
+        elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) {
5951
+                    return true;
5952
+        }
5953
+        // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5663 5954
 
5664 5955
         return false;
5665 5956
     }
@@ -5811,12 +6102,14 @@  discard block
 block discarded – undo
5811 6102
             $birthday = dol_print_date($object->birth, 'day');
5812 6103
 
5813 6104
             $substitutionarray['__MEMBER_ID__'] = $object->id;
5814
-            if (method_exists($object, 'getCivilityLabel'))
5815
-                $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6105
+            if (method_exists($object, 'getCivilityLabel')) {
6106
+                            $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6107
+            }
5816 6108
             $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->firstname) : $object->firstname;
5817 6109
             $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->lastname) : $object->lastname;
5818
-            if (method_exists($object, 'getFullName'))
5819
-                $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs);
6110
+            if (method_exists($object, 'getFullName')) {
6111
+                            $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs);
6112
+            }
5820 6113
             $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe;
5821 6114
             $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address;
5822 6115
             $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip;
@@ -5864,10 +6157,12 @@  discard block
 block discarded – undo
5864 6157
                 $dateplannedstart = '';
5865 6158
                 $datenextexpiration = '';
5866 6159
                 foreach ($object->lines as $line) {
5867
-                    if ($line->date_ouverture_prevue > $dateplannedstart)
5868
-                        $dateplannedstart = $line->date_ouverture_prevue;
5869
-                    if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration))
5870
-                        $datenextexpiration = $line->date_fin_prevue;
6160
+                    if ($line->date_ouverture_prevue > $dateplannedstart) {
6161
+                                            $dateplannedstart = $line->date_ouverture_prevue;
6162
+                    }
6163
+                    if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) {
6164
+                                            $datenextexpiration = $line->date_fin_prevue;
6165
+                    }
5871 6166
                 }
5872 6167
                 $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
5873 6168
                 $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
@@ -5877,8 +6172,9 @@  discard block
 block discarded – undo
5877 6172
 
5878 6173
             // Create dynamic tags for __EXTRAFIELD_FIELD__
5879 6174
             if ($object->table_element && $object->id > 0) {
5880
-                if (!is_object($extrafields))
5881
-                    $extrafields = new ExtraFields($db);
6175
+                if (!is_object($extrafields)) {
6176
+                                    $extrafields = new ExtraFields($db);
6177
+                }
5882 6178
                 $extrafields->fetch_name_optionals_label($object->table_element, true);
5883 6179
 
5884 6180
                 if ($object->fetch_optionals() > 0) {
@@ -5899,12 +6195,15 @@  discard block
 block discarded – undo
5899 6195
                 require_once DOL_BASE_PATH . '/core/lib/payments.lib.php';
5900 6196
                 $outputlangs->loadLangs(array('paypal', 'other'));
5901 6197
                 $typeforonlinepayment = 'free';
5902
-                if (is_object($object) && $object->element == 'commande')
5903
-                    $typeforonlinepayment = 'order';
5904
-                if (is_object($object) && $object->element == 'facture')
5905
-                    $typeforonlinepayment = 'invoice';
5906
-                if (is_object($object) && $object->element == 'member')
5907
-                    $typeforonlinepayment = 'member';
6198
+                if (is_object($object) && $object->element == 'commande') {
6199
+                                    $typeforonlinepayment = 'order';
6200
+                }
6201
+                if (is_object($object) && $object->element == 'facture') {
6202
+                                    $typeforonlinepayment = 'invoice';
6203
+                }
6204
+                if (is_object($object) && $object->element == 'member') {
6205
+                                    $typeforonlinepayment = 'member';
6206
+                }
5908 6207
                 $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']);
5909 6208
                 $paymenturl = $url;
5910 6209
             }
@@ -5914,16 +6213,19 @@  discard block
 block discarded – undo
5914 6213
 
5915 6214
             if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
5916 6215
                 $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
5917
-            } else
5918
-                $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
6216
+            } else {
6217
+                            $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
6218
+            }
5919 6219
             if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') {
5920 6220
                 $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
5921
-            } else
5922
-                $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
6221
+            } else {
6222
+                            $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
6223
+            }
5923 6224
             if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') {
5924 6225
                 $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
5925
-            } else
5926
-                $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
6226
+            } else {
6227
+                            $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
6228
+            }
5927 6229
         }
5928 6230
     }
5929 6231
     if (empty($exclude) || !in_array('objectamount', $exclude)) {
@@ -5933,18 +6235,22 @@  discard block
 block discarded – undo
5933 6235
         $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : '';
5934 6236
         $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : '';
5935 6237
         $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : '';
5936
-        if ($onlykey != 2 || $mysoc->useLocalTax(1))
5937
-            $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : '';
5938
-        if ($onlykey != 2 || $mysoc->useLocalTax(2))
5939
-            $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : '';
6238
+        if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
6239
+                    $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : '';
6240
+        }
6241
+        if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
6242
+                    $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : '';
6243
+        }
5940 6244
 
5941 6245
         $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : '';
5942 6246
         $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : '';
5943 6247
         $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object) ? ($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency) : price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency)) : '';
5944
-        if ($onlykey != 2 || $mysoc->useLocalTax(1))
5945
-            $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : '';
5946
-        if ($onlykey != 2 || $mysoc->useLocalTax(2))
5947
-            $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : '';
6248
+        if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
6249
+                    $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : '';
6250
+        }
6251
+        if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
6252
+                    $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : '';
6253
+        }
5948 6254
 
5949 6255
         // TODO Add keys for foreign multicurrency
5950 6256
         // For backward compatibility
@@ -6014,23 +6320,27 @@  discard block
 block discarded – undo
6014 6320
 {
6015 6321
     global $conf, $langs;
6016 6322
 
6017
-    if (!is_array($substitutionarray))
6018
-        return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6323
+    if (!is_array($substitutionarray)) {
6324
+            return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6325
+    }
6019 6326
 
6020
-    if (empty($outputlangs))
6021
-        $outputlangs = $langs;
6327
+    if (empty($outputlangs)) {
6328
+            $outputlangs = $langs;
6329
+    }
6022 6330
 
6023 6331
     // Make substitution for language keys
6024 6332
     if (is_object($outputlangs)) {
6025 6333
         while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) {
6026 6334
             $msgishtml = 0;
6027
-            if (dol_textishtml($text, 1))
6028
-                $msgishtml = 1;
6335
+            if (dol_textishtml($text, 1)) {
6336
+                            $msgishtml = 1;
6337
+            }
6029 6338
 
6030 6339
             // If key is __(TranslationKey|langfile)__, then force load of langfile.lang
6031 6340
             $tmp = explode('|', $reg[1]);
6032
-            if (!empty($tmp[1]))
6033
-                $outputlangs->load($tmp[1]);
6341
+            if (!empty($tmp[1])) {
6342
+                            $outputlangs->load($tmp[1]);
6343
+            }
6034 6344
 
6035 6345
             $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6036 6346
         }
@@ -6040,23 +6350,29 @@  discard block
 block discarded – undo
6040 6350
     // it is also converted.
6041 6351
     while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) {
6042 6352
         $msgishtml = 0;
6043
-        if (dol_textishtml($text, 1))
6044
-            $msgishtml = 1;
6353
+        if (dol_textishtml($text, 1)) {
6354
+                    $msgishtml = 1;
6355
+        }
6045 6356
 
6046 6357
         $keyfound = $reg[1];
6047
-        if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound))
6048
-            $newval = '*****forbidden*****';
6049
-        else
6050
-            $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound;
6358
+        if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) {
6359
+                    $newval = '*****forbidden*****';
6360
+        } else {
6361
+                    $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound;
6362
+        }
6051 6363
         $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
6052 6364
     }
6053 6365
 
6054 6366
     // Make substitition for array $substitutionarray
6055 6367
     foreach ($substitutionarray as $key => $value) {
6056
-        if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6057
-            $value = '';  // Protection
6058
-        if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6059
-            $value = ''; // Protection
6368
+        if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
6369
+                    $value = '';
6370
+        }
6371
+        // Protection
6372
+        if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
6373
+                    $value = '';
6374
+        }
6375
+        // Protection
6060 6376
 
6061 6377
         $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
6062 6378
     }
@@ -6102,8 +6418,9 @@  discard block
 block discarded – undo
6102 6418
         $dir = dol_buildpath($reldir, 0);
6103 6419
 
6104 6420
         // Check if directory exists
6105
-        if (!dol_is_dir($dir))
6106
-            continue;
6421
+        if (!dol_is_dir($dir)) {
6422
+                    continue;
6423
+        }
6107 6424
 
6108 6425
         $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_');
6109 6426
         foreach ($substitfiles as $substitfile) {
@@ -6115,8 +6432,9 @@  discard block
 block discarded – undo
6115 6432
                 require_once $dir . $substitfile['name'];
6116 6433
                 // Call the user's function, and only if it is defined
6117 6434
                 $function_name = $module . "_" . $callfunc;
6118
-                if (function_exists($function_name))
6119
-                    $function_name($substitutionarray, $outputlangs, $object, $parameters);
6435
+                if (function_exists($function_name)) {
6436
+                                    $function_name($substitutionarray, $outputlangs, $object, $parameters);
6437
+                }
6120 6438
             }
6121 6439
         }
6122 6440
     }
@@ -6152,8 +6470,9 @@  discard block
 block discarded – undo
6152 6470
 
6153 6471
     $out = '';
6154 6472
 
6155
-    if (!is_object($outputlangs))
6156
-        $outputlangs = $langs;
6473
+    if (!is_object($outputlangs)) {
6474
+            $outputlangs = $langs;
6475
+    }
6157 6476
 
6158 6477
     if ($date_start && $date_end) {
6159 6478
         $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
@@ -6182,20 +6501,22 @@  discard block
 block discarded – undo
6182 6501
 
6183 6502
     $ret = '';
6184 6503
     // If order not defined, we use the setup
6185
-    if ($nameorder < 0)
6186
-        $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6504
+    if ($nameorder < 0) {
6505
+            $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6506
+    }
6187 6507
     if ($nameorder && ((string) $nameorder != '2')) {
6188 6508
         $ret .= $firstname;
6189
-        if ($firstname && $lastname)
6190
-            $ret .= ' ';
6509
+        if ($firstname && $lastname) {
6510
+                    $ret .= ' ';
6511
+        }
6191 6512
         $ret .= $lastname;
6192
-    }
6193
-    else if ($nameorder == 2) {
6513
+    } else if ($nameorder == 2) {
6194 6514
         $ret .= $firstname;
6195 6515
     } else {
6196 6516
         $ret .= $lastname;
6197
-        if ($firstname && $lastname)
6198
-            $ret .= ' ';
6517
+        if ($firstname && $lastname) {
6518
+                    $ret .= ' ';
6519
+        }
6199 6520
         $ret .= $firstname;
6200 6521
     }
6201 6522
     return $ret;
@@ -6215,13 +6536,14 @@  discard block
 block discarded – undo
6215 6536
 {
6216 6537
     //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);		This is not deprecated, it is used by setEventMessages function
6217 6538
     if (!is_array($mesgs)) {  // If mesgs is a string
6218
-        if ($mesgs)
6219
-            $_SESSION['dol_events'][$style][] = $mesgs;
6220
-    }
6221
-    else {      // If mesgs is an array
6539
+        if ($mesgs) {
6540
+                    $_SESSION['dol_events'][$style][] = $mesgs;
6541
+        }
6542
+    } else {      // If mesgs is an array
6222 6543
         foreach ($mesgs as $mesg) {
6223
-            if ($mesg)
6224
-                $_SESSION['dol_events'][$style][] = $mesg;
6544
+            if ($mesg) {
6545
+                            $_SESSION['dol_events'][$style][] = $mesg;
6546
+            }
6225 6547
         }
6226 6548
     }
6227 6549
 }
@@ -6241,13 +6563,16 @@  discard block
 block discarded – undo
6241 6563
     if (empty($mesg) && empty($mesgs)) {
6242 6564
         dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
6243 6565
     } else {
6244
-        if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
6245
-            dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6246
-        if (empty($mesgs))
6247
-            setEventMessage($mesg, $style);
6248
-        else {
6249
-            if (!empty($mesg) && !in_array($mesg, $mesgs))
6250
-                setEventMessage($mesg, $style); // Add message string if not already into array
6566
+        if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) {
6567
+                    dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6568
+        }
6569
+        if (empty($mesgs)) {
6570
+                    setEventMessage($mesg, $style);
6571
+        } else {
6572
+            if (!empty($mesg) && !in_array($mesg, $mesgs)) {
6573
+                            setEventMessage($mesg, $style);
6574
+            }
6575
+            // Add message string if not already into array
6251 6576
             setEventMessage($mesgs, $style);
6252 6577
         }
6253 6578
     }
@@ -6266,22 +6591,25 @@  discard block
 block discarded – undo
6266 6591
 {
6267 6592
     // Show mesgs
6268 6593
     if (isset($_SESSION['dol_events']['mesgs'])) {
6269
-        if (empty($disabledoutputofmessages))
6270
-            dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
6594
+        if (empty($disabledoutputofmessages)) {
6595
+                    dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
6596
+        }
6271 6597
         unset($_SESSION['dol_events']['mesgs']);
6272 6598
     }
6273 6599
 
6274 6600
     // Show errors
6275 6601
     if (isset($_SESSION['dol_events']['errors'])) {
6276
-        if (empty($disabledoutputofmessages))
6277
-            dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
6602
+        if (empty($disabledoutputofmessages)) {
6603
+                    dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
6604
+        }
6278 6605
         unset($_SESSION['dol_events']['errors']);
6279 6606
     }
6280 6607
 
6281 6608
     // Show warnings
6282 6609
     if (isset($_SESSION['dol_events']['warnings'])) {
6283
-        if (empty($disabledoutputofmessages))
6284
-            dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
6610
+        if (empty($disabledoutputofmessages)) {
6611
+                    dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
6612
+        }
6285 6613
         unset($_SESSION['dol_events']['warnings']);
6286 6614
     }
6287 6615
 }
@@ -6322,8 +6650,9 @@  discard block
 block discarded – undo
6322 6650
             foreach ($mesgarray as $message) {
6323 6651
                 $ret++;
6324 6652
                 $out .= $langs->trans($message);
6325
-                if ($ret < count($mesgarray))
6326
-                    $out .= "<br>\n";
6653
+                if ($ret < count($mesgarray)) {
6654
+                                    $out .= "<br>\n";
6655
+                }
6327 6656
             }
6328 6657
         }
6329 6658
         if ($mesgstring) {
@@ -6389,8 +6718,9 @@  discard block
 block discarded – undo
6389 6718
  */
6390 6719
 function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0)
6391 6720
 {
6392
-    if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0))
6393
-        return;
6721
+    if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
6722
+            return;
6723
+    }
6394 6724
 
6395 6725
     $iserror = 0;
6396 6726
     $iswarning = 0;
@@ -6405,14 +6735,17 @@  discard block
 block discarded – undo
6405 6735
                 break;
6406 6736
             }
6407 6737
         }
6408
-    } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring))
6409
-        $iserror++;
6410
-    else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring))
6411
-        $iswarning++;
6412
-    if ($style == 'error')
6413
-        $iserror++;
6414
-    if ($style == 'warning')
6415
-        $iswarning++;
6738
+    } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) {
6739
+            $iserror++;
6740
+    } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) {
6741
+            $iswarning++;
6742
+    }
6743
+    if ($style == 'error') {
6744
+            $iserror++;
6745
+    }
6746
+    if ($style == 'warning') {
6747
+            $iswarning++;
6748
+    }
6416 6749
 
6417 6750
     if ($iserror || $iswarning) {
6418 6751
         // Remove div from texts
@@ -6431,9 +6764,10 @@  discard block
 block discarded – undo
6431 6764
             $mesgarray = $newmesgarray;
6432 6765
         }
6433 6766
         print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded);
6434
-    } else
6435
-        print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded);
6436
-}
6767
+    } else {
6768
+            print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded);
6769
+    }
6770
+    }
6437 6771
 
6438 6772
 /**
6439 6773
  *  Print formated error messages to output (Used to show messages on html output).
@@ -6473,15 +6807,17 @@  discard block
 block discarded – undo
6473 6807
         $sizearray = count($array);
6474 6808
         if ($sizearray > 0) {
6475 6809
             $temp = array();
6476
-            foreach (array_keys($array) as $key)
6477
-                $temp[$key] = $array[$key][$index];
6810
+            foreach (array_keys($array) as $key) {
6811
+                            $temp[$key] = $array[$key][$index];
6812
+            }
6478 6813
 
6479
-            if (!$natsort)
6480
-                ($order == 'asc') ? asort($temp) : arsort($temp);
6481
-            else {
6814
+            if (!$natsort) {
6815
+                            ($order == 'asc') ? asort($temp) : arsort($temp);
6816
+            } else {
6482 6817
                 ($case_sensitive) ? natsort($temp) : natcasesort($temp);
6483
-                if ($order != 'asc')
6484
-                    $temp = array_reverse($temp, true);
6818
+                if ($order != 'asc') {
6819
+                                    $temp = array_reverse($temp, true);
6820
+                }
6485 6821
             }
6486 6822
 
6487 6823
             $sorted = array();
@@ -6507,23 +6843,38 @@  discard block
 block discarded – undo
6507 6843
     // We must use here a binary strlen function (so not dol_strlen)
6508 6844
     $strLength = dol_strlen($str);
6509 6845
     for ($i = 0; $i < $strLength; $i++) {
6510
-        if (ord($str[$i]) < 0x80)
6511
-            continue; // 0bbbbbbb
6512
-        elseif ((ord($str[$i]) & 0xE0) == 0xC0)
6513
-            $n = 1; // 110bbbbb
6514
-        elseif ((ord($str[$i]) & 0xF0) == 0xE0)
6515
-            $n = 2; // 1110bbbb
6516
-        elseif ((ord($str[$i]) & 0xF8) == 0xF0)
6517
-            $n = 3; // 11110bbb
6518
-        elseif ((ord($str[$i]) & 0xFC) == 0xF8)
6519
-            $n = 4; // 111110bb
6520
-        elseif ((ord($str[$i]) & 0xFE) == 0xFC)
6521
-            $n = 5; // 1111110b
6522
-        else
6523
-            return false; // Does not match any model
6846
+        if (ord($str[$i]) < 0x80) {
6847
+                    continue;
6848
+        }
6849
+        // 0bbbbbbb
6850
+        elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
6851
+                    $n = 1;
6852
+        }
6853
+        // 110bbbbb
6854
+        elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
6855
+                    $n = 2;
6856
+        }
6857
+        // 1110bbbb
6858
+        elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
6859
+                    $n = 3;
6860
+        }
6861
+        // 11110bbb
6862
+        elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
6863
+                    $n = 4;
6864
+        }
6865
+        // 111110bb
6866
+        elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
6867
+                    $n = 5;
6868
+        }
6869
+        // 1111110b
6870
+        else {
6871
+                    return false;
6872
+        }
6873
+        // Does not match any model
6524 6874
         for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
6525
-            if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80))
6526
-                return false;
6875
+            if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
6876
+                            return false;
6877
+            }
6527 6878
         }
6528 6879
     }
6529 6880
     return true;
@@ -6541,15 +6892,21 @@  discard block
 block discarded – undo
6541 6892
     global $conf;
6542 6893
 
6543 6894
     $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
6544
-    if (empty($tmp) && !empty($_SERVER["WINDIR"]))
6545
-        $tmp = 'iso-8859-1'; // By default for windows
6546
-    if (empty($tmp))
6547
-        $tmp = 'utf-8';          // By default for other
6548
-    if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING))
6549
-        $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
6550
-
6551
-    if ($tmp == 'iso-8859-1')
6552
-        return utf8_decode($str);
6895
+    if (empty($tmp) && !empty($_SERVER["WINDIR"])) {
6896
+            $tmp = 'iso-8859-1';
6897
+    }
6898
+    // By default for windows
6899
+    if (empty($tmp)) {
6900
+            $tmp = 'utf-8';
6901
+    }
6902
+    // By default for other
6903
+    if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) {
6904
+            $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING;
6905
+    }
6906
+
6907
+    if ($tmp == 'iso-8859-1') {
6908
+            return utf8_decode($str);
6909
+    }
6553 6910
     return $str;
6554 6911
 }
6555 6912
 
@@ -6571,8 +6928,9 @@  discard block
 block discarded – undo
6571 6928
     global $cache_codes;
6572 6929
 
6573 6930
     // If key empty
6574
-    if ($key == '')
6575
-        return '';
6931
+    if ($key == '') {
6932
+            return '';
6933
+    }
6576 6934
 
6577 6935
     // Check in cache
6578 6936
     if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
@@ -6584,20 +6942,21 @@  discard block
 block discarded – undo
6584 6942
     $sql = "SELECT " . $fieldid . " as valuetoget";
6585 6943
     $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
6586 6944
     $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'";
6587
-    if (!empty($entityfilter))
6588
-        $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6945
+    if (!empty($entityfilter)) {
6946
+            $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6947
+    }
6589 6948
 
6590 6949
     $resql = $db->query($sql);
6591 6950
     if ($resql) {
6592 6951
         $obj = $db->fetch_object($resql);
6593
-        if ($obj)
6594
-            $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
6595
-        else
6596
-            $cache_codes[$tablename][$key][$fieldid] = '';
6952
+        if ($obj) {
6953
+                    $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
6954
+        } else {
6955
+                    $cache_codes[$tablename][$key][$fieldid] = '';
6956
+        }
6597 6957
         $db->free($resql);
6598 6958
         return $cache_codes[$tablename][$key][$fieldid];
6599
-    }
6600
-    else {
6959
+    } else {
6601 6960
         return -1;
6602 6961
     }
6603 6962
 }
@@ -6644,16 +7003,17 @@  discard block
 block discarded – undo
6644 7003
     global $soc;       // For backward compatibility
6645 7004
     //print $s."<br>\n";
6646 7005
     if ($returnvalue) {
6647
-        if ($hideerrors)
6648
-            return @eval('return ' . $s . ';');
6649
-        else
6650
-            return eval('return ' . $s . ';');
6651
-    }
6652
-    else {
6653
-        if ($hideerrors)
6654
-            @eval($s);
6655
-        else
6656
-            eval($s);
7006
+        if ($hideerrors) {
7007
+                    return @eval('return ' . $s . ';');
7008
+        } else {
7009
+                    return eval('return ' . $s . ';');
7010
+        }
7011
+    } else {
7012
+        if ($hideerrors) {
7013
+                    @eval($s);
7014
+        } else {
7015
+                    eval($s);
7016
+        }
6657 7017
     }
6658 7018
 }
6659 7019
 
@@ -6679,8 +7039,9 @@  discard block
 block discarded – undo
6679 7039
 {
6680 7040
     global $langs;
6681 7041
 
6682
-    if (empty($codelang))
6683
-        return '';
7042
+    if (empty($codelang)) {
7043
+            return '';
7044
+    }
6684 7045
 
6685 7046
     if ($codelang == 'auto') {
6686 7047
         return '<span class="fa fa-globe"></span>';
@@ -6694,9 +7055,9 @@  discard block
 block discarded – undo
6694 7055
         'sv_SV' => 'se'
6695 7056
     );
6696 7057
 
6697
-    if (isset($langtocountryflag[$codelang]))
6698
-        $flagImage = $langtocountryflag[$codelang];
6699
-    else {
7058
+    if (isset($langtocountryflag[$codelang])) {
7059
+            $flagImage = $langtocountryflag[$codelang];
7060
+    } else {
6700 7061
         $tmparray = explode('_', $codelang);
6701 7062
         $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
6702 7063
     }
@@ -6714,15 +7075,20 @@  discard block
 block discarded – undo
6714 7075
 {
6715 7076
     global $mysoc;
6716 7077
 
6717
-    if (strtoupper($countrycode) == 'MQ')
6718
-        return 'fr_CA';
6719
-    if (strtoupper($countrycode) == 'SE')
6720
-        return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
7078
+    if (strtoupper($countrycode) == 'MQ') {
7079
+            return 'fr_CA';
7080
+    }
7081
+    if (strtoupper($countrycode) == 'SE') {
7082
+            return 'sv_SE';
7083
+    }
7084
+    // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
6721 7085
     if (strtoupper($countrycode) == 'CH') {
6722
-        if ($mysoc->country_code == 'FR')
6723
-            return 'fr_CH';
6724
-        if ($mysoc->country_code == 'DE')
6725
-            return 'de_CH';
7086
+        if ($mysoc->country_code == 'FR') {
7087
+                    return 'fr_CH';
7088
+        }
7089
+        if ($mysoc->country_code == 'DE') {
7090
+                    return 'de_CH';
7091
+        }
6726 7092
     }
6727 7093
 
6728 7094
     // Locale list taken from:
@@ -6900,8 +7266,9 @@  discard block
 block discarded – undo
6900 7266
     );
6901 7267
 
6902 7268
     $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode);
6903
-    if (in_array($buildprimarykeytotest, $locales))
6904
-        return strtolower($countrycode) . '_' . strtoupper($countrycode);
7269
+    if (in_array($buildprimarykeytotest, $locales)) {
7270
+            return strtolower($countrycode) . '_' . strtoupper($countrycode);
7271
+    }
6905 7272
 
6906 7273
     foreach ($locales as $locale) {
6907 7274
         $locale_language = locale_get_primary_language($locale);
@@ -6955,18 +7322,21 @@  discard block
 block discarded – undo
6955 7322
 
6956 7323
             if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
6957 7324
                 if (count($values) == 6) {       // new declaration with permissions:  $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
6958
-                    if ($values[0] != $type)
6959
-                        continue;
7325
+                    if ($values[0] != $type) {
7326
+                                            continue;
7327
+                    }
6960 7328
 
6961 7329
                     if (verifCond($values[4])) {
6962
-                        if ($values[3])
6963
-                            $langs->load($values[3]);
7330
+                        if ($values[3]) {
7331
+                                                    $langs->load($values[3]);
7332
+                        }
6964 7333
                         if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
6965 7334
                             $substitutionarray = array();
6966 7335
                             complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
6967 7336
                             $label = make_substitutions($reg[1], $substitutionarray);
6968
-                        } else
6969
-                            $label = $langs->trans($values[2]);
7337
+                        } else {
7338
+                                                    $label = $langs->trans($values[2]);
7339
+                        }
6970 7340
 
6971 7341
                         //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
6972 7342
                         $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
@@ -6974,30 +7344,32 @@  discard block
 block discarded – undo
6974 7344
                         $head[$h][2] = str_replace('+', '', $values[1]);
6975 7345
                         $h++;
6976 7346
                     }
6977
-                }
6978
-                else if (count($values) == 5) {       // deprecated
7347
+                } else if (count($values) == 5) {       // deprecated
6979 7348
                     dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
6980 7349
 
6981
-                    if ($values[0] != $type)
6982
-                        continue;
6983
-                    if ($values[3])
6984
-                        $langs->load($values[3]);
7350
+                    if ($values[0] != $type) {
7351
+                                            continue;
7352
+                    }
7353
+                    if ($values[3]) {
7354
+                                            $langs->load($values[3]);
7355
+                    }
6985 7356
                     if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
6986 7357
                         $substitutionarray = array();
6987 7358
                         complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
6988 7359
                         $label = make_substitutions($reg[1], $substitutionarray);
6989
-                    } else
6990
-                        $label = $langs->trans($values[2]);
7360
+                    } else {
7361
+                                            $label = $langs->trans($values[2]);
7362
+                    }
6991 7363
 
6992 7364
                     $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
6993 7365
                     $head[$h][1] = $label;
6994 7366
                     $head[$h][2] = str_replace('+', '', $values[1]);
6995 7367
                     $h++;
6996 7368
                 }
6997
-            }
6998
-            else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
6999
-                if ($values[0] != $type)
7000
-                    continue;
7369
+            } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
7370
+                if ($values[0] != $type) {
7371
+                                    continue;
7372
+                }
7001 7373
                 $tabname = str_replace('-', '', $values[1]);
7002 7374
                 foreach ($head as $key => $val) {
7003 7375
                     $condition = (!empty($values[3]) ? verifCond($values[3]) : 1);
@@ -7039,10 +7411,11 @@  discard block
 block discarded – undo
7039 7411
     global $action;
7040 7412
     global $micro_start_time;
7041 7413
 
7042
-    if ($zone == 'private')
7043
-        print "\n" . '<!-- Common footer for private page -->' . "\n";
7044
-    else
7045
-        print "\n" . '<!-- Common footer for public page -->' . "\n";
7414
+    if ($zone == 'private') {
7415
+            print "\n" . '<!-- Common footer for private page -->' . "\n";
7416
+    } else {
7417
+            print "\n" . '<!-- Common footer for public page -->' . "\n";
7418
+    }
7046 7419
 
7047 7420
     // A div to store page_y POST parameter so we can read it using javascript
7048 7421
     print "\n<!-- A div to store page_y POST paramater -->\n";
@@ -7051,8 +7424,9 @@  discard block
 block discarded – undo
7051 7424
     $parameters = array();
7052 7425
     $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);    // Note that $action and $object may have been modified by some hooks
7053 7426
     if (empty($reshook)) {
7054
-        if (!empty($conf->global->MAIN_HTML_FOOTER))
7055
-            print $conf->global->MAIN_HTML_FOOTER . "\n";
7427
+        if (!empty($conf->global->MAIN_HTML_FOOTER)) {
7428
+                    print $conf->global->MAIN_HTML_FOOTER . "\n";
7429
+        }
7056 7430
 
7057 7431
         print "\n";
7058 7432
         if (!empty($conf->use_javascript_ajax)) {
@@ -7075,8 +7449,9 @@  discard block
 block discarded – undo
7075 7449
                 print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n";
7076 7450
                 $relativepathstring = $_SERVER["PHP_SELF"];
7077 7451
                 // Clean $relativepathstring
7078
-                if (constant('DOL_URL_ROOT'))
7079
-                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
7452
+                if (constant('DOL_URL_ROOT')) {
7453
+                                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring);
7454
+                }
7080 7455
                 $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
7081 7456
                 $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
7082 7457
                 $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
@@ -7087,14 +7462,17 @@  discard block
 block discarded – undo
7087 7462
                             $tmpqueryarraytohave = explode('&', $defkey);
7088 7463
                             $foundintru = 0;
7089 7464
                             foreach ($tmpqueryarraytohave as $tmpquerytohave) {
7090
-                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
7091
-                                    $foundintru = 1;
7465
+                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
7466
+                                                                    $foundintru = 1;
7467
+                                }
7468
+                            }
7469
+                            if (!$foundintru) {
7470
+                                                            $qualified = 1;
7092 7471
                             }
7093
-                            if (!$foundintru)
7094
-                                $qualified = 1;
7095 7472
                             //var_dump($defkey.'-'.$qualified);
7096
-                        } else
7097
-                            $qualified = 1;
7473
+                        } else {
7474
+                                                    $qualified = 1;
7475
+                        }
7098 7476
 
7099 7477
                         if ($qualified) {
7100 7478
                             foreach ($defval as $paramkey => $paramval) {
@@ -7113,14 +7491,17 @@  discard block
 block discarded – undo
7113 7491
                             $tmpqueryarraytohave = explode('&', $defkey);
7114 7492
                             $foundintru = 0;
7115 7493
                             foreach ($tmpqueryarraytohave as $tmpquerytohave) {
7116
-                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
7117
-                                    $foundintru = 1;
7494
+                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
7495
+                                                                    $foundintru = 1;
7496
+                                }
7497
+                            }
7498
+                            if (!$foundintru) {
7499
+                                                            $qualified = 1;
7118 7500
                             }
7119
-                            if (!$foundintru)
7120
-                                $qualified = 1;
7121 7501
                             //var_dump($defkey.'-'.$qualified);
7122
-                        } else
7123
-                            $qualified = 1;
7502
+                        } else {
7503
+                                                    $qualified = 1;
7504
+                        }
7124 7505
 
7125 7506
                         if ($qualified) {
7126 7507
                             foreach ($defval as $paramkey => $paramval) {
@@ -7159,8 +7540,9 @@  discard block
 block discarded – undo
7159 7540
                 print "\n";
7160 7541
                 print "/* JS CODE TO ENABLE to add memory info */\n";
7161 7542
                 print 'window.console && console.log("';
7162
-                if (!empty($conf->global->MEMCACHED_SERVER))
7163
-                    print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
7543
+                if (!empty($conf->global->MEMCACHED_SERVER)) {
7544
+                                    print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
7545
+                }
7164 7546
                 print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7165 7547
                 if (!empty($micro_start_time)) {   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable.
7166 7548
                     $micro_end_time = microtime(true);
@@ -7290,8 +7672,9 @@  discard block
 block discarded – undo
7290 7672
 
7291 7673
     $crits = explode(' ', $value);
7292 7674
     $res = '';
7293
-    if (!is_array($fields))
7294
-        $fields = array($fields);
7675
+    if (!is_array($fields)) {
7676
+            $fields = array($fields);
7677
+    }
7295 7678
 
7296 7679
     $nboffields = count($fields);
7297 7680
     $end2 = count($crits);
@@ -7354,8 +7737,9 @@  discard block
 block discarded – undo
7354 7737
                 $tmpcrits = explode('|', $crit);
7355 7738
                 $i3 = 0;
7356 7739
                 foreach ($tmpcrits as $tmpcrit) {
7357
-                    if (empty($tmpcrit))
7358
-                        continue;
7740
+                    if (empty($tmpcrit)) {
7741
+                                            continue;
7742
+                    }
7359 7743
 
7360 7744
                     $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
7361 7745
 
@@ -7391,8 +7775,9 @@  discard block
 block discarded – undo
7391 7775
             }
7392 7776
             $i++;
7393 7777
         }
7394
-        if ($newres)
7395
-            $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7778
+        if ($newres) {
7779
+                    $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7780
+        }
7396 7781
         $j++;
7397 7782
     }
7398 7783
     $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
@@ -7432,29 +7817,37 @@  discard block
 block discarded – undo
7432 7817
 function getImageFileNameForSize($file, $extName, $extImgTarget = '')
7433 7818
 {
7434 7819
     $dirName = dirname($file);
7435
-    if ($dirName == '.')
7436
-        $dirName = '';
7820
+    if ($dirName == '.') {
7821
+            $dirName = '';
7822
+    }
7437 7823
 
7438 7824
     $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case
7439 7825
     $fileName = basename($fileName);
7440 7826
 
7441
-    if (empty($extImgTarget))
7442
-        $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
7443
-    if (empty($extImgTarget))
7444
-        $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
7445
-    if (empty($extImgTarget))
7446
-        $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
7447
-    if (empty($extImgTarget))
7448
-        $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
7449
-    if (empty($extImgTarget))
7450
-        $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
7827
+    if (empty($extImgTarget)) {
7828
+            $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
7829
+    }
7830
+    if (empty($extImgTarget)) {
7831
+            $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
7832
+    }
7833
+    if (empty($extImgTarget)) {
7834
+            $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
7835
+    }
7836
+    if (empty($extImgTarget)) {
7837
+            $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
7838
+    }
7839
+    if (empty($extImgTarget)) {
7840
+            $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
7841
+    }
7451 7842
 
7452
-    if (!$extImgTarget)
7453
-        return $file;
7843
+    if (!$extImgTarget) {
7844
+            return $file;
7845
+    }
7454 7846
 
7455 7847
     $subdir = '';
7456
-    if ($extName)
7457
-        $subdir = 'thumbs/';
7848
+    if ($extName) {
7849
+            $subdir = 'thumbs/';
7850
+    }
7458 7851
 
7459 7852
     return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb
7460 7853
 }
@@ -7472,8 +7865,9 @@  discard block
 block discarded – undo
7472 7865
 {
7473 7866
     global $conf, $langs;
7474 7867
 
7475
-    if (empty($conf->use_javascript_ajax))
7476
-        return '';
7868
+    if (empty($conf->use_javascript_ajax)) {
7869
+            return '';
7870
+    }
7477 7871
 
7478 7872
     $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
7479 7873
     //$mime_preview[]='vnd.oasis.opendocument.presentation';
@@ -7481,18 +7875,20 @@  discard block
 block discarded – undo
7481 7875
     $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview);
7482 7876
 
7483 7877
     if ($alldata == 1) {
7484
-        if ($num_mime !== false)
7485
-            return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
7486
-        else
7487
-            return array();
7878
+        if ($num_mime !== false) {
7879
+                    return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
7880
+        } else {
7881
+                    return array();
7882
+        }
7488 7883
     }
7489 7884
 
7490 7885
     // old behavior
7491
-    if ($num_mime !== false)
7492
-        return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
7493
-    else
7494
-        return '';
7495
-}
7886
+    if ($num_mime !== false) {
7887
+            return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
7888
+    } else {
7889
+            return '';
7890
+    }
7891
+    }
7496 7892
 
7497 7893
 /**
7498 7894
  * Make content of an input box selected when we click into input field.
@@ -7509,8 +7905,9 @@  discard block
 block discarded – undo
7509 7905
 				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
7510 7906
 				});
7511 7907
 		    </script>';
7512
-    if ($addlink)
7513
-        $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
7908
+    if ($addlink) {
7909
+            $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
7910
+    }
7514 7911
     return $out;
7515 7912
 }
7516 7913
 
@@ -7892,8 +8289,9 @@  discard block
 block discarded – undo
7892 8289
     if (!isset($dictvalues[$tablename])) {
7893 8290
         $dictvalues[$tablename] = array();
7894 8291
         $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1';
7895
-        if ($checkentity)
7896
-            $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
8292
+        if ($checkentity) {
8293
+                    $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
8294
+        }
7897 8295
 
7898 8296
         $resql = $db->query($sql);
7899 8297
         if ($resql) {
@@ -7905,11 +8303,14 @@  discard block
 block discarded – undo
7905 8303
         }
7906 8304
     }
7907 8305
 
7908
-    if (!empty($dictvalues[$tablename][$id]))
7909
-        return $dictvalues[$tablename][$id]->{$field}; // Found
8306
+    if (!empty($dictvalues[$tablename][$id])) {
8307
+            return $dictvalues[$tablename][$id]->{$field};
8308
+    }
8309
+    // Found
7910 8310
     else { // Not found
7911
-        if ($id > 0)
7912
-            return $id;
8311
+        if ($id > 0) {
8312
+                    return $id;
8313
+        }
7913 8314
         return '';
7914 8315
     }
7915 8316
 }
@@ -7939,8 +8340,9 @@  discard block
 block discarded – undo
7939 8340
             $b = hexdec($hexb);
7940 8341
         }
7941 8342
         $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;    // HSL algorithm
7942
-        if ($bright > 0.6)
7943
-            $res = 1;
8343
+        if ($bright > 0.6) {
8344
+                    $res = 1;
8345
+        }
7944 8346
     }
7945 8347
     return $res;
7946 8348
 }
@@ -7959,8 +8361,10 @@  discard block
 block discarded – undo
7959 8361
 
7960 8362
     //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
7961 8363
     //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
7962
-    if (empty($menuentry['enabled']))
7963
-        return 0; // Entry disabled by condition
8364
+    if (empty($menuentry['enabled'])) {
8365
+            return 0;
8366
+    }
8367
+    // Entry disabled by condition
7964 8368
     if ($type_user && $menuentry['module']) {
7965 8369
         $tmploops = explode('|', $menuentry['module']);
7966 8370
         $found = 0;
@@ -7970,15 +8374,23 @@  discard block
 block discarded – undo
7970 8374
                 break;
7971 8375
             }
7972 8376
         }
7973
-        if (!$found)
7974
-            return 0; // Entry is for menus all excluded to external users
8377
+        if (!$found) {
8378
+                    return 0;
8379
+        }
8380
+        // Entry is for menus all excluded to external users
8381
+    }
8382
+    if (!$menuentry['perms'] && $type_user) {
8383
+            return 0;
8384
+    }
8385
+    // No permissions and user is external
8386
+    if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
8387
+            return 0;
8388
+    }
8389
+    // No permissions and option to hide when not allowed, even for internal user, is on
8390
+    if (!$menuentry['perms']) {
8391
+            return 2;
7975 8392
     }
7976
-    if (!$menuentry['perms'] && $type_user)
7977
-        return 0;            // No permissions and user is external
7978
-    if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
7979
-        return 0; // No permissions and option to hide when not allowed, even for internal user, is on
7980
-    if (!$menuentry['perms'])
7981
-        return 2;               // No permissions and user is external
8393
+    // No permissions and user is external
7982 8394
     return 1;
7983 8395
 }
7984 8396
 
Please login to merge, or discard this patch.
index.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
 define('BASE_PATH', __DIR__);
10 10
 define('DEBUG', true);
11 11
 
12
-require_once BASE_PATH . '/vendor/autoload.php';
13
-require_once BASE_PATH . '/alxarafe/vendor/autoload.php';
12
+require_once BASE_PATH.'/vendor/autoload.php';
13
+require_once BASE_PATH.'/alxarafe/vendor/autoload.php';
14 14
 
15 15
 use Alixar\Helpers\AlixarDispatcher;
16 16
 
Please login to merge, or discard this patch.