Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
Base/MenuManager.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
      * @var DoliDB Database handler.
36 36
      */
37 37
     // public $db;
38
-    var $type_user;         // Put 0 for internal users, 1 for external users
39
-    var $atarget = "";                                // To store default target to use onto links
38
+    var $type_user; // Put 0 for internal users, 1 for external users
39
+    var $atarget = ""; // To store default target to use onto links
40 40
     var $name = "eldy";
41 41
     var $menu_array;
42 42
     var $menu_array_after;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
             $leftmenu = $forceleftmenu;
105 105
         }
106 106
 
107
-        require_once DOL_DOCUMENT_ROOT . '/core/class/menubase.class.php';
107
+        require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php';
108 108
         $tabMenu = array();
109 109
         $menuArbo = new Menubase('eldy');
110 110
         $menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu);
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 
128 128
         //var_dump($this->tabMenu);
129 129
 
130
-        require_once DOL_DOCUMENT_ROOT . '/core/menus/standard/eldy.lib.php';
130
+        require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
131 131
 
132 132
         if ($this->type_user == 1) {
133 133
             $conf->global->MAIN_SEARCHFORM_SOCIETE_DISABLED = 1;
134 134
             $conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED = 1;
135 135
         }
136 136
 
137
-        require_once DOL_DOCUMENT_ROOT . '/core/class/menu.class.php';
137
+        require_once DOL_DOCUMENT_ROOT.'/core/class/menu.class.php';
138 138
         $this->menu = new Menu();
139 139
 
140 140
         if (empty($conf->global->MAIN_MENU_INVERT)) {
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
         }
156 156
 
157 157
         if ($mode == 'topnb') {
158
-            print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode);  // no output
158
+            print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // no output
159 159
             return $this->menu->getNbOfVisibleMenuEntries();
160 160
         }
161 161
 
162 162
         if ($mode == 'jmobile') {     // Used to get menu in xml ul/li
163
-            print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode);      // Fill this->menu that is empty with top menu
163
+            print_eldy_menu($this->db, $this->atarget, $this->type_user, $this->tabMenu, $this->menu, 1, $mode); // Fill this->menu that is empty with top menu
164 164
             // $this->menu->liste is top menu
165 165
             //var_dump($this->menu->liste);exit;
166 166
             $lastlevel = array();
167
-            print '<!-- Generate menu list from menu handler ' . $this->name . ' -->' . "\n";
167
+            print '<!-- Generate menu list from menu handler '.$this->name.' -->'."\n";
168 168
             foreach ($this->menu->liste as $key => $val) {  // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu'
169 169
                 print '<ul class="ulmenu" data-inset="true">';
170 170
                 print '<li class="lilevel0">';
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
                     }
186 186
 
187 187
                     print $val['titre'];
188
-                    print '</a>' . "\n";
188
+                    print '</a>'."\n";
189 189
 
190 190
                     // Search submenu fot this mainmenu entry
191 191
                     $tmpmainmenu = $val['mainmenu'];
192 192
                     $tmpleftmenu = 'all';
193 193
                     $submenu = new Menu();
194
-                    print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu);       // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home)
194
+                    print_left_eldy_menu($this->db, $this->menu_array, $this->menu_array_after, $this->tabMenu, $submenu, 1, $tmpmainmenu, $tmpleftmenu); // Fill $submenu (example with tmpmainmenu='home' tmpleftmenu='all', return left menu tree of Home)
195 195
                     // Note: $submenu contains menu entry with substitution not yet done
196 196
                     //if ($tmpmainmenu.'-'.$tmpleftmenu == 'home-all') { var_dump($submenu); exit; }
197 197
                     //if ($tmpmainmenu=='accountancy') { var_dump($submenu->liste); exit; }
@@ -201,21 +201,21 @@  discard block
 block discarded – undo
201 201
                     $canonnexturl = preg_replace('/\?.*$/', '', $nexturl);
202 202
                     //var_dump($canonrelurl);
203 203
                     //var_dump($canonnexturl);
204
-                    print '<ul>' . "\n";
204
+                    print '<ul>'."\n";
205 205
                     if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools'))) || (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) {
206 206
                         // We add sub entry
207
-                        print str_pad('', 1) . '<li class="lilevel1 ui-btn-icon-right ui-btn">';  // ui-btn to highlight on clic
208
-                        print '<a href="' . $relurl . '">';
209
-                        if ($langs->trans(ucfirst($val['mainmenu']) . "Dashboard") == ucfirst($val['mainmenu']) . "Dashboard") {  // No translation
207
+                        print str_pad('', 1).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
208
+                        print '<a href="'.$relurl.'">';
209
+                        if ($langs->trans(ucfirst($val['mainmenu'])."Dashboard") == ucfirst($val['mainmenu'])."Dashboard") {  // No translation
210 210
                             if (in_array($val['mainmenu'], array('cashdesk', 'externalsite', 'website', 'collab'))) {
211 211
                                 print $langs->trans("Access");
212 212
                             } else {
213 213
                                 print $langs->trans("Dashboard");
214 214
                             }
215 215
                         } else
216
-                            print $langs->trans(ucfirst($val['mainmenu']) . "Dashboard");
216
+                            print $langs->trans(ucfirst($val['mainmenu'])."Dashboard");
217 217
                         print '</a>';
218
-                        print '</li>' . "\n";
218
+                        print '</li>'."\n";
219 219
                     }
220 220
 
221 221
                     if ($val['level'] == 0) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
                         if ($showmenu) {  // Visible (option to hide when not allowed is off or allowed)
250 250
                             $substitarray = array('__LOGIN__' => $user->login, '__USER_ID__' => $user->id, '__USER_SUPERVISOR_ID__' => $user->fk_user);
251 251
                             $substitarray['__USERID__'] = $user->id; // For backward compatibility
252
-                            $val2['url'] = make_substitutions($val2['url'], $substitarray);  // Make also substitution of __(XXX)__ and __[XXX]__
252
+                            $val2['url'] = make_substitutions($val2['url'], $substitarray); // Make also substitution of __(XXX)__ and __[XXX]__
253 253
 
254 254
                             if (!preg_match("/^(http:\/\/|https:\/\/)/i", $val2['url'])) {
255 255
                                 $relurl2 = dol_buildpath($val2['url'], 1);
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
                             }
269 269
 
270 270
                             print str_pad('', $val2['level'] + 1);
271
-                            print '<li class="lilevel' . ($val2['level'] + 1);
271
+                            print '<li class="lilevel'.($val2['level'] + 1);
272 272
                             if ($val2['level'] == 0) {
273
-                                print ' ui-btn-icon-right ui-btn';  // ui-btn to highlight on clic
273
+                                print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
274 274
                             }
275
-                            print $disabled . '">';  // ui-btn to highlight on clic
275
+                            print $disabled.'">'; // ui-btn to highlight on clic
276 276
                             if ($relurl2) {
277 277
                                 if ($val2['enabled']) { // Allowed
278
-                                    print '<a href="' . $relurl2 . '"';
278
+                                    print '<a href="'.$relurl2.'"';
279 279
                                     //print ' data-ajax="false"';
280 280
                                     print '>';
281 281
                                     $lastlevel2[$val2['level']] = 'enabled';
@@ -299,17 +299,17 @@  discard block
 block discarded – undo
299 299
                                 else
300 300
                                     print '</a>';
301 301
                             }
302
-                            print '</li>' . "\n";
302
+                            print '</li>'."\n";
303 303
                         }
304 304
                     }
305 305
                     //var_dump($submenu);
306 306
                     print '</ul>';
307 307
                 }
308 308
                 if ($val['enabled'] == 2) {
309
-                    print '<font class="vsmenudisabled">' . $val['titre'] . '</font>';
309
+                    print '<font class="vsmenudisabled">'.$val['titre'].'</font>';
310 310
                 }
311 311
                 print '</li>';
312
-                print '</ul>' . "\n";
312
+                print '</ul>'."\n";
313 313
             }
314 314
         }
315 315
 
Please login to merge, or discard this patch.
Base/User.php 1 patch
Spacing   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     public $skype;
55 55
     public $twitter;
56 56
     public $facebook;
57
-    public $job;   // job position
57
+    public $job; // job position
58 58
     public $signature;
59 59
 
60 60
     /**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     public $address;
64 64
     public $zip;
65 65
     public $town;
66
-    public $state_id;  // The state/department
66
+    public $state_id; // The state/department
67 67
     public $state_code;
68 68
     public $state;
69 69
     public $office_phone;
@@ -117,26 +117,26 @@  discard block
 block discarded – undo
117 117
     public $datepreviouslogin;
118 118
     public $photo;
119 119
     public $lang;
120
-    public $rights;                        // Array of permissions user->rights->permx
121
-    public $all_permissions_are_loaded;    // All permission are loaded
122
-    public $nb_rights;              // Number of rights granted to the user
123
-    private $_tab_loaded = array();     // Cache array of already loaded permissions
124
-    public $conf;             // To store personal config
125
-    public $default_values;         // To store default values for user
126
-    public $lastsearch_values_tmp;  // To store current search criterias for user
127
-    public $lastsearch_values;      // To store last saved search criterias for user
128
-    public $users = array();  // To store all tree of users hierarchy
129
-    public $parentof;    // To store an array of all parents for all ids.
120
+    public $rights; // Array of permissions user->rights->permx
121
+    public $all_permissions_are_loaded; // All permission are loaded
122
+    public $nb_rights; // Number of rights granted to the user
123
+    private $_tab_loaded = array(); // Cache array of already loaded permissions
124
+    public $conf; // To store personal config
125
+    public $default_values; // To store default values for user
126
+    public $lastsearch_values_tmp; // To store current search criterias for user
127
+    public $lastsearch_values; // To store last saved search criterias for user
128
+    public $users = array(); // To store all tree of users hierarchy
129
+    public $parentof; // To store an array of all parents for all ids.
130 130
     private $cache_childids;
131
-    public $accountancy_code;   // Accountancy code in prevision of the complete accountancy module
132
-    public $thm;     // Average cost of employee - Used for valuation of time spent
133
-    public $tjm;     // Average cost of employee
134
-    public $salary;     // Monthly salary       - Denormalized value from llx_user_employment
135
-    public $salaryextra;    // Monthly salary extra - Denormalized value from llx_user_employment
136
-    public $weeklyhours;    // Weekly hours         - Denormalized value from llx_user_employment
137
-    public $color;      // Define background color for user in agenda
138
-    public $dateemployment;   // Define date of employment by company
139
-    public $dateemploymentend;  // Define date of employment end by company
131
+    public $accountancy_code; // Accountancy code in prevision of the complete accountancy module
132
+    public $thm; // Average cost of employee - Used for valuation of time spent
133
+    public $tjm; // Average cost of employee
134
+    public $salary; // Monthly salary       - Denormalized value from llx_user_employment
135
+    public $salaryextra; // Monthly salary extra - Denormalized value from llx_user_employment
136
+    public $weeklyhours; // Weekly hours         - Denormalized value from llx_user_employment
137
+    public $color; // Define background color for user in agenda
138
+    public $dateemployment; // Define date of employment by company
139
+    public $dateemploymentend; // Define date of employment end by company
140 140
     public $default_c_exp_tax_cat;
141 141
     public $default_range;
142 142
     public $fields = array(
@@ -211,37 +211,37 @@  discard block
 block discarded – undo
211 211
         $sql .= " u.color,";
212 212
         $sql .= " u.dateemployment, u.dateemploymentend,";
213 213
         $sql .= " u.ref_int, u.ref_ext,";
214
-        $sql .= " u.default_range, u.default_c_exp_tax_cat,";   // Expense report default mode
214
+        $sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode
215 215
         $sql .= " c.code as country_code, c.label as country,";
216 216
         $sql .= " d.code_departement as state_code, d.nom as state";
217
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
218
-        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_country as c ON u.fk_country = c.rowid";
219
-        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_departements as d ON u.fk_state = d.rowid";
217
+        $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
218
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON u.fk_country = c.rowid";
219
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d ON u.fk_state = d.rowid";
220 220
 
221 221
         if ($entity < 0) {
222 222
             if ((empty($conf->multicompany->enabled) || empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) && (!empty($user->entity))) {
223
-                $sql .= " WHERE u.entity IN (0," . Globals::$conf->entity . ")";
223
+                $sql .= " WHERE u.entity IN (0,".Globals::$conf->entity.")";
224 224
             } else {
225
-                $sql .= " WHERE u.entity IS NOT NULL";    // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
225
+                $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
226 226
             }
227 227
         } else {  // The fetch was forced on an entity
228 228
             if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
229
-                $sql .= " WHERE u.entity IS NOT NULL";    // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
229
+                $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database
230 230
             } else {
231
-                $sql .= " WHERE u.entity IN (0, " . (($entity != '' && $entity >= 0) ? $entity : Globals::$conf->entity) . ")";   // search in entity provided in parameter
231
+                $sql .= " WHERE u.entity IN (0, ".(($entity != '' && $entity >= 0) ? $entity : Globals::$conf->entity).")"; // search in entity provided in parameter
232 232
             }
233 233
         }
234 234
 
235 235
         if ($sid) {    // permet une recherche du user par son SID ActiveDirectory ou Samba
236 236
             //$sql .= " AND (u.ldap_sid = '" . Config::$dbEngine->escape($sid) . "' OR u.login = '" . Config::$dbEngine->escape($login) . "') LIMIT 1";
237
-            $sql .= " AND (u.ldap_sid = '" . $sid . "' OR u.login = '" . Config::$dbEngine->escape($login) . "') LIMIT 1";
237
+            $sql .= " AND (u.ldap_sid = '".$sid."' OR u.login = '".Config::$dbEngine->escape($login)."') LIMIT 1";
238 238
         } else if ($login) {
239 239
             // $sql .= " AND u.login = '" . Config::$dbEngine->escape($login) . "'";
240
-            $sql .= " AND u.login = '" . $login . "'";
240
+            $sql .= " AND u.login = '".$login."'";
241 241
         } else {
242
-            $sql .= " AND u.rowid = " . $id;
242
+            $sql .= " AND u.rowid = ".$id;
243 243
         }
244
-        $sql .= " ORDER BY u.entity ASC";    // Avoid random result when there is 2 login in 2 different entities
244
+        $sql .= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities
245 245
 
246 246
         $result = Config::$dbEngine->select($sql);
247 247
         // echo "<p>SQL in 2477 of User: '$sql'</p>";
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
                 $this->datelastlogin = $obj->datel;
328 328
                 $this->datepreviouslogin = $obj->datep;
329 329
 
330
-                $this->societe_id = $obj->fk_soc;  // deprecated
330
+                $this->societe_id = $obj->fk_soc; // deprecated
331 331
                 $this->contact_id = $obj->fk_socpeople; // deprecated
332 332
                 $this->socid = $obj->fk_soc;
333 333
                 $this->contactid = $obj->fk_socpeople;
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
                 $this->fetch_optionals();
349 349
             } else {
350 350
                 $this->error = "USERNOTFOUND";
351
-                DolUtils::dol_syslog(get_class($this) . "::fetch user not found", LOG_DEBUG);
351
+                DolUtils::dol_syslog(get_class($this)."::fetch user not found", LOG_DEBUG);
352 352
                 return 0;
353 353
             }
354 354
         } else {
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
         // To get back the global configuration unique to the user
360 360
         if ($loadpersonalconf) {
361 361
             // Load user->conf for user
362
-            $sql = "SELECT param, value FROM " . MAIN_DB_PREFIX . "user_param";
363
-            $sql .= " WHERE fk_user = " . $this->id;
364
-            $sql .= " AND entity = " . Globals::$conf->entity;
362
+            $sql = "SELECT param, value FROM ".MAIN_DB_PREFIX."user_param";
363
+            $sql .= " WHERE fk_user = ".$this->id;
364
+            $sql .= " AND entity = ".Globals::$conf->entity;
365 365
             //DolUtils::dol_syslog(get_class($this).'::fetch load personalized conf', LOG_DEBUG);
366 366
             $resql = Config::$dbEngine->select($sql);
367 367
             if (is_array($resql)) {
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
         // global $conf;
400 400
         // Load user->default_values for user. TODO Save this in memcached ?
401 401
         $sql = "SELECT rowid, entity, type, page, param, value";
402
-        $sql .= " FROM " . MAIN_DB_PREFIX . "default_values";
403
-        $sql .= " WHERE entity IN (" . ($this->entity > 0 ? $this->entity . ", " : "") . Globals::$conf->entity . ")"; // Entity of user (if defined) + current entity
404
-        $sql .= " AND user_id IN (0" . ($this->id > 0 ? ", " . $this->id : "") . ")";       // User 0 (all) + me (if defined)
402
+        $sql .= " FROM ".MAIN_DB_PREFIX."default_values";
403
+        $sql .= " WHERE entity IN (".($this->entity > 0 ? $this->entity.", " : "").Globals::$conf->entity.")"; // Entity of user (if defined) + current entity
404
+        $sql .= " AND user_id IN (0".($this->id > 0 ? ", ".$this->id : "").")"; // User 0 (all) + me (if defined)
405 405
         $resql = Config::$dbEngine->select($sql);
406 406
         if (is_array($resql)) {
407 407
             foreach ($resql as $array) {
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 
451 451
         $entity = (!empty($entity) ? $entity : Globals::$conf->entity);
452 452
 
453
-        DolUtils::dol_syslog(get_class($this) . "::addrights $rid, $allmodule, $allperms, $entity");
453
+        DolUtils::dol_syslog(get_class($this)."::addrights $rid, $allmodule, $allperms, $entity");
454 454
         $error = 0;
455 455
         $whereforadd = '';
456 456
 
@@ -460,9 +460,9 @@  discard block
 block discarded – undo
460 460
             // Si on a demande ajout d'un droit en particulier, on recupere
461 461
             // les caracteristiques (module, perms et subperms) de ce droit.
462 462
             $sql = "SELECT module, perms, subperms";
463
-            $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def";
464
-            $sql .= " WHERE id = '" . Config::$dbEngine->escape($rid) . "'";
465
-            $sql .= " AND entity = " . $entity;
463
+            $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
464
+            $sql .= " WHERE id = '".Config::$dbEngine->escape($rid)."'";
465
+            $sql .= " AND entity = ".$entity;
466 466
 
467 467
             $result = Config::$dbEngine->query($sql);
468 468
             if ($result) {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
             }
477 477
 
478 478
             // Where pour la liste des droits a ajouter
479
-            $whereforadd = "id=" . Config::$dbEngine->escape($rid);
479
+            $whereforadd = "id=".Config::$dbEngine->escape($rid);
480 480
             // Ajout des droits induits
481 481
             if (!empty($subperms)) {
482 482
                 $whereforadd .= " OR (module='$module' AND perms='$perms' AND (subperms='lire' OR subperms='read'))";
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
                 if ($allmodule == 'allmodules') {
494 494
                     $whereforadd = 'allmodules';
495 495
                 } else {
496
-                    $whereforadd = "module='" . Config::$dbEngine->escape($allmodule) . "'";
496
+                    $whereforadd = "module='".Config::$dbEngine->escape($allmodule)."'";
497 497
                     if (!empty($allperms)) {
498
-                        $whereforadd .= " AND perms='" . Config::$dbEngine->escape($allperms) . "'";
498
+                        $whereforadd .= " AND perms='".Config::$dbEngine->escape($allperms)."'";
499 499
                     }
500 500
                 }
501 501
             }
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
         if (!empty($whereforadd)) {
506 506
             //print "$module-$perms-$subperms";
507 507
             $sql = "SELECT id";
508
-            $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def";
509
-            $sql .= " WHERE entity = " . $entity;
508
+            $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
509
+            $sql .= " WHERE entity = ".$entity;
510 510
             if (!empty($whereforadd) && $whereforadd != 'allmodules') {
511
-                $sql .= " AND " . $whereforadd;
511
+                $sql .= " AND ".$whereforadd;
512 512
             }
513 513
 
514 514
             $result = Config::$dbEngine->query($sql);
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
                     $obj = Config::$dbEngine->fetch_object($result);
520 520
                     $nid = $obj->id;
521 521
 
522
-                    $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights WHERE fk_user = " . $this->id . " AND fk_id=" . $nid . " AND entity = " . $entity;
522
+                    $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id." AND fk_id=".$nid." AND entity = ".$entity;
523 523
                     if (!Config::$dbEngine->query($sql))
524 524
                         $error++;
525
-                    $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_rights (entity, fk_user, fk_id) VALUES (" . $entity . ", " . $this->id . ", " . $nid . ")";
525
+                    $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (entity, fk_user, fk_id) VALUES (".$entity.", ".$this->id.", ".$nid.")";
526 526
                     if (!Config::$dbEngine->query($sql))
527 527
                         $error++;
528 528
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 
538 538
         if (!$error && !$notrigger) {
539 539
             $langs->load("other");
540
-            $this->context = array('audit' => $langs->trans("PermissionsAdd") . ($rid ? ' (id=' . $rid . ')' : ''));
540
+            $this->context = array('audit' => $langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : ''));
541 541
 
542 542
             // Call trigger
543 543
             $result = $this->call_trigger('USER_MODIFY', $user);
@@ -581,9 +581,9 @@  discard block
 block discarded – undo
581 581
             // Si on a demande supression d'un droit en particulier, on recupere
582 582
             // les caracteristiques module, perms et subperms de ce droit.
583 583
             $sql = "SELECT module, perms, subperms";
584
-            $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def";
585
-            $sql .= " WHERE id = '" . Config::$dbEngine->escape($rid) . "'";
586
-            $sql .= " AND entity = " . $entity;
584
+            $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
585
+            $sql .= " WHERE id = '".Config::$dbEngine->escape($rid)."'";
586
+            $sql .= " AND entity = ".$entity;
587 587
 
588 588
             $result = Config::$dbEngine->query($sql);
589 589
             if ($result) {
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
             }
598 598
 
599 599
             // Where pour la liste des droits a supprimer
600
-            $wherefordel = "id=" . Config::$dbEngine->escape($rid);
600
+            $wherefordel = "id=".Config::$dbEngine->escape($rid);
601 601
             // Suppression des droits induits
602 602
             if ($subperms == 'lire' || $subperms == 'read') {
603 603
                 $wherefordel .= " OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)";
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
                 if ($allmodule == 'allmodules') {
613 613
                     $wherefordel = 'allmodules';
614 614
                 } else {
615
-                    $wherefordel = "module='" . Config::$dbEngine->escape($allmodule) . "'";
615
+                    $wherefordel = "module='".Config::$dbEngine->escape($allmodule)."'";
616 616
                     if (!empty($allperms)) {
617
-                        $whereforadd .= " AND perms='" . Config::$dbEngine->escape($allperms) . "'";
617
+                        $whereforadd .= " AND perms='".Config::$dbEngine->escape($allperms)."'";
618 618
                     }
619 619
                 }
620 620
             }
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
         if (!empty($wherefordel)) {
625 625
             //print "$module-$perms-$subperms";
626 626
             $sql = "SELECT id";
627
-            $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def";
628
-            $sql .= " WHERE entity = " . $entity;
627
+            $sql .= " FROM ".MAIN_DB_PREFIX."rights_def";
628
+            $sql .= " WHERE entity = ".$entity;
629 629
             if (!empty($wherefordel) && $wherefordel != 'allmodules') {
630
-                $sql .= " AND " . $wherefordel;
630
+                $sql .= " AND ".$wherefordel;
631 631
             }
632 632
 
633 633
             $result = Config::$dbEngine->query($sql);
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
                     $obj = Config::$dbEngine->fetch_object($result);
639 639
                     $nid = $obj->id;
640 640
 
641
-                    $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights";
642
-                    $sql .= " WHERE fk_user = " . $this->id . " AND fk_id=" . $nid;
643
-                    $sql .= " AND entity = " . $entity;
641
+                    $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights";
642
+                    $sql .= " WHERE fk_user = ".$this->id." AND fk_id=".$nid;
643
+                    $sql .= " AND entity = ".$entity;
644 644
                     if (!Config::$dbEngine->query($sql)) {
645 645
                         $error++;
646 646
                     }
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 
656 656
         if (!$error && !$notrigger) {
657 657
             $langs->load("other");
658
-            $this->context = array('audit' => $langs->trans("PermissionsDelete") . ($rid ? ' (id=' . $rid . ')' : ''));
658
+            $this->context = array('audit' => $langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : ''));
659 659
 
660 660
             // Call trigger
661 661
             $result = $this->call_trigger('USER_MODIFY', $user);
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
      */
683 683
     function clearrights()
684 684
     {
685
-        DolUtils::dol_syslog(get_class($this) . "::clearrights reset user->rights");
685
+        DolUtils::dol_syslog(get_class($this)."::clearrights reset user->rights");
686 686
         $this->rights = '';
687 687
         $this->all_permissions_are_loaded = false;
688 688
         $this->_tab_loaded = array();
@@ -715,19 +715,19 @@  discard block
 block discarded – undo
715 715
         // Recuperation des droits utilisateurs + recuperation des droits groupes
716 716
         // D'abord les droits utilisateurs
717 717
         $sql = "SELECT DISTINCT r.module, r.perms, r.subperms";
718
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user_rights as ur";
719
-        $sql .= ", " . MAIN_DB_PREFIX . "rights_def as r";
718
+        $sql .= " FROM ".MAIN_DB_PREFIX."user_rights as ur";
719
+        $sql .= ", ".MAIN_DB_PREFIX."rights_def as r";
720 720
         $sql .= " WHERE r.id = ur.fk_id";
721 721
         if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) {
722
-            $sql .= " AND r.entity IN (0," . (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "") . Globals::$conf->entity . ")";
722
+            $sql .= " AND r.entity IN (0,".(!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) ? "1," : "").Globals::$conf->entity.")";
723 723
         } else {
724
-            $sql .= " AND ur.entity = " . Globals::$conf->entity;
724
+            $sql .= " AND ur.entity = ".Globals::$conf->entity;
725 725
         }
726
-        $sql .= " AND ur.fk_user= " . $this->id;
726
+        $sql .= " AND ur.fk_user= ".$this->id;
727 727
         $sql .= " AND r.perms IS NOT NULL";
728 728
         if ($moduletag) {
729 729
             // $sql .= " AND r.module = '" . Config::$dbEngine->escape($moduletag) . "'";
730
-            $sql .= " AND r.module = '" . $moduletag . "'";
730
+            $sql .= " AND r.module = '".$moduletag."'";
731 731
         }
732 732
 
733 733
         $resql = Config::$dbEngine->select($sql);
@@ -768,25 +768,25 @@  discard block
 block discarded – undo
768 768
 
769 769
         // Maintenant les droits groupes
770 770
         $sql = "SELECT DISTINCT r.module, r.perms, r.subperms";
771
-        $sql .= " FROM " . MAIN_DB_PREFIX . "usergroup_rights as gr,";
772
-        $sql .= " " . MAIN_DB_PREFIX . "usergroup_user as gu,";
773
-        $sql .= " " . MAIN_DB_PREFIX . "rights_def as r";
771
+        $sql .= " FROM ".MAIN_DB_PREFIX."usergroup_rights as gr,";
772
+        $sql .= " ".MAIN_DB_PREFIX."usergroup_user as gu,";
773
+        $sql .= " ".MAIN_DB_PREFIX."rights_def as r";
774 774
         $sql .= " WHERE r.id = gr.fk_id";
775 775
         if (!empty($conf->global->MULTICOMPANY_BACKWARD_COMPATIBILITY)) {
776 776
             if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
777
-                $sql .= " AND gu.entity IN (0," . Globals::$conf->entity . ")";
777
+                $sql .= " AND gu.entity IN (0,".Globals::$conf->entity.")";
778 778
             } else {
779
-                $sql .= " AND r.entity = " . Globals::$conf->entity;
779
+                $sql .= " AND r.entity = ".Globals::$conf->entity;
780 780
             }
781 781
         } else {
782
-            $sql .= " AND gr.entity = " . Globals::$conf->entity;
783
-            $sql .= " AND r.entity = " . Globals::$conf->entity;
782
+            $sql .= " AND gr.entity = ".Globals::$conf->entity;
783
+            $sql .= " AND r.entity = ".Globals::$conf->entity;
784 784
         }
785 785
         $sql .= " AND gr.fk_usergroup = gu.fk_usergroup";
786
-        $sql .= " AND gu.fk_user = " . $this->id;
786
+        $sql .= " AND gu.fk_user = ".$this->id;
787 787
         $sql .= " AND r.perms IS NOT NULL";
788 788
         if ($moduletag) {
789
-            $sql .= " AND r.module = '" . $moduletag . "'";
789
+            $sql .= " AND r.module = '".$moduletag."'";
790 790
         }
791 791
 
792 792
         $resql = Config::$dbEngine->select($sql);
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
         Config::$dbEngine->begin();
867 867
 
868 868
         // Deactivate user
869
-        $sql = "UPDATE " . MAIN_DB_PREFIX . "user";
870
-        $sql .= " SET statut = " . $this->statut;
871
-        $sql .= " WHERE rowid = " . $this->id;
869
+        $sql = "UPDATE ".MAIN_DB_PREFIX."user";
870
+        $sql .= " SET statut = ".$this->statut;
871
+        $sql .= " WHERE rowid = ".$this->id;
872 872
         $result = Config::$dbEngine->query($sql);
873 873
 
874
-        DolUtils::dol_syslog(get_class($this) . "::setstatus", LOG_DEBUG);
874
+        DolUtils::dol_syslog(get_class($this)."::setstatus", LOG_DEBUG);
875 875
         if ($result) {
876 876
             // Call trigger
877 877
             $result = $this->call_trigger('USER_ENABLEDISABLE', $user);
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
         }
909 909
 
910 910
         // Get current categories
911
-        require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
911
+        require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
912 912
         $c = new Categorie(Config::$dbEngine);
913 913
         $existing = $c->containing($this->id, Categorie::TYPE_USER, 'id');
914 914
 
@@ -951,10 +951,10 @@  discard block
 block discarded – undo
951 951
 
952 952
         $this->fetch($this->id);
953 953
 
954
-        DolUtils::dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
954
+        DolUtils::dol_syslog(get_class($this)."::delete", LOG_DEBUG);
955 955
 
956 956
         // Remove rights
957
-        $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights WHERE fk_user = " . $this->id;
957
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = ".$this->id;
958 958
 
959 959
         if (!$error && !Config::$dbEngine->query($sql)) {
960 960
             $error++;
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
         }
963 963
 
964 964
         // Remove group
965
-        $sql = "DELETE FROM " . MAIN_DB_PREFIX . "usergroup_user WHERE fk_user  = " . $this->id;
965
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user WHERE fk_user  = ".$this->id;
966 966
         if (!$error && !Config::$dbEngine->query($sql)) {
967 967
             $error++;
968 968
             $this->error = Config::$dbEngine->lasterror();
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 
971 971
         // If contact, remove link
972 972
         if ($this->contact_id) {
973
-            $sql = "UPDATE " . MAIN_DB_PREFIX . "socpeople SET fk_user_creat = null WHERE rowid = " . $this->contact_id;
973
+            $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET fk_user_creat = null WHERE rowid = ".$this->contact_id;
974 974
             if (!$error && !Config::$dbEngine->query($sql)) {
975 975
                 $error++;
976 976
                 $this->error = Config::$dbEngine->lasterror();
@@ -982,14 +982,14 @@  discard block
 block discarded – undo
982 982
             $result = $this->deleteExtraFields();
983 983
             if ($result < 0) {
984 984
                 $error++;
985
-                DolUtils::dol_syslog(get_class($this) . "::delete error -4 " . $this->error, LOG_ERR);
985
+                DolUtils::dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
986 986
             }
987 987
         }
988 988
 
989 989
         // Remove user
990 990
         if (!$error) {
991
-            $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user WHERE rowid = " . $this->id;
992
-            DolUtils::dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
991
+            $sql = "DELETE FROM ".MAIN_DB_PREFIX."user WHERE rowid = ".$this->id;
992
+            DolUtils::dol_syslog(get_class($this)."::delete", LOG_DEBUG);
993 993
             if (!Config::$dbEngine->query($sql)) {
994 994
                 $error++;
995 995
                 $this->error = Config::$dbEngine->lasterror();
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
         if (!isset($this->entity)) {
1032 1032
             $this->entity = Globals::$conf->entity; // If not defined, we use default value
1033 1033
         }
1034
-        DolUtils::dol_syslog(get_class($this) . "::create login=" . $this->login . ", user=" . (is_object($user) ? $user->id : ''), LOG_DEBUG);
1034
+        DolUtils::dol_syslog(get_class($this)."::create login=".$this->login.", user=".(is_object($user) ? $user->id : ''), LOG_DEBUG);
1035 1035
 
1036 1036
         // Check parameters
1037 1037
         if (!empty($conf->global->USER_MAIL_REQUIRED) && !isValidEMail($this->email)) {
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
         $error = 0;
1051 1051
         Config::$dbEngine->begin();
1052 1052
 
1053
-        $sql = "SELECT login FROM " . MAIN_DB_PREFIX . "user";
1054
-        $sql .= " WHERE login ='" . Config::$dbEngine->escape($this->login) . "'";
1055
-        $sql .= " AND entity IN (0," . Config::$dbEngine->escape($conf->entity) . ")";
1053
+        $sql = "SELECT login FROM ".MAIN_DB_PREFIX."user";
1054
+        $sql .= " WHERE login ='".Config::$dbEngine->escape($this->login)."'";
1055
+        $sql .= " AND entity IN (0,".Config::$dbEngine->escape($conf->entity).")";
1056 1056
 
1057
-        DolUtils::dol_syslog(get_class($this) . "::create", LOG_DEBUG);
1057
+        DolUtils::dol_syslog(get_class($this)."::create", LOG_DEBUG);
1058 1058
         $resql = Config::$dbEngine->query($sql);
1059 1059
         if ($resql) {
1060 1060
             $num = Config::$dbEngine->num_rows($resql);
@@ -1062,17 +1062,17 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
             if ($num) {
1064 1064
                 $this->error = 'ErrorLoginAlreadyExists';
1065
-                DolUtils::dol_syslog(get_class($this) . "::create " . $this->error, LOG_WARNING);
1065
+                DolUtils::dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
1066 1066
                 Config::$dbEngine->rollback();
1067 1067
                 return -6;
1068 1068
             } else {
1069
-                $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user (datec,login,ldap_sid,entity)";
1070
-                $sql .= " VALUES('" . Config::$dbEngine->idate($this->datec) . "','" . Config::$dbEngine->escape($this->login) . "','" . Config::$dbEngine->escape($this->ldap_sid) . "'," . Config::$dbEngine->escape($this->entity) . ")";
1069
+                $sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec,login,ldap_sid,entity)";
1070
+                $sql .= " VALUES('".Config::$dbEngine->idate($this->datec)."','".Config::$dbEngine->escape($this->login)."','".Config::$dbEngine->escape($this->ldap_sid)."',".Config::$dbEngine->escape($this->entity).")";
1071 1071
                 $result = Config::$dbEngine->query($sql);
1072 1072
 
1073
-                DolUtils::dol_syslog(get_class($this) . "::create", LOG_DEBUG);
1073
+                DolUtils::dol_syslog(get_class($this)."::create", LOG_DEBUG);
1074 1074
                 if ($result) {
1075
-                    $this->id = Config::$dbEngine->last_insert_id(MAIN_DB_PREFIX . "user");
1075
+                    $this->id = Config::$dbEngine->last_insert_id(MAIN_DB_PREFIX."user");
1076 1076
 
1077 1077
                     // Set default rights
1078 1078
                     if ($this->set_default_rights() < 0) {
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
                     }
1090 1090
 
1091 1091
                     if (!empty($conf->global->STOCK_USERSTOCK_AUTOCREATE)) {
1092
-                        require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
1092
+                        require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
1093 1093
                         $langs->load("stocks");
1094 1094
                         $entrepot = new Entrepot(Config::$dbEngine);
1095 1095
                         $entrepot->libelle = $langs->trans("PersonalStock", $this->getFullName($langs));
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
                         return $this->id;
1114 1114
                     } else {
1115 1115
                         //$this->error=$interface->error;
1116
-                        DolUtils::dol_syslog(get_class($this) . "::create " . $this->error, LOG_ERR);
1116
+                        DolUtils::dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
1117 1117
                         Config::$dbEngine->rollback();
1118 1118
                         return -3;
1119 1119
                     }
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
         $this->employee = 0;
1167 1167
 
1168 1168
         if (empty($login)) {
1169
-            $login = strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4));
1169
+            $login = strtolower(substr($contact->firstname, 0, 4)).strtolower(substr($contact->lastname, 0, 4));
1170 1170
         }
1171 1171
         $this->login = $login;
1172 1172
 
@@ -1175,15 +1175,15 @@  discard block
 block discarded – undo
1175 1175
         // Cree et positionne $this->id
1176 1176
         $result = $this->create($user);
1177 1177
         if ($result > 0) {
1178
-            $sql = "UPDATE " . MAIN_DB_PREFIX . "user";
1179
-            $sql .= " SET fk_socpeople=" . $contact->id;
1178
+            $sql = "UPDATE ".MAIN_DB_PREFIX."user";
1179
+            $sql .= " SET fk_socpeople=".$contact->id;
1180 1180
             if ($contact->socid) {
1181
-                $sql .= ", fk_soc=" . $contact->socid;
1181
+                $sql .= ", fk_soc=".$contact->socid;
1182 1182
             }
1183
-            $sql .= " WHERE rowid=" . $this->id;
1183
+            $sql .= " WHERE rowid=".$this->id;
1184 1184
             $resql = Config::$dbEngine->query($sql);
1185 1185
 
1186
-            DolUtils::dol_syslog(get_class($this) . "::create_from_contact", LOG_DEBUG);
1186
+            DolUtils::dol_syslog(get_class($this)."::create_from_contact", LOG_DEBUG);
1187 1187
             if ($resql) {
1188 1188
                 $this->context['createfromcontact'] = 'createfromcontact';
1189 1189
 
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
             }
1207 1207
         } else {
1208 1208
             // $this->error deja positionne
1209
-            DolUtils::dol_syslog(get_class($this) . "::create_from_contact - 0");
1209
+            DolUtils::dol_syslog(get_class($this)."::create_from_contact - 0");
1210 1210
 
1211 1211
             Config::$dbEngine->rollback();
1212 1212
             return $result;
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
         $this->country_id = $member->country_id;
1242 1242
 
1243 1243
         if (empty($login)) {
1244
-            $login = strtolower(substr($member->firstname, 0, 4)) . strtolower(substr($member->lastname, 0, 4));
1244
+            $login = strtolower(substr($member->firstname, 0, 4)).strtolower(substr($member->lastname, 0, 4));
1245 1245
         }
1246 1246
         $this->login = $login;
1247 1247
 
@@ -1256,11 +1256,11 @@  discard block
 block discarded – undo
1256 1256
             }
1257 1257
 
1258 1258
             if ($result > 0 && $member->fk_soc) { // If member is linked to a thirdparty
1259
-                $sql = "UPDATE " . MAIN_DB_PREFIX . "user";
1260
-                $sql .= " SET fk_soc=" . $member->fk_soc;
1261
-                $sql .= " WHERE rowid=" . $this->id;
1259
+                $sql = "UPDATE ".MAIN_DB_PREFIX."user";
1260
+                $sql .= " SET fk_soc=".$member->fk_soc;
1261
+                $sql .= " WHERE rowid=".$this->id;
1262 1262
 
1263
-                DolUtils::dol_syslog(get_class($this) . "::create_from_member", LOG_DEBUG);
1263
+                DolUtils::dol_syslog(get_class($this)."::create_from_member", LOG_DEBUG);
1264 1264
                 $resql = Config::$dbEngine->query($sql);
1265 1265
                 if ($resql) {
1266 1266
                     Config::$dbEngine->commit();
@@ -1295,9 +1295,9 @@  discard block
 block discarded – undo
1295 1295
         // phpcs:enable
1296 1296
         global $conf;
1297 1297
 
1298
-        $sql = "SELECT id FROM " . MAIN_DB_PREFIX . "rights_def";
1298
+        $sql = "SELECT id FROM ".MAIN_DB_PREFIX."rights_def";
1299 1299
         $sql .= " WHERE bydefault = 1";
1300
-        $sql .= " AND entity = " . Globals::$conf->entity;
1300
+        $sql .= " AND entity = ".Globals::$conf->entity;
1301 1301
 
1302 1302
         $resql = Config::$dbEngine->query($sql);
1303 1303
         if ($resql) {
@@ -1314,10 +1314,10 @@  discard block
 block discarded – undo
1314 1314
         $i = 0;
1315 1315
         while ($i < $num) {
1316 1316
 
1317
-            $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]";
1317
+            $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user = $this->id AND fk_id=$rd[$i]";
1318 1318
             $result = Config::$dbEngine->query($sql);
1319 1319
 
1320
-            $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_rights (fk_user, fk_id) VALUES ($this->id, $rd[$i])";
1320
+            $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_rights (fk_user, fk_id) VALUES ($this->id, $rd[$i])";
1321 1321
             $result = Config::$dbEngine->query($sql);
1322 1322
             if (!$result) {
1323 1323
                 return -1;
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
         $nbrowsaffected = 0;
1346 1346
         $error = 0;
1347 1347
 
1348
-        DolUtils::dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncmember=" . $nosyncmember . ", nosyncmemberpass=" . $nosyncmemberpass);
1348
+        DolUtils::dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncmember=".$nosyncmember.", nosyncmemberpass=".$nosyncmemberpass);
1349 1349
 
1350 1350
         // Clean parameters
1351 1351
         $this->lastname = trim($this->lastname);
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
         $this->job = trim($this->job);
1374 1374
         $this->signature = trim($this->signature);
1375 1375
         $this->note = trim($this->note);
1376
-        $this->openid = trim(empty($this->openid) ? '' : $this->openid);    // Avoid warning
1376
+        $this->openid = trim(empty($this->openid) ? '' : $this->openid); // Avoid warning
1377 1377
         $this->admin = $this->admin ? $this->admin : 0;
1378 1378
         $this->address = empty($this->address) ? '' : $this->address;
1379 1379
         $this->zip = empty($this->zip) ? '' : $this->zip;
@@ -1398,59 +1398,59 @@  discard block
 block discarded – undo
1398 1398
         Config::$dbEngine->begin();
1399 1399
 
1400 1400
         // Update datas
1401
-        $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET";
1402
-        $sql .= " lastname = '" . Config::$dbEngine->escape($this->lastname) . "'";
1403
-        $sql .= ", firstname = '" . Config::$dbEngine->escape($this->firstname) . "'";
1404
-        $sql .= ", employee = " . $this->employee;
1405
-        $sql .= ", login = '" . Config::$dbEngine->escape($this->login) . "'";
1406
-        $sql .= ", api_key = " . ($this->api_key ? "'" . Config::$dbEngine->escape($this->api_key) . "'" : "null");
1407
-        $sql .= ", gender = " . ($this->gender != -1 ? "'" . Config::$dbEngine->escape($this->gender) . "'" : "null"); // 'man' or 'woman'
1408
-        $sql .= ", birth=" . (strval($this->birth) != '' ? "'" . Config::$dbEngine->idate($this->birth) . "'" : 'null');
1401
+        $sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
1402
+        $sql .= " lastname = '".Config::$dbEngine->escape($this->lastname)."'";
1403
+        $sql .= ", firstname = '".Config::$dbEngine->escape($this->firstname)."'";
1404
+        $sql .= ", employee = ".$this->employee;
1405
+        $sql .= ", login = '".Config::$dbEngine->escape($this->login)."'";
1406
+        $sql .= ", api_key = ".($this->api_key ? "'".Config::$dbEngine->escape($this->api_key)."'" : "null");
1407
+        $sql .= ", gender = ".($this->gender != -1 ? "'".Config::$dbEngine->escape($this->gender)."'" : "null"); // 'man' or 'woman'
1408
+        $sql .= ", birth=".(strval($this->birth) != '' ? "'".Config::$dbEngine->idate($this->birth)."'" : 'null');
1409 1409
         if (!empty($user->admin)) {
1410
-            $sql .= ", admin = " . $this->admin; // admin flag can be set/unset only by an admin user
1411
-        }
1412
-        $sql .= ", address = '" . Config::$dbEngine->escape($this->address) . "'";
1413
-        $sql .= ", zip = '" . Config::$dbEngine->escape($this->zip) . "'";
1414
-        $sql .= ", town = '" . Config::$dbEngine->escape($this->town) . "'";
1415
-        $sql .= ", fk_state = " . ((!empty($this->state_id) && $this->state_id > 0) ? "'" . Config::$dbEngine->escape($this->state_id) . "'" : "null");
1416
-        $sql .= ", fk_country = " . ((!empty($this->country_id) && $this->country_id > 0) ? "'" . Config::$dbEngine->escape($this->country_id) . "'" : "null");
1417
-        $sql .= ", office_phone = '" . Config::$dbEngine->escape($this->office_phone) . "'";
1418
-        $sql .= ", office_fax = '" . Config::$dbEngine->escape($this->office_fax) . "'";
1419
-        $sql .= ", user_mobile = '" . Config::$dbEngine->escape($this->user_mobile) . "'";
1420
-        $sql .= ", email = '" . Config::$dbEngine->escape($this->email) . "'";
1421
-        $sql .= ", skype = '" . Config::$dbEngine->escape($this->skype) . "'";
1422
-        $sql .= ", twitter = '" . Config::$dbEngine->escape($this->twitter) . "'";
1423
-        $sql .= ", facebook = '" . Config::$dbEngine->escape($this->facebook) . "'";
1424
-        $sql .= ", job = '" . Config::$dbEngine->escape($this->job) . "'";
1425
-        $sql .= ", signature = '" . Config::$dbEngine->escape($this->signature) . "'";
1426
-        $sql .= ", accountancy_code = '" . Config::$dbEngine->escape($this->accountancy_code) . "'";
1427
-        $sql .= ", color = '" . Config::$dbEngine->escape($this->color) . "'";
1428
-        $sql .= ", dateemployment=" . (strval($this->dateemployment) != '' ? "'" . Config::$dbEngine->idate($this->dateemployment) . "'" : 'null');
1429
-        $sql .= ", dateemploymentend=" . (strval($this->dateemploymentend) != '' ? "'" . Config::$dbEngine->idate($this->dateemploymentend) . "'" : 'null');
1430
-        $sql .= ", note = '" . Config::$dbEngine->escape($this->note) . "'";
1431
-        $sql .= ", photo = " . ($this->photo ? "'" . Config::$dbEngine->escape($this->photo) . "'" : "null");
1432
-        $sql .= ", openid = " . ($this->openid ? "'" . Config::$dbEngine->escape($this->openid) . "'" : "null");
1433
-        $sql .= ", fk_user = " . ($this->fk_user > 0 ? "'" . Config::$dbEngine->escape($this->fk_user) . "'" : "null");
1410
+            $sql .= ", admin = ".$this->admin; // admin flag can be set/unset only by an admin user
1411
+        }
1412
+        $sql .= ", address = '".Config::$dbEngine->escape($this->address)."'";
1413
+        $sql .= ", zip = '".Config::$dbEngine->escape($this->zip)."'";
1414
+        $sql .= ", town = '".Config::$dbEngine->escape($this->town)."'";
1415
+        $sql .= ", fk_state = ".((!empty($this->state_id) && $this->state_id > 0) ? "'".Config::$dbEngine->escape($this->state_id)."'" : "null");
1416
+        $sql .= ", fk_country = ".((!empty($this->country_id) && $this->country_id > 0) ? "'".Config::$dbEngine->escape($this->country_id)."'" : "null");
1417
+        $sql .= ", office_phone = '".Config::$dbEngine->escape($this->office_phone)."'";
1418
+        $sql .= ", office_fax = '".Config::$dbEngine->escape($this->office_fax)."'";
1419
+        $sql .= ", user_mobile = '".Config::$dbEngine->escape($this->user_mobile)."'";
1420
+        $sql .= ", email = '".Config::$dbEngine->escape($this->email)."'";
1421
+        $sql .= ", skype = '".Config::$dbEngine->escape($this->skype)."'";
1422
+        $sql .= ", twitter = '".Config::$dbEngine->escape($this->twitter)."'";
1423
+        $sql .= ", facebook = '".Config::$dbEngine->escape($this->facebook)."'";
1424
+        $sql .= ", job = '".Config::$dbEngine->escape($this->job)."'";
1425
+        $sql .= ", signature = '".Config::$dbEngine->escape($this->signature)."'";
1426
+        $sql .= ", accountancy_code = '".Config::$dbEngine->escape($this->accountancy_code)."'";
1427
+        $sql .= ", color = '".Config::$dbEngine->escape($this->color)."'";
1428
+        $sql .= ", dateemployment=".(strval($this->dateemployment) != '' ? "'".Config::$dbEngine->idate($this->dateemployment)."'" : 'null');
1429
+        $sql .= ", dateemploymentend=".(strval($this->dateemploymentend) != '' ? "'".Config::$dbEngine->idate($this->dateemploymentend)."'" : 'null');
1430
+        $sql .= ", note = '".Config::$dbEngine->escape($this->note)."'";
1431
+        $sql .= ", photo = ".($this->photo ? "'".Config::$dbEngine->escape($this->photo)."'" : "null");
1432
+        $sql .= ", openid = ".($this->openid ? "'".Config::$dbEngine->escape($this->openid)."'" : "null");
1433
+        $sql .= ", fk_user = ".($this->fk_user > 0 ? "'".Config::$dbEngine->escape($this->fk_user)."'" : "null");
1434 1434
         if (isset($this->thm) || $this->thm != '') {
1435
-            $sql .= ", thm= " . ($this->thm != '' ? "'" . Config::$dbEngine->escape($this->thm) . "'" : "null");
1435
+            $sql .= ", thm= ".($this->thm != '' ? "'".Config::$dbEngine->escape($this->thm)."'" : "null");
1436 1436
         }
1437 1437
         if (isset($this->tjm) || $this->tjm != '') {
1438
-            $sql .= ", tjm= " . ($this->tjm != '' ? "'" . Config::$dbEngine->escape($this->tjm) . "'" : "null");
1438
+            $sql .= ", tjm= ".($this->tjm != '' ? "'".Config::$dbEngine->escape($this->tjm)."'" : "null");
1439 1439
         }
1440 1440
         if (isset($this->salary) || $this->salary != '') {
1441
-            $sql .= ", salary= " . ($this->salary != '' ? "'" . Config::$dbEngine->escape($this->salary) . "'" : "null");
1441
+            $sql .= ", salary= ".($this->salary != '' ? "'".Config::$dbEngine->escape($this->salary)."'" : "null");
1442 1442
         }
1443 1443
         if (isset($this->salaryextra) || $this->salaryextra != '') {
1444
-            $sql .= ", salaryextra= " . ($this->salaryextra != '' ? "'" . Config::$dbEngine->escape($this->salaryextra) . "'" : "null");
1444
+            $sql .= ", salaryextra= ".($this->salaryextra != '' ? "'".Config::$dbEngine->escape($this->salaryextra)."'" : "null");
1445 1445
         }
1446
-        $sql .= ", weeklyhours= " . ($this->weeklyhours != '' ? "'" . Config::$dbEngine->escape($this->weeklyhours) . "'" : "null");
1447
-        $sql .= ", entity = '" . Config::$dbEngine->escape($this->entity) . "'";
1448
-        $sql .= ", default_range = " . ($this->default_range > 0 ? $this->default_range : 'null');
1449
-        $sql .= ", default_c_exp_tax_cat = " . ($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
1446
+        $sql .= ", weeklyhours= ".($this->weeklyhours != '' ? "'".Config::$dbEngine->escape($this->weeklyhours)."'" : "null");
1447
+        $sql .= ", entity = '".Config::$dbEngine->escape($this->entity)."'";
1448
+        $sql .= ", default_range = ".($this->default_range > 0 ? $this->default_range : 'null');
1449
+        $sql .= ", default_c_exp_tax_cat = ".($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null');
1450 1450
 
1451
-        $sql .= " WHERE rowid = " . $this->id;
1451
+        $sql .= " WHERE rowid = ".$this->id;
1452 1452
 
1453
-        DolUtils::dol_syslog(get_class($this) . "::update", LOG_DEBUG);
1453
+        DolUtils::dol_syslog(get_class($this)."::update", LOG_DEBUG);
1454 1454
         $resql = Config::$dbEngine->query($sql);
1455 1455
         if ($resql) {
1456 1456
             $nbrowsaffected += Config::$dbEngine->affected_rows($resql);
@@ -1468,8 +1468,8 @@  discard block
 block discarded – undo
1468 1468
 
1469 1469
             // If user is linked to a member, remove old link to this member
1470 1470
             if ($this->fk_member > 0) {
1471
-                DolUtils::dol_syslog(get_class($this) . "::update remove link with member. We will recreate it later", LOG_DEBUG);
1472
-                $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member = NULL where fk_member = " . $this->fk_member;
1471
+                DolUtils::dol_syslog(get_class($this)."::update remove link with member. We will recreate it later", LOG_DEBUG);
1472
+                $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL where fk_member = ".$this->fk_member;
1473 1473
                 $resql = Config::$dbEngine->query($sql);
1474 1474
                 if (!$resql) {
1475 1475
                     $this->error = Config::$dbEngine->error();
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
                 }
1479 1479
             }
1480 1480
             // Set link to user
1481
-            DolUtils::dol_syslog(get_class($this) . "::update set link with member", LOG_DEBUG);
1482
-            $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET fk_member =" . ($this->fk_member > 0 ? $this->fk_member : 'null') . " where rowid = " . $this->id;
1481
+            DolUtils::dol_syslog(get_class($this)."::update set link with member", LOG_DEBUG);
1482
+            $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member =".($this->fk_member > 0 ? $this->fk_member : 'null')." where rowid = ".$this->id;
1483 1483
             $resql = Config::$dbEngine->query($sql);
1484 1484
             if (!$resql) {
1485 1485
                 $this->error = Config::$dbEngine->error();
@@ -1489,9 +1489,9 @@  discard block
 block discarded – undo
1489 1489
 
1490 1490
             if ($nbrowsaffected) { // If something has changed in data
1491 1491
                 if ($this->fk_member > 0 && !$nosyncmember) {
1492
-                    DolUtils::dol_syslog(get_class($this) . "::update user is linked with a member. We try to update member too.", LOG_DEBUG);
1492
+                    DolUtils::dol_syslog(get_class($this)."::update user is linked with a member. We try to update member too.", LOG_DEBUG);
1493 1493
 
1494
-                    require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
1494
+                    require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
1495 1495
 
1496 1496
                     // This user is linked with a member, so we also update member information
1497 1497
                     // if this is an update.
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
                         if ($result < 0) {
1532 1532
                             $this->error = $adh->error;
1533 1533
                             $this->errors = $adh->errors;
1534
-                            DolUtils::dol_syslog(get_class($this) . "::update error after calling adh->update to sync it with user: " . $this->error, LOG_ERR);
1534
+                            DolUtils::dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
1535 1535
                             $error++;
1536 1536
                         }
1537 1537
                     } else {
@@ -1542,9 +1542,9 @@  discard block
 block discarded – undo
1542 1542
                 }
1543 1543
 
1544 1544
                 if ($this->contact_id > 0 && !$nosynccontact) {
1545
-                    DolUtils::dol_syslog(get_class($this) . "::update user is linked with a contact. We try to update contact too.", LOG_DEBUG);
1545
+                    DolUtils::dol_syslog(get_class($this)."::update user is linked with a contact. We try to update contact too.", LOG_DEBUG);
1546 1546
 
1547
-                    require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
1547
+                    require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
1548 1548
 
1549 1549
                     // This user is linked with a contact, so we also update contact information
1550 1550
                     // if this is an update.
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
                         if ($result < 0) {
1585 1585
                             $this->error = $tmpobj->error;
1586 1586
                             $this->errors = $tmpobj->errors;
1587
-                            DolUtils::dol_syslog(get_class($this) . "::update error after calling adh->update to sync it with user: " . $this->error, LOG_ERR);
1587
+                            DolUtils::dol_syslog(get_class($this)."::update error after calling adh->update to sync it with user: ".$this->error, LOG_ERR);
1588 1588
                             $error++;
1589 1589
                         }
1590 1590
                     } else {
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
                 Config::$dbEngine->commit();
1619 1619
                 return $nbrowsaffected;
1620 1620
             } else {
1621
-                DolUtils::dol_syslog(get_class($this) . "::update error=" . $this->error, LOG_ERR);
1621
+                DolUtils::dol_syslog(get_class($this)."::update error=".$this->error, LOG_ERR);
1622 1622
                 Config::$dbEngine->rollback();
1623 1623
                 return -1;
1624 1624
             }
@@ -1641,20 +1641,20 @@  discard block
 block discarded – undo
1641 1641
         // phpcs:enable
1642 1642
         $now = dol_now();
1643 1643
 
1644
-        $sql = "UPDATE " . MAIN_DB_PREFIX . "user SET";
1644
+        $sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
1645 1645
         $sql .= " datepreviouslogin = datelastlogin,";
1646
-        $sql .= " datelastlogin = '" . Config::$dbEngine->idate($now) . "',";
1647
-        $sql .= " tms = tms";    // La date de derniere modif doit changer sauf pour la mise a jour de date de derniere connexion
1648
-        $sql .= " WHERE rowid = " . $this->id;
1646
+        $sql .= " datelastlogin = '".Config::$dbEngine->idate($now)."',";
1647
+        $sql .= " tms = tms"; // La date de derniere modif doit changer sauf pour la mise a jour de date de derniere connexion
1648
+        $sql .= " WHERE rowid = ".$this->id;
1649 1649
 
1650
-        DolUtils::dol_syslog(get_class($this) . "::update_last_login_date user->id=" . $this->id . " " . $sql, LOG_DEBUG);
1650
+        DolUtils::dol_syslog(get_class($this)."::update_last_login_date user->id=".$this->id." ".$sql, LOG_DEBUG);
1651 1651
         $resql = Config::$dbEngine->query($sql);
1652 1652
         if ($resql) {
1653 1653
             $this->datepreviouslogin = $this->datelastlogin;
1654 1654
             $this->datelastlogin = $now;
1655 1655
             return 1;
1656 1656
         } else {
1657
-            $this->error = Config::$dbEngine->lasterror() . ' sql=' . $sql;
1657
+            $this->error = Config::$dbEngine->lasterror().' sql='.$sql;
1658 1658
             return -1;
1659 1659
         }
1660 1660
     }
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
     function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0)
1673 1673
     {
1674 1674
         global $conf, $langs;
1675
-        require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php';
1675
+        require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
1676 1676
 
1677 1677
         $error = 0;
1678 1678
 
1679
-        DolUtils::dol_syslog(get_class($this) . "::setPassword user=" . $user->id . " password=" . preg_replace('/./i', '*', $password) . " changelater=" . $changelater . " notrigger=" . $notrigger . " nosyncmember=" . $nosyncmember, LOG_DEBUG);
1679
+        DolUtils::dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i', '*', $password)." changelater=".$changelater." notrigger=".$notrigger." nosyncmember=".$nosyncmember, LOG_DEBUG);
1680 1680
 
1681 1681
         // If new password not provided, we generate one
1682 1682
         if (!$password) {
@@ -1694,17 +1694,17 @@  discard block
 block discarded – undo
1694 1694
 
1695 1695
             Config::$dbEngine->begin();
1696 1696
 
1697
-            $sql = "UPDATE " . MAIN_DB_PREFIX . "user";
1698
-            $sql .= " SET pass_crypted = '" . Config::$dbEngine->escape($password_crypted) . "',";
1697
+            $sql = "UPDATE ".MAIN_DB_PREFIX."user";
1698
+            $sql .= " SET pass_crypted = '".Config::$dbEngine->escape($password_crypted)."',";
1699 1699
             $sql .= " pass_temp = null";
1700 1700
             if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {
1701 1701
                 $sql .= ", pass = null";
1702 1702
             } else {
1703
-                $sql .= ", pass = '" . Config::$dbEngine->escape($password) . "'";
1703
+                $sql .= ", pass = '".Config::$dbEngine->escape($password)."'";
1704 1704
             }
1705
-            $sql .= " WHERE rowid = " . $this->id;
1705
+            $sql .= " WHERE rowid = ".$this->id;
1706 1706
 
1707
-            DolUtils::dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG);
1707
+            DolUtils::dol_syslog(get_class($this)."::setPassword", LOG_DEBUG);
1708 1708
             $result = Config::$dbEngine->query($sql);
1709 1709
             if ($result) {
1710 1710
                 if (Config::$dbEngine->affected_rows($result)) {
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
                     $this->pass_indatabase_crypted = $password_crypted;
1714 1714
 
1715 1715
                     if ($this->fk_member && !$nosyncmember) {
1716
-                        require_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php';
1716
+                        require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
1717 1717
 
1718 1718
                         // This user is linked with a member, so we also update members informations
1719 1719
                         // if this is an update.
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
                             $result = $adh->setPassword($user, $this->pass, (empty($conf->global->DATABASE_PWD_ENCRYPTED) ? 0 : 1), 1); // Cryptage non gere dans module adherent
1725 1725
                             if ($result < 0) {
1726 1726
                                 $this->error = $adh->error;
1727
-                                DolUtils::dol_syslog(get_class($this) . "::setPassword " . $this->error, LOG_ERR);
1727
+                                DolUtils::dol_syslog(get_class($this)."::setPassword ".$this->error, LOG_ERR);
1728 1728
                                 $error++;
1729 1729
                             }
1730 1730
                         } else {
@@ -1733,7 +1733,7 @@  discard block
 block discarded – undo
1733 1733
                         }
1734 1734
                     }
1735 1735
 
1736
-                    DolUtils::dol_syslog(get_class($this) . "::setPassword notrigger=" . $notrigger . " error=" . $error, LOG_DEBUG);
1736
+                    DolUtils::dol_syslog(get_class($this)."::setPassword notrigger=".$notrigger." error=".$error, LOG_DEBUG);
1737 1737
 
1738 1738
                     if (!$error && !$notrigger) {
1739 1739
                         // Call trigger
@@ -1760,11 +1760,11 @@  discard block
 block discarded – undo
1760 1760
         } else {
1761 1761
             // We store clear password in password temporary field.
1762 1762
             // After receiving confirmation link, we will crypt it and store it in pass_crypted
1763
-            $sql = "UPDATE " . MAIN_DB_PREFIX . "user";
1764
-            $sql .= " SET pass_temp = '" . Config::$dbEngine->escape($password) . "'";
1765
-            $sql .= " WHERE rowid = " . $this->id;
1763
+            $sql = "UPDATE ".MAIN_DB_PREFIX."user";
1764
+            $sql .= " SET pass_temp = '".Config::$dbEngine->escape($password)."'";
1765
+            $sql .= " WHERE rowid = ".$this->id;
1766 1766
 
1767
-            DolUtils::dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG); // No log
1767
+            DolUtils::dol_syslog(get_class($this)."::setPassword", LOG_DEBUG); // No log
1768 1768
             $result = Config::$dbEngine->query($sql);
1769 1769
             if ($result) {
1770 1770
                 return $password;
@@ -1790,7 +1790,7 @@  discard block
 block discarded – undo
1790 1790
         global $conf, $langs;
1791 1791
         global $dolibarr_main_url_root;
1792 1792
 
1793
-        require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
1793
+        require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
1794 1794
 
1795 1795
         $msgishtml = 0;
1796 1796
 
@@ -1815,36 +1815,36 @@  discard block
 block discarded – undo
1815 1815
         $subject = $outputlangs->transnoentitiesnoconv("SubjectNewPassword", $appli);
1816 1816
 
1817 1817
         // Define $urlwithroot
1818
-        $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_URL_ROOT, '/') . '$/i', '', trim($dolibarr_main_url_root));
1819
-        $urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;  // This is to use external domain name found into config file
1818
+        $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
1819
+        $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
1820 1820
 
1821 1821
         if (!$changelater) {
1822
-            $url = $urlwithroot . '/';
1822
+            $url = $urlwithroot.'/';
1823 1823
 
1824
-            $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . ".\n";
1825
-            $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs") . " :\n\n";
1826
-            $mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
1827
-            $mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
1824
+            $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived").".\n";
1825
+            $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyIs")." :\n\n";
1826
+            $mesg .= $outputlangs->transnoentitiesnoconv("Login")." = ".$this->login."\n";
1827
+            $mesg .= $outputlangs->transnoentitiesnoconv("Password")." = ".$password."\n\n";
1828 1828
             $mesg .= "\n";
1829 1829
 
1830
-            $mesg .= $outputlangs->transnoentitiesnoconv("ClickHereToGoTo", $appli) . ': ' . $url . "\n\n";
1830
+            $mesg .= $outputlangs->transnoentitiesnoconv("ClickHereToGoTo", $appli).': '.$url."\n\n";
1831 1831
             $mesg .= "--\n";
1832 1832
             $mesg .= $user->getFullName($outputlangs); // Username that make then sending
1833 1833
 
1834
-            DolUtils::dol_syslog(get_class($this) . "::send_password changelater is off, url=" . $url);
1834
+            DolUtils::dol_syslog(get_class($this)."::send_password changelater is off, url=".$url);
1835 1835
         } else {
1836
-            $url = $urlwithroot . '/user/passwordforgotten.php?action=validatenewpassword&username=' . $this->login . "&passwordhash=" . dol_hash($password);
1836
+            $url = $urlwithroot.'/user/passwordforgotten.php?action=validatenewpassword&username='.$this->login."&passwordhash=".dol_hash($password);
1837 1837
 
1838
-            $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived") . "\n";
1839
-            $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyWillBe") . " :\n\n";
1840
-            $mesg .= $outputlangs->transnoentitiesnoconv("Login") . " = " . $this->login . "\n";
1841
-            $mesg .= $outputlangs->transnoentitiesnoconv("Password") . " = " . $password . "\n\n";
1838
+            $mesg .= $outputlangs->transnoentitiesnoconv("RequestToResetPasswordReceived")."\n";
1839
+            $mesg .= $outputlangs->transnoentitiesnoconv("NewKeyWillBe")." :\n\n";
1840
+            $mesg .= $outputlangs->transnoentitiesnoconv("Login")." = ".$this->login."\n";
1841
+            $mesg .= $outputlangs->transnoentitiesnoconv("Password")." = ".$password."\n\n";
1842 1842
             $mesg .= "\n";
1843
-            $mesg .= $outputlangs->transnoentitiesnoconv("YouMustClickToChange") . " :\n";
1844
-            $mesg .= $url . "\n\n";
1845
-            $mesg .= $outputlangs->transnoentitiesnoconv("ForgetIfNothing") . "\n\n";
1843
+            $mesg .= $outputlangs->transnoentitiesnoconv("YouMustClickToChange")." :\n";
1844
+            $mesg .= $url."\n\n";
1845
+            $mesg .= $outputlangs->transnoentitiesnoconv("ForgetIfNothing")."\n\n";
1846 1846
 
1847
-            DolUtils::dol_syslog(get_class($this) . "::send_password changelater is on, url=" . $url);
1847
+            DolUtils::dol_syslog(get_class($this)."::send_password changelater is on, url=".$url);
1848 1848
         }
1849 1849
 
1850 1850
         $mailfile = new CMailFile(
@@ -1855,7 +1855,7 @@  discard block
 block discarded – undo
1855 1855
             return 1;
1856 1856
         } else {
1857 1857
             $langs->trans("errors");
1858
-            $this->error = $langs->trans("ErrorFailedToSendPassword") . ' ' . $mailfile->error;
1858
+            $this->error = $langs->trans("ErrorFailedToSendPassword").' '.$mailfile->error;
1859 1859
             return -1;
1860 1860
         }
1861 1861
     }
@@ -1880,8 +1880,8 @@  discard block
 block discarded – undo
1880 1880
     {
1881 1881
         // phpcs:enable
1882 1882
         $sql = "SELECT url, login, pass, poste ";
1883
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user_clicktodial as u";
1884
-        $sql .= " WHERE u.fk_user = " . $this->id;
1883
+        $sql .= " FROM ".MAIN_DB_PREFIX."user_clicktodial as u";
1884
+        $sql .= " WHERE u.fk_user = ".$this->id;
1885 1885
 
1886 1886
         $resql = Config::$dbEngine->query($sql);
1887 1887
         if ($resql) {
@@ -1915,21 +1915,21 @@  discard block
 block discarded – undo
1915 1915
         // phpcs:enable
1916 1916
         Config::$dbEngine->begin();
1917 1917
 
1918
-        $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_clicktodial";
1919
-        $sql .= " WHERE fk_user = " . $this->id;
1918
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."user_clicktodial";
1919
+        $sql .= " WHERE fk_user = ".$this->id;
1920 1920
 
1921
-        DolUtils::dol_syslog(get_class($this) . '::update_clicktodial', LOG_DEBUG);
1921
+        DolUtils::dol_syslog(get_class($this).'::update_clicktodial', LOG_DEBUG);
1922 1922
         $result = Config::$dbEngine->query($sql);
1923 1923
 
1924
-        $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_clicktodial";
1924
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_clicktodial";
1925 1925
         $sql .= " (fk_user,url,login,pass,poste)";
1926
-        $sql .= " VALUES (" . $this->id;
1927
-        $sql .= ", '" . Config::$dbEngine->escape($this->clicktodial_url) . "'";
1928
-        $sql .= ", '" . Config::$dbEngine->escape($this->clicktodial_login) . "'";
1929
-        $sql .= ", '" . Config::$dbEngine->escape($this->clicktodial_password) . "'";
1930
-        $sql .= ", '" . Config::$dbEngine->escape($this->clicktodial_poste) . "')";
1926
+        $sql .= " VALUES (".$this->id;
1927
+        $sql .= ", '".Config::$dbEngine->escape($this->clicktodial_url)."'";
1928
+        $sql .= ", '".Config::$dbEngine->escape($this->clicktodial_login)."'";
1929
+        $sql .= ", '".Config::$dbEngine->escape($this->clicktodial_password)."'";
1930
+        $sql .= ", '".Config::$dbEngine->escape($this->clicktodial_poste)."')";
1931 1931
 
1932
-        DolUtils::dol_syslog(get_class($this) . '::update_clicktodial', LOG_DEBUG);
1932
+        DolUtils::dol_syslog(get_class($this).'::update_clicktodial', LOG_DEBUG);
1933 1933
         $result = Config::$dbEngine->query($sql);
1934 1934
         if ($result) {
1935 1935
             Config::$dbEngine->commit();
@@ -1959,20 +1959,20 @@  discard block
 block discarded – undo
1959 1959
 
1960 1960
         Config::$dbEngine->begin();
1961 1961
 
1962
-        $sql = "DELETE FROM " . MAIN_DB_PREFIX . "usergroup_user";
1963
-        $sql .= " WHERE fk_user  = " . $this->id;
1964
-        $sql .= " AND fk_usergroup = " . $group;
1965
-        $sql .= " AND entity = " . $entity;
1962
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
1963
+        $sql .= " WHERE fk_user  = ".$this->id;
1964
+        $sql .= " AND fk_usergroup = ".$group;
1965
+        $sql .= " AND entity = ".$entity;
1966 1966
 
1967 1967
         $result = Config::$dbEngine->query($sql);
1968 1968
 
1969
-        $sql = "INSERT INTO " . MAIN_DB_PREFIX . "usergroup_user (entity, fk_user, fk_usergroup)";
1970
-        $sql .= " VALUES (" . $entity . "," . $this->id . "," . $group . ")";
1969
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup_user (entity, fk_user, fk_usergroup)";
1970
+        $sql .= " VALUES (".$entity.",".$this->id.",".$group.")";
1971 1971
 
1972 1972
         $result = Config::$dbEngine->query($sql);
1973 1973
         if ($result) {
1974 1974
             if (!$error && !$notrigger) {
1975
-                $this->newgroupid = $group;    // deprecated. Remove this.
1975
+                $this->newgroupid = $group; // deprecated. Remove this.
1976 1976
                 $this->context = array('audit' => $langs->trans("UserSetInGroup"), 'newgroupid' => $group);
1977 1977
 
1978 1978
                 // Call trigger
@@ -1987,7 +1987,7 @@  discard block
 block discarded – undo
1987 1987
                 Config::$dbEngine->commit();
1988 1988
                 return 1;
1989 1989
             } else {
1990
-                DolUtils::dol_syslog(get_class($this) . "::SetInGroup " . $this->error, LOG_ERR);
1990
+                DolUtils::dol_syslog(get_class($this)."::SetInGroup ".$this->error, LOG_ERR);
1991 1991
                 Config::$dbEngine->rollback();
1992 1992
                 return -2;
1993 1993
             }
@@ -2016,15 +2016,15 @@  discard block
 block discarded – undo
2016 2016
 
2017 2017
         Config::$dbEngine->begin();
2018 2018
 
2019
-        $sql = "DELETE FROM " . MAIN_DB_PREFIX . "usergroup_user";
2020
-        $sql .= " WHERE fk_user  = " . $this->id;
2021
-        $sql .= " AND fk_usergroup = " . $group;
2022
-        $sql .= " AND entity = " . $entity;
2019
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
2020
+        $sql .= " WHERE fk_user  = ".$this->id;
2021
+        $sql .= " AND fk_usergroup = ".$group;
2022
+        $sql .= " AND entity = ".$entity;
2023 2023
 
2024 2024
         $result = Config::$dbEngine->query($sql);
2025 2025
         if ($result) {
2026 2026
             if (!$error && !$notrigger) {
2027
-                $this->oldgroupid = $group;    // deprecated. Remove this.
2027
+                $this->oldgroupid = $group; // deprecated. Remove this.
2028 2028
                 $this->context = array('audit' => $langs->trans("UserRemovedFromGroup"), 'oldgroupid' => $group);
2029 2029
 
2030 2030
                 // Call trigger
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
                 return 1;
2041 2041
             } else {
2042 2042
                 $this->error = $interface->error;
2043
-                DolUtils::dol_syslog(get_class($this) . "::RemoveFromGroup " . $this->error, LOG_ERR);
2043
+                DolUtils::dol_syslog(get_class($this)."::RemoveFromGroup ".$this->error, LOG_ERR);
2044 2044
                 Config::$dbEngine->rollback();
2045 2045
                 return -2;
2046 2046
             }
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
     function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '')
2065 2065
     {
2066 2066
         // $result = '<a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $this->id . '">';
2067
-        $result = '<a href="' . BASE_URI . '?controller=user&method=card&id=' . $this->id . '">';
2067
+        $result = '<a href="'.BASE_URI.'?controller=user&method=card&id='.$this->id.'">';
2068 2068
         $result .= Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize);
2069 2069
         $result .= '</a>';
2070 2070
 
@@ -2114,49 +2114,49 @@  discard block
 block discarded – undo
2114 2114
 
2115 2115
         // Info Login
2116 2116
         $label .= '<div class="centpercent">';
2117
-        $label .= '<u>' . $langs->trans("User") . '</u><br>';
2118
-        $label .= '<b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs, '');
2117
+        $label .= '<u>'.$langs->trans("User").'</u><br>';
2118
+        $label .= '<b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs, '');
2119 2119
         if (!empty($this->login)) {
2120
-            $label .= '<br><b>' . $langs->trans('Login') . ':</b> ' . $this->login;
2120
+            $label .= '<br><b>'.$langs->trans('Login').':</b> '.$this->login;
2121 2121
         }
2122
-        $label .= '<br><b>' . $langs->trans("EMail") . ':</b> ' . $this->email;
2122
+        $label .= '<br><b>'.$langs->trans("EMail").':</b> '.$this->email;
2123 2123
         if (!empty($this->admin)) {
2124
-            $label .= '<br><b>' . $langs->trans("Administrator") . '</b>: ' . yn($this->admin);
2124
+            $label .= '<br><b>'.$langs->trans("Administrator").'</b>: '.yn($this->admin);
2125 2125
         }
2126 2126
         if (!empty($this->socid)) { // Add thirdparty for external users
2127 2127
             $thirdpartystatic = new Societe($db);
2128 2128
             $thirdpartystatic->fetch($this->socid);
2129 2129
             if (empty($hidethirdpartylogo)) {
2130
-                $companylink = ' ' . $thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
2130
+                $companylink = ' '.$thirdpartystatic->getNomUrl(2, (($option == 'nolink') ? 'nolink' : '')); // picto only of company
2131 2131
             }
2132
-            $company = ' (' . $langs->trans("Company") . ': ' . $thirdpartystatic->name . ')';
2132
+            $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')';
2133 2133
         }
2134
-        $type = ($this->socid ? $langs->trans("External") . $company : $langs->trans("Internal"));
2135
-        $label .= '<br><b>' . $langs->trans("Type") . ':</b> ' . $type;
2136
-        $label .= '<br><b>' . $langs->trans("Status") . '</b>: ' . $this->getLibStatut(0);
2134
+        $type = ($this->socid ? $langs->trans("External").$company : $langs->trans("Internal"));
2135
+        $label .= '<br><b>'.$langs->trans("Type").':</b> '.$type;
2136
+        $label .= '<br><b>'.$langs->trans("Status").'</b>: '.$this->getLibStatut(0);
2137 2137
         $label .= '</div>';
2138 2138
         if ($infologin > 0) {
2139 2139
             $label .= '<br>';
2140
-            $label .= '<br><u>' . $langs->trans("Connection") . '</u>';
2141
-            $label .= '<br><b>' . $langs->trans("IPAddress") . '</b>: ' . $_SERVER["REMOTE_ADDR"];
2140
+            $label .= '<br><u>'.$langs->trans("Connection").'</u>';
2141
+            $label .= '<br><b>'.$langs->trans("IPAddress").'</b>: '.$_SERVER["REMOTE_ADDR"];
2142 2142
             if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) {
2143
-                $label .= '<br><b>' . $langs->trans("ConnectedOnMultiCompany") . ':</b> ' . Globals::$conf->entity . ' (user entity ' . $this->entity . ')';
2143
+                $label .= '<br><b>'.$langs->trans("ConnectedOnMultiCompany").':</b> '.Globals::$conf->entity.' (user entity '.$this->entity.')';
2144 2144
             }
2145
-            $label .= '<br><b>' . $langs->trans("AuthenticationMode") . ':</b> ' . $_SESSION["dol_authmode"] . (empty($dolibarr_main_demo) ? '' : ' (demo)');
2146
-            $label .= '<br><b>' . $langs->trans("ConnectedSince") . ':</b> ' . dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
2147
-            $label .= '<br><b>' . $langs->trans("PreviousConnexion") . ':</b> ' . dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
2148
-            $label .= '<br><b>' . $langs->trans("CurrentTheme") . ':</b> ' . Globals::$conf->theme;
2149
-            $label .= '<br><b>' . $langs->trans("CurrentMenuManager") . ':</b> ' . $menumanager->name;
2145
+            $label .= '<br><b>'.$langs->trans("AuthenticationMode").':</b> '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)');
2146
+            $label .= '<br><b>'.$langs->trans("ConnectedSince").':</b> '.dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
2147
+            $label .= '<br><b>'.$langs->trans("PreviousConnexion").':</b> '.dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
2148
+            $label .= '<br><b>'.$langs->trans("CurrentTheme").':</b> '.Globals::$conf->theme;
2149
+            $label .= '<br><b>'.$langs->trans("CurrentMenuManager").':</b> '.$menumanager->name;
2150 2150
             $s = picto_from_langcode($langs->getDefaultLang());
2151
-            $label .= '<br><b>' . $langs->trans("CurrentUserLanguage") . ':</b> ' . ($s ? $s . ' ' : '') . $langs->getDefaultLang();
2152
-            $label .= '<br><b>' . $langs->trans("Browser") . ':</b> ' . Globals::$conf->browser->name . ($conf->browser->version ? ' ' . Globals::$conf->browser->version : '') . ' (' . $_SERVER['HTTP_USER_AGENT'] . ')';
2153
-            $label .= '<br><b>' . $langs->trans("Layout") . ':</b> ' . Globals::$conf->browser->layout;
2154
-            $label .= '<br><b>' . $langs->trans("Screen") . ':</b> ' . $_SESSION['dol_screenwidth'] . ' x ' . $_SESSION['dol_screenheight'];
2151
+            $label .= '<br><b>'.$langs->trans("CurrentUserLanguage").':</b> '.($s ? $s.' ' : '').$langs->getDefaultLang();
2152
+            $label .= '<br><b>'.$langs->trans("Browser").':</b> '.Globals::$conf->browser->name.($conf->browser->version ? ' '.Globals::$conf->browser->version : '').' ('.$_SERVER['HTTP_USER_AGENT'].')';
2153
+            $label .= '<br><b>'.$langs->trans("Layout").':</b> '.Globals::$conf->browser->layout;
2154
+            $label .= '<br><b>'.$langs->trans("Screen").':</b> '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight'];
2155 2155
             if ($conf->browser->layout == 'phone') {
2156
-                $label .= '<br><b>' . $langs->trans("Phone") . ':</b> ' . $langs->trans("Yes");
2156
+                $label .= '<br><b>'.$langs->trans("Phone").':</b> '.$langs->trans("Yes");
2157 2157
             }
2158 2158
             if (!empty($_SESSION["disablemodules"])) {
2159
-                $label .= '<br><b>' . $langs->trans("DisabledModules") . ':</b> <br>' . join(', ', explode(',', $_SESSION["disablemodules"]));
2159
+                $label .= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.join(', ', explode(',', $_SESSION["disablemodules"]));
2160 2160
             }
2161 2161
         }
2162 2162
         if ($infologin < 0) {
@@ -2164,10 +2164,10 @@  discard block
 block discarded – undo
2164 2164
         }
2165 2165
 
2166 2166
         // $url = DOL_URL_ROOT . '/user/card.php?id=' . $this->id;
2167
-        $url = BASE_URI . '?controller=user&method=card&id=' . $this->id;
2167
+        $url = BASE_URI.'?controller=user&method=card&id='.$this->id;
2168 2168
         if ($option == 'leave') {
2169 2169
             //$url = DOL_URL_ROOT . '/holiday/list.php?id=' . $this->id;
2170
-            $url = BASE_URI . '?controller=holiday&method=list&id=' . $this->id;
2170
+            $url = BASE_URI.'?controller=holiday&method=list&id='.$this->id;
2171 2171
         }
2172 2172
         if ($option != 'nolink') {
2173 2173
             // Add param to save lastsearch_values or not
@@ -2180,16 +2180,16 @@  discard block
 block discarded – undo
2180 2180
             }
2181 2181
         }
2182 2182
 
2183
-        $linkstart = '<a href="' . $url . '"';
2183
+        $linkstart = '<a href="'.$url.'"';
2184 2184
         $linkclose = "";
2185 2185
         if (empty($notooltip)) {
2186 2186
             if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2187 2187
                 $langs->load("users");
2188 2188
                 $label = $langs->trans("ShowUser");
2189
-                $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';
2189
+                $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
2190 2190
             }
2191
-            $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"';
2192
-            $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"';
2191
+            $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
2192
+            $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
2193 2193
 
2194 2194
             /*
2195 2195
               $hookmanager->initHooks(array('userdao'));
@@ -2199,7 +2199,7 @@  discard block
 block discarded – undo
2199 2199
              */
2200 2200
         }
2201 2201
 
2202
-        $linkstart .= $linkclose . '>';
2202
+        $linkstart .= $linkclose.'>';
2203 2203
         $linkend = '</a>';
2204 2204
 
2205 2205
         //if ($withpictoimg == -1) $result.='<div class="nowrap">';
@@ -2211,15 +2211,15 @@  discard block
 block discarded – undo
2211 2211
             }
2212 2212
             // Only picto
2213 2213
             if ($withpictoimg > 0) {
2214
-                $picto = '<!-- picto user --><div class="inline-block nopadding userimg' . ($morecss ? ' ' . $morecss : '') . '">' . img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . '</div>';
2214
+                $picto = '<!-- picto user --><div class="inline-block nopadding userimg'.($morecss ? ' '.$morecss : '').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1).'</div>';
2215 2215
             } else { // Picto must be a photo
2216
-                $picto = '<!-- picto photo user --><div class="inline-block nopadding userimg' . ($morecss ? ' ' . $morecss : '') . '"' . ($paddafterimage ? ' ' . $paddafterimage : '') . '>' . Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1) . '</div>';
2216
+                $picto = '<!-- picto photo user --><div class="inline-block nopadding userimg'.($morecss ? ' '.$morecss : '').'"'.($paddafterimage ? ' '.$paddafterimage : '').'>'.Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1).'</div>';
2217 2217
             }
2218 2218
             $result .= $picto;
2219 2219
         }
2220 2220
         if ($withpictoimg > -2 && $withpictoimg != 2) {
2221 2221
             if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
2222
-                $result .= '<div class="inline-block nopadding valignmiddle usertext' . ((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled') . ($morecss ? ' ' . $morecss : '') . '">';
2222
+                $result .= '<div class="inline-block nopadding valignmiddle usertext'.((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled').($morecss ? ' '.$morecss : '').'">';
2223 2223
             }
2224 2224
             if ($mode == 'login') {
2225 2225
                 $result .= dol_trunc($this->login, $maxlen);
@@ -2237,7 +2237,7 @@  discard block
 block discarded – undo
2237 2237
         global $action;
2238 2238
         $hookmanager->initHooks(array('userdao'));
2239 2239
         $parameters = array('id' => $this->id, 'getnomurl' => $result);
2240
-        $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
2240
+        $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
2241 2241
         if ($reshook > 0) {
2242 2242
             $result = $hookmanager->resPrint;
2243 2243
         } else {
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
         $result = '';
2262 2262
 
2263 2263
         // $linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
2264
-        $linkstart = '<a href="' . BASE_URI . '?controller=user&method=card&id=' . $this->id . '">';
2264
+        $linkstart = '<a href="'.BASE_URI.'?controller=user&method=card&id='.$this->id.'">';
2265 2265
         $linkend = '</a>';
2266 2266
 
2267 2267
         //Check user's rights to see an other user
@@ -2271,7 +2271,7 @@  discard block
 block discarded – undo
2271 2271
 
2272 2272
         if ($option == 'xxx') {
2273 2273
             //$linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">';
2274
-            $linkstart = '<a href="' . BASE_URI . '?controller=user&method=card.php&id=' . $this->id . '">';
2274
+            $linkstart = '<a href="'.BASE_URI.'?controller=user&method=card.php&id='.$this->id.'">';
2275 2275
             $linkend = '</a>';
2276 2276
         }
2277 2277
 
@@ -2328,9 +2328,9 @@  discard block
 block discarded – undo
2328 2328
             }
2329 2329
         } elseif ($mode == 2) {
2330 2330
             if ($statut == 1) {
2331
-                return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"') . ' ' . $langs->trans('Enabled');
2331
+                return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
2332 2332
             } elseif ($statut == 0) {
2333
-                return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"') . ' ' . $langs->trans('Disabled');
2333
+                return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
2334 2334
             }
2335 2335
         } elseif ($mode == 3) {
2336 2336
             if ($statut == 1) {
@@ -2340,15 +2340,15 @@  discard block
 block discarded – undo
2340 2340
             }
2341 2341
         } elseif ($mode == 4) {
2342 2342
             if ($statut == 1) {
2343
-                return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"') . ' ' . $langs->trans('Enabled');
2343
+                return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"').' '.$langs->trans('Enabled');
2344 2344
             } elseif ($statut == 0) {
2345
-                return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"') . ' ' . $langs->trans('Disabled');
2345
+                return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled');
2346 2346
             }
2347 2347
         } elseif ($mode == 5) {
2348 2348
             if ($statut == 1) {
2349
-                return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
2349
+                return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
2350 2350
             } elseif ($statut == 0) {
2351
-                return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
2351
+                return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
2352 2352
             }
2353 2353
         }
2354 2354
     }
@@ -2369,11 +2369,11 @@  discard block
 block discarded – undo
2369 2369
         global $conf;
2370 2370
         $dn = '';
2371 2371
         if ($mode == 0) {
2372
-            $dn = Globals::$conf->global->LDAP_KEY_USERS . "=" . $info[$conf->global->LDAP_KEY_USERS] . "," . Globals::$conf->global->LDAP_USER_DN;
2372
+            $dn = Globals::$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".Globals::$conf->global->LDAP_USER_DN;
2373 2373
         } elseif ($mode == 1) {
2374 2374
             $dn = Globals::$conf->global->LDAP_USER_DN;
2375 2375
         } elseif ($mode == 2) {
2376
-            $dn = Globals::$conf->global->LDAP_KEY_USERS . "=" . $info[$conf->global->LDAP_KEY_USERS];
2376
+            $dn = Globals::$conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS];
2377 2377
         }
2378 2378
         return $dn;
2379 2379
     }
@@ -2571,8 +2571,8 @@  discard block
 block discarded – undo
2571 2571
     {
2572 2572
         $sql = "SELECT u.rowid, u.login as ref, u.datec,";
2573 2573
         $sql .= " u.tms as date_modification, u.entity";
2574
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
2575
-        $sql .= " WHERE u.rowid = " . $id;
2574
+        $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
2575
+        $sql .= " WHERE u.rowid = ".$id;
2576 2576
 
2577 2577
         $result = Config::$dbEngine->query($sql);
2578 2578
         if ($result) {
@@ -2601,9 +2601,9 @@  discard block
 block discarded – undo
2601 2601
     function getNbOfEMailings()
2602 2602
     {
2603 2603
         $sql = "SELECT count(mc.email) as nb";
2604
-        $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles as mc";
2605
-        $sql .= " WHERE mc.email = '" . Config::$dbEngine->escape($this->email) . "'";
2606
-        $sql .= " AND mc.statut NOT IN (-1,0)";      // -1 erreur, 0 non envoye, 1 envoye avec succes
2604
+        $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
2605
+        $sql .= " WHERE mc.email = '".Config::$dbEngine->escape($this->email)."'";
2606
+        $sql .= " AND mc.statut NOT IN (-1,0)"; // -1 erreur, 0 non envoye, 1 envoye avec succes
2607 2607
 
2608 2608
         $resql = Config::$dbEngine->query($sql);
2609 2609
         if ($resql) {
@@ -2631,19 +2631,19 @@  discard block
 block discarded – undo
2631 2631
         global $conf;
2632 2632
 
2633 2633
         $sql = "SELECT count(rowid) as nb";
2634
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user";
2634
+        $sql .= " FROM ".MAIN_DB_PREFIX."user";
2635 2635
         if ($option == 'superadmin') {
2636 2636
             $sql .= " WHERE entity = 0";
2637 2637
             if ($admin >= 0) {
2638
-                $sql .= " AND admin = " . $admin;
2638
+                $sql .= " AND admin = ".$admin;
2639 2639
             }
2640 2640
         } else {
2641
-            $sql .= " WHERE entity IN (" . getEntity('user', 0) . ")";
2641
+            $sql .= " WHERE entity IN (".getEntity('user', 0).")";
2642 2642
             if ($limitTo == 'active') {
2643 2643
                 $sql .= " AND statut = 1";
2644 2644
             }
2645 2645
             if ($admin >= 0) {
2646
-                $sql .= " AND admin = " . $admin;
2646
+                $sql .= " AND admin = ".$admin;
2647 2647
             }
2648 2648
         }
2649 2649
 
@@ -2694,7 +2694,7 @@  discard block
 block discarded – undo
2694 2694
 
2695 2695
         $result = $this->update($user);
2696 2696
 
2697
-        DolUtils::dol_syslog(get_class($this) . "::update_ldap2dolibarr result=" . $result, LOG_DEBUG);
2697
+        DolUtils::dol_syslog(get_class($this)."::update_ldap2dolibarr result=".$result, LOG_DEBUG);
2698 2698
 
2699 2699
         return $result;
2700 2700
     }
@@ -2709,10 +2709,10 @@  discard block
 block discarded – undo
2709 2709
     function get_children()
2710 2710
     {
2711 2711
         // phpcs:enable
2712
-        $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "user";
2713
-        $sql .= " WHERE fk_user = " . $this->id;
2712
+        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user";
2713
+        $sql .= " WHERE fk_user = ".$this->id;
2714 2714
 
2715
-        DolUtils::dol_syslog(get_class($this) . "::get_children result=" . $result, LOG_DEBUG);
2715
+        DolUtils::dol_syslog(get_class($this)."::get_children result=".$result, LOG_DEBUG);
2716 2716
         $res = Config::$dbEngine->query($sql);
2717 2717
         if ($res) {
2718 2718
             $users = array();
@@ -2741,11 +2741,11 @@  discard block
 block discarded – undo
2741 2741
 
2742 2742
         // Load array[child]=parent
2743 2743
         $sql = "SELECT fk_user as id_parent, rowid as id_son";
2744
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user";
2744
+        $sql .= " FROM ".MAIN_DB_PREFIX."user";
2745 2745
         $sql .= " WHERE fk_user <> 0";
2746
-        $sql .= " AND entity IN (" . getEntity('user') . ")";
2746
+        $sql .= " AND entity IN (".getEntity('user').")";
2747 2747
 
2748
-        DolUtils::dol_syslog(get_class($this) . "::loadParentOf", LOG_DEBUG);
2748
+        DolUtils::dol_syslog(get_class($this)."::loadParentOf", LOG_DEBUG);
2749 2749
         $resql = Config::$dbEngine->query($sql);
2750 2750
         if ($resql) {
2751 2751
             while ($obj = Config::$dbEngine->fetch_object($resql)) {
@@ -2788,20 +2788,20 @@  discard block
 block discarded – undo
2788 2788
 
2789 2789
         // Init $this->users array
2790 2790
         $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates
2791
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
2791
+        $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
2792 2792
         // Add fields from hooks
2793 2793
         $parameters = array();
2794
-        $reshook = $hookmanager->executeHooks('printUserListWhere', $parameters);    // Note that $action and $object may have been modified by hook
2794
+        $reshook = $hookmanager->executeHooks('printUserListWhere', $parameters); // Note that $action and $object may have been modified by hook
2795 2795
         if ($reshook > 0) {
2796 2796
             $sql .= $hookmanager->resPrint;
2797 2797
         } else {
2798
-            $sql .= " WHERE u.entity IN (" . getEntity('user') . ")";
2798
+            $sql .= " WHERE u.entity IN (".getEntity('user').")";
2799 2799
         }
2800 2800
         if ($filter) {
2801
-            $sql .= " AND " . $filter;
2801
+            $sql .= " AND ".$filter;
2802 2802
         }
2803 2803
 
2804
-        DolUtils::dol_syslog(get_class($this) . "::get_full_tree get user list", LOG_DEBUG);
2804
+        DolUtils::dol_syslog(get_class($this)."::get_full_tree get user list", LOG_DEBUG);
2805 2805
         $resql = Config::$dbEngine->query($sql);
2806 2806
         if ($resql) {
2807 2807
             $i = 0;
@@ -2827,7 +2827,7 @@  discard block
 block discarded – undo
2827 2827
         }
2828 2828
 
2829 2829
         // We add the fullpath property to each elements of first level (no parent exists)
2830
-        DolUtils::dol_syslog(get_class($this) . "::get_full_tree call to build_path_from_id_user", LOG_DEBUG);
2830
+        DolUtils::dol_syslog(get_class($this)."::get_full_tree call to build_path_from_id_user", LOG_DEBUG);
2831 2831
         foreach ($this->users as $key => $val) {
2832 2832
             $result = $this->build_path_from_id_user($key, 0); // Process a branch from the root user key (this user has no parent)
2833 2833
             if ($result < 0) {
@@ -2839,18 +2839,18 @@  discard block
 block discarded – undo
2839 2839
         // Exclude leaf including $deleteafterid from tree
2840 2840
         if ($deleteafterid) {
2841 2841
             //print "Look to discard user ".$deleteafterid."\n";
2842
-            $keyfilter1 = '^' . $deleteafterid . '$';
2843
-            $keyfilter2 = '_' . $deleteafterid . '$';
2844
-            $keyfilter3 = '^' . $deleteafterid . '_';
2845
-            $keyfilter4 = '_' . $deleteafterid . '_';
2842
+            $keyfilter1 = '^'.$deleteafterid.'$';
2843
+            $keyfilter2 = '_'.$deleteafterid.'$';
2844
+            $keyfilter3 = '^'.$deleteafterid.'_';
2845
+            $keyfilter4 = '_'.$deleteafterid.'_';
2846 2846
             foreach ($this->users as $key => $val) {
2847
-                if (preg_match('/' . $keyfilter1 . '/', $val['fullpath']) || preg_match('/' . $keyfilter2 . '/', $val['fullpath']) || preg_match('/' . $keyfilter3 . '/', $val['fullpath']) || preg_match('/' . $keyfilter4 . '/', $val['fullpath'])) {
2847
+                if (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath']) || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath'])) {
2848 2848
                     unset($this->users[$key]);
2849 2849
                 }
2850 2850
             }
2851 2851
         }
2852 2852
 
2853
-        DolUtils::dol_syslog(get_class($this) . "::get_full_tree dol_sort_array", LOG_DEBUG);
2853
+        DolUtils::dol_syslog(get_class($this)."::get_full_tree dol_sort_array", LOG_DEBUG);
2854 2854
         $this->users = dol_sort_array($this->users, 'fullname', 'asc', true, false);
2855 2855
 
2856 2856
         //var_dump($this->users);
@@ -2878,10 +2878,10 @@  discard block
 block discarded – undo
2878 2878
 
2879 2879
             $idtoscan = $this->id;
2880 2880
 
2881
-            DolUtils::dol_syslog("Build childid for id = " . $idtoscan);
2881
+            DolUtils::dol_syslog("Build childid for id = ".$idtoscan);
2882 2882
             foreach ($this->users as $id => $val) {
2883 2883
                 //var_dump($val['fullpath']);
2884
-                if (preg_match('/_' . $idtoscan . '_/', $val['fullpath'])) {
2884
+                if (preg_match('/_'.$idtoscan.'_/', $val['fullpath'])) {
2885 2885
                     $childids[$val['id']] = $val['id'];
2886 2886
                 }
2887 2887
             }
@@ -2907,16 +2907,16 @@  discard block
 block discarded – undo
2907 2907
     function build_path_from_id_user($id_user, $protection = 0)
2908 2908
     {
2909 2909
         // phpcs:enable
2910
-        DolUtils::dol_syslog(get_class($this) . "::build_path_from_id_user id_user=" . $id_user . " protection=" . $protection, LOG_DEBUG);
2910
+        DolUtils::dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG);
2911 2911
 
2912 2912
         if (!empty($this->users[$id_user]['fullpath'])) {
2913 2913
             // Already defined
2914
-            DolUtils::dol_syslog(get_class($this) . "::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING);
2914
+            DolUtils::dol_syslog(get_class($this)."::build_path_from_id_user fullpath and fullname already defined", LOG_WARNING);
2915 2915
             return 0;
2916 2916
         }
2917 2917
 
2918 2918
         // Define fullpath and fullname
2919
-        $this->users[$id_user]['fullpath'] = '_' . $id_user;
2919
+        $this->users[$id_user]['fullpath'] = '_'.$id_user;
2920 2920
         $this->users[$id_user]['fullname'] = $this->users[$id_user]['lastname'];
2921 2921
         $i = 0;
2922 2922
         $cursor_user = $id_user;
@@ -2925,11 +2925,11 @@  discard block
 block discarded – undo
2925 2925
         while (!empty($this->parentof[$cursor_user])) {
2926 2926
             if (in_array($this->parentof[$cursor_user], $useridfound)) {
2927 2927
                 DolUtils::dol_syslog("The hierarchy of user has a recursive loop", LOG_WARNING);
2928
-                return -1;     // Should not happen. Protection against looping hierarchy
2928
+                return -1; // Should not happen. Protection against looping hierarchy
2929 2929
             }
2930 2930
             $useridfound[] = $this->parentof[$cursor_user];
2931
-            $this->users[$id_user]['fullpath'] = '_' . $this->parentof[$cursor_user] . $this->users[$id_user]['fullpath'];
2932
-            $this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'] . ' >> ' . $this->users[$id_user]['fullname'];
2931
+            $this->users[$id_user]['fullpath'] = '_'.$this->parentof[$cursor_user].$this->users[$id_user]['fullpath'];
2932
+            $this->users[$id_user]['fullname'] = $this->users[$this->parentof[$cursor_user]]['lastname'].' >> '.$this->users[$id_user]['fullname'];
2933 2933
             $i++;
2934 2934
             $cursor_user = $this->parentof[$cursor_user];
2935 2935
         }
@@ -2971,10 +2971,10 @@  discard block
 block discarded – undo
2971 2971
         $this->nb = array();
2972 2972
 
2973 2973
         $sql = "SELECT count(u.rowid) as nb";
2974
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
2974
+        $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
2975 2975
         $sql .= " WHERE u.statut > 0";
2976 2976
         //$sql.= " AND employee != 0";
2977
-        $sql .= " AND u.entity IN (" . getEntity('user') . ")";
2977
+        $sql .= " AND u.entity IN (".getEntity('user').")";
2978 2978
 
2979 2979
         $resql = Config::$dbEngine->query($sql);
2980 2980
         if ($resql) {
@@ -3039,8 +3039,8 @@  discard block
 block discarded – undo
3039 3039
         }
3040 3040
 
3041 3041
         $sql = "SELECT rowid, email, user_mobile, civility, lastname, firstname";
3042
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user";
3043
-        $sql .= " WHERE rowid = '" . $rowid . "'";
3042
+        $sql .= " FROM ".MAIN_DB_PREFIX."user";
3043
+        $sql .= " WHERE rowid = '".$rowid."'";
3044 3044
 
3045 3045
         $resql = Config::$dbEngine->query($sql);
3046 3046
         if ($resql) {
@@ -3050,7 +3050,7 @@  discard block
 block discarded – undo
3050 3050
                 $obj = Config::$dbEngine->fetch_object($resql);
3051 3051
 
3052 3052
                 if ($mode == 'email') {
3053
-                    $user_property = dolGetFirstLastname($obj->firstname, $obj->lastname) . " <" . $obj->email . ">";
3053
+                    $user_property = dolGetFirstLastname($obj->firstname, $obj->lastname)." <".$obj->email.">";
3054 3054
                 } else if ($mode == 'mobile') {
3055 3055
                     $user_property = $obj->user_mobile;
3056 3056
                 }
@@ -3077,7 +3077,7 @@  discard block
 block discarded – undo
3077 3077
         global $conf;
3078 3078
 
3079 3079
         $sql = "SELECT t.rowid";
3080
-        $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t ';
3080
+        $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t ';
3081 3081
         $sql .= " WHERE 1";
3082 3082
 
3083 3083
         // Manage filter
@@ -3085,25 +3085,25 @@  discard block
 block discarded – undo
3085 3085
         if (!empty($filter)) {
3086 3086
             foreach ($filter as $key => $value) {
3087 3087
                 if ($key == 't.rowid') {
3088
-                    $sqlwhere[] = $key . '=' . $value;
3088
+                    $sqlwhere[] = $key.'='.$value;
3089 3089
                 } elseif (strpos($key, 'date') !== false) {
3090
-                    $sqlwhere[] = $key . ' = \'' . Config::$dbEngine->idate($value) . '\'';
3090
+                    $sqlwhere[] = $key.' = \''.Config::$dbEngine->idate($value).'\'';
3091 3091
                 } elseif ($key == 'customsql') {
3092 3092
                     $sqlwhere[] = $value;
3093 3093
                 } else {
3094
-                    $sqlwhere[] = $key . ' LIKE \'%' . Config::$dbEngine->escape($value) . '%\'';
3094
+                    $sqlwhere[] = $key.' LIKE \'%'.Config::$dbEngine->escape($value).'%\'';
3095 3095
                 }
3096 3096
             }
3097 3097
         }
3098 3098
         if (count($sqlwhere) > 0) {
3099
-            $sql .= ' AND (' . implode(' ' . $filtermode . ' ', $sqlwhere) . ')';
3099
+            $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
3100 3100
         }
3101 3101
         $sql .= Config::$dbEngine->order($sortfield, $sortorder);
3102 3102
         if ($limit) {
3103 3103
             $sql .= Config::$dbEngine->plimit($limit + 1, $offset);
3104 3104
         }
3105 3105
 
3106
-        DolUtils::dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG);
3106
+        DolUtils::dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
3107 3107
 
3108 3108
         $resql = Config::$dbEngine->query($sql);
3109 3109
         if ($resql) {
Please login to merge, or discard this patch.
Base/AlixarBasicView.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
      */
132 132
     function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arrayofjs = '', $arrayofcss = '', $disablejmobile = 0, $disablenofollow = 0)
133 133
     {
134
-        $this->top_httphead();  // TODO: Null method!
134
+        $this->top_httphead(); // TODO: Null method!
135 135
         // TODO: Nothing to do?
136 136
         return;
137 137
 
Please login to merge, or discard this patch.
Base/Menubase.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     public $titre;
84 84
     //public Globals::$langs;
85 85
     public $level;
86
-    public $leftmenu;  //<! Not used
86
+    public $leftmenu; //<! Not used
87 87
     public $perms;
88 88
     public $enabled;
89 89
     //public $user;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         $this->type = trim($this->type);
118 118
         $this->mainmenu = trim($this->mainmenu);
119 119
         $this->leftmenu = trim($this->leftmenu);
120
-        $this->fk_menu = (int) $this->fk_menu;          // If -1, fk_mainmenu and fk_leftmenu must be defined
120
+        $this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined
121 121
         $this->fk_mainmenu = trim($this->fk_mainmenu);
122 122
         $this->fk_leftmenu = trim($this->fk_leftmenu);
123 123
         $this->position = (int) $this->position;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         // may use an already used value because its internal cursor does not increase when we do
145 145
         // an insert with a forced id.
146 146
         if (in_array(Globals::$db->type, array('pgsql'))) {
147
-            $sql = "SELECT MAX(rowid) as maxrowid FROM " . MAIN_DB_PREFIX . "menu";
147
+            $sql = "SELECT MAX(rowid) as maxrowid FROM ".MAIN_DB_PREFIX."menu";
148 148
             $resqlrowid = Globals::$db->query($sql);
149 149
             if ($resqlrowid) {
150 150
                 $obj = Globals::$db->fetch_object($resqlrowid);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                     $maxrowid = 1;
156 156
                 }
157 157
 
158
-                $sql = "SELECT setval('" . MAIN_DB_PREFIX . "menu_rowid_seq', " . ($maxrowid) . ")";
158
+                $sql = "SELECT setval('".MAIN_DB_PREFIX."menu_rowid_seq', ".($maxrowid).")";
159 159
                 //print $sql; exit;
160 160
                 $resqlrowidset = Globals::$db->query($sql);
161 161
                 if (!$resqlrowidset) {
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 
169 169
         // Check that entry does not exists yet on key menu_handler-fk_menu-position-url-entity, to avoid errors with postgresql
170 170
         $sql = "SELECT count(*)";
171
-        $sql .= " FROM " . MAIN_DB_PREFIX . "menu";
172
-        $sql .= " WHERE menu_handler = '" . Globals::$db->escape($this->menu_handler) . "'";
173
-        $sql .= " AND fk_menu = " . ((int) $this->fk_menu);
174
-        $sql .= " AND position = " . ((int) $this->position);
175
-        $sql .= " AND url = '" . Globals::$db->escape($this->url) . "'";
176
-        $sql .= " AND entity = " . Globals::$conf->entity;
171
+        $sql .= " FROM ".MAIN_DB_PREFIX."menu";
172
+        $sql .= " WHERE menu_handler = '".Globals::$db->escape($this->menu_handler)."'";
173
+        $sql .= " AND fk_menu = ".((int) $this->fk_menu);
174
+        $sql .= " AND position = ".((int) $this->position);
175
+        $sql .= " AND url = '".Globals::$db->escape($this->url)."'";
176
+        $sql .= " AND entity = ".Globals::$conf->entity;
177 177
 
178 178
         $result = Globals::$db->query($sql);
179 179
         if ($result) {
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
             if ($row[0] == 0) {   // If not found
183 183
                 // Insert request
184
-                $sql = "INSERT INTO " . MAIN_DB_PREFIX . "menu(";
184
+                $sql = "INSERT INTO ".MAIN_DB_PREFIX."menu(";
185 185
                 $sql .= "menu_handler,";
186 186
                 $sql .= "entity,";
187 187
                 $sql .= "module,";
@@ -200,38 +200,38 @@  discard block
 block discarded – undo
200 200
                 $sql .= "enabled,";
201 201
                 $sql .= "usertype";
202 202
                 $sql .= ") VALUES (";
203
-                $sql .= " '" . Globals::$db->escape($this->menu_handler) . "',";
204
-                $sql .= " '" . Globals::$db->escape($conf->entity) . "',";
205
-                $sql .= " '" . Globals::$db->escape($this->module) . "',";
206
-                $sql .= " '" . Globals::$db->escape($this->type) . "',";
207
-                $sql .= " " . ($this->mainmenu ? "'" . Globals::$db->escape($this->mainmenu) . "'" : "''") . ",";    // Can't be null
208
-                $sql .= " " . ($this->leftmenu ? "'" . Globals::$db->escape($this->leftmenu) . "'" : "null") . ",";
209
-                $sql .= " " . ((int) $this->fk_menu) . ",";
210
-                $sql .= " " . ($this->fk_mainmenu ? "'" . Globals::$db->escape($this->fk_mainmenu) . "'" : "null") . ",";
211
-                $sql .= " " . ($this->fk_leftmenu ? "'" . Globals::$db->escape($this->fk_leftmenu) . "'" : "null") . ",";
212
-                $sql .= " " . ((int) $this->position) . ",";
213
-                $sql .= " '" . Globals::$db->escape($this->url) . "',";
214
-                $sql .= " '" . Globals::$db->escape($this->target) . "',";
215
-                $sql .= " '" . Globals::$db->escape($this->titre) . "',";
216
-                $sql .= " '" . Globals::$db->escape($this->langs) . "',";
217
-                $sql .= " '" . Globals::$db->escape($this->perms) . "',";
218
-                $sql .= " '" . Globals::$db->escape($this->enabled) . "',";
219
-                $sql .= " '" . Globals::$db->escape($this->user) . "'";
203
+                $sql .= " '".Globals::$db->escape($this->menu_handler)."',";
204
+                $sql .= " '".Globals::$db->escape($conf->entity)."',";
205
+                $sql .= " '".Globals::$db->escape($this->module)."',";
206
+                $sql .= " '".Globals::$db->escape($this->type)."',";
207
+                $sql .= " ".($this->mainmenu ? "'".Globals::$db->escape($this->mainmenu)."'" : "''").","; // Can't be null
208
+                $sql .= " ".($this->leftmenu ? "'".Globals::$db->escape($this->leftmenu)."'" : "null").",";
209
+                $sql .= " ".((int) $this->fk_menu).",";
210
+                $sql .= " ".($this->fk_mainmenu ? "'".Globals::$db->escape($this->fk_mainmenu)."'" : "null").",";
211
+                $sql .= " ".($this->fk_leftmenu ? "'".Globals::$db->escape($this->fk_leftmenu)."'" : "null").",";
212
+                $sql .= " ".((int) $this->position).",";
213
+                $sql .= " '".Globals::$db->escape($this->url)."',";
214
+                $sql .= " '".Globals::$db->escape($this->target)."',";
215
+                $sql .= " '".Globals::$db->escape($this->titre)."',";
216
+                $sql .= " '".Globals::$db->escape($this->langs)."',";
217
+                $sql .= " '".Globals::$db->escape($this->perms)."',";
218
+                $sql .= " '".Globals::$db->escape($this->enabled)."',";
219
+                $sql .= " '".Globals::$db->escape($this->user)."'";
220 220
                 $sql .= ")";
221 221
 
222
-                DolUtils::dol_syslog(get_class($this) . "::create", LOG_DEBUG);
222
+                DolUtils::dol_syslog(get_class($this)."::create", LOG_DEBUG);
223 223
                 $resql = Globals::$db->query($sql);
224 224
                 if ($resql) {
225
-                    $this->id = Globals::$db->last_insert_id(MAIN_DB_PREFIX . "menu");
226
-                    DolUtils::dol_syslog(get_class($this) . "::create record added has rowid=" . $this->id, LOG_DEBUG);
225
+                    $this->id = Globals::$db->last_insert_id(MAIN_DB_PREFIX."menu");
226
+                    DolUtils::dol_syslog(get_class($this)."::create record added has rowid=".$this->id, LOG_DEBUG);
227 227
 
228 228
                     return $this->id;
229 229
                 } else {
230
-                    $this->error = "Error " . Globals::$db->lasterror();
230
+                    $this->error = "Error ".Globals::$db->lasterror();
231 231
                     return -1;
232 232
                 }
233 233
             } else {
234
-                DolUtils::dol_syslog(get_class($this) . "::create menu entry already exists", LOG_WARNING);
234
+                DolUtils::dol_syslog(get_class($this)."::create menu entry already exists", LOG_WARNING);
235 235
                 $this->error = 'Error Menu entry already exists';
236 236
                 return 0;
237 237
             }
@@ -272,29 +272,29 @@  discard block
 block discarded – undo
272 272
         // Check parameters
273 273
         // Put here code to add control on parameters values
274 274
         // Update request
275
-        $sql = "UPDATE " . MAIN_DB_PREFIX . "menu SET";
276
-        $sql .= " menu_handler='" . Globals::$db->escape($this->menu_handler) . "',";
277
-        $sql .= " module='" . Globals::$db->escape($this->module) . "',";
278
-        $sql .= " type='" . Globals::$db->escape($this->type) . "',";
279
-        $sql .= " mainmenu='" . Globals::$db->escape($this->mainmenu) . "',";
280
-        $sql .= " leftmenu='" . Globals::$db->escape($this->leftmenu) . "',";
281
-        $sql .= " fk_menu=" . $this->fk_menu . ",";
282
-        $sql .= " fk_mainmenu=" . ($this->fk_mainmenu ? "'" . Globals::$db->escape($this->fk_mainmenu) . "'" : "null") . ",";
283
-        $sql .= " fk_leftmenu=" . ($this->fk_leftmenu ? "'" . Globals::$db->escape($this->fk_leftmenu) . "'" : "null") . ",";
284
-        $sql .= " position=" . ($this->position > 0 ? $this->position : 0) . ",";
285
-        $sql .= " url='" . Globals::$db->escape($this->url) . "',";
286
-        $sql .= " target='" . Globals::$db->escape($this->target) . "',";
287
-        $sql .= " titre='" . Globals::$db->escape($this->titre) . "',";
288
-        $sql .= " langs='" . Globals::$db->escape($this->langs) . "',";
289
-        $sql .= " perms='" . Globals::$db->escape($this->perms) . "',";
290
-        $sql .= " enabled='" . Globals::$db->escape($this->enabled) . "',";
291
-        $sql .= " usertype='" . Globals::$db->escape($this->user) . "'";
292
-        $sql .= " WHERE rowid=" . $this->id;
293
-
294
-        DolUtils::dol_syslog(get_class($this) . "::update", LOG_DEBUG);
275
+        $sql = "UPDATE ".MAIN_DB_PREFIX."menu SET";
276
+        $sql .= " menu_handler='".Globals::$db->escape($this->menu_handler)."',";
277
+        $sql .= " module='".Globals::$db->escape($this->module)."',";
278
+        $sql .= " type='".Globals::$db->escape($this->type)."',";
279
+        $sql .= " mainmenu='".Globals::$db->escape($this->mainmenu)."',";
280
+        $sql .= " leftmenu='".Globals::$db->escape($this->leftmenu)."',";
281
+        $sql .= " fk_menu=".$this->fk_menu.",";
282
+        $sql .= " fk_mainmenu=".($this->fk_mainmenu ? "'".Globals::$db->escape($this->fk_mainmenu)."'" : "null").",";
283
+        $sql .= " fk_leftmenu=".($this->fk_leftmenu ? "'".Globals::$db->escape($this->fk_leftmenu)."'" : "null").",";
284
+        $sql .= " position=".($this->position > 0 ? $this->position : 0).",";
285
+        $sql .= " url='".Globals::$db->escape($this->url)."',";
286
+        $sql .= " target='".Globals::$db->escape($this->target)."',";
287
+        $sql .= " titre='".Globals::$db->escape($this->titre)."',";
288
+        $sql .= " langs='".Globals::$db->escape($this->langs)."',";
289
+        $sql .= " perms='".Globals::$db->escape($this->perms)."',";
290
+        $sql .= " enabled='".Globals::$db->escape($this->enabled)."',";
291
+        $sql .= " usertype='".Globals::$db->escape($this->user)."'";
292
+        $sql .= " WHERE rowid=".$this->id;
293
+
294
+        DolUtils::dol_syslog(get_class($this)."::update", LOG_DEBUG);
295 295
         $resql = Globals::$db->query($sql);
296 296
         if (!$resql) {
297
-            $this->error = "Error " . Globals::$db->lasterror();
297
+            $this->error = "Error ".Globals::$db->lasterror();
298 298
             return -1;
299 299
         }
300 300
 
@@ -332,10 +332,10 @@  discard block
 block discarded – undo
332 332
         $sql .= " t.enabled,";
333 333
         $sql .= " t.usertype as user,";
334 334
         $sql .= " t.tms";
335
-        $sql .= " FROM " . MAIN_DB_PREFIX . "menu as t";
336
-        $sql .= " WHERE t.rowid = " . $id;
335
+        $sql .= " FROM ".MAIN_DB_PREFIX."menu as t";
336
+        $sql .= " WHERE t.rowid = ".$id;
337 337
 
338
-        DolUtils::dol_syslog(get_class($this) . "::fetch", LOG_DEBUG);
338
+        DolUtils::dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
339 339
         $resql = Globals::$db->query($sql);
340 340
         if ($resql) {
341 341
             if (Globals::$db->num_rows($resql)) {
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
             return 1;
368 368
         } else {
369
-            $this->error = "Error " . Globals::$db->lasterror();
369
+            $this->error = "Error ".Globals::$db->lasterror();
370 370
             return -1;
371 371
         }
372 372
     }
@@ -381,13 +381,13 @@  discard block
 block discarded – undo
381 381
     {
382 382
         // global $conf, Globals::$langs;
383 383
 
384
-        $sql = "DELETE FROM " . MAIN_DB_PREFIX . "menu";
385
-        $sql .= " WHERE rowid=" . $this->id;
384
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
385
+        $sql .= " WHERE rowid=".$this->id;
386 386
 
387
-        DolUtils::dol_syslog(get_class($this) . "::delete", LOG_DEBUG);
387
+        DolUtils::dol_syslog(get_class($this)."::delete", LOG_DEBUG);
388 388
         $resql = Globals::$db->query($sql);
389 389
         if (!$resql) {
390
-            $this->error = "Error " . Globals::$db->lasterror();
390
+            $this->error = "Error ".Globals::$db->lasterror();
391 391
             return -1;
392 392
         }
393 393
 
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
         // global Globals::$langs, $user, $conf; // To export to DolUtils::dol_eval function
439 439
         // global $mainmenu, $leftmenu;  // To export to DolUtils::dol_eval function
440 440
 
441
-        $mainmenu = $mymainmenu;  // To export to DolUtils::dol_eval function
442
-        $leftmenu = $myleftmenu;  // To export to DolUtils::dol_eval function
441
+        $mainmenu = $mymainmenu; // To export to DolUtils::dol_eval function
442
+        $leftmenu = $myleftmenu; // To export to DolUtils::dol_eval function
443 443
 
444 444
         $newTabMenu = array();
445 445
         foreach ($tabMenu as $val) {
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
         //global Globals::$langs, $user, $conf;  // To export to DolUtils::dol_eval function
469 469
         // global $mainmenu, $leftmenu;  // To export to DolUtils::dol_eval function
470 470
 
471
-        $mainmenu = $mymainmenu;  // To export to DolUtils::dol_eval function
472
-        $leftmenu = $myleftmenu;  // To export to DolUtils::dol_eval function
471
+        $mainmenu = $mymainmenu; // To export to DolUtils::dol_eval function
472
+        $leftmenu = $myleftmenu; // To export to DolUtils::dol_eval function
473 473
         // Detect what is top mainmenu id
474 474
         $menutopid = '';
475 475
         foreach ($tabMenu as $key => $val) {
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                     if ($found) {
525 525
                         $this->newmenu->insert($lastid, $val['url'], $val['titre'], $searchlastsub, $val['perms'], $val['target'], $val['mainmenu'], $val['leftmenu'], $val['position']);
526 526
                     } else {
527
-                        DolUtils::dol_syslog("Error. Modules " . $val['module'] . " has defined a menu entry with a parent='fk_mainmenu=" . $val['fk_leftmenu'] . ",fk_leftmenu=" . $val['fk_leftmenu'] . "' and position=" . $val['position'] . '. The parent was not found. May be you forget it into your definition of menu, or may be the parent has a "position" that is after the child (fix field "position" of parent or child in this case).', LOG_WARNING);
527
+                        DolUtils::dol_syslog("Error. Modules ".$val['module']." has defined a menu entry with a parent='fk_mainmenu=".$val['fk_leftmenu'].",fk_leftmenu=".$val['fk_leftmenu']."' and position=".$val['position'].'. The parent was not found. May be you forget it into your definition of menu, or may be the parent has a "position" that is after the child (fix field "position" of parent or child in this case).', LOG_WARNING);
528 528
                         //print "Parent menu not found !!<br>";
529 529
                     }
530 530
                 }
@@ -550,13 +550,13 @@  discard block
 block discarded – undo
550 550
         //global $mainmenu, $leftmenu; // To export to DolUtils::dol_eval function
551 551
 
552 552
         $menutopid = 0;
553
-        $mainmenu = $mymainmenu;  // To export to DolUtils::dol_eval function
554
-        $leftmenu = $myleftmenu;  // To export to DolUtils::dol_eval function
553
+        $mainmenu = $mymainmenu; // To export to DolUtils::dol_eval function
554
+        $leftmenu = $myleftmenu; // To export to DolUtils::dol_eval function
555 555
 
556 556
         $sql = "SELECT m.rowid, m.type, m.module, m.fk_menu, m.fk_mainmenu, m.fk_leftmenu, m.url, m.titre, m.langs, m.perms, m.enabled, m.target, m.mainmenu, m.leftmenu, m.position";
557
-        $sql .= " FROM " . MAIN_DB_PREFIX . "menu as m";
558
-        $sql .= " WHERE m.entity IN (0," . Globals::$conf->entity . ")";
559
-        $sql .= " AND m.menu_handler IN ('" . $menu_handler . "','all')";
557
+        $sql .= " FROM ".MAIN_DB_PREFIX."menu as m";
558
+        $sql .= " WHERE m.entity IN (0,".Globals::$conf->entity.")";
559
+        $sql .= " AND m.menu_handler IN ('".$menu_handler."','all')";
560 560
         if ($type_user == 0) {
561 561
             $sql .= " AND m.usertype IN (0,2)";
562 562
         }
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
         //print $sql;
568 568
         //$tmp1=microtime(true);
569 569
         //print '>>> 1 0<br>';
570
-        DolUtils::dol_syslog(get_class($this) . "::menuLoad mymainmenu=" . $mymainmenu . " myleftmenu=" . $myleftmenu . " type_user=" . $type_user . " menu_handler=" . $menu_handler . " tabMenu size=" . count($tabMenu) . "", LOG_DEBUG);
570
+        DolUtils::dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG);
571 571
         $resql = Config::$dbEngine->select($sql);
572 572
         if (is_array($resql)) {
573 573
             $a = 0;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 
601 601
                 // Define $title
602 602
                 if ($enabled) {
603
-                    $title = Globals::$langs->trans($menu['titre']);  // If $menu['titre'] start with $, a DolUtils::dol_eval is done.
603
+                    $title = Globals::$langs->trans($menu['titre']); // If $menu['titre'] start with $, a DolUtils::dol_eval is done.
604 604
                     //var_dump($title.'-'.$menu['titre']);
605 605
                     if ($title == $menu['titre']) {   // Translation not found
606 606
                         if (!empty($menu['langs'])) {    // If there is a dedicated translation file
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 
614 614
                         if (preg_match("/\//", $menu['titre'])) { // To manage translation when title is string1/string2
615 615
                             $tab_titre = explode("/", $menu['titre']);
616
-                            $title = Globals::$langs->trans($tab_titre[0]) . "/" . Globals::$langs->trans($tab_titre[1]);
616
+                            $title = Globals::$langs->trans($tab_titre[0])."/".Globals::$langs->trans($tab_titre[1]);
617 617
                         } else if (preg_match('/\|\|/', $menu['titre'])) { // To manage different translation (Title||AltTitle@ConditionForAltTitle)
618 618
                             $tab_title = explode("||", $menu['titre']);
619 619
                             $alt_title = explode("@", $tab_title[1]);
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
                     $tabMenu[$b]['url'] = $menu['url'];
633 633
                     if (!preg_match("/^(http:\/\/|https:\/\/)/i", $tabMenu[$b]['url'])) {
634 634
                         if (preg_match('/\?/', $tabMenu[$b]['url'])) {
635
-                            $tabMenu[$b]['url'] .= '&amp;idmenu=' . $menu['rowid'];
635
+                            $tabMenu[$b]['url'] .= '&amp;idmenu='.$menu['rowid'];
636 636
                         } else {
637
-                            $tabMenu[$b]['url'] .= '?idmenu=' . $menu['rowid'];
637
+                            $tabMenu[$b]['url'] .= '?idmenu='.$menu['rowid'];
638 638
                         }
639 639
                     }
640 640
                     $tabMenu[$b]['titre'] = $title;
Please login to merge, or discard this patch.
Base/CommonObject.php 1 patch
Spacing   +1526 added lines, -1526 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @var string[]	Array of error strings
36 36
 	 */
37
-	public $errors=array();
37
+	public $errors = array();
38 38
 
39 39
 	/**
40 40
 	 * @var string ID to identify managed object
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * @var int    Name of subtable line
51 51
 	 */
52
-	public $table_element_line='';
52
+	public $table_element_line = '';
53 53
 
54 54
 	/**
55 55
 	 * @var string		Key value used to track if data is coming from import wizard
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	/**
60 60
 	 * @var mixed		Contains data to manage extrafields
61 61
 	 */
62
-	public $array_options=array();
62
+	public $array_options = array();
63 63
 
64 64
 	/**
65 65
 	 * @var int[][]		Array of linked objects ids. Loaded by ->fetchObjectLinked
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * @var array<string,mixed>		Can be used to pass information when only object is provided to method
90 90
 	 */
91
-	public $context=array();
91
+	public $context = array();
92 92
 
93 93
 	/**
94 94
 	 * @var string		Contains canvas name if record is an alternative canvas record
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 * @var mixed		Contains comments
349 349
 	 * @see fetchComments()
350 350
 	 */
351
-	public $comments=array();
351
+	public $comments = array();
352 352
 
353 353
 	/**
354 354
 	 * @var int
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
 	public $civility_id;
375 375
 
376 376
 	// Dates
377
-	public $date_creation;			// Date creation
378
-	public $date_validation;		// Date validation
379
-	public $date_modification;		// Date last change (tms field)
377
+	public $date_creation; // Date creation
378
+	public $date_validation; // Date validation
379
+	public $date_modification; // Date last change (tms field)
380 380
 
381 381
 
382 382
 
@@ -392,29 +392,29 @@  discard block
 block discarded – undo
392 392
 	 *  @param	string	$ref_ext	Ref ext of object to check
393 393
 	 *  @return int     			<0 if KO, 0 if OK but not found, >0 if OK and exists
394 394
 	 */
395
-	static function isExistingObject($element, $id, $ref='', $ref_ext='')
395
+	static function isExistingObject($element, $id, $ref = '', $ref_ext = '')
396 396
 	{
397
-		global $db,$conf;
397
+		global $db, $conf;
398 398
 
399 399
 		$sql = "SELECT rowid, ref, ref_ext";
400
-		$sql.= " FROM ".MAIN_DB_PREFIX.$element;
401
-		$sql.= " WHERE entity IN (".getEntity($element).")" ;
400
+		$sql .= " FROM ".MAIN_DB_PREFIX.$element;
401
+		$sql .= " WHERE entity IN (".getEntity($element).")";
402 402
 
403
-		if ($id > 0) $sql.= " AND rowid = ".$db->escape($id);
404
-		else if ($ref) $sql.= " AND ref = '".$db->escape($ref)."'";
405
-		else if ($ref_ext) $sql.= " AND ref_ext = '".$db->escape($ref_ext)."'";
403
+		if ($id > 0) $sql .= " AND rowid = ".$db->escape($id);
404
+		else if ($ref) $sql .= " AND ref = '".$db->escape($ref)."'";
405
+		else if ($ref_ext) $sql .= " AND ref_ext = '".$db->escape($ref_ext)."'";
406 406
 		else {
407
-			$error='ErrorWrongParameters';
407
+			$error = 'ErrorWrongParameters';
408 408
 			dol_print_error(get_class()."::isExistingObject ".$error, LOG_ERR);
409 409
 			return -1;
410 410
 		}
411
-		if ($ref || $ref_ext) $sql.= " AND entity = ".$conf->entity;
411
+		if ($ref || $ref_ext) $sql .= " AND entity = ".$conf->entity;
412 412
 
413 413
 		dol_syslog(get_class()."::isExistingObject", LOG_DEBUG);
414 414
 		$resql = $db->query($sql);
415 415
 		if ($resql)
416 416
 		{
417
-			$num=$db->num_rows($resql);
417
+			$num = $db->num_rows($resql);
418 418
 			if ($num > 0) return 1;
419 419
 			else return 0;
420 420
 		}
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 	 */
429 429
 	function errorsToString()
430 430
 	{
431
-		return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ',$this->errors)):'');
431
+		return $this->error.(is_array($this->errors) ? (($this->error != '' ? ', ' : '').join(', ', $this->errors)) : '');
432 432
 	}
433 433
 
434 434
 	/**
@@ -440,23 +440,23 @@  discard block
 block discarded – undo
440 440
 	 * 	@param	int			$maxlen			Maximum length
441 441
 	 * 	@return	string						String with full name
442 442
 	 */
443
-	function getFullName($langs,$option=0,$nameorder=-1,$maxlen=0)
443
+	function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0)
444 444
 	{
445 445
 		//print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
446
-		$lastname=$this->lastname;
447
-		$firstname=$this->firstname;
448
-		if (empty($lastname))  $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:(isset($this->societe)?$this->societe:(isset($this->company)?$this->company:'')))));
446
+		$lastname = $this->lastname;
447
+		$firstname = $this->firstname;
448
+		if (empty($lastname))  $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : '')))));
449 449
 
450
-		$ret='';
450
+		$ret = '';
451 451
 		if ($option && $this->civility_id)
452 452
 		{
453
-			if ($langs->transnoentitiesnoconv("Civility".$this->civility_id)!="Civility".$this->civility_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civility_id).' ';
454
-			else $ret.=$this->civility_id.' ';
453
+			if ($langs->transnoentitiesnoconv("Civility".$this->civility_id) != "Civility".$this->civility_id) $ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_id).' ';
454
+			else $ret .= $this->civility_id.' ';
455 455
 		}
456 456
 
457
-		$ret.=dolGetFirstLastname($firstname, $lastname, $nameorder);
457
+		$ret .= dolGetFirstLastname($firstname, $lastname, $nameorder);
458 458
 
459
-		return dol_trunc($ret,$maxlen);
459
+		return dol_trunc($ret, $maxlen);
460 460
 	}
461 461
 
462 462
 	/**
@@ -467,24 +467,24 @@  discard block
 block discarded – undo
467 467
 	 *  @param		int		    $withregion			1=Add region into address string
468 468
 	 *	@return		string							Full address string
469 469
 	 */
470
-	function getFullAddress($withcountry=0, $sep="\n", $withregion=0)
470
+	function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0)
471 471
 	{
472 472
 		if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
473 473
 		{
474
-			require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
475
-			$tmparray=getCountry($this->country_id,'all');
476
-			$this->country_code=$tmparray['code'];
477
-			$this->country     =$tmparray['label'];
474
+			require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
475
+			$tmparray = getCountry($this->country_id, 'all');
476
+			$this->country_code = $tmparray['code'];
477
+			$this->country     = $tmparray['label'];
478 478
 		}
479 479
 
480 480
         if ($withregion && $this->state_id && (empty($this->state_code) || empty($this->state) || empty($this->region) || empty($this->region_cpde)))
481 481
     	{
482
-    		require_once DOL_DOCUMENT_ROOT .'/core/lib/company.lib.php';
483
-    		$tmparray=getState($this->state_id,'all',0,1);
484
-			$this->state_code   =$tmparray['code'];
485
-			$this->state        =$tmparray['label'];
486
-			$this->region_code  =$tmparray['region_code'];
487
-			$this->region       =$tmparray['region'];
482
+    		require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
483
+    		$tmparray = getState($this->state_id, 'all', 0, 1);
484
+			$this->state_code   = $tmparray['code'];
485
+			$this->state        = $tmparray['label'];
486
+			$this->region_code  = $tmparray['region_code'];
487
+			$this->region       = $tmparray['region'];
488 488
         }
489 489
 
490 490
 		return dol_format_address($this, $withcountry, $sep);
@@ -502,108 +502,108 @@  discard block
 block discarded – undo
502 502
 	{
503 503
 		global $conf, $langs;
504 504
 
505
-		$countriesusingstate=array('AU','US','IN','GB','ES','UK','TR');    // See also option MAIN_FORCE_STATE_INTO_ADDRESS
505
+		$countriesusingstate = array('AU', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also option MAIN_FORCE_STATE_INTO_ADDRESS
506 506
 
507
-		$contactid=0;
508
-		$thirdpartyid=0;
507
+		$contactid = 0;
508
+		$thirdpartyid = 0;
509 509
 		if ($this->element == 'societe')
510 510
 		{
511
-			$thirdpartyid=$this->id;
511
+			$thirdpartyid = $this->id;
512 512
 		}
513 513
 		if ($this->element == 'contact')
514 514
 		{
515
-			$contactid=$this->id;
516
-			$thirdpartyid=$object->fk_soc;
515
+			$contactid = $this->id;
516
+			$thirdpartyid = $object->fk_soc;
517 517
 		}
518 518
 		if ($this->element == 'user')
519 519
 		{
520
-			$contactid=$this->contact_id;
521
-			$thirdpartyid=$object->fk_soc;
520
+			$contactid = $this->contact_id;
521
+			$thirdpartyid = $object->fk_soc;
522 522
 		}
523 523
 
524
-		$out='<!-- BEGIN part to show address block -->';
524
+		$out = '<!-- BEGIN part to show address block -->';
525 525
 
526
-		$outdone=0;
527
-		$coords = $this->getFullAddress(1,', ',$conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
526
+		$outdone = 0;
527
+		$coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
528 528
 		if ($coords)
529 529
 		{
530
-			if (! empty($conf->use_javascript_ajax))
530
+			if (!empty($conf->use_javascript_ajax))
531 531
 			{
532
-				$namecoords = $this->getFullName($langs,1).'<br>'.$coords;
532
+				$namecoords = $this->getFullName($langs, 1).'<br>'.$coords;
533 533
 				// hideonsmatphone because copyToClipboard call jquery dialog that does not work with jmobile
534
-				$out.='<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">';
535
-				$out.=img_picto($langs->trans("Address"), 'object_address.png');
536
-				$out.='</a> ';
534
+				$out .= '<a href="#" class="hideonsmartphone" onclick="return copyToClipboard(\''.dol_escape_js($namecoords).'\',\''.dol_escape_js($langs->trans("HelpCopyToClipboard")).'\');">';
535
+				$out .= img_picto($langs->trans("Address"), 'object_address.png');
536
+				$out .= '</a> ';
537 537
 			}
538
-			$out.=dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++;
538
+			$out .= dol_print_address($coords, 'address_'.$htmlkey.'_'.$this->id, $this->element, $this->id, 1, ', '); $outdone++;
539 539
 			$outdone++;
540 540
 		}
541 541
 
542
-		if (! in_array($this->country_code,$countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)   // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
542
+		if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)   // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress
543 543
 				&& empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state)
544 544
 		{
545 545
             if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
546
-                $out.=($outdone?' - ':'').$this->region.' - '.$this->state;
546
+                $out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state;
547 547
             }
548 548
             else {
549
-                $out.=($outdone?' - ':'').$this->state;
549
+                $out .= ($outdone ? ' - ' : '').$this->state;
550 550
             }
551 551
 			$outdone++;
552 552
 		}
553 553
 
554
-		if (! empty($this->phone) || ! empty($this->phone_pro) || ! empty($this->phone_mobile) || ! empty($this->phone_perso) || ! empty($this->fax) || ! empty($this->office_phone) || ! empty($this->user_mobile) || ! empty($this->office_fax)) $out.=($outdone?'<br>':'');
555
-		if (! empty($this->phone) && empty($this->phone_pro)) {		// For objects that store pro phone into ->phone
556
-			$out.=dol_print_phone($this->phone,$this->country_code,$contactid,$thirdpartyid,'AC_TEL','&nbsp;','phone',$langs->trans("PhonePro")); $outdone++;
554
+		if (!empty($this->phone) || !empty($this->phone_pro) || !empty($this->phone_mobile) || !empty($this->phone_perso) || !empty($this->fax) || !empty($this->office_phone) || !empty($this->user_mobile) || !empty($this->office_fax)) $out .= ($outdone ? '<br>' : '');
555
+		if (!empty($this->phone) && empty($this->phone_pro)) {		// For objects that store pro phone into ->phone
556
+			$out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', '&nbsp;', 'phone', $langs->trans("PhonePro")); $outdone++;
557 557
 		}
558
-		if (! empty($this->phone_pro)) {
559
-			$out.=dol_print_phone($this->phone_pro,$this->country_code,$contactid,$thirdpartyid,'AC_TEL','&nbsp;','phone',$langs->trans("PhonePro")); $outdone++;
558
+		if (!empty($this->phone_pro)) {
559
+			$out .= dol_print_phone($this->phone_pro, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', '&nbsp;', 'phone', $langs->trans("PhonePro")); $outdone++;
560 560
 		}
561
-		if (! empty($this->phone_mobile)) {
562
-			$out.=dol_print_phone($this->phone_mobile,$this->country_code,$contactid,$thirdpartyid,'AC_TEL','&nbsp;','mobile',$langs->trans("PhoneMobile")); $outdone++;
561
+		if (!empty($this->phone_mobile)) {
562
+			$out .= dol_print_phone($this->phone_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', '&nbsp;', 'mobile', $langs->trans("PhoneMobile")); $outdone++;
563 563
 		}
564
-		if (! empty($this->phone_perso)) {
565
-			$out.=dol_print_phone($this->phone_perso,$this->country_code,$contactid,$thirdpartyid,'AC_TEL','&nbsp;','phone',$langs->trans("PhonePerso")); $outdone++;
564
+		if (!empty($this->phone_perso)) {
565
+			$out .= dol_print_phone($this->phone_perso, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', '&nbsp;', 'phone', $langs->trans("PhonePerso")); $outdone++;
566 566
 		}
567
-		if (! empty($this->office_phone)) {
568
-			$out.=dol_print_phone($this->office_phone,$this->country_code,$contactid,$thirdpartyid,'AC_TEL','&nbsp;','phone',$langs->trans("PhonePro")); $outdone++;
567
+		if (!empty($this->office_phone)) {
568
+			$out .= dol_print_phone($this->office_phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', '&nbsp;', 'phone', $langs->trans("PhonePro")); $outdone++;
569 569
 		}
570
-		if (! empty($this->user_mobile)) {
571
-			$out.=dol_print_phone($this->user_mobile,$this->country_code,$contactid,$thirdpartyid,'AC_TEL','&nbsp;','mobile',$langs->trans("PhoneMobile")); $outdone++;
570
+		if (!empty($this->user_mobile)) {
571
+			$out .= dol_print_phone($this->user_mobile, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', '&nbsp;', 'mobile', $langs->trans("PhoneMobile")); $outdone++;
572 572
 		}
573
-		if (! empty($this->fax)) {
574
-			$out.=dol_print_phone($this->fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX','&nbsp;','fax',$langs->trans("Fax")); $outdone++;
573
+		if (!empty($this->fax)) {
574
+			$out .= dol_print_phone($this->fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', '&nbsp;', 'fax', $langs->trans("Fax")); $outdone++;
575 575
 		}
576
-		if (! empty($this->office_fax)) {
577
-			$out.=dol_print_phone($this->office_fax,$this->country_code,$contactid,$thirdpartyid,'AC_FAX','&nbsp;','fax',$langs->trans("Fax")); $outdone++;
576
+		if (!empty($this->office_fax)) {
577
+			$out .= dol_print_phone($this->office_fax, $this->country_code, $contactid, $thirdpartyid, 'AC_FAX', '&nbsp;', 'fax', $langs->trans("Fax")); $outdone++;
578 578
 		}
579 579
 
580
-		$out.='<div style="clear: both;"></div>';
581
-		$outdone=0;
582
-		if (! empty($this->email))
580
+		$out .= '<div style="clear: both;"></div>';
581
+		$outdone = 0;
582
+		if (!empty($this->email))
583 583
 		{
584
-			$out.=dol_print_email($this->email,$this->id,$object->id,'AC_EMAIL',0,0,1);
584
+			$out .= dol_print_email($this->email, $this->id, $object->id, 'AC_EMAIL', 0, 0, 1);
585 585
 			$outdone++;
586 586
 		}
587
-		if (! empty($this->url))
587
+		if (!empty($this->url))
588 588
 		{
589
-			$out.=dol_print_url($this->url,'_goout',0,1);
589
+			$out .= dol_print_url($this->url, '_goout', 0, 1);
590 590
 			$outdone++;
591 591
 		}
592
-		$out.='<div style="clear: both;">';
593
-		if (! empty($conf->socialnetworks->enabled))
592
+		$out .= '<div style="clear: both;">';
593
+		if (!empty($conf->socialnetworks->enabled))
594 594
 		{
595
-			if ($this->skype) $out.=dol_print_socialnetworks($this->skype,$this->id,$object->id,'skype');
595
+			if ($this->skype) $out .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype');
596 596
 			$outdone++;
597
-			if ($this->jabberid) $out.=dol_print_socialnetworks($this->jabberid,$this->id,$object->id,'jabber');
597
+			if ($this->jabberid) $out .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber');
598 598
 			$outdone++;
599
-			if ($this->twitter) $out.=dol_print_socialnetworks($this->twitter,$this->id,$object->id,'twitter');
599
+			if ($this->twitter) $out .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter');
600 600
 			$outdone++;
601
-			if ($this->facebook) $out.=dol_print_socialnetworks($this->facebook,$this->id,$object->id,'facebook');
601
+			if ($this->facebook) $out .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook');
602 602
 			$outdone++;
603 603
 		}
604
-		$out.='</div>';
604
+		$out .= '</div>';
605 605
 
606
-		$out.='<!-- END Part to show address block -->';
606
+		$out .= '<!-- END Part to show address block -->';
607 607
 
608 608
 		return $out;
609 609
 	}
@@ -616,17 +616,17 @@  discard block
 block discarded – undo
616 616
 	 * @param	int		$relativelink		0=Return full external link, 1=Return link relative to root of file
617 617
 	 * @return	string						Link or empty string if there is no download link
618 618
 	 */
619
-	function getLastMainDocLink($modulepart, $initsharekey=0, $relativelink=0)
619
+	function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0)
620 620
 	{
621 621
 		global $user, $dolibarr_main_url_root;
622 622
 
623 623
 		if (empty($this->last_main_doc))
624 624
 		{
625
-			return '';		// No way to known which document name to use
625
+			return ''; // No way to known which document name to use
626 626
 		}
627 627
 
628 628
 		include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
629
-		$ecmfile=new EcmFiles($this->db);
629
+		$ecmfile = new EcmFiles($this->db);
630 630
 		$result = $ecmfile->fetch(0, '', $this->last_main_doc);
631 631
 		if ($result < 0)
632 632
 		{
@@ -674,26 +674,26 @@  discard block
 block discarded – undo
674 674
 		}
675 675
 
676 676
 		// Define $urlwithroot
677
-		$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
678
-		$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
677
+		$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
678
+		$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
679 679
 		//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
680 680
 
681
-		$forcedownload=0;
681
+		$forcedownload = 0;
682 682
 
683
-		$paramlink='';
683
+		$paramlink = '';
684 684
 		//if (! empty($modulepart)) $paramlink.=($paramlink?'&':'').'modulepart='.$modulepart;		// For sharing with hash (so public files), modulepart is not required.
685 685
 		//if (! empty($ecmfile->entity)) $paramlink.='&entity='.$ecmfile->entity; 					// For sharing with hash (so public files), entity is not required.
686 686
 		//$paramlink.=($paramlink?'&':'').'file='.urlencode($filepath);								// No need of name of file for public link, we will use the hash
687
-		if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share;			// Hash for public share
688
-		if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
687
+		if (!empty($ecmfile->share)) $paramlink .= ($paramlink ? '&' : '').'hashp='.$ecmfile->share; // Hash for public share
688
+		if ($forcedownload) $paramlink .= ($paramlink ? '&' : '').'attachment=1';
689 689
 
690 690
 		if ($relativelink)
691 691
 		{
692
-			$linktoreturn='document.php'.($paramlink?'?'.$paramlink:'');
692
+			$linktoreturn = 'document.php'.($paramlink ? '?'.$paramlink : '');
693 693
 		}
694 694
 		else
695 695
 		{
696
-			$linktoreturn=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
696
+			$linktoreturn = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : '');
697 697
 		}
698 698
 
699 699
 		// Here $ecmfile->share is defined
@@ -711,10 +711,10 @@  discard block
 block discarded – undo
711 711
 	 *  @param  int		$notrigger			Disable all triggers
712 712
 	 *  @return int                 		<0 if KO, >0 if OK
713 713
 	 */
714
-	function add_contact($fk_socpeople, $type_contact, $source='external',$notrigger=0)
714
+	function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0)
715 715
 	{
716 716
         // phpcs:enable
717
-		global $user,$langs;
717
+		global $user, $langs;
718 718
 
719 719
 
720 720
 		dol_syslog(get_class($this)."::add_contact $fk_socpeople, $type_contact, $source, $notrigger");
@@ -723,43 +723,43 @@  discard block
 block discarded – undo
723 723
 		if ($fk_socpeople <= 0)
724 724
 		{
725 725
 			$langs->load("errors");
726
-			$this->error=$langs->trans("ErrorWrongValueForParameterX","1");
727
-			dol_syslog(get_class($this)."::add_contact ".$this->error,LOG_ERR);
726
+			$this->error = $langs->trans("ErrorWrongValueForParameterX", "1");
727
+			dol_syslog(get_class($this)."::add_contact ".$this->error, LOG_ERR);
728 728
 			return -1;
729 729
 		}
730
-		if (! $type_contact)
730
+		if (!$type_contact)
731 731
 		{
732 732
 			$langs->load("errors");
733
-			$this->error=$langs->trans("ErrorWrongValueForParameterX","2");
734
-			dol_syslog(get_class($this)."::add_contact ".$this->error,LOG_ERR);
733
+			$this->error = $langs->trans("ErrorWrongValueForParameterX", "2");
734
+			dol_syslog(get_class($this)."::add_contact ".$this->error, LOG_ERR);
735 735
 			return -2;
736 736
 		}
737 737
 
738
-		$id_type_contact=0;
738
+		$id_type_contact = 0;
739 739
 		if (is_numeric($type_contact))
740 740
 		{
741
-			$id_type_contact=$type_contact;
741
+			$id_type_contact = $type_contact;
742 742
 		}
743 743
 		else
744 744
 		{
745 745
 			// We look for id type_contact
746 746
 			$sql = "SELECT tc.rowid";
747
-			$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
748
-			$sql.= " WHERE tc.element='".$this->db->escape($this->element)."'";
749
-			$sql.= " AND tc.source='".$this->db->escape($source)."'";
750
-			$sql.= " AND tc.code='".$this->db->escape($type_contact)."' AND tc.active=1";
747
+			$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
748
+			$sql .= " WHERE tc.element='".$this->db->escape($this->element)."'";
749
+			$sql .= " AND tc.source='".$this->db->escape($source)."'";
750
+			$sql .= " AND tc.code='".$this->db->escape($type_contact)."' AND tc.active=1";
751 751
 			//print $sql;
752
-			$resql=$this->db->query($sql);
752
+			$resql = $this->db->query($sql);
753 753
 			if ($resql)
754 754
 			{
755 755
 				$obj = $this->db->fetch_object($resql);
756
-				if ($obj) $id_type_contact=$obj->rowid;
756
+				if ($obj) $id_type_contact = $obj->rowid;
757 757
 			}
758 758
 		}
759 759
 
760 760
 		if ($id_type_contact == 0)
761 761
 		{
762
-			$this->error='CODE_NOT_VALID_FOR_THIS_ELEMENT';
762
+			$this->error = 'CODE_NOT_VALID_FOR_THIS_ELEMENT';
763 763
 			dol_syslog("CODE_NOT_VALID_FOR_THIS_ELEMENT: Code type of contact '".$type_contact."' does not exists or is not active for element ".$this->element.", we can ignore it");
764 764
 			return -3;
765 765
 		}
@@ -767,35 +767,35 @@  discard block
 block discarded – undo
767 767
 		$datecreate = dol_now();
768 768
 
769 769
 		// Socpeople must have already been added by some trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error
770
-		$TListeContacts=$this->liste_contact(-1, $source);
771
-		$already_added=false;
772
-		if(!empty($TListeContacts)) {
773
-			foreach($TListeContacts as $array_contact) {
774
-				if($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) {
775
-					$already_added=true;
770
+		$TListeContacts = $this->liste_contact(-1, $source);
771
+		$already_added = false;
772
+		if (!empty($TListeContacts)) {
773
+			foreach ($TListeContacts as $array_contact) {
774
+				if ($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) {
775
+					$already_added = true;
776 776
 					break;
777 777
 				}
778 778
 			}
779 779
 		}
780 780
 
781
-		if(!$already_added) {
781
+		if (!$already_added) {
782 782
 
783 783
 			$this->db->begin();
784 784
 
785 785
 			// Insert into database
786 786
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
787
-			$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
788
-			$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
789
-			$sql.= "'".$this->db->idate($datecreate)."'";
790
-			$sql.= ", 4, ". $id_type_contact;
791
-			$sql.= ")";
787
+			$sql .= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
788
+			$sql .= " VALUES (".$this->id.", ".$fk_socpeople." , ";
789
+			$sql .= "'".$this->db->idate($datecreate)."'";
790
+			$sql .= ", 4, ".$id_type_contact;
791
+			$sql .= ")";
792 792
 
793
-			$resql=$this->db->query($sql);
793
+			$resql = $this->db->query($sql);
794 794
 			if ($resql)
795 795
 			{
796
-				if (! $notrigger)
796
+				if (!$notrigger)
797 797
 				{
798
-					$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
798
+					$result = $this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
799 799
 					if ($result < 0)
800 800
 					{
801 801
 						$this->db->rollback();
@@ -810,14 +810,14 @@  discard block
 block discarded – undo
810 810
 			{
811 811
 				if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
812 812
 				{
813
-					$this->error=$this->db->errno();
813
+					$this->error = $this->db->errno();
814 814
 					$this->db->rollback();
815 815
 					echo 'err rollback';
816 816
 					return -2;
817 817
 				}
818 818
 				else
819 819
 				{
820
-					$this->error=$this->db->error();
820
+					$this->error = $this->db->error();
821 821
 					$this->db->rollback();
822 822
 					return -1;
823 823
 				}
@@ -833,15 +833,15 @@  discard block
 block discarded – undo
833 833
 	 *    @param    string          $source     Nature of contact ('internal' or 'external')
834 834
 	 *    @return   int                         >0 if OK, <0 if KO
835 835
 	 */
836
-	function copy_linked_contact($objFrom, $source='internal')
836
+	function copy_linked_contact($objFrom, $source = 'internal')
837 837
 	{
838 838
         // phpcs:enable
839 839
 		$contacts = $objFrom->liste_contact(-1, $source);
840
-		foreach($contacts as $contact)
840
+		foreach ($contacts as $contact)
841 841
 		{
842 842
 			if ($this->add_contact($contact['id'], $contact['fk_c_type_contact'], $contact['source']) < 0)
843 843
 			{
844
-				$this->error=$this->db->lasterror();
844
+				$this->error = $this->db->lasterror();
845 845
 				return -1;
846 846
 			}
847 847
 		}
@@ -858,23 +858,23 @@  discard block
 block discarded – undo
858 858
 	 *      @param  int		$fk_socpeople	    Id of soc_people to update (not modified if 0)
859 859
 	 *      @return int                 		<0 if KO, >= 0 if OK
860 860
 	 */
861
-	function update_contact($rowid, $statut, $type_contact_id=0, $fk_socpeople=0)
861
+	function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0)
862 862
 	{
863 863
         // phpcs:enable
864 864
 		// Insert into database
865 865
 		$sql = "UPDATE ".MAIN_DB_PREFIX."element_contact set";
866
-		$sql.= " statut = ".$statut;
867
-		if ($type_contact_id) $sql.= ", fk_c_type_contact = '".$type_contact_id ."'";
868
-		if ($fk_socpeople) $sql.= ", fk_socpeople = '".$fk_socpeople ."'";
869
-		$sql.= " where rowid = ".$rowid;
870
-		$resql=$this->db->query($sql);
866
+		$sql .= " statut = ".$statut;
867
+		if ($type_contact_id) $sql .= ", fk_c_type_contact = '".$type_contact_id."'";
868
+		if ($fk_socpeople) $sql .= ", fk_socpeople = '".$fk_socpeople."'";
869
+		$sql .= " where rowid = ".$rowid;
870
+		$resql = $this->db->query($sql);
871 871
 		if ($resql)
872 872
 		{
873 873
 			return 0;
874 874
 		}
875 875
 		else
876 876
 		{
877
-			$this->error=$this->db->lasterror();
877
+			$this->error = $this->db->lasterror();
878 878
 			return -1;
879 879
 		}
880 880
 	}
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 *    @param	int		$notrigger		Disable all triggers
888 888
 	 *    @return   int						>0 if OK, <0 if KO
889 889
 	 */
890
-	function delete_contact($rowid, $notrigger=0)
890
+	function delete_contact($rowid, $notrigger = 0)
891 891
 	{
892 892
         // phpcs:enable
893 893
 		global $user;
@@ -896,14 +896,14 @@  discard block
 block discarded – undo
896 896
 		$this->db->begin();
897 897
 
898 898
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
899
-		$sql.= " WHERE rowid =".$rowid;
899
+		$sql .= " WHERE rowid =".$rowid;
900 900
 
901 901
 		dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG);
902 902
 		if ($this->db->query($sql))
903 903
 		{
904
-			if (! $notrigger)
904
+			if (!$notrigger)
905 905
 			{
906
-				$result=$this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
906
+				$result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user);
907 907
 				if ($result < 0) { $this->db->rollback(); return -1; }
908 908
 			}
909 909
 
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 		}
913 913
 		else
914 914
 		{
915
-			$this->error=$this->db->lasterror();
915
+			$this->error = $this->db->lasterror();
916 916
 			$this->db->rollback();
917 917
 			return -1;
918 918
 		}
@@ -926,22 +926,22 @@  discard block
 block discarded – undo
926 926
 	 *	  @param	string	$code		Type of contact (code or id)
927 927
 	 *    @return   int					>0 if OK, <0 if KO
928 928
 	 */
929
-	function delete_linked_contact($source='',$code='')
929
+	function delete_linked_contact($source = '', $code = '')
930 930
 	{
931 931
         // phpcs:enable
932 932
 		$temp = array();
933
-		$typeContact = $this->liste_type_contact($source,'',0,0,$code);
933
+		$typeContact = $this->liste_type_contact($source, '', 0, 0, $code);
934 934
 
935
-		foreach($typeContact as $key => $value)
935
+		foreach ($typeContact as $key => $value)
936 936
 		{
937
-			array_push($temp,$key);
937
+			array_push($temp, $key);
938 938
 		}
939 939
 		$listId = implode(",", $temp);
940 940
 
941 941
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
942
-		$sql.= " WHERE element_id = ".$this->id;
942
+		$sql .= " WHERE element_id = ".$this->id;
943 943
 		if ($listId)
944
-			$sql.= " AND fk_c_type_contact IN (".$listId.")";
944
+			$sql .= " AND fk_c_type_contact IN (".$listId.")";
945 945
 
946 946
 		dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG);
947 947
 		if ($this->db->query($sql))
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 		}
951 951
 		else
952 952
 		{
953
-			$this->error=$this->db->lasterror();
953
+			$this->error = $this->db->lasterror();
954 954
 			return -1;
955 955
 		}
956 956
 	}
@@ -965,54 +965,54 @@  discard block
 block discarded – undo
965 965
 	 *    @param    string      $code       Filter on this code of contact type ('SHIPPING', 'BILLING', ...)
966 966
 	 *    @return	array|int		        Array of contacts, -1 if error
967 967
 	 */
968
-	function liste_contact($statut=-1,$source='external',$list=0,$code='')
968
+	function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '')
969 969
 	{
970 970
         // phpcs:enable
971 971
 		global $langs;
972 972
 
973
-		$tab=array();
974
-
975
-		$sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact";    // This field contains id of llx_socpeople or id of llx_user
976
-		if ($source == 'internal') $sql.=", '-1' as socid, t.statut as statuscontact, t.login, t.photo";
977
-		if ($source == 'external' || $source == 'thirdparty') $sql.=", t.fk_soc as socid, t.statut as statuscontact";
978
-		$sql.= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email";
979
-		$sql.= ", tc.source, tc.element, tc.code, tc.libelle";
980
-		$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
981
-		$sql.= ", ".MAIN_DB_PREFIX."element_contact ec";
982
-		if ($source == 'internal') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
983
-		if ($source == 'external'|| $source == 'thirdparty') $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
984
-		$sql.= " WHERE ec.element_id =".$this->id;
985
-		$sql.= " AND ec.fk_c_type_contact=tc.rowid";
986
-		$sql.= " AND tc.element='".$this->db->escape($this->element)."'";
987
-		if ($code) $sql.= " AND tc.code = '".$this->db->escape($code)."'";
988
-		if ($source == 'internal') $sql.= " AND tc.source = 'internal'";
989
-		if ($source == 'external' || $source == 'thirdparty') $sql.= " AND tc.source = 'external'";
990
-		$sql.= " AND tc.active=1";
991
-		if ($statut >= 0) $sql.= " AND ec.statut = '".$statut."'";
992
-		$sql.=" ORDER BY t.lastname ASC";
973
+		$tab = array();
974
+
975
+		$sql = "SELECT ec.rowid, ec.statut as statuslink, ec.fk_socpeople as id, ec.fk_c_type_contact"; // This field contains id of llx_socpeople or id of llx_user
976
+		if ($source == 'internal') $sql .= ", '-1' as socid, t.statut as statuscontact, t.login, t.photo";
977
+		if ($source == 'external' || $source == 'thirdparty') $sql .= ", t.fk_soc as socid, t.statut as statuscontact";
978
+		$sql .= ", t.civility as civility, t.lastname as lastname, t.firstname, t.email";
979
+		$sql .= ", tc.source, tc.element, tc.code, tc.libelle";
980
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc";
981
+		$sql .= ", ".MAIN_DB_PREFIX."element_contact ec";
982
+		if ($source == 'internal') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user t on ec.fk_socpeople = t.rowid";
983
+		if ($source == 'external' || $source == 'thirdparty') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople t on ec.fk_socpeople = t.rowid";
984
+		$sql .= " WHERE ec.element_id =".$this->id;
985
+		$sql .= " AND ec.fk_c_type_contact=tc.rowid";
986
+		$sql .= " AND tc.element='".$this->db->escape($this->element)."'";
987
+		if ($code) $sql .= " AND tc.code = '".$this->db->escape($code)."'";
988
+		if ($source == 'internal') $sql .= " AND tc.source = 'internal'";
989
+		if ($source == 'external' || $source == 'thirdparty') $sql .= " AND tc.source = 'external'";
990
+		$sql .= " AND tc.active=1";
991
+		if ($statut >= 0) $sql .= " AND ec.statut = '".$statut."'";
992
+		$sql .= " ORDER BY t.lastname ASC";
993 993
 
994 994
 		dol_syslog(get_class($this)."::liste_contact", LOG_DEBUG);
995
-		$resql=$this->db->query($sql);
995
+		$resql = $this->db->query($sql);
996 996
 		if ($resql)
997 997
 		{
998
-			$num=$this->db->num_rows($resql);
999
-			$i=0;
998
+			$num = $this->db->num_rows($resql);
999
+			$i = 0;
1000 1000
 			while ($i < $num)
1001 1001
 			{
1002 1002
 				$obj = $this->db->fetch_object($resql);
1003 1003
 
1004
-				if (! $list)
1004
+				if (!$list)
1005 1005
 				{
1006
-					$transkey="TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
1007
-					$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
1008
-					$tab[$i]=array('source'=>$obj->source,'socid'=>$obj->socid,'id'=>$obj->id,
1009
-								   'nom'=>$obj->lastname,      // For backward compatibility
1006
+					$transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code;
1007
+					$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
1008
+					$tab[$i] = array('source'=>$obj->source, 'socid'=>$obj->socid, 'id'=>$obj->id,
1009
+								   'nom'=>$obj->lastname, // For backward compatibility
1010 1010
 								   'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact,
1011 1011
 								   'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact);
1012 1012
 				}
1013 1013
 				else
1014 1014
 				{
1015
-					$tab[$i]=$obj->id;
1015
+					$tab[$i] = $obj->id;
1016 1016
 				}
1017 1017
 
1018 1018
 				$i++;
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
 		}
1023 1023
 		else
1024 1024
 		{
1025
-			$this->error=$this->db->lasterror();
1025
+			$this->error = $this->db->lasterror();
1026 1026
 			dol_print_error($this->db);
1027 1027
 			return -1;
1028 1028
 		}
@@ -1038,16 +1038,16 @@  discard block
 block discarded – undo
1038 1038
 	function swapContactStatus($rowid)
1039 1039
 	{
1040 1040
 		$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
1041
-		$sql.= " tc.code, tc.libelle";
1041
+		$sql .= " tc.code, tc.libelle";
1042 1042
 		//$sql.= ", s.fk_soc";
1043
-		$sql.= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)";
1043
+		$sql .= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)";
1044 1044
 		//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.rowid";	// Si contact de type external, alors il est lie a une societe
1045
-		$sql.= " WHERE ec.rowid =".$rowid;
1046
-		$sql.= " AND ec.fk_c_type_contact=tc.rowid";
1047
-		$sql.= " AND tc.element = '".$this->db->escape($this->element)."'";
1045
+		$sql .= " WHERE ec.rowid =".$rowid;
1046
+		$sql .= " AND ec.fk_c_type_contact=tc.rowid";
1047
+		$sql .= " AND tc.element = '".$this->db->escape($this->element)."'";
1048 1048
 
1049 1049
 		dol_syslog(get_class($this)."::swapContactStatus", LOG_DEBUG);
1050
-		$resql=$this->db->query($sql);
1050
+		$resql = $this->db->query($sql);
1051 1051
 		if ($resql)
1052 1052
 		{
1053 1053
 			$obj = $this->db->fetch_object($resql);
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 		}
1059 1059
 		else
1060 1060
 		{
1061
-			$this->error=$this->db->error();
1061
+			$this->error = $this->db->error();
1062 1062
 			dol_print_error($this->db);
1063 1063
 			return -1;
1064 1064
 		}
@@ -1075,44 +1075,44 @@  discard block
 block discarded – undo
1075 1075
 	 *		@param	string	$code		Type of contact (Example: 'CUSTOMER', 'SERVICE')
1076 1076
 	 *      @return array       		Array list of type of contacts (id->label if option=0, code->label if option=1)
1077 1077
 	 */
1078
-	function liste_type_contact($source='internal', $order='position', $option=0, $activeonly=0, $code='')
1078
+	function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '')
1079 1079
 	{
1080 1080
         // phpcs:enable
1081 1081
 		global $langs;
1082 1082
 
1083
-		if (empty($order)) $order='position';
1084
-		if ($order == 'position') $order.=',code';
1083
+		if (empty($order)) $order = 'position';
1084
+		if ($order == 'position') $order .= ',code';
1085 1085
 
1086 1086
 		$tab = array();
1087 1087
 		$sql = "SELECT DISTINCT tc.rowid, tc.code, tc.libelle, tc.position";
1088
-		$sql.= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
1089
-		$sql.= " WHERE tc.element='".$this->db->escape($this->element)."'";
1090
-		if ($activeonly == 1) $sql.= " AND tc.active=1"; // only the active types
1091
-		if (! empty($source) && $source != 'all') $sql.= " AND tc.source='".$this->db->escape($source)."'";
1092
-		if (! empty($code)) $sql.= " AND tc.code='".$this->db->escape($code)."'";
1093
-		$sql.= $this->db->order($order,'ASC');
1088
+		$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
1089
+		$sql .= " WHERE tc.element='".$this->db->escape($this->element)."'";
1090
+		if ($activeonly == 1) $sql .= " AND tc.active=1"; // only the active types
1091
+		if (!empty($source) && $source != 'all') $sql .= " AND tc.source='".$this->db->escape($source)."'";
1092
+		if (!empty($code)) $sql .= " AND tc.code='".$this->db->escape($code)."'";
1093
+		$sql .= $this->db->order($order, 'ASC');
1094 1094
 
1095 1095
 		//print "sql=".$sql;
1096
-		$resql=$this->db->query($sql);
1096
+		$resql = $this->db->query($sql);
1097 1097
 		if ($resql)
1098 1098
 		{
1099
-			$num=$this->db->num_rows($resql);
1100
-			$i=0;
1099
+			$num = $this->db->num_rows($resql);
1100
+			$i = 0;
1101 1101
 			while ($i < $num)
1102 1102
 			{
1103 1103
 				$obj = $this->db->fetch_object($resql);
1104 1104
 
1105
-				$transkey="TypeContact_".$this->element."_".$source."_".$obj->code;
1106
-				$libelle_type=($langs->trans($transkey)!=$transkey ? $langs->trans($transkey) : $obj->libelle);
1107
-				if (empty($option)) $tab[$obj->rowid]=$libelle_type;
1108
-				else $tab[$obj->code]=$libelle_type;
1105
+				$transkey = "TypeContact_".$this->element."_".$source."_".$obj->code;
1106
+				$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
1107
+				if (empty($option)) $tab[$obj->rowid] = $libelle_type;
1108
+				else $tab[$obj->code] = $libelle_type;
1109 1109
 				$i++;
1110 1110
 			}
1111 1111
 			return $tab;
1112 1112
 		}
1113 1113
 		else
1114 1114
 		{
1115
-			$this->error=$this->db->lasterror();
1115
+			$this->error = $this->db->lasterror();
1116 1116
 			//dol_print_error($this->db);
1117 1117
 			return null;
1118 1118
 		}
@@ -1129,53 +1129,53 @@  discard block
 block discarded – undo
1129 1129
 	 *		@param	int		$status		limited to a certain status
1130 1130
 	 *      @return array       		List of id for such contacts
1131 1131
 	 */
1132
-	function getIdContact($source,$code,$status=0)
1132
+	function getIdContact($source, $code, $status = 0)
1133 1133
 	{
1134 1134
 		global $conf;
1135 1135
 
1136
-		$result=array();
1137
-		$i=0;
1136
+		$result = array();
1137
+		$i = 0;
1138 1138
 		//cas particulier pour les expeditions
1139
-		if($this->element=='shipping' && $this->origin_id != 0) {
1140
-			$id=$this->origin_id;
1141
-			$element='commande';
1142
-        } else if($this->element=='reception' && $this->origin_id != 0) {
1143
-            $id=$this->origin_id;
1144
-            $element='order_supplier';
1139
+		if ($this->element == 'shipping' && $this->origin_id != 0) {
1140
+			$id = $this->origin_id;
1141
+			$element = 'commande';
1142
+        } else if ($this->element == 'reception' && $this->origin_id != 0) {
1143
+            $id = $this->origin_id;
1144
+            $element = 'order_supplier';
1145 1145
 		} else {
1146
-			$id=$this->id;
1147
-			$element=$this->element;
1146
+			$id = $this->id;
1147
+			$element = $this->element;
1148 1148
 		}
1149 1149
 
1150 1150
 		$sql = "SELECT ec.fk_socpeople";
1151
-		$sql.= " FROM ".MAIN_DB_PREFIX."element_contact as ec,";
1152
-		if ($source == 'internal') $sql.= " ".MAIN_DB_PREFIX."user as c,";
1153
-		if ($source == 'external') $sql.= " ".MAIN_DB_PREFIX."socpeople as c,";
1154
-		$sql.= " ".MAIN_DB_PREFIX."c_type_contact as tc";
1155
-		$sql.= " WHERE ec.element_id = ".$id;
1156
-		$sql.= " AND ec.fk_socpeople = c.rowid";
1157
-		if ($source == 'internal') $sql.= " AND c.entity IN (".getEntity('user').")";
1158
-		if ($source == 'external') $sql.= " AND c.entity IN (".getEntity('societe').")";
1159
-		$sql.= " AND ec.fk_c_type_contact = tc.rowid";
1160
-		$sql.= " AND tc.element = '".$element."'";
1161
-		$sql.= " AND tc.source = '".$source."'";
1162
-		$sql.= " AND tc.code = '".$code."'";
1163
-		$sql.= " AND tc.active = 1";
1164
-		if ($status) $sql.= " AND ec.statut = ".$status;
1151
+		$sql .= " FROM ".MAIN_DB_PREFIX."element_contact as ec,";
1152
+		if ($source == 'internal') $sql .= " ".MAIN_DB_PREFIX."user as c,";
1153
+		if ($source == 'external') $sql .= " ".MAIN_DB_PREFIX."socpeople as c,";
1154
+		$sql .= " ".MAIN_DB_PREFIX."c_type_contact as tc";
1155
+		$sql .= " WHERE ec.element_id = ".$id;
1156
+		$sql .= " AND ec.fk_socpeople = c.rowid";
1157
+		if ($source == 'internal') $sql .= " AND c.entity IN (".getEntity('user').")";
1158
+		if ($source == 'external') $sql .= " AND c.entity IN (".getEntity('societe').")";
1159
+		$sql .= " AND ec.fk_c_type_contact = tc.rowid";
1160
+		$sql .= " AND tc.element = '".$element."'";
1161
+		$sql .= " AND tc.source = '".$source."'";
1162
+		$sql .= " AND tc.code = '".$code."'";
1163
+		$sql .= " AND tc.active = 1";
1164
+		if ($status) $sql .= " AND ec.statut = ".$status;
1165 1165
 
1166 1166
 		dol_syslog(get_class($this)."::getIdContact", LOG_DEBUG);
1167
-		$resql=$this->db->query($sql);
1167
+		$resql = $this->db->query($sql);
1168 1168
 		if ($resql)
1169 1169
 		{
1170 1170
 			while ($obj = $this->db->fetch_object($resql))
1171 1171
 			{
1172
-				$result[$i]=$obj->fk_socpeople;
1172
+				$result[$i] = $obj->fk_socpeople;
1173 1173
 				$i++;
1174 1174
 			}
1175 1175
 		}
1176 1176
 		else
1177 1177
 		{
1178
-			$this->error=$this->db->error();
1178
+			$this->error = $this->db->error();
1179 1179
 			return null;
1180 1180
 		}
1181 1181
 
@@ -1189,16 +1189,16 @@  discard block
 block discarded – undo
1189 1189
 	 *		@param	int		$contactid      Id du contact. Use this->contactid if empty.
1190 1190
 	 *		@return	int						<0 if KO, >0 if OK
1191 1191
 	 */
1192
-	function fetch_contact($contactid=null)
1192
+	function fetch_contact($contactid = null)
1193 1193
 	{
1194 1194
         // phpcs:enable
1195
-		if (empty($contactid)) $contactid=$this->contactid;
1195
+		if (empty($contactid)) $contactid = $this->contactid;
1196 1196
 
1197 1197
 		if (empty($contactid)) return 0;
1198 1198
 
1199 1199
 		require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
1200 1200
 		$contact = new Contact($this->db);
1201
-		$result=$contact->fetch($contactid);
1201
+		$result = $contact->fetch($contactid);
1202 1202
 		$this->contact = $contact;
1203 1203
 		return $result;
1204 1204
 	}
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
 	 *		@param		int		$force_thirdparty_id	Force thirdparty id
1211 1211
 	 *		@return		int								<0 if KO, >0 if OK
1212 1212
 	 */
1213
-	function fetch_thirdparty($force_thirdparty_id=0)
1213
+	function fetch_thirdparty($force_thirdparty_id = 0)
1214 1214
 	{
1215 1215
         // phpcs:enable
1216 1216
 		global $conf;
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 		if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty) && empty($force_thirdparty_id))
1219 1219
 			return 0;
1220 1220
 
1221
-		require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
1221
+		require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
1222 1222
 
1223 1223
 		$idtofetch = isset($this->socid) ? $this->socid : (isset($this->fk_soc) ? $this->fk_soc : $this->fk_thirdparty);
1224 1224
 		if ($force_thirdparty_id)
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 
1282 1282
 		dol_syslog(get_class($this).'::fetch_barcode this->element='.$this->element.' this->barcode_type='.$this->barcode_type);
1283 1283
 
1284
-		$idtype=$this->barcode_type;
1284
+		$idtype = $this->barcode_type;
1285 1285
 		if (empty($idtype) && $idtype != '0')	// If type of barcode no set, we try to guess. If set to '0' it means we forced to have type remain not defined
1286 1286
 		{
1287 1287
 			if ($this->element == 'product')      $idtype = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
@@ -1294,8 +1294,8 @@  discard block
 block discarded – undo
1294 1294
 			if (empty($this->barcode_type) || empty($this->barcode_type_code) || empty($this->barcode_type_label) || empty($this->barcode_type_coder))    // If data not already loaded
1295 1295
 			{
1296 1296
 				$sql = "SELECT rowid, code, libelle as label, coder";
1297
-				$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
1298
-				$sql.= " WHERE rowid = ".$idtype;
1297
+				$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
1298
+				$sql .= " WHERE rowid = ".$idtype;
1299 1299
 				dol_syslog(get_class($this).'::fetch_barcode', LOG_DEBUG);
1300 1300
 				$resql = $this->db->query($sql);
1301 1301
 				if ($resql)
@@ -1328,13 +1328,13 @@  discard block
 block discarded – undo
1328 1328
         // phpcs:enable
1329 1329
 		include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
1330 1330
 
1331
-		if (empty($this->fk_project) && ! empty($this->fk_projet)) $this->fk_project = $this->fk_projet;	// For backward compatibility
1331
+		if (empty($this->fk_project) && !empty($this->fk_projet)) $this->fk_project = $this->fk_projet; // For backward compatibility
1332 1332
 		if (empty($this->fk_project)) return 0;
1333 1333
 
1334 1334
 		$project = new Project($this->db);
1335 1335
 		$result = $project->fetch($this->fk_project);
1336 1336
 
1337
-		$this->projet = $project;	// deprecated
1337
+		$this->projet = $project; // deprecated
1338 1338
 		$this->project = $project;
1339 1339
 		return $result;
1340 1340
 	}
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 	{
1371 1371
         // phpcs:enable
1372 1372
 		$user = new User($this->db);
1373
-		$result=$user->fetch($userid);
1373
+		$result = $user->fetch($userid);
1374 1374
 		$this->user = $user;
1375 1375
 		return $result;
1376 1376
 	}
@@ -1408,14 +1408,14 @@  discard block
 block discarded – undo
1408 1408
 	{
1409 1409
 		global $conf;
1410 1410
 
1411
-		$result=false;
1411
+		$result = false;
1412 1412
 
1413 1413
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX.$table;
1414
-		$sql.= " WHERE ".$field." = '".$key."'";
1415
-		if (! empty($element)) {
1416
-			$sql.= " AND entity IN (".getEntity($element).")";
1414
+		$sql .= " WHERE ".$field." = '".$key."'";
1415
+		if (!empty($element)) {
1416
+			$sql .= " AND entity IN (".getEntity($element).")";
1417 1417
 		} else {
1418
-			$sql.= " AND entity = ".$conf->entity;
1418
+			$sql .= " AND entity = ".$conf->entity;
1419 1419
 		}
1420 1420
 
1421 1421
 		dol_syslog(get_class($this).'::fetchObjectFrom', LOG_DEBUG);
@@ -1442,10 +1442,10 @@  discard block
 block discarded – undo
1442 1442
 	 */
1443 1443
 	function getValueFrom($table, $id, $field)
1444 1444
 	{
1445
-		$result=false;
1445
+		$result = false;
1446 1446
 		if (!empty($id) && !empty($field) && !empty($table)) {
1447 1447
 			$sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
1448
-			$sql.= " WHERE rowid = ".$id;
1448
+			$sql .= " WHERE rowid = ".$id;
1449 1449
 
1450 1450
 			dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
1451 1451
 			$resql = $this->db->query($sql);
@@ -1474,36 +1474,36 @@  discard block
 block discarded – undo
1474 1474
 	 *	@return	int							<0 if KO, >0 if OK
1475 1475
 	 *  @see updateExtraField
1476 1476
 	 */
1477
-	function setValueFrom($field, $value, $table='', $id=null, $format='', $id_field='', $fuser=null, $trigkey='', $fk_user_field='fk_user_modif')
1477
+	function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif')
1478 1478
 	{
1479
-		global $user,$langs,$conf;
1479
+		global $user, $langs, $conf;
1480 1480
 
1481
-		if (empty($table)) 	  $table=$this->table_element;
1482
-		if (empty($id))    	  $id=$this->id;
1483
-		if (empty($format))   $format='text';
1484
-		if (empty($id_field)) $id_field='rowid';
1481
+		if (empty($table)) 	  $table = $this->table_element;
1482
+		if (empty($id))    	  $id = $this->id;
1483
+		if (empty($format))   $format = 'text';
1484
+		if (empty($id_field)) $id_field = 'rowid';
1485 1485
 
1486
-		$error=0;
1486
+		$error = 0;
1487 1487
 
1488 1488
 		$this->db->begin();
1489 1489
 
1490 1490
 		// Special case
1491
-		if ($table == 'product' && $field == 'note_private') $field='note';
1491
+		if ($table == 'product' && $field == 'note_private') $field = 'note';
1492 1492
 		if (in_array($table, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))) $fk_user_field = 'fk_user_mod';
1493 1493
 
1494 1494
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
1495 1495
 
1496
-		if ($format == 'text') $sql.= $field." = '".$this->db->escape($value)."'";
1497
-		else if ($format == 'int') $sql.= $field." = ".$this->db->escape($value);
1498
-		else if ($format == 'date') $sql.= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null");
1496
+		if ($format == 'text') $sql .= $field." = '".$this->db->escape($value)."'";
1497
+		else if ($format == 'int') $sql .= $field." = ".$this->db->escape($value);
1498
+		else if ($format == 'date') $sql .= $field." = ".($value ? "'".$this->db->idate($value)."'" : "null");
1499 1499
 
1500 1500
 		if ($fk_user_field)
1501 1501
 		{
1502
-			if (! empty($fuser) && is_object($fuser)) $sql.=", ".$fk_user_field." = ".$fuser->id;
1503
-			elseif (empty($fuser) || $fuser != 'none') $sql.=", ".$fk_user_field." = ".$user->id;
1502
+			if (!empty($fuser) && is_object($fuser)) $sql .= ", ".$fk_user_field." = ".$fuser->id;
1503
+			elseif (empty($fuser) || $fuser != 'none') $sql .= ", ".$fk_user_field." = ".$user->id;
1504 1504
 		}
1505 1505
 
1506
-		$sql.= " WHERE ".$id_field." = ".$id;
1506
+		$sql .= " WHERE ".$id_field." = ".$id;
1507 1507
 
1508 1508
 		dol_syslog(get_class($this)."::".__FUNCTION__."", LOG_DEBUG);
1509 1509
 		$resql = $this->db->query($sql);
@@ -1520,11 +1520,11 @@  discard block
 block discarded – undo
1520 1520
 				{
1521 1521
 					$result = $this->fetchCommon($id);
1522 1522
 				}
1523
-				if ($result >= 0) $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user);   // This may set this->errors
1523
+				if ($result >= 0) $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors
1524 1524
 				if ($result < 0) $error++;
1525 1525
 			}
1526 1526
 
1527
-			if (! $error)
1527
+			if (!$error)
1528 1528
 			{
1529 1529
 				if (property_exists($this, $field)) $this->$field = $value;
1530 1530
 				$this->db->commit();
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
 		}
1539 1539
 		else
1540 1540
 		{
1541
-			$this->error=$this->db->lasterror();
1541
+			$this->error = $this->db->lasterror();
1542 1542
 			$this->db->rollback();
1543 1543
 			return -1;
1544 1544
 		}
@@ -1553,14 +1553,14 @@  discard block
 block discarded – undo
1553 1553
 	 *		@param	int		$nodbprefix	Do not include DB prefix to forge table name
1554 1554
 	 *      @return int         		<0 if KO, >0 if OK
1555 1555
 	 */
1556
-	function load_previous_next_ref($filter, $fieldid, $nodbprefix=0)
1556
+	function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0)
1557 1557
 	{
1558 1558
         // phpcs:enable
1559 1559
 		global $conf, $user;
1560 1560
 
1561
-		if (! $this->table_element)
1561
+		if (!$this->table_element)
1562 1562
 		{
1563
-			dol_print_error('',get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
1563
+			dol_print_error('', get_class($this)."::load_previous_next_ref was called on objet with property table_element not defined");
1564 1564
 			return -1;
1565 1565
 		}
1566 1566
 		if ($fieldid == 'none') return 1;
@@ -1575,45 +1575,45 @@  discard block
 block discarded – undo
1575 1575
 		if ($this->element == 'societe') $alias = 'te';
1576 1576
 
1577 1577
 		$sql = "SELECT MAX(te.".$fieldid.")";
1578
-		$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
1579
-		if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1580
-			$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
1581
-		}
1582
-		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s";	// If we need to link to societe to limit select to entity
1583
-		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s";	// If we need to link to societe to limit select to socid
1584
-		else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid";	// If we need to link to societe to limit select to socid
1585
-		if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid)  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
1586
-		$sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'";  // ->ref must always be defined (set to id if field does not exists)
1587
-		if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id;
1588
-		if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)';
1589
-		if (! empty($filter))
1590
-		{
1591
-			if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND ";   // For backward compatibility
1592
-			$sql.=$filter;
1593
-		}
1594
-		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid';			// If we need to link to societe to limit select to entity
1595
-		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid';			// If we need to link to societe to limit select to socid
1578
+		$sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
1579
+		if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1580
+			$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
1581
+		}
1582
+		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
1583
+		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
1584
+		else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
1585
+		if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid)  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
1586
+		$sql .= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
1587
+		if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
1588
+		if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)';
1589
+		if (!empty($filter))
1590
+		{
1591
+			if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility
1592
+			$sql .= $filter;
1593
+		}
1594
+		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
1595
+		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
1596 1596
 		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
1597
-			if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1598
-				if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
1599
-					$sql.= " AND te.entity IS NOT NULL"; // Show all users
1597
+			if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1598
+				if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
1599
+					$sql .= " AND te.entity IS NOT NULL"; // Show all users
1600 1600
 				} else {
1601
-					$sql.= " AND ug.fk_user = te.rowid";
1602
-					$sql.= " AND ug.entity IN (".getEntity($this->element).")";
1601
+					$sql .= " AND ug.fk_user = te.rowid";
1602
+					$sql .= " AND ug.entity IN (".getEntity($this->element).")";
1603 1603
 				}
1604 1604
 			} else {
1605
-				$sql.= ' AND te.entity IN ('.getEntity($this->element).')';
1605
+				$sql .= ' AND te.entity IN ('.getEntity($this->element).')';
1606 1606
 			}
1607 1607
 		}
1608
-		if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid;
1609
-		if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)';
1610
-		if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid;
1608
+		if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid;
1609
+		if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
1610
+		if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid;
1611 1611
 		//print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
1612 1612
 
1613 1613
 		$result = $this->db->query($sql);
1614
-		if (! $result)
1614
+		if (!$result)
1615 1615
 		{
1616
-			$this->error=$this->db->lasterror();
1616
+			$this->error = $this->db->lasterror();
1617 1617
 			return -1;
1618 1618
 		}
1619 1619
 		$row = $this->db->fetch_row($result);
@@ -1621,46 +1621,46 @@  discard block
 block discarded – undo
1621 1621
 
1622 1622
 
1623 1623
 		$sql = "SELECT MIN(te.".$fieldid.")";
1624
-		$sql.= " FROM ".(empty($nodbprefix)?MAIN_DB_PREFIX:'').$this->table_element." as te";
1625
-		if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1626
-			$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
1627
-		}
1628
-		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ", ".MAIN_DB_PREFIX."societe as s";	// If we need to link to societe to limit select to entity
1629
-		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s";	// If we need to link to societe to limit select to socid
1630
-		else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid";	// If we need to link to societe to limit select to socid
1631
-		if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
1632
-		$sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'";  // ->ref must always be defined (set to id if field does not exists)
1633
-		if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND sc.fk_user = " .$user->id;
1634
-		if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql.= " AND (sc.fk_user = " .$user->id.' OR te.fk_soc IS NULL)';
1635
-		if (! empty($filter))
1636
-		{
1637
-			if (! preg_match('/^\s*AND/i', $filter)) $sql.=" AND ";   // For backward compatibility
1638
-			$sql.=$filter;
1639
-		}
1640
-		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid';			// If we need to link to societe to limit select to entity
1641
-		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql.= ' AND te.fk_soc = s.rowid';			// If we need to link to societe to limit select to socid
1624
+		$sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
1625
+		if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1626
+			$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
1627
+		}
1628
+		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
1629
+		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
1630
+		else if ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
1631
+		if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc";
1632
+		$sql .= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
1633
+		if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
1634
+		if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)';
1635
+		if (!empty($filter))
1636
+		{
1637
+			if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility
1638
+			$sql .= $filter;
1639
+		}
1640
+		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
1641
+		else if ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
1642 1642
 		if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
1643
-			if ($this->element == 'user' && ! empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1644
-				if (! empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
1645
-					$sql.= " AND te.entity IS NOT NULL"; // Show all users
1643
+			if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1644
+				if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
1645
+					$sql .= " AND te.entity IS NOT NULL"; // Show all users
1646 1646
 				} else {
1647
-					$sql.= " AND ug.fk_user = te.rowid";
1648
-					$sql.= " AND ug.entity IN (".getEntity($this->element).")";
1647
+					$sql .= " AND ug.fk_user = te.rowid";
1648
+					$sql .= " AND ug.entity IN (".getEntity($this->element).")";
1649 1649
 				}
1650 1650
 			} else {
1651
-				$sql.= ' AND te.entity IN ('.getEntity($this->element).')';
1651
+				$sql .= ' AND te.entity IN ('.getEntity($this->element).')';
1652 1652
 			}
1653 1653
 		}
1654
-		if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql.= ' AND te.fk_soc = ' . $socid;
1655
-		if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql.= ' AND (te.fk_soc = ' . $socid.' OR te.fk_soc IS NULL)';
1656
-		if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql.= ' AND te.rowid = ' . $socid;
1654
+		if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid;
1655
+		if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
1656
+		if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid;
1657 1657
 		//print 'socid='.$socid.' restrictiononfksoc='.$this->restrictiononfksoc.' ismultientitymanaged = '.$this->ismultientitymanaged.' filter = '.$filter.' -> '.$sql."<br>";
1658 1658
 		// Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null
1659 1659
 
1660 1660
 		$result = $this->db->query($sql);
1661
-		if (! $result)
1661
+		if (!$result)
1662 1662
 		{
1663
-			$this->error=$this->db->lasterror();
1663
+			$this->error = $this->db->lasterror();
1664 1664
 			return -2;
1665 1665
 		}
1666 1666
 		$row = $this->db->fetch_row($result);
@@ -1677,11 +1677,11 @@  discard block
 block discarded – undo
1677 1677
 	 *      @return array				Array of id of contacts (if source=external or internal)
1678 1678
 	 * 									Array of id of third parties with at least one contact on object (if source=thirdparty)
1679 1679
 	 */
1680
-	function getListContactId($source='external')
1680
+	function getListContactId($source = 'external')
1681 1681
 	{
1682 1682
 		$contactAlreadySelected = array();
1683
-		$tab = $this->liste_contact(-1,$source);
1684
-		$num=count($tab);
1683
+		$tab = $this->liste_contact(-1, $source);
1684
+		$num = count($tab);
1685 1685
 		$i = 0;
1686 1686
 		while ($i < $num)
1687 1687
 		{
@@ -1701,24 +1701,24 @@  discard block
 block discarded – undo
1701 1701
 	 */
1702 1702
 	function setProject($projectid)
1703 1703
 	{
1704
-		if (! $this->table_element)
1704
+		if (!$this->table_element)
1705 1705
 		{
1706
-			dol_syslog(get_class($this)."::setProject was called on objet with property table_element not defined",LOG_ERR);
1706
+			dol_syslog(get_class($this)."::setProject was called on objet with property table_element not defined", LOG_ERR);
1707 1707
 			return -1;
1708 1708
 		}
1709 1709
 
1710 1710
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
1711 1711
 		if ($this->table_element == 'actioncomm')
1712 1712
 		{
1713
-			if ($projectid) $sql.= ' SET fk_project = '.$projectid;
1714
-			else $sql.= ' SET fk_project = NULL';
1715
-			$sql.= ' WHERE id = '.$this->id;
1713
+			if ($projectid) $sql .= ' SET fk_project = '.$projectid;
1714
+			else $sql .= ' SET fk_project = NULL';
1715
+			$sql .= ' WHERE id = '.$this->id;
1716 1716
 		}
1717 1717
 		else
1718 1718
 		{
1719
-			if ($projectid) $sql.= ' SET fk_projet = '.$projectid;
1720
-			else $sql.= ' SET fk_projet = NULL';
1721
-			$sql.= ' WHERE rowid = '.$this->id;
1719
+			if ($projectid) $sql .= ' SET fk_projet = '.$projectid;
1720
+			else $sql .= ' SET fk_projet = NULL';
1721
+			$sql .= ' WHERE rowid = '.$this->id;
1722 1722
 		}
1723 1723
 
1724 1724
 		dol_syslog(get_class($this)."::setProject", LOG_DEBUG);
@@ -1764,14 +1764,14 @@  discard block
 block discarded – undo
1764 1764
 			else
1765 1765
 			{
1766 1766
 				dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
1767
-				$this->error=$this->db->error();
1767
+				$this->error = $this->db->error();
1768 1768
 				return -1;
1769 1769
 			}
1770 1770
 		}
1771 1771
 		else
1772 1772
 		{
1773 1773
 			dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
1774
-			$this->error='Status of the object is incompatible '.$this->statut;
1774
+			$this->error = 'Status of the object is incompatible '.$this->statut;
1775 1775
 			return -2;
1776 1776
 		}
1777 1777
 	}
@@ -1798,21 +1798,21 @@  discard block
 block discarded – undo
1798 1798
 				$this->multicurrency_code = $code;
1799 1799
 
1800 1800
 				list($fk_multicurrency, $rate) = MultiCurrency::getIdAndTxFromCode($this->db, $code);
1801
-				if ($rate) $this->setMulticurrencyRate($rate,2);
1801
+				if ($rate) $this->setMulticurrencyRate($rate, 2);
1802 1802
 
1803 1803
 				return 1;
1804 1804
 			}
1805 1805
 			else
1806 1806
 			{
1807 1807
 				dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error());
1808
-				$this->error=$this->db->error();
1808
+				$this->error = $this->db->error();
1809 1809
 				return -1;
1810 1810
 			}
1811 1811
 		}
1812 1812
 		else
1813 1813
 		{
1814 1814
 			dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible');
1815
-			$this->error='Status of the object is incompatible '.$this->statut;
1815
+			$this->error = 'Status of the object is incompatible '.$this->statut;
1816 1816
 			return -2;
1817 1817
 		}
1818 1818
 	}
@@ -1824,7 +1824,7 @@  discard block
 block discarded – undo
1824 1824
 	 *  @param		int		$mode	mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency
1825 1825
 	 *  @return		int				>0 if OK, <0 if KO
1826 1826
 	 */
1827
-	function setMulticurrencyRate($rate, $mode=1)
1827
+	function setMulticurrencyRate($rate, $mode = 1)
1828 1828
 	{
1829 1829
 		dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')');
1830 1830
 		if ($this->statut >= 0 || $this->element == 'societe')
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
 				{
1845 1845
 					foreach ($this->lines as &$line)
1846 1846
 					{
1847
-						if($mode == 1) {
1847
+						if ($mode == 1) {
1848 1848
 							$line->subprice = 0;
1849 1849
 						}
1850 1850
 
@@ -1852,14 +1852,14 @@  discard block
 block discarded – undo
1852 1852
 							case 'propal':
1853 1853
 								$this->updateline(
1854 1854
 									$line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
1855
-									($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line,
1855
+									($line->description ? $line->description : $line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line,
1856 1856
 									$line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start,
1857 1857
 									$line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice
1858 1858
 								);
1859 1859
 								break;
1860 1860
 							case 'commande':
1861 1861
 								$this->updateline(
1862
-									$line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent,
1862
+									$line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent,
1863 1863
 									$line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->date_start, $line->date_end,
1864 1864
 									$line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label,
1865 1865
 									$line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice
@@ -1867,7 +1867,7 @@  discard block
 block discarded – undo
1867 1867
 								break;
1868 1868
 							case 'facture':
1869 1869
 								$this->updateline(
1870
-									$line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent,
1870
+									$line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent,
1871 1871
 									$line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits,
1872 1872
 									$line->product_type, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label,
1873 1873
 									$line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice
@@ -1876,21 +1876,21 @@  discard block
 block discarded – undo
1876 1876
 							case 'supplier_proposal':
1877 1877
 								$this->updateline(
1878 1878
 									$line->id, $line->subprice, $line->qty, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx,
1879
-									($line->description?$line->description:$line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line,
1879
+									($line->description ? $line->description : $line->desc), 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line,
1880 1880
 									$line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->array_options,
1881 1881
 									$line->ref_fourn, $line->multicurrency_subprice
1882 1882
 								);
1883 1883
 								break;
1884 1884
 							case 'order_supplier':
1885 1885
 								$this->updateline(
1886
-									$line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->qty, $line->remise_percent,
1886
+									$line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->qty, $line->remise_percent,
1887 1887
 									$line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, false,
1888 1888
 									$line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice
1889 1889
 								);
1890 1890
 								break;
1891 1891
 							case 'invoice_supplier':
1892 1892
 								$this->updateline(
1893
-									$line->id, ($line->description?$line->description:$line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx,
1893
+									$line->id, ($line->description ? $line->description : $line->desc), $line->subprice, $line->tva_tx, $line->localtax1_tx,
1894 1894
 									$line->localtax2_tx, $line->qty, 0, 'HT', $line->info_bits, $line->product_type, $line->remise_percent, false,
1895 1895
 									$line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice
1896 1896
 								);
@@ -1907,14 +1907,14 @@  discard block
 block discarded – undo
1907 1907
 			else
1908 1908
 			{
1909 1909
 				dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error());
1910
-				$this->error=$this->db->error();
1910
+				$this->error = $this->db->error();
1911 1911
 				return -1;
1912 1912
 			}
1913 1913
 		}
1914 1914
 		else
1915 1915
 		{
1916 1916
 			dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible');
1917
-			$this->error='Status of the object is incompatible '.$this->statut;
1917
+			$this->error = 'Status of the object is incompatible '.$this->statut;
1918 1918
 			return -2;
1919 1919
 		}
1920 1920
 	}
@@ -1944,20 +1944,20 @@  discard block
 block discarded – undo
1944 1944
 				$this->cond_reglement_id = $id;
1945 1945
 				// for supplier
1946 1946
 				if (get_class($this) == 'Fournisseur') $this->cond_reglement_supplier_id = $id;
1947
-				$this->cond_reglement = $id;	// for compatibility
1947
+				$this->cond_reglement = $id; // for compatibility
1948 1948
 				return 1;
1949 1949
 			}
1950 1950
 			else
1951 1951
 			{
1952 1952
 				dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
1953
-				$this->error=$this->db->error();
1953
+				$this->error = $this->db->error();
1954 1954
 				return -1;
1955 1955
 			}
1956 1956
 		}
1957 1957
 		else
1958 1958
 		{
1959 1959
 			dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
1960
-			$this->error='Status of the object is incompatible '.$this->statut;
1960
+			$this->error = 'Status of the object is incompatible '.$this->statut;
1961 1961
 			return -2;
1962 1962
 		}
1963 1963
 	}
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
 		if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address';
1976 1976
 
1977 1977
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET ".$fieldname." = ".$id;
1978
-		$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
1978
+		$sql .= " WHERE rowid = ".$this->id." AND fk_statut = 0";
1979 1979
 
1980 1980
 		if ($this->db->query($sql))
1981 1981
 		{
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
 		}
1985 1985
 		else
1986 1986
 		{
1987
-			$this->error=$this->db->error();
1987
+			$this->error = $this->db->error();
1988 1988
 			dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error);
1989 1989
 			return -1;
1990 1990
 		}
@@ -2000,29 +2000,29 @@  discard block
 block discarded – undo
2000 2000
 	 *
2001 2001
 	 *  @return     int              1 if OK, 0 if KO
2002 2002
 	 */
2003
-	function setShippingMethod($shipping_method_id, $notrigger=false, $userused=null)
2003
+	function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null)
2004 2004
 	{
2005 2005
         global $user;
2006 2006
 
2007
-        if (empty($userused)) $userused=$user;
2007
+        if (empty($userused)) $userused = $user;
2008 2008
 
2009 2009
         $error = 0;
2010 2010
 
2011
-		if (! $this->table_element) {
2012
-			dol_syslog(get_class($this)."::setShippingMethod was called on objet with property table_element not defined",LOG_ERR);
2011
+		if (!$this->table_element) {
2012
+			dol_syslog(get_class($this)."::setShippingMethod was called on objet with property table_element not defined", LOG_ERR);
2013 2013
 			return -1;
2014 2014
 		}
2015 2015
 
2016 2016
         $this->db->begin();
2017 2017
 
2018
-		if ($shipping_method_id<0) $shipping_method_id='NULL';
2018
+		if ($shipping_method_id < 0) $shipping_method_id = 'NULL';
2019 2019
 		dol_syslog(get_class($this).'::setShippingMethod('.$shipping_method_id.')');
2020 2020
 
2021 2021
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
2022
-		$sql.= " SET fk_shipping_method = ".$shipping_method_id;
2023
-		$sql.= " WHERE rowid=".$this->id;
2022
+		$sql .= " SET fk_shipping_method = ".$shipping_method_id;
2023
+		$sql .= " WHERE rowid=".$this->id;
2024 2024
         $resql = $this->db->query($sql);
2025
-		if (! $resql) {
2025
+		if (!$resql) {
2026 2026
 			dol_syslog(get_class($this).'::setShippingMethod Error ', LOG_DEBUG);
2027 2027
 			$this->error = $this->db->lasterror();
2028 2028
 			$error++;
@@ -2030,8 +2030,8 @@  discard block
 block discarded – undo
2030 2030
             if (!$notrigger)
2031 2031
             {
2032 2032
                 // Call trigger
2033
-                $this->context=array('shippingmethodupdate'=>1);
2034
-                $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused);
2033
+                $this->context = array('shippingmethodupdate'=>1);
2034
+                $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $userused);
2035 2035
                 if ($result < 0) $error++;
2036 2036
                 // End call trigger
2037 2037
             }
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
             $this->db->rollback();
2042 2042
             return -1;
2043 2043
         } else {
2044
-            $this->shipping_method_id = ($shipping_method_id=='NULL')?null:$shipping_method_id;
2044
+            $this->shipping_method_id = ($shipping_method_id == 'NULL') ?null:$shipping_method_id;
2045 2045
             $this->db->commit();
2046 2046
             return 1;
2047 2047
         }
@@ -2056,23 +2056,23 @@  discard block
 block discarded – undo
2056 2056
 	 */
2057 2057
 	function setWarehouse($warehouse_id)
2058 2058
 	{
2059
-		if (! $this->table_element) {
2060
-			dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined",LOG_ERR);
2059
+		if (!$this->table_element) {
2060
+			dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR);
2061 2061
 			return -1;
2062 2062
 		}
2063
-		if ($warehouse_id<0) $warehouse_id='NULL';
2063
+		if ($warehouse_id < 0) $warehouse_id = 'NULL';
2064 2064
 		dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')');
2065 2065
 
2066 2066
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
2067
-		$sql.= " SET fk_warehouse = ".$warehouse_id;
2068
-		$sql.= " WHERE rowid=".$this->id;
2067
+		$sql .= " SET fk_warehouse = ".$warehouse_id;
2068
+		$sql .= " WHERE rowid=".$this->id;
2069 2069
 
2070 2070
 		if ($this->db->query($sql)) {
2071
-			$this->warehouse_id = ($warehouse_id=='NULL')?null:$warehouse_id;
2071
+			$this->warehouse_id = ($warehouse_id == 'NULL') ?null:$warehouse_id;
2072 2072
 			return 1;
2073 2073
 		} else {
2074 2074
 			dol_syslog(get_class($this).'::setWarehouse Error ', LOG_DEBUG);
2075
-			$this->error=$this->db->error();
2075
+			$this->error = $this->db->error();
2076 2076
 			return 0;
2077 2077
 		}
2078 2078
 	}
@@ -2087,25 +2087,25 @@  discard block
 block discarded – undo
2087 2087
 	 */
2088 2088
 	function setDocModel($user, $modelpdf)
2089 2089
 	{
2090
-		if (! $this->table_element)
2090
+		if (!$this->table_element)
2091 2091
 		{
2092
-			dol_syslog(get_class($this)."::setDocModel was called on objet with property table_element not defined",LOG_ERR);
2092
+			dol_syslog(get_class($this)."::setDocModel was called on objet with property table_element not defined", LOG_ERR);
2093 2093
 			return -1;
2094 2094
 		}
2095 2095
 
2096
-		$newmodelpdf=dol_trunc($modelpdf,255);
2096
+		$newmodelpdf = dol_trunc($modelpdf, 255);
2097 2097
 
2098 2098
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
2099
-		$sql.= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'";
2100
-		$sql.= " WHERE rowid = ".$this->id;
2099
+		$sql .= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'";
2100
+		$sql .= " WHERE rowid = ".$this->id;
2101 2101
 		// if ($this->element == 'facture') $sql.= " AND fk_statut < 2";
2102 2102
 		// if ($this->element == 'propal')  $sql.= " AND fk_statut = 0";
2103 2103
 
2104 2104
 		dol_syslog(get_class($this)."::setDocModel", LOG_DEBUG);
2105
-		$resql=$this->db->query($sql);
2105
+		$resql = $this->db->query($sql);
2106 2106
 		if ($resql)
2107 2107
 		{
2108
-			$this->modelpdf=$modelpdf;
2108
+			$this->modelpdf = $modelpdf;
2109 2109
 			return 1;
2110 2110
 		}
2111 2111
 		else
@@ -2124,29 +2124,29 @@  discard block
 block discarded – undo
2124 2124
 	 *  @param      User	$userused		Object user
2125 2125
 	 *  @return		int				1 if OK, 0 if KO
2126 2126
 	 */
2127
-	function setBankAccount($fk_account, $notrigger=false, $userused=null)
2127
+	function setBankAccount($fk_account, $notrigger = false, $userused = null)
2128 2128
 	{
2129 2129
         global $user;
2130 2130
 
2131
-        if (empty($userused)) $userused=$user;
2131
+        if (empty($userused)) $userused = $user;
2132 2132
 
2133 2133
         $error = 0;
2134 2134
 
2135
-		if (! $this->table_element) {
2136
-			dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined",LOG_ERR);
2135
+		if (!$this->table_element) {
2136
+			dol_syslog(get_class($this)."::setBankAccount was called on objet with property table_element not defined", LOG_ERR);
2137 2137
 			return -1;
2138 2138
 		}
2139 2139
         $this->db->begin();
2140 2140
 
2141
-		if ($fk_account<0) $fk_account='NULL';
2141
+		if ($fk_account < 0) $fk_account = 'NULL';
2142 2142
 		dol_syslog(get_class($this).'::setBankAccount('.$fk_account.')');
2143 2143
 
2144 2144
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
2145
-		$sql.= " SET fk_account = ".$fk_account;
2146
-		$sql.= " WHERE rowid=".$this->id;
2145
+		$sql .= " SET fk_account = ".$fk_account;
2146
+		$sql .= " WHERE rowid=".$this->id;
2147 2147
 
2148 2148
         $resql = $this->db->query($sql);
2149
-        if (! $resql)
2149
+        if (!$resql)
2150 2150
         {
2151 2151
             dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error());
2152 2152
             $this->error = $this->db->lasterror();
@@ -2157,8 +2157,8 @@  discard block
 block discarded – undo
2157 2157
             if (!$notrigger)
2158 2158
             {
2159 2159
                 // Call trigger
2160
-                $this->context=array('bankaccountupdate'=>1);
2161
-                $result = $this->call_trigger(strtoupper(get_class($this)) . '_MODIFY', $userused);
2160
+                $this->context = array('bankaccountupdate'=>1);
2161
+                $result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $userused);
2162 2162
                 if ($result < 0) $error++;
2163 2163
                 // End call trigger
2164 2164
             }
@@ -2170,7 +2170,7 @@  discard block
 block discarded – undo
2170 2170
         }
2171 2171
         else
2172 2172
         {
2173
-            $this->fk_account = ($fk_account=='NULL')?null:$fk_account;
2173
+            $this->fk_account = ($fk_account == 'NULL') ?null:$fk_account;
2174 2174
             $this->db->commit();
2175 2175
             return 1;
2176 2176
         }
@@ -2189,26 +2189,26 @@  discard block
 block discarded – undo
2189 2189
 	 * 	@param		boolean		$fk_parent_line    Table with fk_parent_line field or not
2190 2190
 	 * 	@return		int                            <0 if KO, >0 if OK
2191 2191
 	 */
2192
-	function line_order($renum=false, $rowidorder='ASC', $fk_parent_line=true)
2192
+	function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true)
2193 2193
 	{
2194 2194
         // phpcs:enable
2195
-		if (! $this->table_element_line)
2195
+		if (!$this->table_element_line)
2196 2196
 		{
2197
-			dol_syslog(get_class($this)."::line_order was called on objet with property table_element_line not defined",LOG_ERR);
2197
+			dol_syslog(get_class($this)."::line_order was called on objet with property table_element_line not defined", LOG_ERR);
2198 2198
 			return -1;
2199 2199
 		}
2200
-		if (! $this->fk_element)
2200
+		if (!$this->fk_element)
2201 2201
 		{
2202
-			dol_syslog(get_class($this)."::line_order was called on objet with property fk_element not defined",LOG_ERR);
2202
+			dol_syslog(get_class($this)."::line_order was called on objet with property fk_element not defined", LOG_ERR);
2203 2203
 			return -1;
2204 2204
 		}
2205 2205
 
2206 2206
 		// Count number of lines to reorder (according to choice $renum)
2207
-		$nl=0;
2207
+		$nl = 0;
2208 2208
 		$sql = 'SELECT count(rowid) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2209
-		$sql.= ' WHERE '.$this->fk_element.'='.$this->id;
2210
-		if (! $renum) $sql.= ' AND rang = 0';
2211
-		if ($renum) $sql.= ' AND rang <> 0';
2209
+		$sql .= ' WHERE '.$this->fk_element.'='.$this->id;
2210
+		if (!$renum) $sql .= ' AND rang = 0';
2211
+		if ($renum) $sql .= ' AND rang <> 0';
2212 2212
 
2213 2213
 		dol_syslog(get_class($this)."::line_order", LOG_DEBUG);
2214 2214
 		$resql = $this->db->query($sql);
@@ -2222,28 +2222,28 @@  discard block
 block discarded – undo
2222 2222
 		{
2223 2223
 			// The goal of this part is to reorder all lines, with all children lines sharing the same
2224 2224
 			// counter that parents.
2225
-			$rows=array();
2225
+			$rows = array();
2226 2226
 
2227 2227
 			// We first search all lines that are parent lines (for multilevel details lines)
2228 2228
 			$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2229
-			$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2230
-			if ($fk_parent_line) $sql.= ' AND fk_parent_line IS NULL';
2231
-			$sql.= ' ORDER BY rang ASC, rowid '.$rowidorder;
2229
+			$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2230
+			if ($fk_parent_line) $sql .= ' AND fk_parent_line IS NULL';
2231
+			$sql .= ' ORDER BY rang ASC, rowid '.$rowidorder;
2232 2232
 
2233 2233
 			dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG);
2234 2234
 			$resql = $this->db->query($sql);
2235 2235
 			if ($resql)
2236 2236
 			{
2237
-				$i=0;
2237
+				$i = 0;
2238 2238
 				$num = $this->db->num_rows($resql);
2239 2239
 				while ($i < $num)
2240 2240
 				{
2241 2241
 					$row = $this->db->fetch_row($resql);
2242
-					$rows[] = $row[0];	// Add parent line into array rows
2242
+					$rows[] = $row[0]; // Add parent line into array rows
2243 2243
 					$childrens = $this->getChildrenOfLine($row[0]);
2244
-					if (! empty($childrens))
2244
+					if (!empty($childrens))
2245 2245
 					{
2246
-						foreach($childrens as $child)
2246
+						foreach ($childrens as $child)
2247 2247
 						{
2248 2248
 							array_push($rows, $child);
2249 2249
 						}
@@ -2252,11 +2252,11 @@  discard block
 block discarded – undo
2252 2252
 				}
2253 2253
 
2254 2254
 				// Now we set a new number for each lines (parent and children with children included into parent tree)
2255
-				if (! empty($rows))
2255
+				if (!empty($rows))
2256 2256
 				{
2257
-					foreach($rows as $key => $row)
2257
+					foreach ($rows as $key => $row)
2258 2258
 					{
2259
-						$this->updateRangOfLine($row, ($key+1));
2259
+						$this->updateRangOfLine($row, ($key + 1));
2260 2260
 					}
2261 2261
 				}
2262 2262
 			}
@@ -2276,18 +2276,18 @@  discard block
 block discarded – undo
2276 2276
 	 */
2277 2277
 	function getChildrenOfLine($id)
2278 2278
 	{
2279
-		$rows=array();
2279
+		$rows = array();
2280 2280
 
2281 2281
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2282
-		$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2283
-		$sql.= ' AND fk_parent_line = '.$id;
2284
-		$sql.= ' ORDER BY rang ASC';
2282
+		$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2283
+		$sql .= ' AND fk_parent_line = '.$id;
2284
+		$sql .= ' ORDER BY rang ASC';
2285 2285
 
2286 2286
 		dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id."", LOG_DEBUG);
2287 2287
 		$resql = $this->db->query($sql);
2288 2288
 		if ($resql)
2289 2289
 		{
2290
-			$i=0;
2290
+			$i = 0;
2291 2291
 			$num = $this->db->num_rows($resql);
2292 2292
 			while ($i < $num)
2293 2293
 			{
@@ -2308,7 +2308,7 @@  discard block
 block discarded – undo
2308 2308
 	 * 	@param	boolean		$fk_parent_line		Table with fk_parent_line field or not
2309 2309
 	 * 	@return	void
2310 2310
 	 */
2311
-	function line_up($rowid, $fk_parent_line=true)
2311
+	function line_up($rowid, $fk_parent_line = true)
2312 2312
 	{
2313 2313
         // phpcs:enable
2314 2314
 		$this->line_order(false, 'ASC', $fk_parent_line);
@@ -2328,7 +2328,7 @@  discard block
 block discarded – undo
2328 2328
 	 * 	@param	boolean		$fk_parent_line		Table with fk_parent_line field or not
2329 2329
 	 * 	@return	void
2330 2330
 	 */
2331
-	function line_down($rowid, $fk_parent_line=true)
2331
+	function line_down($rowid, $fk_parent_line = true)
2332 2332
 	{
2333 2333
         // phpcs:enable
2334 2334
 		$this->line_order(false, 'ASC', $fk_parent_line);
@@ -2350,16 +2350,16 @@  discard block
 block discarded – undo
2350 2350
 	 * 	@param	int		$rang		Position
2351 2351
 	 * 	@return	void
2352 2352
 	 */
2353
-	function updateRangOfLine($rowid,$rang)
2353
+	function updateRangOfLine($rowid, $rang)
2354 2354
 	{
2355 2355
 		$fieldposition = 'rang';
2356 2356
 		if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
2357 2357
 
2358 2358
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
2359
-		$sql.= ' WHERE rowid = '.$rowid;
2359
+		$sql .= ' WHERE rowid = '.$rowid;
2360 2360
 
2361 2361
 		dol_syslog(get_class($this)."::updateRangOfLine", LOG_DEBUG);
2362
-		if (! $this->db->query($sql))
2362
+		if (!$this->db->query($sql))
2363 2363
 		{
2364 2364
 			dol_print_error($this->db);
2365 2365
 		}
@@ -2376,9 +2376,9 @@  discard block
 block discarded – undo
2376 2376
 	{
2377 2377
         // phpcs:enable
2378 2378
 		$num = count($rows);
2379
-		for ($i = 0 ; $i < $num ; $i++)
2379
+		for ($i = 0; $i < $num; $i++)
2380 2380
 		{
2381
-			$this->updateRangOfLine($rows[$i], ($i+1));
2381
+			$this->updateRangOfLine($rows[$i], ($i + 1));
2382 2382
 		}
2383 2383
 	}
2384 2384
 
@@ -2389,21 +2389,21 @@  discard block
 block discarded – undo
2389 2389
 	 * 	@param	int		$rang		Position
2390 2390
 	 * 	@return	void
2391 2391
 	 */
2392
-	function updateLineUp($rowid,$rang)
2392
+	function updateLineUp($rowid, $rang)
2393 2393
 	{
2394 2394
 		if ($rang > 1)
2395 2395
 		{
2396 2396
 			$fieldposition = 'rang';
2397 2397
 			if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
2398 2398
 
2399
-			$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang ;
2400
-			$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2401
-			$sql.= ' AND rang = '.($rang - 1);
2402
-			if ($this->db->query($sql) )
2399
+			$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
2400
+			$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2401
+			$sql .= ' AND rang = '.($rang - 1);
2402
+			if ($this->db->query($sql))
2403 2403
 			{
2404 2404
 				$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang - 1);
2405
-				$sql.= ' WHERE rowid = '.$rowid;
2406
-				if (! $this->db->query($sql) )
2405
+				$sql .= ' WHERE rowid = '.$rowid;
2406
+				if (!$this->db->query($sql))
2407 2407
 				{
2408 2408
 					dol_print_error($this->db);
2409 2409
 				}
@@ -2423,7 +2423,7 @@  discard block
 block discarded – undo
2423 2423
 	 * 	@param	int		$max		Max
2424 2424
 	 * 	@return	void
2425 2425
 	 */
2426
-	function updateLineDown($rowid,$rang,$max)
2426
+	function updateLineDown($rowid, $rang, $max)
2427 2427
 	{
2428 2428
 		if ($rang < $max)
2429 2429
 		{
@@ -2431,13 +2431,13 @@  discard block
 block discarded – undo
2431 2431
 			if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position';
2432 2432
 
2433 2433
 			$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.$rang;
2434
-			$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2435
-			$sql.= ' AND rang = '.($rang+1);
2436
-			if ($this->db->query($sql) )
2434
+			$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2435
+			$sql .= ' AND rang = '.($rang + 1);
2436
+			if ($this->db->query($sql))
2437 2437
 			{
2438
-				$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang+1);
2439
-				$sql.= ' WHERE rowid = '.$rowid;
2440
-				if (! $this->db->query($sql) )
2438
+				$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element_line.' SET '.$fieldposition.' = '.($rang + 1);
2439
+				$sql .= ' WHERE rowid = '.$rowid;
2440
+				if (!$this->db->query($sql))
2441 2441
 				{
2442 2442
 					dol_print_error($this->db);
2443 2443
 				}
@@ -2458,7 +2458,7 @@  discard block
 block discarded – undo
2458 2458
 	function getRangOfLine($rowid)
2459 2459
 	{
2460 2460
 		$sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2461
-		$sql.= ' WHERE rowid ='.$rowid;
2461
+		$sql .= ' WHERE rowid ='.$rowid;
2462 2462
 
2463 2463
 		dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG);
2464 2464
 		$resql = $this->db->query($sql);
@@ -2478,8 +2478,8 @@  discard block
 block discarded – undo
2478 2478
 	function getIdOfLine($rang)
2479 2479
 	{
2480 2480
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2481
-		$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2482
-		$sql.= ' AND rang = '.$rang;
2481
+		$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2482
+		$sql .= ' AND rang = '.$rang;
2483 2483
 		$resql = $this->db->query($sql);
2484 2484
 		if ($resql)
2485 2485
 		{
@@ -2495,22 +2495,22 @@  discard block
 block discarded – undo
2495 2495
 	 * 	@param		int		$fk_parent_line		Parent line id
2496 2496
 	 *  @return     int  			   			Max value of rang in table of lines
2497 2497
 	 */
2498
-	function line_max($fk_parent_line=0)
2498
+	function line_max($fk_parent_line = 0)
2499 2499
 	{
2500 2500
         // phpcs:enable
2501 2501
 		// Search the last rang with fk_parent_line
2502 2502
 		if ($fk_parent_line)
2503 2503
 		{
2504 2504
 			$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2505
-			$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2506
-			$sql.= ' AND fk_parent_line = '.$fk_parent_line;
2505
+			$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2506
+			$sql .= ' AND fk_parent_line = '.$fk_parent_line;
2507 2507
 
2508 2508
 			dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
2509 2509
 			$resql = $this->db->query($sql);
2510 2510
 			if ($resql)
2511 2511
 			{
2512 2512
 				$row = $this->db->fetch_row($resql);
2513
-				if (! empty($row[0]))
2513
+				if (!empty($row[0]))
2514 2514
 				{
2515 2515
 					return $row[0];
2516 2516
 				}
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
 		else
2525 2525
 		{
2526 2526
 			$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2527
-			$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2527
+			$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2528 2528
 
2529 2529
 			dol_syslog(get_class($this)."::line_max", LOG_DEBUG);
2530 2530
 			$resql = $this->db->query($sql);
@@ -2546,15 +2546,15 @@  discard block
 block discarded – undo
2546 2546
 	function update_ref_ext($ref_ext)
2547 2547
 	{
2548 2548
         // phpcs:enable
2549
-		if (! $this->table_element)
2549
+		if (!$this->table_element)
2550 2550
 		{
2551 2551
 			dol_syslog(get_class($this)."::update_ref_ext was called on objet with property table_element not defined", LOG_ERR);
2552 2552
 			return -1;
2553 2553
 		}
2554 2554
 
2555 2555
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
2556
-		$sql.= " SET ref_ext = '".$this->db->escape($ref_ext)."'";
2557
-		$sql.= " WHERE ".(isset($this->table_rowid)?$this->table_rowid:'rowid')." = ". $this->id;
2556
+		$sql .= " SET ref_ext = '".$this->db->escape($ref_ext)."'";
2557
+		$sql .= " WHERE ".(isset($this->table_rowid) ? $this->table_rowid : 'rowid')." = ".$this->id;
2558 2558
 
2559 2559
 		dol_syslog(get_class($this)."::update_ref_ext", LOG_DEBUG);
2560 2560
 		if ($this->db->query($sql))
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
 		}
2565 2565
 		else
2566 2566
 		{
2567
-			$this->error=$this->db->error();
2567
+			$this->error = $this->db->error();
2568 2568
 			return -1;
2569 2569
 		}
2570 2570
 	}
@@ -2577,31 +2577,31 @@  discard block
 block discarded – undo
2577 2577
 	 *  @param		string		$suffix		'', '_public' or '_private'
2578 2578
 	 *  @return     int      		   		<0 if KO, >0 if OK
2579 2579
 	 */
2580
-	function update_note($note, $suffix='')
2580
+	function update_note($note, $suffix = '')
2581 2581
 	{
2582 2582
         // phpcs:enable
2583 2583
 		global $user;
2584 2584
 
2585
-		if (! $this->table_element)
2585
+		if (!$this->table_element)
2586 2586
 		{
2587
-			$this->error='update_note was called on objet with property table_element not defined';
2587
+			$this->error = 'update_note was called on objet with property table_element not defined';
2588 2588
 			dol_syslog(get_class($this)."::update_note was called on objet with property table_element not defined", LOG_ERR);
2589 2589
 			return -1;
2590 2590
 		}
2591
-		if (! in_array($suffix,array('','_public','_private')))
2591
+		if (!in_array($suffix, array('', '_public', '_private')))
2592 2592
 		{
2593
-			$this->error='update_note Parameter suffix must be empty, \'_private\' or \'_public\'';
2593
+			$this->error = 'update_note Parameter suffix must be empty, \'_private\' or \'_public\'';
2594 2594
 			dol_syslog(get_class($this)."::update_note Parameter suffix must be empty, '_private' or '_public'", LOG_ERR);
2595 2595
 			return -2;
2596 2596
 		}
2597 2597
 		// Special cas
2598 2598
 		//var_dump($this->table_element);exit;
2599
-		if ($this->table_element == 'product') $suffix='';
2599
+		if ($this->table_element == 'product') $suffix = '';
2600 2600
 
2601 2601
 		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
2602
-		$sql.= " SET note".$suffix." = ".(!empty($note)?("'".$this->db->escape($note)."'"):"NULL");
2603
-		$sql.= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment'))?"fk_user_mod":"fk_user_modif")." = ".$user->id;
2604
-		$sql.= " WHERE rowid =". $this->id;
2602
+		$sql .= " SET note".$suffix." = ".(!empty($note) ? ("'".$this->db->escape($note)."'") : "NULL");
2603
+		$sql .= " ,".(in_array($this->table_element, array('actioncomm', 'adherent', 'advtargetemailing', 'cronjob', 'establishment')) ? "fk_user_mod" : "fk_user_modif")." = ".$user->id;
2604
+		$sql .= " WHERE rowid =".$this->id;
2605 2605
 
2606 2606
 		dol_syslog(get_class($this)."::update_note", LOG_DEBUG);
2607 2607
 		if ($this->db->query($sql))
@@ -2610,14 +2610,14 @@  discard block
 block discarded – undo
2610 2610
 			else if ($suffix == '_private') $this->note_private = $note;
2611 2611
 			else
2612 2612
 			{
2613
-				$this->note = $note;      // deprecated
2613
+				$this->note = $note; // deprecated
2614 2614
 				$this->note_private = $note;
2615 2615
 			}
2616 2616
 			return 1;
2617 2617
 		}
2618 2618
 		else
2619 2619
 		{
2620
-			$this->error=$this->db->lasterror();
2620
+			$this->error = $this->db->lasterror();
2621 2621
 			return -1;
2622 2622
 		}
2623 2623
 	}
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
 	function update_note_public($note)
2635 2635
 	{
2636 2636
         // phpcs:enable
2637
-		return $this->update_note($note,'_public');
2637
+		return $this->update_note($note, '_public');
2638 2638
 	}
2639 2639
 
2640 2640
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -2648,7 +2648,7 @@  discard block
 block discarded – undo
2648 2648
 	 *  @param	Societe	$seller				If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object.
2649 2649
 	 *	@return	int    			           	<0 if KO, >0 if OK
2650 2650
 	 */
2651
-	function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller=null)
2651
+	function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null)
2652 2652
 	{
2653 2653
         // phpcs:enable
2654 2654
 		global $conf, $hookmanager, $action;
@@ -2668,8 +2668,8 @@  discard block
 block discarded – undo
2668 2668
 		elseif ($this->element == 'supplier_proposal')
2669 2669
 			$MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_PROPOSAL";
2670 2670
 
2671
-		if (! empty($MODULE)) {
2672
-			if (! empty($conf->global->$MODULE)) {
2671
+		if (!empty($MODULE)) {
2672
+			if (!empty($conf->global->$MODULE)) {
2673 2673
 				$modsactivated = explode(',', $conf->global->$MODULE);
2674 2674
 				foreach ($modsactivated as $mod) {
2675 2675
 					if ($conf->$mod->enabled)
@@ -2680,44 +2680,44 @@  discard block
 block discarded – undo
2680 2680
 
2681 2681
 		include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
2682 2682
 
2683
-		if ($roundingadjust == '-1') $roundingadjust='auto';	// For backward compatibility
2683
+		if ($roundingadjust == '-1') $roundingadjust = 'auto'; // For backward compatibility
2684 2684
 
2685
-		$forcedroundingmode=$roundingadjust;
2686
-		if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
2687
-		elseif ($forcedroundingmode == 'auto') $forcedroundingmode='0';
2685
+		$forcedroundingmode = $roundingadjust;
2686
+		if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode = $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
2687
+		elseif ($forcedroundingmode == 'auto') $forcedroundingmode = '0';
2688 2688
 
2689
-		$error=0;
2689
+		$error = 0;
2690 2690
 
2691 2691
 		$multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1;
2692 2692
 
2693 2693
 		// Define constants to find lines to sum
2694
-		$fieldtva='total_tva';
2695
-		$fieldlocaltax1='total_localtax1';
2696
-		$fieldlocaltax2='total_localtax2';
2697
-		$fieldup='subprice';
2694
+		$fieldtva = 'total_tva';
2695
+		$fieldlocaltax1 = 'total_localtax1';
2696
+		$fieldlocaltax2 = 'total_localtax2';
2697
+		$fieldup = 'subprice';
2698 2698
 		if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
2699 2699
 		{
2700
-			$fieldtva='tva';
2701
-			$fieldup='pu_ht';
2700
+			$fieldtva = 'tva';
2701
+			$fieldup = 'pu_ht';
2702 2702
 		}
2703 2703
 		if ($this->element == 'expensereport')
2704 2704
 		{
2705
-			$fieldup='value_unit';
2705
+			$fieldup = 'value_unit';
2706 2706
 		}
2707 2707
 
2708 2708
 		$sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,';
2709
-		$sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type';
2710
-			if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent';
2711
-			$sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
2712
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2713
-		$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
2709
+		$sql .= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type';
2710
+			if ($this->table_element_line == 'facturedet') $sql .= ', situation_percent';
2711
+			$sql .= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
2712
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
2713
+		$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
2714 2714
 		if ($exclspec)
2715 2715
 		{
2716
-			$product_field='product_type';
2717
-			if ($this->table_element_line == 'contratdet') $product_field='';    // contratdet table has no product_type field
2718
-			if ($product_field) $sql.= ' AND '.$product_field.' <> 9';
2716
+			$product_field = 'product_type';
2717
+			if ($this->table_element_line == 'contratdet') $product_field = ''; // contratdet table has no product_type field
2718
+			if ($product_field) $sql .= ' AND '.$product_field.' <> 9';
2719 2719
 		}
2720
-		$sql.= ' ORDER by rowid';	// We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used
2720
+		$sql .= ' ORDER by rowid'; // We want to be sure to always use same order of line to not change lines differently when option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND is used
2721 2721
 
2722 2722
 		dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
2723 2723
 		$resql = $this->db->query($sql);
@@ -2731,7 +2731,7 @@  discard block
 block discarded – undo
2731 2731
 			$total_ht_by_vats  = array();
2732 2732
 			$total_tva_by_vats = array();
2733 2733
 			$total_ttc_by_vats = array();
2734
-			$this->multicurrency_total_ht	= 0;
2734
+			$this->multicurrency_total_ht = 0;
2735 2735
 			$this->multicurrency_total_tva	= 0;
2736 2736
 			$this->multicurrency_total_ttc	= 0;
2737 2737
 
@@ -2742,54 +2742,54 @@  discard block
 block discarded – undo
2742 2742
 				$obj = $this->db->fetch_object($resql);
2743 2743
 
2744 2744
 				// Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none'
2745
-				$parameters=array('fk_element' => $obj->rowid);
2745
+				$parameters = array('fk_element' => $obj->rowid);
2746 2746
 				$reshook = $hookmanager->executeHooks('changeRoundingMode', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
2747 2747
 
2748 2748
 				if (empty($reshook) && $forcedroundingmode == '0')	// Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
2749 2749
 				{
2750
-					$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
2751
-					$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
2752
-					$diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1);
2750
+					$localtax_array = array($obj->localtax1_type, $obj->localtax1_tx, $obj->localtax2_type, $obj->localtax2_tx);
2751
+					$tmpcal = calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
2752
+					$diff = price2num($tmpcal[1] - $obj->total_tva, 'MT', 1);
2753 2753
 					if ($diff)
2754 2754
 					{
2755
-						$sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid;
2755
+						$sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid;
2756 2756
 						dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
2757
-								$resqlfix=$this->db->query($sqlfix);
2758
-								if (! $resqlfix) dol_print_error($this->db,'Failed to update line');
2757
+								$resqlfix = $this->db->query($sqlfix);
2758
+								if (!$resqlfix) dol_print_error($this->db, 'Failed to update line');
2759 2759
 								$obj->total_tva = $tmpcal[1];
2760 2760
 								$obj->total_ttc = $tmpcal[2];
2761 2761
 						//
2762 2762
 					}
2763 2763
 				}
2764 2764
 
2765
-				$this->total_ht        += $obj->total_ht;		// The field visible at end of line detail
2765
+				$this->total_ht        += $obj->total_ht; // The field visible at end of line detail
2766 2766
 				$this->total_tva       += $obj->total_tva;
2767 2767
 				$this->total_localtax1 += $obj->total_localtax1;
2768 2768
 				$this->total_localtax2 += $obj->total_localtax2;
2769 2769
 				$this->total_ttc       += $obj->total_ttc;
2770
-				$this->multicurrency_total_ht        += $obj->multicurrency_total_ht;		// The field visible at end of line detail
2770
+				$this->multicurrency_total_ht        += $obj->multicurrency_total_ht; // The field visible at end of line detail
2771 2771
 				$this->multicurrency_total_tva       += $obj->multicurrency_total_tva;
2772 2772
 				$this->multicurrency_total_ttc       += $obj->multicurrency_total_ttc;
2773 2773
 
2774
-				if (! isset($total_ht_by_vats[$obj->vatrate]))  $total_ht_by_vats[$obj->vatrate]=0;
2775
-				if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0;
2776
-				if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0;
2774
+				if (!isset($total_ht_by_vats[$obj->vatrate]))  $total_ht_by_vats[$obj->vatrate] = 0;
2775
+				if (!isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate] = 0;
2776
+				if (!isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate] = 0;
2777 2777
 				$total_ht_by_vats[$obj->vatrate]  += $obj->total_ht;
2778 2778
 				$total_tva_by_vats[$obj->vatrate] += $obj->total_tva;
2779 2779
 				$total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc;
2780 2780
 
2781 2781
 				if ($forcedroundingmode == '1')	// Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency
2782 2782
 				{
2783
-					$tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1);
2784
-					$diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1);
2783
+					$tmpvat = price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1);
2784
+					$diff = price2num($total_tva_by_vats[$obj->vatrate] - $tmpvat, 'MT', 1);
2785 2785
 					//print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")."<br>\n";
2786 2786
 					if ($diff)
2787 2787
 					{
2788 2788
 						if (abs($diff) > 0.1) { dol_syslog('A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); exit; }
2789
-						$sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid;
2789
+						$sqlfix = "UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid;
2790 2790
 						dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
2791
-								$resqlfix=$this->db->query($sqlfix);
2792
-								if (! $resqlfix) dol_print_error($this->db,'Failed to update line');
2791
+								$resqlfix = $this->db->query($sqlfix);
2792
+								if (!$resqlfix) dol_print_error($this->db, 'Failed to update line');
2793 2793
 								$this->total_tva -= $diff;
2794 2794
 								$this->total_ttc -= $diff;
2795 2795
 								$total_tva_by_vats[$obj->vatrate] -= $diff;
@@ -2801,11 +2801,11 @@  discard block
 block discarded – undo
2801 2801
 			}
2802 2802
 
2803 2803
 			// Add revenue stamp to total
2804
-			$this->total_ttc       			+= isset($this->revenuestamp)?$this->revenuestamp:0;
2805
-			$this->multicurrency_total_ttc  += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0;
2804
+			$this->total_ttc += isset($this->revenuestamp) ? $this->revenuestamp : 0;
2805
+			$this->multicurrency_total_ttc += isset($this->revenuestamp) ? ($this->revenuestamp * $multicurrency_tx) : 0;
2806 2806
 
2807 2807
 			// Situations totals
2808
-			if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE )
2808
+			if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits') && $this->type != $this::TYPE_CREDIT_NOTE)
2809 2809
 			{
2810 2810
 				$prev_sits = $this->get_prev_sits();
2811 2811
 
@@ -2824,17 +2824,17 @@  discard block
 block discarded – undo
2824 2824
 			$this->db->free($resql);
2825 2825
 
2826 2826
 			// Now update global field total_ht, total_ttc and tva
2827
-			$fieldht='total_ht';
2828
-			$fieldtva='tva';
2829
-			$fieldlocaltax1='localtax1';
2830
-			$fieldlocaltax2='localtax2';
2831
-			$fieldttc='total_ttc';
2827
+			$fieldht = 'total_ht';
2828
+			$fieldtva = 'tva';
2829
+			$fieldlocaltax1 = 'localtax1';
2830
+			$fieldlocaltax2 = 'localtax2';
2831
+			$fieldttc = 'total_ttc';
2832 2832
 			// Specific code for backward compatibility with old field names
2833
-			if ($this->element == 'facture' || $this->element == 'facturerec')             $fieldht='total';
2834
-			if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva';
2835
-			if ($this->element == 'propal')                                                $fieldttc='total';
2836
-			if ($this->element == 'expensereport')                                         $fieldtva='total_tva';
2837
-			if ($this->element == 'supplier_proposal')                                     $fieldttc='total';
2833
+			if ($this->element == 'facture' || $this->element == 'facturerec')             $fieldht = 'total';
2834
+			if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva = 'total_tva';
2835
+			if ($this->element == 'propal')                                                $fieldttc = 'total';
2836
+			if ($this->element == 'expensereport')                                         $fieldtva = 'total_tva';
2837
+			if ($this->element == 'supplier_proposal')                                     $fieldttc = 'total';
2838 2838
 
2839 2839
 			if (empty($nodatabaseupdate))
2840 2840
 			{
@@ -2851,16 +2851,16 @@  discard block
 block discarded – undo
2851 2851
 
2852 2852
 
2853 2853
 				dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
2854
-				$resql=$this->db->query($sql);
2855
-				if (! $resql)
2854
+				$resql = $this->db->query($sql);
2855
+				if (!$resql)
2856 2856
 				{
2857 2857
 					$error++;
2858
-					$this->error=$this->db->lasterror();
2859
-					$this->errors[]=$this->db->lasterror();
2858
+					$this->error = $this->db->lasterror();
2859
+					$this->errors[] = $this->db->lasterror();
2860 2860
 				}
2861 2861
 			}
2862 2862
 
2863
-			if (! $error)
2863
+			if (!$error)
2864 2864
 			{
2865 2865
 				return 1;
2866 2866
 			}
@@ -2871,7 +2871,7 @@  discard block
 block discarded – undo
2871 2871
 		}
2872 2872
 		else
2873 2873
 		{
2874
-			dol_print_error($this->db,'Bad request in update_price');
2874
+			dol_print_error($this->db, 'Bad request in update_price');
2875 2875
 			return -1;
2876 2876
 		}
2877 2877
 	}
@@ -2885,30 +2885,30 @@  discard block
 block discarded – undo
2885 2885
 	 *	@return		int					<=0 if KO, >0 if OK
2886 2886
 	 *	@see		fetchObjectLinked, updateObjectLinked, deleteObjectLinked
2887 2887
 	 */
2888
-	function add_object_linked($origin=null, $origin_id=null)
2888
+	function add_object_linked($origin = null, $origin_id = null)
2889 2889
 	{
2890 2890
         // phpcs:enable
2891
-		$origin = (! empty($origin) ? $origin : $this->origin);
2892
-		$origin_id = (! empty($origin_id) ? $origin_id : $this->origin_id);
2891
+		$origin = (!empty($origin) ? $origin : $this->origin);
2892
+		$origin_id = (!empty($origin_id) ? $origin_id : $this->origin_id);
2893 2893
 
2894 2894
 		// Special case
2895
-		if ($origin == 'order') $origin='commande';
2896
-		if ($origin == 'invoice') $origin='facture';
2897
-		if ($origin == 'invoice_template') $origin='facturerec';
2898
-    	if ($origin == 'supplierorder') $origin='order_supplier';
2895
+		if ($origin == 'order') $origin = 'commande';
2896
+		if ($origin == 'invoice') $origin = 'facture';
2897
+		if ($origin == 'invoice_template') $origin = 'facturerec';
2898
+    	if ($origin == 'supplierorder') $origin = 'order_supplier';
2899 2899
 		$this->db->begin();
2900 2900
 
2901 2901
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
2902
-		$sql.= "fk_source";
2903
-		$sql.= ", sourcetype";
2904
-		$sql.= ", fk_target";
2905
-		$sql.= ", targettype";
2906
-		$sql.= ") VALUES (";
2907
-		$sql.= $origin_id;
2908
-		$sql.= ", '".$this->db->escape($origin)."'";
2909
-		$sql.= ", ".$this->id;
2910
-		$sql.= ", '".$this->db->escape($this->element)."'";
2911
-		$sql.= ")";
2902
+		$sql .= "fk_source";
2903
+		$sql .= ", sourcetype";
2904
+		$sql .= ", fk_target";
2905
+		$sql .= ", targettype";
2906
+		$sql .= ") VALUES (";
2907
+		$sql .= $origin_id;
2908
+		$sql .= ", '".$this->db->escape($origin)."'";
2909
+		$sql .= ", ".$this->id;
2910
+		$sql .= ", '".$this->db->escape($this->element)."'";
2911
+		$sql .= ")";
2912 2912
 
2913 2913
 		dol_syslog(get_class($this)."::add_object_linked", LOG_DEBUG);
2914 2914
 		if ($this->db->query($sql))
@@ -2918,7 +2918,7 @@  discard block
 block discarded – undo
2918 2918
 	  	}
2919 2919
 	  	else
2920 2920
 	  	{
2921
-	  		$this->error=$this->db->lasterror();
2921
+	  		$this->error = $this->db->lasterror();
2922 2922
 	  		$this->db->rollback();
2923 2923
 	  		return 0;
2924 2924
 	  	}
@@ -2946,33 +2946,33 @@  discard block
 block discarded – undo
2946 2946
 	 *	@return int							<0 if KO, >0 if OK
2947 2947
 	 *  @see	add_object_linked, updateObjectLinked, deleteObjectLinked
2948 2948
 	 */
2949
-	function fetchObjectLinked($sourceid=null,$sourcetype='',$targetid=null,$targettype='',$clause='OR',$alsosametype=1,$orderby='sourcetype',$loadalsoobjects=1)
2949
+	function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1)
2950 2950
 	{
2951 2951
 		global $conf;
2952 2952
 
2953
-		$this->linkedObjectsIds=array();
2954
-		$this->linkedObjects=array();
2953
+		$this->linkedObjectsIds = array();
2954
+		$this->linkedObjects = array();
2955 2955
 
2956
-		$justsource=false;
2957
-		$justtarget=false;
2958
-		$withtargettype=false;
2959
-		$withsourcetype=false;
2956
+		$justsource = false;
2957
+		$justtarget = false;
2958
+		$withtargettype = false;
2959
+		$withsourcetype = false;
2960 2960
 
2961
-		if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid))
2961
+		if (!empty($sourceid) && !empty($sourcetype) && empty($targetid))
2962 2962
 		{
2963
-			$justsource=true;  // the source (id and type) is a search criteria
2964
-			if (! empty($targettype)) $withtargettype=true;
2963
+			$justsource = true; // the source (id and type) is a search criteria
2964
+			if (!empty($targettype)) $withtargettype = true;
2965 2965
 		}
2966
-		if (! empty($targetid) && ! empty($targettype) && empty($sourceid))
2966
+		if (!empty($targetid) && !empty($targettype) && empty($sourceid))
2967 2967
 		{
2968
-			$justtarget=true;  // the target (id and type) is a search criteria
2969
-			if (! empty($sourcetype)) $withsourcetype=true;
2968
+			$justtarget = true; // the target (id and type) is a search criteria
2969
+			if (!empty($sourcetype)) $withsourcetype = true;
2970 2970
 		}
2971 2971
 
2972
-		$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
2973
-		$targetid = (! empty($targetid) ? $targetid : $this->id);
2974
-		$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
2975
-		$targettype = (! empty($targettype) ? $targettype : $this->element);
2972
+		$sourceid = (!empty($sourceid) ? $sourceid : $this->id);
2973
+		$targetid = (!empty($targetid) ? $targetid : $this->id);
2974
+		$sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element);
2975
+		$targettype = (!empty($targettype) ? $targettype : $this->element);
2976 2976
 
2977 2977
 		/*if (empty($sourceid) && empty($targetid))
2978 2978
 		 {
@@ -2982,25 +2982,25 @@  discard block
 block discarded – undo
2982 2982
 
2983 2983
 		// Links between objects are stored in table element_element
2984 2984
 		$sql = 'SELECT rowid, fk_source, sourcetype, fk_target, targettype';
2985
-		$sql.= ' FROM '.MAIN_DB_PREFIX.'element_element';
2986
-		$sql.= " WHERE ";
2985
+		$sql .= ' FROM '.MAIN_DB_PREFIX.'element_element';
2986
+		$sql .= " WHERE ";
2987 2987
 		if ($justsource || $justtarget)
2988 2988
 		{
2989 2989
 			if ($justsource)
2990 2990
 			{
2991
-				$sql.= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'";
2992
-				if ($withtargettype) $sql.= " AND targettype = '".$targettype."'";
2991
+				$sql .= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'";
2992
+				if ($withtargettype) $sql .= " AND targettype = '".$targettype."'";
2993 2993
 			}
2994 2994
 			else if ($justtarget)
2995 2995
 			{
2996
-				$sql.= "fk_target = ".$targetid." AND targettype = '".$targettype."'";
2997
-				if ($withsourcetype) $sql.= " AND sourcetype = '".$sourcetype."'";
2996
+				$sql .= "fk_target = ".$targetid." AND targettype = '".$targettype."'";
2997
+				if ($withsourcetype) $sql .= " AND sourcetype = '".$sourcetype."'";
2998 2998
 			}
2999 2999
 		}
3000 3000
 		else
3001 3001
 		{
3002
-			$sql.= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')";
3003
-			$sql.= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')";
3002
+			$sql .= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')";
3003
+			$sql .= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')";
3004 3004
 		}
3005 3005
 		$sql .= ' ORDER BY '.$orderby;
3006 3006
 
@@ -3017,36 +3017,36 @@  discard block
 block discarded – undo
3017 3017
 				{
3018 3018
 					if ($justsource)
3019 3019
 					{
3020
-						$this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target;
3020
+						$this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target;
3021 3021
 					}
3022 3022
 					else if ($justtarget)
3023 3023
 					{
3024
-						$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source;
3024
+						$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid] = $obj->fk_source;
3025 3025
 					}
3026 3026
 				}
3027 3027
 				else
3028 3028
 				{
3029 3029
 					if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype)
3030 3030
 					{
3031
-						$this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target;
3031
+						$this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target;
3032 3032
 					}
3033 3033
 					if ($obj->fk_target == $targetid && $obj->targettype == $targettype)
3034 3034
 					{
3035
-						$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source;
3035
+						$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid] = $obj->fk_source;
3036 3036
 					}
3037 3037
 				}
3038 3038
 				$i++;
3039 3039
 			}
3040 3040
 
3041
-			if (! empty($this->linkedObjectsIds))
3041
+			if (!empty($this->linkedObjectsIds))
3042 3042
 			{
3043 3043
 				$tmparray = $this->linkedObjectsIds;
3044
-				foreach($tmparray as $objecttype => $objectids)       // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...)
3044
+				foreach ($tmparray as $objecttype => $objectids)       // $objecttype is a module name ('facture', 'mymodule', ...) or a module name with a suffix ('project_task', 'mymodule_myobj', ...)
3045 3045
 				{
3046 3046
 					// Parse element/subelement (ex: project_task, cabinetmed_consultation, ...)
3047 3047
 					$module = $element = $subelement = $objecttype;
3048 3048
 					if ($objecttype != 'supplier_proposal' && $objecttype != 'order_supplier' && $objecttype != 'invoice_supplier'
3049
-						&& preg_match('/^([^_]+)_([^_]+)/i',$objecttype,$regs))
3049
+						&& preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
3050 3050
 					{
3051 3051
 						$module = $element = $regs[1];
3052 3052
 						$subelement = $regs[2];
@@ -3054,31 +3054,31 @@  discard block
 block discarded – undo
3054 3054
 
3055 3055
 					$classpath = $element.'/class';
3056 3056
 					// To work with non standard classpath or module name
3057
-					if ($objecttype == 'facture')			{
3057
+					if ($objecttype == 'facture') {
3058 3058
 						$classpath = 'compta/facture/class';
3059 3059
 					}
3060
-					else if ($objecttype == 'facturerec')			{
3060
+					else if ($objecttype == 'facturerec') {
3061 3061
 						$classpath = 'compta/facture/class'; $module = 'facture';
3062 3062
 					}
3063
-					else if ($objecttype == 'propal')			{
3063
+					else if ($objecttype == 'propal') {
3064 3064
 						$classpath = 'comm/propal/class';
3065 3065
 					}
3066
-					else if ($objecttype == 'supplier_proposal')			{
3066
+					else if ($objecttype == 'supplier_proposal') {
3067 3067
 						$classpath = 'supplier_proposal/class';
3068 3068
 					}
3069
-					else if ($objecttype == 'shipping')			{
3069
+					else if ($objecttype == 'shipping') {
3070 3070
 						$classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon';
3071 3071
 					}
3072
-					else if ($objecttype == 'delivery')			{
3072
+					else if ($objecttype == 'delivery') {
3073 3073
 						$classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon';
3074 3074
 					}
3075
-					else if ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier')	{
3075
+					else if ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') {
3076 3076
 						$classpath = 'fourn/class'; $module = 'fournisseur';
3077 3077
 					}
3078
-					else if ($objecttype == 'fichinter')			{
3078
+					else if ($objecttype == 'fichinter') {
3079 3079
 						$classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter';
3080 3080
 					}
3081
-					else if ($objecttype == 'subscription')			{
3081
+					else if ($objecttype == 'subscription') {
3082 3082
 						$classpath = 'adherents/class'; $module = 'adherent';
3083 3083
 					}
3084 3084
 
@@ -3091,16 +3091,16 @@  discard block
 block discarded – undo
3091 3091
 					else if ($objecttype == 'invoice_supplier') {
3092 3092
 						$classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur';
3093 3093
 					}
3094
-					else if ($objecttype == 'order_supplier')   {
3094
+					else if ($objecttype == 'order_supplier') {
3095 3095
 						$classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur';
3096 3096
 					}
3097
-					else if ($objecttype == 'supplier_proposal')   {
3097
+					else if ($objecttype == 'supplier_proposal') {
3098 3098
 						$classfile = 'supplier_proposal'; $classname = 'SupplierProposal';
3099 3099
 					}
3100
-					else if ($objecttype == 'facturerec')   {
3100
+					else if ($objecttype == 'facturerec') {
3101 3101
 						$classfile = 'facture-rec'; $classname = 'FactureRec';
3102 3102
 					}
3103
-					else if ($objecttype == 'subscription')   {
3103
+					else if ($objecttype == 'subscription') {
3104 3104
 						$classfile = 'subscription'; $classname = 'Subscription';
3105 3105
 					}
3106 3106
 
@@ -3113,7 +3113,7 @@  discard block
 block discarded – undo
3113 3113
 							//print '/'.$classpath.'/'.$classfile.'.class.php '.class_exists($classname);
3114 3114
 							if (class_exists($classname))
3115 3115
 							{
3116
-								foreach($objectids as $i => $objectid)	// $i is rowid into llx_element_element
3116
+								foreach ($objectids as $i => $objectid)	// $i is rowid into llx_element_element
3117 3117
 								{
3118 3118
 									$object = new $classname($this->db);
3119 3119
 									$ret = $object->fetch($objectid);
@@ -3150,28 +3150,28 @@  discard block
 block discarded – undo
3150 3150
 	 *	@return							int	>0 if OK, <0 if KO
3151 3151
 	 *	@see	add_object_linked, fetObjectLinked, deleteObjectLinked
3152 3152
 	 */
3153
-	function updateObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='')
3153
+	function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '')
3154 3154
 	{
3155
-		$updatesource=false;
3156
-		$updatetarget=false;
3155
+		$updatesource = false;
3156
+		$updatetarget = false;
3157 3157
 
3158
-		if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource=true;
3159
-		else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $updatetarget=true;
3158
+		if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $updatesource = true;
3159
+		else if (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $updatetarget = true;
3160 3160
 
3161 3161
 		$sql = "UPDATE ".MAIN_DB_PREFIX."element_element SET ";
3162 3162
 		if ($updatesource)
3163 3163
 		{
3164
-			$sql.= "fk_source = ".$sourceid;
3165
-			$sql.= ", sourcetype = '".$this->db->escape($sourcetype)."'";
3166
-			$sql.= " WHERE fk_target = ".$this->id;
3167
-			$sql.= " AND targettype = '".$this->db->escape($this->element)."'";
3164
+			$sql .= "fk_source = ".$sourceid;
3165
+			$sql .= ", sourcetype = '".$this->db->escape($sourcetype)."'";
3166
+			$sql .= " WHERE fk_target = ".$this->id;
3167
+			$sql .= " AND targettype = '".$this->db->escape($this->element)."'";
3168 3168
 		}
3169 3169
 		else if ($updatetarget)
3170 3170
 		{
3171
-			$sql.= "fk_target = ".$targetid;
3172
-			$sql.= ", targettype = '".$this->db->escape($targettype)."'";
3173
-			$sql.= " WHERE fk_source = ".$this->id;
3174
-			$sql.= " AND sourcetype = '".$this->db->escape($this->element)."'";
3171
+			$sql .= "fk_target = ".$targetid;
3172
+			$sql .= ", targettype = '".$this->db->escape($targettype)."'";
3173
+			$sql .= " WHERE fk_source = ".$this->id;
3174
+			$sql .= " AND sourcetype = '".$this->db->escape($this->element)."'";
3175 3175
 		}
3176 3176
 
3177 3177
 		dol_syslog(get_class($this)."::updateObjectLinked", LOG_DEBUG);
@@ -3181,7 +3181,7 @@  discard block
 block discarded – undo
3181 3181
 		}
3182 3182
 		else
3183 3183
 		{
3184
-			$this->error=$this->db->lasterror();
3184
+			$this->error = $this->db->lasterror();
3185 3185
 			return -1;
3186 3186
 		}
3187 3187
 	}
@@ -3197,42 +3197,42 @@  discard block
 block discarded – undo
3197 3197
 	 *	@return     					int	>0 if OK, <0 if KO
3198 3198
 	 *	@see	add_object_linked, updateObjectLinked, fetchObjectLinked
3199 3199
 	 */
3200
-	function deleteObjectLinked($sourceid=null, $sourcetype='', $targetid=null, $targettype='', $rowid='')
3200
+	function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '')
3201 3201
 	{
3202
-		$deletesource=false;
3203
-		$deletetarget=false;
3202
+		$deletesource = false;
3203
+		$deletetarget = false;
3204 3204
 
3205
-		if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource=true;
3206
-		else if (empty($sourceid) && empty($sourcetype) && ! empty($targetid) && ! empty($targettype)) $deletetarget=true;
3205
+		if (!empty($sourceid) && !empty($sourcetype) && empty($targetid) && empty($targettype)) $deletesource = true;
3206
+		else if (empty($sourceid) && empty($sourcetype) && !empty($targetid) && !empty($targettype)) $deletetarget = true;
3207 3207
 
3208
-		$sourceid = (! empty($sourceid) ? $sourceid : $this->id);
3209
-		$sourcetype = (! empty($sourcetype) ? $sourcetype : $this->element);
3210
-		$targetid = (! empty($targetid) ? $targetid : $this->id);
3211
-		$targettype = (! empty($targettype) ? $targettype : $this->element);
3208
+		$sourceid = (!empty($sourceid) ? $sourceid : $this->id);
3209
+		$sourcetype = (!empty($sourcetype) ? $sourcetype : $this->element);
3210
+		$targetid = (!empty($targetid) ? $targetid : $this->id);
3211
+		$targettype = (!empty($targettype) ? $targettype : $this->element);
3212 3212
 
3213 3213
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_element";
3214
-		$sql.= " WHERE";
3214
+		$sql .= " WHERE";
3215 3215
 		if ($rowid > 0)
3216 3216
 		{
3217
-			$sql.=" rowid = ".$rowid;
3217
+			$sql .= " rowid = ".$rowid;
3218 3218
 		}
3219 3219
 		else
3220 3220
 		{
3221 3221
 			if ($deletesource)
3222 3222
 			{
3223
-				$sql.= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'";
3224
-				$sql.= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'";
3223
+				$sql .= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'";
3224
+				$sql .= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'";
3225 3225
 			}
3226 3226
 			else if ($deletetarget)
3227 3227
 			{
3228
-				$sql.= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'";
3229
-				$sql.= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'";
3228
+				$sql .= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'";
3229
+				$sql .= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'";
3230 3230
 			}
3231 3231
 			else
3232 3232
 			{
3233
-				$sql.= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')";
3234
-				$sql.= " OR";
3235
-				$sql.= " (fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."')";
3233
+				$sql .= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')";
3234
+				$sql .= " OR";
3235
+				$sql .= " (fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."')";
3236 3236
 			}
3237 3237
 		}
3238 3238
 
@@ -3243,8 +3243,8 @@  discard block
 block discarded – undo
3243 3243
 		}
3244 3244
 		else
3245 3245
 		{
3246
-			$this->error=$this->db->lasterror();
3247
-			$this->errors[]=$this->error;
3246
+			$this->error = $this->db->lasterror();
3247
+			$this->errors[] = $this->error;
3248 3248
 			return -1;
3249 3249
 		}
3250 3250
 	}
@@ -3258,30 +3258,30 @@  discard block
 block discarded – undo
3258 3258
 	 *      @param	string	$trigkey		Trigger key to use for trigger
3259 3259
 	 *      @return int						<0 if KO, >0 if OK
3260 3260
 	 */
3261
-	function setStatut($status, $elementId=null, $elementType='', $trigkey='')
3261
+	function setStatut($status, $elementId = null, $elementType = '', $trigkey = '')
3262 3262
 	{
3263
-		global $user,$langs,$conf;
3263
+		global $user, $langs, $conf;
3264 3264
 
3265
-		$savElementId=$elementId;  // To be used later to know if we were using the method using the id of this or not.
3265
+		$savElementId = $elementId; // To be used later to know if we were using the method using the id of this or not.
3266 3266
 
3267
-		$elementId = (!empty($elementId)?$elementId:$this->id);
3268
-		$elementTable = (!empty($elementType)?$elementType:$this->table_element);
3267
+		$elementId = (!empty($elementId) ? $elementId : $this->id);
3268
+		$elementTable = (!empty($elementType) ? $elementType : $this->table_element);
3269 3269
 
3270 3270
 		$this->db->begin();
3271 3271
 
3272
-		$fieldstatus="fk_statut";
3273
-		if ($elementTable == 'facture_rec') $fieldstatus="suspended";
3274
-		if ($elementTable == 'mailing') $fieldstatus="statut";
3275
-		if ($elementTable == 'cronjob') $fieldstatus="status";
3276
-		if ($elementTable == 'user') $fieldstatus="statut";
3277
-		if ($elementTable == 'expensereport') $fieldstatus="fk_statut";
3278
-		if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus="status";
3272
+		$fieldstatus = "fk_statut";
3273
+		if ($elementTable == 'facture_rec') $fieldstatus = "suspended";
3274
+		if ($elementTable == 'mailing') $fieldstatus = "statut";
3275
+		if ($elementTable == 'cronjob') $fieldstatus = "status";
3276
+		if ($elementTable == 'user') $fieldstatus = "statut";
3277
+		if ($elementTable == 'expensereport') $fieldstatus = "fk_statut";
3278
+		if ($elementTable == 'commande_fournisseur_dispatch') $fieldstatus = "status";
3279 3279
 
3280 3280
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$elementTable;
3281
-		$sql.= " SET ".$fieldstatus." = ".$status;
3281
+		$sql .= " SET ".$fieldstatus." = ".$status;
3282 3282
 		// If status = 1 = validated, update also fk_user_valid
3283
-		if ($status == 1 && $elementTable == 'expensereport') $sql.=", fk_user_valid = ".$user->id;
3284
-		$sql.= " WHERE rowid=".$elementId;
3283
+		if ($status == 1 && $elementTable == 'expensereport') $sql .= ", fk_user_valid = ".$user->id;
3284
+		$sql .= " WHERE rowid=".$elementId;
3285 3285
 
3286 3286
 		dol_syslog(get_class($this)."::setStatut", LOG_DEBUG);
3287 3287
 		if ($this->db->query($sql))
@@ -3291,27 +3291,27 @@  discard block
 block discarded – undo
3291 3291
 			// Try autoset of trigkey
3292 3292
 			if (empty($trigkey))
3293 3293
 			{
3294
-				if ($this->element == 'supplier_proposal' && $status == 2) $trigkey='SUPPLIER_PROPOSAL_SIGN';   // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class
3295
-				if ($this->element == 'supplier_proposal' && $status == 3) $trigkey='SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class
3296
-				if ($this->element == 'supplier_proposal' && $status == 4) $trigkey='SUPPLIER_PROPOSAL_CLOSE';  // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class
3297
-				if ($this->element == 'fichinter' && $status == 3) $trigkey='FICHINTER_CLASSIFY_DONE';
3298
-				if ($this->element == 'fichinter' && $status == 2) $trigkey='FICHINTER_CLASSIFY_BILLED';
3299
-				if ($this->element == 'fichinter' && $status == 1) $trigkey='FICHINTER_CLASSIFY_UNBILLED';
3294
+				if ($this->element == 'supplier_proposal' && $status == 2) $trigkey = 'SUPPLIER_PROPOSAL_SIGN'; // 2 = SupplierProposal::STATUS_SIGNED. Can't use constant into this generic class
3295
+				if ($this->element == 'supplier_proposal' && $status == 3) $trigkey = 'SUPPLIER_PROPOSAL_REFUSE'; // 3 = SupplierProposal::STATUS_REFUSED. Can't use constant into this generic class
3296
+				if ($this->element == 'supplier_proposal' && $status == 4) $trigkey = 'SUPPLIER_PROPOSAL_CLOSE'; // 4 = SupplierProposal::STATUS_CLOSED. Can't use constant into this generic class
3297
+				if ($this->element == 'fichinter' && $status == 3) $trigkey = 'FICHINTER_CLASSIFY_DONE';
3298
+				if ($this->element == 'fichinter' && $status == 2) $trigkey = 'FICHINTER_CLASSIFY_BILLED';
3299
+				if ($this->element == 'fichinter' && $status == 1) $trigkey = 'FICHINTER_CLASSIFY_UNBILLED';
3300 3300
 			}
3301 3301
 
3302 3302
 			if ($trigkey)
3303 3303
 			{
3304 3304
 				// Appel des triggers
3305
-				include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
3306
-				$interface=new Interfaces($this->db);
3307
-				$result=$interface->run_triggers($trigkey,$this,$user,$langs,$conf);
3305
+				include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
3306
+				$interface = new Interfaces($this->db);
3307
+				$result = $interface->run_triggers($trigkey, $this, $user, $langs, $conf);
3308 3308
 				if ($result < 0) {
3309
-					$error++; $this->errors=$interface->errors;
3309
+					$error++; $this->errors = $interface->errors;
3310 3310
 				}
3311 3311
 				// Fin appel triggers
3312 3312
 			}
3313 3313
 
3314
-			if (! $error)
3314
+			if (!$error)
3315 3315
 			{
3316 3316
 				$this->db->commit();
3317 3317
 
@@ -3326,13 +3326,13 @@  discard block
 block discarded – undo
3326 3326
 			else
3327 3327
 			{
3328 3328
 				$this->db->rollback();
3329
-				dol_syslog(get_class($this)."::setStatus ".$this->error,LOG_ERR);
3329
+				dol_syslog(get_class($this)."::setStatus ".$this->error, LOG_ERR);
3330 3330
 				return -1;
3331 3331
 			}
3332 3332
 		}
3333 3333
 		else
3334 3334
 		{
3335
-			$this->error=$this->db->lasterror();
3335
+			$this->error = $this->db->lasterror();
3336 3336
 			$this->db->rollback();
3337 3337
 			return -1;
3338 3338
 		}
@@ -3346,21 +3346,21 @@  discard block
 block discarded – undo
3346 3346
 	 *  @param      string	$ref    Record ref
3347 3347
 	 *  @return		int				<0 if KO, 0 if nothing done, >0 if OK
3348 3348
 	 */
3349
-	function getCanvas($id=0,$ref='')
3349
+	function getCanvas($id = 0, $ref = '')
3350 3350
 	{
3351 3351
 		global $conf;
3352 3352
 
3353 3353
 		if (empty($id) && empty($ref)) return 0;
3354
-		if (! empty($conf->global->MAIN_DISABLE_CANVAS)) return 0;    // To increase speed. Not enabled by default.
3354
+		if (!empty($conf->global->MAIN_DISABLE_CANVAS)) return 0; // To increase speed. Not enabled by default.
3355 3355
 
3356 3356
 		// Clean parameters
3357 3357
 		$ref = trim($ref);
3358 3358
 
3359 3359
 		$sql = "SELECT rowid, canvas";
3360
-		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element;
3361
-		$sql.= " WHERE entity IN (".getEntity($this->element).")";
3362
-		if (! empty($id))  $sql.= " AND rowid = ".$id;
3363
-		if (! empty($ref)) $sql.= " AND ref = '".$this->db->escape($ref)."'";
3360
+		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
3361
+		$sql .= " WHERE entity IN (".getEntity($this->element).")";
3362
+		if (!empty($id))  $sql .= " AND rowid = ".$id;
3363
+		if (!empty($ref)) $sql .= " AND ref = '".$this->db->escape($ref)."'";
3364 3364
 
3365 3365
 		$resql = $this->db->query($sql);
3366 3366
 		if ($resql)
@@ -3368,7 +3368,7 @@  discard block
 block discarded – undo
3368 3368
 			$obj = $this->db->fetch_object($resql);
3369 3369
 			if ($obj)
3370 3370
 			{
3371
-				$this->canvas   = $obj->canvas;
3371
+				$this->canvas = $obj->canvas;
3372 3372
 				return 1;
3373 3373
 			}
3374 3374
 			else return 0;
@@ -3390,7 +3390,7 @@  discard block
 block discarded – undo
3390 3390
 	function getSpecialCode($lineid)
3391 3391
 	{
3392 3392
 		$sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line;
3393
-		$sql.= ' WHERE rowid = '.$lineid;
3393
+		$sql .= ' WHERE rowid = '.$lineid;
3394 3394
 		$resql = $this->db->query($sql);
3395 3395
 		if ($resql)
3396 3396
 		{
@@ -3406,14 +3406,14 @@  discard block
 block discarded – undo
3406 3406
 	 *  @param	int		$id			Force id of object
3407 3407
 	 *  @return	int					<0 if KO, 0 if not used, >0 if already used
3408 3408
 	 */
3409
-	function isObjectUsed($id=0)
3409
+	function isObjectUsed($id = 0)
3410 3410
 	{
3411 3411
 		global $langs;
3412 3412
 
3413
-		if (empty($id)) $id=$this->id;
3413
+		if (empty($id)) $id = $this->id;
3414 3414
 
3415 3415
 		// Check parameters
3416
-		if (! isset($this->childtables) || ! is_array($this->childtables) || count($this->childtables) == 0)
3416
+		if (!isset($this->childtables) || !is_array($this->childtables) || count($this->childtables) == 0)
3417 3417
 		{
3418 3418
 			dol_print_error('Called isObjectUsed on a class with property this->childtables not defined');
3419 3419
 			return -1;
@@ -3421,24 +3421,24 @@  discard block
 block discarded – undo
3421 3421
 
3422 3422
 		$arraytoscan = $this->childtables;
3423 3423
 		// For backward compatibility, we check if array is old format array('table1', 'table2', ...)
3424
-		$tmparray=array_keys($this->childtables);
3424
+		$tmparray = array_keys($this->childtables);
3425 3425
 		if (is_numeric($tmparray[0]))
3426 3426
 		{
3427 3427
 			$arraytoscan = array_flip($this->childtables);
3428 3428
 		}
3429 3429
 
3430 3430
 		// Test if child exists
3431
-		$haschild=0;
3432
-		foreach($arraytoscan as $table => $elementname)
3431
+		$haschild = 0;
3432
+		foreach ($arraytoscan as $table => $elementname)
3433 3433
 		{
3434 3434
 			//print $id.'-'.$table.'-'.$elementname.'<br>';
3435 3435
 			// Check if third party can be deleted
3436 3436
 			$sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX.$table;
3437
-			$sql.= " WHERE ".$this->fk_element." = ".$id;
3438
-			$resql=$this->db->query($sql);
3437
+			$sql .= " WHERE ".$this->fk_element." = ".$id;
3438
+			$resql = $this->db->query($sql);
3439 3439
 			if ($resql)
3440 3440
 			{
3441
-				$obj=$this->db->fetch_object($resql);
3441
+				$obj = $this->db->fetch_object($resql);
3442 3442
 				if ($obj->nb > 0)
3443 3443
 				{
3444 3444
 					$langs->load("errors");
@@ -3446,24 +3446,24 @@  discard block
 block discarded – undo
3446 3446
 					$haschild += $obj->nb;
3447 3447
 					if (is_numeric($elementname))	// old usage
3448 3448
 					{
3449
-						$this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table);
3449
+						$this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table);
3450 3450
 					}
3451 3451
 					else	// new usage: $elementname=Translation key
3452 3452
 					{
3453
-						$this->errors[]=$langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname));
3453
+						$this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname));
3454 3454
 					}
3455
-					break;    // We found at least one, we stop here
3455
+					break; // We found at least one, we stop here
3456 3456
 				}
3457 3457
 			}
3458 3458
 			else
3459 3459
 			{
3460
-				$this->errors[]=$this->db->lasterror();
3460
+				$this->errors[] = $this->db->lasterror();
3461 3461
 				return -1;
3462 3462
 			}
3463 3463
 		}
3464 3464
 		if ($haschild > 0)
3465 3465
 		{
3466
-			$this->errors[]="ErrorRecordHasChildren";
3466
+			$this->errors[] = "ErrorRecordHasChildren";
3467 3467
 			return $haschild;
3468 3468
 		}
3469 3469
 		else return 0;
@@ -3475,18 +3475,18 @@  discard block
 block discarded – undo
3475 3475
 	 *	@param	int		$predefined		-1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service
3476 3476
 	 *  @return	int						<0 if KO, 0 if no predefined products, nb of lines with predefined products if found
3477 3477
 	 */
3478
-	function hasProductsOrServices($predefined=-1)
3478
+	function hasProductsOrServices($predefined = -1)
3479 3479
 	{
3480
-		$nb=0;
3480
+		$nb = 0;
3481 3481
 
3482
-		foreach($this->lines as $key => $val)
3482
+		foreach ($this->lines as $key => $val)
3483 3483
 		{
3484
-			$qualified=0;
3485
-			if ($predefined == -1) $qualified=1;
3486
-			if ($predefined == 1 && $val->fk_product > 0) $qualified=1;
3487
-			if ($predefined == 0 && $val->fk_product <= 0) $qualified=1;
3488
-			if ($predefined == 2 && $val->fk_product > 0 && $val->product_type==0) $qualified=1;
3489
-			if ($predefined == 3 && $val->fk_product > 0 && $val->product_type==1) $qualified=1;
3484
+			$qualified = 0;
3485
+			if ($predefined == -1) $qualified = 1;
3486
+			if ($predefined == 1 && $val->fk_product > 0) $qualified = 1;
3487
+			if ($predefined == 0 && $val->fk_product <= 0) $qualified = 1;
3488
+			if ($predefined == 2 && $val->fk_product > 0 && $val->product_type == 0) $qualified = 1;
3489
+			if ($predefined == 3 && $val->fk_product > 0 && $val->product_type == 1) $qualified = 1;
3490 3490
 			if ($qualified) $nb++;
3491 3491
 		}
3492 3492
 		dol_syslog(get_class($this).'::hasProductsOrServices we found '.$nb.' qualified lines of products/servcies');
@@ -3500,24 +3500,24 @@  discard block
 block discarded – undo
3500 3500
 	 */
3501 3501
 	function getTotalDiscount()
3502 3502
 	{
3503
-		$total_discount=0.00;
3503
+		$total_discount = 0.00;
3504 3504
 
3505 3505
 		$sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht";
3506
-		$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element."det";
3507
-		$sql.= " WHERE ".$this->fk_element." = ".$this->id;
3506
+		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element."det";
3507
+		$sql .= " WHERE ".$this->fk_element." = ".$this->id;
3508 3508
 
3509 3509
 		dol_syslog(get_class($this).'::getTotalDiscount', LOG_DEBUG);
3510 3510
 		$resql = $this->db->query($sql);
3511 3511
 		if ($resql)
3512 3512
 		{
3513
-			$num=$this->db->num_rows($resql);
3514
-			$i=0;
3513
+			$num = $this->db->num_rows($resql);
3514
+			$i = 0;
3515 3515
 			while ($i < $num)
3516 3516
 			{
3517 3517
 				$obj = $this->db->fetch_object($resql);
3518 3518
 
3519 3519
 				$pu_ht = $obj->pu_ht;
3520
-				$qty= $obj->qty;
3520
+				$qty = $obj->qty;
3521 3521
 				$total_ht = $obj->total_ht;
3522 3522
 
3523 3523
 				$total_discount_line = floatval(price2num(($pu_ht * $qty) - $total_ht, 'MT'));
@@ -3551,17 +3551,17 @@  discard block
 block discarded – undo
3551 3551
 		{
3552 3552
 			if (isset($line->qty_asked))
3553 3553
 			{
3554
-				if (empty($totalOrdered)) $totalOrdered=0;  // Avoid warning because $totalOrdered is ''
3555
-				$totalOrdered+=$line->qty_asked;    // defined for shipment only
3554
+				if (empty($totalOrdered)) $totalOrdered = 0; // Avoid warning because $totalOrdered is ''
3555
+				$totalOrdered += $line->qty_asked; // defined for shipment only
3556 3556
 			}
3557 3557
 			if (isset($line->qty_shipped))
3558 3558
 			{
3559
-				if (empty($totalToShip)) $totalToShip=0;    // Avoid warning because $totalToShip is ''
3560
-				$totalToShip+=$line->qty_shipped;   // defined for shipment only
3561
-            }else if ($line->element == 'commandefournisseurdispatch' && isset($line->qty))
3559
+				if (empty($totalToShip)) $totalToShip = 0; // Avoid warning because $totalToShip is ''
3560
+				$totalToShip += $line->qty_shipped; // defined for shipment only
3561
+            } else if ($line->element == 'commandefournisseurdispatch' && isset($line->qty))
3562 3562
             {
3563
-                if (empty($totalToShip)) $totalToShip=0;
3564
-                $totalToShip+=$line->qty;   // defined for reception only
3563
+                if (empty($totalToShip)) $totalToShip = 0;
3564
+                $totalToShip += $line->qty; // defined for reception only
3565 3565
 			}
3566 3566
 
3567 3567
 			// Define qty, weight, volume, weight_units, volume_units
@@ -3574,27 +3574,27 @@  discard block
 block discarded – undo
3574 3574
 			}
3575 3575
 
3576 3576
 			$weight = $line->weight ? $line->weight : 0;
3577
-            ($weight==0 && !empty($line->product->weight))? $weight=$line->product->weight: 0;
3577
+            ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0;
3578 3578
 			$volume = $line->volume ? $line->volume : 0;
3579
-			($volume==0 && !empty($line->product->volume))? $volume=$line->product->volume: 0;
3579
+			($volume == 0 && !empty($line->product->volume)) ? $volume = $line->product->volume : 0;
3580 3580
 
3581
-			$weight_units=$line->weight_units;
3582
-			($weight_units==0 && !empty($line->product->weight_units))? $weight_units=$line->product->weight_units: 0;
3583
-			$volume_units=$line->volume_units;
3584
-			($volume_units==0 && !empty($line->product->volume_units))? $volume_units=$line->product->volume_units: 0;
3581
+			$weight_units = $line->weight_units;
3582
+			($weight_units == 0 && !empty($line->product->weight_units)) ? $weight_units = $line->product->weight_units : 0;
3583
+			$volume_units = $line->volume_units;
3584
+			($volume_units == 0 && !empty($line->product->volume_units)) ? $volume_units = $line->product->volume_units : 0;
3585 3585
 
3586
-			$weightUnit=0;
3587
-			$volumeUnit=0;
3588
-			if (! empty($weight_units)) $weightUnit = $weight_units;
3589
-			if (! empty($volume_units)) $volumeUnit = $volume_units;
3586
+			$weightUnit = 0;
3587
+			$volumeUnit = 0;
3588
+			if (!empty($weight_units)) $weightUnit = $weight_units;
3589
+			if (!empty($volume_units)) $volumeUnit = $volume_units;
3590 3590
 
3591
-			if (empty($totalWeight)) $totalWeight=0;  // Avoid warning because $totalWeight is ''
3592
-			if (empty($totalVolume)) $totalVolume=0;  // Avoid warning because $totalVolume is ''
3591
+			if (empty($totalWeight)) $totalWeight = 0; // Avoid warning because $totalWeight is ''
3592
+			if (empty($totalVolume)) $totalVolume = 0; // Avoid warning because $totalVolume is ''
3593 3593
 
3594 3594
 			//var_dump($line->volume_units);
3595 3595
 			if ($weight_units < 50)   // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch)
3596 3596
 			{
3597
-				$trueWeightUnit=pow(10, $weightUnit);
3597
+				$trueWeightUnit = pow(10, $weightUnit);
3598 3598
 				$totalWeight += $weight * $qty * $trueWeightUnit;
3599 3599
 			}
3600 3600
 			else {
@@ -3608,18 +3608,18 @@  discard block
 block discarded – undo
3608 3608
 			$totalWeight += $weight * $qty * $trueWeightUnit;
3609 3609
 		}
3610 3610
 		else
3611
-					$totalWeight += $weight * $qty;   // This may be wrong if we mix different units
3611
+					$totalWeight += $weight * $qty; // This may be wrong if we mix different units
3612 3612
 			}
3613 3613
 			if ($volume_units < 50)   // >50 means a standard unit (power of 10 of official unit), > 50 means an exotic unit (like inch)
3614 3614
 			{
3615 3615
 				//print $line->volume."x".$line->volume_units."x".($line->volume_units < 50)."x".$volumeUnit;
3616
-				$trueVolumeUnit=pow(10, $volumeUnit);
3616
+				$trueVolumeUnit = pow(10, $volumeUnit);
3617 3617
 				//print $line->volume;
3618 3618
 				$totalVolume += $volume * $qty * $trueVolumeUnit;
3619 3619
 			}
3620 3620
 			else
3621 3621
 			{
3622
-				$totalVolume += $volume * $qty;   // This may be wrong if we mix different units
3622
+				$totalVolume += $volume * $qty; // This may be wrong if we mix different units
3623 3623
 			}
3624 3624
 		}
3625 3625
 
@@ -3636,17 +3636,17 @@  discard block
 block discarded – undo
3636 3636
 	{
3637 3637
 		$this->db->begin();
3638 3638
 
3639
-		$extraparams = (! empty($this->extraparams) ? json_encode($this->extraparams) : null);
3639
+		$extraparams = (!empty($this->extraparams) ? json_encode($this->extraparams) : null);
3640 3640
 
3641 3641
 		$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
3642
-		$sql.= " SET extraparams = ".(! empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
3643
-		$sql.= " WHERE rowid = ".$this->id;
3642
+		$sql .= " SET extraparams = ".(!empty($extraparams) ? "'".$this->db->escape($extraparams)."'" : "null");
3643
+		$sql .= " WHERE rowid = ".$this->id;
3644 3644
 
3645 3645
 		dol_syslog(get_class($this)."::setExtraParameters", LOG_DEBUG);
3646 3646
 		$resql = $this->db->query($sql);
3647
-		if (! $resql)
3647
+		if (!$resql)
3648 3648
 		{
3649
-			$this->error=$this->db->lasterror();
3649
+			$this->error = $this->db->lasterror();
3650 3650
 			$this->db->rollback();
3651 3651
 			return -1;
3652 3652
 		}
@@ -3681,7 +3681,7 @@  discard block
 block discarded – undo
3681 3681
 			}
3682 3682
 		}
3683 3683
 
3684
-		$out .= (($res->code && $this->location_incoterms)?' - ':'').$this->location_incoterms;
3684
+		$out .= (($res->code && $this->location_incoterms) ? ' - ' : '').$this->location_incoterms;
3685 3685
 
3686 3686
 		return $out;
3687 3687
 	}
@@ -3727,11 +3727,11 @@  discard block
 block discarded – undo
3727 3727
 		if ($this->id && $this->table_element)
3728 3728
 		{
3729 3729
 			$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
3730
-			$sql.= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
3731
-			$sql.= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null");
3732
-			$sql.= " WHERE rowid = " . $this->id;
3730
+			$sql .= " SET fk_incoterms = ".($id_incoterm > 0 ? $id_incoterm : "null");
3731
+			$sql .= ", location_incoterms = ".($id_incoterm > 0 ? "'".$this->db->escape($location)."'" : "null");
3732
+			$sql .= " WHERE rowid = ".$this->id;
3733 3733
 			dol_syslog(get_class($this).'::setIncoterms', LOG_DEBUG);
3734
-			$resql=$this->db->query($sql);
3734
+			$resql = $this->db->query($sql);
3735 3735
 			if ($resql)
3736 3736
 			{
3737 3737
 				$this->fk_incoterms = $id_incoterm;
@@ -3772,24 +3772,24 @@  discard block
 block discarded – undo
3772 3772
 	 */
3773 3773
 	function formAddObjectLine($dateSelector, $seller, $buyer)
3774 3774
 	{
3775
-		global $conf,$user,$langs,$object,$hookmanager;
3776
-		global $form,$bcnd,$var;
3775
+		global $conf, $user, $langs, $object, $hookmanager;
3776
+		global $form, $bcnd, $var;
3777 3777
 
3778 3778
 		// Line extrafield
3779 3779
 		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
3780 3780
 		$extrafieldsline = new ExtraFields($this->db);
3781
-		$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
3781
+		$extralabelslines = $extrafieldsline->fetch_name_optionals_label($this->table_element_line);
3782 3782
 
3783 3783
 		// Output template part (modules that overwrite templates must declare this into descriptor)
3784 3784
 		// Use global variables + $dateSelector + $seller and $buyer
3785
-		$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
3786
-		foreach($dirtpls as $reldir)
3785
+		$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
3786
+		foreach ($dirtpls as $reldir)
3787 3787
 		{
3788 3788
 			$tpl = dol_buildpath($reldir.'/objectline_create.tpl.php');
3789 3789
 			if (empty($conf->file->strict_mode)) {
3790
-				$res=@include $tpl;
3790
+				$res = @include $tpl;
3791 3791
 			} else {
3792
-				$res=include $tpl; // for debug
3792
+				$res = include $tpl; // for debug
3793 3793
 			}
3794 3794
 			if ($res) break;
3795 3795
 		}
@@ -3813,24 +3813,24 @@  discard block
 block discarded – undo
3813 3813
 	 *	@param  int	    	$dateSelector      	1=Show also date range input fields
3814 3814
 	 *	@return	void
3815 3815
 	 */
3816
-	function printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0)
3816
+	function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0)
3817 3817
 	{
3818 3818
 		global $conf, $hookmanager, $langs, $user;
3819 3819
 		// TODO We should not use global var for this !
3820 3820
 		global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove, $outputalsopricetotalwithtax;
3821 3821
 
3822 3822
 		// Define usemargins
3823
-		$usemargins=0;
3824
-		if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1;
3823
+		$usemargins = 0;
3824
+		if (!empty($conf->margin->enabled) && !empty($this->element) && in_array($this->element, array('facture', 'propal', 'commande'))) $usemargins = 1;
3825 3825
 
3826 3826
 		$num = count($this->lines);
3827 3827
 
3828 3828
 		// Line extrafield
3829 3829
 		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
3830 3830
 		$extrafieldsline = new ExtraFields($this->db);
3831
-		$extralabelslines=$extrafieldsline->fetch_name_optionals_label($this->table_element_line);
3831
+		$extralabelslines = $extrafieldsline->fetch_name_optionals_label($this->table_element_line);
3832 3832
 
3833
-		$parameters = array('num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
3833
+		$parameters = array('num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
3834 3834
 		$reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
3835 3835
 		if (empty($reshook))
3836 3836
 		{
@@ -3840,7 +3840,7 @@  discard block
 block discarded – undo
3840 3840
 			print '<tr class="liste_titre nodrag nodrop">';
3841 3841
 
3842 3842
 			// Adds a line numbering column
3843
-			if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print '<td class="linecolnum" align="center" width="5">&nbsp;</td>';
3843
+			if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print '<td class="linecolnum" align="center" width="5">&nbsp;</td>';
3844 3844
 
3845 3845
 			// Description
3846 3846
 			print '<td class="linecoldescription">'.$langs->trans('Description').'</td>';
@@ -3864,7 +3864,7 @@  discard block
 block discarded – undo
3864 3864
 			// Qty
3865 3865
 			print '<td class="linecolqty" align="right">'.$langs->trans('Qty').'</td>';
3866 3866
 
3867
-			if($conf->global->PRODUCT_USE_UNITS)
3867
+			if ($conf->global->PRODUCT_USE_UNITS)
3868 3868
 			{
3869 3869
 				print '<td class="linecoluseunit" align="left">'.$langs->trans('Unit').'</td>';
3870 3870
 			}
@@ -3873,10 +3873,10 @@  discard block
 block discarded – undo
3873 3873
 			print '<td class="linecoldiscount" align="right">'.$langs->trans('ReductionShort').'</td>';
3874 3874
 
3875 3875
 			if ($this->situation_cycle_ref) {
3876
-				print '<td class="linecolcycleref" align="right">' . $langs->trans('Progress') . '</td>';
3876
+				print '<td class="linecolcycleref" align="right">'.$langs->trans('Progress').'</td>';
3877 3877
 			}
3878 3878
 
3879
-			if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
3879
+			if ($usemargins && !empty($conf->margin->enabled) && empty($user->societe_id))
3880 3880
 			{
3881 3881
 				if (!empty($user->rights->margins->creer))
3882 3882
 				{
@@ -3886,9 +3886,9 @@  discard block
 block discarded – undo
3886 3886
 						print '<td class="linecolmargin1 margininfos" align="right" width="80">'.$langs->trans('CostPrice').'</td>';
3887 3887
 				}
3888 3888
 
3889
-				if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
3889
+				if (!empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous)
3890 3890
 					print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarginRate').'</td>';
3891
-				if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous)
3891
+				if (!empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous)
3892 3892
 					print '<td class="linecolmargin2 margininfos" align="right" width="50">'.$langs->trans('MarkRate').'</td>';
3893 3893
 			}
3894 3894
 
@@ -3900,13 +3900,13 @@  discard block
 block discarded – undo
3900 3900
 
3901 3901
 			if ($outputalsopricetotalwithtax) print '<td align="right" width="80">'.$langs->trans('TotalTTCShort').'</td>';
3902 3902
 
3903
-			print '<td class="linecoledit"></td>';  // No width to allow autodim
3903
+			print '<td class="linecoledit"></td>'; // No width to allow autodim
3904 3904
 
3905 3905
 			print '<td class="linecoldelete" width="10"></td>';
3906 3906
 
3907 3907
 			print '<td class="linecolmove" width="10"></td>';
3908 3908
 
3909
-			if($action == 'selectlines')
3909
+			if ($action == 'selectlines')
3910 3910
 			{
3911 3911
 			    print '<td class="linecolcheckall" align="center">';
3912 3912
 			    print '<input type="checkbox" class="linecheckboxtoggle" />';
@@ -3919,7 +3919,7 @@  discard block
 block discarded – undo
3919 3919
 		}
3920 3920
 
3921 3921
 		$var = true;
3922
-		$i	 = 0;
3922
+		$i = 0;
3923 3923
 
3924 3924
 		print "<tbody>\n";
3925 3925
 		foreach ($this->lines as $line)
@@ -3932,18 +3932,18 @@  discard block
 block discarded – undo
3932 3932
 			{
3933 3933
 				if (empty($line->fk_parent_line))
3934 3934
 				{
3935
-					$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
3936
-					$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
3935
+					$parameters = array('line'=>$line, 'var'=>$var, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline);
3936
+					$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
3937 3937
 				}
3938 3938
 				else
3939 3939
 				{
3940
-					$parameters = array('line'=>$line,'var'=>$var,'num'=>$num,'i'=>$i,'dateSelector'=>$dateSelector,'seller'=>$seller,'buyer'=>$buyer,'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline, 'fk_parent_line'=>$line->fk_parent_line);
3941
-					$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
3940
+					$parameters = array('line'=>$line, 'var'=>$var, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'extrafieldsline'=>$extrafieldsline, 'fk_parent_line'=>$line->fk_parent_line);
3941
+					$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
3942 3942
 				}
3943 3943
 			}
3944 3944
 			if (empty($reshook))
3945 3945
 			{
3946
-				$this->printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected,$extrafieldsline);
3946
+				$this->printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected, $extrafieldsline);
3947 3947
 			}
3948 3948
 
3949 3949
 			$i++;
@@ -3967,23 +3967,23 @@  discard block
 block discarded – undo
3967 3967
 	 *  @param  int			$extrafieldsline	Object of extrafield line attribute
3968 3968
 	 *	@return	void
3969 3969
 	 */
3970
-	function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
3970
+	function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0)
3971 3971
 	{
3972
-		global $conf,$langs,$user,$object,$hookmanager;
3973
-		global $form,$bc,$bcdd;
3974
-		global $object_rights, $disableedit, $disablemove, $disableremove;   // TODO We should not use global var for this !
3972
+		global $conf, $langs, $user, $object, $hookmanager;
3973
+		global $form, $bc, $bcdd;
3974
+		global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
3975 3975
 
3976 3976
 		$object_rights = $this->getRights();
3977 3977
 
3978
-		$element=$this->element;
3978
+		$element = $this->element;
3979 3979
 
3980
-		$text=''; $description=''; $type=0;
3980
+		$text = ''; $description = ''; $type = 0;
3981 3981
 
3982 3982
 		// Show product and description
3983
-		$type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type);
3983
+		$type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type);
3984 3984
 		// Try to enhance type detection using date_start and date_end for free lines where type was not saved.
3985
-		if (! empty($line->date_start)) $type=1; // deprecated
3986
-		if (! empty($line->date_end)) $type=1; // deprecated
3985
+		if (!empty($line->date_start)) $type = 1; // deprecated
3986
+		if (!empty($line->date_end)) $type = 1; // deprecated
3987 3987
 
3988 3988
 		// Ligne en mode visu
3989 3989
 		if ($action != 'editline' || $selected != $line->id)
@@ -3996,14 +3996,14 @@  discard block
 block discarded – undo
3996 3996
 
3997 3997
 				$product_static->ref = $line->ref; //can change ref in hook
3998 3998
 				$product_static->label = $line->label; //can change label in hook
3999
-				$text=$product_static->getNomUrl(1);
3999
+				$text = $product_static->getNomUrl(1);
4000 4000
 
4001 4001
 				// Define output language and label
4002
-				if (! empty($conf->global->MAIN_MULTILANGS))
4002
+				if (!empty($conf->global->MAIN_MULTILANGS))
4003 4003
 				{
4004
-					if (! is_object($this->thirdparty))
4004
+					if (!is_object($this->thirdparty))
4005 4005
 					{
4006
-						dol_print_error('','Error: Method printObjectLine was called on an object and object->fetch_thirdparty was not done before');
4006
+						dol_print_error('', 'Error: Method printObjectLine was called on an object and object->fetch_thirdparty was not done before');
4007 4007
 						return;
4008 4008
 					}
4009 4009
 
@@ -4011,38 +4011,38 @@  discard block
 block discarded – undo
4011 4011
 					$prod->fetch($line->fk_product);
4012 4012
 
4013 4013
 					$outputlangs = $langs;
4014
-					$newlang='';
4015
-					if (empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
4016
-					if (! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang)) $newlang=$this->thirdparty->default_lang;		// For language to language of customer
4017
-					if (! empty($newlang))
4014
+					$newlang = '';
4015
+					if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
4016
+					if (!empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE) && empty($newlang)) $newlang = $this->thirdparty->default_lang; // For language to language of customer
4017
+					if (!empty($newlang))
4018 4018
 					{
4019
-						$outputlangs = new Translate("",$conf);
4019
+						$outputlangs = new Translate("", $conf);
4020 4020
 						$outputlangs->setDefaultLang($newlang);
4021 4021
 					}
4022 4022
 
4023
-					$label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label;
4023
+					$label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label;
4024 4024
 				}
4025 4025
 				else
4026 4026
 				{
4027 4027
 					$label = $line->product_label;
4028 4028
 				}
4029 4029
 
4030
-				$text.= ' - '.(! empty($line->label)?$line->label:$label);
4031
-				$description.=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($line->description));	// Description is what to show on popup. We shown nothing if already into desc.
4030
+				$text .= ' - '.(!empty($line->label) ? $line->label : $label);
4031
+				$description .= (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($line->description)); // Description is what to show on popup. We shown nothing if already into desc.
4032 4032
 			}
4033 4033
 
4034
-			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
4034
+			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU');
4035 4035
 
4036 4036
 			// Output template part (modules that overwrite templates must declare this into descriptor)
4037 4037
 			// Use global variables + $dateSelector + $seller and $buyer
4038
-			$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
4039
-			foreach($dirtpls as $reldir)
4038
+			$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
4039
+			foreach ($dirtpls as $reldir)
4040 4040
 			{
4041 4041
 				$tpl = dol_buildpath($reldir.'/objectline_view.tpl.php');
4042 4042
 				if (empty($conf->file->strict_mode)) {
4043
-					$res=@include $tpl;
4043
+					$res = @include $tpl;
4044 4044
 				} else {
4045
-					$res=include $tpl; // for debug
4045
+					$res = include $tpl; // for debug
4046 4046
 				}
4047 4047
 				if ($res) break;
4048 4048
 			}
@@ -4051,21 +4051,21 @@  discard block
 block discarded – undo
4051 4051
 		// Ligne en mode update
4052 4052
 		if ($this->statut == 0 && $action == 'editline' && $selected == $line->id)
4053 4053
 		{
4054
-			$label = (! empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : ''));
4055
-			$placeholder=' placeholder="'.$langs->trans("Label").'"';
4054
+			$label = (!empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : ''));
4055
+			$placeholder = ' placeholder="'.$langs->trans("Label").'"';
4056 4056
 
4057
-			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx/100)), 'MU');
4057
+			$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU');
4058 4058
 
4059 4059
 			// Output template part (modules that overwrite templates must declare this into descriptor)
4060 4060
 			// Use global variables + $dateSelector + $seller and $buyer
4061
-			$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
4062
-			foreach($dirtpls as $reldir)
4061
+			$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
4062
+			foreach ($dirtpls as $reldir)
4063 4063
 			{
4064 4064
 				$tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php');
4065 4065
 				if (empty($conf->file->strict_mode)) {
4066
-					$res=@include $tpl;
4066
+					$res = @include $tpl;
4067 4067
 				} else {
4068
-					$res=include $tpl; // for debug
4068
+					$res = include $tpl; // for debug
4069 4069
 				}
4070 4070
 				if ($res) break;
4071 4071
 			}
@@ -4085,7 +4085,7 @@  discard block
 block discarded – undo
4085 4085
 	 *	@param	string		$restrictlist		''=All lines, 'services'=Restrict to services only
4086 4086
 	 *  @return	void
4087 4087
 	 */
4088
-	function printOriginLinesList($restrictlist='')
4088
+	function printOriginLinesList($restrictlist = '')
4089 4089
 	{
4090 4090
 		global $langs, $hookmanager, $conf;
4091 4091
 
@@ -4096,26 +4096,26 @@  discard block
 block discarded – undo
4096 4096
 		print '<td align="right">'.$langs->trans('PriceUHT').'</td>';
4097 4097
 		if (!empty($conf->multicurrency->enabled)) print '<td align="right">'.$langs->trans('PriceUHTCurrency').'</td>';
4098 4098
 		print '<td align="right">'.$langs->trans('Qty').'</td>';
4099
-		if($conf->global->PRODUCT_USE_UNITS)
4099
+		if ($conf->global->PRODUCT_USE_UNITS)
4100 4100
 		{
4101 4101
 			print '<td align="left">'.$langs->trans('Unit').'</td>';
4102 4102
 		}
4103 4103
 		print '<td align="right">'.$langs->trans('ReductionShort').'</td></tr>';
4104 4104
 
4105 4105
 		$var = true;
4106
-		$i	 = 0;
4106
+		$i = 0;
4107 4107
 
4108
-		if (! empty($this->lines))
4108
+		if (!empty($this->lines))
4109 4109
 		{
4110 4110
 			foreach ($this->lines as $line)
4111 4111
 			{
4112
-				if (is_object($hookmanager) && (($line->product_type == 9 && ! empty($line->special_code)) || ! empty($line->fk_parent_line)))
4112
+				if (is_object($hookmanager) && (($line->product_type == 9 && !empty($line->special_code)) || !empty($line->fk_parent_line)))
4113 4113
 				{
4114 4114
 					if (empty($line->fk_parent_line))
4115 4115
 					{
4116
-						$parameters=array('line'=>$line,'var'=>$var,'i'=>$i);
4117
-						$action='';
4118
-						$hookmanager->executeHooks('printOriginObjectLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
4116
+						$parameters = array('line'=>$line, 'var'=>$var, 'i'=>$i);
4117
+						$action = '';
4118
+						$hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
4119 4119
 					}
4120 4120
 				}
4121 4121
 				else
@@ -4139,103 +4139,103 @@  discard block
 block discarded – undo
4139 4139
 	 *	@param	string				$restrictlist		''=All lines, 'services'=Restrict to services only (strike line if not)
4140 4140
 	 * 	@return	void
4141 4141
 	 */
4142
-	function printOriginLine($line, $var, $restrictlist='')
4142
+	function printOriginLine($line, $var, $restrictlist = '')
4143 4143
 	{
4144 4144
 		global $langs, $conf;
4145 4145
 
4146 4146
 		//var_dump($line);
4147 4147
 		if (!empty($line->date_start))
4148 4148
 		{
4149
-			$date_start=$line->date_start;
4149
+			$date_start = $line->date_start;
4150 4150
 		}
4151 4151
 		else
4152 4152
 		{
4153
-			$date_start=$line->date_debut_prevue;
4154
-			if ($line->date_debut_reel) $date_start=$line->date_debut_reel;
4153
+			$date_start = $line->date_debut_prevue;
4154
+			if ($line->date_debut_reel) $date_start = $line->date_debut_reel;
4155 4155
 		}
4156 4156
 		if (!empty($line->date_end))
4157 4157
 		{
4158
-			$date_end=$line->date_end;
4158
+			$date_end = $line->date_end;
4159 4159
 		}
4160 4160
 		else
4161 4161
 		{
4162
-			$date_end=$line->date_fin_prevue;
4163
-			if ($line->date_fin_reel) $date_end=$line->date_fin_reel;
4162
+			$date_end = $line->date_fin_prevue;
4163
+			if ($line->date_fin_reel) $date_end = $line->date_fin_reel;
4164 4164
 		}
4165 4165
 
4166 4166
 		$this->tpl['label'] = '';
4167
-		if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow');
4167
+		if (!empty($line->fk_parent_line)) $this->tpl['label'] .= img_picto('', 'rightarrow');
4168 4168
 
4169 4169
 		if (($line->info_bits & 2) == 2)  // TODO Not sure this is used for source object
4170 4170
 		{
4171
-			$discount=new DiscountAbsolute($this->db);
4171
+			$discount = new DiscountAbsolute($this->db);
4172 4172
 			$discount->fk_soc = $this->socid;
4173
-			$this->tpl['label'].= $discount->getNomUrl(0,'discount');
4173
+			$this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
4174 4174
 		}
4175
-		else if (! empty($line->fk_product))
4175
+		else if (!empty($line->fk_product))
4176 4176
 		{
4177 4177
 			$productstatic = new Product($this->db);
4178 4178
 			$productstatic->id = $line->fk_product;
4179 4179
 			$productstatic->ref = $line->ref;
4180 4180
 			$productstatic->type = $line->fk_product_type;
4181
-            if(empty($productstatic->ref)){
4181
+            if (empty($productstatic->ref)) {
4182 4182
 				$line->fetch_product();
4183 4183
 				$productstatic = $line->product;
4184 4184
 			}
4185 4185
 			
4186
-			$this->tpl['label'].= $productstatic->getNomUrl(1);
4187
-			$this->tpl['label'].= ' - '.(! empty($line->label)?$line->label:$line->product_label);
4186
+			$this->tpl['label'] .= $productstatic->getNomUrl(1);
4187
+			$this->tpl['label'] .= ' - '.(!empty($line->label) ? $line->label : $line->product_label);
4188 4188
 			// Dates
4189 4189
 			if ($line->product_type == 1 && ($date_start || $date_end))
4190 4190
 			{
4191
-				$this->tpl['label'].= get_date_range($date_start,$date_end);
4191
+				$this->tpl['label'] .= get_date_range($date_start, $date_end);
4192 4192
 			}
4193 4193
 		}
4194 4194
 		else
4195 4195
 		{
4196
-			$this->tpl['label'].= ($line->product_type == -1 ? '&nbsp;' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product')));
4196
+			$this->tpl['label'] .= ($line->product_type == -1 ? '&nbsp;' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product')));
4197 4197
 			if (!empty($line->desc)) {
4198
-				$this->tpl['label'].=$line->desc;
4199
-			}else {
4200
-				$this->tpl['label'].= ($line->label ? '&nbsp;'.$line->label : '');
4198
+				$this->tpl['label'] .= $line->desc;
4199
+			} else {
4200
+				$this->tpl['label'] .= ($line->label ? '&nbsp;'.$line->label : '');
4201 4201
 			}
4202 4202
 			
4203 4203
 			// Dates
4204 4204
 			if ($line->product_type == 1 && ($date_start || $date_end))
4205 4205
 			{
4206
-				$this->tpl['label'].= get_date_range($date_start,$date_end);
4206
+				$this->tpl['label'] .= get_date_range($date_start, $date_end);
4207 4207
 			}
4208 4208
 		}
4209 4209
 
4210
-		if (! empty($line->desc))
4210
+		if (!empty($line->desc))
4211 4211
 		{
4212 4212
 			if ($line->desc == '(CREDIT_NOTE)')  // TODO Not sure this is used for source object
4213 4213
 			{
4214
-				$discount=new DiscountAbsolute($this->db);
4214
+				$discount = new DiscountAbsolute($this->db);
4215 4215
 				$discount->fetch($line->fk_remise_except);
4216
-				$this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0));
4216
+				$this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
4217 4217
 			}
4218 4218
 			elseif ($line->desc == '(DEPOSIT)')  // TODO Not sure this is used for source object
4219 4219
 			{
4220
-				$discount=new DiscountAbsolute($this->db);
4220
+				$discount = new DiscountAbsolute($this->db);
4221 4221
 				$discount->fetch($line->fk_remise_except);
4222
-				$this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0));
4222
+				$this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
4223 4223
 			}
4224 4224
 			elseif ($line->desc == '(EXCESS RECEIVED)')
4225 4225
 			{
4226
-				$discount=new DiscountAbsolute($this->db);
4226
+				$discount = new DiscountAbsolute($this->db);
4227 4227
 				$discount->fetch($line->fk_remise_except);
4228
-				$this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived",$discount->getNomUrl(0));
4228
+				$this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
4229 4229
 			}
4230 4230
 			elseif ($line->desc == '(EXCESS PAID)')
4231 4231
 			{
4232
-				$discount=new DiscountAbsolute($this->db);
4232
+				$discount = new DiscountAbsolute($this->db);
4233 4233
 				$discount->fetch($line->fk_remise_except);
4234
-				$this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid",$discount->getNomUrl(0));
4234
+				$this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
4235 4235
 			}
4236 4236
 			else
4237 4237
 			{
4238
-				$this->tpl['description'] = dol_trunc($line->desc,60);
4238
+				$this->tpl['description'] = dol_trunc($line->desc, 60);
4239 4239
 			}
4240 4240
 		}
4241 4241
 		else
@@ -4246,7 +4246,7 @@  discard block
 block discarded – undo
4246 4246
         // VAT Rate
4247 4247
         $this->tpl['vat_rate'] = vatrate($line->tva_tx, true);
4248 4248
         $this->tpl['vat_rate'] .= (($line->info_bits & 1) == 1) ? '*' : '';
4249
-        if (! empty($line->vat_src_code) && ! preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'].=' ('.$line->vat_src_code.')';
4249
+        if (!empty($line->vat_src_code) && !preg_match('/\(/', $this->tpl['vat_rate'])) $this->tpl['vat_rate'] .= ' ('.$line->vat_src_code.')';
4250 4250
 
4251 4251
 		$this->tpl['price'] = price($line->subprice);
4252 4252
 		$this->tpl['multicurrency_price'] = price($line->multicurrency_subprice);
@@ -4255,19 +4255,19 @@  discard block
 block discarded – undo
4255 4255
 		$this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : '&nbsp;';
4256 4256
 
4257 4257
 		// Is the line strike or not
4258
-		$this->tpl['strike']=0;
4259
-		if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike']=1;
4258
+		$this->tpl['strike'] = 0;
4259
+		if ($restrictlist == 'services' && $line->product_type != Product::TYPE_SERVICE) $this->tpl['strike'] = 1;
4260 4260
 
4261 4261
 		// Output template part (modules that overwrite templates must declare this into descriptor)
4262 4262
 		// Use global variables + $dateSelector + $seller and $buyer
4263
-		$dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl'));
4264
-		foreach($dirtpls as $reldir)
4263
+		$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
4264
+		foreach ($dirtpls as $reldir)
4265 4265
 		{
4266 4266
 			$tpl = dol_buildpath($reldir.'/originproductline.tpl.php');
4267 4267
 			if (empty($conf->file->strict_mode)) {
4268
-				$res=@include $tpl;
4268
+				$res = @include $tpl;
4269 4269
 			} else {
4270
-				$res=include $tpl; // for debug
4270
+				$res = include $tpl; // for debug
4271 4271
 			}
4272 4272
 			if ($res) break;
4273 4273
 		}
@@ -4285,26 +4285,26 @@  discard block
 block discarded – undo
4285 4285
 	 *	@param		int		$mandatory			Mandatory or not
4286 4286
 	 *	@return		int							<=0 if KO, >0 if OK
4287 4287
 	 */
4288
-	function add_element_resource($resource_id, $resource_type, $busy=0, $mandatory=0)
4288
+	function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0)
4289 4289
 	{
4290 4290
         // phpcs:enable
4291 4291
 		$this->db->begin();
4292 4292
 
4293 4293
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources (";
4294
-		$sql.= "resource_id";
4295
-		$sql.= ", resource_type";
4296
-		$sql.= ", element_id";
4297
-		$sql.= ", element_type";
4298
-		$sql.= ", busy";
4299
-		$sql.= ", mandatory";
4300
-		$sql.= ") VALUES (";
4301
-		$sql.= $resource_id;
4302
-		$sql.= ", '".$this->db->escape($resource_type)."'";
4303
-		$sql.= ", '".$this->db->escape($this->id)."'";
4304
-		$sql.= ", '".$this->db->escape($this->element)."'";
4305
-		$sql.= ", '".$this->db->escape($busy)."'";
4306
-		$sql.= ", '".$this->db->escape($mandatory)."'";
4307
-		$sql.= ")";
4294
+		$sql .= "resource_id";
4295
+		$sql .= ", resource_type";
4296
+		$sql .= ", element_id";
4297
+		$sql .= ", element_type";
4298
+		$sql .= ", busy";
4299
+		$sql .= ", mandatory";
4300
+		$sql .= ") VALUES (";
4301
+		$sql .= $resource_id;
4302
+		$sql .= ", '".$this->db->escape($resource_type)."'";
4303
+		$sql .= ", '".$this->db->escape($this->id)."'";
4304
+		$sql .= ", '".$this->db->escape($this->element)."'";
4305
+		$sql .= ", '".$this->db->escape($busy)."'";
4306
+		$sql .= ", '".$this->db->escape($mandatory)."'";
4307
+		$sql .= ")";
4308 4308
 
4309 4309
 		dol_syslog(get_class($this)."::add_element_resource", LOG_DEBUG);
4310 4310
 		if ($this->db->query($sql))
@@ -4314,7 +4314,7 @@  discard block
 block discarded – undo
4314 4314
 		}
4315 4315
 		else
4316 4316
 		{
4317
-			$this->error=$this->db->lasterror();
4317
+			$this->error = $this->db->lasterror();
4318 4318
 			$this->db->rollback();
4319 4319
 			return  0;
4320 4320
 		}
@@ -4329,7 +4329,7 @@  discard block
 block discarded – undo
4329 4329
 	 *    @param	int		$notrigger		Disable all triggers
4330 4330
 	 *    @return   int						>0 if OK, <0 if KO
4331 4331
 	 */
4332
-	function delete_resource($rowid, $element, $notrigger=0)
4332
+	function delete_resource($rowid, $element, $notrigger = 0)
4333 4333
 	{
4334 4334
         // phpcs:enable
4335 4335
 		global $user;
@@ -4337,22 +4337,22 @@  discard block
 block discarded – undo
4337 4337
 		$this->db->begin();
4338 4338
 
4339 4339
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
4340
-		$sql.= " WHERE rowid=".$rowid;
4340
+		$sql .= " WHERE rowid=".$rowid;
4341 4341
 
4342 4342
 		dol_syslog(get_class($this)."::delete_resource", LOG_DEBUG);
4343 4343
 
4344
-		$resql=$this->db->query($sql);
4345
-		if (! $resql)
4344
+		$resql = $this->db->query($sql);
4345
+		if (!$resql)
4346 4346
 		{
4347
-			$this->error=$this->db->lasterror();
4347
+			$this->error = $this->db->lasterror();
4348 4348
 			$this->db->rollback();
4349 4349
 			return -1;
4350 4350
 		}
4351 4351
 		else
4352 4352
 		{
4353
-			if (! $notrigger)
4353
+			if (!$notrigger)
4354 4354
 			{
4355
-				$result=$this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user);
4355
+				$result = $this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user);
4356 4356
 				if ($result < 0) { $this->db->rollback(); return -1; }
4357 4357
 			}
4358 4358
 			$this->db->commit();
@@ -4371,8 +4371,8 @@  discard block
 block discarded – undo
4371 4371
 		// Force a copy of this->lines, otherwise it will point to same object.
4372 4372
 		if (isset($this->lines) && is_array($this->lines))
4373 4373
 		{
4374
-			$nboflines=count($this->lines);
4375
-			for($i=0; $i < $nboflines; $i++)
4374
+			$nboflines = count($this->lines);
4375
+			for ($i = 0; $i < $nboflines; $i++)
4376 4376
 			{
4377 4377
 				$this->lines[$i] = clone $this->lines[$i];
4378 4378
 			}
@@ -4392,43 +4392,43 @@  discard block
 block discarded – undo
4392 4392
 	 * @return 	int 						>0 if OK, <0 if KO
4393 4393
 	 * @see	addFileIntoDatabaseIndex
4394 4394
 	 */
4395
-	protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
4395
+	protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams = null)
4396 4396
 	{
4397 4397
 		global $conf, $langs, $user;
4398 4398
 
4399
-		$srctemplatepath='';
4399
+		$srctemplatepath = '';
4400 4400
 
4401 4401
 		// Increase limit for PDF build
4402
-		$err=error_reporting();
4402
+		$err = error_reporting();
4403 4403
 		error_reporting(0);
4404 4404
 		@set_time_limit(120);
4405 4405
 		error_reporting($err);
4406 4406
 
4407 4407
 		// If selected model is a filename template (then $modele="modelname" or "modelname:filename")
4408
-		$tmp=explode(':',$modele,2);
4409
-		if (! empty($tmp[1]))
4408
+		$tmp = explode(':', $modele, 2);
4409
+		if (!empty($tmp[1]))
4410 4410
 		{
4411
-			$modele=$tmp[0];
4412
-			$srctemplatepath=$tmp[1];
4411
+			$modele = $tmp[0];
4412
+			$srctemplatepath = $tmp[1];
4413 4413
 		}
4414 4414
 
4415 4415
 		// Search template files
4416
-		$file=''; $classname=''; $filefound=0;
4417
-		$dirmodels=array('/');
4418
-		if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
4419
-		foreach($dirmodels as $reldir)
4416
+		$file = ''; $classname = ''; $filefound = 0;
4417
+		$dirmodels = array('/');
4418
+		if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
4419
+		foreach ($dirmodels as $reldir)
4420 4420
 		{
4421
-			foreach(array('doc','pdf') as $prefix)
4421
+			foreach (array('doc', 'pdf') as $prefix)
4422 4422
 			{
4423
-				if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php";     // Member module use prefix_module.class.php
4423
+				if (in_array(get_class($this), array('Adherent'))) $file = $prefix."_".$modele.".class.php"; // Member module use prefix_module.class.php
4424 4424
 				else $file = $prefix."_".$modele.".modules.php";
4425 4425
 
4426 4426
 				// On verifie l'emplacement du modele
4427
-				$file=dol_buildpath($reldir.$modelspath.$file,0);
4427
+				$file = dol_buildpath($reldir.$modelspath.$file, 0);
4428 4428
 				if (file_exists($file))
4429 4429
 				{
4430
-					$filefound=1;
4431
-					$classname=$prefix.'_'.$modele;
4430
+					$filefound = 1;
4431
+					$classname = $prefix.'_'.$modele;
4432 4432
 					break;
4433 4433
 				}
4434 4434
 			}
@@ -4438,7 +4438,7 @@  discard block
 block discarded – undo
4438 4438
 		// If generator was found
4439 4439
 		if ($filefound)
4440 4440
 		{
4441
-			global $db;  // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db
4441
+			global $db; // Required to solve a conception default in commonstickergenerator.class.php making an include of code using $db
4442 4442
 
4443 4443
 			require_once $file;
4444 4444
 
@@ -4447,32 +4447,32 @@  discard block
 block discarded – undo
4447 4447
 			// If generator is ODT, we must have srctemplatepath defined, if not we set it.
4448 4448
 			if ($obj->type == 'odt' && empty($srctemplatepath))
4449 4449
 			{
4450
-				$varfortemplatedir=$obj->scandir;
4451
-				if ($varfortemplatedir && ! empty($conf->global->$varfortemplatedir))
4450
+				$varfortemplatedir = $obj->scandir;
4451
+				if ($varfortemplatedir && !empty($conf->global->$varfortemplatedir))
4452 4452
 				{
4453
-					$dirtoscan=$conf->global->$varfortemplatedir;
4453
+					$dirtoscan = $conf->global->$varfortemplatedir;
4454 4454
 
4455
-					$listoffiles=array();
4455
+					$listoffiles = array();
4456 4456
 
4457 4457
 					// Now we add first model found in directories scanned
4458
-					$listofdir=explode(',',$dirtoscan);
4459
-					foreach($listofdir as $key => $tmpdir)
4458
+					$listofdir = explode(',', $dirtoscan);
4459
+					foreach ($listofdir as $key => $tmpdir)
4460 4460
 					{
4461
-						$tmpdir=trim($tmpdir);
4462
-						$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
4463
-						if (! $tmpdir) { unset($listofdir[$key]); continue; }
4461
+						$tmpdir = trim($tmpdir);
4462
+						$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
4463
+						if (!$tmpdir) { unset($listofdir[$key]); continue; }
4464 4464
 						if (is_dir($tmpdir))
4465 4465
 						{
4466
-							$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.od(s|t)$','','name',SORT_ASC,0);
4467
-							if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
4466
+							$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.od(s|t)$', '', 'name', SORT_ASC, 0);
4467
+							if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
4468 4468
 						}
4469 4469
 					}
4470 4470
 
4471 4471
 					if (count($listoffiles))
4472 4472
 					{
4473
-						foreach($listoffiles as $record)
4473
+						foreach ($listoffiles as $record)
4474 4474
 						{
4475
-							$srctemplatepath=$record['fullname'];
4475
+							$srctemplatepath = $record['fullname'];
4476 4476
 							break;
4477 4477
 						}
4478 4478
 					}
@@ -4480,27 +4480,27 @@  discard block
 block discarded – undo
4480 4480
 
4481 4481
 				if (empty($srctemplatepath))
4482 4482
 				{
4483
-					$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
4483
+					$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotDefined';
4484 4484
 					return -1;
4485 4485
 				}
4486 4486
 			}
4487 4487
 
4488
-			if ($obj->type == 'odt' && ! empty($srctemplatepath))
4488
+			if ($obj->type == 'odt' && !empty($srctemplatepath))
4489 4489
 			{
4490
-				if (! dol_is_file($srctemplatepath))
4490
+				if (!dol_is_file($srctemplatepath))
4491 4491
 				{
4492
-					$this->error='ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
4492
+					$this->error = 'ErrorGenerationAskedForOdtTemplateWithSrcFileNotFound';
4493 4493
 					return -1;
4494 4494
 				}
4495 4495
 			}
4496 4496
 
4497 4497
 			// We save charset_output to restore it because write_file can change it if needed for
4498 4498
 			// output format that does not support UTF8.
4499
-			$sav_charset_output=$outputlangs->charset_output;
4499
+			$sav_charset_output = $outputlangs->charset_output;
4500 4500
 
4501 4501
 			if (in_array(get_class($this), array('Adherent')))
4502 4502
 			{
4503
-				$arrayofrecords = array();   // The write_file of templates of adherent class need this var
4503
+				$arrayofrecords = array(); // The write_file of templates of adherent class need this var
4504 4504
 				$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
4505 4505
 			}
4506 4506
 			else
@@ -4511,41 +4511,41 @@  discard block
 block discarded – undo
4511 4511
 
4512 4512
 			if ($resultwritefile > 0)
4513 4513
 			{
4514
-				$outputlangs->charset_output=$sav_charset_output;
4514
+				$outputlangs->charset_output = $sav_charset_output;
4515 4515
 
4516 4516
 				// We delete old preview
4517 4517
 				require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
4518 4518
 				dol_delete_preview($this);
4519 4519
 
4520 4520
 				// Index file in database
4521
-				if (! empty($obj->result['fullpath']))
4521
+				if (!empty($obj->result['fullpath']))
4522 4522
 				{
4523 4523
 					$destfull = $obj->result['fullpath'];
4524 4524
 					$upload_dir = dirname($destfull);
4525 4525
 					$destfile = basename($destfull);
4526
-					$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
4526
+					$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $upload_dir);
4527 4527
 
4528
-					if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
4528
+					if (!preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir))     // If not a tmp dir
4529 4529
 					{
4530 4530
 						$filename = basename($destfile);
4531 4531
 						$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
4532 4532
 						$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
4533 4533
 
4534 4534
 						include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
4535
-						$ecmfile=new EcmFiles($this->db);
4536
-						$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
4535
+						$ecmfile = new EcmFiles($this->db);
4536
+						$result = $ecmfile->fetch(0, '', ($rel_dir ? $rel_dir.'/' : '').$filename);
4537 4537
 
4538 4538
 						// Set the public "share" key
4539 4539
 						$setsharekey = false;
4540 4540
 						if ($this->element == 'propal')
4541 4541
 						{
4542
-							$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL;	// Replace this with 1 when feature to make online signature is ok
4543
-							if ($useonlinesignature) $setsharekey=true;
4544
-							if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
4542
+							$useonlinesignature = $conf->global->MAIN_FEATURES_LEVEL; // Replace this with 1 when feature to make online signature is ok
4543
+							if ($useonlinesignature) $setsharekey = true;
4544
+							if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true;
4545 4545
 						}
4546
-						if ($this->element == 'commande'     && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD))        $setsharekey=true;
4547
-						if ($this->element == 'facture'      && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD))      $setsharekey=true;
4548
-						if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true;
4546
+						if ($this->element == 'commande' && !empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD))        $setsharekey = true;
4547
+						if ($this->element == 'facture' && !empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD))      $setsharekey = true;
4548
+						if ($this->element == 'bank_account' && !empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey = true;
4549 4549
 
4550 4550
 						if ($setsharekey)
4551 4551
 						{
@@ -4558,11 +4558,11 @@  discard block
 block discarded – undo
4558 4558
 
4559 4559
 						if ($result > 0)
4560 4560
 						{
4561
-							$ecmfile->label = md5_file(dol_osencode($destfull));	// hash of file content
4561
+							$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
4562 4562
 							$ecmfile->fullpath_orig = '';
4563 4563
 							$ecmfile->gen_or_uploaded = 'generated';
4564
-							$ecmfile->description = '';    // indexed content
4565
-							$ecmfile->keyword = '';        // keyword content
4564
+							$ecmfile->description = ''; // indexed content
4565
+							$ecmfile->keyword = ''; // keyword content
4566 4566
 							$result = $ecmfile->update($user);
4567 4567
 							if ($result < 0)
4568 4568
 							{
@@ -4574,11 +4574,11 @@  discard block
 block discarded – undo
4574 4574
 							$ecmfile->entity = $conf->entity;
4575 4575
 							$ecmfile->filepath = $rel_dir;
4576 4576
 							$ecmfile->filename = $filename;
4577
-							$ecmfile->label = md5_file(dol_osencode($destfull));	// hash of file content
4577
+							$ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
4578 4578
 							$ecmfile->fullpath_orig = '';
4579 4579
 							$ecmfile->gen_or_uploaded = 'generated';
4580
-							$ecmfile->description = '';    // indexed content
4581
-							$ecmfile->keyword = '';        // keyword content
4580
+							$ecmfile->description = ''; // indexed content
4581
+							$ecmfile->keyword = ''; // keyword content
4582 4582
 							$ecmfile->src_object_type = $this->table_element;
4583 4583
 							$ecmfile->src_object_id   = $this->id;
4584 4584
 
@@ -4595,14 +4595,14 @@  discard block
 block discarded – undo
4595 4595
 						//var_dump($obj->update_main_doc_field);exit;
4596 4596
 
4597 4597
 						// Update the last_main_doc field into main object (if documenent generator has property ->update_main_doc_field set)
4598
-						$update_main_doc_field=0;
4599
-						if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
4600
-						if ($update_main_doc_field && ! empty($this->table_element))
4598
+						$update_main_doc_field = 0;
4599
+						if (!empty($obj->update_main_doc_field)) $update_main_doc_field = 1;
4600
+						if ($update_main_doc_field && !empty($this->table_element))
4601 4601
 						{
4602 4602
 							$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".($ecmfile->filepath.'/'.$ecmfile->filename)."'";
4603
-							$sql.= ' WHERE rowid = '.$this->id;
4603
+							$sql .= ' WHERE rowid = '.$this->id;
4604 4604
 							$resql = $this->db->query($sql);
4605
-							if (! $resql) dol_print_error($this->db);
4605
+							if (!$resql) dol_print_error($this->db);
4606 4606
 						}
4607 4607
 					}
4608 4608
 				}
@@ -4618,15 +4618,15 @@  discard block
 block discarded – undo
4618 4618
 			}
4619 4619
 			else
4620 4620
 			{
4621
-				$outputlangs->charset_output=$sav_charset_output;
4621
+				$outputlangs->charset_output = $sav_charset_output;
4622 4622
 				dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
4623 4623
 				return -1;
4624 4624
 			}
4625 4625
 		}
4626 4626
 		else
4627 4627
 		{
4628
-			$this->error=$langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$file);
4629
-			dol_print_error('',$this->error);
4628
+			$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $file);
4629
+			dol_print_error('', $this->error);
4630 4630
 			return -1;
4631 4631
 		}
4632 4632
 	}
@@ -4642,9 +4642,9 @@  discard block
 block discarded – undo
4642 4642
 	{
4643 4643
 		global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality;
4644 4644
 
4645
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';		// This define also $maxwidthsmall, $quality, ...
4645
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ...
4646 4646
 
4647
-		$file_osencoded=dol_osencode($file);
4647
+		$file_osencoded = dol_osencode($file);
4648 4648
 		if (file_exists($file_osencoded))
4649 4649
 		{
4650 4650
 			// Create small thumbs for company (Ratio is near 16/9)
@@ -4674,7 +4674,7 @@  discard block
 block discarded – undo
4674 4674
 	 * @param   string              $alternatevalue     Alternate value to use
4675 4675
 	 * @return  string|string[]                         Default value (can be an array if the GETPOST return an array)
4676 4676
 	 **/
4677
-	function getDefaultCreateValueFor($fieldname, $alternatevalue=null)
4677
+	function getDefaultCreateValueFor($fieldname, $alternatevalue = null)
4678 4678
 	{
4679 4679
 		global $conf, $_POST;
4680 4680
 
@@ -4683,16 +4683,16 @@  discard block
 block discarded – undo
4683 4683
 
4684 4684
 		if (isset($alternatevalue)) return $alternatevalue;
4685 4685
 
4686
-		$newelement=$this->element;
4687
-		if ($newelement == 'facture') $newelement='invoice';
4688
-		if ($newelement == 'commande') $newelement='order';
4686
+		$newelement = $this->element;
4687
+		if ($newelement == 'facture') $newelement = 'invoice';
4688
+		if ($newelement == 'commande') $newelement = 'order';
4689 4689
 		if (empty($newelement))
4690 4690
 		{
4691 4691
 			dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING);
4692 4692
 			return '';
4693 4693
 		}
4694 4694
 
4695
-		$keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname);
4695
+		$keyforfieldname = strtoupper($newelement.'_DEFAULT_'.$fieldname);
4696 4696
 		//var_dump($keyforfieldname);
4697 4697
 		if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname;
4698 4698
 
@@ -4717,21 +4717,21 @@  discard block
 block discarded – undo
4717 4717
 	function call_trigger($trigger_name, $user)
4718 4718
 	{
4719 4719
         // phpcs:enable
4720
-		global $langs,$conf;
4720
+		global $langs, $conf;
4721 4721
 
4722
-		include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
4723
-		$interface=new Interfaces($this->db);
4724
-		$result=$interface->run_triggers($trigger_name,$this,$user,$langs,$conf);
4722
+		include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php';
4723
+		$interface = new Interfaces($this->db);
4724
+		$result = $interface->run_triggers($trigger_name, $this, $user, $langs, $conf);
4725 4725
 
4726 4726
 		if ($result < 0)
4727 4727
 		{
4728 4728
 			if (!empty($this->errors))
4729 4729
 			{
4730
-				$this->errors=array_unique(array_merge($this->errors,$interface->errors));   // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
4730
+				$this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
4731 4731
 			}
4732 4732
 			else
4733 4733
 			{
4734
-				$this->errors=$interface->errors;
4734
+				$this->errors = $interface->errors;
4735 4735
 			}
4736 4736
 		}
4737 4737
 		return $result;
@@ -4750,19 +4750,19 @@  discard block
 block discarded – undo
4750 4750
 	 *  @param  array	$optionsArray   Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters.
4751 4751
 	 *  @return	int						<0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded
4752 4752
 	 */
4753
-	function fetch_optionals($rowid=null, $optionsArray=null)
4753
+	function fetch_optionals($rowid = null, $optionsArray = null)
4754 4754
 	{
4755 4755
         // phpcs:enable
4756
-		if (empty($rowid)) $rowid=$this->id;
4756
+		if (empty($rowid)) $rowid = $this->id;
4757 4757
 
4758 4758
 		// To avoid SQL errors. Probably not the better solution though
4759 4759
 		if (!$this->table_element) {
4760 4760
 			return 0;
4761 4761
 		}
4762 4762
 
4763
-		$this->array_options=array();
4763
+		$this->array_options = array();
4764 4764
 
4765
-		if (! is_array($optionsArray))
4765
+		if (!is_array($optionsArray))
4766 4766
 		{
4767 4767
 			// If $extrafields is not a known object, we initialize it. Best practice is to have $extrafields defined into card.php or list.php page.
4768 4768
 			// TODO Use of existing $extrafield is not yet ready (must mutualize code that use extrafields in form first)
@@ -4778,7 +4778,7 @@  discard block
 block discarded – undo
4778 4778
 			{
4779 4779
 				$extrafields->fetch_name_optionals_label($this->table_element);
4780 4780
 			}
4781
-			$optionsArray = (! empty($extrafields->attributes[$this->table_element]['label'])?$extrafields->attributes[$this->table_element]['label']:null);
4781
+			$optionsArray = (!empty($extrafields->attributes[$this->table_element]['label']) ? $extrafields->attributes[$this->table_element]['label'] : null);
4782 4782
 		}
4783 4783
 		else
4784 4784
 		{
@@ -4797,18 +4797,18 @@  discard block
 block discarded – undo
4797 4797
 			{
4798 4798
 				if (empty($extrafields->attributes[$this->table_element]['type'][$name]) || $extrafields->attributes[$this->table_element]['type'][$name] != 'separate')
4799 4799
 				{
4800
-					$sql.= ", ".$name;
4800
+					$sql .= ", ".$name;
4801 4801
 				}
4802 4802
 			}
4803
-			$sql.= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields";
4804
-			$sql.= " WHERE fk_object = ".$rowid;
4803
+			$sql .= " FROM ".MAIN_DB_PREFIX.$table_element."_extrafields";
4804
+			$sql .= " WHERE fk_object = ".$rowid;
4805 4805
 
4806 4806
 			//dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG);		// Too verbose
4807
-			$resql=$this->db->query($sql);
4807
+			$resql = $this->db->query($sql);
4808 4808
 			if ($resql)
4809 4809
 			{
4810 4810
 				$this->array_options = array();
4811
-				$numrows=$this->db->num_rows($resql);
4811
+				$numrows = $this->db->num_rows($resql);
4812 4812
 				if ($numrows)
4813 4813
 				{
4814 4814
 					$tab = $this->db->fetch_array($resql);
@@ -4816,17 +4816,17 @@  discard block
 block discarded – undo
4816 4816
 					foreach ($tab as $key => $value)
4817 4817
 					{
4818 4818
 						// Test fetch_array ! is_int($key) because fetch_array result is a mix table with Key as alpha and Key as int (depend db engine)
4819
-						if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
4819
+						if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && !is_int($key))
4820 4820
 						{
4821 4821
 							// we can add this attribute to object
4822
-							if (! empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date','datetime')))
4822
+							if (!empty($extrafields) && in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime')))
4823 4823
 							{
4824 4824
 								//var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
4825
-								$this->array_options["options_".$key]=$this->db->jdate($value);
4825
+								$this->array_options["options_".$key] = $this->db->jdate($value);
4826 4826
 							}
4827 4827
 							else
4828 4828
 							{
4829
-								$this->array_options["options_".$key]=$value;
4829
+								$this->array_options["options_".$key] = $value;
4830 4830
 							}
4831 4831
 
4832 4832
 							//var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]);
@@ -4862,10 +4862,10 @@  discard block
 block discarded – undo
4862 4862
 
4863 4863
 		$sql_del = "DELETE FROM ".MAIN_DB_PREFIX.$table_element."_extrafields WHERE fk_object = ".$this->id;
4864 4864
 		dol_syslog(get_class($this)."::deleteExtraFields delete", LOG_DEBUG);
4865
-		$resql=$this->db->query($sql_del);
4866
-		if (! $resql)
4865
+		$resql = $this->db->query($sql_del);
4866
+		if (!$resql)
4867 4867
 		{
4868
-			$this->error=$this->db->lasterror();
4868
+			$this->error = $this->db->lasterror();
4869 4869
 			$this->db->rollback();
4870 4870
 			return -1;
4871 4871
 		}
@@ -4886,36 +4886,36 @@  discard block
 block discarded – undo
4886 4886
 	 *  @return int 						-1=error, O=did nothing, 1=OK
4887 4887
 	 *  @see updateExtraField, setValueFrom
4888 4888
 	 */
4889
-	function insertExtraFields($trigger='', $userused=null)
4889
+	function insertExtraFields($trigger = '', $userused = null)
4890 4890
 	{
4891
-		global $conf,$langs,$user;
4891
+		global $conf, $langs, $user;
4892 4892
 
4893
-		if (empty($userused)) $userused=$user;
4893
+		if (empty($userused)) $userused = $user;
4894 4894
 
4895
-		$error=0;
4895
+		$error = 0;
4896 4896
 
4897
-		if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0;	// For avoid conflicts if trigger used
4897
+		if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used
4898 4898
 
4899
-		if (! empty($this->array_options))
4899
+		if (!empty($this->array_options))
4900 4900
 		{
4901 4901
 			// Check parameters
4902 4902
 			$langs->load('admin');
4903 4903
 			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
4904 4904
 			$extrafields = new ExtraFields($this->db);
4905
-			$target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element);
4905
+			$target_extrafields = $extrafields->fetch_name_optionals_label($this->table_element);
4906 4906
 
4907 4907
 			//Eliminate copied source object extra_fields that do not exist in target object
4908
-			$new_array_options=array();
4908
+			$new_array_options = array();
4909 4909
 			foreach ($this->array_options as $key => $value) {
4910
-				if (in_array(substr($key,8), array_keys($target_extrafields)))	// We remove the 'options_' from $key for test
4910
+				if (in_array(substr($key, 8), array_keys($target_extrafields)))	// We remove the 'options_' from $key for test
4911 4911
 					$new_array_options[$key] = $value;
4912 4912
 				elseif (in_array($key, array_keys($target_extrafields)))		// We test on $key that does not contains the 'options_' prefix
4913 4913
 					$new_array_options['options_'.$key] = $value;
4914 4914
 			}
4915 4915
 
4916
-			foreach($new_array_options as $key => $value)
4916
+			foreach ($new_array_options as $key => $value)
4917 4917
 			{
4918
-			   	$attributeKey      = substr($key,8);   // Remove 'options_' prefix
4918
+			   	$attributeKey      = substr($key, 8); // Remove 'options_' prefix
4919 4919
 			   	$attributeType     = $extrafields->attributes[$this->table_element]['type'][$attributeKey];
4920 4920
 			   	$attributeLabel    = $extrafields->attributes[$this->table_element]['label'][$attributeKey];
4921 4921
 			   	$attributeParam    = $extrafields->attributes[$this->table_element]['param'][$attributeKey];
@@ -4923,13 +4923,13 @@  discard block
 block discarded – undo
4923 4923
 
4924 4924
 			   	if ($attributeRequired)
4925 4925
 			   	{
4926
-			   		$mandatorypb=false;
4927
-			   		if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb=true;
4928
-			   		if ($this->array_options[$key] === '') $mandatorypb=true;
4926
+			   		$mandatorypb = false;
4927
+			   		if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true;
4928
+			   		if ($this->array_options[$key] === '') $mandatorypb = true;
4929 4929
 			   		if ($mandatorypb)
4930 4930
 			   		{
4931 4931
 			   			dol_syslog($this->error);
4932
-			   			$this->errors[]=$langs->trans('ErrorFieldRequired', $attributeLabel);
4932
+			   			$this->errors[] = $langs->trans('ErrorFieldRequired', $attributeLabel);
4933 4933
 			   			return -1;
4934 4934
 			   		}
4935 4935
 			   	}
@@ -4940,25 +4940,25 @@  discard block
 block discarded – undo
4940 4940
 			   	switch ($attributeType)
4941 4941
 			   	{
4942 4942
 			   		case 'int':
4943
-			  			if (!is_numeric($value) && $value!='')
4943
+			  			if (!is_numeric($value) && $value != '')
4944 4944
 			   			{
4945
-			   				$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
4945
+			   				$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
4946 4946
 			   				return -1;
4947 4947
 			  			}
4948
-			   			elseif ($value=='')
4948
+			   			elseif ($value == '')
4949 4949
 			   			{
4950 4950
 			   				$new_array_options[$key] = null;
4951 4951
 			   			}
4952 4952
 			 			break;
4953 4953
 					case 'double':
4954 4954
 						$value = price2num($value);
4955
-						if (!is_numeric($value) && $value!='')
4955
+						if (!is_numeric($value) && $value != '')
4956 4956
 						{
4957 4957
 							dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
4958
-							$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
4958
+							$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
4959 4959
 							return -1;
4960 4960
 						}
4961
-						elseif ($value=='')
4961
+						elseif ($value == '')
4962 4962
 						{
4963 4963
 							$new_array_options[$key] = null;
4964 4964
 						}
@@ -4972,12 +4972,12 @@  discard block
 block discarded – undo
4972 4972
              			}
4973 4973
              			break;*/
4974 4974
 			   		case 'password':
4975
-			   			$algo='';
4975
+			   			$algo = '';
4976 4976
 			   			if ($this->array_options[$key] != '' && is_array($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']))
4977 4977
 			   			{
4978 4978
 			   				// If there is an encryption choice, we use it to crypt data before insert
4979 4979
 			   				$tmparrays = array_keys($extrafields->attributes[$this->table_element]['param'][$attributeKey]['options']);
4980
-			   				$algo=reset($tmparrays);
4980
+			   				$algo = reset($tmparrays);
4981 4981
 			   				if ($algo != '')
4982 4982
 			   				{
4983 4983
 			   					//global $action;		// $action may be 'create', 'update', 'update_extras'...
@@ -4988,7 +4988,7 @@  discard block
 block discarded – undo
4988 4988
 			   						//var_dump($this->oldcopy->array_options[$key]); var_dump($this->array_options[$key]);
4989 4989
 				   					if ($this->array_options[$key] == $this->oldcopy->array_options[$key])	// If old value crypted in database is same than submited new value, it means we don't change it, so we don't update.
4990 4990
 				   					{
4991
-				   						$new_array_options[$key] = $this->array_options[$key];	// Value is kept
4991
+				   						$new_array_options[$key] = $this->array_options[$key]; // Value is kept
4992 4992
 				   					}
4993 4993
 									else
4994 4994
 									{
@@ -4999,7 +4999,7 @@  discard block
 block discarded – undo
4999 4999
 			   					}
5000 5000
 			   					else
5001 5001
 			   					{
5002
-			   						$new_array_options[$key] = $this->array_options[$key];	// Value is kept
5002
+			   						$new_array_options[$key] = $this->array_options[$key]; // Value is kept
5003 5003
 			   					}
5004 5004
 			   				}
5005 5005
 			   			}
@@ -5016,13 +5016,13 @@  discard block
 block discarded – undo
5016 5016
 						break;
5017 5017
 					case 'datetime':
5018 5018
 						// If data is a string instead of a timestamp, we convert it
5019
-						if (! is_int($this->array_options[$key])) {
5019
+						if (!is_int($this->array_options[$key])) {
5020 5020
 							$this->array_options[$key] = strtotime($this->array_options[$key]);
5021 5021
 						}
5022 5022
 						$new_array_options[$key] = $this->db->idate($this->array_options[$key]);
5023 5023
 						break;
5024 5024
 		   			case 'link':
5025
-						$param_list=array_keys($attributeParam['options']);
5025
+						$param_list = array_keys($attributeParam['options']);
5026 5026
 						// 0 : ObjectName
5027 5027
 						// 1 : classPath
5028 5028
 						$InfoFieldList = explode(":", $param_list[0]);
@@ -5031,18 +5031,18 @@  discard block
 block discarded – undo
5031 5031
 						{
5032 5032
 							if ($value == '-1')	// -1 is key for no defined in combo list of objects
5033 5033
 							{
5034
-								$new_array_options[$key]='';
5034
+								$new_array_options[$key] = '';
5035 5035
 							}
5036 5036
 							elseif ($value)
5037 5037
 							{
5038 5038
 								$object = new $InfoFieldList[0]($this->db);
5039
-								if (is_numeric($value)) $res=$object->fetch($value);
5040
-								else $res=$object->fetch('',$value);
5039
+								if (is_numeric($value)) $res = $object->fetch($value);
5040
+								else $res = $object->fetch('', $value);
5041 5041
 
5042
-								if ($res > 0) $new_array_options[$key]=$object->id;
5042
+								if ($res > 0) $new_array_options[$key] = $object->id;
5043 5043
 								else
5044 5044
 								{
5045
-									$this->error="Id/Ref '".$value."' for object '".$object->element."' not found";
5045
+									$this->error = "Id/Ref '".$value."' for object '".$object->element."' not found";
5046 5046
 									$this->db->rollback();
5047 5047
 									return -1;
5048 5048
 								}
@@ -5066,46 +5066,46 @@  discard block
 block discarded – undo
5066 5066
 			$this->db->query($sql_del);
5067 5067
 
5068 5068
 			$sql = "INSERT INTO ".MAIN_DB_PREFIX.$table_element."_extrafields (fk_object";
5069
-			foreach($new_array_options as $key => $value)
5069
+			foreach ($new_array_options as $key => $value)
5070 5070
 			{
5071
-				$attributeKey = substr($key,8);   // Remove 'options_' prefix
5071
+				$attributeKey = substr($key, 8); // Remove 'options_' prefix
5072 5072
 				// Add field of attribut
5073 5073
 				if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator
5074
-					$sql.=",".$attributeKey;
5074
+					$sql .= ",".$attributeKey;
5075 5075
 			}
5076 5076
 			$sql .= ") VALUES (".$this->id;
5077 5077
 
5078
-			foreach($new_array_options as $key => $value)
5078
+			foreach ($new_array_options as $key => $value)
5079 5079
 			{
5080
-				$attributeKey = substr($key,8);   // Remove 'options_' prefix
5080
+				$attributeKey = substr($key, 8); // Remove 'options_' prefix
5081 5081
 				// Add field of attribute
5082 5082
 				if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator)
5083 5083
 				{
5084 5084
 					if ($new_array_options[$key] != '')
5085 5085
 					{
5086
-						$sql.=",'".$this->db->escape($new_array_options[$key])."'";
5086
+						$sql .= ",'".$this->db->escape($new_array_options[$key])."'";
5087 5087
 					}
5088 5088
 					else
5089 5089
 					{
5090
-						$sql.=",null";
5090
+						$sql .= ",null";
5091 5091
 					}
5092 5092
 				}
5093 5093
 			}
5094
-			$sql.=")";
5094
+			$sql .= ")";
5095 5095
 
5096 5096
 			dol_syslog(get_class($this)."::insertExtraFields insert", LOG_DEBUG);
5097 5097
 			$resql = $this->db->query($sql);
5098
-			if (! $resql)
5098
+			if (!$resql)
5099 5099
 			{
5100
-				$this->error=$this->db->lasterror();
5100
+				$this->error = $this->db->lasterror();
5101 5101
 				$error++;
5102 5102
 			}
5103 5103
 
5104
-			if (! $error && $trigger)
5104
+			if (!$error && $trigger)
5105 5105
 			{
5106 5106
 				// Call trigger
5107
-				$this->context=array('extrafieldaddupdate'=>1);
5108
-				$result=$this->call_trigger($trigger, $userused);
5107
+				$this->context = array('extrafieldaddupdate'=>1);
5108
+				$result = $this->call_trigger($trigger, $userused);
5109 5109
 				if ($result < 0) $error++;
5110 5110
 				// End call trigger
5111 5111
 			}
@@ -5134,25 +5134,25 @@  discard block
 block discarded – undo
5134 5134
 	 *  @return int                 		-1=error, O=did nothing, 1=OK
5135 5135
 	 *  @see setValueFrom, insertExtraFields
5136 5136
 	 */
5137
-	function updateExtraField($key, $trigger=null, $userused=null)
5137
+	function updateExtraField($key, $trigger = null, $userused = null)
5138 5138
 	{
5139
-		global $conf,$langs,$user;
5139
+		global $conf, $langs, $user;
5140 5140
 
5141
-		if (empty($userused)) $userused=$user;
5141
+		if (empty($userused)) $userused = $user;
5142 5142
 
5143
-		$error=0;
5143
+		$error = 0;
5144 5144
 
5145
-		if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0;	// For avoid conflicts if trigger used
5145
+		if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used
5146 5146
 
5147
-		if (! empty($this->array_options) && isset($this->array_options["options_".$key]))
5147
+		if (!empty($this->array_options) && isset($this->array_options["options_".$key]))
5148 5148
 		{
5149 5149
 			// Check parameters
5150 5150
 			$langs->load('admin');
5151 5151
 			require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
5152 5152
 			$extrafields = new ExtraFields($this->db);
5153
-			$target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element);
5153
+			$target_extrafields = $extrafields->fetch_name_optionals_label($this->table_element);
5154 5154
 
5155
-			$value=$this->array_options["options_".$key];
5155
+			$value = $this->array_options["options_".$key];
5156 5156
 
5157 5157
 			$attributeType     = $extrafields->attributes[$this->table_element]['type'][$key];
5158 5158
 			$attributeLabel    = $extrafields->attributes[$this->table_element]['label'][$key];
@@ -5165,25 +5165,25 @@  discard block
 block discarded – undo
5165 5165
 			switch ($attributeType)
5166 5166
 			{
5167 5167
 				case 'int':
5168
-					if (!is_numeric($value) && $value!='')
5168
+					if (!is_numeric($value) && $value != '')
5169 5169
 					{
5170
-						$this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel);
5170
+						$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
5171 5171
 						return -1;
5172 5172
 					}
5173
-					elseif ($value=='')
5173
+					elseif ($value == '')
5174 5174
 					{
5175 5175
 						$this->array_options["options_".$key] = null;
5176 5176
 					}
5177 5177
 					break;
5178 5178
 				case 'double':
5179 5179
 					$value = price2num($value);
5180
-					if (!is_numeric($value) && $value!='')
5180
+					if (!is_numeric($value) && $value != '')
5181 5181
 					{
5182 5182
 						dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
5183
-						$this->errors[]=$langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
5183
+						$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
5184 5184
 						return -1;
5185 5185
 					}
5186
-					elseif ($value=='')
5186
+					elseif ($value == '')
5187 5187
 					{
5188 5188
 						$this->array_options["options_".$key] = null;
5189 5189
 					}
@@ -5200,13 +5200,13 @@  discard block
 block discarded – undo
5200 5200
 					$this->array_options["options_".$key] = price2num($this->array_options["options_".$key]);
5201 5201
 					break;
5202 5202
 				case 'date':
5203
-					$this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]);
5203
+					$this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]);
5204 5204
 					break;
5205 5205
 				case 'datetime':
5206
-					$this->array_options["options_".$key]=$this->db->idate($this->array_options["options_".$key]);
5206
+					$this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]);
5207 5207
 					break;
5208 5208
 				case 'link':
5209
-					$param_list=array_keys($attributeParam['options']);
5209
+					$param_list = array_keys($attributeParam['options']);
5210 5210
 					// 0 : ObjectName
5211 5211
 					// 1 : classPath
5212 5212
 					$InfoFieldList = explode(":", $param_list[0]);
@@ -5214,8 +5214,8 @@  discard block
 block discarded – undo
5214 5214
 					if ($value)
5215 5215
 					{
5216 5216
 						$object = new $InfoFieldList[0]($this->db);
5217
-						$object->fetch(0,$value);
5218
-						$this->array_options["options_".$key]=$object->id;
5217
+						$object->fetch(0, $value);
5218
+						$this->array_options["options_".$key] = $object->id;
5219 5219
 					}
5220 5220
 					break;
5221 5221
 			}
@@ -5224,24 +5224,24 @@  discard block
 block discarded – undo
5224 5224
 			$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key."='".$this->db->escape($this->array_options["options_".$key])."'";
5225 5225
 			$sql .= " WHERE fk_object = ".$this->id;
5226 5226
 			$resql = $this->db->query($sql);
5227
-			if (! $resql)
5227
+			if (!$resql)
5228 5228
 			{
5229 5229
 				$error++;
5230
-				$this->error=$this->db->lasterror();
5230
+				$this->error = $this->db->lasterror();
5231 5231
 			}
5232 5232
 
5233
-			if (! $error && $trigger)
5233
+			if (!$error && $trigger)
5234 5234
 			{
5235 5235
 				// Call trigger
5236
-				$this->context=array('extrafieldupdate'=>1);
5237
-				$result=$this->call_trigger($trigger, $userused);
5236
+				$this->context = array('extrafieldupdate'=>1);
5237
+				$result = $this->call_trigger($trigger, $userused);
5238 5238
 				if ($result < 0) $error++;
5239 5239
 				// End call trigger
5240 5240
 			}
5241 5241
 
5242 5242
 			if ($error)
5243 5243
 			{
5244
-				dol_syslog(get_class($this) . "::".__METHOD__ . $this->error, LOG_ERR);
5244
+				dol_syslog(get_class($this)."::".__METHOD__.$this->error, LOG_ERR);
5245 5245
 				$this->db->rollback();
5246 5246
 				return -1;
5247 5247
 			}
@@ -5268,71 +5268,71 @@  discard block
 block discarded – undo
5268 5268
 	 * @param  string|int		$morecss       Value for css to define style/length of field. May also be a numeric.
5269 5269
 	 * @return string
5270 5270
 	 */
5271
-	function showInputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $morecss=0)
5271
+	function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0)
5272 5272
 	{
5273
-		global $conf,$langs,$form;
5273
+		global $conf, $langs, $form;
5274 5274
 
5275
-		if (! is_object($form))
5275
+		if (!is_object($form))
5276 5276
 		{
5277 5277
 			require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
5278
-			$form=new Form($this->db);
5278
+			$form = new Form($this->db);
5279 5279
 		}
5280 5280
 
5281
-		$val=$this->fields[$key];
5281
+		$val = $this->fields[$key];
5282 5282
 
5283
-		$out='';
5284
-        $type='';
5283
+		$out = '';
5284
+        $type = '';
5285 5285
         $param = array();
5286
-        $param['options']=array();
5287
-        $size =$this->fields[$key]['size'];
5286
+        $param['options'] = array();
5287
+        $size = $this->fields[$key]['size'];
5288 5288
         // Because we work on extrafields
5289
-        if(preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)){
5290
-            $param['options']=array($reg[1].':'.$reg[2]=>'N');
5291
-            $type ='link';
5292
-        } elseif(preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) {
5293
-            $param['options']=array($reg[1].':'.$reg[2]=>'N');
5294
-            $type ='link';
5295
-        } elseif(preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
5296
-            $param['options']=array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
5297
-            $type ='sellist';
5298
-        } elseif(preg_match('/varchar\((\d+)\)/', $val['type'],$reg)) {
5299
-            $param['options']=array();
5300
-            $type ='varchar';
5301
-            $size=$reg[1];
5302
-        } elseif(preg_match('/varchar/', $val['type'])) {
5303
-            $param['options']=array();
5304
-            $type ='varchar';
5305
-        } elseif(is_array($this->fields[$key]['arrayofkeyval'])) {
5306
-            $param['options']=$this->fields[$key]['arrayofkeyval'];
5307
-            $type ='select';
5289
+        if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) {
5290
+            $param['options'] = array($reg[1].':'.$reg[2]=>'N');
5291
+            $type = 'link';
5292
+        } elseif (preg_match('/^link:(.*):(.*)/i', $val['type'], $reg)) {
5293
+            $param['options'] = array($reg[1].':'.$reg[2]=>'N');
5294
+            $type = 'link';
5295
+        } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
5296
+            $param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4]=>'N');
5297
+            $type = 'sellist';
5298
+        } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) {
5299
+            $param['options'] = array();
5300
+            $type = 'varchar';
5301
+            $size = $reg[1];
5302
+        } elseif (preg_match('/varchar/', $val['type'])) {
5303
+            $param['options'] = array();
5304
+            $type = 'varchar';
5305
+        } elseif (is_array($this->fields[$key]['arrayofkeyval'])) {
5306
+            $param['options'] = $this->fields[$key]['arrayofkeyval'];
5307
+            $type = 'select';
5308 5308
         } else {
5309
-            $param['options']=array();
5310
-            $type =$this->fields[$key]['type'];
5309
+            $param['options'] = array();
5310
+            $type = $this->fields[$key]['type'];
5311 5311
         }
5312 5312
 
5313
-		$label=$this->fields[$key]['label'];
5313
+		$label = $this->fields[$key]['label'];
5314 5314
 		//$elementtype=$this->fields[$key]['elementtype'];	// Seems not used
5315
-		$default=$this->fields[$key]['default'];
5316
-		$computed=$this->fields[$key]['computed'];
5317
-		$unique=$this->fields[$key]['unique'];
5318
-		$required=$this->fields[$key]['required'];
5315
+		$default = $this->fields[$key]['default'];
5316
+		$computed = $this->fields[$key]['computed'];
5317
+		$unique = $this->fields[$key]['unique'];
5318
+		$required = $this->fields[$key]['required'];
5319 5319
 
5320
-		$langfile=$this->fields[$key]['langfile'];
5321
-		$list=$this->fields[$key]['list'];
5322
-		$hidden=abs($this->fields[$key]['visible'])!=1?1:0;
5320
+		$langfile = $this->fields[$key]['langfile'];
5321
+		$list = $this->fields[$key]['list'];
5322
+		$hidden = abs($this->fields[$key]['visible']) != 1 ? 1 : 0;
5323 5323
 
5324 5324
 		$objectid = $this->id;
5325 5325
 
5326 5326
 
5327 5327
 		if ($computed)
5328 5328
 		{
5329
-			if (! preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
5329
+			if (!preg_match('/^search_/', $keyprefix)) return '<span class="opacitymedium">'.$langs->trans("AutomaticallyCalculated").'</span>';
5330 5330
 			else return '';
5331 5331
 		}
5332 5332
 
5333 5333
 
5334 5334
 		// Use in priority showsize from parameters, then $val['css'] then autodefine
5335
-		if (empty($morecss) && ! empty($val['css']))
5335
+		if (empty($morecss) && !empty($val['css']))
5336 5336
 		{
5337 5337
 			$showsize = $val['css'];
5338 5338
 		}
@@ -5346,16 +5346,16 @@  discard block
 block discarded – undo
5346 5346
 			{
5347 5347
 				$morecss = 'minwidth200imp';
5348 5348
 			}
5349
-			elseif (in_array($type,array('int','integer','price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
5349
+			elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type))
5350 5350
 			{
5351 5351
 				$morecss = 'maxwidth75';
5352 5352
                         }elseif ($type == 'url')
5353 5353
 			{
5354
-				$morecss='minwidth400';
5354
+				$morecss = 'minwidth400';
5355 5355
 			}
5356 5356
 			elseif ($type == 'boolean')
5357 5357
 			{
5358
-				$morecss='';
5358
+				$morecss = '';
5359 5359
 			}
5360 5360
 			else
5361 5361
 			{
@@ -5374,12 +5374,12 @@  discard block
 block discarded – undo
5374 5374
 			}
5375 5375
 		}
5376 5376
 
5377
-		if (in_array($type,array('date','datetime')))
5377
+		if (in_array($type, array('date', 'datetime')))
5378 5378
 		{
5379
-			$tmp=explode(',',$size);
5380
-			$newsize=$tmp[0];
5379
+			$tmp = explode(',', $size);
5380
+			$newsize = $tmp[0];
5381 5381
 
5382
-			$showtime = in_array($type,array('datetime')) ? 1 : 0;
5382
+			$showtime = in_array($type, array('datetime')) ? 1 : 0;
5383 5383
 
5384 5384
 			// Do not show current date when field not required (see selectDate() method)
5385 5385
 			if (!$required && $value == '') $value = '-1';
@@ -5387,237 +5387,237 @@  discard block
 block discarded – undo
5387 5387
 			// TODO Must also support $moreparam
5388 5388
 			$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
5389 5389
 		}
5390
-		elseif (in_array($type,array('int','integer')))
5390
+		elseif (in_array($type, array('int', 'integer')))
5391 5391
 		{
5392
-			$tmp=explode(',',$size);
5393
-			$newsize=$tmp[0];
5394
-			$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
5392
+			$tmp = explode(',', $size);
5393
+			$newsize = $tmp[0];
5394
+			$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
5395 5395
 		}
5396 5396
 		elseif (preg_match('/varchar/', $type))
5397 5397
 		{
5398
-			$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam?$moreparam:'').'>';
5398
+			$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
5399 5399
 		}
5400 5400
 		elseif (in_array($type, array('mail', 'phone', 'url')))
5401 5401
 		{
5402
-			$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
5402
+			$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
5403 5403
 		}
5404 5404
 		elseif ($type == 'text')
5405 5405
 		{
5406
-			if (! preg_match('/search_/', $keyprefix))		// If keyprefix is search_ or search_options_, we must just use a simple text field
5406
+			if (!preg_match('/search_/', $keyprefix))		// If keyprefix is search_ or search_options_, we must just use a simple text field
5407 5407
 			{
5408 5408
 				require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
5409
-				$doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,false,ROWS_5,'90%');
5410
-				$out=$doleditor->Create(1);
5409
+				$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%');
5410
+				$out = $doleditor->Create(1);
5411 5411
 			}
5412 5412
 			else
5413 5413
 			{
5414
-				$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
5414
+				$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
5415 5415
 			}
5416 5416
 		}
5417 5417
 		elseif ($type == 'html')
5418 5418
 		{
5419
-			if (! preg_match('/search_/', $keyprefix))		// If keyprefix is search_ or search_options_, we must just use a simple text field
5419
+			if (!preg_match('/search_/', $keyprefix))		// If keyprefix is search_ or search_options_, we must just use a simple text field
5420 5420
 			{
5421 5421
 				require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
5422
-				$doleditor=new DolEditor($keyprefix.$key.$keysuffix,$value,'',200,'dolibarr_notes','In',false,false,! empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE,ROWS_5,'90%');
5423
-				$out=$doleditor->Create(1);
5422
+				$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%');
5423
+				$out = $doleditor->Create(1);
5424 5424
 			}
5425 5425
 			else
5426 5426
 			{
5427
-				$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam?$moreparam:'').'>';
5427
+				$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
5428 5428
 			}
5429 5429
 		}
5430 5430
 		elseif ($type == 'boolean')
5431 5431
 		{
5432
-			$checked='';
5432
+			$checked = '';
5433 5433
 			if (!empty($value)) {
5434
-				$checked=' checked value="1" ';
5434
+				$checked = ' checked value="1" ';
5435 5435
 			} else {
5436
-				$checked=' value="1" ';
5436
+				$checked = ' value="1" ';
5437 5437
 			}
5438
-			$out='<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam?$moreparam:'').'>';
5438
+			$out = '<input type="checkbox" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.$checked.' '.($moreparam ? $moreparam : '').'>';
5439 5439
 		}
5440 5440
 		elseif ($type == 'price')
5441 5441
 		{
5442 5442
 			if (!empty($value)) {		// $value in memory is a php numeric, we format it into user number format.
5443
-				$value=price($value);
5443
+				$value = price($value);
5444 5444
 			}
5445
-			$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
5445
+			$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> '.$langs->getCurrencySymbol($conf->currency);
5446 5446
 		}
5447
-		elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/',$type))
5447
+		elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type))
5448 5448
 		{
5449 5449
 			if (!empty($value)) {		// $value in memory is a php numeric, we format it into user number format.
5450
-				$value=price($value);
5450
+				$value = price($value);
5451 5451
 			}
5452
-			$out='<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
5452
+			$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'> ';
5453 5453
 		}
5454 5454
 		elseif ($type == 'select')
5455 5455
 		{
5456 5456
 			$out = '';
5457
-			if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
5457
+			if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
5458 5458
 			{
5459
-				include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
5460
-				$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
5459
+				include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
5460
+				$out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
5461 5461
 			}
5462 5462
 
5463
-			$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
5464
-                if((! isset($this->fields[$key]['default'])) ||($this->fields[$key]['notnull']!=1))$out.='<option value="0">&nbsp;</option>';
5463
+			$out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>';
5464
+                if ((!isset($this->fields[$key]['default'])) || ($this->fields[$key]['notnull'] != 1))$out .= '<option value="0">&nbsp;</option>';
5465 5465
 			foreach ($param['options'] as $key => $val)
5466 5466
 			{
5467 5467
 				if ((string) $key == '') continue;
5468 5468
 				list($val, $parent) = explode('|', $val);
5469
-				$out.='<option value="'.$key.'"';
5470
-				$out.= (((string) $value == (string) $key)?' selected':'');
5471
-				$out.= (!empty($parent)?' parent="'.$parent.'"':'');
5472
-				$out.='>'.$val.'</option>';
5469
+				$out .= '<option value="'.$key.'"';
5470
+				$out .= (((string) $value == (string) $key) ? ' selected' : '');
5471
+				$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
5472
+				$out .= '>'.$val.'</option>';
5473 5473
 			}
5474
-			$out.='</select>';
5474
+			$out .= '</select>';
5475 5475
 		}
5476 5476
 		elseif ($type == 'sellist')
5477 5477
 		{
5478 5478
 			$out = '';
5479
-			if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
5479
+			if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
5480 5480
 			{
5481
-				include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
5482
-				$out.= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
5481
+				include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
5482
+				$out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
5483 5483
 			}
5484 5484
 
5485
-			$out.='<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'').'>';
5485
+			$out .= '<select class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '').'>';
5486 5486
 			if (is_array($param['options']))
5487 5487
 			{
5488
-				$param_list=array_keys($param['options']);
5488
+				$param_list = array_keys($param['options']);
5489 5489
 				$InfoFieldList = explode(":", $param_list[0]);
5490
-				$parentName='';
5491
-				$parentField='';
5490
+				$parentName = '';
5491
+				$parentField = '';
5492 5492
 				// 0 : tableName
5493 5493
 				// 1 : label field name
5494 5494
 				// 2 : key fields name (if differ of rowid)
5495 5495
 				// 3 : key field parent (for dependent lists)
5496 5496
 				// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
5497
-				$keyList=(empty($InfoFieldList[2])?'rowid':$InfoFieldList[2].' as rowid');
5497
+				$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
5498 5498
 
5499 5499
 
5500
-				if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4]))
5500
+				if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4]))
5501 5501
 				{
5502 5502
 					if (strpos($InfoFieldList[4], 'extra.') !== false)
5503 5503
 					{
5504
-						$keyList='main.'.$InfoFieldList[2].' as rowid';
5504
+						$keyList = 'main.'.$InfoFieldList[2].' as rowid';
5505 5505
 					} else {
5506
-						$keyList=$InfoFieldList[2].' as rowid';
5506
+						$keyList = $InfoFieldList[2].' as rowid';
5507 5507
 					}
5508 5508
 				}
5509
-				if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3]))
5509
+				if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3]))
5510 5510
 				{
5511 5511
 					list($parentName, $parentField) = explode('|', $InfoFieldList[3]);
5512
-					$keyList.= ', '.$parentField;
5512
+					$keyList .= ', '.$parentField;
5513 5513
 				}
5514 5514
 
5515
-				$fields_label = explode('|',$InfoFieldList[1]);
5515
+				$fields_label = explode('|', $InfoFieldList[1]);
5516 5516
 				if (is_array($fields_label))
5517 5517
 				{
5518
-					$keyList .=', ';
5518
+					$keyList .= ', ';
5519 5519
 					$keyList .= implode(', ', $fields_label);
5520 5520
 				}
5521 5521
 
5522
-				$sqlwhere='';
5522
+				$sqlwhere = '';
5523 5523
 				$sql = 'SELECT '.$keyList;
5524
-				$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0];
5524
+				$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
5525 5525
 				if (!empty($InfoFieldList[4]))
5526 5526
 				{
5527 5527
 					// can use SELECT request
5528
-					if (strpos($InfoFieldList[4], '$SEL$')!==false) {
5529
-						$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
5528
+					if (strpos($InfoFieldList[4], '$SEL$') !== false) {
5529
+						$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
5530 5530
 					}
5531 5531
 
5532 5532
 					// current object id can be use into filter
5533
-					if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
5534
-						$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
5533
+					if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
5534
+						$InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
5535 5535
 					} else {
5536
-						$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
5536
+						$InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
5537 5537
 					}
5538 5538
 					//We have to join on extrafield table
5539
-					if (strpos($InfoFieldList[4], 'extra')!==false)
5539
+					if (strpos($InfoFieldList[4], 'extra') !== false)
5540 5540
 					{
5541
-						$sql.= ' as main, '.MAIN_DB_PREFIX .$InfoFieldList[0].'_extrafields as extra';
5542
-						$sqlwhere.= ' WHERE extra.fk_object=main.'.$InfoFieldList[2]. ' AND '.$InfoFieldList[4];
5541
+						$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
5542
+						$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
5543 5543
 					}
5544 5544
 					else
5545 5545
 					{
5546
-						$sqlwhere.= ' WHERE '.$InfoFieldList[4];
5546
+						$sqlwhere .= ' WHERE '.$InfoFieldList[4];
5547 5547
 					}
5548 5548
 				}
5549 5549
 				else
5550 5550
 				{
5551
-					$sqlwhere.= ' WHERE 1=1';
5551
+					$sqlwhere .= ' WHERE 1=1';
5552 5552
 				}
5553 5553
 				// Some tables may have field, some other not. For the moment we disable it.
5554
-				if (in_array($InfoFieldList[0],array('tablewithentity')))
5554
+				if (in_array($InfoFieldList[0], array('tablewithentity')))
5555 5555
 				{
5556
-					$sqlwhere.= ' AND entity = '.$conf->entity;
5556
+					$sqlwhere .= ' AND entity = '.$conf->entity;
5557 5557
 				}
5558
-				$sql.=$sqlwhere;
5558
+				$sql .= $sqlwhere;
5559 5559
 				//print $sql;
5560 5560
 
5561
-				$sql .= ' ORDER BY ' . implode(', ', $fields_label);
5561
+				$sql .= ' ORDER BY '.implode(', ', $fields_label);
5562 5562
 
5563 5563
 				dol_syslog(get_class($this).'::showInputField type=sellist', LOG_DEBUG);
5564 5564
 				$resql = $this->db->query($sql);
5565 5565
 				if ($resql)
5566 5566
 				{
5567
-					$out.='<option value="0">&nbsp;</option>';
5567
+					$out .= '<option value="0">&nbsp;</option>';
5568 5568
 					$num = $this->db->num_rows($resql);
5569 5569
 					$i = 0;
5570 5570
 					while ($i < $num)
5571 5571
 					{
5572
-						$labeltoshow='';
5572
+						$labeltoshow = '';
5573 5573
 						$obj = $this->db->fetch_object($resql);
5574 5574
 
5575 5575
 						// Several field into label (eq table:code|libelle:rowid)
5576 5576
 						$notrans = false;
5577
-						$fields_label = explode('|',$InfoFieldList[1]);
5577
+						$fields_label = explode('|', $InfoFieldList[1]);
5578 5578
 						if (is_array($fields_label))
5579 5579
 						{
5580 5580
 							$notrans = true;
5581 5581
 							foreach ($fields_label as $field_toshow)
5582 5582
 							{
5583
-								$labeltoshow.= $obj->$field_toshow.' ';
5583
+								$labeltoshow .= $obj->$field_toshow.' ';
5584 5584
 							}
5585 5585
 						}
5586 5586
 						else
5587 5587
 						{
5588
-							$labeltoshow=$obj->{$InfoFieldList[1]};
5588
+							$labeltoshow = $obj->{$InfoFieldList[1]};
5589 5589
 						}
5590
-						$labeltoshow=dol_trunc($labeltoshow,45);
5590
+						$labeltoshow = dol_trunc($labeltoshow, 45);
5591 5591
 
5592 5592
 						if ($value == $obj->rowid)
5593 5593
 						{
5594 5594
 							foreach ($fields_label as $field_toshow)
5595 5595
 							{
5596
-								$translabel=$langs->trans($obj->$field_toshow);
5597
-								if ($translabel!=$obj->$field_toshow) {
5598
-									$labeltoshow=dol_trunc($translabel,18).' ';
5599
-								}else {
5600
-									$labeltoshow=dol_trunc($obj->$field_toshow,18).' ';
5596
+								$translabel = $langs->trans($obj->$field_toshow);
5597
+								if ($translabel != $obj->$field_toshow) {
5598
+									$labeltoshow = dol_trunc($translabel, 18).' ';
5599
+								} else {
5600
+									$labeltoshow = dol_trunc($obj->$field_toshow, 18).' ';
5601 5601
 								}
5602 5602
 							}
5603
-							$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
5603
+							$out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
5604 5604
 						}
5605 5605
 						else
5606 5606
 						{
5607
-							if (! $notrans)
5607
+							if (!$notrans)
5608 5608
 							{
5609
-								$translabel=$langs->trans($obj->{$InfoFieldList[1]});
5610
-								if ($translabel!=$obj->{$InfoFieldList[1]}) {
5611
-									$labeltoshow=dol_trunc($translabel,18);
5609
+								$translabel = $langs->trans($obj->{$InfoFieldList[1]});
5610
+								if ($translabel != $obj->{$InfoFieldList[1]}) {
5611
+									$labeltoshow = dol_trunc($translabel, 18);
5612 5612
 								}
5613 5613
 								else {
5614
-									$labeltoshow=dol_trunc($obj->{$InfoFieldList[1]},18);
5614
+									$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]},18);
5615 5615
 								}
5616 5616
 							}
5617
-							if (empty($labeltoshow)) $labeltoshow='(not defined)';
5618
-							if ($value==$obj->rowid)
5617
+							if (empty($labeltoshow)) $labeltoshow = '(not defined)';
5618
+							if ($value == $obj->rowid)
5619 5619
 							{
5620
-								$out.='<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
5620
+								$out .= '<option value="'.$obj->rowid.'" selected>'.$labeltoshow.'</option>';
5621 5621
 							}
5622 5622
 
5623 5623
 							if (!empty($InfoFieldList[3]) && $parentField)
@@ -5625,10 +5625,10 @@  discard block
 block discarded – undo
5625 5625
 								$parent = $parentName.':'.$obj->{$parentField};
5626 5626
 							}
5627 5627
 
5628
-							$out.='<option value="'.$obj->rowid.'"';
5629
-							$out.= ($value==$obj->rowid?' selected':'');
5630
-							$out.= (!empty($parent)?' parent="'.$parent.'"':'');
5631
-							$out.='>'.$labeltoshow.'</option>';
5628
+							$out .= '<option value="'.$obj->rowid.'"';
5629
+							$out .= ($value == $obj->rowid ? ' selected' : '');
5630
+							$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
5631
+							$out .= '>'.$labeltoshow.'</option>';
5632 5632
 						}
5633 5633
 
5634 5634
 						$i++;
@@ -5639,23 +5639,23 @@  discard block
 block discarded – undo
5639 5639
 					print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
5640 5640
 				}
5641 5641
 			}
5642
-			$out.='</select>';
5642
+			$out .= '</select>';
5643 5643
 		}
5644 5644
 		elseif ($type == 'checkbox')
5645 5645
 		{
5646
-			$value_arr=explode(',',$value);
5647
-			$out=$form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options'])?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
5646
+			$value_arr = explode(',', $value);
5647
+			$out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
5648 5648
 		}
5649 5649
 		elseif ($type == 'radio')
5650 5650
 		{
5651
-			$out='';
5651
+			$out = '';
5652 5652
 			foreach ($param['options'] as $keyopt => $val)
5653 5653
 			{
5654
-				$out.='<input class="flat '.$morecss.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam?$moreparam:'');
5655
-				$out.=' value="'.$keyopt.'"';
5656
-				$out.=' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
5657
-				$out.= ($value==$keyopt?'checked':'');
5658
-				$out.='/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>';
5654
+				$out .= '<input class="flat '.$morecss.'" type="radio" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" '.($moreparam ? $moreparam : '');
5655
+				$out .= ' value="'.$keyopt.'"';
5656
+				$out .= ' id="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'"';
5657
+				$out .= ($value == $keyopt ? 'checked' : '');
5658
+				$out .= '/><label for="'.$keyprefix.$key.$keysuffix.'_'.$keyopt.'">'.$val.'</label><br>';
5659 5659
 			}
5660 5660
 		}
5661 5661
 		elseif ($type == 'chkbxlst')
@@ -5670,24 +5670,24 @@  discard block
 block discarded – undo
5670 5670
 			if (is_array($param['options'])) {
5671 5671
 				$param_list = array_keys($param['options']);
5672 5672
 				$InfoFieldList = explode(":", $param_list[0]);
5673
-				$parentName='';
5674
-				$parentField='';
5673
+				$parentName = '';
5674
+				$parentField = '';
5675 5675
 				// 0 : tableName
5676 5676
 				// 1 : label field name
5677 5677
 				// 2 : key fields name (if differ of rowid)
5678 5678
 				// 3 : key field parent (for dependent lists)
5679 5679
 				// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
5680
-				$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2] . ' as rowid');
5680
+				$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
5681 5681
 
5682
-				if (count($InfoFieldList) > 3 && ! empty($InfoFieldList[3])) {
5683
-					list ( $parentName, $parentField ) = explode('|', $InfoFieldList[3]);
5684
-					$keyList .= ', ' . $parentField;
5682
+				if (count($InfoFieldList) > 3 && !empty($InfoFieldList[3])) {
5683
+					list ($parentName, $parentField) = explode('|', $InfoFieldList[3]);
5684
+					$keyList .= ', '.$parentField;
5685 5685
 				}
5686
-				if (count($InfoFieldList) > 4 && ! empty($InfoFieldList[4])) {
5686
+				if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
5687 5687
 					if (strpos($InfoFieldList[4], 'extra.') !== false) {
5688
-						$keyList = 'main.' . $InfoFieldList[2] . ' as rowid';
5688
+						$keyList = 'main.'.$InfoFieldList[2].' as rowid';
5689 5689
 					} else {
5690
-						$keyList = $InfoFieldList[2] . ' as rowid';
5690
+						$keyList = $InfoFieldList[2].' as rowid';
5691 5691
 					}
5692 5692
 				}
5693 5693
 
@@ -5698,50 +5698,50 @@  discard block
 block discarded – undo
5698 5698
 				}
5699 5699
 
5700 5700
 				$sqlwhere = '';
5701
-				$sql = 'SELECT ' . $keyList;
5702
-				$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
5703
-				if (! empty($InfoFieldList[4])) {
5701
+				$sql = 'SELECT '.$keyList;
5702
+				$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
5703
+				if (!empty($InfoFieldList[4])) {
5704 5704
 
5705 5705
 					// can use SELECT request
5706
-					if (strpos($InfoFieldList[4], '$SEL$')!==false) {
5707
-						$InfoFieldList[4]=str_replace('$SEL$','SELECT',$InfoFieldList[4]);
5706
+					if (strpos($InfoFieldList[4], '$SEL$') !== false) {
5707
+						$InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
5708 5708
 					}
5709 5709
 
5710 5710
 					// current object id can be use into filter
5711
-					if (strpos($InfoFieldList[4], '$ID$')!==false && !empty($objectid)) {
5712
-						$InfoFieldList[4]=str_replace('$ID$',$objectid,$InfoFieldList[4]);
5711
+					if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
5712
+						$InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
5713 5713
 					} else {
5714
-						$InfoFieldList[4]=str_replace('$ID$','0',$InfoFieldList[4]);
5714
+						$InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
5715 5715
 					}
5716 5716
 
5717 5717
 					// We have to join on extrafield table
5718 5718
 					if (strpos($InfoFieldList[4], 'extra') !== false) {
5719
-						$sql .= ' as main, ' . MAIN_DB_PREFIX . $InfoFieldList[0] . '_extrafields as extra';
5720
-						$sqlwhere .= ' WHERE extra.fk_object=main.' . $InfoFieldList[2] . ' AND ' . $InfoFieldList[4];
5719
+						$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
5720
+						$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
5721 5721
 					} else {
5722
-						$sqlwhere .= ' WHERE ' . $InfoFieldList[4];
5722
+						$sqlwhere .= ' WHERE '.$InfoFieldList[4];
5723 5723
 					}
5724 5724
 				} else {
5725 5725
 					$sqlwhere .= ' WHERE 1=1';
5726 5726
 				}
5727 5727
 				// Some tables may have field, some other not. For the moment we disable it.
5728
-				if (in_array($InfoFieldList[0], array ('tablewithentity')))
5728
+				if (in_array($InfoFieldList[0], array('tablewithentity')))
5729 5729
 				{
5730
-					$sqlwhere .= ' AND entity = ' . $conf->entity;
5730
+					$sqlwhere .= ' AND entity = '.$conf->entity;
5731 5731
 				}
5732 5732
 				// $sql.=preg_replace('/^ AND /','',$sqlwhere);
5733 5733
 				// print $sql;
5734 5734
 
5735 5735
 				$sql .= $sqlwhere;
5736
-				dol_syslog(get_class($this) . '::showInputField type=chkbxlst',LOG_DEBUG);
5736
+				dol_syslog(get_class($this).'::showInputField type=chkbxlst', LOG_DEBUG);
5737 5737
 				$resql = $this->db->query($sql);
5738 5738
 				if ($resql) {
5739 5739
 					$num = $this->db->num_rows($resql);
5740 5740
 					$i = 0;
5741 5741
 
5742
-					$data=array();
5742
+					$data = array();
5743 5743
 
5744
-					while ( $i < $num ) {
5744
+					while ($i < $num) {
5745 5745
 						$labeltoshow = '';
5746 5746
 						$obj = $this->db->fetch_object($resql);
5747 5747
 
@@ -5750,8 +5750,8 @@  discard block
 block discarded – undo
5750 5750
 						$fields_label = explode('|', $InfoFieldList[1]);
5751 5751
 						if (is_array($fields_label)) {
5752 5752
 							$notrans = true;
5753
-							foreach ( $fields_label as $field_toshow ) {
5754
-								$labeltoshow .= $obj->$field_toshow . ' ';
5753
+							foreach ($fields_label as $field_toshow) {
5754
+								$labeltoshow .= $obj->$field_toshow.' ';
5755 5755
 							}
5756 5756
 						} else {
5757 5757
 							$labeltoshow = $obj->{$InfoFieldList[1]};
@@ -5759,18 +5759,18 @@  discard block
 block discarded – undo
5759 5759
 						$labeltoshow = dol_trunc($labeltoshow, 45);
5760 5760
 
5761 5761
 						if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
5762
-							foreach ( $fields_label as $field_toshow ) {
5762
+							foreach ($fields_label as $field_toshow) {
5763 5763
 								$translabel = $langs->trans($obj->$field_toshow);
5764 5764
 								if ($translabel != $obj->$field_toshow) {
5765
-									$labeltoshow = dol_trunc($translabel, 18) . ' ';
5765
+									$labeltoshow = dol_trunc($translabel, 18).' ';
5766 5766
 								} else {
5767
-									$labeltoshow = dol_trunc($obj->$field_toshow, 18) . ' ';
5767
+									$labeltoshow = dol_trunc($obj->$field_toshow, 18).' ';
5768 5768
 								}
5769 5769
 							}
5770 5770
 
5771
-							$data[$obj->rowid]=$labeltoshow;
5771
+							$data[$obj->rowid] = $labeltoshow;
5772 5772
 						} else {
5773
-							if (! $notrans) {
5773
+							if (!$notrans) {
5774 5774
 								$translabel = $langs->trans($obj->{$InfoFieldList[1]});
5775 5775
 								if ($translabel != $obj->{$InfoFieldList[1]}) {
5776 5776
 									$labeltoshow = dol_trunc($translabel, 18);
@@ -5782,67 +5782,67 @@  discard block
 block discarded – undo
5782 5782
 								$labeltoshow = '(not defined)';
5783 5783
 
5784 5784
 								if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
5785
-									$data[$obj->rowid]=$labeltoshow;
5785
+									$data[$obj->rowid] = $labeltoshow;
5786 5786
 								}
5787 5787
 
5788
-								if (! empty($InfoFieldList[3]) && $parentField) {
5789
-									$parent = $parentName . ':' . $obj->{$parentField};
5788
+								if (!empty($InfoFieldList[3]) && $parentField) {
5789
+									$parent = $parentName.':'.$obj->{$parentField};
5790 5790
 								}
5791 5791
 
5792
-								$data[$obj->rowid]=$labeltoshow;
5792
+								$data[$obj->rowid] = $labeltoshow;
5793 5793
 						}
5794 5794
 
5795
-						$i ++;
5795
+						$i++;
5796 5796
 					}
5797 5797
 					$this->db->free($resql);
5798 5798
 
5799
-					$out=$form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
5799
+					$out = $form->multiselectarray($keyprefix.$key.$keysuffix, $data, $value_arr, '', 0, '', 0, '100%');
5800 5800
 				} else {
5801
-					print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.<br>';
5801
+					print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.<br>';
5802 5802
 				}
5803 5803
 			}
5804 5804
 		}
5805 5805
 		elseif ($type == 'link')
5806 5806
 		{
5807
-			$param_list=array_keys($param['options']);				// $param_list='ObjectName:classPath'
5808
-			$showempty=(($required && $default != '')?0:1);
5809
-			$out=$form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
5807
+			$param_list = array_keys($param['options']); // $param_list='ObjectName:classPath'
5808
+			$showempty = (($required && $default != '') ? 0 : 1);
5809
+			$out = $form->selectForForms($param_list[0], $keyprefix.$key.$keysuffix, $value, $showempty);
5810 5810
 			if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
5811 5811
 			{
5812
-            			list($class,$classfile)=explode(':',$param_list[0]);
5813
-            			if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path=dol_buildpath(dirname(dirname($classfile)).'/card.php',1);
5814
-            			else $url_path=dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php',1);
5815
-            			$out.='<a class="butActionNew" href="'.$url_path.'?action=create&backtopage='.$_SERVER['PHP_SELF'].'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
5812
+            			list($class, $classfile) = explode(':', $param_list[0]);
5813
+            			if (file_exists(dol_buildpath(dirname(dirname($classfile)).'/card.php'))) $url_path = dol_buildpath(dirname(dirname($classfile)).'/card.php', 1);
5814
+            			else $url_path = dol_buildpath(dirname(dirname($classfile)).'/'.$class.'_card.php', 1);
5815
+            			$out .= '<a class="butActionNew" href="'.$url_path.'?action=create&backtopage='.$_SERVER['PHP_SELF'].'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
5816 5816
             			// TODO Add Javascript code to add input fields contents to new elements urls
5817 5817
 			}
5818 5818
 		}
5819 5819
 		elseif ($type == 'password')
5820 5820
 		{
5821 5821
 			// If prefix is 'search_', field is used as a filter, we use a common text field.
5822
-			$out='<input type="'.($keyprefix=='search_'?'text':'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'>';
5822
+			$out = '<input type="'.($keyprefix == 'search_' ? 'text' : 'password').'" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.$value.'" '.($moreparam ? $moreparam : '').'>';
5823 5823
 		}
5824 5824
 		elseif ($type == 'array')
5825 5825
 		{
5826 5826
 			$newval = $val;
5827 5827
 			$newval['type'] = 'varchar(256)';
5828 5828
 
5829
-			$out='';
5829
+			$out = '';
5830 5830
 
5831 5831
 			$inputs = array();
5832
-			if(! empty($value)) {
5833
-				foreach($value as $option) {
5834
-					$out.= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
5835
-					$out.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'<br></span>';
5832
+			if (!empty($value)) {
5833
+				foreach ($value as $option) {
5834
+					$out .= '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
5835
+					$out .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $showsize).'<br></span>';
5836 5836
 				}
5837 5837
 			}
5838 5838
 
5839
-			$out.= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>';
5839
+			$out .= '<a id="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_add" href="javascript:;"><span class="fa fa-plus-circle valignmiddle"></span></a>';
5840 5840
 
5841 5841
 			$newInput = '<span><a class="'.dol_escape_htmltag($keyprefix.$key.$keysuffix).'_del" href="javascript:;"><span class="fa fa-minus-circle valignmiddle"></span></a> ';
5842
-			$newInput.= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'<br></span>';
5842
+			$newInput .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', '', $moreparam, '', '', $showsize).'<br></span>';
5843 5843
 
5844
-			if(! empty($conf->use_javascript_ajax)) {
5845
-				$out.= '
5844
+			if (!empty($conf->use_javascript_ajax)) {
5845
+				$out .= '
5846 5846
 					<script type="text/javascript">
5847 5847
 					$(document).ready(function() {
5848 5848
 						$("a#'.dol_escape_js($keyprefix.$key.$keysuffix).'_add").click(function() {
@@ -5857,7 +5857,7 @@  discard block
 block discarded – undo
5857 5857
 			}
5858 5858
 		}
5859 5859
 		if (!empty($hidden)) {
5860
-			$out='<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
5860
+			$out = '<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
5861 5861
 		}
5862 5862
 		/* Add comments
5863 5863
 		 if ($type == 'date') $out.=' (YYYY-MM-DD)';
@@ -5879,14 +5879,14 @@  discard block
 block discarded – undo
5879 5879
 	 * @param  mixed   $showsize       Value for css to define size. May also be a numeric.
5880 5880
 	 * @return string
5881 5881
 	 */
5882
-	function showOutputField($val, $key, $value, $moreparam='', $keysuffix='', $keyprefix='', $showsize=0)
5882
+	function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0)
5883 5883
 	{
5884
-		global $conf,$langs,$form;
5884
+		global $conf, $langs, $form;
5885 5885
 
5886
-		if (! is_object($form))
5886
+		if (!is_object($form))
5887 5887
 		{
5888 5888
 			require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
5889
-			$form=new Form($this->db);
5889
+			$form = new Form($this->db);
5890 5890
 		}
5891 5891
 
5892 5892
 		$objectid = $this->id;
@@ -5897,28 +5897,28 @@  discard block
 block discarded – undo
5897 5897
 		// Convert var to be able to share same code than showOutputField of extrafields
5898 5898
 		if (preg_match('/varchar\((\d+)\)/', $type, $reg))
5899 5899
 		{
5900
-			$type = 'varchar';		// convert varchar(xx) int varchar
5900
+			$type = 'varchar'; // convert varchar(xx) int varchar
5901 5901
 			$size = $reg[1];
5902 5902
 		}
5903
-		elseif (preg_match('/varchar/', $type)) $type = 'varchar';		// convert varchar(xx) int varchar
5904
-		if (is_array($val['arrayofkeyval'])) $type='select';
5905
-		if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type='link';
5903
+		elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
5904
+		if (is_array($val['arrayofkeyval'])) $type = 'select';
5905
+		if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link';
5906 5906
 
5907
-		$default=$val['default'];
5908
-		$computed=$val['computed'];
5909
-		$unique=$val['unique'];
5910
-		$required=$val['required'];
5911
-		$param=$val['param'];
5907
+		$default = $val['default'];
5908
+		$computed = $val['computed'];
5909
+		$unique = $val['unique'];
5910
+		$required = $val['required'];
5911
+		$param = $val['param'];
5912 5912
 		if (is_array($val['arrayofkeyval'])) $param['options'] = $val['arrayofkeyval'];
5913 5913
 		if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg))
5914 5914
 		{
5915
-			$type='link';
5916
-			$param['options']=array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
5915
+			$type = 'link';
5916
+			$param['options'] = array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
5917 5917
 		}
5918
-		$langfile=$val['langfile'];
5919
-		$list=$val['list'];
5920
-		$help=$val['help'];
5921
-		$hidden=(($val['visible'] == 0) ? 1 : 0);			// If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
5918
+		$langfile = $val['langfile'];
5919
+		$list = $val['list'];
5920
+		$help = $val['help'];
5921
+		$hidden = (($val['visible'] == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller)
5922 5922
 
5923 5923
 		if ($hidden) return '';
5924 5924
 
@@ -5942,18 +5942,18 @@  discard block
 block discarded – undo
5942 5942
 				//$showsize=19;
5943 5943
 				$showsize = 'minwidth200imp';
5944 5944
 			}
5945
-			elseif (in_array($type,array('int','double','price')))
5945
+			elseif (in_array($type, array('int', 'double', 'price')))
5946 5946
 			{
5947 5947
 				//$showsize=10;
5948 5948
 				$showsize = 'maxwidth75';
5949 5949
 			}
5950 5950
 			elseif ($type == 'url')
5951 5951
 			{
5952
-				$showsize='minwidth400';
5952
+				$showsize = 'minwidth400';
5953 5953
 			}
5954 5954
 			elseif ($type == 'boolean')
5955 5955
 			{
5956
-				$showsize='';
5956
+				$showsize = '';
5957 5957
 			}
5958 5958
 			else
5959 5959
 			{
@@ -5974,90 +5974,90 @@  discard block
 block discarded – undo
5974 5974
 		}
5975 5975
 
5976 5976
 		// Format output value differently according to properties of field
5977
-		if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value=$this->getNomUrl(1, '', 0, '', 1);
5978
-		elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value=$this->getLibStatut(3);
5977
+		if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value = $this->getNomUrl(1, '', 0, '', 1);
5978
+		elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value = $this->getLibStatut(3);
5979 5979
 		elseif ($type == 'date')
5980 5980
 		{
5981
-			if(! empty($value)) {
5982
-				$value=dol_print_date($value,'day');
5981
+			if (!empty($value)) {
5982
+				$value = dol_print_date($value, 'day');
5983 5983
 			} else {
5984
-				$value='';
5984
+				$value = '';
5985 5985
 			}
5986 5986
 		}
5987 5987
 		elseif ($type == 'datetime')
5988 5988
 		{
5989
-			if(! empty($value)) {
5990
-				$value=dol_print_date($value,'dayhour');
5989
+			if (!empty($value)) {
5990
+				$value = dol_print_date($value, 'dayhour');
5991 5991
 			} else {
5992
-				$value='';
5992
+				$value = '';
5993 5993
 			}
5994 5994
 		}
5995 5995
 		elseif ($type == 'double')
5996 5996
 		{
5997 5997
 			if (!empty($value)) {
5998
-				$value=price($value);
5998
+				$value = price($value);
5999 5999
 			}
6000 6000
 		}
6001 6001
 		elseif ($type == 'boolean')
6002 6002
 		{
6003
-			$checked='';
6003
+			$checked = '';
6004 6004
 			if (!empty($value)) {
6005
-				$checked=' checked ';
6005
+				$checked = ' checked ';
6006 6006
 			}
6007
-			$value='<input type="checkbox" '.$checked.' '.($moreparam?$moreparam:'').' readonly disabled>';
6007
+			$value = '<input type="checkbox" '.$checked.' '.($moreparam ? $moreparam : '').' readonly disabled>';
6008 6008
 		}
6009 6009
 		elseif ($type == 'mail')
6010 6010
 		{
6011
-			$value=dol_print_email($value,0,0,0,64,1,1);
6011
+			$value = dol_print_email($value, 0, 0, 0, 64, 1, 1);
6012 6012
 		}
6013 6013
 		elseif ($type == 'url')
6014 6014
 		{
6015
-			$value=dol_print_url($value,'_blank',32,1);
6015
+			$value = dol_print_url($value, '_blank', 32, 1);
6016 6016
 		}
6017 6017
 		elseif ($type == 'phone')
6018 6018
 		{
6019
-			$value=dol_print_phone($value, '', 0, 0, '', '&nbsp;', 1);
6019
+			$value = dol_print_phone($value, '', 0, 0, '', '&nbsp;', 1);
6020 6020
 		}
6021 6021
 		elseif ($type == 'price')
6022 6022
 		{
6023
-			$value=price($value,0,$langs,0,0,-1,$conf->currency);
6023
+			$value = price($value, 0, $langs, 0, 0, -1, $conf->currency);
6024 6024
 		}
6025 6025
 		elseif ($type == 'select')
6026 6026
 		{
6027
-			$value=$param['options'][$value];
6027
+			$value = $param['options'][$value];
6028 6028
 		}
6029 6029
 		elseif ($type == 'sellist')
6030 6030
 		{
6031
-			$param_list=array_keys($param['options']);
6031
+			$param_list = array_keys($param['options']);
6032 6032
 			$InfoFieldList = explode(":", $param_list[0]);
6033 6033
 
6034
-			$selectkey="rowid";
6035
-			$keyList='rowid';
6034
+			$selectkey = "rowid";
6035
+			$keyList = 'rowid';
6036 6036
 
6037
-			if (count($InfoFieldList)>=3)
6037
+			if (count($InfoFieldList) >= 3)
6038 6038
 			{
6039 6039
 				$selectkey = $InfoFieldList[2];
6040
-				$keyList=$InfoFieldList[2].' as rowid';
6040
+				$keyList = $InfoFieldList[2].' as rowid';
6041 6041
 			}
6042 6042
 
6043
-			$fields_label = explode('|',$InfoFieldList[1]);
6044
-			if(is_array($fields_label)) {
6045
-				$keyList .=', ';
6043
+			$fields_label = explode('|', $InfoFieldList[1]);
6044
+			if (is_array($fields_label)) {
6045
+				$keyList .= ', ';
6046 6046
 				$keyList .= implode(', ', $fields_label);
6047 6047
 			}
6048 6048
 
6049 6049
 			$sql = 'SELECT '.$keyList;
6050
-			$sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[0];
6051
-			if (strpos($InfoFieldList[4], 'extra')!==false)
6050
+			$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
6051
+			if (strpos($InfoFieldList[4], 'extra') !== false)
6052 6052
 			{
6053
-				$sql.= ' as main';
6053
+				$sql .= ' as main';
6054 6054
 			}
6055
-			if ($selectkey=='rowid' && empty($value)) {
6056
-				$sql.= " WHERE ".$selectkey."=0";
6057
-			} elseif ($selectkey=='rowid') {
6058
-				$sql.= " WHERE ".$selectkey."=".$this->db->escape($value);
6059
-			}else {
6060
-				$sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
6055
+			if ($selectkey == 'rowid' && empty($value)) {
6056
+				$sql .= " WHERE ".$selectkey."=0";
6057
+			} elseif ($selectkey == 'rowid') {
6058
+				$sql .= " WHERE ".$selectkey."=".$this->db->escape($value);
6059
+			} else {
6060
+				$sql .= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
6061 6061
 			}
6062 6062
 
6063 6063
 			//$sql.= ' AND entity = '.$conf->entity;
@@ -6066,38 +6066,38 @@  discard block
 block discarded – undo
6066 6066
 			$resql = $this->db->query($sql);
6067 6067
 			if ($resql)
6068 6068
 			{
6069
-				$value='';	// value was used, so now we reste it to use it to build final output
6069
+				$value = ''; // value was used, so now we reste it to use it to build final output
6070 6070
 
6071 6071
 				$obj = $this->db->fetch_object($resql);
6072 6072
 
6073 6073
 				// Several field into label (eq table:code|libelle:rowid)
6074
-				$fields_label = explode('|',$InfoFieldList[1]);
6074
+				$fields_label = explode('|', $InfoFieldList[1]);
6075 6075
 
6076
-				if(is_array($fields_label) && count($fields_label)>1)
6076
+				if (is_array($fields_label) && count($fields_label) > 1)
6077 6077
 				{
6078 6078
 					foreach ($fields_label as $field_toshow)
6079 6079
 					{
6080
-						$translabel='';
6080
+						$translabel = '';
6081 6081
 						if (!empty($obj->$field_toshow)) {
6082
-							$translabel=$langs->trans($obj->$field_toshow);
6082
+							$translabel = $langs->trans($obj->$field_toshow);
6083 6083
 						}
6084
-						if ($translabel!=$field_toshow) {
6085
-							$value.=dol_trunc($translabel,18).' ';
6086
-						}else {
6087
-							$value.=$obj->$field_toshow.' ';
6084
+						if ($translabel != $field_toshow) {
6085
+							$value .= dol_trunc($translabel, 18).' ';
6086
+						} else {
6087
+							$value .= $obj->$field_toshow.' ';
6088 6088
 						}
6089 6089
 					}
6090 6090
 				}
6091 6091
 				else
6092 6092
 				{
6093
-					$translabel='';
6093
+					$translabel = '';
6094 6094
 					if (!empty($obj->{$InfoFieldList[1]})) {
6095
-						$translabel=$langs->trans($obj->{$InfoFieldList[1]});
6095
+						$translabel = $langs->trans($obj->{$InfoFieldList[1]});
6096 6096
 					}
6097
-					if ($translabel!=$obj->{$InfoFieldList[1]}) {
6098
-						$value=dol_trunc($translabel,18);
6099
-					}else {
6100
-						$value=$obj->{$InfoFieldList[1]};
6097
+					if ($translabel != $obj->{$InfoFieldList[1]}) {
6098
+						$value = dol_trunc($translabel, 18);
6099
+					} else {
6100
+						$value = $obj->{$InfoFieldList[1]};
6101 6101
 					}
6102 6102
 				}
6103 6103
 			}
@@ -6105,18 +6105,18 @@  discard block
 block discarded – undo
6105 6105
 		}
6106 6106
 		elseif ($type == 'radio')
6107 6107
 		{
6108
-			$value=$param['options'][$value];
6108
+			$value = $param['options'][$value];
6109 6109
 		}
6110 6110
 		elseif ($type == 'checkbox')
6111 6111
 		{
6112
-			$value_arr=explode(',',$value);
6113
-			$value='';
6114
-			if (is_array($value_arr) && count($value_arr)>0)
6112
+			$value_arr = explode(',', $value);
6113
+			$value = '';
6114
+			if (is_array($value_arr) && count($value_arr) > 0)
6115 6115
 			{
6116 6116
 				foreach ($value_arr as $keyval=>$valueval) {
6117
-					$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>';
6117
+					$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>';
6118 6118
 				}
6119
-				$value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
6119
+				$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
6120 6120
 			}
6121 6121
 		}
6122 6122
 		elseif ($type == 'chkbxlst')
@@ -6131,7 +6131,7 @@  discard block
 block discarded – undo
6131 6131
 
6132 6132
 			if (count($InfoFieldList) >= 3) {
6133 6133
 				$selectkey = $InfoFieldList[2];
6134
-				$keyList = $InfoFieldList[2] . ' as rowid';
6134
+				$keyList = $InfoFieldList[2].' as rowid';
6135 6135
 			}
6136 6136
 
6137 6137
 			$fields_label = explode('|', $InfoFieldList[1]);
@@ -6140,75 +6140,75 @@  discard block
 block discarded – undo
6140 6140
 				$keyList .= implode(', ', $fields_label);
6141 6141
 			}
6142 6142
 
6143
-			$sql = 'SELECT ' . $keyList;
6144
-			$sql .= ' FROM ' . MAIN_DB_PREFIX . $InfoFieldList[0];
6143
+			$sql = 'SELECT '.$keyList;
6144
+			$sql .= ' FROM '.MAIN_DB_PREFIX.$InfoFieldList[0];
6145 6145
 			if (strpos($InfoFieldList[4], 'extra') !== false) {
6146 6146
 				$sql .= ' as main';
6147 6147
 			}
6148 6148
 			// $sql.= " WHERE ".$selectkey."='".$this->db->escape($value)."'";
6149 6149
 			// $sql.= ' AND entity = '.$conf->entity;
6150 6150
 
6151
-			dol_syslog(get_class($this) . ':showOutputField:$type=chkbxlst',LOG_DEBUG);
6151
+			dol_syslog(get_class($this).':showOutputField:$type=chkbxlst', LOG_DEBUG);
6152 6152
 			$resql = $this->db->query($sql);
6153 6153
 			if ($resql) {
6154 6154
 				$value = ''; // value was used, so now we reste it to use it to build final output
6155
-				$toprint=array();
6156
-				while ( $obj = $this->db->fetch_object($resql) ) {
6155
+				$toprint = array();
6156
+				while ($obj = $this->db->fetch_object($resql)) {
6157 6157
 
6158 6158
 					// Several field into label (eq table:code|libelle:rowid)
6159 6159
 					$fields_label = explode('|', $InfoFieldList[1]);
6160 6160
 					if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) {
6161 6161
 						if (is_array($fields_label) && count($fields_label) > 1) {
6162
-							foreach ( $fields_label as $field_toshow ) {
6162
+							foreach ($fields_label as $field_toshow) {
6163 6163
 								$translabel = '';
6164
-								if (! empty($obj->$field_toshow)) {
6164
+								if (!empty($obj->$field_toshow)) {
6165 6165
 									$translabel = $langs->trans($obj->$field_toshow);
6166 6166
 								}
6167 6167
 								if ($translabel != $field_toshow) {
6168
-									$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
6168
+									$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
6169 6169
 								} else {
6170
-									$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->$field_toshow.'</li>';
6170
+									$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->$field_toshow.'</li>';
6171 6171
 								}
6172 6172
 							}
6173 6173
 						} else {
6174 6174
 							$translabel = '';
6175
-							if (! empty($obj->{$InfoFieldList[1]})) {
6175
+							if (!empty($obj->{$InfoFieldList[1]})) {
6176 6176
 								$translabel = $langs->trans($obj->{$InfoFieldList[1]});
6177 6177
 							}
6178 6178
 							if ($translabel != $obj->{$InfoFieldList[1]}) {
6179
-								$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
6179
+								$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.dol_trunc($translabel, 18).'</li>';
6180 6180
 							} else {
6181
-								$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->{$InfoFieldList[1]}.'</li>';
6181
+								$toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$obj->{$InfoFieldList[1]}.'</li>';
6182 6182
 							}
6183 6183
 						}
6184 6184
 					}
6185 6185
 				}
6186
-				$value='<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
6186
+				$value = '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
6187 6187
 			} else {
6188
-				dol_syslog(get_class($this) . '::showOutputField error ' . $this->db->lasterror(), LOG_WARNING);
6188
+				dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
6189 6189
 			}
6190 6190
 		}
6191 6191
 		elseif ($type == 'link')
6192 6192
 		{
6193
-			$out='';
6193
+			$out = '';
6194 6194
 
6195 6195
 			// only if something to display (perf)
6196 6196
 			if ($value)
6197 6197
 			{
6198
-				$param_list=array_keys($param['options']);				// $param_list='ObjectName:classPath'
6198
+				$param_list = array_keys($param['options']); // $param_list='ObjectName:classPath'
6199 6199
 
6200 6200
 				$InfoFieldList = explode(":", $param_list[0]);
6201
-				$classname=$InfoFieldList[0];
6202
-				$classpath=$InfoFieldList[1];
6203
-				$getnomurlparam=(empty($InfoFieldList[2]) ? 3 : $InfoFieldList[2]);
6204
-				if (! empty($classpath))
6201
+				$classname = $InfoFieldList[0];
6202
+				$classpath = $InfoFieldList[1];
6203
+				$getnomurlparam = (empty($InfoFieldList[2]) ? 3 : $InfoFieldList[2]);
6204
+				if (!empty($classpath))
6205 6205
 				{
6206 6206
 					dol_include_once($InfoFieldList[1]);
6207 6207
 					if ($classname && class_exists($classname))
6208 6208
 					{
6209 6209
 						$object = new $classname($this->db);
6210 6210
 						$object->fetch($value);
6211
-						$value=$object->getNomUrl($getnomurlparam);
6211
+						$value = $object->getNomUrl($getnomurlparam);
6212 6212
 					}
6213 6213
 				}
6214 6214
 				else
@@ -6217,15 +6217,15 @@  discard block
 block discarded – undo
6217 6217
 					return 'Error bad setup of extrafield';
6218 6218
 				}
6219 6219
 			}
6220
-			else $value='';
6220
+			else $value = '';
6221 6221
 		}
6222 6222
 		elseif ($type == 'text' || $type == 'html')
6223 6223
 		{
6224
-			$value=dol_htmlentitiesbr($value);
6224
+			$value = dol_htmlentitiesbr($value);
6225 6225
 		}
6226 6226
 		elseif ($type == 'password')
6227 6227
 		{
6228
-			$value=preg_replace('/./i','*',$value);
6228
+			$value = preg_replace('/./i', '*', $value);
6229 6229
 		}
6230 6230
 		elseif ($type == 'array')
6231 6231
 		{
@@ -6233,7 +6233,7 @@  discard block
 block discarded – undo
6233 6233
 		}
6234 6234
 
6235 6235
 		//print $type.'-'.$size;
6236
-		$out=$value;
6236
+		$out = $value;
6237 6237
 
6238 6238
 		return $out;
6239 6239
 	}
@@ -6250,11 +6250,11 @@  discard block
 block discarded – undo
6250 6250
 	 * @param	string		$onetrtd		All fields in same tr td
6251 6251
 	 * @return 	string
6252 6252
 	 */
6253
-	function showOptionals($extrafields, $mode='view', $params=null, $keysuffix='', $keyprefix='', $onetrtd=0)
6253
+	function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0)
6254 6254
 	{
6255 6255
 		global $db, $conf, $langs, $action, $form;
6256 6256
 
6257
-		if (! is_object($form)) $form=new Form($db);
6257
+		if (!is_object($form)) $form = new Form($db);
6258 6258
 
6259 6259
 		$out = '';
6260 6260
 
@@ -6265,10 +6265,10 @@  discard block
 block discarded – undo
6265 6265
 			$out .= "\n";
6266 6266
 
6267 6267
 			$e = 0;
6268
-			foreach($extrafields->attributes[$this->table_element]['label'] as $key=>$label)
6268
+			foreach ($extrafields->attributes[$this->table_element]['label'] as $key=>$label)
6269 6269
 			{
6270 6270
 				// Show only the key field in params
6271
-				if (is_array($params) && array_key_exists('onlykey',$params) && $key != $params['onlykey']) continue;
6271
+				if (is_array($params) && array_key_exists('onlykey', $params) && $key != $params['onlykey']) continue;
6272 6272
 
6273 6273
 				$enabled = 1;
6274 6274
 				if ($enabled && isset($extrafields->attributes[$this->table_element]['list'][$key]))
@@ -6282,25 +6282,25 @@  discard block
 block discarded – undo
6282 6282
 					$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
6283 6283
 				}
6284 6284
 
6285
-				if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue;	// <> -1 and <> 1 and <> 3 = not visible on forms, only on list
6285
+				if (($mode == 'create' || $mode == 'edit') && abs($enabled) != 1 && abs($enabled) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
6286 6286
 				if (empty($perms)) continue;
6287 6287
 
6288 6288
 				// Load language if required
6289
-				if (! empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]);
6289
+				if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]);
6290 6290
 
6291
-				$colspan='3';
6292
-				if (is_array($params) && count($params)>0) {
6293
-					if (array_key_exists('colspan',$params)) {
6294
-						$colspan=$params['colspan'];
6291
+				$colspan = '3';
6292
+				if (is_array($params) && count($params) > 0) {
6293
+					if (array_key_exists('colspan', $params)) {
6294
+						$colspan = $params['colspan'];
6295 6295
 					}
6296 6296
 				}
6297 6297
 
6298
-				switch($mode) {
6298
+				switch ($mode) {
6299 6299
 					case "view":
6300
-						$value=$this->array_options["options_".$key.$keysuffix];
6300
+						$value = $this->array_options["options_".$key.$keysuffix];
6301 6301
 						break;
6302 6302
 					case "edit":
6303
-						$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none');				// GETPOST can get value from GET, POST or setup of default values.
6303
+						$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
6304 6304
 						// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
6305 6305
 						if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
6306 6306
 						{
@@ -6311,7 +6311,7 @@  discard block
 block discarded – undo
6311 6311
 								$value = $getposttemp;
6312 6312
 							}
6313 6313
 						} else {
6314
-							$value = $this->array_options["options_" . $key];			// No GET, no POST, no default value, so we take value of object.
6314
+							$value = $this->array_options["options_".$key]; // No GET, no POST, no default value, so we take value of object.
6315 6315
 						}
6316 6316
 						//var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value);
6317 6317
 						break;
@@ -6323,11 +6323,11 @@  discard block
 block discarded – undo
6323 6323
 				}
6324 6324
 				else
6325 6325
 				{
6326
-					$csstyle='';
6327
-					$class=(!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : '');
6328
-					if (is_array($params) && count($params)>0) {
6329
-						if (array_key_exists('style',$params)) {
6330
-							$csstyle=$params['style'];
6326
+					$csstyle = '';
6327
+					$class = (!empty($extrafields->attributes[$this->table_element]['hidden'][$key]) ? 'hideobject ' : '');
6328
+					if (is_array($params) && count($params) > 0) {
6329
+						if (array_key_exists('style', $params)) {
6330
+							$csstyle = $params['style'];
6331 6331
 						}
6332 6332
 					}
6333 6333
 
@@ -6340,43 +6340,43 @@  discard block
 block discarded – undo
6340 6340
 
6341 6341
 					$out .= '<tr id="'.$html_id.'" '.$csstyle.' class="'.$class.$this->element.'_extras_'.$key.'" '.$domData.' >';
6342 6342
 
6343
-					if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
6343
+					if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0)
6344 6344
 					{
6345
-						if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan='0'; }
6345
+						if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; }
6346 6346
 					}
6347 6347
 
6348 6348
 					if ($action == 'selectlines') { $colspan++; }
6349 6349
 
6350 6350
 					// Convert date into timestamp format (value in memory must be a timestamp)
6351
-					if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('date','datetime')))
6351
+					if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime')))
6352 6352
 					{
6353
-						$datenotinstring = $this->array_options['options_' . $key];
6354
-						if (! is_numeric($this->array_options['options_' . $key]))	// For backward compatibility
6353
+						$datenotinstring = $this->array_options['options_'.$key];
6354
+						if (!is_numeric($this->array_options['options_'.$key]))	// For backward compatibility
6355 6355
 						{
6356 6356
 							$datenotinstring = $this->db->jdate($datenotinstring);
6357 6357
 						}
6358
-						$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min",'int',3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day",'int',3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year",'int',3)):$datenotinstring;
6358
+						$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
6359 6359
 					}
6360 6360
 					// Convert float submited string into real php numeric (value in memory must be a php numeric)
6361
-					if (in_array($extrafields->attributes[$this->table_element]['type'][$key],array('price','double')))
6361
+					if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double')))
6362 6362
 					{
6363
-						$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)):$this->array_options['options_'.$key];
6363
+						$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key];
6364 6364
 					}
6365 6365
 
6366 6366
 					$labeltoshow = $langs->trans($label);
6367 6367
 
6368 6368
 					$out .= '<td class="titlefield';
6369
-					if (GETPOST('action','none') == 'create') $out.='create';
6370
-					if ($mode != 'view' && ! empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired';
6369
+					if (GETPOST('action', 'none') == 'create') $out .= 'create';
6370
+					if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired';
6371 6371
 					$out .= '">';
6372
-					if (! empty($extrafields->attributes[$object->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]);
6372
+					if (!empty($extrafields->attributes[$object->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$object->table_element]['help'][$key]);
6373 6373
 					else $out .= $labeltoshow;
6374 6374
 					$out .= '</td>';
6375 6375
 
6376 6376
 					$html_id = !empty($this->id) ? $this->element.'_extras_'.$key.'_'.$this->id : '';
6377
-					$out .='<td id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'" '.($colspan?' colspan="'.$colspan.'"':'').'>';
6377
+					$out .= '<td id="'.$html_id.'" class="'.$this->element.'_extras_'.$key.'" '.($colspan ? ' colspan="'.$colspan.'"' : '').'>';
6378 6378
 
6379
-					switch($mode) {
6379
+					switch ($mode) {
6380 6380
 						case "view":
6381 6381
 							$out .= $extrafields->showOutputField($key, $value);
6382 6382
 							break;
@@ -6387,14 +6387,14 @@  discard block
 block discarded – undo
6387 6387
 
6388 6388
 					$out .= '</td>';
6389 6389
 
6390
-					if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
6390
+					if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= '</tr>';
6391 6391
 					else $out .= '</tr>';
6392 6392
 					$e++;
6393 6393
 				}
6394 6394
 			}
6395 6395
 			$out .= "\n";
6396 6396
 			// Add code to manage list depending on others
6397
-			if (! empty($conf->use_javascript_ajax)) {
6397
+			if (!empty($conf->use_javascript_ajax)) {
6398 6398
 				$out .= '
6399 6399
 				<script type="text/javascript">
6400 6400
 				    jQuery(document).ready(function() {
@@ -6440,7 +6440,7 @@  discard block
 block discarded – undo
6440 6440
 		global $user;
6441 6441
 
6442 6442
 		$element = $this->element;
6443
-		if ($element == 'facturerec') $element='facture';
6443
+		if ($element == 'facturerec') $element = 'facture';
6444 6444
 
6445 6445
 		return $user->rights->{$element};
6446 6446
 	}
@@ -6457,15 +6457,15 @@  discard block
 block discarded – undo
6457 6457
 	 * @param  int         $ignoreerrors  Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one)
6458 6458
 	 * @return bool						  True if success, False if error
6459 6459
 	 */
6460
-	public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
6460
+	public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0)
6461 6461
 	{
6462 6462
 		foreach ($tables as $table)
6463 6463
 		{
6464 6464
 			$sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_soc = '.$dest_id.' WHERE fk_soc = '.$origin_id;
6465 6465
 
6466
-			if (! $db->query($sql))
6466
+			if (!$db->query($sql))
6467 6467
 			{
6468
-				if ($ignoreerrors) return true;		// TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B.
6468
+				if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B.
6469 6469
 				//$this->errors = $db->lasterror();
6470 6470
 				return false;
6471 6471
 			}
@@ -6499,7 +6499,7 @@  discard block
 block discarded – undo
6499 6499
 		else
6500 6500
 		{
6501 6501
 			// Get cost price for margin calculation
6502
-			if (! empty($fk_product))
6502
+			if (!empty($fk_product))
6503 6503
 			{
6504 6504
 				if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice')
6505 6505
 				{
@@ -6536,7 +6536,7 @@  discard block
 block discarded – undo
6536 6536
 					}
6537 6537
 				}
6538 6538
 
6539
-				if (empty($buyPrice) && isset($conf->global->MARGIN_TYPE) && in_array($conf->global->MARGIN_TYPE, array('1','pmp','costprice')))
6539
+				if (empty($buyPrice) && isset($conf->global->MARGIN_TYPE) && in_array($conf->global->MARGIN_TYPE, array('1', 'pmp', 'costprice')))
6540 6540
 				{
6541 6541
 					require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
6542 6542
 					$productFournisseur = new ProductFournisseur($this->db);
@@ -6573,18 +6573,18 @@  discard block
 block discarded – undo
6573 6573
 	 *  @param		int		$usesharelink	Use the public shared link of image (if not available, the 'nophoto' image will be shown instead)
6574 6574
 	 *  @return     string					Html code to show photo. Number of photos shown is saved in this->nbphoto
6575 6575
 	 */
6576
-	function show_photos($modulepart, $sdir, $size=0, $nbmax=0, $nbbyrow=5, $showfilename=0, $showaction=0, $maxHeight=120, $maxWidth=160, $nolink=0, $notitle=0, $usesharelink=0)
6576
+	function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0)
6577 6577
 	{
6578 6578
         // phpcs:enable
6579
-		global $conf,$user,$langs;
6579
+		global $conf, $user, $langs;
6580 6580
 
6581
-		include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
6582
-		include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php';
6581
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
6582
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
6583 6583
 
6584
-		$sortfield='position_name';
6585
-		$sortorder='asc';
6584
+		$sortfield = 'position_name';
6585
+		$sortorder = 'asc';
6586 6586
 
6587
-		$dir = $sdir . '/';
6587
+		$dir = $sdir.'/';
6588 6588
 		$pdir = '/';
6589 6589
 		if ($modulepart == 'ticket')
6590 6590
 		{
@@ -6598,28 +6598,28 @@  discard block
 block discarded – undo
6598 6598
 		}
6599 6599
 
6600 6600
 		// For backward compatibility
6601
-		if ($modulepart == 'product' && ! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
6601
+		if ($modulepart == 'product' && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
6602 6602
 		{
6603
-			$dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,$modulepart) . $this->id ."/photos/";
6604
-			$pdir = '/' . get_exdir($this->id,2,0,0,$this,$modulepart) . $this->id ."/photos/";
6603
+			$dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/";
6604
+			$pdir = '/'.get_exdir($this->id, 2, 0, 0, $this, $modulepart).$this->id."/photos/";
6605 6605
 		}
6606 6606
 
6607 6607
 		// Defined relative dir to DOL_DATA_ROOT
6608 6608
 		$relativedir = '';
6609 6609
 		if ($dir)
6610 6610
 		{
6611
-			$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $dir);
6612
-			$relativedir = preg_replace('/^[\\/]/','',$relativedir);
6613
-			$relativedir = preg_replace('/[\\/]$/','',$relativedir);
6611
+			$relativedir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT, '/').'/', '', $dir);
6612
+			$relativedir = preg_replace('/^[\\/]/', '', $relativedir);
6613
+			$relativedir = preg_replace('/[\\/]$/', '', $relativedir);
6614 6614
 		}
6615 6615
 
6616 6616
 		$dirthumb = $dir.'thumbs/';
6617 6617
 		$pdirthumb = $pdir.'thumbs/';
6618 6618
 
6619
-		$return ='<!-- Photo -->'."\n";
6620
-		$nbphoto=0;
6619
+		$return = '<!-- Photo -->'."\n";
6620
+		$nbphoto = 0;
6621 6621
 
6622
-		$filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
6622
+		$filearray = dol_dir_list($dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
6623 6623
 
6624 6624
 		/*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))    // For backward compatiblity, we scan also old dirs
6625 6625
 		 {
@@ -6633,12 +6633,12 @@  discard block
 block discarded – undo
6633 6633
 		{
6634 6634
 			if ($sortfield && $sortorder)
6635 6635
 			{
6636
-				$filearray=dol_sort_array($filearray, $sortfield, $sortorder);
6636
+				$filearray = dol_sort_array($filearray, $sortfield, $sortorder);
6637 6637
 			}
6638 6638
 
6639
-			foreach($filearray as $key => $val)
6639
+			foreach ($filearray as $key => $val)
6640 6640
 			{
6641
-				$photo='';
6641
+				$photo = '';
6642 6642
 				$file = $val['name'];
6643 6643
 
6644 6644
 				//if (! utf8_check($file)) $file=utf8_encode($file);	// To be sure file is stored in UTF8 in memory
@@ -6653,36 +6653,36 @@  discard block
 block discarded – undo
6653 6653
 					if ($size == 1 || $size == 'small') {   // Format vignette
6654 6654
 
6655 6655
 						// Find name of thumb file
6656
-						$photo_vignette=basename(getImageFileNameForSize($dir.$file, '_small'));
6657
-						if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette='';
6656
+						$photo_vignette = basename(getImageFileNameForSize($dir.$file, '_small'));
6657
+						if (!dol_is_file($dirthumb.$photo_vignette)) $photo_vignette = '';
6658 6658
 
6659 6659
 						// Get filesize of original file
6660
-						$imgarray=dol_getImageSize($dir.$photo);
6660
+						$imgarray = dol_getImageSize($dir.$photo);
6661 6661
 
6662 6662
 						if ($nbbyrow > 0)
6663 6663
 						{
6664
-							if ($nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
6664
+							if ($nbphoto == 1) $return .= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
6665 6665
 
6666
-							if ($nbphoto % $nbbyrow == 1) $return.= '<tr align=center valign=middle border=1>';
6667
-							$return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
6666
+							if ($nbphoto % $nbbyrow == 1) $return .= '<tr align=center valign=middle border=1>';
6667
+							$return .= '<td width="'.ceil(100 / $nbbyrow).'%" class="photo">';
6668 6668
 						}
6669 6669
 						else if ($nbbyrow < 0) $return .= '<div class="inline-block">';
6670 6670
 
6671
-						$return.= "\n";
6671
+						$return .= "\n";
6672 6672
 
6673
-						$relativefile=preg_replace('/^\//', '', $pdir.$photo);
6673
+						$relativefile = preg_replace('/^\//', '', $pdir.$photo);
6674 6674
 						if (empty($nolink))
6675 6675
 						{
6676
-							$urladvanced=getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity);
6677
-							if ($urladvanced) $return.='<a href="'.$urladvanced.'">';
6678
-							else $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
6676
+							$urladvanced = getAdvancedPreviewUrl($modulepart, $relativefile, 0, 'entity='.$this->entity);
6677
+							if ($urladvanced) $return .= '<a href="'.$urladvanced.'">';
6678
+							else $return .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="aphoto" target="_blank">';
6679 6679
 						}
6680 6680
 
6681 6681
 						// Show image (width height=$maxHeight)
6682 6682
 						// Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine
6683
-						$alt=$langs->transnoentitiesnoconv('File').': '.$relativefile;
6684
-						$alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
6685
-						if ($notitle) $alt='';
6683
+						$alt = $langs->transnoentitiesnoconv('File').': '.$relativefile;
6684
+						$alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height'];
6685
+						if ($notitle) $alt = '';
6686 6686
 
6687 6687
 						if ($usesharelink)
6688 6688
 						{
@@ -6690,81 +6690,81 @@  discard block
 block discarded – undo
6690 6690
 							{
6691 6691
 								if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
6692 6692
 								{
6693
-									$return.= '<!-- Show original file (thumb not yet available with shared links) -->';
6694
-									$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
6693
+									$return .= '<!-- Show original file (thumb not yet available with shared links) -->';
6694
+									$return .= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
6695 6695
 								}
6696 6696
 								else {
6697
-									$return.= '<!-- Show original file -->';
6698
-									$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
6697
+									$return .= '<!-- Show original file -->';
6698
+									$return .= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?hashp='.urlencode($val['share']).'" title="'.dol_escape_htmltag($alt).'">';
6699 6699
 								}
6700 6700
 							}
6701 6701
 							else
6702 6702
 							{
6703
-								$return.= '<!-- Show nophoto file (because file is not shared) -->';
6704
-								$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">';
6703
+								$return .= '<!-- Show nophoto file (because file is not shared) -->';
6704
+								$return .= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png" title="'.dol_escape_htmltag($alt).'">';
6705 6705
 							}
6706 6706
 						}
6707 6707
 						else
6708 6708
 						{
6709 6709
 							if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
6710 6710
 							{
6711
-								$return.= '<!-- Show thumb -->';
6712
-								$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
6711
+								$return .= '<!-- Show thumb -->';
6712
+								$return .= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">';
6713 6713
 							}
6714 6714
 							else {
6715
-								$return.= '<!-- Show original file -->';
6716
-								$return.= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
6715
+								$return .= '<!-- Show original file -->';
6716
+								$return .= '<img class="photo photowithmargin" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">';
6717 6717
 							}
6718 6718
 						}
6719 6719
 
6720
-						if (empty($nolink)) $return.= '</a>';
6721
-						$return.="\n";
6720
+						if (empty($nolink)) $return .= '</a>';
6721
+						$return .= "\n";
6722 6722
 
6723
-						if ($showfilename) $return.= '<br>'.$viewfilename;
6723
+						if ($showfilename) $return .= '<br>'.$viewfilename;
6724 6724
 						if ($showaction)
6725 6725
 						{
6726
-							$return.= '<br>';
6726
+							$return .= '<br>';
6727 6727
 							// On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites
6728 6728
 							if ($photo_vignette && (image_format_supported($photo) > 0) && ($this->imgWidth > $maxWidth || $this->imgHeight > $maxHeight))
6729 6729
 							{
6730
-								$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
6730
+								$return .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=addthumb&amp;file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'), 'refresh').'&nbsp;&nbsp;</a>';
6731 6731
 							}
6732 6732
 							// Special cas for product
6733 6733
 							if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer))
6734 6734
 							{
6735 6735
 								// Link to resize
6736
-								$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> &nbsp; ';
6736
+								$return .= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> &nbsp; ';
6737 6737
 
6738 6738
 								// Link to delete
6739
-								$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
6740
-								$return.= img_delete().'</a>';
6739
+								$return .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
6740
+								$return .= img_delete().'</a>';
6741 6741
 							}
6742 6742
 						}
6743
-						$return.= "\n";
6743
+						$return .= "\n";
6744 6744
 
6745 6745
 						if ($nbbyrow > 0)
6746 6746
 						{
6747
-							$return.= '</td>';
6748
-							if (($nbphoto % $nbbyrow) == 0) $return.= '</tr>';
6747
+							$return .= '</td>';
6748
+							if (($nbphoto % $nbbyrow) == 0) $return .= '</tr>';
6749 6749
 						}
6750
-						else if ($nbbyrow < 0) $return.='</div>';
6750
+						else if ($nbbyrow < 0) $return .= '</div>';
6751 6751
 					}
6752 6752
 
6753 6753
 					if (empty($size)) {     // Format origine
6754
-						$return.= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">';
6754
+						$return .= '<img class="photo photowithmargin" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">';
6755 6755
 
6756
-						if ($showfilename) $return.= '<br>'.$viewfilename;
6756
+						if ($showfilename) $return .= '<br>'.$viewfilename;
6757 6757
 						if ($showaction)
6758 6758
 						{
6759 6759
 							// Special case for product
6760 6760
 							if ($modulepart == 'product' && ($user->rights->produit->creer || $user->rights->service->creer))
6761 6761
 							{
6762 6762
 								// Link to resize
6763
-								$return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> &nbsp; ';
6763
+								$return .= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$this->id.'&amp;file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"), 'resize', '').'</a> &nbsp; ';
6764 6764
 
6765 6765
 								// Link to delete
6766
-								$return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
6767
-								$return.= img_delete().'</a>';
6766
+								$return .= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=delete&amp;file='.urlencode($pdir.$viewfilename).'">';
6767
+								$return .= img_delete().'</a>';
6768 6768
 							}
6769 6769
 						}
6770 6770
 					}
@@ -6774,18 +6774,18 @@  discard block
 block discarded – undo
6774 6774
 				}
6775 6775
 			}
6776 6776
 
6777
-			if ($size==1 || $size=='small')
6777
+			if ($size == 1 || $size == 'small')
6778 6778
 			{
6779 6779
 				if ($nbbyrow > 0)
6780 6780
 				{
6781 6781
 					// Ferme tableau
6782 6782
 					while ($nbphoto % $nbbyrow)
6783 6783
 					{
6784
-						$return.= '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
6784
+						$return .= '<td width="'.ceil(100 / $nbbyrow).'%">&nbsp;</td>';
6785 6785
 						$nbphoto++;
6786 6786
 					}
6787 6787
 
6788
-					if ($nbphoto) $return.= '</table>';
6788
+					if ($nbphoto) $return .= '</table>';
6789 6789
 				}
6790 6790
 			}
6791 6791
 		}
@@ -6804,9 +6804,9 @@  discard block
 block discarded – undo
6804 6804
 	 */
6805 6805
 	protected function isArray($info)
6806 6806
 	{
6807
-		if(is_array($info))
6807
+		if (is_array($info))
6808 6808
 		{
6809
-			if(isset($info['type']) && $info['type']=='array') return true;
6809
+			if (isset($info['type']) && $info['type'] == 'array') return true;
6810 6810
 			else return false;
6811 6811
 		}
6812 6812
 		else return false;
@@ -6820,9 +6820,9 @@  discard block
 block discarded – undo
6820 6820
 	 */
6821 6821
 	protected function isNull($info)
6822 6822
 	{
6823
-		if(is_array($info))
6823
+		if (is_array($info))
6824 6824
 		{
6825
-			if(isset($info['type']) && $info['type']=='null') return true;
6825
+			if (isset($info['type']) && $info['type'] == 'null') return true;
6826 6826
 			else return false;
6827 6827
 		}
6828 6828
 		else return false;
@@ -6836,7 +6836,7 @@  discard block
 block discarded – undo
6836 6836
 	 */
6837 6837
 	public function isDate($info)
6838 6838
 	{
6839
-		if(isset($info['type']) && ($info['type']=='date' || $info['type']=='datetime' || $info['type']=='timestamp')) return true;
6839
+		if (isset($info['type']) && ($info['type'] == 'date' || $info['type'] == 'datetime' || $info['type'] == 'timestamp')) return true;
6840 6840
 		else return false;
6841 6841
 	}
6842 6842
 
@@ -6848,9 +6848,9 @@  discard block
 block discarded – undo
6848 6848
 	 */
6849 6849
 	public function isInt($info)
6850 6850
 	{
6851
-		if(is_array($info))
6851
+		if (is_array($info))
6852 6852
 		{
6853
-			if(isset($info['type']) && ($info['type']=='int' || preg_match('/^integer/i',$info['type']) ) ) return true;
6853
+			if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) return true;
6854 6854
 			else return false;
6855 6855
 		}
6856 6856
 		else return false;
@@ -6864,7 +6864,7 @@  discard block
 block discarded – undo
6864 6864
 	 */
6865 6865
 	public function isFloat($info)
6866 6866
 	{
6867
-		if(is_array($info))
6867
+		if (is_array($info))
6868 6868
 		{
6869 6869
 			if (isset($info['type']) && (preg_match('/^(double|real)/i', $info['type']))) return true;
6870 6870
 			else return false;
@@ -6880,9 +6880,9 @@  discard block
 block discarded – undo
6880 6880
 	 */
6881 6881
 	public function isText($info)
6882 6882
 	{
6883
-		if(is_array($info))
6883
+		if (is_array($info))
6884 6884
 		{
6885
-			if(isset($info['type']) && $info['type']=='text') return true;
6885
+			if (isset($info['type']) && $info['type'] == 'text') return true;
6886 6886
 			else return false;
6887 6887
 		}
6888 6888
 		else return false;
@@ -6896,9 +6896,9 @@  discard block
 block discarded – undo
6896 6896
 	 */
6897 6897
 	protected function isIndex($info)
6898 6898
 	{
6899
-		if(is_array($info))
6899
+		if (is_array($info))
6900 6900
 		{
6901
-			if(isset($info['index']) && $info['index']==true) return true;
6901
+			if (isset($info['index']) && $info['index'] == true) return true;
6902 6902
 			else return false;
6903 6903
 		}
6904 6904
 		else return false;
@@ -6914,13 +6914,13 @@  discard block
 block discarded – undo
6914 6914
 	{
6915 6915
 		global $conf;
6916 6916
 
6917
-		$queryarray=array();
6917
+		$queryarray = array();
6918 6918
 		foreach ($this->fields as $field=>$info)	// Loop on definition of fields
6919 6919
 		{
6920 6920
 			// Depending on field type ('datetime', ...)
6921
-			if($this->isDate($info))
6921
+			if ($this->isDate($info))
6922 6922
 			{
6923
-				if(empty($this->{$field}))
6923
+				if (empty($this->{$field}))
6924 6924
 				{
6925 6925
 					$queryarray[$field] = null;
6926 6926
 				}
@@ -6929,10 +6929,10 @@  discard block
 block discarded – undo
6929 6929
 					$queryarray[$field] = $this->db->idate($this->{$field});
6930 6930
 				}
6931 6931
 			}
6932
-			else if($this->isArray($info))
6932
+			else if ($this->isArray($info))
6933 6933
 			{
6934
-				if(! empty($this->{$field})) {
6935
-					if(! is_array($this->{$field})) {
6934
+				if (!empty($this->{$field})) {
6935
+					if (!is_array($this->{$field})) {
6936 6936
 						$this->{$field} = array($this->{$field});
6937 6937
 					}
6938 6938
 					$queryarray[$field] = serialize($this->{$field});
@@ -6940,19 +6940,19 @@  discard block
 block discarded – undo
6940 6940
 					$queryarray[$field] = null;
6941 6941
 				}
6942 6942
 			}
6943
-			else if($this->isInt($info))
6943
+			else if ($this->isInt($info))
6944 6944
 			{
6945
-				if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field]=$conf->entity;
6945
+				if ($field == 'entity' && is_null($this->{$field})) $queryarray[$field] = $conf->entity;
6946 6946
 				else
6947 6947
 				{
6948 6948
 					$queryarray[$field] = (int) price2num($this->{$field});
6949
-					if (empty($queryarray[$field])) $queryarray[$field]=0;		// May be reset to null later if property 'notnull' is -1 for this field.
6949
+					if (empty($queryarray[$field])) $queryarray[$field] = 0; // May be reset to null later if property 'notnull' is -1 for this field.
6950 6950
 				}
6951 6951
 			}
6952
-			else if($this->isFloat($info))
6952
+			else if ($this->isFloat($info))
6953 6953
 			{
6954 6954
 				$queryarray[$field] = (double) price2num($this->{$field});
6955
-				if (empty($queryarray[$field])) $queryarray[$field]=0;
6955
+				if (empty($queryarray[$field])) $queryarray[$field] = 0;
6956 6956
 			}
6957 6957
 			else
6958 6958
 			{
@@ -6960,7 +6960,7 @@  discard block
 block discarded – undo
6960 6960
 			}
6961 6961
 
6962 6962
 			if ($info['type'] == 'timestamp' && empty($queryarray[$field])) unset($queryarray[$field]);
6963
-			if (! empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null;
6963
+			if (!empty($info['notnull']) && $info['notnull'] == -1 && empty($queryarray[$field])) $queryarray[$field] = null;
6964 6964
 		}
6965 6965
 
6966 6966
 		return $queryarray;
@@ -6976,35 +6976,35 @@  discard block
 block discarded – undo
6976 6976
 	{
6977 6977
 		foreach ($this->fields as $field => $info)
6978 6978
 		{
6979
-			if($this->isDate($info))
6979
+			if ($this->isDate($info))
6980 6980
 			{
6981
-				if(empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
6981
+				if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
6982 6982
 				else $this->{$field} = strtotime($obj->{$field});
6983 6983
 			}
6984
-			elseif($this->isArray($info))
6984
+			elseif ($this->isArray($info))
6985 6985
 			{
6986
-				if(! empty($obj->{$field})) {
6986
+				if (!empty($obj->{$field})) {
6987 6987
 					$this->{$field} = @unserialize($obj->{$field});
6988 6988
 					// Hack for data not in UTF8
6989
-					if($this->{$field } === false) @unserialize(utf8_decode($obj->{$field}));
6989
+					if ($this->{$field } === false) @unserialize(utf8_decode($obj->{$field}));
6990 6990
 				} else {
6991 6991
 					$this->{$field} = array();
6992 6992
 				}
6993 6993
 			}
6994
-			elseif($this->isInt($info))
6994
+			elseif ($this->isInt($info))
6995 6995
 			{
6996 6996
 				if ($field == 'rowid') $this->id = (int) $obj->{$field};
6997 6997
 				else $this->{$field} = (int) $obj->{$field};
6998 6998
 			}
6999
-			elseif($this->isFloat($info))
6999
+			elseif ($this->isFloat($info))
7000 7000
 			{
7001 7001
 				$this->{$field} = (double) $obj->{$field};
7002 7002
 			}
7003
-			elseif($this->isNull($info))
7003
+			elseif ($this->isNull($info))
7004 7004
 			{
7005 7005
 				$val = $obj->{$field};
7006 7006
 				// zero is not null
7007
-				$this->{$field} = (is_null($val) || (empty($val) && $val!==0 && $val!=='0') ? null : $val);
7007
+				$this->{$field} = (is_null($val) || (empty($val) && $val !== 0 && $val !== '0') ? null : $val);
7008 7008
 			}
7009 7009
 			else
7010 7010
 			{
@@ -7013,7 +7013,7 @@  discard block
 block discarded – undo
7013 7013
 		}
7014 7014
 
7015 7015
 		// If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions.
7016
-		if (! isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id;
7016
+		if (!isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id;
7017 7017
 	}
7018 7018
 
7019 7019
 	/**
@@ -7055,14 +7055,14 @@  discard block
 block discarded – undo
7055 7055
 
7056 7056
 		$error = 0;
7057 7057
 
7058
-		$now=dol_now();
7058
+		$now = dol_now();
7059 7059
 
7060 7060
 		$fieldvalues = $this->setSaveQuery();
7061
-		if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation']=$this->db->idate($now);
7062
-		if (array_key_exists('fk_user_creat', $fieldvalues) && ! ($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat']=$user->id;
7063
-		unset($fieldvalues['rowid']);	// The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
7061
+		if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now);
7062
+		if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id;
7063
+		unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
7064 7064
 
7065
-		$keys=array();
7065
+		$keys = array();
7066 7066
 		$values = array();
7067 7067
 		foreach ($fieldvalues as $k => $v) {
7068 7068
 			$keys[$k] = $k;
@@ -7071,58 +7071,58 @@  discard block
 block discarded – undo
7071 7071
 		}
7072 7072
 
7073 7073
 		// Clean and check mandatory
7074
-		foreach($keys as $key)
7074
+		foreach ($keys as $key)
7075 7075
 		{
7076 7076
 			// If field is an implicit foreign key field
7077
-			if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]='';
7078
-			if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]='';
7077
+			if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = '';
7078
+			if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = '';
7079 7079
 
7080 7080
 			//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
7081
-			if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && ! isset($values[$key]) && is_null($val['default']))
7081
+			if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && !isset($values[$key]) && is_null($val['default']))
7082 7082
 			{
7083 7083
 				$error++;
7084
-				$this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
7084
+				$this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
7085 7085
 			}
7086 7086
 
7087 7087
 			// If field is an implicit foreign key field
7088
-			if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key]='null';
7089
-			if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key]='null';
7088
+			if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key] = 'null';
7089
+			if (!empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key] = 'null';
7090 7090
 		}
7091 7091
 
7092 7092
 		if ($error) return -1;
7093 7093
 
7094 7094
 		$this->db->begin();
7095 7095
 
7096
-		if (! $error)
7096
+		if (!$error)
7097 7097
 		{
7098 7098
 			$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
7099
-			$sql.= ' ('.implode( ", ", $keys ).')';
7100
-			$sql.= ' VALUES ('.implode( ", ", $values ).')';
7099
+			$sql .= ' ('.implode(", ", $keys).')';
7100
+			$sql .= ' VALUES ('.implode(", ", $values).')';
7101 7101
 
7102 7102
 			$res = $this->db->query($sql);
7103
-			if ($res===false) {
7103
+			if ($res === false) {
7104 7104
 				$error++;
7105 7105
 				$this->errors[] = $this->db->lasterror();
7106 7106
 			}
7107 7107
 		}
7108 7108
 
7109
-		if (! $error)
7109
+		if (!$error)
7110 7110
 		{
7111
-			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
7111
+			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
7112 7112
 		}
7113 7113
 
7114 7114
 		// Create extrafields
7115
-		if (! $error)
7115
+		if (!$error)
7116 7116
 		{
7117
-			$result=$this->insertExtraFields();
7117
+			$result = $this->insertExtraFields();
7118 7118
 			if ($result < 0) $error++;
7119 7119
 		}
7120 7120
 
7121 7121
 		// Triggers
7122
-		if (! $error && ! $notrigger)
7122
+		if (!$error && !$notrigger)
7123 7123
 		{
7124 7124
 			// Call triggers
7125
-			$result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE',$user);
7125
+			$result = $this->call_trigger(strtoupper(get_class($this)).'_CREATE', $user);
7126 7126
 			if ($result < 0) { $error++; }
7127 7127
 			// End call triggers
7128 7128
 		}
@@ -7151,13 +7151,13 @@  discard block
 block discarded – undo
7151 7151
 		if (empty($id) && empty($ref) && empty($morewhere)) return -1;
7152 7152
 
7153 7153
 		$sql = 'SELECT '.$this->getFieldList();
7154
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
7154
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
7155 7155
 
7156
-		if (!empty($id))  $sql.= ' WHERE rowid = '.$id;
7157
-		elseif (!empty($ref)) $sql.= " WHERE ref = ".$this->quote($ref, $this->fields['ref']);
7158
-		else $sql.=' WHERE 1 = 1';	// usage with empty id and empty ref is very rare
7159
-		if ($morewhere)   $sql.= $morewhere;
7160
-		$sql.=' LIMIT 1';	// This is a fetch, to be sure to get only one record
7156
+		if (!empty($id))  $sql .= ' WHERE rowid = '.$id;
7157
+		elseif (!empty($ref)) $sql .= " WHERE ref = ".$this->quote($ref, $this->fields['ref']);
7158
+		else $sql .= ' WHERE 1 = 1'; // usage with empty id and empty ref is very rare
7159
+		if ($morewhere)   $sql .= $morewhere;
7160
+		$sql .= ' LIMIT 1'; // This is a fetch, to be sure to get only one record
7161 7161
 
7162 7162
 		$res = $this->db->query($sql);
7163 7163
 		if ($res)
@@ -7194,14 +7194,14 @@  discard block
 block discarded – undo
7194 7194
 
7195 7195
 		$error = 0;
7196 7196
 
7197
-		$now=dol_now();
7197
+		$now = dol_now();
7198 7198
 
7199 7199
 		$fieldvalues = $this->setSaveQuery();
7200
-		if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification']=$this->db->idate($now);
7201
-		if (array_key_exists('fk_user_modif', $fieldvalues) && ! ($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif']=$user->id;
7202
-		unset($fieldvalues['rowid']);	// The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
7200
+		if (array_key_exists('date_modification', $fieldvalues) && empty($fieldvalues['date_modification'])) $fieldvalues['date_modification'] = $this->db->idate($now);
7201
+		if (array_key_exists('fk_user_modif', $fieldvalues) && !($fieldvalues['fk_user_modif'] > 0)) $fieldvalues['fk_user_modif'] = $user->id;
7202
+		unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
7203 7203
 
7204
-		$keys=array();
7204
+		$keys = array();
7205 7205
 		$values = array();
7206 7206
 		foreach ($fieldvalues as $k => $v) {
7207 7207
 			$keys[$k] = $k;
@@ -7211,10 +7211,10 @@  discard block
 block discarded – undo
7211 7211
 		}
7212 7212
 
7213 7213
 		// Clean and check mandatory
7214
-		foreach($keys as $key)
7214
+		foreach ($keys as $key)
7215 7215
 		{
7216
-			if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]='';		// This is an implicit foreign key field
7217
-			if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]='';					// This is an explicit foreign key field
7216
+			if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; // This is an implicit foreign key field
7217
+			if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; // This is an explicit foreign key field
7218 7218
 
7219 7219
 			//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
7220 7220
 			/*
@@ -7225,13 +7225,13 @@  discard block
 block discarded – undo
7225 7225
 			}*/
7226 7226
 		}
7227 7227
 
7228
-		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode( ',', $tmp ).' WHERE rowid='.$this->id ;
7228
+		$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET '.implode(',', $tmp).' WHERE rowid='.$this->id;
7229 7229
 
7230 7230
 		$this->db->begin();
7231
-		if (! $error)
7231
+		if (!$error)
7232 7232
 		{
7233 7233
 			$res = $this->db->query($sql);
7234
-			if ($res===false)
7234
+			if ($res === false)
7235 7235
 			{
7236 7236
 				$error++;
7237 7237
 				$this->errors[] = $this->db->lasterror();
@@ -7239,9 +7239,9 @@  discard block
 block discarded – undo
7239 7239
 		}
7240 7240
 
7241 7241
 		// Update extrafield
7242
-		if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options)>0)
7242
+		if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($this->array_options) && count($this->array_options) > 0)
7243 7243
 		{
7244
-			$result=$this->insertExtraFields();
7244
+			$result = $this->insertExtraFields();
7245 7245
 			if ($result < 0)
7246 7246
 			{
7247 7247
 				$error++;
@@ -7249,10 +7249,10 @@  discard block
 block discarded – undo
7249 7249
 		}
7250 7250
 
7251 7251
 		// Triggers
7252
-		if (! $error && ! $notrigger)
7252
+		if (!$error && !$notrigger)
7253 7253
 		{
7254 7254
 			// Call triggers
7255
-			$result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user);
7255
+			$result = $this->call_trigger(strtoupper(get_class($this)).'_MODIFY', $user);
7256 7256
 			if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
7257 7257
 			// End call triggers
7258 7258
 		}
@@ -7275,68 +7275,68 @@  discard block
 block discarded – undo
7275 7275
 	 * @param	int		$forcechilddeletion		0=no, 1=Force deletion of children
7276 7276
 	 * @return 	int             				<=0 if KO, >0 if OK
7277 7277
 	 */
7278
-	public function deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
7278
+	public function deleteCommon(User $user, $notrigger = false, $forcechilddeletion = 0)
7279 7279
 	{
7280
-		$error=0;
7280
+		$error = 0;
7281 7281
 
7282 7282
 		$this->db->begin();
7283 7283
 
7284 7284
 		if ($forcechilddeletion)
7285 7285
 		{
7286
-			foreach($this->childtables as $table)
7286
+			foreach ($this->childtables as $table)
7287 7287
 			{
7288 7288
 				$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$table.' WHERE '.$this->fk_element.' = '.$this->id;
7289 7289
 				$resql = $this->db->query($sql);
7290
-				if (! $resql)
7290
+				if (!$resql)
7291 7291
 				{
7292
-					$this->error=$this->db->lasterror();
7293
-					$this->errors[]=$this->error;
7292
+					$this->error = $this->db->lasterror();
7293
+					$this->errors[] = $this->error;
7294 7294
 					$this->db->rollback();
7295 7295
 					return -1;
7296 7296
 				}
7297 7297
 			}
7298 7298
 		}
7299
-		elseif (! empty($this->fk_element) && ! empty($this->childtables))	// If object has childs linked with a foreign key field, we check all child tables.
7299
+		elseif (!empty($this->fk_element) && !empty($this->childtables))	// If object has childs linked with a foreign key field, we check all child tables.
7300 7300
 		{
7301 7301
 			$objectisused = $this->isObjectUsed($this->id);
7302
-			if (! empty($objectisused))
7302
+			if (!empty($objectisused))
7303 7303
 			{
7304 7304
 				dol_syslog(get_class($this)."::deleteCommon Can't delete record as it has some child", LOG_WARNING);
7305
-				$this->error='ErrorRecordHasChildren';
7306
-				$this->errors[]=$this->error;
7305
+				$this->error = 'ErrorRecordHasChildren';
7306
+				$this->errors[] = $this->error;
7307 7307
 				$this->db->rollback();
7308 7308
 				return 0;
7309 7309
 			}
7310 7310
 		}
7311 7311
 
7312
-		if (! $error) {
7313
-			if (! $notrigger) {
7312
+		if (!$error) {
7313
+			if (!$notrigger) {
7314 7314
 				// Call triggers
7315
-				$result=$this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user);
7315
+				$result = $this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user);
7316 7316
 				if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
7317 7317
 				// End call triggers
7318 7318
 			}
7319 7319
 		}
7320 7320
 
7321
-		if (! $error && ! empty($this->isextrafieldmanaged))
7321
+		if (!$error && !empty($this->isextrafieldmanaged))
7322 7322
 		{
7323
-			$sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element."_extrafields";
7324
-			$sql.= " WHERE fk_object=" . $this->id;
7323
+			$sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element."_extrafields";
7324
+			$sql .= " WHERE fk_object=".$this->id;
7325 7325
 
7326 7326
 			$resql = $this->db->query($sql);
7327
-			if (! $resql)
7327
+			if (!$resql)
7328 7328
 			{
7329 7329
 				$this->errors[] = $this->db->lasterror();
7330 7330
 				$error++;
7331 7331
 			}
7332 7332
 		}
7333 7333
 
7334
-		if (! $error)
7334
+		if (!$error)
7335 7335
 		{
7336 7336
 			$sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
7337 7337
 
7338 7338
 			$res = $this->db->query($sql);
7339
-			if($res===false) {
7339
+			if ($res === false) {
7340 7340
 				$error++;
7341 7341
 				$this->errors[] = $this->db->lasterror();
7342 7342
 			}
@@ -7377,9 +7377,9 @@  discard block
 block discarded – undo
7377 7377
 		require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
7378 7378
 
7379 7379
 		$comment = new Comment($this->db);
7380
-		$result=$comment->fetchAllFor($this->element, $this->id);
7381
-		if ($result<0) {
7382
-			$this->errors=array_merge($this->errors, $comment->errors);
7380
+		$result = $comment->fetchAllFor($this->element, $this->id);
7381
+		if ($result < 0) {
7382
+			$this->errors = array_merge($this->errors, $comment->errors);
7383 7383
 			return -1;
7384 7384
 		} else {
7385 7385
 			$this->comments = $comment->comments;
Please login to merge, or discard this patch.
Base/Form.php 1 patch
Spacing   +897 added lines, -897 removed lines patch added patch discarded remove patch
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
         if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;/', $typeofdata)) {
112 112
             if (!empty($perm)) {
113 113
                 $tmp = explode(':', $typeofdata);
114
-                $ret .= '<div class="editkey_' . $tmp[0] . (!empty($tmp[1]) ? ' ' . $tmp[1] : '') . '" id="' . $htmlname . '">';
114
+                $ret .= '<div class="editkey_'.$tmp[0].(!empty($tmp[1]) ? ' '.$tmp[1] : '').'" id="'.$htmlname.'">';
115 115
                 if ($fieldrequired)
116 116
                     $ret .= '<span class="fieldrequired">';
117 117
                 $ret .= $langs->trans($text);
118 118
                 if ($fieldrequired)
119 119
                     $ret .= '</span>';
120
-                $ret .= '</div>' . "\n";
120
+                $ret .= '</div>'."\n";
121 121
             }
122 122
             else {
123 123
                 if ($fieldrequired)
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
             }
129 129
         }
130 130
         else {
131
-            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) {
131
+            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
132 132
                 $ret .= '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
133 133
             }
134 134
             if ($fieldrequired) {
@@ -141,14 +141,14 @@  discard block
 block discarded – undo
141 141
             if (!empty($notabletag)) {
142 142
                 $ret .= ' ';
143 143
             }
144
-            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) {
144
+            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
145 145
                 $ret .= '</td>';
146 146
             }
147
-            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) {
147
+            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
148 148
                 $ret .= '<td align="right">';
149 149
             }
150
-            if ($htmlname && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) {
151
-                $ret .= '<a href="' . $_SERVER["PHP_SELF"] . '?action=edit' . $htmlname . '&amp;' . $paramid . '=' . $object->id . $moreparam . '">' . img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)) . '</a>';
150
+            if ($htmlname && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
151
+                $ret .= '<a href="'.$_SERVER["PHP_SELF"].'?action=edit'.$htmlname.'&amp;'.$paramid.'='.$object->id.$moreparam.'">'.img_edit($langs->trans('Edit'), ($notabletag ? 0 : 1)).'</a>';
152 152
             }
153 153
             if (!empty($notabletag) && $notabletag == 1) {
154 154
                 $ret .= ' : ';
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
             if (!empty($notabletag) && $notabletag == 3) {
157 157
                 $ret .= ' ';
158 158
             }
159
-            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) {
159
+            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
160 160
                 $ret .= '</td>';
161 161
             }
162
-            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit' . $htmlname && $perm) {
162
+            if (empty($notabletag) && GETPOST('action', 'aZ09') != 'edit'.$htmlname && $perm) {
163 163
                 $ret .= '</tr></table>';
164 164
             }
165 165
         }
@@ -199,41 +199,41 @@  discard block
 block discarded – undo
199 199
         if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !preg_match('/^select;|datehourpicker/', $typeofdata)) { // TODO add jquery timepicker
200 200
             $ret .= $this->editInPlace($object, $value, $htmlname, $perm, $typeofdata, $editvalue, $extObject, $custommsg);
201 201
         } else {
202
-            if (GETPOST('action', 'aZ09') == 'edit' . $htmlname) {
202
+            if (GETPOST('action', 'aZ09') == 'edit'.$htmlname) {
203 203
                 $ret .= "\n";
204
-                $ret .= '<form method="post" action="' . $_SERVER["PHP_SELF"] . ($moreparam ? '?' . $moreparam : '') . '">';
205
-                $ret .= '<input type="hidden" name="action" value="set' . $htmlname . '">';
206
-                $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
207
-                $ret .= '<input type="hidden" name="' . $paramid . '" value="' . $object->id . '">';
204
+                $ret .= '<form method="post" action="'.$_SERVER["PHP_SELF"].($moreparam ? '?'.$moreparam : '').'">';
205
+                $ret .= '<input type="hidden" name="action" value="set'.$htmlname.'">';
206
+                $ret .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
207
+                $ret .= '<input type="hidden" name="'.$paramid.'" value="'.$object->id.'">';
208 208
                 if (empty($notabletag))
209 209
                     $ret .= '<table class="nobordernopadding centpercent" cellpadding="0" cellspacing="0">';
210 210
                 if (empty($notabletag))
211 211
                     $ret .= '<tr><td>';
212 212
                 if (preg_match('/^(string|email)/', $typeofdata)) {
213 213
                     $tmp = explode(':', $typeofdata);
214
-                    $ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($editvalue ? $editvalue : $value) . '"' . ($tmp[1] ? ' size="' . $tmp[1] . '"' : '') . '>';
214
+                    $ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($editvalue ? $editvalue : $value).'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').'>';
215 215
                 } else if (preg_match('/^(numeric|amount)/', $typeofdata)) {
216 216
                     $tmp = explode(':', $typeofdata);
217 217
                     $valuetoshow = price2num($editvalue ? $editvalue : $value);
218
-                    $ret .= '<input type="text" id="' . $htmlname . '" name="' . $htmlname . '" value="' . ($valuetoshow != '' ? price($valuetoshow) : '') . '"' . ($tmp[1] ? ' size="' . $tmp[1] . '"' : '') . '>';
218
+                    $ret .= '<input type="text" id="'.$htmlname.'" name="'.$htmlname.'" value="'.($valuetoshow != '' ? price($valuetoshow) : '').'"'.($tmp[1] ? ' size="'.$tmp[1].'"' : '').'>';
219 219
                 } else if (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) {
220 220
                     $tmp = explode(':', $typeofdata);
221 221
                     $cols = $tmp[2];
222 222
                     $morealt = '';
223 223
                     if (preg_match('/%/', $cols)) {
224
-                        $morealt = ' style="width: ' . $cols . '"';
224
+                        $morealt = ' style="width: '.$cols.'"';
225 225
                         $cols = '';
226 226
                     }
227 227
 
228 228
                     $valuetoshow = ($editvalue ? $editvalue : $value);
229 229
 
230
-                    $ret .= '<textarea id="' . $htmlname . '" name="' . $htmlname . '" wrap="soft" rows="' . ($tmp[1] ? $tmp[1] : '20') . '"' . ($cols ? ' cols="' . $cols . '"' : 'class="quatrevingtpercent"') . $morealt . '">';
230
+                    $ret .= '<textarea id="'.$htmlname.'" name="'.$htmlname.'" wrap="soft" rows="'.($tmp[1] ? $tmp[1] : '20').'"'.($cols ? ' cols="'.$cols.'"' : 'class="quatrevingtpercent"').$morealt.'">';
231 231
                     $ret .= dol_string_neverthesehtmltags($valuetoshow, array('textarea'));
232 232
                     $ret .= '</textarea>';
233 233
                 } else if ($typeofdata == 'day' || $typeofdata == 'datepicker') {
234
-                    $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form' . $htmlname, 1, 0);
234
+                    $ret .= $this->selectDate($value, $htmlname, 0, 0, 1, 'form'.$htmlname, 1, 0);
235 235
                 } else if ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') {
236
-                    $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form' . $htmlname, 1, 0);
236
+                    $ret .= $this->selectDate($value, $htmlname, 1, 1, 1, 'form'.$htmlname, 1, 0);
237 237
                 } else if (preg_match('/^select;/', $typeofdata)) {
238 238
                     $arraydata = explode(',', preg_replace('/^select;/', '', $typeofdata));
239 239
                     foreach ($arraydata as $val) {
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
                     }
243 243
                     $ret .= $this->selectarray($htmlname, $arraylist, $value);
244 244
                 } else if (preg_match('/^ckeditor/', $typeofdata)) {
245
-                    $tmp = explode(':', $typeofdata);  // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols
246
-                    require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
245
+                    $tmp = explode(':', $typeofdata); // Example: ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols
246
+                    require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
247 247
                     $doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), ($tmp[2] ? $tmp[2] : ''), ($tmp[3] ? $tmp[3] : '100'), ($tmp[1] ? $tmp[1] : 'dolibarr_notes'), 'In', ($tmp[5] ? $tmp[5] : 0), true, true, ($tmp[6] ? $tmp[6] : '20'), ($tmp[7] ? $tmp[7] : '100'));
248 248
                     $ret .= $doleditor->Create(1);
249 249
                 }
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
                 if (empty($notabletag))
254 254
                     $ret .= '<td align="left">';
255 255
                 //else $ret.='<div class="clearboth"></div>';
256
-                $ret .= '<input type="submit" class="button' . (empty($notabletag) ? '' : ' ') . '" name="modify" value="' . $langs->trans("Modify") . '">';
256
+                $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="modify" value="'.$langs->trans("Modify").'">';
257 257
                 if (preg_match('/ckeditor|textarea/', $typeofdata) && empty($notabletag))
258
-                    $ret .= '<br>' . "\n";
259
-                $ret .= '<input type="submit" class="button' . (empty($notabletag) ? '' : ' ') . '" name="cancel" value="' . $langs->trans("Cancel") . '">';
258
+                    $ret .= '<br>'."\n";
259
+                $ret .= '<input type="submit" class="button'.(empty($notabletag) ? '' : ' ').'" name="cancel" value="'.$langs->trans("Cancel").'">';
260 260
                 if (empty($notabletag))
261 261
                     $ret .= '</td>';
262 262
 
263 263
                 if (empty($notabletag))
264
-                    $ret .= '</tr></table>' . "\n";
265
-                $ret .= '</form>' . "\n";
264
+                    $ret .= '</tr></table>'."\n";
265
+                $ret .= '</form>'."\n";
266 266
             }
267 267
             else {
268 268
                 if (preg_match('/^(email)/', $typeofdata))
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                     if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
288 288
                         $firstline = preg_replace('/<br>.*/', '', $tmpcontent);
289 289
                         $firstline = preg_replace('/[\n\r].*/', '', $firstline);
290
-                        $tmpcontent = $firstline . ((strlen($firstline) != strlen($tmpcontent)) ? '...' : '');
290
+                        $tmpcontent = $firstline.((strlen($firstline) != strlen($tmpcontent)) ? '...' : '');
291 291
                     }
292 292
                     $ret .= $tmpcontent;
293 293
                 } else
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                     $inputOption = $tmp[1];
356 356
                 if (!empty($tmp[2]))
357 357
                     $savemethod = $tmp[2];
358
-                $out .= '<input id="width_' . $htmlname . '" value="' . $inputOption . '" type="hidden"/>' . "\n";
358
+                $out .= '<input id="width_'.$htmlname.'" value="'.$inputOption.'" type="hidden"/>'."\n";
359 359
             }
360 360
             else if ((preg_match('/^day$/', $inputType)) || (preg_match('/^datepicker/', $inputType)) || (preg_match('/^datehourpicker/', $inputType))) {
361 361
                 $tmp = explode(':', $inputType);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                 if (!empty($tmp[2]))
366 366
                     $savemethod = $tmp[2];
367 367
 
368
-                $out .= '<input id="timestamp" type="hidden"/>' . "\n"; // Use for timestamp format
368
+                $out .= '<input id="timestamp" type="hidden"/>'."\n"; // Use for timestamp format
369 369
             }
370 370
             else if (preg_match('/^(select|autocomplete)/', $inputType)) {
371 371
                 $tmp = explode(':', $inputType);
@@ -393,35 +393,35 @@  discard block
 block discarded – undo
393 393
                     $savemethod = $tmp[4];
394 394
 
395 395
                 if (!empty($conf->fckeditor->enabled)) {
396
-                    $out .= '<input id="ckeditor_toolbar" value="' . $toolbar . '" type="hidden"/>' . "\n";
396
+                    $out .= '<input id="ckeditor_toolbar" value="'.$toolbar.'" type="hidden"/>'."\n";
397 397
                 } else {
398 398
                     $inputType = 'textarea';
399 399
                 }
400 400
             }
401 401
 
402
-            $out .= '<input id="element_' . $htmlname . '" value="' . $element . '" type="hidden"/>' . "\n";
403
-            $out .= '<input id="table_element_' . $htmlname . '" value="' . $table_element . '" type="hidden"/>' . "\n";
404
-            $out .= '<input id="fk_element_' . $htmlname . '" value="' . $fk_element . '" type="hidden"/>' . "\n";
405
-            $out .= '<input id="loadmethod_' . $htmlname . '" value="' . $loadmethod . '" type="hidden"/>' . "\n";
402
+            $out .= '<input id="element_'.$htmlname.'" value="'.$element.'" type="hidden"/>'."\n";
403
+            $out .= '<input id="table_element_'.$htmlname.'" value="'.$table_element.'" type="hidden"/>'."\n";
404
+            $out .= '<input id="fk_element_'.$htmlname.'" value="'.$fk_element.'" type="hidden"/>'."\n";
405
+            $out .= '<input id="loadmethod_'.$htmlname.'" value="'.$loadmethod.'" type="hidden"/>'."\n";
406 406
             if (!empty($savemethod))
407
-                $out .= '<input id="savemethod_' . $htmlname . '" value="' . $savemethod . '" type="hidden"/>' . "\n";
407
+                $out .= '<input id="savemethod_'.$htmlname.'" value="'.$savemethod.'" type="hidden"/>'."\n";
408 408
             if (!empty($ext_element))
409
-                $out .= '<input id="ext_element_' . $htmlname . '" value="' . $ext_element . '" type="hidden"/>' . "\n";
409
+                $out .= '<input id="ext_element_'.$htmlname.'" value="'.$ext_element.'" type="hidden"/>'."\n";
410 410
             if (!empty($custommsg)) {
411 411
                 if (is_array($custommsg)) {
412 412
                     if (!empty($custommsg['success']))
413
-                        $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg['success'] . '" type="hidden"/>' . "\n";
413
+                        $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg['success'].'" type="hidden"/>'."\n";
414 414
                     if (!empty($custommsg['error']))
415
-                        $out .= '<input id="errormsg_' . $htmlname . '" value="' . $custommsg['error'] . '" type="hidden"/>' . "\n";
415
+                        $out .= '<input id="errormsg_'.$htmlname.'" value="'.$custommsg['error'].'" type="hidden"/>'."\n";
416 416
                 } else
417
-                    $out .= '<input id="successmsg_' . $htmlname . '" value="' . $custommsg . '" type="hidden"/>' . "\n";
417
+                    $out .= '<input id="successmsg_'.$htmlname.'" value="'.$custommsg.'" type="hidden"/>'."\n";
418 418
             }
419 419
             if ($inputType == 'textarea') {
420
-                $out .= '<input id="textarea_' . $htmlname . '_rows" value="' . $rows . '" type="hidden"/>' . "\n";
421
-                $out .= '<input id="textarea_' . $htmlname . '_cols" value="' . $cols . '" type="hidden"/>' . "\n";
420
+                $out .= '<input id="textarea_'.$htmlname.'_rows" value="'.$rows.'" type="hidden"/>'."\n";
421
+                $out .= '<input id="textarea_'.$htmlname.'_cols" value="'.$cols.'" type="hidden"/>'."\n";
422 422
             }
423
-            $out .= '<span id="viewval_' . $htmlname . '" class="viewval_' . $inputType . ($button_only ? ' inactive' : ' active') . '">' . $value . '</span>' . "\n";
424
-            $out .= '<span id="editval_' . $htmlname . '" class="editval_' . $inputType . ($button_only ? ' inactive' : ' active') . ' hideobject">' . (!empty($editvalue) ? $editvalue : $value) . '</span>' . "\n";
423
+            $out .= '<span id="viewval_'.$htmlname.'" class="viewval_'.$inputType.($button_only ? ' inactive' : ' active').'">'.$value.'</span>'."\n";
424
+            $out .= '<span id="editval_'.$htmlname.'" class="editval_'.$inputType.($button_only ? ' inactive' : ' active').' hideobject">'.(!empty($editvalue) ? $editvalue : $value).'</span>'."\n";
425 425
         } else {
426 426
             $out = $value;
427 427
         }
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
         global $conf;
454 454
 
455 455
         if ($incbefore) {
456
-            $text = $incbefore . $text;
456
+            $text = $incbefore.$text;
457 457
         }
458 458
         if (!$htmltext) {
459 459
             return $text;
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 
474 474
         $extrastyle = '';
475 475
         if ($direction < 0) {
476
-            $extracss = ($extracss ? $extracss . ' ' : '') . 'inline-block';
476
+            $extracss = ($extracss ? $extracss.' ' : '').'inline-block';
477 477
             $extrastyle = 'padding: 0px; padding-left: 3px !important;';
478 478
         }
479 479
         if ($direction > 0) {
480
-            $extracss = ($extracss ? $extracss . ' ' : '') . 'inline-block';
480
+            $extracss = ($extracss ? $extracss.' ' : '').'inline-block';
481 481
             $extrastyle = 'padding: 0px; padding-right: 3px !important;';
482 482
         }
483 483
 
@@ -490,53 +490,53 @@  discard block
 block discarded – undo
490 490
             $htmltext = str_replace('"', "&quot;", $htmltext);
491 491
         } else {
492 492
             $classfortooltip = 'classfortooltiponclick';
493
-            $textfordialog .= '<div style="display: none;" id="idfortooltiponclick_' . $tooltiptrigger . '" class="classfortooltiponclicktext">' . $htmltext . '</div>';
493
+            $textfordialog .= '<div style="display: none;" id="idfortooltiponclick_'.$tooltiptrigger.'" class="classfortooltiponclicktext">'.$htmltext.'</div>';
494 494
         }
495 495
         if ($tooltipon == 2 || $tooltipon == 3) {
496
-            $paramfortooltipimg = ' class="' . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '"';
496
+            $paramfortooltipimg = ' class="'.$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'"';
497 497
             if ($tooltiptrigger == '') {
498
-                $paramfortooltipimg .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on img tag to store tooltip
498
+                $paramfortooltipimg .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on img tag to store tooltip
499 499
             } else {
500
-                $paramfortooltipimg .= ' dolid="' . $tooltiptrigger . '"';
500
+                $paramfortooltipimg .= ' dolid="'.$tooltiptrigger.'"';
501 501
             }
502 502
         } else {
503
-            $paramfortooltipimg = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag
503
+            $paramfortooltipimg = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag
504 504
         }
505 505
         if ($tooltipon == 1 || $tooltipon == 3) {
506
-            $paramfortooltiptd = ' class="' . ($tooltipon == 3 ? 'cursorpointer ' : '') . $classfortooltip . ' inline-block' . ($extracss ? ' ' . $extracss : '') . '" style="padding: 0px;' . ($extrastyle ? ' ' . $extrastyle : '') . '" ';
506
+            $paramfortooltiptd = ' class="'.($tooltipon == 3 ? 'cursorpointer ' : '').$classfortooltip.' inline-block'.($extracss ? ' '.$extracss : '').'" style="padding: 0px;'.($extrastyle ? ' '.$extrastyle : '').'" ';
507 507
             if ($tooltiptrigger == '') {
508
-                $paramfortooltiptd .= ' title="' . ($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)) . '"'; // Attribut to put on td tag to store tooltip
508
+                $paramfortooltiptd .= ' title="'.($noencodehtmltext ? $htmltext : dol_escape_htmltag($htmltext, 1)).'"'; // Attribut to put on td tag to store tooltip
509 509
             } else {
510
-                $paramfortooltiptd .= ' dolid="' . $tooltiptrigger . '"';
510
+                $paramfortooltiptd .= ' dolid="'.$tooltiptrigger.'"';
511 511
             }
512 512
         } else {
513
-            $paramfortooltiptd = ($extracss ? ' class="' . $extracss . '"' : '') . ($extrastyle ? ' style="' . $extrastyle . '"' : ''); // Attribut to put on td text tag
513
+            $paramfortooltiptd = ($extracss ? ' class="'.$extracss.'"' : '').($extrastyle ? ' style="'.$extrastyle.'"' : ''); // Attribut to put on td text tag
514 514
         }
515 515
         if (empty($notabs)) {
516 516
             $s .= '<table class="nobordernopadding" summary=""><tr style="height: auto;">';
517 517
         } elseif ($notabs == 2) {
518
-            $s .= '<div class="inline-block' . ($forcenowrap ? ' nowrap' : '') . '">';
518
+            $s .= '<div class="inline-block'.($forcenowrap ? ' nowrap' : '').'">';
519 519
         }
520 520
         // Define value if value is before
521 521
         if ($direction < 0) {
522
-            $s .= '<' . $tag . $paramfortooltipimg;
522
+            $s .= '<'.$tag.$paramfortooltipimg;
523 523
             if ($tag == 'td') {
524 524
                 $s .= ' valign="top" width="14"';
525 525
             }
526
-            $s .= '>' . $textfordialog . $img . '</' . $tag . '>';
526
+            $s .= '>'.$textfordialog.$img.'</'.$tag.'>';
527 527
         }
528 528
         // Use another method to help avoid having a space in value in order to use this value with jquery
529 529
         // Define label
530 530
         if ((string) $text != '') {
531
-            $s .= '<' . $tag . $paramfortooltiptd . '>' . $text . '</' . $tag . '>';
531
+            $s .= '<'.$tag.$paramfortooltiptd.'>'.$text.'</'.$tag.'>';
532 532
         }
533 533
         // Define value if value is after
534 534
         if ($direction > 0) {
535
-            $s .= '<' . $tag . $paramfortooltipimg;
535
+            $s .= '<'.$tag.$paramfortooltipimg;
536 536
             if ($tag == 'td') {
537 537
                 $s .= ' valign="middle" width="14"';
538 538
             }
539
-            $s .= '>' . $textfordialog . $img . '</' . $tag . '>';
539
+            $s .= '>'.$textfordialog.$img.'</'.$tag.'>';
540 540
         }
541 541
         if (empty($notabs)) {
542 542
             $s .= '</tr></table>';
@@ -629,15 +629,15 @@  discard block
 block discarded – undo
629 629
 
630 630
         $disabled = 0;
631 631
         $ret = '<div class="centpercent center">';
632
-        $ret .= '<select class="flat' . (empty($conf->use_javascript_ajax) ? '' : ' hideobject') . ' massaction massactionselect" name="massaction"' . ($disabled ? ' disabled="disabled"' : '') . '>';
632
+        $ret .= '<select class="flat'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' massaction massactionselect" name="massaction"'.($disabled ? ' disabled="disabled"' : '').'>';
633 633
 
634 634
         // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
635 635
         $parameters = array();
636
-        $reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters);    // Note that $action and $object may have been modified by hook
636
+        $reshook = $hookmanager->executeHooks('addMoreMassActions', $parameters); // Note that $action and $object may have been modified by hook
637 637
         if (empty($reshook)) {
638
-            $ret .= '<option value="0"' . ($disabled ? ' disabled="disabled"' : '') . '>-- ' . $langs->trans("SelectAction") . ' --</option>';
638
+            $ret .= '<option value="0"'.($disabled ? ' disabled="disabled"' : '').'>-- '.$langs->trans("SelectAction").' --</option>';
639 639
             foreach ($arrayofaction as $code => $label) {
640
-                $ret .= '<option value="' . $code . '"' . ($disabled ? ' disabled="disabled"' : '') . '>' . $label . '</option>';
640
+                $ret .= '<option value="'.$code.'"'.($disabled ? ' disabled="disabled"' : '').'>'.$label.'</option>';
641 641
             }
642 642
         }
643 643
         $ret .= $hookmanager->resPrint;
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
         $ret .= '</select>';
646 646
         // Warning: if you set submit button to disabled, post using 'Enter' will no more work if there is no another input submit. So we add a hidden button
647 647
         $ret .= '<input type="submit" name="confirmmassactioninvisible" style="display: none" tabindex="-1">'; // Hidden button BEFORE so it is the one used when we submit with ENTER.
648
-        $ret .= '<input type="submit" disabled name="confirmmassaction" class="button' . (empty($conf->use_javascript_ajax) ? '' : ' hideobject') . ' massaction massactionconfirmed" value="' . dol_escape_htmltag($langs->trans("Confirm")) . '">';
648
+        $ret .= '<input type="submit" disabled name="confirmmassaction" class="button'.(empty($conf->use_javascript_ajax) ? '' : ' hideobject').' massaction massactionconfirmed" value="'.dol_escape_htmltag($langs->trans("Confirm")).'">';
649 649
         $ret .= '</div>';
650 650
 
651 651
         if (!empty($conf->use_javascript_ajax)) {
@@ -659,11 +659,11 @@  discard block
 block discarded – undo
659 659
     	  				if ($(this).is(\':checked\')) atleastoneselected++;
660 660
     	  			});
661 661
 					console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected);
662
-    	  			if (atleastoneselected || ' . $alwaysvisible . ')
662
+    	  			if (atleastoneselected || ' . $alwaysvisible.')
663 663
     	  			{
664 664
     	  				jQuery(".massaction").show();
665
-        			    ' . ($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("' . $selected . '"); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '') . '
666
-        			    ' . ($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0"); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '') . '
665
+        			    ' . ($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("'.$selected.'"); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '').'
666
+        			    ' . ($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0"); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '').'
667 667
     	  			}
668 668
     	  			else
669 669
     	  			{
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
         $atleastonefavorite = 0;
733 733
 
734 734
         $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite";
735
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_country";
735
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_country";
736 736
         $sql .= " WHERE active > 0";
737 737
         //$sql.= " ORDER BY code ASC";
738 738
 
739
-        dol_syslog(get_class($this) . "::select_country", LOG_DEBUG);
739
+        dol_syslog(get_class($this)."::select_country", LOG_DEBUG);
740 740
         $resql = $this->db->query($sql);
741 741
         if ($resql) {
742
-            $out .= '<select id="select' . $htmlname . '" class="flat maxwidth200onsmartphone selectcountry' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" ' . $htmloption . '>';
742
+            $out .= '<select id="select'.$htmlname.'" class="flat maxwidth200onsmartphone selectcountry'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" '.$htmloption.'>';
743 743
             $num = $this->db->num_rows($resql);
744 744
             $i = 0;
745 745
             if ($num) {
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
                     $countryArray[$i]['rowid'] = $obj->rowid;
751 751
                     $countryArray[$i]['code_iso'] = $obj->code_iso;
752 752
                     $countryArray[$i]['code_iso3'] = $obj->code_iso3;
753
-                    $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country" . $obj->code_iso) != "Country" . $obj->code_iso ? $langs->transnoentitiesnoconv("Country" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
753
+                    $countryArray[$i]['label'] = ($obj->code_iso && $langs->transnoentitiesnoconv("Country".$obj->code_iso) != "Country".$obj->code_iso ? $langs->transnoentitiesnoconv("Country".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
754 754
                     $countryArray[$i]['favorite'] = $obj->favorite;
755 755
                     $favorite[$i] = $obj->favorite;
756 756
                     $label[$i] = dol_string_unaccent($countryArray[$i]['label']);
@@ -763,16 +763,16 @@  discard block
 block discarded – undo
763 763
                     $countryArray = dol_sort_array($countryArray, 'label');
764 764
 
765 765
                 if ($showempty) {
766
-                    $out .= '<option value="">&nbsp;</option>' . "\n";
766
+                    $out .= '<option value="">&nbsp;</option>'."\n";
767 767
                 }
768 768
 
769 769
                 if ($addspecialentries) { // Add dedicated entries for groups of countries
770 770
                     //if ($showempty) $out.= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>';
771
-                    $out .= '<option value="special_allnotme"' . ($selected == 'special_allnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>';
772
-                    $out .= '<option value="special_eec"' . ($selected == 'special_eec' ? ' selected' : '') . '>' . $langs->trans("CountriesInEEC") . '</option>';
771
+                    $out .= '<option value="special_allnotme"'.($selected == 'special_allnotme' ? ' selected' : '').'>'.$langs->trans("CountriesExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
772
+                    $out .= '<option value="special_eec"'.($selected == 'special_eec' ? ' selected' : '').'>'.$langs->trans("CountriesInEEC").'</option>';
773 773
                     if ($mysoc->isInEEC())
774
-                        $out .= '<option value="special_eecnotme"' . ($selected == 'special_eecnotme' ? ' selected' : '') . '>' . $langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country" . $mysoc->country_code)) . '</option>';
775
-                    $out .= '<option value="special_noteec"' . ($selected == 'special_noteec' ? ' selected' : '') . '>' . $langs->trans("CountriesNotInEEC") . '</option>';
774
+                        $out .= '<option value="special_eecnotme"'.($selected == 'special_eecnotme' ? ' selected' : '').'>'.$langs->trans("CountriesInEECExceptMe", $langs->transnoentitiesnoconv("Country".$mysoc->country_code)).'</option>';
775
+                    $out .= '<option value="special_noteec"'.($selected == 'special_noteec' ? ' selected' : '').'>'.$langs->trans("CountriesNotInEEC").'</option>';
776 776
                     $out .= '<option value="" disabled class="selectoptiondisabledwhite">--------------</option>';
777 777
                 }
778 778
 
@@ -790,16 +790,16 @@  discard block
 block discarded – undo
790 790
                     }
791 791
                     if ($selected && $selected != '-1' && ($selected == $row['rowid'] || $selected == $row['code_iso'] || $selected == $row['code_iso3'] || $selected == $row['label'])) {
792 792
                         $foundselected = true;
793
-                        $out .= '<option value="' . ($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']) . '" selected>';
793
+                        $out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'" selected>';
794 794
                     } else {
795
-                        $out .= '<option value="' . ($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']) . '">';
795
+                        $out .= '<option value="'.($usecodeaskey ? ($usecodeaskey == 'code2' ? $row['code_iso'] : $row['code_iso3']) : $row['rowid']).'">';
796 796
                     }
797 797
                     if ($row['label'])
798 798
                         $out .= dol_trunc($row['label'], $maxlength, 'middle');
799 799
                     else
800 800
                         $out .= '&nbsp;';
801 801
                     if ($row['code_iso'])
802
-                        $out .= ' (' . $row['code_iso'] . ')';
802
+                        $out .= ' ('.$row['code_iso'].')';
803 803
                     $out .= '</option>';
804 804
                 }
805 805
             }
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
         }
811 811
 
812 812
         // Make select dynamic
813
-        include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
814
-        $out .= ajax_combobox('select' . $htmlname);
813
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
814
+        $out .= ajax_combobox('select'.$htmlname);
815 815
 
816 816
         return $out;
817 817
     }
@@ -840,25 +840,25 @@  discard block
 block discarded – undo
840 840
         $incotermArray = array();
841 841
 
842 842
         $sql = "SELECT rowid, code";
843
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_incoterms";
843
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_incoterms";
844 844
         $sql .= " WHERE active > 0";
845 845
         $sql .= " ORDER BY code ASC";
846 846
 
847
-        dol_syslog(get_class($this) . "::select_incoterm", LOG_DEBUG);
847
+        dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG);
848 848
         $resql = $this->db->query($sql);
849 849
         if ($resql) {
850 850
             if ($conf->use_javascript_ajax && !$forcecombo) {
851
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
851
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
852 852
                 $out .= ajax_combobox($htmlname, $events);
853 853
             }
854 854
 
855 855
             if (!empty($page)) {
856
-                $out .= '<form method="post" action="' . $page . '">';
856
+                $out .= '<form method="post" action="'.$page.'">';
857 857
                 $out .= '<input type="hidden" name="action" value="set_incoterms">';
858
-                $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
858
+                $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
859 859
             }
860 860
 
861
-            $out .= '<select id="' . $htmlname . '" class="flat selectincoterm minwidth100imp noenlargeonsmartphone" name="' . $htmlname . '" ' . $htmloption . '>';
861
+            $out .= '<select id="'.$htmlname.'" class="flat selectincoterm minwidth100imp noenlargeonsmartphone" name="'.$htmlname.'" '.$htmloption.'>';
862 862
             $out .= '<option value="0">&nbsp;</option>';
863 863
             $num = $this->db->num_rows($resql);
864 864
             $i = 0;
@@ -874,9 +874,9 @@  discard block
 block discarded – undo
874 874
 
875 875
                 foreach ($incotermArray as $row) {
876 876
                     if ($selected && ($selected == $row['rowid'] || $selected == $row['code'])) {
877
-                        $out .= '<option value="' . $row['rowid'] . '" selected>';
877
+                        $out .= '<option value="'.$row['rowid'].'" selected>';
878 878
                     } else {
879
-                        $out .= '<option value="' . $row['rowid'] . '">';
879
+                        $out .= '<option value="'.$row['rowid'].'">';
880 880
                     }
881 881
 
882 882
                     if ($row['code'])
@@ -887,10 +887,10 @@  discard block
 block discarded – undo
887 887
             }
888 888
             $out .= '</select>';
889 889
 
890
-            $out .= '<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="' . $location_incoterms . '">';
890
+            $out .= '<input id="location_incoterms" class="maxwidth100onsmartphone" name="location_incoterms" value="'.$location_incoterms.'">';
891 891
 
892 892
             if (!empty($page)) {
893
-                $out .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '"></form>';
893
+                $out .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'"></form>';
894 894
             }
895 895
         } else {
896 896
             dol_print_error($this->db);
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
         // If product & services are enabled or both disabled.
920 920
         if ($forceall == 1 || (empty($forceall) && !empty($conf->product->enabled) && !empty($conf->service->enabled)) || (empty($forceall) && empty($conf->product->enabled) && empty($conf->service->enabled))) {
921 921
             if (empty($hidetext))
922
-                print $langs->trans("Type") . ': ';
923
-            print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">';
922
+                print $langs->trans("Type").': ';
923
+            print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
924 924
             if ($showempty) {
925 925
                 print '<option value="-1"';
926 926
                 if ($selected == -1)
@@ -931,26 +931,26 @@  discard block
 block discarded – undo
931 931
             print '<option value="0"';
932 932
             if (0 == $selected)
933 933
                 print ' selected';
934
-            print '>' . $langs->trans("Product");
934
+            print '>'.$langs->trans("Product");
935 935
 
936 936
             print '<option value="1"';
937 937
             if (1 == $selected)
938 938
                 print ' selected';
939
-            print '>' . $langs->trans("Service");
939
+            print '>'.$langs->trans("Service");
940 940
 
941 941
             print '</select>';
942 942
             //if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
943 943
         }
944 944
         if ((empty($forceall) && empty($conf->product->enabled) && !empty($conf->service->enabled)) || $forceall == 3) {
945 945
             print $langs->trans("Service");
946
-            print '<input type="hidden" name="' . $htmlname . '" value="1">';
946
+            print '<input type="hidden" name="'.$htmlname.'" value="1">';
947 947
         }
948 948
         if ((empty($forceall) && !empty($conf->product->enabled) && empty($conf->service->enabled)) || $forceall == 2) {
949 949
             print $langs->trans("Product");
950
-            print '<input type="hidden" name="' . $htmlname . '" value="0">';
950
+            print '<input type="hidden" name="'.$htmlname.'" value="0">';
951 951
         }
952 952
         if ($forceall < 0) { // This should happened only for contracts when both predefined product and service are disabled.
953
-            print '<input type="hidden" name="' . $htmlname . '" value="1">'; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1
953
+            print '<input type="hidden" name="'.$htmlname.'" value="1">'; // By default we set on service for contract. If CONTRACT_SUPPORT_PRODUCTS is set, forceall should be 1 not -1
954 954
         }
955 955
     }
956 956
 
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
 
968 968
         $num = count($this->cache_types_fees);
969 969
         if ($num > 0)
970
-            return 0;    // Cache already loaded
970
+            return 0; // Cache already loaded
971 971
 
972 972
         dol_syslog(__METHOD__, LOG_DEBUG);
973 973
 
974 974
         $langs->load("trips");
975 975
 
976 976
         $sql = "SELECT c.code, c.label";
977
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_type_fees as c";
977
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as c";
978 978
         $sql .= " WHERE active > 0";
979 979
 
980 980
         $resql = $this->db->query($sql);
@@ -1014,11 +1014,11 @@  discard block
 block discarded – undo
1014 1014
         // phpcs:enable
1015 1015
         global $user, $langs;
1016 1016
 
1017
-        dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG);
1017
+        dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
1018 1018
 
1019 1019
         $this->load_cache_types_fees();
1020 1020
 
1021
-        print '<select id="select_' . $htmlname . '" class="flat" name="' . $htmlname . '">';
1021
+        print '<select id="select_'.$htmlname.'" class="flat" name="'.$htmlname.'">';
1022 1022
         if ($showempty) {
1023 1023
             print '<option value="-1"';
1024 1024
             if ($selected == -1)
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
         }
1028 1028
 
1029 1029
         foreach ($this->cache_types_fees as $key => $value) {
1030
-            print '<option value="' . $key . '"';
1030
+            print '<option value="'.$key.'"';
1031 1031
             if ($key == $selected)
1032 1032
                 print ' selected';
1033 1033
             print '>';
@@ -1090,25 +1090,25 @@  discard block
 block discarded – undo
1090 1090
             // No immediate load of all database
1091 1091
             $placeholder = '';
1092 1092
             if ($selected && empty($selected_input_value)) {
1093
-                require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
1093
+                require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
1094 1094
                 $societetmp = new Societe($this->db);
1095 1095
                 $societetmp->fetch($selected);
1096 1096
                 $selected_input_value = $societetmp->name;
1097 1097
                 unset($societetmp);
1098 1098
             }
1099 1099
             // mode 1
1100
-            $urloption = 'htmlname=' . $htmlname . '&outjson=1&filter=' . $filter . ($showtype ? '&showtype=' . $showtype : '');
1101
-            $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1100
+            $urloption = 'htmlname='.$htmlname.'&outjson=1&filter='.$filter.($showtype ? '&showtype='.$showtype : '');
1101
+            $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1102 1102
             $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
1103 1103
             if (empty($hidelabel))
1104
-                print $langs->trans("RefOrLabel") . ' : ';
1104
+                print $langs->trans("RefOrLabel").' : ';
1105 1105
             else if ($hidelabel > 1) {
1106
-                $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
1106
+                $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
1107 1107
                 if ($hidelabel == 2) {
1108 1108
                     $out .= img_picto($langs->trans("Search"), 'search');
1109 1109
                 }
1110 1110
             }
1111
-            $out .= '<input type="text" class="' . $morecss . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />';
1111
+            $out .= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->THIRDPARTY_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
1112 1112
             if ($hidelabel == 3) {
1113 1113
                 $out .= img_picto($langs->trans("Search"), 'search');
1114 1114
             }
@@ -1169,20 +1169,20 @@  discard block
 block discarded – undo
1169 1169
             $sql .= " , dictp.code as country_code";
1170 1170
         }
1171 1171
 
1172
-        $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s";
1172
+        $sql .= " FROM (".MAIN_DB_PREFIX."societe as s";
1173 1173
         if (!$user->rights->societe->client->voir && !$user->socid)
1174
-            $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
1174
+            $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
1175 1175
         $sql .= " )";
1176 1176
         if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
1177
-            $sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "c_country as dictp ON dictp.rowid=s.fk_pays";
1177
+            $sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid=s.fk_pays";
1178 1178
         }
1179
-        $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")";
1179
+        $sql .= " WHERE s.entity IN (".getEntity('societe').")";
1180 1180
         if (!empty($user->socid))
1181
-            $sql .= " AND s.rowid = " . $user->socid;
1181
+            $sql .= " AND s.rowid = ".$user->socid;
1182 1182
         if ($filter)
1183
-            $sql .= " AND (" . $filter . ")";
1183
+            $sql .= " AND (".$filter.")";
1184 1184
         if (!$user->rights->societe->client->voir && !$user->socid)
1185
-            $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
1185
+            $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
1186 1186
         if (!empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX))
1187 1187
             $sql .= " AND s.status <> 0";
1188 1188
         // Add criteria
@@ -1197,31 +1197,31 @@  discard block
 block discarded – undo
1197 1197
             foreach ($scrit as $crit) {
1198 1198
                 if ($i > 0)
1199 1199
                     $sql .= " AND ";
1200
-                $sql .= "(s.nom LIKE '" . $this->db->escape($prefix . $crit) . "%')";
1200
+                $sql .= "(s.nom LIKE '".$this->db->escape($prefix.$crit)."%')";
1201 1201
                 $i++;
1202 1202
             }
1203 1203
             if (count($scrit) > 1)
1204 1204
                 $sql .= ")";
1205 1205
             if (!empty($conf->barcode->enabled)) {
1206
-                $sql .= " OR s.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'";
1206
+                $sql .= " OR s.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
1207 1207
             }
1208
-            $sql .= " OR s.code_client LIKE '" . $this->db->escape($prefix . $filterkey) . "%' OR s.code_fournisseur LIKE '" . $this->db->escape($prefix . $filterkey) . "%'";
1208
+            $sql .= " OR s.code_client LIKE '".$this->db->escape($prefix.$filterkey)."%' OR s.code_fournisseur LIKE '".$this->db->escape($prefix.$filterkey)."%'";
1209 1209
             $sql .= ")";
1210 1210
         }
1211 1211
         $sql .= $this->db->order("nom", "ASC");
1212 1212
         $sql .= $this->db->plimit($limit, 0);
1213 1213
 
1214 1214
         // Build output string
1215
-        dol_syslog(get_class($this) . "::select_thirdparty_list", LOG_DEBUG);
1215
+        dol_syslog(get_class($this)."::select_thirdparty_list", LOG_DEBUG);
1216 1216
         $resql = $this->db->query($sql);
1217 1217
         if ($resql) {
1218 1218
             if (!$forcecombo) {
1219
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
1219
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1220 1220
                 $out .= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT);
1221 1221
             }
1222 1222
 
1223 1223
             // Construct $out and $outarray
1224
-            $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($moreparam ? ' ' . $moreparam : '') . ' name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . '>' . "\n";
1224
+            $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($moreparam ? ' '.$moreparam : '').' name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').'>'."\n";
1225 1225
 
1226 1226
             $textifempty = '';
1227 1227
             // Do not use textifempty = ' ' or '&nbsp;' here, or search on key will search on ' key'.
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
                     $textifempty .= $langs->trans("All");
1234 1234
             }
1235 1235
             if ($showempty)
1236
-                $out .= '<option value="-1">' . $textifempty . '</option>' . "\n";
1236
+                $out .= '<option value="-1">'.$textifempty.'</option>'."\n";
1237 1237
 
1238 1238
             $num = $this->db->num_rows($resql);
1239 1239
             $i = 0;
@@ -1243,18 +1243,18 @@  discard block
 block discarded – undo
1243 1243
                     $label = '';
1244 1244
                     if ($conf->global->SOCIETE_ADD_REF_IN_LIST) {
1245 1245
                         if (($obj->client) && (!empty($obj->code_client))) {
1246
-                            $label = $obj->code_client . ' - ';
1246
+                            $label = $obj->code_client.' - ';
1247 1247
                         }
1248 1248
                         if (($obj->fournisseur) && (!empty($obj->code_fournisseur))) {
1249
-                            $label .= $obj->code_fournisseur . ' - ';
1249
+                            $label .= $obj->code_fournisseur.' - ';
1250 1250
                         }
1251
-                        $label .= ' ' . $obj->name;
1251
+                        $label .= ' '.$obj->name;
1252 1252
                     } else {
1253 1253
                         $label = $obj->name;
1254 1254
                     }
1255 1255
 
1256 1256
                     if (!empty($obj->name_alias)) {
1257
-                        $label .= ' (' . $obj->name_alias . ')';
1257
+                        $label .= ' ('.$obj->name_alias.')';
1258 1258
                     }
1259 1259
 
1260 1260
                     if ($showtype) {
@@ -1263,25 +1263,25 @@  discard block
 block discarded – undo
1263 1263
                         if ($obj->client == 1 || $obj->client == 3)
1264 1264
                             $label .= $langs->trans("Customer");
1265 1265
                         if ($obj->client == 2 || $obj->client == 3)
1266
-                            $label .= ($obj->client == 3 ? ', ' : '') . $langs->trans("Prospect");
1266
+                            $label .= ($obj->client == 3 ? ', ' : '').$langs->trans("Prospect");
1267 1267
                         if ($obj->fournisseur)
1268
-                            $label .= ($obj->client ? ', ' : '') . $langs->trans("Supplier");
1268
+                            $label .= ($obj->client ? ', ' : '').$langs->trans("Supplier");
1269 1269
                         if ($obj->client || $obj->fournisseur)
1270 1270
                             $label .= ')';
1271 1271
                     }
1272 1272
 
1273 1273
                     if ($conf->global->COMPANY_SHOW_ADDRESS_SELECTLIST) {
1274
-                        $label .= '-' . $obj->address . '-' . $obj->zip . ' ' . $obj->town;
1274
+                        $label .= '-'.$obj->address.'-'.$obj->zip.' '.$obj->town;
1275 1275
                         if (!empty($obj->country_code)) {
1276
-                            $label .= ' ' . $langs->trans('Country' . $obj->country_code);
1276
+                            $label .= ' '.$langs->trans('Country'.$obj->country_code);
1277 1277
                         }
1278 1278
                     }
1279 1279
 
1280 1280
                     if (empty($outputmode)) {
1281 1281
                         if (in_array($obj->rowid, $selected)) {
1282
-                            $out .= '<option value="' . $obj->rowid . '" selected>' . $label . '</option>';
1282
+                            $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
1283 1283
                         } else {
1284
-                            $out .= '<option value="' . $obj->rowid . '">' . $label . '</option>';
1284
+                            $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
1285 1285
                         }
1286 1286
                     } else {
1287 1287
                         array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label));
@@ -1292,7 +1292,7 @@  discard block
 block discarded – undo
1292 1292
                         $out .= "\n";
1293 1293
                 }
1294 1294
             }
1295
-            $out .= '</select>' . "\n";
1295
+            $out .= '</select>'."\n";
1296 1296
         }
1297 1297
         else {
1298 1298
             dol_print_error($this->db);
@@ -1324,17 +1324,17 @@  discard block
 block discarded – undo
1324 1324
         // On recherche les remises
1325 1325
         $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,";
1326 1326
         $sql .= " re.description, re.fk_facture_source";
1327
-        $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re";
1328
-        $sql .= " WHERE re.fk_soc = " . (int) $socid;
1329
-        $sql .= " AND re.entity = " . $conf->entity;
1327
+        $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re";
1328
+        $sql .= " WHERE re.fk_soc = ".(int) $socid;
1329
+        $sql .= " AND re.entity = ".$conf->entity;
1330 1330
         if ($filter)
1331
-            $sql .= " AND " . $filter;
1331
+            $sql .= " AND ".$filter;
1332 1332
         $sql .= " ORDER BY re.description ASC";
1333 1333
 
1334
-        dol_syslog(get_class($this) . "::select_remises", LOG_DEBUG);
1334
+        dol_syslog(get_class($this)."::select_remises", LOG_DEBUG);
1335 1335
         $resql = $this->db->query($sql);
1336 1336
         if ($resql) {
1337
-            print '<select id="select_' . $htmlname . '" class="flat maxwidthonsmartphone" name="' . $htmlname . '">';
1337
+            print '<select id="select_'.$htmlname.'" class="flat maxwidthonsmartphone" name="'.$htmlname.'">';
1338 1338
             $num = $this->db->num_rows($resql);
1339 1339
 
1340 1340
             $qualifiedlines = $num;
@@ -1367,10 +1367,10 @@  discard block
 block discarded – undo
1367 1367
                     if (!empty($conf->global->MAIN_SHOW_FACNUMBER_IN_DISCOUNT_LIST) && !empty($obj->fk_facture_source)) {
1368 1368
                         $tmpfac = new Facture($this->db);
1369 1369
                         if ($tmpfac->fetch($obj->fk_facture_source) > 0)
1370
-                            $desc = $desc . ' - ' . $tmpfac->ref;
1370
+                            $desc = $desc.' - '.$tmpfac->ref;
1371 1371
                     }
1372 1372
 
1373
-                    print '<option value="' . $obj->rowid . '"' . $selectstring . $disabled . '>' . $desc . ' (' . price($obj->amount_ht) . ' ' . $langs->trans("HT") . ' - ' . price($obj->amount_ttc) . ' ' . $langs->trans("TTC") . ')</option>';
1373
+                    print '<option value="'.$obj->rowid.'"'.$selectstring.$disabled.'>'.$desc.' ('.price($obj->amount_ht).' '.$langs->trans("HT").' - '.price($obj->amount_ttc).' '.$langs->trans("TTC").')</option>';
1374 1374
                     $i++;
1375 1375
                 }
1376 1376
             }
@@ -1450,7 +1450,7 @@  discard block
 block discarded – undo
1450 1450
         $out = '';
1451 1451
 
1452 1452
         if (!is_object($hookmanager)) {
1453
-            include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php';
1453
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
1454 1454
             $hookmanager = new HookManager($this->db);
1455 1455
         }
1456 1456
 
@@ -1458,36 +1458,36 @@  discard block
 block discarded – undo
1458 1458
         $sql = "SELECT sp.rowid, sp.lastname, sp.statut, sp.firstname, sp.poste";
1459 1459
         if ($showsoc > 0)
1460 1460
             $sql .= " , s.nom as company";
1461
-        $sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as sp";
1461
+        $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp";
1462 1462
         if ($showsoc > 0)
1463
-            $sql .= " LEFT OUTER JOIN  " . MAIN_DB_PREFIX . "societe as s ON s.rowid=sp.fk_soc";
1464
-        $sql .= " WHERE sp.entity IN (" . getEntity('socpeople') . ")";
1463
+            $sql .= " LEFT OUTER JOIN  ".MAIN_DB_PREFIX."societe as s ON s.rowid=sp.fk_soc";
1464
+        $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
1465 1465
         if ($socid > 0 || $socid == -1)
1466
-            $sql .= " AND sp.fk_soc=" . $socid;
1466
+            $sql .= " AND sp.fk_soc=".$socid;
1467 1467
         if (!empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX))
1468 1468
             $sql .= " AND sp.statut <> 0";
1469 1469
         $sql .= " ORDER BY sp.lastname ASC";
1470 1470
 
1471
-        dol_syslog(get_class($this) . "::select_contacts", LOG_DEBUG);
1471
+        dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG);
1472 1472
         $resql = $this->db->query($sql);
1473 1473
         if ($resql) {
1474 1474
             $num = $this->db->num_rows($resql);
1475 1475
 
1476 1476
             if ($conf->use_javascript_ajax && !$forcecombo && !$options_only) {
1477
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
1477
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1478 1478
                 $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT);
1479 1479
             }
1480 1480
 
1481 1481
             if ($htmlname != 'none' || $options_only)
1482
-                $out .= '<select class="flat' . ($moreclass ? ' ' . $moreclass : '') . '" id="' . $htmlid . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . (!empty($moreparam) ? $moreparam : '') . '>';
1482
+                $out .= '<select class="flat'.($moreclass ? ' '.$moreclass : '').'" id="'.$htmlid.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.(!empty($moreparam) ? $moreparam : '').'>';
1483 1483
             if (($showempty == 1 || ($showempty == 3 && $num > 1)) && !$multiple)
1484
-                $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '>&nbsp;</option>';
1484
+                $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>&nbsp;</option>';
1485 1485
             if ($showempty == 2)
1486
-                $out .= '<option value="0"' . (in_array(0, $selected) ? ' selected' : '') . '>' . $langs->trans("Internal") . '</option>';
1486
+                $out .= '<option value="0"'.(in_array(0, $selected) ? ' selected' : '').'>'.$langs->trans("Internal").'</option>';
1487 1487
             $num = $this->db->num_rows($resql);
1488 1488
             $i = 0;
1489 1489
             if ($num) {
1490
-                include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
1490
+                include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
1491 1491
                 $contactstatic = new Contact($this->db);
1492 1492
 
1493 1493
                 while ($i < $num) {
@@ -1504,27 +1504,27 @@  discard block
 block discarded – undo
1504 1504
                             if (is_array($limitto) && count($limitto) && !in_array($obj->rowid, $limitto))
1505 1505
                                 $disabled = 1;
1506 1506
                             if (!empty($selected) && in_array($obj->rowid, $selected)) {
1507
-                                $out .= '<option value="' . $obj->rowid . '"';
1507
+                                $out .= '<option value="'.$obj->rowid.'"';
1508 1508
                                 if ($disabled)
1509 1509
                                     $out .= ' disabled';
1510 1510
                                 $out .= ' selected>';
1511 1511
                                 $out .= $contactstatic->getFullName($langs);
1512 1512
                                 if ($showfunction && $obj->poste)
1513
-                                    $out .= ' (' . $obj->poste . ')';
1513
+                                    $out .= ' ('.$obj->poste.')';
1514 1514
                                 if (($showsoc > 0) && $obj->company)
1515
-                                    $out .= ' - (' . $obj->company . ')';
1515
+                                    $out .= ' - ('.$obj->company.')';
1516 1516
                                 $out .= '</option>';
1517 1517
                             }
1518 1518
                             else {
1519
-                                $out .= '<option value="' . $obj->rowid . '"';
1519
+                                $out .= '<option value="'.$obj->rowid.'"';
1520 1520
                                 if ($disabled)
1521 1521
                                     $out .= ' disabled';
1522 1522
                                 $out .= '>';
1523 1523
                                 $out .= $contactstatic->getFullName($langs);
1524 1524
                                 if ($showfunction && $obj->poste)
1525
-                                    $out .= ' (' . $obj->poste . ')';
1525
+                                    $out .= ' ('.$obj->poste.')';
1526 1526
                                 if (($showsoc > 0) && $obj->company)
1527
-                                    $out .= ' - (' . $obj->company . ')';
1527
+                                    $out .= ' - ('.$obj->company.')';
1528 1528
                                 $out .= '</option>';
1529 1529
                             }
1530 1530
                         }
@@ -1532,9 +1532,9 @@  discard block
 block discarded – undo
1532 1532
                             if (in_array($obj->rowid, $selected)) {
1533 1533
                                 $out .= $contactstatic->getFullName($langs);
1534 1534
                                 if ($showfunction && $obj->poste)
1535
-                                    $out .= ' (' . $obj->poste . ')';
1535
+                                    $out .= ' ('.$obj->poste.')';
1536 1536
                                 if (($showsoc > 0) && $obj->company)
1537
-                                    $out .= ' - (' . $obj->company . ')';
1537
+                                    $out .= ' - ('.$obj->company.')';
1538 1538
                             }
1539 1539
                         }
1540 1540
                     }
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
                 }
1543 1543
             }
1544 1544
             else {
1545
-                $out .= '<option value="-1"' . (($showempty == 2 || $multiple) ? '' : ' selected') . ' disabled>';
1545
+                $out .= '<option value="-1"'.(($showempty == 2 || $multiple) ? '' : ' selected').' disabled>';
1546 1546
                 $out .= ($socid != -1) ? ($langs->trans($socid ? "NoContactDefinedForThirdParty" : "NoContactDefined")) : $langs->trans('SelectAThirdPartyFirst');
1547 1547
                 $out .= '</option>';
1548 1548
             }
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
                 'showsoc' => $showsoc,
1557 1557
             );
1558 1558
 
1559
-            $reshook = $hookmanager->executeHooks('afterSelectContactOptions', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
1559
+            $reshook = $hookmanager->executeHooks('afterSelectContactOptions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1560 1560
 
1561 1561
             if ($htmlname != 'none' || $options_only) {
1562 1562
                 $out .= '</select>';
@@ -1655,33 +1655,33 @@  discard block
 block discarded – undo
1655 1655
         if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
1656 1656
             $sql .= ", e.label";
1657 1657
         }
1658
-        $sql .= " FROM " . MAIN_DB_PREFIX . "user as u";
1658
+        $sql .= " FROM ".MAIN_DB_PREFIX."user as u";
1659 1659
         if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
1660
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=u.entity";
1660
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity";
1661 1661
             if ($force_entity)
1662
-                $sql .= " WHERE u.entity IN (0," . $force_entity . ")";
1662
+                $sql .= " WHERE u.entity IN (0,".$force_entity.")";
1663 1663
             else
1664 1664
                 $sql .= " WHERE u.entity IS NOT NULL";
1665 1665
         }
1666 1666
         else {
1667 1667
             if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
1668
-                $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "usergroup_user as ug";
1668
+                $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug";
1669 1669
                 $sql .= " ON ug.fk_user = u.rowid";
1670
-                $sql .= " WHERE ug.entity = " . $conf->entity;
1670
+                $sql .= " WHERE ug.entity = ".$conf->entity;
1671 1671
             } else {
1672
-                $sql .= " WHERE u.entity IN (0," . $conf->entity . ")";
1672
+                $sql .= " WHERE u.entity IN (0,".$conf->entity.")";
1673 1673
             }
1674 1674
         }
1675 1675
         if (!empty($user->societe_id))
1676
-            $sql .= " AND u.fk_soc = " . $user->societe_id;
1676
+            $sql .= " AND u.fk_soc = ".$user->societe_id;
1677 1677
         if (is_array($exclude) && $excludeUsers)
1678
-            $sql .= " AND u.rowid NOT IN (" . $excludeUsers . ")";
1678
+            $sql .= " AND u.rowid NOT IN (".$excludeUsers.")";
1679 1679
         if ($includeUsers)
1680
-            $sql .= " AND u.rowid IN (" . $includeUsers . ")";
1680
+            $sql .= " AND u.rowid IN (".$includeUsers.")";
1681 1681
         if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive)
1682 1682
             $sql .= " AND u.statut <> 0";
1683 1683
         if (!empty($morefilter))
1684
-            $sql .= " " . $morefilter;
1684
+            $sql .= " ".$morefilter;
1685 1685
 
1686 1686
         if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
1687 1687
             $sql .= " ORDER BY u.firstname ASC";
@@ -1689,22 +1689,22 @@  discard block
 block discarded – undo
1689 1689
             $sql .= " ORDER BY u.lastname ASC";
1690 1690
         }
1691 1691
 
1692
-        dol_syslog(get_class($this) . "::select_dolusers", LOG_DEBUG);
1692
+        dol_syslog(get_class($this)."::select_dolusers", LOG_DEBUG);
1693 1693
         $resql = $this->db->query($sql);
1694 1694
         if ($resql) {
1695 1695
             $num = $this->db->num_rows($resql);
1696 1696
             $i = 0;
1697 1697
             if ($num) {
1698 1698
                 // Enhance with select2
1699
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
1699
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
1700 1700
                 $out .= ajax_combobox($htmlname);
1701 1701
 
1702 1702
                 // do not use maxwidthonsmartphone by default. Set it by caller so auto size to 100% will work when not defined
1703
-                $out .= '<select class="flat' . ($morecss ? ' minwidth100 ' . $morecss : ' minwidth200') . '" id="' . $htmlname . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>';
1703
+                $out .= '<select class="flat'.($morecss ? ' minwidth100 '.$morecss : ' minwidth200').'" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>';
1704 1704
                 if ($show_empty && !$multiple)
1705
-                    $out .= '<option value="-1"' . ((empty($selected) || in_array(-1, $selected)) ? ' selected' : '') . '>&nbsp;</option>' . "\n";
1705
+                    $out .= '<option value="-1"'.((empty($selected) || in_array(-1, $selected)) ? ' selected' : '').'>&nbsp;</option>'."\n";
1706 1706
                 if ($show_every)
1707
-                    $out .= '<option value="-2"' . ((in_array(-2, $selected)) ? ' selected' : '') . '>-- ' . $langs->trans("Everybody") . ' --</option>' . "\n";
1707
+                    $out .= '<option value="-2"'.((in_array(-2, $selected)) ? ' selected' : '').'>-- '.$langs->trans("Everybody").' --</option>'."\n";
1708 1708
 
1709 1709
                 $userstatic = new User($this->db);
1710 1710
 
@@ -1719,14 +1719,14 @@  discard block
 block discarded – undo
1719 1719
                     if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly))
1720 1720
                         $disableline = ($enableonlytext ? $enableonlytext : '1');
1721 1721
 
1722
-                    if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected) )) {
1723
-                        $out .= '<option value="' . $obj->rowid . '"';
1722
+                    if ((is_object($selected) && $selected->id == $obj->rowid) || (!is_object($selected) && in_array($obj->rowid, $selected))) {
1723
+                        $out .= '<option value="'.$obj->rowid.'"';
1724 1724
                         if ($disableline)
1725 1725
                             $out .= ' disabled';
1726 1726
                         $out .= ' selected>';
1727 1727
                     }
1728 1728
                     else {
1729
-                        $out .= '<option value="' . $obj->rowid . '"';
1729
+                        $out .= '<option value="'.$obj->rowid.'"';
1730 1730
                         if ($disableline)
1731 1731
                             $out .= ' disabled';
1732 1732
                         $out .= '>';
@@ -1742,31 +1742,31 @@  discard block
 block discarded – undo
1742 1742
                     // Complete name with more info
1743 1743
                     $moreinfo = 0;
1744 1744
                     if (!empty($conf->global->MAIN_SHOW_LOGIN)) {
1745
-                        $out .= ($moreinfo ? ' - ' : ' (') . $obj->login;
1745
+                        $out .= ($moreinfo ? ' - ' : ' (').$obj->login;
1746 1746
                         $moreinfo++;
1747 1747
                     }
1748 1748
                     if ($showstatus >= 0) {
1749 1749
                         if ($obj->statut == 1 && $showstatus == 1) {
1750
-                            $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Enabled');
1750
+                            $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Enabled');
1751 1751
                             $moreinfo++;
1752 1752
                         }
1753 1753
                         if ($obj->statut == 0) {
1754
-                            $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans('Disabled');
1754
+                            $out .= ($moreinfo ? ' - ' : ' (').$langs->trans('Disabled');
1755 1755
                             $moreinfo++;
1756 1756
                         }
1757 1757
                     }
1758 1758
                     if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && !$user->entity) {
1759 1759
                         if (!$obj->entity) {
1760
-                            $out .= ($moreinfo ? ' - ' : ' (') . $langs->trans("AllEntities");
1760
+                            $out .= ($moreinfo ? ' - ' : ' (').$langs->trans("AllEntities");
1761 1761
                             $moreinfo++;
1762 1762
                         } else {
1763
-                            $out .= ($moreinfo ? ' - ' : ' (') . ($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined"));
1763
+                            $out .= ($moreinfo ? ' - ' : ' (').($obj->label ? $obj->label : $langs->trans("EntityNameNotDefined"));
1764 1764
                             $moreinfo++;
1765 1765
                         }
1766 1766
                     }
1767 1767
                     $out .= ($moreinfo ? ')' : '');
1768 1768
                     if ($disableline && $disableline != '1') {
1769
-                        $out .= ' - ' . $disableline; // This is text from $enableonlytext parameter
1769
+                        $out .= ' - '.$disableline; // This is text from $enableonlytext parameter
1770 1770
                     }
1771 1771
                     $out .= '</option>';
1772 1772
                     $outarray[$userstatic->id] = $userstatic->getFullName($langs, $fullNameMode, -1, $maxlength);
@@ -1774,8 +1774,8 @@  discard block
 block discarded – undo
1774 1774
                     $i++;
1775 1775
                 }
1776 1776
             } else {
1777
-                $out .= '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '" disabled>';
1778
-                $out .= '<option value="">' . $langs->trans("None") . '</option>';
1777
+                $out .= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'" disabled>';
1778
+                $out .= '<option value="">'.$langs->trans("None").'</option>';
1779 1779
             }
1780 1780
             $out .= '</select>';
1781 1781
         } else {
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
             $out .= '<input type="hidden" class="removedassignedhidden" name="removedassigned" value="">';
1827 1827
             $out .= '<script type="text/javascript" language="javascript">jQuery(document).ready(function () {    jQuery(".removedassigned").click(function() {        jQuery(".removedassignedhidden").val(jQuery(this).val());    });})</script>';
1828 1828
             $out .= $this->select_dolusers('', $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity, $maxlength, $showstatus, $morefilter);
1829
-            $out .= ' <input type="submit" class="button valignmiddle" name="' . $action . 'assignedtouser" value="' . dol_escape_htmltag($langs->trans("Add")) . '">';
1829
+            $out .= ' <input type="submit" class="button valignmiddle" name="'.$action.'assignedtouser" value="'.dol_escape_htmltag($langs->trans("Add")).'">';
1830 1830
             $out .= '<br>';
1831 1831
         }
1832 1832
         $assignedtouser = array();
@@ -1850,16 +1850,16 @@  discard block
 block discarded – undo
1850 1850
             $out .= $userstatic->getNomUrl(-1);
1851 1851
             if ($i == 0) {
1852 1852
                 $ownerid = $value['id'];
1853
-                $out .= ' (' . $langs->trans("Owner") . ')';
1853
+                $out .= ' ('.$langs->trans("Owner").')';
1854 1854
             }
1855 1855
             if ($nbassignetouser > 1 && $action != 'view') {
1856
-                $out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Remove"), 'delete', '', 0, 1) . '" value="' . $userstatic->id . '" class="removedassigned" id="removedassigned_' . $userstatic->id . '" name="removedassigned_' . $userstatic->id . '">';
1856
+                $out .= ' <input type="image" style="border: 0px;" src="'.img_picto($langs->trans("Remove"), 'delete', '', 0, 1).'" value="'.$userstatic->id.'" class="removedassigned" id="removedassigned_'.$userstatic->id.'" name="removedassigned_'.$userstatic->id.'">';
1857 1857
             }
1858 1858
             // Show my availability
1859 1859
             if ($showproperties) {
1860 1860
                 if ($ownerid == $value['id'] && is_array($listofuserid) && count($listofuserid) && in_array($ownerid, array_keys($listofuserid))) {
1861 1861
                     $out .= '<div class="myavailability inline-block">';
1862
-                    $out .= '&nbsp;-&nbsp;<span class="opacitymedium">' . $langs->trans("Availability") . ':</span>  <input id="transparency" class="marginleftonly marginrightonly" ' . ($action == 'view' ? 'disabled' : '') . ' type="checkbox" name="transparency"' . ($listofuserid[$ownerid]['transparency'] ? ' checked' : '') . '>' . $langs->trans("Busy");
1862
+                    $out .= '&nbsp;-&nbsp;<span class="opacitymedium">'.$langs->trans("Availability").':</span>  <input id="transparency" class="marginleftonly marginrightonly" '.($action == 'view' ? 'disabled' : '').' type="checkbox" name="transparency"'.($listofuserid[$ownerid]['transparency'] ? ' checked' : '').'>'.$langs->trans("Busy");
1863 1863
                     $out .= '</div>';
1864 1864
                 }
1865 1865
             }
@@ -1913,19 +1913,19 @@  discard block
 block discarded – undo
1913 1913
             $placeholder = '';
1914 1914
 
1915 1915
             if ($selected && empty($selected_input_value)) {
1916
-                require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
1916
+                require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
1917 1917
                 $producttmpselect = new Product($this->db);
1918 1918
                 $producttmpselect->fetch($selected);
1919 1919
                 $selected_input_value = $producttmpselect->ref;
1920 1920
                 unset($producttmpselect);
1921 1921
             }
1922 1922
             // mode=1 means customers products
1923
-            $urloption = 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=1&status=' . $status . '&finished=' . $finished . '&hidepriceinlabel=' . $hidepriceinlabel . '&warehousestatus=' . $warehouseStatus;
1923
+            $urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus;
1924 1924
             //Price by customer
1925 1925
             if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
1926
-                $urloption .= '&socid=' . $socid;
1926
+                $urloption .= '&socid='.$socid;
1927 1927
             }
1928
-            print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1928
+            print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
1929 1929
 
1930 1930
             if (!empty($conf->variants->enabled)) {
1931 1931
 
@@ -2002,14 +2002,14 @@  discard block
 block discarded – undo
2002 2002
                                 <?php
2003 2003
                             }
2004 2004
                             if (empty($hidelabel))
2005
-                                print $langs->trans("RefOrLabel") . ' : ';
2005
+                                print $langs->trans("RefOrLabel").' : ';
2006 2006
                             else if ($hidelabel > 1) {
2007
-                                $placeholder = ' placeholder="' . $langs->trans("RefOrLabel") . '"';
2007
+                                $placeholder = ' placeholder="'.$langs->trans("RefOrLabel").'"';
2008 2008
                                 if ($hidelabel == 2) {
2009 2009
                                     print img_picto($langs->trans("Search"), 'search');
2010 2010
                                 }
2011 2011
                             }
2012
-                            print '<input type="text" class="minwidth100" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '"' . $placeholder . ' ' . (!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '') . ' />';
2012
+                            print '<input type="text" class="minwidth100" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.$placeholder.' '.(!empty($conf->global->PRODUCT_SEARCH_AUTOFOCUS) ? 'autofocus' : '').' />';
2013 2013
                             if ($hidelabel == 3) {
2014 2014
                                 print img_picto($langs->trans("Search"), 'search');
2015 2015
                             }
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
 
2053 2053
         $warehouseStatusArray = array();
2054 2054
         if (!empty($warehouseStatus)) {
2055
-            require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php';
2055
+            require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
2056 2056
             if (preg_match('/warehouseclosed/', $warehouseStatus)) {
2057 2057
                 $warehouseStatusArray[] = Entrepot::STATUS_CLOSED;
2058 2058
             }
@@ -2068,13 +2068,13 @@  discard block
 block discarded – undo
2068 2068
         (count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock";
2069 2069
 
2070 2070
         $sql = "SELECT ";
2071
-        $sql .= $selectFields . $selectFieldsGrouped;
2071
+        $sql .= $selectFields.$selectFieldsGrouped;
2072 2072
 
2073 2073
         if (!empty($conf->global->PRODUCT_SORT_BY_CATEGORY)) {
2074 2074
             //Product category
2075
-            $sql .= ", (SELECT " . MAIN_DB_PREFIX . "categorie_product.fk_categorie
2076
-						FROM " . MAIN_DB_PREFIX . "categorie_product
2077
-						WHERE " . MAIN_DB_PREFIX . "categorie_product.fk_product=p.rowid
2075
+            $sql .= ", (SELECT ".MAIN_DB_PREFIX."categorie_product.fk_categorie
2076
+						FROM " . MAIN_DB_PREFIX."categorie_product
2077
+						WHERE " . MAIN_DB_PREFIX."categorie_product.fk_product=p.rowid
2078 2078
 						LIMIT 1
2079 2079
 				) AS categorie_product_id ";
2080 2080
         }
@@ -2093,45 +2093,45 @@  discard block
 block discarded – undo
2093 2093
         }
2094 2094
         // Price by quantity
2095 2095
         if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
2096
-            $sql .= ", (SELECT pp.rowid FROM " . MAIN_DB_PREFIX . "product_price as pp WHERE pp.fk_product = p.rowid";
2096
+            $sql .= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid";
2097 2097
             if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
2098
-                $sql .= " AND price_level=" . $price_level;
2098
+                $sql .= " AND price_level=".$price_level;
2099 2099
             $sql .= " ORDER BY date_price";
2100 2100
             $sql .= " DESC LIMIT 1) as price_rowid";
2101
-            $sql .= ", (SELECT pp.price_by_qty FROM " . MAIN_DB_PREFIX . "product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable
2101
+            $sql .= ", (SELECT pp.price_by_qty FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid"; // price_by_qty is 1 if some prices by qty exists in subtable
2102 2102
             if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
2103
-                $sql .= " AND price_level=" . $price_level;
2103
+                $sql .= " AND price_level=".$price_level;
2104 2104
             $sql .= " ORDER BY date_price";
2105 2105
             $sql .= " DESC LIMIT 1) as price_by_qty";
2106 2106
             $selectFields .= ", price_rowid, price_by_qty";
2107 2107
         }
2108
-        $sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
2108
+        $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
2109 2109
         if (count($warehouseStatusArray)) {
2110
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock as ps on ps.fk_product = p.rowid";
2111
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entrepot as e on ps.fk_entrepot = e.rowid";
2110
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid";
2111
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid";
2112 2112
         }
2113 2113
 
2114 2114
         // include search in supplier ref
2115 2115
         if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF)) {
2116
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2116
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2117 2117
         }
2118 2118
 
2119 2119
         //Price by customer
2120 2120
         if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
2121
-            $sql .= " LEFT JOIN  " . MAIN_DB_PREFIX . "product_customer_price as pcp ON pcp.fk_soc=" . $socid . " AND pcp.fk_product=p.rowid";
2121
+            $sql .= " LEFT JOIN  ".MAIN_DB_PREFIX."product_customer_price as pcp ON pcp.fk_soc=".$socid." AND pcp.fk_product=p.rowid";
2122 2122
         }
2123 2123
         // Multilang : we add translation
2124 2124
         if (!empty($conf->global->MAIN_MULTILANGS)) {
2125
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='" . $langs->getDefaultLang() . "'";
2125
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lang as pl ON pl.fk_product = p.rowid AND pl.lang='".$langs->getDefaultLang()."'";
2126 2126
         }
2127 2127
 
2128 2128
         if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
2129
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_attribute_combination pac ON pac.fk_product_child = p.rowid";
2129
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid";
2130 2130
         }
2131 2131
 
2132
-        $sql .= ' WHERE p.entity IN (' . getEntity('product') . ')';
2132
+        $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
2133 2133
         if (count($warehouseStatusArray)) {
2134
-            $sql .= ' AND (p.fk_product_type = 1 OR e.statut IN (' . $this->db->escape(implode(',', $warehouseStatusArray)) . '))';
2134
+            $sql .= ' AND (p.fk_product_type = 1 OR e.statut IN ('.$this->db->escape(implode(',', $warehouseStatusArray)).'))';
2135 2135
         }
2136 2136
 
2137 2137
         if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) {
@@ -2139,17 +2139,17 @@  discard block
 block discarded – undo
2139 2139
         }
2140 2140
 
2141 2141
         if ($finished == 0) {
2142
-            $sql .= " AND p.finished = " . $finished;
2142
+            $sql .= " AND p.finished = ".$finished;
2143 2143
         } elseif ($finished == 1) {
2144
-            $sql .= " AND p.finished = " . $finished;
2144
+            $sql .= " AND p.finished = ".$finished;
2145 2145
             if ($status >= 0)
2146
-                $sql .= " AND p.tosell = " . $status;
2146
+                $sql .= " AND p.tosell = ".$status;
2147 2147
         }
2148 2148
         elseif ($status >= 0) {
2149
-            $sql .= " AND p.tosell = " . $status;
2149
+            $sql .= " AND p.tosell = ".$status;
2150 2150
         }
2151 2151
         if (strval($filtertype) != '')
2152
-            $sql .= " AND p.fk_product_type=" . $filtertype;
2152
+            $sql .= " AND p.fk_product_type=".$filtertype;
2153 2153
         // Add criteria on ref/label
2154 2154
         if ($filterkey != '') {
2155 2155
             $sql .= ' AND (';
@@ -2162,27 +2162,27 @@  discard block
 block discarded – undo
2162 2162
             foreach ($scrit as $crit) {
2163 2163
                 if ($i > 0)
2164 2164
                     $sql .= " AND ";
2165
-                $sql .= "(p.ref LIKE '" . $db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $db->escape($prefix . $crit) . "%'";
2165
+                $sql .= "(p.ref LIKE '".$db->escape($prefix.$crit)."%' OR p.label LIKE '".$db->escape($prefix.$crit)."%'";
2166 2166
                 if (!empty($conf->global->MAIN_MULTILANGS))
2167
-                    $sql .= " OR pl.label LIKE '" . $db->escape($prefix . $crit) . "%'";
2167
+                    $sql .= " OR pl.label LIKE '".$db->escape($prefix.$crit)."%'";
2168 2168
                 if (!empty($conf->global->PRODUCT_AJAX_SEARCH_ON_DESCRIPTION)) {
2169
-                    $sql .= " OR p.description LIKE '" . $db->escape($prefix . $crit) . "%'";
2169
+                    $sql .= " OR p.description LIKE '".$db->escape($prefix.$crit)."%'";
2170 2170
                     if (!empty($conf->global->MAIN_MULTILANGS))
2171
-                        $sql .= " OR pl.description LIKE '" . $db->escape($prefix . $crit) . "%'";
2171
+                        $sql .= " OR pl.description LIKE '".$db->escape($prefix.$crit)."%'";
2172 2172
                 }
2173 2173
                 if (!empty($conf->global->MAIN_SEARCH_PRODUCT_BY_FOURN_REF))
2174
-                    $sql .= " OR pfp.ref_fourn LIKE '" . $db->escape($prefix . $crit) . "%'";
2174
+                    $sql .= " OR pfp.ref_fourn LIKE '".$db->escape($prefix.$crit)."%'";
2175 2175
                 $sql .= ")";
2176 2176
                 $i++;
2177 2177
             }
2178 2178
             if (count($scrit) > 1)
2179 2179
                 $sql .= ")";
2180 2180
             if (!empty($conf->barcode->enabled))
2181
-                $sql .= " OR p.barcode LIKE '" . $db->escape($prefix . $filterkey) . "%'";
2181
+                $sql .= " OR p.barcode LIKE '".$db->escape($prefix.$filterkey)."%'";
2182 2182
             $sql .= ')';
2183 2183
         }
2184 2184
         if (count($warehouseStatusArray)) {
2185
-            $sql .= ' GROUP BY' . $selectFields;
2185
+            $sql .= ' GROUP BY'.$selectFields;
2186 2186
         }
2187 2187
 
2188 2188
         //Sort by category
@@ -2197,21 +2197,21 @@  discard block
 block discarded – undo
2197 2197
         $sql .= $db->plimit($limit, 0);
2198 2198
 
2199 2199
         // Build output string
2200
-        dol_syslog(get_class($this) . "::select_produits_list search product", LOG_DEBUG);
2200
+        dol_syslog(get_class($this)."::select_produits_list search product", LOG_DEBUG);
2201 2201
         $result = $this->db->query($sql);
2202 2202
         if ($result) {
2203
-            require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
2204
-            require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php';
2203
+            require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
2204
+            require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
2205 2205
             $num = $this->db->num_rows($result);
2206 2206
 
2207 2207
             $events = null;
2208 2208
 
2209 2209
             if (!$forcecombo) {
2210
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
2210
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
2211 2211
                 $out .= ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT);
2212 2212
             }
2213 2213
 
2214
-            $out .= '<select class="flat' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '" id="' . $htmlname . '">';
2214
+            $out .= '<select class="flat'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'" id="'.$htmlname.'">';
2215 2215
 
2216 2216
             $textifempty = '';
2217 2217
             // Do not use textifempty = ' ' or '&nbsp;' here, or search on key will search on ' key'.
@@ -2223,7 +2223,7 @@  discard block
 block discarded – undo
2223 2223
                     $textifempty .= $langs->trans("All");
2224 2224
             }
2225 2225
             if ($showempty)
2226
-                $out .= '<option value="0" selected>' . $textifempty . '</option>';
2226
+                $out .= '<option value="0" selected>'.$textifempty.'</option>';
2227 2227
 
2228 2228
             $i = 0;
2229 2229
             while ($num && $i < $num) {
@@ -2233,11 +2233,11 @@  discard block
 block discarded – undo
2233 2233
 
2234 2234
                 if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1) { // Price by quantity will return many prices for the same product
2235 2235
                     $sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
2236
-                    $sql .= " FROM " . MAIN_DB_PREFIX . "product_price_by_qty";
2237
-                    $sql .= " WHERE fk_product_price=" . $objp->price_rowid;
2236
+                    $sql .= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
2237
+                    $sql .= " WHERE fk_product_price=".$objp->price_rowid;
2238 2238
                     $sql .= " ORDER BY quantity ASC";
2239 2239
 
2240
-                    dol_syslog(get_class($this) . "::select_produits_list search price by qty", LOG_DEBUG);
2240
+                    dol_syslog(get_class($this)."::select_produits_list search price by qty", LOG_DEBUG);
2241 2241
                     $result2 = $this->db->query($sql);
2242 2242
                     if ($result2) {
2243 2243
                         $nb_prices = $this->db->num_rows($result2);
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
         if (!empty($objp->label_translated))
2342 2342
             $label = $objp->label_translated;
2343 2343
         if (!empty($filterkey) && $filterkey != '')
2344
-            $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1);
2344
+            $label = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $label, 1);
2345 2345
 
2346 2346
         $outkey = $objp->rowid;
2347 2347
         $outref = $objp->ref;
@@ -2353,10 +2353,10 @@  discard block
 block discarded – undo
2353 2353
         $outdurationvalue = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : '';
2354 2354
         $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : '';
2355 2355
 
2356
-        $opt = '<option value="' . $objp->rowid . '"';
2356
+        $opt = '<option value="'.$objp->rowid.'"';
2357 2357
         $opt .= ($objp->rowid == $selected) ? ' selected' : '';
2358 2358
         if (!empty($objp->price_by_qty_rowid) && $objp->price_by_qty_rowid > 0) {
2359
-            $opt .= ' pbq="' . $objp->price_by_qty_rowid . '" data-pbq="' . $objp->price_by_qty_rowid . '" data-pbqqty="' . $objp->price_by_qty_quantity . '" data-pbqpercent="' . $objp->price_by_qty_remise_percent . '"';
2359
+            $opt .= ' pbq="'.$objp->price_by_qty_rowid.'" data-pbq="'.$objp->price_by_qty_rowid.'" data-pbqqty="'.$objp->price_by_qty_quantity.'" data-pbqpercent="'.$objp->price_by_qty_remise_percent.'"';
2360 2360
         }
2361 2361
         if (!empty($conf->stock->enabled) && $objp->fk_product_type == 0 && isset($objp->stock)) {
2362 2362
             if ($objp->stock > 0)
@@ -2367,16 +2367,16 @@  discard block
 block discarded – undo
2367 2367
         $opt .= '>';
2368 2368
         $opt .= $objp->ref;
2369 2369
         if ($outbarcode)
2370
-            $opt .= ' (' . $outbarcode . ')';
2371
-        $opt .= ' - ' . dol_trunc($label, $maxlengtharticle);
2370
+            $opt .= ' ('.$outbarcode.')';
2371
+        $opt .= ' - '.dol_trunc($label, $maxlengtharticle);
2372 2372
 
2373 2373
         $objRef = $objp->ref;
2374 2374
         if (!empty($filterkey) && $filterkey != '')
2375
-            $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1);
2375
+            $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1);
2376 2376
         $outval .= $objRef;
2377 2377
         if ($outbarcode)
2378
-            $outval .= ' (' . $outbarcode . ')';
2379
-        $outval .= ' - ' . dol_trunc($label, $maxlengtharticle);
2378
+            $outval .= ' ('.$outbarcode.')';
2379
+        $outval .= ' - '.dol_trunc($label, $maxlengtharticle);
2380 2380
 
2381 2381
         $found = 0;
2382 2382
 
@@ -2384,25 +2384,25 @@  discard block
 block discarded – undo
2384 2384
         // If we need a particular price level (from 1 to 6)
2385 2385
         if (empty($hidepriceinlabel) && $price_level >= 1 && (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
2386 2386
             $sql = "SELECT price, price_ttc, price_base_type, tva_tx";
2387
-            $sql .= " FROM " . MAIN_DB_PREFIX . "product_price";
2388
-            $sql .= " WHERE fk_product='" . $objp->rowid . "'";
2389
-            $sql .= " AND entity IN (" . getEntity('productprice') . ")";
2390
-            $sql .= " AND price_level=" . $price_level;
2387
+            $sql .= " FROM ".MAIN_DB_PREFIX."product_price";
2388
+            $sql .= " WHERE fk_product='".$objp->rowid."'";
2389
+            $sql .= " AND entity IN (".getEntity('productprice').")";
2390
+            $sql .= " AND price_level=".$price_level;
2391 2391
             $sql .= " ORDER BY date_price DESC, rowid DESC"; // Warning DESC must be both on date_price and rowid.
2392 2392
             $sql .= " LIMIT 1";
2393 2393
 
2394
-            dol_syslog(get_class($this) . '::constructProductListOption search price for level ' . $price_level . '', LOG_DEBUG);
2394
+            dol_syslog(get_class($this).'::constructProductListOption search price for level '.$price_level.'', LOG_DEBUG);
2395 2395
             $result2 = $this->db->query($sql);
2396 2396
             if ($result2) {
2397 2397
                 $objp2 = $this->db->fetch_object($result2);
2398 2398
                 if ($objp2) {
2399 2399
                     $found = 1;
2400 2400
                     if ($objp2->price_base_type == 'HT') {
2401
-                        $opt .= ' - ' . price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("HT");
2402
-                        $outval .= ' - ' . price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("HT");
2401
+                        $opt .= ' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
2402
+                        $outval .= ' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
2403 2403
                     } else {
2404
-                        $opt .= ' - ' . price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("TTC");
2405
-                        $outval .= ' - ' . price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("TTC");
2404
+                        $opt .= ' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
2405
+                        $outval .= ' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
2406 2406
                     }
2407 2407
                     $outprice_ht = price($objp2->price);
2408 2408
                     $outprice_ttc = price($objp2->price_ttc);
@@ -2420,13 +2420,13 @@  discard block
 block discarded – undo
2420 2420
             $outqty = $objp->quantity;
2421 2421
             $outdiscount = $objp->remise_percent;
2422 2422
             if ($objp->quantity == 1) {
2423
-                $opt .= ' - ' . price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/";
2424
-                $outval .= ' - ' . price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/";
2423
+                $opt .= ' - '.price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/";
2424
+                $outval .= ' - '.price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/";
2425 2425
                 $opt .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
2426 2426
                 $outval .= $langs->transnoentities("Unit");
2427 2427
             } else {
2428
-                $opt .= ' - ' . price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity;
2429
-                $outval .= ' - ' . price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity;
2428
+                $opt .= ' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
2429
+                $outval .= ' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
2430 2430
                 $opt .= $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
2431 2431
                 $outval .= $langs->transnoentities("Units");
2432 2432
             }
@@ -2437,12 +2437,12 @@  discard block
 block discarded – undo
2437 2437
             $outtva_tx = $objp->tva_tx;
2438 2438
         }
2439 2439
         if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1) {
2440
-            $opt .= " (" . price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
2441
-            $outval .= " (" . price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->transnoentities("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
2440
+            $opt .= " (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
2441
+            $outval .= " (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
2442 2442
         }
2443 2443
         if (empty($hidepriceinlabel) && !empty($objp->remise_percent) && $objp->remise_percent >= 1) {
2444
-            $opt .= " - " . $langs->trans("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
2445
-            $outval .= " - " . $langs->transnoentities("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
2444
+            $opt .= " - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
2445
+            $outval .= " - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
2446 2446
         }
2447 2447
 
2448 2448
         // Price by customer
@@ -2451,11 +2451,11 @@  discard block
 block discarded – undo
2451 2451
                 $found = 1;
2452 2452
 
2453 2453
                 if ($objp->custprice_base_type == 'HT') {
2454
-                    $opt .= ' - ' . price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("HT");
2455
-                    $outval .= ' - ' . price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("HT");
2454
+                    $opt .= ' - '.price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
2455
+                    $outval .= ' - '.price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
2456 2456
                 } else {
2457
-                    $opt .= ' - ' . price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("TTC");
2458
-                    $outval .= ' - ' . price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("TTC");
2457
+                    $opt .= ' - '.price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
2458
+                    $outval .= ' - '.price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
2459 2459
                 }
2460 2460
 
2461 2461
                 $outprice_ht = price($objp->custprice);
@@ -2468,11 +2468,11 @@  discard block
 block discarded – undo
2468 2468
         // If level no defined or multiprice not found, we used the default price
2469 2469
         if (empty($hidepriceinlabel) && !$found) {
2470 2470
             if ($objp->price_base_type == 'HT') {
2471
-                $opt .= ' - ' . price($objp->price, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("HT");
2472
-                $outval .= ' - ' . price($objp->price, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("HT");
2471
+                $opt .= ' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
2472
+                $outval .= ' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
2473 2473
             } else {
2474
-                $opt .= ' - ' . price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->trans("TTC");
2475
-                $outval .= ' - ' . price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency) . ' ' . $langs->transnoentities("TTC");
2474
+                $opt .= ' - '.price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
2475
+                $outval .= ' - '.price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
2476 2476
             }
2477 2477
             $outprice_ht = price($objp->price);
2478 2478
             $outprice_ttc = price($objp->price_ttc);
@@ -2481,21 +2481,21 @@  discard block
 block discarded – undo
2481 2481
         }
2482 2482
 
2483 2483
         if (!empty($conf->stock->enabled) && isset($objp->stock) && $objp->fk_product_type == 0) {
2484
-            $opt .= ' - ' . $langs->trans("Stock") . ':' . $objp->stock;
2484
+            $opt .= ' - '.$langs->trans("Stock").':'.$objp->stock;
2485 2485
 
2486 2486
             if ($objp->stock > 0) {
2487
-                $outval .= ' - <span class="product_line_stock_ok">' . $langs->transnoentities("Stock") . ':' . $objp->stock . '</span>';
2487
+                $outval .= ' - <span class="product_line_stock_ok">'.$langs->transnoentities("Stock").':'.$objp->stock.'</span>';
2488 2488
             } elseif ($objp->stock <= 0) {
2489
-                $outval .= ' - <span class="product_line_stock_too_low">' . $langs->transnoentities("Stock") . ':' . $objp->stock . '</span>';
2489
+                $outval .= ' - <span class="product_line_stock_too_low">'.$langs->transnoentities("Stock").':'.$objp->stock.'</span>';
2490 2490
             }
2491 2491
         }
2492 2492
 
2493 2493
         if ($outdurationvalue && $outdurationunit) {
2494 2494
             $da = array("h" => $langs->trans("Hour"), "d" => $langs->trans("Day"), "w" => $langs->trans("Week"), "m" => $langs->trans("Month"), "y" => $langs->trans("Year"));
2495 2495
             if (isset($da[$outdurationunit])) {
2496
-                $key = $da[$outdurationunit] . ($outdurationvalue > 1 ? 's' : '');
2497
-                $opt .= ' - ' . $outdurationvalue . ' ' . $langs->trans($key);
2498
-                $outval .= ' - ' . $outdurationvalue . ' ' . $langs->transnoentities($key);
2496
+                $key = $da[$outdurationunit].($outdurationvalue > 1 ? 's' : '');
2497
+                $opt .= ' - '.$outdurationvalue.' '.$langs->trans($key);
2498
+                $outval .= ' - '.$outdurationvalue.' '.$langs->transnoentities($key);
2499 2499
             }
2500 2500
         }
2501 2501
 
@@ -2526,7 +2526,7 @@  discard block
 block discarded – undo
2526 2526
         $selected_input_value = '';
2527 2527
         if (!empty($conf->use_javascript_ajax) && !empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) {
2528 2528
             if ($selected > 0) {
2529
-                require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
2529
+                require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
2530 2530
                 $producttmpselect = new Product($this->db);
2531 2531
                 $producttmpselect->fetch($selected);
2532 2532
                 $selected_input_value = $producttmpselect->ref;
@@ -2534,9 +2534,9 @@  discard block
 block discarded – undo
2534 2534
             }
2535 2535
 
2536 2536
             // mode=2 means suppliers products
2537
-            $urloption = ($socid > 0 ? 'socid=' . $socid . '&' : '') . 'htmlname=' . $htmlname . '&outjson=1&price_level=' . $price_level . '&type=' . $filtertype . '&mode=2&status=' . $status . '&finished=' . $finished . '&alsoproductwithnosupplierprice=' . $alsoproductwithnosupplierprice;
2538
-            print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT . '/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
2539
-            print ($hidelabel ? '' : $langs->trans("RefOrLabel") . ' : ') . '<input type="text" size="20" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $selected_input_value . '">';
2537
+            $urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
2538
+            print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
2539
+            print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').'<input type="text" size="20" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'">';
2540 2540
         } else {
2541 2541
             print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', -1, 0, 0, $alsoproductwithnosupplierprice);
2542 2542
         }
@@ -2572,17 +2572,17 @@  discard block
 block discarded – undo
2572 2572
         $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.remise_percent, pfp.remise, pfp.unitprice,";
2573 2573
         $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, pfp.fk_soc, s.nom as name,";
2574 2574
         $sql .= " pfp.supplier_reputation";
2575
-        $sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
2576
-        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2575
+        $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
2576
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2577 2577
         if ($socid)
2578
-            $sql .= " AND pfp.fk_soc = " . $socid;
2579
-        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON pfp.fk_soc = s.rowid";
2580
-        $sql .= " WHERE p.entity IN (" . getEntity('product') . ")";
2578
+            $sql .= " AND pfp.fk_soc = ".$socid;
2579
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
2580
+        $sql .= " WHERE p.entity IN (".getEntity('product').")";
2581 2581
         $sql .= " AND p.tobuy = 1";
2582 2582
         if (strval($filtertype) != '')
2583
-            $sql .= " AND p.fk_product_type=" . $this->db->escape($filtertype);
2583
+            $sql .= " AND p.fk_product_type=".$this->db->escape($filtertype);
2584 2584
         if (!empty($filtre))
2585
-            $sql .= " " . $filtre;
2585
+            $sql .= " ".$filtre;
2586 2586
         // Add criteria on ref/label
2587 2587
         if ($filterkey != '') {
2588 2588
             $sql .= ' AND (';
@@ -2595,13 +2595,13 @@  discard block
 block discarded – undo
2595 2595
             foreach ($scrit as $crit) {
2596 2596
                 if ($i > 0)
2597 2597
                     $sql .= " AND ";
2598
-                $sql .= "(pfp.ref_fourn LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.ref LIKE '" . $this->db->escape($prefix . $crit) . "%' OR p.label LIKE '" . $this->db->escape($prefix . $crit) . "%')";
2598
+                $sql .= "(pfp.ref_fourn LIKE '".$this->db->escape($prefix.$crit)."%' OR p.ref LIKE '".$this->db->escape($prefix.$crit)."%' OR p.label LIKE '".$this->db->escape($prefix.$crit)."%')";
2599 2599
                 $i++;
2600 2600
             }
2601 2601
             if (count($scrit) > 1)
2602 2602
                 $sql .= ")";
2603 2603
             if (!empty($conf->barcode->enabled))
2604
-                $sql .= " OR p.barcode LIKE '" . $this->db->escape($prefix . $filterkey) . "%'";
2604
+                $sql .= " OR p.barcode LIKE '".$this->db->escape($prefix.$filterkey)."%'";
2605 2605
             $sql .= ')';
2606 2606
         }
2607 2607
         $sql .= " ORDER BY pfp.ref_fourn DESC, pfp.quantity ASC";
@@ -2609,15 +2609,15 @@  discard block
 block discarded – undo
2609 2609
 
2610 2610
         // Build output string
2611 2611
 
2612
-        dol_syslog(get_class($this) . "::select_produits_fournisseurs_list", LOG_DEBUG);
2612
+        dol_syslog(get_class($this)."::select_produits_fournisseurs_list", LOG_DEBUG);
2613 2613
         $result = $this->db->query($sql);
2614 2614
         if ($result) {
2615
-            require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php';
2615
+            require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
2616 2616
 
2617 2617
             $num = $this->db->num_rows($result);
2618 2618
 
2619 2619
             //$out.='<select class="flat" id="select'.$htmlname.'" name="'.$htmlname.'">';	// remove select to have id same with combo and ajax
2620
-            $out .= '<select class="flat maxwidthonsmartphone" id="' . $htmlname . '" name="' . $htmlname . '">';
2620
+            $out .= '<select class="flat maxwidthonsmartphone" id="'.$htmlname.'" name="'.$htmlname.'">';
2621 2621
             if (!$selected)
2622 2622
                 $out .= '<option value="0" selected>&nbsp;</option>';
2623 2623
             else
@@ -2627,9 +2627,9 @@  discard block
 block discarded – undo
2627 2627
             while ($i < $num) {
2628 2628
                 $objp = $this->db->fetch_object($result);
2629 2629
 
2630
-                $outkey = $objp->idprodfournprice;                                                    // id in table of price
2630
+                $outkey = $objp->idprodfournprice; // id in table of price
2631 2631
                 if (!$outkey && $alsoproductwithnosupplierprice)
2632
-                    $outkey = 'idprod_' . $objp->rowid;   // id of product
2632
+                    $outkey = 'idprod_'.$objp->rowid; // id of product
2633 2633
 
2634 2634
                 $outref = $objp->ref;
2635 2635
                 $outval = '';
@@ -2639,36 +2639,36 @@  discard block
 block discarded – undo
2639 2639
                 $outdurationvalue = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, 0, dol_strlen($objp->duration) - 1) : '';
2640 2640
                 $outdurationunit = $outtype == Product::TYPE_SERVICE ? substr($objp->duration, -1) : '';
2641 2641
 
2642
-                $opt = '<option value="' . $outkey . '"';
2642
+                $opt = '<option value="'.$outkey.'"';
2643 2643
                 if ($selected && $selected == $objp->idprodfournprice)
2644 2644
                     $opt .= ' selected';
2645 2645
                 if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice))
2646 2646
                     $opt .= ' disabled';
2647 2647
                 if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) {
2648
-                    $opt .= ' pbq="' . $objp->idprodfournprice . '" data-pbq="' . $objp->idprodfournprice . '" data-pbqqty="' . $objp->quantity . '" data-pbqpercent="' . $objp->remise_percent . '"';
2648
+                    $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqpercent="'.$objp->remise_percent.'"';
2649 2649
                 }
2650 2650
                 $opt .= '>';
2651 2651
 
2652 2652
                 $objRef = $objp->ref;
2653 2653
                 if ($filterkey && $filterkey != '')
2654
-                    $objRef = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRef, 1);
2654
+                    $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRef, 1);
2655 2655
                 $objRefFourn = $objp->ref_fourn;
2656 2656
                 if ($filterkey && $filterkey != '')
2657
-                    $objRefFourn = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $objRefFourn, 1);
2657
+                    $objRefFourn = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $objRefFourn, 1);
2658 2658
                 $label = $objp->label;
2659 2659
                 if ($filterkey && $filterkey != '')
2660
-                    $label = preg_replace('/(' . preg_quote($filterkey) . ')/i', '<strong>$1</strong>', $label, 1);
2660
+                    $label = preg_replace('/('.preg_quote($filterkey).')/i', '<strong>$1</strong>', $label, 1);
2661 2661
 
2662 2662
                 $opt .= $objp->ref;
2663 2663
                 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn))
2664
-                    $opt .= ' (' . $objp->ref_fourn . ')';
2664
+                    $opt .= ' ('.$objp->ref_fourn.')';
2665 2665
                 $opt .= ' - ';
2666 2666
                 $outval .= $objRef;
2667 2667
                 if (!empty($objp->idprodfournprice) && ($objp->ref != $objp->ref_fourn))
2668
-                    $outval .= ' (' . $objRefFourn . ')';
2668
+                    $outval .= ' ('.$objRefFourn.')';
2669 2669
                 $outval .= ' - ';
2670
-                $opt .= dol_trunc($label, 72) . ' - ';
2671
-                $outval .= dol_trunc($label, 72) . ' - ';
2670
+                $opt .= dol_trunc($label, 72).' - ';
2671
+                $outval .= dol_trunc($label, 72).' - ';
2672 2672
 
2673 2673
                 if (!empty($objp->idprodfournprice)) {
2674 2674
                     $outqty = $objp->quantity;
@@ -2690,39 +2690,39 @@  discard block
 block discarded – undo
2690 2690
                         }
2691 2691
                     }
2692 2692
                     if ($objp->quantity == 1) {
2693
-                        $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency) . "/";
2694
-                        $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency) . "/";
2693
+                        $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/";
2694
+                        $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/";
2695 2695
                         $opt .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
2696 2696
                         $outval .= $langs->transnoentities("Unit");
2697 2697
                     } else {
2698
-                        $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity;
2699
-                        $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $objp->quantity;
2700
-                        $opt .= ' ' . $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
2701
-                        $outval .= ' ' . $langs->transnoentities("Units");
2698
+                        $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
2699
+                        $outval .= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
2700
+                        $opt .= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
2701
+                        $outval .= ' '.$langs->transnoentities("Units");
2702 2702
                     }
2703 2703
 
2704 2704
                     if ($objp->quantity >= 1) {
2705
-                        $opt .= " (" . price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
2706
-                        $outval .= " (" . price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->transnoentities("Unit") . ")"; // Do not use strtolower because it breaks utf8 encoding
2705
+                        $opt .= " (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
2706
+                        $outval .= " (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding
2707 2707
                     }
2708 2708
                     if ($objp->remise_percent >= 1) {
2709
-                        $opt .= " - " . $langs->trans("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
2710
-                        $outval .= " - " . $langs->transnoentities("Discount") . " : " . vatrate($objp->remise_percent) . ' %';
2709
+                        $opt .= " - ".$langs->trans("Discount")." : ".vatrate($objp->remise_percent).' %';
2710
+                        $outval .= " - ".$langs->transnoentities("Discount")." : ".vatrate($objp->remise_percent).' %';
2711 2711
                     }
2712 2712
                     if ($objp->duration) {
2713
-                        $opt .= " - " . $objp->duration;
2714
-                        $outval .= " - " . $objp->duration;
2713
+                        $opt .= " - ".$objp->duration;
2714
+                        $outval .= " - ".$objp->duration;
2715 2715
                     }
2716 2716
                     if (!$socid) {
2717
-                        $opt .= " - " . dol_trunc($objp->name, 8);
2718
-                        $outval .= " - " . dol_trunc($objp->name, 8);
2717
+                        $opt .= " - ".dol_trunc($objp->name, 8);
2718
+                        $outval .= " - ".dol_trunc($objp->name, 8);
2719 2719
                     }
2720 2720
                     if ($objp->supplier_reputation) {
2721 2721
                         //TODO dictionary
2722 2722
                         $reputations = array('' => $langs->trans('Standard'), 'FAVORITE' => $langs->trans('Favorite'), 'NOTTHGOOD' => $langs->trans('NotTheGoodQualitySupplier'), 'DONOTORDER' => $langs->trans('DoNotOrderThisProductToThisSupplier'));
2723 2723
 
2724
-                        $opt .= " - " . $reputations[$objp->supplier_reputation];
2725
-                        $outval .= " - " . $reputations[$objp->supplier_reputation];
2724
+                        $opt .= " - ".$reputations[$objp->supplier_reputation];
2725
+                        $outval .= " - ".$reputations[$objp->supplier_reputation];
2726 2726
                     }
2727 2727
                 } else {
2728 2728
                     if (empty($alsoproductwithnosupplierprice)) {     // No supplier price defined for couple product/supplier
@@ -2756,7 +2756,7 @@  discard block
 block discarded – undo
2756 2756
 
2757 2757
             $this->db->free($result);
2758 2758
 
2759
-            include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
2759
+            include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
2760 2760
             $out .= ajax_combobox($htmlname);
2761 2761
 
2762 2762
             if (empty($outputmode))
@@ -2787,39 +2787,39 @@  discard block
 block discarded – undo
2787 2787
         $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, pfp.fk_soc,";
2788 2788
         $sql .= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,";
2789 2789
         $sql .= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name";
2790
-        $sql .= " FROM " . MAIN_DB_PREFIX . "product as p";
2791
-        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2792
-        $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe as s ON pfp.fk_soc = s.rowid";
2793
-        $sql .= " WHERE pfp.entity IN (" . getEntity('productsupplierprice') . ")";
2790
+        $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
2791
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product";
2792
+        $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON pfp.fk_soc = s.rowid";
2793
+        $sql .= " WHERE pfp.entity IN (".getEntity('productsupplierprice').")";
2794 2794
         $sql .= " AND p.tobuy = 1";
2795 2795
         $sql .= " AND s.fournisseur = 1";
2796
-        $sql .= " AND p.rowid = " . $productid;
2796
+        $sql .= " AND p.rowid = ".$productid;
2797 2797
         $sql .= " ORDER BY s.nom, pfp.ref_fourn DESC";
2798 2798
 
2799
-        dol_syslog(get_class($this) . "::select_product_fourn_price", LOG_DEBUG);
2799
+        dol_syslog(get_class($this)."::select_product_fourn_price", LOG_DEBUG);
2800 2800
         $result = $this->db->query($sql);
2801 2801
 
2802 2802
         if ($result) {
2803 2803
             $num = $this->db->num_rows($result);
2804 2804
 
2805
-            $form = '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">';
2805
+            $form = '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
2806 2806
 
2807 2807
             if (!$num) {
2808
-                $form .= '<option value="0">-- ' . $langs->trans("NoSupplierPriceDefinedForThisProduct") . ' --</option>';
2808
+                $form .= '<option value="0">-- '.$langs->trans("NoSupplierPriceDefinedForThisProduct").' --</option>';
2809 2809
             } else {
2810
-                require_once DOL_DOCUMENT_ROOT . '/product/dynamic_price/class/price_parser.class.php';
2810
+                require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
2811 2811
                 $form .= '<option value="0">&nbsp;</option>';
2812 2812
 
2813 2813
                 $i = 0;
2814 2814
                 while ($i < $num) {
2815 2815
                     $objp = $this->db->fetch_object($result);
2816 2816
 
2817
-                    $opt = '<option value="' . $objp->idprodfournprice . '"';
2817
+                    $opt = '<option value="'.$objp->idprodfournprice.'"';
2818 2818
                     //if there is only one supplier, preselect it
2819 2819
                     if ($num == 1 || ($selected_supplier > 0 && $objp->fk_soc == $selected_supplier)) {
2820 2820
                         $opt .= ' selected';
2821 2821
                     }
2822
-                    $opt .= '>' . $objp->name . ' - ' . $objp->ref_fourn . ' - ';
2822
+                    $opt .= '>'.$objp->name.' - '.$objp->ref_fourn.' - ';
2823 2823
 
2824 2824
                     if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_supplier_price_expression)) {
2825 2825
                         $prod_supplier = new ProductFournisseur($this->db);
@@ -2838,10 +2838,10 @@  discard block
 block discarded – undo
2838 2838
                         }
2839 2839
                     }
2840 2840
                     if ($objp->quantity == 1) {
2841
-                        $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency) . "/";
2841
+                        $opt .= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/";
2842 2842
                     }
2843 2843
 
2844
-                    $opt .= $objp->quantity . ' ';
2844
+                    $opt .= $objp->quantity.' ';
2845 2845
 
2846 2846
                     if ($objp->quantity == 1) {
2847 2847
                         $opt .= $langs->trans("Unit");
@@ -2850,10 +2850,10 @@  discard block
 block discarded – undo
2850 2850
                     }
2851 2851
                     if ($objp->quantity > 1) {
2852 2852
                         $opt .= " - ";
2853
-                        $opt .= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency) . "/" . $langs->trans("Unit");
2853
+                        $opt .= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit");
2854 2854
                     }
2855 2855
                     if ($objp->duration)
2856
-                        $opt .= " - " . $objp->duration;
2856
+                        $opt .= " - ".$objp->duration;
2857 2857
                     $opt .= "</option>\n";
2858 2858
 
2859 2859
                     $form .= $opt;
@@ -2885,14 +2885,14 @@  discard block
 block discarded – undo
2885 2885
         // phpcs:enable
2886 2886
         // looking for users
2887 2887
         $sql = "SELECT a.rowid, a.label";
2888
-        $sql .= " FROM " . MAIN_DB_PREFIX . "societe_address as a";
2889
-        $sql .= " WHERE a.fk_soc = " . $socid;
2888
+        $sql .= " FROM ".MAIN_DB_PREFIX."societe_address as a";
2889
+        $sql .= " WHERE a.fk_soc = ".$socid;
2890 2890
         $sql .= " ORDER BY a.label ASC";
2891 2891
 
2892
-        dol_syslog(get_class($this) . "::select_address", LOG_DEBUG);
2892
+        dol_syslog(get_class($this)."::select_address", LOG_DEBUG);
2893 2893
         $resql = $this->db->query($sql);
2894 2894
         if ($resql) {
2895
-            print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">';
2895
+            print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
2896 2896
             if ($showempty)
2897 2897
                 print '<option value="0">&nbsp;</option>';
2898 2898
             $num = $this->db->num_rows($resql);
@@ -2902,9 +2902,9 @@  discard block
 block discarded – undo
2902 2902
                     $obj = $this->db->fetch_object($resql);
2903 2903
 
2904 2904
                     if ($selected && $selected == $obj->rowid) {
2905
-                        print '<option value="' . $obj->rowid . '" selected>' . $obj->label . '</option>';
2905
+                        print '<option value="'.$obj->rowid.'" selected>'.$obj->label.'</option>';
2906 2906
                     } else {
2907
-                        print '<option value="' . $obj->rowid . '">' . $obj->label . '</option>';
2907
+                        print '<option value="'.$obj->rowid.'">'.$obj->label.'</option>';
2908 2908
                     }
2909 2909
                     $i++;
2910 2910
                 }
@@ -2929,13 +2929,13 @@  discard block
 block discarded – undo
2929 2929
 
2930 2930
         $num = count($this->cache_conditions_paiements);
2931 2931
         if ($num > 0)
2932
-            return 0;    // Cache already loaded
2932
+            return 0; // Cache already loaded
2933 2933
 
2934 2934
         dol_syslog(__METHOD__, LOG_DEBUG);
2935 2935
 
2936 2936
         $sql = "SELECT rowid, code, libelle as label";
2937
-        $sql .= " FROM " . MAIN_DB_PREFIX . 'c_payment_term';
2938
-        $sql .= " WHERE entity IN (" . getEntity('c_payment_term') . ")";
2937
+        $sql .= " FROM ".MAIN_DB_PREFIX.'c_payment_term';
2938
+        $sql .= " WHERE entity IN (".getEntity('c_payment_term').")";
2939 2939
         $sql .= " AND active > 0";
2940 2940
         $sql .= " ORDER BY sortorder";
2941 2941
 
@@ -2947,7 +2947,7 @@  discard block
 block discarded – undo
2947 2947
                 $obj = $this->db->fetch_object($resql);
2948 2948
 
2949 2949
                 // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
2950
-                $label = ($langs->trans("PaymentConditionShort" . $obj->code) != ("PaymentConditionShort" . $obj->code) ? $langs->trans("PaymentConditionShort" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
2950
+                $label = ($langs->trans("PaymentConditionShort".$obj->code) != ("PaymentConditionShort".$obj->code) ? $langs->trans("PaymentConditionShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
2951 2951
                 $this->cache_conditions_paiements[$obj->rowid]['code'] = $obj->code;
2952 2952
                 $this->cache_conditions_paiements[$obj->rowid]['label'] = $label;
2953 2953
                 $i++;
@@ -2975,14 +2975,14 @@  discard block
 block discarded – undo
2975 2975
 
2976 2976
         $num = count($this->cache_availability);
2977 2977
         if ($num > 0)
2978
-            return 0;    // Cache already loaded
2978
+            return 0; // Cache already loaded
2979 2979
 
2980 2980
         dol_syslog(__METHOD__, LOG_DEBUG);
2981 2981
 
2982 2982
         $langs->load('propal');
2983 2983
 
2984 2984
         $sql = "SELECT rowid, code, label";
2985
-        $sql .= " FROM " . MAIN_DB_PREFIX . 'c_availability';
2985
+        $sql .= " FROM ".MAIN_DB_PREFIX.'c_availability';
2986 2986
         $sql .= " WHERE active > 0";
2987 2987
 
2988 2988
         $resql = $this->db->query($sql);
@@ -2993,7 +2993,7 @@  discard block
 block discarded – undo
2993 2993
                 $obj = $this->db->fetch_object($resql);
2994 2994
 
2995 2995
                 // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
2996
-                $label = ($langs->trans("AvailabilityType" . $obj->code) != ("AvailabilityType" . $obj->code) ? $langs->trans("AvailabilityType" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
2996
+                $label = ($langs->trans("AvailabilityType".$obj->code) != ("AvailabilityType".$obj->code) ? $langs->trans("AvailabilityType".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
2997 2997
                 $this->cache_availability[$obj->rowid]['code'] = $obj->code;
2998 2998
                 $this->cache_availability[$obj->rowid]['label'] = $label;
2999 2999
                 $i++;
@@ -3023,16 +3023,16 @@  discard block
 block discarded – undo
3023 3023
 
3024 3024
         $this->load_cache_availability();
3025 3025
 
3026
-        dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG);
3026
+        dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
3027 3027
 
3028
-        print '<select id="' . $htmlname . '" class="flat" name="' . $htmlname . '">';
3028
+        print '<select id="'.$htmlname.'" class="flat" name="'.$htmlname.'">';
3029 3029
         if ($addempty)
3030 3030
             print '<option value="0">&nbsp;</option>';
3031 3031
         foreach ($this->cache_availability as $id => $arrayavailability) {
3032 3032
             if ($selected == $id) {
3033
-                print '<option value="' . $id . '" selected>';
3033
+                print '<option value="'.$id.'" selected>';
3034 3034
             } else {
3035
-                print '<option value="' . $id . '">';
3035
+                print '<option value="'.$id.'">';
3036 3036
             }
3037 3037
             print $arrayavailability['label'];
3038 3038
             print '</option>';
@@ -3053,10 +3053,10 @@  discard block
 block discarded – undo
3053 3053
 
3054 3054
         $num = count($this->cache_demand_reason);
3055 3055
         if ($num > 0)
3056
-            return 0;    // Cache already loaded
3056
+            return 0; // Cache already loaded
3057 3057
 
3058 3058
         $sql = "SELECT rowid, code, label";
3059
-        $sql .= " FROM " . MAIN_DB_PREFIX . 'c_input_reason';
3059
+        $sql .= " FROM ".MAIN_DB_PREFIX.'c_input_reason';
3060 3060
         $sql .= " WHERE active > 0";
3061 3061
 
3062 3062
         $resql = $this->db->query($sql);
@@ -3069,10 +3069,10 @@  discard block
 block discarded – undo
3069 3069
 
3070 3070
                 // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
3071 3071
                 $label = ($obj->label != '-' ? $obj->label : '');
3072
-                if ($langs->trans("DemandReasonType" . $obj->code) != ("DemandReasonType" . $obj->code))
3073
-                    $label = $langs->trans("DemandReasonType" . $obj->code); // So translation key DemandReasonTypeSRC_XXX will work
3072
+                if ($langs->trans("DemandReasonType".$obj->code) != ("DemandReasonType".$obj->code))
3073
+                    $label = $langs->trans("DemandReasonType".$obj->code); // So translation key DemandReasonTypeSRC_XXX will work
3074 3074
                 if ($langs->trans($obj->code) != $obj->code)
3075
-                    $label = $langs->trans($obj->code);                // So translation key SRC_XXX will work
3075
+                    $label = $langs->trans($obj->code); // So translation key SRC_XXX will work
3076 3076
 
3077 3077
                 $tmparray[$obj->rowid]['id'] = $obj->rowid;
3078 3078
                 $tmparray[$obj->rowid]['code'] = $obj->code;
@@ -3107,17 +3107,17 @@  discard block
 block discarded – undo
3107 3107
 
3108 3108
         $this->loadCacheInputReason();
3109 3109
 
3110
-        print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">';
3110
+        print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
3111 3111
         if ($addempty)
3112
-            print '<option value="0"' . (empty($selected) ? ' selected' : '') . '>&nbsp;</option>';
3112
+            print '<option value="0"'.(empty($selected) ? ' selected' : '').'>&nbsp;</option>';
3113 3113
         foreach ($this->cache_demand_reason as $id => $arraydemandreason) {
3114 3114
             if ($arraydemandreason['code'] == $exclude)
3115 3115
                 continue;
3116 3116
 
3117 3117
             if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code'])) {
3118
-                print '<option value="' . $arraydemandreason['id'] . '" selected>';
3118
+                print '<option value="'.$arraydemandreason['id'].'" selected>';
3119 3119
             } else {
3120
-                print '<option value="' . $arraydemandreason['id'] . '">';
3120
+                print '<option value="'.$arraydemandreason['id'].'">';
3121 3121
             }
3122 3122
             $label = $arraydemandreason['label']; // Translation of label was already done into the ->loadCacheInputReason
3123 3123
             print $langs->trans($label);
@@ -3141,15 +3141,15 @@  discard block
 block discarded – undo
3141 3141
 
3142 3142
         $num = count($this->cache_types_paiements);
3143 3143
         if ($num > 0)
3144
-            return $num;    // Cache already loaded
3144
+            return $num; // Cache already loaded
3145 3145
 
3146 3146
         dol_syslog(__METHOD__, LOG_DEBUG);
3147 3147
 
3148 3148
         $this->cache_types_paiements = array();
3149 3149
 
3150 3150
         $sql = "SELECT id, code, libelle as label, type, active";
3151
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_paiement";
3152
-        $sql .= " WHERE entity IN (" . getEntity('c_paiement') . ")";
3151
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_paiement";
3152
+        $sql .= " WHERE entity IN (".getEntity('c_paiement').")";
3153 3153
         //if ($active >= 0) $sql.= " AND active = ".$active;
3154 3154
 
3155 3155
         $resql = $this->db->query($sql);
@@ -3160,7 +3160,7 @@  discard block
 block discarded – undo
3160 3160
                 $obj = $this->db->fetch_object($resql);
3161 3161
 
3162 3162
                 // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
3163
-                $label = ($langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != ("PaymentTypeShort" . $obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
3163
+                $label = ($langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) != ("PaymentTypeShort".$obj->code) ? $langs->transnoentitiesnoconv("PaymentTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : ''));
3164 3164
                 $this->cache_types_paiements[$obj->id]['id'] = $obj->id;
3165 3165
                 $this->cache_types_paiements[$obj->id]['code'] = $obj->code;
3166 3166
                 $this->cache_types_paiements[$obj->id]['label'] = $label;
@@ -3197,7 +3197,7 @@  discard block
 block discarded – undo
3197 3197
         // phpcs:enable
3198 3198
         global $langs, $user, $conf;
3199 3199
 
3200
-        dol_syslog(__METHOD__ . " selected=" . $selected . ", htmlname=" . $htmlname, LOG_DEBUG);
3200
+        dol_syslog(__METHOD__." selected=".$selected.", htmlname=".$htmlname, LOG_DEBUG);
3201 3201
 
3202 3202
         $this->load_cache_conditions_paiements();
3203 3203
 
@@ -3205,14 +3205,14 @@  discard block
 block discarded – undo
3205 3205
         if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID))
3206 3206
             $selected = $conf->global->MAIN_DEFAULT_PAYMENT_TERM_ID;
3207 3207
 
3208
-        print '<select id="' . $htmlname . '" class="flat selectpaymentterms' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">';
3208
+        print '<select id="'.$htmlname.'" class="flat selectpaymentterms'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
3209 3209
         if ($addempty)
3210 3210
             print '<option value="0">&nbsp;</option>';
3211 3211
         foreach ($this->cache_conditions_paiements as $id => $arrayconditions) {
3212 3212
             if ($selected == $id) {
3213
-                print '<option value="' . $id . '" selected>';
3213
+                print '<option value="'.$id.'" selected>';
3214 3214
             } else {
3215
-                print '<option value="' . $id . '">';
3215
+                print '<option value="'.$id.'">';
3216 3216
             }
3217 3217
             print $arrayconditions['label'];
3218 3218
             print '</option>';
@@ -3242,7 +3242,7 @@  discard block
 block discarded – undo
3242 3242
         // phpcs:enable
3243 3243
         global $langs, $user;
3244 3244
 
3245
-        dol_syslog(__METHOD__ . " " . $selected . ", " . $htmlname . ", " . $filtertype . ", " . $format, LOG_DEBUG);
3245
+        dol_syslog(__METHOD__." ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
3246 3246
 
3247 3247
         $filterarray = array();
3248 3248
         if ($filtertype == 'CRDT')
@@ -3254,7 +3254,7 @@  discard block
 block discarded – undo
3254 3254
 
3255 3255
         $this->load_cache_types_paiements();
3256 3256
 
3257
-        print '<select id="select' . $htmlname . '" class="flat selectpaymenttypes' . ($morecss ? ' ' . $morecss : '') . '" name="' . $htmlname . '">';
3257
+        print '<select id="select'.$htmlname.'" class="flat selectpaymenttypes'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
3258 3258
         if ($empty)
3259 3259
             print '<option value="">&nbsp;</option>';
3260 3260
         foreach ($this->cache_types_paiements as $id => $arraytypes) {
@@ -3271,13 +3271,13 @@  discard block
 block discarded – undo
3271 3271
                 continue;
3272 3272
 
3273 3273
             if ($format == 0)
3274
-                print '<option value="' . $id . '"';
3274
+                print '<option value="'.$id.'"';
3275 3275
             elseif ($format == 1)
3276
-                print '<option value="' . $arraytypes['code'] . '"';
3276
+                print '<option value="'.$arraytypes['code'].'"';
3277 3277
             elseif ($format == 2)
3278
-                print '<option value="' . $arraytypes['code'] . '"';
3278
+                print '<option value="'.$arraytypes['code'].'"';
3279 3279
             elseif ($format == 3)
3280
-                print '<option value="' . $id . '"';
3280
+                print '<option value="'.$id.'"';
3281 3281
             // Si selected est text, on compare avec code, sinon avec id
3282 3282
             if (preg_match('/[a-z]/i', $selected) && $selected == $arraytypes['code'])
3283 3283
                 print ' selected';
@@ -3313,16 +3313,16 @@  discard block
 block discarded – undo
3313 3313
 
3314 3314
         $return = '';
3315 3315
 
3316
-        $return .= '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">';
3316
+        $return .= '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
3317 3317
         $options = array(
3318 3318
             'HT' => $langs->trans("HT"),
3319 3319
             'TTC' => $langs->trans("TTC")
3320 3320
         );
3321 3321
         foreach ($options as $id => $value) {
3322 3322
             if ($selected == $id) {
3323
-                $return .= '<option value="' . $id . '" selected>' . $value;
3323
+                $return .= '<option value="'.$id.'" selected>'.$value;
3324 3324
             } else {
3325
-                $return .= '<option value="' . $id . '">' . $value;
3325
+                $return .= '<option value="'.$id.'">'.$value;
3326 3326
             }
3327 3327
             $return .= '</option>';
3328 3328
         }
@@ -3349,30 +3349,30 @@  discard block
 block discarded – undo
3349 3349
         $langs->load("deliveries");
3350 3350
 
3351 3351
         $sql = "SELECT rowid, code, libelle as label";
3352
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_shipment_mode";
3352
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode";
3353 3353
         $sql .= " WHERE active > 0";
3354 3354
         if ($filtre)
3355
-            $sql .= " AND " . $filtre;
3355
+            $sql .= " AND ".$filtre;
3356 3356
         $sql .= " ORDER BY libelle ASC";
3357 3357
 
3358
-        dol_syslog(get_class($this) . "::selectShippingMode", LOG_DEBUG);
3358
+        dol_syslog(get_class($this)."::selectShippingMode", LOG_DEBUG);
3359 3359
         $result = $this->db->query($sql);
3360 3360
         if ($result) {
3361 3361
             $num = $this->db->num_rows($result);
3362 3362
             $i = 0;
3363 3363
             if ($num) {
3364
-                print '<select id="select' . $htmlname . '" class="flat selectshippingmethod" name="' . $htmlname . '"' . ($moreattrib ? ' ' . $moreattrib : '') . '>';
3364
+                print '<select id="select'.$htmlname.'" class="flat selectshippingmethod" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
3365 3365
                 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
3366 3366
                     print '<option value="-1">&nbsp;</option>';
3367 3367
                 }
3368 3368
                 while ($i < $num) {
3369 3369
                     $obj = $this->db->fetch_object($result);
3370 3370
                     if ($selected == $obj->rowid) {
3371
-                        print '<option value="' . $obj->rowid . '" selected>';
3371
+                        print '<option value="'.$obj->rowid.'" selected>';
3372 3372
                     } else {
3373
-                        print '<option value="' . $obj->rowid . '">';
3373
+                        print '<option value="'.$obj->rowid.'">';
3374 3374
                     }
3375
-                    print ($langs->trans("SendingMethod" . strtoupper($obj->code)) != "SendingMethod" . strtoupper($obj->code)) ? $langs->trans("SendingMethod" . strtoupper($obj->code)) : $obj->label;
3375
+                    print ($langs->trans("SendingMethod".strtoupper($obj->code)) != "SendingMethod".strtoupper($obj->code)) ? $langs->trans("SendingMethod".strtoupper($obj->code)) : $obj->label;
3376 3376
                     print '</option>';
3377 3377
                     $i++;
3378 3378
                 }
@@ -3403,16 +3403,16 @@  discard block
 block discarded – undo
3403 3403
         $langs->load("deliveries");
3404 3404
 
3405 3405
         if ($htmlname != "none") {
3406
-            print '<form method="POST" action="' . $page . '">';
3406
+            print '<form method="POST" action="'.$page.'">';
3407 3407
             print '<input type="hidden" name="action" value="setshippingmethod">';
3408
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
3408
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
3409 3409
             $this->selectShippingMethod($selected, $htmlname, '', $addempty);
3410
-            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
3410
+            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
3411 3411
             print '</form>';
3412 3412
         } else {
3413 3413
             if ($selected) {
3414 3414
                 $code = $langs->getLabelFromKey($db, $selected, 'c_shipment_mode', 'rowid', 'code');
3415
-                print $langs->trans("SendingMethod" . strtoupper($code));
3415
+                print $langs->trans("SendingMethod".strtoupper($code));
3416 3416
             } else {
3417 3417
                 print "&nbsp;";
3418 3418
             }
@@ -3434,7 +3434,7 @@  discard block
 block discarded – undo
3434 3434
         $langs->load('bills');
3435 3435
 
3436 3436
         $opt = '<option value ="" selected></option>';
3437
-        $sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1';
3437
+        $sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM '.MAIN_DB_PREFIX.'facture WHERE situation_counter>=1';
3438 3438
         $sql .= ' ORDER by situation_cycle_ref, situation_counter desc';
3439 3439
         $resql = $this->db->query($sql);
3440 3440
         if ($resql && $this->db->num_rows($resql) > 0) {
@@ -3452,9 +3452,9 @@  discard block
 block discarded – undo
3452 3452
                             //Not prov?
3453 3453
                             if (substr($obj->ref, 1, 4) != 'PROV') {
3454 3454
                                 if ($selected == $obj->rowid) {
3455
-                                    $opt .= '<option value="' . $obj->rowid . '" selected>' . $obj->ref . '</option>';
3455
+                                    $opt .= '<option value="'.$obj->rowid.'" selected>'.$obj->ref.'</option>';
3456 3456
                                 } else {
3457
-                                    $opt .= '<option value="' . $obj->rowid . '">' . $obj->ref . '</option>';
3457
+                                    $opt .= '<option value="'.$obj->rowid.'">'.$obj->ref.'</option>';
3458 3458
                                 }
3459 3459
                             }
3460 3460
                         }
@@ -3462,10 +3462,10 @@  discard block
 block discarded – undo
3462 3462
                 }
3463 3463
             }
3464 3464
         } else {
3465
-            dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR);
3465
+            dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR);
3466 3466
         }
3467 3467
         if ($opt == '<option value ="" selected></option>') {
3468
-            $opt = '<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>';
3468
+            $opt = '<option value ="0" selected>'.$langs->trans('NoSituations').'</option>';
3469 3469
         }
3470 3470
         return $opt;
3471 3471
     }
@@ -3484,9 +3484,9 @@  discard block
 block discarded – undo
3484 3484
 
3485 3485
         $langs->load('products');
3486 3486
 
3487
-        $return = '<select class="flat" id="' . $htmlname . '" name="' . $htmlname . '">';
3487
+        $return = '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
3488 3488
 
3489
-        $sql = 'SELECT rowid, label, code from ' . MAIN_DB_PREFIX . 'c_units';
3489
+        $sql = 'SELECT rowid, label, code from '.MAIN_DB_PREFIX.'c_units';
3490 3490
         $sql .= ' WHERE active > 0';
3491 3491
 
3492 3492
         $resql = $this->db->query($sql);
@@ -3496,14 +3496,14 @@  discard block
 block discarded – undo
3496 3496
 
3497 3497
             while ($res = $this->db->fetch_object($resql)) {
3498 3498
                 $unitLabel = $res->label;
3499
-                if (!empty($langs->tab_translate['unit' . $res->code])) { // check if Translation is available before
3500
-                    $unitLabel = $langs->trans('unit' . $res->code) != $res->label ? $langs->trans('unit' . $res->code) : $res->label;
3499
+                if (!empty($langs->tab_translate['unit'.$res->code])) { // check if Translation is available before
3500
+                    $unitLabel = $langs->trans('unit'.$res->code) != $res->label ? $langs->trans('unit'.$res->code) : $res->label;
3501 3501
                 }
3502 3502
 
3503 3503
                 if ($selected == $res->rowid) {
3504
-                    $return .= '<option value="' . $res->rowid . '" selected>' . $unitLabel . '</option>';
3504
+                    $return .= '<option value="'.$res->rowid.'" selected>'.$unitLabel.'</option>';
3505 3505
                 } else {
3506
-                    $return .= '<option value="' . $res->rowid . '">' . $unitLabel . '</option>';
3506
+                    $return .= '<option value="'.$res->rowid.'">'.$unitLabel.'</option>';
3507 3507
                 }
3508 3508
             }
3509 3509
             $return .= '</select>';
@@ -3533,21 +3533,21 @@  discard block
 block discarded – undo
3533 3533
         $num = 0;
3534 3534
 
3535 3535
         $sql = "SELECT rowid, label, bank, clos as status, currency_code";
3536
-        $sql .= " FROM " . MAIN_DB_PREFIX . "bank_account";
3537
-        $sql .= " WHERE entity IN (" . getEntity('bank_account') . ")";
3536
+        $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
3537
+        $sql .= " WHERE entity IN (".getEntity('bank_account').")";
3538 3538
         if ($statut != 2)
3539
-            $sql .= " AND clos = '" . $statut . "'";
3539
+            $sql .= " AND clos = '".$statut."'";
3540 3540
         if ($filtre)
3541
-            $sql .= " AND " . $filtre;
3541
+            $sql .= " AND ".$filtre;
3542 3542
         $sql .= " ORDER BY label";
3543 3543
 
3544
-        dol_syslog(get_class($this) . "::select_comptes", LOG_DEBUG);
3544
+        dol_syslog(get_class($this)."::select_comptes", LOG_DEBUG);
3545 3545
         $result = $this->db->query($sql);
3546 3546
         if ($result) {
3547 3547
             $num = $this->db->num_rows($result);
3548 3548
             $i = 0;
3549 3549
             if ($num) {
3550
-                print '<select id="select' . $htmlname . '" class="flat selectbankaccount" name="' . $htmlname . '"' . ($moreattrib ? ' ' . $moreattrib : '') . '>';
3550
+                print '<select id="select'.$htmlname.'" class="flat selectbankaccount" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
3551 3551
                 if ($useempty == 1 || ($useempty == 2 && $num > 1)) {
3552 3552
                     print '<option value="-1">&nbsp;</option>';
3553 3553
                 }
@@ -3555,15 +3555,15 @@  discard block
 block discarded – undo
3555 3555
                 while ($i < $num) {
3556 3556
                     $obj = $this->db->fetch_object($result);
3557 3557
                     if ($selected == $obj->rowid) {
3558
-                        print '<option value="' . $obj->rowid . '" selected>';
3558
+                        print '<option value="'.$obj->rowid.'" selected>';
3559 3559
                     } else {
3560
-                        print '<option value="' . $obj->rowid . '">';
3560
+                        print '<option value="'.$obj->rowid.'">';
3561 3561
                     }
3562 3562
                     print trim($obj->label);
3563 3563
                     if ($showcurrency)
3564
-                        print ' (' . $obj->currency_code . ')';
3564
+                        print ' ('.$obj->currency_code.')';
3565 3565
                     if ($statut == 2 && $obj->status == 1)
3566
-                        print ' (' . $langs->trans("Closed") . ')';
3566
+                        print ' ('.$langs->trans("Closed").')';
3567 3567
                     print '</option>';
3568 3568
                     $i++;
3569 3569
                 }
@@ -3571,9 +3571,9 @@  discard block
 block discarded – undo
3571 3571
             }
3572 3572
             else {
3573 3573
                 if ($statut == 0)
3574
-                    print '<span class="opacitymedium">' . $langs->trans("NoActiveBankAccountDefined") . '</span>';
3574
+                    print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
3575 3575
                 else
3576
-                    print '<span class="opacitymedium">' . $langs->trans("NoBankAccountFound") . '</span>';
3576
+                    print '<span class="opacitymedium">'.$langs->trans("NoBankAccountFound").'</span>';
3577 3577
             }
3578 3578
         }
3579 3579
         else {
@@ -3596,19 +3596,19 @@  discard block
 block discarded – undo
3596 3596
     {
3597 3597
         global $langs;
3598 3598
         if ($htmlname != "none") {
3599
-            print '<form method="POST" action="' . $page . '">';
3599
+            print '<form method="POST" action="'.$page.'">';
3600 3600
             print '<input type="hidden" name="action" value="setbankaccount">';
3601
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
3601
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
3602 3602
             $nbaccountfound = $this->select_comptes($selected, $htmlname, 0, '', $addempty);
3603 3603
             if ($nbaccountfound > 0)
3604
-                print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
3604
+                print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
3605 3605
             print '</form>';
3606 3606
         } else {
3607 3607
 
3608 3608
             $langs->load('banks');
3609 3609
 
3610 3610
             if ($selected) {
3611
-                require_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php';
3611
+                require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
3612 3612
                 $bankstatic = new Account($this->db);
3613 3613
                 $result = $bankstatic->fetch($selected);
3614 3614
                 if ($result)
@@ -3638,19 +3638,19 @@  discard block
 block discarded – undo
3638 3638
         global $conf, $langs;
3639 3639
         $langs->load("categories");
3640 3640
 
3641
-        include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
3641
+        include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
3642 3642
 
3643 3643
         // For backward compatibility
3644 3644
         if (is_numeric($type)) {
3645
-            dol_syslog(__METHOD__ . ': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
3645
+            dol_syslog(__METHOD__.': using numeric value for parameter type is deprecated. Use string code instead.', LOG_WARNING);
3646 3646
         }
3647 3647
 
3648 3648
         if ($type === Categorie::TYPE_BANK_LINE) {
3649 3649
             // TODO Move this into common category feature
3650 3650
             $categids = array();
3651 3651
             $sql = "SELECT c.label, c.rowid";
3652
-            $sql .= " FROM " . MAIN_DB_PREFIX . "bank_categ as c";
3653
-            $sql .= " WHERE entity = " . $conf->entity;
3652
+            $sql .= " FROM ".MAIN_DB_PREFIX."bank_categ as c";
3653
+            $sql .= " WHERE entity = ".$conf->entity;
3654 3654
             $sql .= " ORDER BY c.label";
3655 3655
             $result = $this->db->query($sql);
3656 3656
             if ($result) {
@@ -3671,11 +3671,11 @@  discard block
 block discarded – undo
3671 3671
             $cate_arbo = $cat->get_full_arbo($type, $excludeafterid);
3672 3672
         }
3673 3673
 
3674
-        $output = '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">';
3674
+        $output = '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
3675 3675
         $outarray = array();
3676 3676
         if (is_array($cate_arbo)) {
3677 3677
             if (!count($cate_arbo))
3678
-                $output .= '<option value="-1" disabled>' . $langs->trans("NoCategoriesDefined") . '</option>';
3678
+                $output .= '<option value="-1" disabled>'.$langs->trans("NoCategoriesDefined").'</option>';
3679 3679
             else {
3680 3680
                 $output .= '<option value="-1">&nbsp;</option>';
3681 3681
                 foreach ($cate_arbo as $key => $value) {
@@ -3684,7 +3684,7 @@  discard block
 block discarded – undo
3684 3684
                     } else {
3685 3685
                         $add = '';
3686 3686
                     }
3687
-                    $output .= '<option ' . $add . 'value="' . $cate_arbo[$key]['id'] . '">' . dol_trunc($cate_arbo[$key]['fulllabel'], $maxlength, 'middle') . '</option>';
3687
+                    $output .= '<option '.$add.'value="'.$cate_arbo[$key]['id'].'">'.dol_trunc($cate_arbo[$key]['fulllabel'], $maxlength, 'middle').'</option>';
3688 3688
 
3689 3689
                     $outarray[$cate_arbo[$key]['id']] = $cate_arbo[$key]['fulllabel'];
3690 3690
                 }
@@ -3718,7 +3718,7 @@  discard block
 block discarded – undo
3718 3718
     function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500)
3719 3719
     {
3720 3720
         // phpcs:enable
3721
-        dol_syslog(__METHOD__ . ': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
3721
+        dol_syslog(__METHOD__.': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING);
3722 3722
         print $this->formconfirm($page, $title, $question, $action, $formquestion, $selectedchoice, $useajax, $height, $width);
3723 3723
     }
3724 3724
 
@@ -3766,36 +3766,36 @@  discard block
 block discarded – undo
3766 3766
             foreach ($formquestion as $key => $input) {
3767 3767
                 if (is_array($input) && !empty($input)) {
3768 3768
                     if ($input['type'] == 'hidden') {
3769
-                        $more .= '<input type="hidden" id="' . $input['name'] . '" name="' . $input['name'] . '" value="' . dol_escape_htmltag($input['value']) . '">' . "\n";
3769
+                        $more .= '<input type="hidden" id="'.$input['name'].'" name="'.$input['name'].'" value="'.dol_escape_htmltag($input['value']).'">'."\n";
3770 3770
                     }
3771 3771
                 }
3772 3772
             }
3773 3773
 
3774 3774
             // Now add questions
3775
-            $more .= '<table class="paddingtopbottomonly" width="100%">' . "\n";
3775
+            $more .= '<table class="paddingtopbottomonly" width="100%">'."\n";
3776 3776
             if (!empty($formquestion['text']))
3777
-                $more .= '<tr><td colspan="2">' . $formquestion['text'] . '</td></tr>' . "\n";
3777
+                $more .= '<tr><td colspan="2">'.$formquestion['text'].'</td></tr>'."\n";
3778 3778
             foreach ($formquestion as $key => $input) {
3779 3779
                 if (is_array($input) && !empty($input)) {
3780
-                    $size = (!empty($input['size']) ? ' size="' . $input['size'] . '"' : '');
3781
-                    $moreattr = (!empty($input['moreattr']) ? ' ' . $input['moreattr'] : '');
3782
-                    $morecss = (!empty($input['morecss']) ? ' ' . $input['morecss'] : '');
3780
+                    $size = (!empty($input['size']) ? ' size="'.$input['size'].'"' : '');
3781
+                    $moreattr = (!empty($input['moreattr']) ? ' '.$input['moreattr'] : '');
3782
+                    $morecss = (!empty($input['morecss']) ? ' '.$input['morecss'] : '');
3783 3783
 
3784 3784
                     if ($input['type'] == 'text') {
3785
-                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td><td align="left"><input type="text" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $size . ' value="' . $input['value'] . '"' . $moreattr . ' /></td></tr>' . "\n";
3785
+                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td align="left"><input type="text" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
3786 3786
                     } elseif ($input['type'] == 'password') {
3787
-                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td><td align="left"><input type="password" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $size . ' value="' . $input['value'] . '"' . $moreattr . ' /></td></tr>' . "\n";
3787
+                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td><td align="left"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></td></tr>'."\n";
3788 3788
                     } elseif ($input['type'] == 'select') {
3789
-                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>';
3789
+                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>';
3790 3790
                         if (!empty($input['label']))
3791
-                            $more .= $input['label'] . '</td><td class="tdtop" align="left">';
3791
+                            $more .= $input['label'].'</td><td class="tdtop" align="left">';
3792 3792
                         $more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
3793
-                        $more .= '</td></tr>' . "\n";
3793
+                        $more .= '</td></tr>'."\n";
3794 3794
                     }
3795 3795
                     elseif ($input['type'] == 'checkbox') {
3796 3796
                         $more .= '<tr>';
3797
-                        $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . ' </td><td align="left">';
3798
-                        $more .= '<input type="checkbox" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '"' . $moreattr;
3797
+                        $more .= '<td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].' </td><td align="left">';
3798
+                        $more .= '<input type="checkbox" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$moreattr;
3799 3799
                         if (!is_bool($input['value']) && $input['value'] != 'false' && $input['value'] != '0')
3800 3800
                             $more .= ' checked';
3801 3801
                         if (is_bool($input['value']) && $input['value'])
@@ -3803,51 +3803,51 @@  discard block
 block discarded – undo
3803 3803
                         if (isset($input['disabled']))
3804 3804
                             $more .= ' disabled';
3805 3805
                         $more .= ' /></td>';
3806
-                        $more .= '</tr>' . "\n";
3806
+                        $more .= '</tr>'."\n";
3807 3807
                     }
3808 3808
                     elseif ($input['type'] == 'radio') {
3809 3809
                         $i = 0;
3810 3810
                         foreach ($input['values'] as $selkey => $selval) {
3811 3811
                             $more .= '<tr>';
3812 3812
                             if ($i == 0)
3813
-                                $more .= '<td' . (empty($input['tdclass']) ? ' class="tdtop"' : (' class="tdtop ' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>';
3813
+                                $more .= '<td'.(empty($input['tdclass']) ? ' class="tdtop"' : (' class="tdtop '.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
3814 3814
                             else
3815
-                                $more .= '<td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>&nbsp;</td>';
3816
-                            $more .= '<td><input type="radio" class="flat' . $morecss . '" id="' . $input['name'] . '" name="' . $input['name'] . '" value="' . $selkey . '"' . $moreattr;
3815
+                                $more .= '<td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>&nbsp;</td>';
3816
+                            $more .= '<td><input type="radio" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'" value="'.$selkey.'"'.$moreattr;
3817 3817
                             if ($input['disabled'])
3818 3818
                                 $more .= ' disabled';
3819 3819
                             $more .= ' /> ';
3820 3820
                             $more .= $selval;
3821
-                            $more .= '</td></tr>' . "\n";
3821
+                            $more .= '</td></tr>'."\n";
3822 3822
                             $i++;
3823 3823
                         }
3824 3824
                     }
3825 3825
                     elseif ($input['type'] == 'date') {
3826
-                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>' . $input['label'] . '</td>';
3826
+                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>'.$input['label'].'</td>';
3827 3827
                         $more .= '<td align="left">';
3828 3828
                         $more .= $this->selectDate($input['value'], $input['name'], 0, 0, 0, '', 1, 0);
3829
-                        $more .= '</td></tr>' . "\n";
3830
-                        $formquestion[] = array('name' => $input['name'] . 'day');
3831
-                        $formquestion[] = array('name' => $input['name'] . 'month');
3832
-                        $formquestion[] = array('name' => $input['name'] . 'year');
3833
-                        $formquestion[] = array('name' => $input['name'] . 'hour');
3834
-                        $formquestion[] = array('name' => $input['name'] . 'min');
3829
+                        $more .= '</td></tr>'."\n";
3830
+                        $formquestion[] = array('name' => $input['name'].'day');
3831
+                        $formquestion[] = array('name' => $input['name'].'month');
3832
+                        $formquestion[] = array('name' => $input['name'].'year');
3833
+                        $formquestion[] = array('name' => $input['name'].'hour');
3834
+                        $formquestion[] = array('name' => $input['name'].'min');
3835 3835
                     } elseif ($input['type'] == 'other') {
3836
-                        $more .= '<tr><td' . (empty($input['tdclass']) ? '' : (' class="' . $input['tdclass'] . '"')) . '>';
3836
+                        $more .= '<tr><td'.(empty($input['tdclass']) ? '' : (' class="'.$input['tdclass'].'"')).'>';
3837 3837
                         if (!empty($input['label']))
3838
-                            $more .= $input['label'] . '</td><td align="left">';
3838
+                            $more .= $input['label'].'</td><td align="left">';
3839 3839
                         $more .= $input['value'];
3840
-                        $more .= '</td></tr>' . "\n";
3840
+                        $more .= '</td></tr>'."\n";
3841 3841
                     }
3842 3842
 
3843 3843
                     elseif ($input['type'] == 'onecolumn') {
3844 3844
                         $more .= '<tr><td colspan="2" align="left">';
3845 3845
                         $more .= $input['value'];
3846
-                        $more .= '</td></tr>' . "\n";
3846
+                        $more .= '</td></tr>'."\n";
3847 3847
                     }
3848 3848
                 }
3849 3849
             }
3850
-            $more .= '</table>' . "\n";
3850
+            $more .= '</table>'."\n";
3851 3851
         }
3852 3852
 
3853 3853
         // JQUI method dialog is broken with jmobile, we use standard HTML.
@@ -3866,10 +3866,10 @@  discard block
 block discarded – undo
3866 3866
                 $button = $useajax;
3867 3867
                 $useajax = 1;
3868 3868
                 $autoOpen = false;
3869
-                $dialogconfirm .= '-' . $button;
3869
+                $dialogconfirm .= '-'.$button;
3870 3870
             }
3871
-            $pageyes = $page . (preg_match('/\?/', $page) ? '&' : '?') . 'action=' . $action . '&confirm=yes';
3872
-            $pageno = ($useajax == 2 ? $page . (preg_match('/\?/', $page) ? '&' : '?') . 'confirm=no' : '');
3871
+            $pageyes = $page.(preg_match('/\?/', $page) ? '&' : '?').'action='.$action.'&confirm=yes';
3872
+            $pageno = ($useajax == 2 ? $page.(preg_match('/\?/', $page) ? '&' : '?').'confirm=no' : '');
3873 3873
             // Add input fields into list of fields to read during submit (inputok and inputko)
3874 3874
             if (is_array($formquestion)) {
3875 3875
                 foreach ($formquestion as $key => $input) {
@@ -3881,20 +3881,20 @@  discard block
 block discarded – undo
3881 3881
                 }
3882 3882
             }
3883 3883
             // Show JQuery confirm box. Note that global var $useglobalvars is used inside this template
3884
-            $formconfirm .= '<div id="' . $dialogconfirm . '" title="' . dol_escape_htmltag($title) . '" style="display: none;">';
3884
+            $formconfirm .= '<div id="'.$dialogconfirm.'" title="'.dol_escape_htmltag($title).'" style="display: none;">';
3885 3885
             if (!empty($more)) {
3886
-                $formconfirm .= '<div class="confirmquestions">' . $more . '</div>';
3886
+                $formconfirm .= '<div class="confirmquestions">'.$more.'</div>';
3887 3887
             }
3888
-            $formconfirm .= ($question ? '<div class="confirmmessage">' . img_help('', '') . ' ' . $question . '</div>' : '');
3889
-            $formconfirm .= '</div>' . "\n";
3888
+            $formconfirm .= ($question ? '<div class="confirmmessage">'.img_help('', '').' '.$question.'</div>' : '');
3889
+            $formconfirm .= '</div>'."\n";
3890 3890
 
3891
-            $formconfirm .= "\n<!-- begin ajax formconfirm page=" . $page . " -->\n";
3892
-            $formconfirm .= '<script type="text/javascript">' . "\n";
3891
+            $formconfirm .= "\n<!-- begin ajax formconfirm page=".$page." -->\n";
3892
+            $formconfirm .= '<script type="text/javascript">'."\n";
3893 3893
             $formconfirm .= 'jQuery(document).ready(function() {
3894 3894
             $(function() {
3895
-            	$( "#' . $dialogconfirm . '" ).dialog(
3895
+            	$( "#' . $dialogconfirm.'" ).dialog(
3896 3896
             	{
3897
-                    autoOpen: ' . ($autoOpen ? "true" : "false") . ',';
3897
+                    autoOpen: ' . ($autoOpen ? "true" : "false").',';
3898 3898
             if ($newselectedchoice == 'no') {
3899 3899
                 $formconfirm .= '
3900 3900
 						open: function() {
@@ -3903,15 +3903,15 @@  discard block
 block discarded – undo
3903 3903
             }
3904 3904
             $formconfirm .= '
3905 3905
                     resizable: false,
3906
-                    height: "' . $height . '",
3907
-                    width: "' . $width . '",
3906
+                    height: "' . $height.'",
3907
+                    width: "' . $width.'",
3908 3908
                     modal: true,
3909 3909
                     closeOnEscape: false,
3910 3910
                     buttons: {
3911
-                        "' . dol_escape_js($langs->transnoentities("Yes")) . '": function() {
3911
+                        "' . dol_escape_js($langs->transnoentities("Yes")).'": function() {
3912 3912
                         	var options="";
3913
-                        	var inputok = ' . json_encode($inputok) . ';
3914
-                         	var pageyes = "' . dol_escape_js(!empty($pageyes) ? $pageyes : '') . '";
3913
+                        	var inputok = ' . json_encode($inputok).';
3914
+                         	var pageyes = "' . dol_escape_js(!empty($pageyes) ? $pageyes : '').'";
3915 3915
                          	if (inputok.length>0) {
3916 3916
                          		$.each(inputok, function(i, inputname) {
3917 3917
                          			var more = "";
@@ -3927,10 +3927,10 @@  discard block
 block discarded – undo
3927 3927
             				if (pageyes.length > 0) { location.href = urljump; }
3928 3928
                             $(this).dialog("close");
3929 3929
                         },
3930
-                        "' . dol_escape_js($langs->transnoentities("No")) . '": function() {
3930
+                        "' . dol_escape_js($langs->transnoentities("No")).'": function() {
3931 3931
                         	var options = "";
3932
-                         	var inputko = ' . json_encode($inputko) . ';
3933
-                         	var pageno="' . dol_escape_js(!empty($pageno) ? $pageno : '') . '";
3932
+                         	var inputko = ' . json_encode($inputko).';
3933
+                         	var pageno="' . dol_escape_js(!empty($pageno) ? $pageno : '').'";
3934 3934
                          	if (inputko.length>0) {
3935 3935
                          		$.each(inputko, function(i, inputname) {
3936 3936
                          			var more = "";
@@ -3949,10 +3949,10 @@  discard block
 block discarded – undo
3949 3949
                 }
3950 3950
                 );
3951 3951
 
3952
-            	var button = "' . $button . '";
3952
+            	var button = "' . $button.'";
3953 3953
             	if (button.length > 0) {
3954 3954
                 	$( "#" + button ).click(function() {
3955
-                		$("#' . $dialogconfirm . '").dialog("open");
3955
+                		$("#' . $dialogconfirm.'").dialog("open");
3956 3956
         			});
3957 3957
                 }
3958 3958
             });
@@ -3960,37 +3960,37 @@  discard block
 block discarded – undo
3960 3960
             </script>';
3961 3961
             $formconfirm .= "<!-- end ajax formconfirm -->\n";
3962 3962
         } else {
3963
-            $formconfirm .= "\n<!-- begin formconfirm page=" . $page . " -->\n";
3963
+            $formconfirm .= "\n<!-- begin formconfirm page=".$page." -->\n";
3964 3964
 
3965 3965
             if (empty($disableformtag))
3966
-                $formconfirm .= '<form method="POST" action="' . $page . '" class="notoptoleftroright">' . "\n";
3966
+                $formconfirm .= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";
3967 3967
 
3968
-            $formconfirm .= '<input type="hidden" name="action" value="' . $action . '">' . "\n";
3968
+            $formconfirm .= '<input type="hidden" name="action" value="'.$action.'">'."\n";
3969 3969
             if (empty($disableformtag))
3970
-                $formconfirm .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">' . "\n";
3970
+                $formconfirm .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
3971 3971
 
3972
-            $formconfirm .= '<table width="100%" class="valid">' . "\n";
3972
+            $formconfirm .= '<table width="100%" class="valid">'."\n";
3973 3973
 
3974 3974
             // Line title
3975
-            $formconfirm .= '<tr class="validtitre"><td class="validtitre" colspan="3">' . img_picto('', 'recent') . ' ' . $title . '</td></tr>' . "\n";
3975
+            $formconfirm .= '<tr class="validtitre"><td class="validtitre" colspan="3">'.img_picto('', 'recent').' '.$title.'</td></tr>'."\n";
3976 3976
 
3977 3977
             // Line form fields
3978 3978
             if ($more) {
3979
-                $formconfirm .= '<tr class="valid"><td class="valid" colspan="3">' . "\n";
3979
+                $formconfirm .= '<tr class="valid"><td class="valid" colspan="3">'."\n";
3980 3980
                 $formconfirm .= $more;
3981
-                $formconfirm .= '</td></tr>' . "\n";
3981
+                $formconfirm .= '</td></tr>'."\n";
3982 3982
             }
3983 3983
 
3984 3984
             // Line with question
3985 3985
             $formconfirm .= '<tr class="valid">';
3986
-            $formconfirm .= '<td class="valid">' . $question . '</td>';
3986
+            $formconfirm .= '<td class="valid">'.$question.'</td>';
3987 3987
             $formconfirm .= '<td class="valid">';
3988 3988
             $formconfirm .= $this->selectyesno("confirm", $newselectedchoice);
3989 3989
             $formconfirm .= '</td>';
3990
-            $formconfirm .= '<td class="valid" align="center"><input class="button valignmiddle" type="submit" value="' . $langs->trans("Validate") . '"></td>';
3991
-            $formconfirm .= '</tr>' . "\n";
3990
+            $formconfirm .= '<td class="valid" align="center"><input class="button valignmiddle" type="submit" value="'.$langs->trans("Validate").'"></td>';
3991
+            $formconfirm .= '</tr>'."\n";
3992 3992
 
3993
-            $formconfirm .= '</table>' . "\n";
3993
+            $formconfirm .= '</table>'."\n";
3994 3994
 
3995 3995
             if (empty($disableformtag))
3996 3996
                 $formconfirm .= "</form>\n";
@@ -4021,8 +4021,8 @@  discard block
 block discarded – undo
4021 4021
         // phpcs:enable
4022 4022
         global $langs;
4023 4023
 
4024
-        require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
4025
-        require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
4024
+        require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
4025
+        require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
4026 4026
 
4027 4027
         $out = '';
4028 4028
 
@@ -4031,11 +4031,11 @@  discard block
 block discarded – undo
4031 4031
         $langs->load("project");
4032 4032
         if ($htmlname != "none") {
4033 4033
             $out .= "\n";
4034
-            $out .= '<form method="post" action="' . $page . '">';
4034
+            $out .= '<form method="post" action="'.$page.'">';
4035 4035
             $out .= '<input type="hidden" name="action" value="classin">';
4036
-            $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4036
+            $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4037 4037
             $out .= $formproject->select_projects($socid, $selected, $htmlname, $maxlength, 0, 1, $discard_closed, $forcefocus, 0, 0, '', 1);
4038
-            $out .= '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
4038
+            $out .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
4039 4039
             $out .= '</form>';
4040 4040
         } else {
4041 4041
             if ($selected) {
@@ -4070,11 +4070,11 @@  discard block
 block discarded – undo
4070 4070
         // phpcs:enable
4071 4071
         global $langs;
4072 4072
         if ($htmlname != "none") {
4073
-            print '<form method="post" action="' . $page . '">';
4073
+            print '<form method="post" action="'.$page.'">';
4074 4074
             print '<input type="hidden" name="action" value="setconditions">';
4075
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4075
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4076 4076
             $this->select_conditions_paiements($selected, $htmlname, -1, $addempty);
4077
-            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
4077
+            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4078 4078
             print '</form>';
4079 4079
         } else {
4080 4080
             if ($selected) {
@@ -4101,11 +4101,11 @@  discard block
 block discarded – undo
4101 4101
         // phpcs:enable
4102 4102
         global $langs;
4103 4103
         if ($htmlname != "none") {
4104
-            print '<form method="post" action="' . $page . '">';
4104
+            print '<form method="post" action="'.$page.'">';
4105 4105
             print '<input type="hidden" name="action" value="setavailability">';
4106
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4106
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4107 4107
             $this->selectAvailabilityDelay($selected, $htmlname, -1, $addempty);
4108
-            print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
4108
+            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
4109 4109
             print '</form>';
4110 4110
         } else {
4111 4111
             if ($selected) {
@@ -4131,11 +4131,11 @@  discard block
 block discarded – undo
4131 4131
     {
4132 4132
         global $langs;
4133 4133
         if ($htmlname != "none") {
4134
-            print '<form method="post" action="' . $page . '">';
4134
+            print '<form method="post" action="'.$page.'">';
4135 4135
             print '<input type="hidden" name="action" value="setdemandreason">';
4136
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4136
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4137 4137
             $this->selectInputReason($selected, $htmlname, -1, $addempty);
4138
-            print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
4138
+            print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
4139 4139
             print '</form>';
4140 4140
         } else {
4141 4141
             if ($selected) {
@@ -4173,14 +4173,14 @@  discard block
 block discarded – undo
4173 4173
         $ret = '';
4174 4174
 
4175 4175
         if ($htmlname != "none") {
4176
-            $ret .= '<form method="post" action="' . $page . '" name="form' . $htmlname . '">';
4177
-            $ret .= '<input type="hidden" name="action" value="set' . $htmlname . '">';
4178
-            $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4176
+            $ret .= '<form method="post" action="'.$page.'" name="form'.$htmlname.'">';
4177
+            $ret .= '<input type="hidden" name="action" value="set'.$htmlname.'">';
4178
+            $ret .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4179 4179
             $ret .= '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
4180 4180
             $ret .= '<tr><td>';
4181
-            $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form' . $htmlname, 1, 0);
4181
+            $ret .= $this->selectDate($selected, $htmlname, $displayhour, $displaymin, 1, 'form'.$htmlname, 1, 0);
4182 4182
             $ret .= '</td>';
4183
-            $ret .= '<td align="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
4183
+            $ret .= '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
4184 4184
             $ret .= '</tr></table></form>';
4185 4185
         } else {
4186 4186
             if ($displayhour)
@@ -4211,15 +4211,15 @@  discard block
 block discarded – undo
4211 4211
         global $langs;
4212 4212
 
4213 4213
         if ($htmlname != "none") {
4214
-            print '<form method="POST" action="' . $page . '" name="form' . $htmlname . '">';
4215
-            print '<input type="hidden" name="action" value="set' . $htmlname . '">';
4216
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4214
+            print '<form method="POST" action="'.$page.'" name="form'.$htmlname.'">';
4215
+            print '<input type="hidden" name="action" value="set'.$htmlname.'">';
4216
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4217 4217
             print $this->select_dolusers($selected, $htmlname, 1, $exclude, 0, $include);
4218
-            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
4218
+            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4219 4219
             print '</form>';
4220 4220
         } else {
4221 4221
             if ($selected) {
4222
-                require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php';
4222
+                require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
4223 4223
                 $theuser = new User($this->db);
4224 4224
                 $theuser->fetch($selected);
4225 4225
                 print $theuser->getNomUrl(1);
@@ -4245,11 +4245,11 @@  discard block
 block discarded – undo
4245 4245
         // phpcs:enable
4246 4246
         global $langs;
4247 4247
         if ($htmlname != "none") {
4248
-            print '<form method="POST" action="' . $page . '">';
4248
+            print '<form method="POST" action="'.$page.'">';
4249 4249
             print '<input type="hidden" name="action" value="setmode">';
4250
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4250
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4251 4251
             $this->select_types_paiements($selected, $htmlname, $filtertype, 0, 0, 0, 0, $active);
4252
-            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
4252
+            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4253 4253
             print '</form>';
4254 4254
         } else {
4255 4255
             if ($selected) {
@@ -4275,11 +4275,11 @@  discard block
 block discarded – undo
4275 4275
         // phpcs:enable
4276 4276
         global $langs;
4277 4277
         if ($htmlname != "none") {
4278
-            print '<form method="POST" action="' . $page . '">';
4278
+            print '<form method="POST" action="'.$page.'">';
4279 4279
             print '<input type="hidden" name="action" value="setmulticurrencycode">';
4280
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4280
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4281 4281
             print $this->selectMultiCurrency($selected, $htmlname, 0);
4282
-            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
4282
+            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4283 4283
             print '</form>';
4284 4284
         } else {
4285 4285
             dol_include_once('/core/lib/company.lib.php');
@@ -4303,21 +4303,21 @@  discard block
 block discarded – undo
4303 4303
         global $langs, $mysoc, $conf;
4304 4304
 
4305 4305
         if ($htmlname != "none") {
4306
-            print '<form method="POST" action="' . $page . '">';
4306
+            print '<form method="POST" action="'.$page.'">';
4307 4307
             print '<input type="hidden" name="action" value="setmulticurrencyrate">';
4308
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4309
-            print '<input type="text" name="' . $htmlname . '" value="' . (!empty($rate) ? price($rate) : 1) . '" size="10" /> ';
4308
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4309
+            print '<input type="text" name="'.$htmlname.'" value="'.(!empty($rate) ? price($rate) : 1).'" size="10" /> ';
4310 4310
             print '<select name="calculation_mode">';
4311
-            print '<option value="1">' . $currency . ' > ' . $conf->currency . '</option>';
4312
-            print '<option value="2">' . $conf->currency . ' > ' . $currency . '</option>';
4311
+            print '<option value="1">'.$currency.' > '.$conf->currency.'</option>';
4312
+            print '<option value="2">'.$conf->currency.' > '.$currency.'</option>';
4313 4313
             print '</select> ';
4314
-            print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
4314
+            print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4315 4315
             print '</form>';
4316 4316
         } else {
4317 4317
             if (!empty($rate)) {
4318 4318
                 print price($rate, 1, $langs, 1, 0);
4319 4319
                 if ($currency && $rate != 1)
4320
-                    print ' &nbsp; (' . price($rate, 1, $langs, 1, 0) . ' ' . $currency . ' = 1 ' . $conf->currency . ')';
4320
+                    print ' &nbsp; ('.price($rate, 1, $langs, 1, 0).' '.$currency.' = 1 '.$conf->currency.')';
4321 4321
             }
4322 4322
             else {
4323 4323
                 print 1;
@@ -4346,14 +4346,14 @@  discard block
 block discarded – undo
4346 4346
         // phpcs:enable
4347 4347
         global $conf, $langs;
4348 4348
         if ($htmlname != "none") {
4349
-            print '<form method="post" action="' . $page . '">';
4349
+            print '<form method="post" action="'.$page.'">';
4350 4350
             print '<input type="hidden" name="action" value="setabsolutediscount">';
4351
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4351
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4352 4352
             print '<div class="inline-block">';
4353 4353
             if (!empty($discount_type)) {
4354 4354
                 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
4355 4355
                     if (!$filter || $filter == "fk_invoice_supplier_source IS NULL")
4356
-                        $translationKey = 'HasAbsoluteDiscountFromSupplier';    // If we want deposit to be substracted to payments only and not to total of final invoice
4356
+                        $translationKey = 'HasAbsoluteDiscountFromSupplier'; // If we want deposit to be substracted to payments only and not to total of final invoice
4357 4357
                     else
4358 4358
                         $translationKey = 'HasCreditNoteFromSupplier';
4359 4359
                 }
@@ -4366,7 +4366,7 @@  discard block
 block discarded – undo
4366 4366
             } else {
4367 4367
                 if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
4368 4368
                     if (!$filter || $filter == "fk_facture_source IS NULL")
4369
-                        $translationKey = 'CompanyHasAbsoluteDiscount';    // If we want deposit to be substracted to payments only and not to total of final invoice
4369
+                        $translationKey = 'CompanyHasAbsoluteDiscount'; // If we want deposit to be substracted to payments only and not to total of final invoice
4370 4370
                     else
4371 4371
                         $translationKey = 'CompanyHasCreditNote';
4372 4372
                 }
@@ -4383,21 +4383,21 @@  discard block
 block discarded – undo
4383 4383
             print '</div>';
4384 4384
             if (empty($hidelist)) {
4385 4385
                 print '<div class="inline-block" style="padding-right: 10px">';
4386
-                $newfilter = 'discount_type=' . intval($discount_type);
4386
+                $newfilter = 'discount_type='.intval($discount_type);
4387 4387
                 if (!empty($discount_type)) {
4388 4388
                     $newfilter .= ' AND fk_invoice_supplier IS NULL AND fk_invoice_supplier_line IS NULL'; // Supplier discounts available
4389 4389
                 } else {
4390 4390
                     $newfilter .= ' AND fk_facture IS NULL AND fk_facture_line IS NULL'; // Customer discounts available
4391 4391
                 }
4392 4392
                 if ($filter)
4393
-                    $newfilter .= ' AND (' . $filter . ')';
4393
+                    $newfilter .= ' AND ('.$filter.')';
4394 4394
                 $nbqualifiedlines = $this->select_remises($selected, $htmlname, $newfilter, $socid, $maxvalue);
4395 4395
                 if ($nbqualifiedlines > 0) {
4396
-                    print ' &nbsp; <input type="submit" class="button" value="' . dol_escape_htmltag($langs->trans("UseLine")) . '"';
4396
+                    print ' &nbsp; <input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("UseLine")).'"';
4397 4397
                     if (!empty($discount_type) && $filter && $filter != "fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')")
4398
-                        print ' title="' . $langs->trans("UseCreditNoteInInvoicePayment") . '"';
4398
+                        print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
4399 4399
                     if (empty($discount_type) && $filter && $filter != "fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')")
4400
-                        print ' title="' . $langs->trans("UseCreditNoteInInvoicePayment") . '"';
4400
+                        print ' title="'.$langs->trans("UseCreditNoteInInvoicePayment").'"';
4401 4401
 
4402 4402
                     print '>';
4403 4403
                 }
@@ -4434,22 +4434,22 @@  discard block
 block discarded – undo
4434 4434
         global $langs, $conf;
4435 4435
 
4436 4436
         if ($htmlname != "none") {
4437
-            print '<form method="post" action="' . $page . '">';
4437
+            print '<form method="post" action="'.$page.'">';
4438 4438
             print '<input type="hidden" name="action" value="set_contact">';
4439
-            print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4439
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4440 4440
             print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
4441 4441
             print '<tr><td>';
4442 4442
             $num = $this->select_contacts($societe->id, $selected, $htmlname);
4443 4443
             if ($num == 0) {
4444 4444
                 $addcontact = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress"));
4445
-                print '<a href="' . DOL_URL_ROOT . '/contact/card.php?socid=' . $societe->id . '&amp;action=create&amp;backtoreferer=1">' . $addcontact . '</a>';
4445
+                print '<a href="'.DOL_URL_ROOT.'/contact/card.php?socid='.$societe->id.'&amp;action=create&amp;backtoreferer=1">'.$addcontact.'</a>';
4446 4446
             }
4447 4447
             print '</td>';
4448
-            print '<td align="left"><input type="submit" class="button" value="' . $langs->trans("Modify") . '"></td>';
4448
+            print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
4449 4449
             print '</tr></table></form>';
4450 4450
         } else {
4451 4451
             if ($selected) {
4452
-                require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
4452
+                require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
4453 4453
                 $contact = new Contact($this->db);
4454 4454
                 $contact->fetch($selected);
4455 4455
                 print $contact->getFullName($langs);
@@ -4481,15 +4481,15 @@  discard block
 block discarded – undo
4481 4481
 
4482 4482
         $out = '';
4483 4483
         if ($htmlname != "none") {
4484
-            $out .= '<form method="post" action="' . $page . '">';
4484
+            $out .= '<form method="post" action="'.$page.'">';
4485 4485
             $out .= '<input type="hidden" name="action" value="set_thirdparty">';
4486
-            $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
4486
+            $out .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
4487 4487
             $out .= $this->select_company($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events);
4488
-            $out .= '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '">';
4488
+            $out .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
4489 4489
             $out .= '</form>';
4490 4490
         } else {
4491 4491
             if ($selected) {
4492
-                require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
4492
+                require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
4493 4493
                 $soc = new Societe($this->db);
4494 4494
                 $soc->fetch($selected);
4495 4495
                 $out .= $soc->getNomUrl($langs);
@@ -4535,17 +4535,17 @@  discard block
 block discarded – undo
4535 4535
         $out = '';
4536 4536
 
4537 4537
         if ($selected == 'euro' || $selected == 'euros')
4538
-            $selected = 'EUR';   // Pour compatibilite
4538
+            $selected = 'EUR'; // Pour compatibilite
4539 4539
 
4540
-        $out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="' . $htmlname . '" id="' . $htmlname . '">';
4540
+        $out .= '<select class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'" id="'.$htmlname.'">';
4541 4541
         foreach ($langs->cache_currencies as $code_iso => $currency) {
4542 4542
             if ($selected && $selected == $code_iso) {
4543
-                $out .= '<option value="' . $code_iso . '" selected>';
4543
+                $out .= '<option value="'.$code_iso.'" selected>';
4544 4544
             } else {
4545
-                $out .= '<option value="' . $code_iso . '">';
4545
+                $out .= '<option value="'.$code_iso.'">';
4546 4546
             }
4547 4547
             $out .= $currency['label'];
4548
-            $out .= ' (' . $langs->getCurrencySymbol($code_iso) . ')';
4548
+            $out .= ' ('.$langs->getCurrencySymbol($code_iso).')';
4549 4549
             $out .= '</option>';
4550 4550
         }
4551 4551
         $out .= '</select>';
@@ -4553,7 +4553,7 @@  discard block
 block discarded – undo
4553 4553
             $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
4554 4554
 
4555 4555
         // Make select dynamic
4556
-        include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
4556
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
4557 4557
         $out .= ajax_combobox($htmlname);
4558 4558
 
4559 4559
         return $out;
@@ -4571,12 +4571,12 @@  discard block
 block discarded – undo
4571 4571
     {
4572 4572
         global $db, $conf, $langs, $user;
4573 4573
 
4574
-        $langs->loadCacheCurrencies('');        // Load ->cache_currencies
4574
+        $langs->loadCacheCurrencies(''); // Load ->cache_currencies
4575 4575
 
4576 4576
         $TCurrency = array();
4577 4577
 
4578
-        $sql = 'SELECT code FROM ' . MAIN_DB_PREFIX . 'multicurrency';
4579
-        $sql .= " WHERE entity IN ('" . getEntity('mutlicurrency') . "')";
4578
+        $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'multicurrency';
4579
+        $sql .= " WHERE entity IN ('".getEntity('mutlicurrency')."')";
4580 4580
         $resql = $db->query($sql);
4581 4581
         if ($resql) {
4582 4582
             while ($obj = $db->fetch_object($resql))
@@ -4584,7 +4584,7 @@  discard block
 block discarded – undo
4584 4584
         }
4585 4585
 
4586 4586
         $out = '';
4587
-        $out .= '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">';
4587
+        $out .= '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
4588 4588
         if ($useempty)
4589 4589
             $out .= '<option value=""></option>';
4590 4590
         // If company current currency not in table, we add it into list. Should always be available.
@@ -4595,12 +4595,12 @@  discard block
 block discarded – undo
4595 4595
             foreach ($langs->cache_currencies as $code_iso => $currency) {
4596 4596
                 if (isset($TCurrency[$code_iso])) {
4597 4597
                     if (!empty($selected) && $selected == $code_iso)
4598
-                        $out .= '<option value="' . $code_iso . '" selected="selected">';
4598
+                        $out .= '<option value="'.$code_iso.'" selected="selected">';
4599 4599
                     else
4600
-                        $out .= '<option value="' . $code_iso . '">';
4600
+                        $out .= '<option value="'.$code_iso.'">';
4601 4601
 
4602 4602
                     $out .= $currency['label'];
4603
-                    $out .= ' (' . $langs->getCurrencySymbol($code_iso) . ')';
4603
+                    $out .= ' ('.$langs->getCurrencySymbol($code_iso).')';
4604 4604
                     $out .= '</option>';
4605 4605
                 }
4606 4606
             }
@@ -4608,7 +4608,7 @@  discard block
 block discarded – undo
4608 4608
 
4609 4609
         $out .= '</select>';
4610 4610
         // Make select dynamic
4611
-        include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
4611
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
4612 4612
         $out .= ajax_combobox($htmlname);
4613 4613
 
4614 4614
         return $out;
@@ -4628,15 +4628,15 @@  discard block
 block discarded – undo
4628 4628
 
4629 4629
         $num = count($this->cache_vatrates);
4630 4630
         if ($num > 0)
4631
-            return $num;    // Cache already loaded
4631
+            return $num; // Cache already loaded
4632 4632
 
4633 4633
         dol_syslog(__METHOD__, LOG_DEBUG);
4634 4634
 
4635 4635
         $sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.recuperableonly";
4636
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4636
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4637 4637
         $sql .= " WHERE t.fk_pays = c.rowid";
4638 4638
         $sql .= " AND t.active > 0";
4639
-        $sql .= " AND c.code IN (" . $country_code . ")";
4639
+        $sql .= " AND c.code IN (".$country_code.")";
4640 4640
         $sql .= " ORDER BY t.code ASC, t.taux ASC, t.recuperableonly ASC";
4641 4641
 
4642 4642
         $resql = $this->db->query($sql);
@@ -4654,28 +4654,28 @@  discard block
 block discarded – undo
4654 4654
                     $this->cache_vatrates[$i]['localtax2'] = $obj->localtax2;
4655 4655
                     $this->cache_vatrates[$i]['localtax2_type'] = $obj->localtax1_type;
4656 4656
 
4657
-                    $this->cache_vatrates[$i]['label'] = $obj->taux . '%' . ($obj->code ? ' (' . $obj->code . ')' : '');   // Label must contains only 0-9 , . % or *
4658
-                    $this->cache_vatrates[$i]['labelallrates'] = $obj->taux . '/' . ($obj->localtax1 ? $obj->localtax1 : '0') . '/' . ($obj->localtax2 ? $obj->localtax2 : '0') . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label
4657
+                    $this->cache_vatrates[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or *
4658
+                    $this->cache_vatrates[$i]['labelallrates'] = $obj->taux.'/'.($obj->localtax1 ? $obj->localtax1 : '0').'/'.($obj->localtax2 ? $obj->localtax2 : '0').($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label
4659 4659
                     $positiverates = '';
4660 4660
                     if ($obj->taux)
4661
-                        $positiverates .= ($positiverates ? '/' : '') . $obj->taux;
4661
+                        $positiverates .= ($positiverates ? '/' : '').$obj->taux;
4662 4662
                     if ($obj->localtax1)
4663
-                        $positiverates .= ($positiverates ? '/' : '') . $obj->localtax1;
4663
+                        $positiverates .= ($positiverates ? '/' : '').$obj->localtax1;
4664 4664
                     if ($obj->localtax2)
4665
-                        $positiverates .= ($positiverates ? '/' : '') . $obj->localtax2;
4665
+                        $positiverates .= ($positiverates ? '/' : '').$obj->localtax2;
4666 4666
                     if (empty($positiverates))
4667 4667
                         $positiverates = '0';
4668
-                    $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates . ($obj->code ? ' (' . $obj->code . ')' : ''); // Must never be used as key, only label
4668
+                    $this->cache_vatrates[$i]['labelpositiverates'] = $positiverates.($obj->code ? ' ('.$obj->code.')' : ''); // Must never be used as key, only label
4669 4669
                 }
4670 4670
 
4671 4671
                 return $num;
4672 4672
             }
4673 4673
             else {
4674
-                $this->error = '<font class="error">' . $langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code) . '</font>';
4674
+                $this->error = '<font class="error">'.$langs->trans("ErrorNoVATRateDefinedForSellerCountry", $country_code).'</font>';
4675 4675
                 return -1;
4676 4676
             }
4677 4677
         } else {
4678
-            $this->error = '<font class="error">' . $this->db->error() . '</font>';
4678
+            $this->error = '<font class="error">'.$this->db->error().'</font>';
4679 4679
             return -2;
4680 4680
         }
4681 4681
     }
@@ -4724,9 +4724,9 @@  discard block
 block discarded – undo
4724 4724
         // Check parameters
4725 4725
         if (is_object($societe_vendeuse) && !$societe_vendeuse->country_code) {
4726 4726
             if ($societe_vendeuse->id == $mysoc->id) {
4727
-                $return .= '<font class="error">' . $langs->trans("ErrorYourCountryIsNotDefined") . '</div>';
4727
+                $return .= '<font class="error">'.$langs->trans("ErrorYourCountryIsNotDefined").'</div>';
4728 4728
             } else {
4729
-                $return .= '<font class="error">' . $langs->trans("ErrorSupplierCountryIsNotDefined") . '</div>';
4729
+                $return .= '<font class="error">'.$langs->trans("ErrorSupplierCountryIsNotDefined").'</div>';
4730 4730
             }
4731 4731
             return $return;
4732 4732
         }
@@ -4737,32 +4737,32 @@  discard block
 block discarded – undo
4737 4737
         // Define list of countries to use to search VAT rates to show
4738 4738
         // First we defined code_country to use to find list
4739 4739
         if (is_object($societe_vendeuse)) {
4740
-            $code_country = "'" . $societe_vendeuse->country_code . "'";
4740
+            $code_country = "'".$societe_vendeuse->country_code."'";
4741 4741
         } else {
4742
-            $code_country = "'" . $mysoc->country_code . "'";   // Pour compatibilite ascendente
4742
+            $code_country = "'".$mysoc->country_code."'"; // Pour compatibilite ascendente
4743 4743
         }
4744 4744
         if (!empty($conf->global->SERVICE_ARE_ECOMMERCE_200238EC)) {    // If option to have vat for end customer for services is on
4745
-            require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
4745
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
4746 4746
             if (!isInEEC($societe_vendeuse) && (!is_object($societe_acheteuse) || (isInEEC($societe_acheteuse) && !$societe_acheteuse->isACompany()))) {
4747 4747
                 // We also add the buyer
4748 4748
                 if (is_numeric($type)) {
4749 4749
                     if ($type == 1) { // We know product is a service
4750
-                        $code_country .= ",'" . $societe_acheteuse->country_code . "'";
4750
+                        $code_country .= ",'".$societe_acheteuse->country_code."'";
4751 4751
                     }
4752 4752
                 } else if (!$idprod) {  // We don't know type of product
4753
-                    $code_country .= ",'" . $societe_acheteuse->country_code . "'";
4753
+                    $code_country .= ",'".$societe_acheteuse->country_code."'";
4754 4754
                 } else {
4755 4755
                     $prodstatic = new Product($this->db);
4756 4756
                     $prodstatic->fetch($idprod);
4757 4757
                     if ($prodstatic->type == Product::TYPE_SERVICE) {   // We know product is a service
4758
-                        $code_country .= ",'" . $societe_acheteuse->country_code . "'";
4758
+                        $code_country .= ",'".$societe_acheteuse->country_code."'";
4759 4759
                     }
4760 4760
                 }
4761 4761
             }
4762 4762
         }
4763 4763
 
4764 4764
         // Now we get list
4765
-        $num = $this->load_cache_vatrates($code_country);   // If no vat defined, return -1 with message into this->error
4765
+        $num = $this->load_cache_vatrates($code_country); // If no vat defined, return -1 with message into this->error
4766 4766
 
4767 4767
         if ($num > 0) {
4768 4768
             // Definition du taux a pre-selectionner (si defaulttx non force et donc vaut -1 ou '')
@@ -4795,13 +4795,13 @@  discard block
 block discarded – undo
4795 4795
             if (is_object($societe_vendeuse) && $societe_vendeuse->id == $mysoc->id && $societe_vendeuse->tva_assuj == "0") {
4796 4796
                 // Override/enable VAT for expense report regardless of global setting - needed if expense report used for business expenses
4797 4797
                 if (empty($conf->global->OVERRIDE_VAT_FOR_EXPENSE_REPORT)) {
4798
-                    $title = ' title="' . $langs->trans('VATIsNotUsed') . '"';
4798
+                    $title = ' title="'.$langs->trans('VATIsNotUsed').'"';
4799 4799
                     $disabled = true;
4800 4800
                 }
4801 4801
             }
4802 4802
 
4803 4803
             if (!$options_only) {
4804
-                $return .= '<select class="flat minwidth75imp" id="' . $htmlname . '" name="' . $htmlname . '"' . ($disabled ? ' disabled' : '') . $title . '>';
4804
+                $return .= '<select class="flat minwidth75imp" id="'.$htmlname.'" name="'.$htmlname.'"'.($disabled ? ' disabled' : '').$title.'>';
4805 4805
             }
4806 4806
 
4807 4807
             $selectedfound = false;
@@ -4814,11 +4814,11 @@  discard block
 block discarded – undo
4814 4814
                 $key = $rate['txtva'];
4815 4815
                 $key .= $rate['nprtva'] ? '*' : '';
4816 4816
                 if ($mode > 0 && $rate['code'])
4817
-                    $key .= ' (' . $rate['code'] . ')';
4817
+                    $key .= ' ('.$rate['code'].')';
4818 4818
                 if ($mode < 0)
4819 4819
                     $key = $rate['rowid'];
4820 4820
 
4821
-                $return .= '<option value="' . $key . '"';
4821
+                $return .= '<option value="'.$key.'"';
4822 4822
                 if (!$selectedfound) {
4823 4823
                     if ($defaultcode) { // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag
4824 4824
                         if ($defaultcode == $rate['code']) {
@@ -4838,7 +4838,7 @@  discard block
 block discarded – undo
4838 4838
                     $return .= vatrate($rate['label']);
4839 4839
                 }
4840 4840
                 //$return.=($rate['code']?' '.$rate['code']:'');
4841
-                $return .= (empty($rate['code']) && $rate['nprtva']) ? ' *' : '';         // We show the *  (old behaviour only if new vat code is not used)
4841
+                $return .= (empty($rate['code']) && $rate['nprtva']) ? ' *' : ''; // We show the *  (old behaviour only if new vat code is not used)
4842 4842
 
4843 4843
                 $return .= '</option>';
4844 4844
             }
@@ -4937,7 +4937,7 @@  discard block
 block discarded – undo
4937 4937
         $orig_set_time = $set_time;
4938 4938
 
4939 4939
         if ($set_time === '' && $emptydate == 0) {
4940
-            include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
4940
+            include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
4941 4941
             $set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone
4942 4942
         }
4943 4943
 
@@ -4990,36 +4990,36 @@  discard block
 block discarded – undo
4990 4990
                 //print "e".$set_time." t ".$conf->format_date_short;
4991 4991
                 if (strval($set_time) != '' && $set_time != -1) {
4992 4992
                     //$formated_date=dol_print_date($set_time,$conf->format_date_short);
4993
-                    $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput"));  // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
4993
+                    $formated_date = dol_print_date($set_time, $langs->trans("FormatDateShortInput")); // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
4994 4994
                 }
4995 4995
 
4996 4996
                 // Calendrier popup version eldy
4997 4997
                 if ($usecalendar == "eldy") {
4998 4998
                     // Zone de saisie manuelle de la date
4999
-                    $retstring .= '<input id="' . $prefix . '" name="' . $prefix . '" type="text" class="maxwidth75" maxlength="11" value="' . $formated_date . '"';
4999
+                    $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidth75" maxlength="11" value="'.$formated_date.'"';
5000 5000
                     $retstring .= ($disabled ? ' disabled' : '');
5001
-                    $retstring .= ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\'); "';  // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
5001
+                    $retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
5002 5002
                     $retstring .= '>';
5003 5003
 
5004 5004
                     // Icone calendrier
5005 5005
                     if (!$disabled) {
5006
-                        $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons"';
5007
-                        $base = DOL_URL_ROOT . '/core/';
5008
-                        $retstring .= ' onClick="showDP(\'' . $base . '\',\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\',\'' . $langs->defaultlang . '\');"';
5009
-                        $retstring .= '>' . img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"') . '</button>';
5006
+                        $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons"';
5007
+                        $base = DOL_URL_ROOT.'/core/';
5008
+                        $retstring .= ' onClick="showDP(\''.$base.'\',\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\',\''.$langs->defaultlang.'\');"';
5009
+                        $retstring .= '>'.img_object($langs->trans("SelectDate"), 'calendarday', 'class="datecallink"').'</button>';
5010 5010
                     } else
5011
-                        $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons">' . img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"') . '</button>';
5011
+                        $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>';
5012 5012
 
5013
-                    $retstring .= '<input type="hidden" id="' . $prefix . 'day"   name="' . $prefix . 'day"   value="' . $sday . '">' . "\n";
5014
-                    $retstring .= '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . "\n";
5015
-                    $retstring .= '<input type="hidden" id="' . $prefix . 'year"  name="' . $prefix . 'year"  value="' . $syear . '">' . "\n";
5013
+                    $retstring .= '<input type="hidden" id="'.$prefix.'day"   name="'.$prefix.'day"   value="'.$sday.'">'."\n";
5014
+                    $retstring .= '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
5015
+                    $retstring .= '<input type="hidden" id="'.$prefix.'year"  name="'.$prefix.'year"  value="'.$syear.'">'."\n";
5016 5016
                 }
5017 5017
                 elseif ($usecalendar == 'jquery') {
5018 5018
                     if (!$disabled) {
5019 5019
                         // Output javascript for datepicker
5020 5020
                         $retstring .= "<script type='text/javascript'>";
5021
-                        $retstring .= "$(function(){ $('#" . $prefix . "').datepicker({
5022
-							dateFormat: '" . $langs->trans("FormatDateShortJQueryInput") . "',
5021
+                        $retstring .= "$(function(){ $('#".$prefix."').datepicker({
5022
+							dateFormat: '" . $langs->trans("FormatDateShortJQueryInput")."',
5023 5023
 							autoclose: true,
5024 5024
 							todayHighlight: true,";
5025 5025
                         if (!empty($conf->dol_use_jmobile)) {
@@ -5042,7 +5042,7 @@  discard block
 block discarded – undo
5042 5042
                              */
5043 5043
                             $retstring .= "
5044 5044
 								showOn: 'button',
5045
-								buttonImage: '" . DOL_BASE_URI . "/theme/" . $conf->theme . "/img/object_calendarday.png',
5045
+								buttonImage: '" . DOL_BASE_URI."/theme/".$conf->theme."/img/object_calendarday.png',
5046 5046
 								buttonImageOnly: true";
5047 5047
                         }
5048 5048
                         $retstring .= "
@@ -5052,9 +5052,9 @@  discard block
 block discarded – undo
5052 5052
 
5053 5053
                     // Zone de saisie manuelle de la date
5054 5054
                     $retstring .= '<div class="nowrap inline-block">';
5055
-                    $retstring .= '<input id="' . $prefix . '" name="' . $prefix . '" type="text" class="maxwidth75" maxlength="11" value="' . $formated_date . '"';
5055
+                    $retstring .= '<input id="'.$prefix.'" name="'.$prefix.'" type="text" class="maxwidth75" maxlength="11" value="'.$formated_date.'"';
5056 5056
                     $retstring .= ($disabled ? ' disabled' : '');
5057
-                    $retstring .= ' onChange="dpChangeDay(\'' . $prefix . '\',\'' . $langs->trans("FormatDateShortJavaInput") . '\'); "';  // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
5057
+                    $retstring .= ' onChange="dpChangeDay(\''.$prefix.'\',\''.$langs->trans("FormatDateShortJavaInput").'\'); "'; // FormatDateShortInput for dol_print_date / FormatDateShortJavaInput that is same for javascript
5058 5058
                     $retstring .= '>';
5059 5059
 
5060 5060
                     // Icone calendrier
@@ -5069,13 +5069,13 @@  discard block
 block discarded – undo
5069 5069
                           $retstring.='});';
5070 5070
                           $retstring.="</script>"; */
5071 5071
                     } else {
5072
-                        $retstring .= '<button id="' . $prefix . 'Button" type="button" class="dpInvisibleButtons">' . img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"') . '</button>';
5072
+                        $retstring .= '<button id="'.$prefix.'Button" type="button" class="dpInvisibleButtons">'.img_object($langs->trans("Disabled"), 'calendarday', 'class="datecallink"').'</button>';
5073 5073
                     }
5074 5074
 
5075 5075
                     $retstring .= '</div>';
5076
-                    $retstring .= '<input type="hidden" id="' . $prefix . 'day"   name="' . $prefix . 'day"   value="' . $sday . '">' . "\n";
5077
-                    $retstring .= '<input type="hidden" id="' . $prefix . 'month" name="' . $prefix . 'month" value="' . $smonth . '">' . "\n";
5078
-                    $retstring .= '<input type="hidden" id="' . $prefix . 'year"  name="' . $prefix . 'year"  value="' . $syear . '">' . "\n";
5076
+                    $retstring .= '<input type="hidden" id="'.$prefix.'day"   name="'.$prefix.'day"   value="'.$sday.'">'."\n";
5077
+                    $retstring .= '<input type="hidden" id="'.$prefix.'month" name="'.$prefix.'month" value="'.$smonth.'">'."\n";
5078
+                    $retstring .= '<input type="hidden" id="'.$prefix.'year"  name="'.$prefix.'year"  value="'.$syear.'">'."\n";
5079 5079
                 } else {
5080 5080
                     $retstring .= "Bad value of MAIN_POPUP_CALENDAR";
5081 5081
                 }
@@ -5084,26 +5084,26 @@  discard block
 block discarded – undo
5084 5084
             else {
5085 5085
                 //$retstring.='<div class="inline-block">';
5086 5086
                 // Day
5087
-                $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50imp" id="' . $prefix . 'day" name="' . $prefix . 'day">';
5087
+                $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50imp" id="'.$prefix.'day" name="'.$prefix.'day">';
5088 5088
 
5089 5089
                 if ($emptydate || $set_time == -1) {
5090 5090
                     $retstring .= '<option value="0" selected>&nbsp;</option>';
5091 5091
                 }
5092 5092
 
5093 5093
                 for ($day = 1; $day <= 31; $day++) {
5094
-                    $retstring .= '<option value="' . $day . '"' . ($day == $sday ? ' selected' : '') . '>' . $day . '</option>';
5094
+                    $retstring .= '<option value="'.$day.'"'.($day == $sday ? ' selected' : '').'>'.$day.'</option>';
5095 5095
                 }
5096 5096
 
5097 5097
                 $retstring .= "</select>";
5098 5098
 
5099
-                $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp" id="' . $prefix . 'month" name="' . $prefix . 'month">';
5099
+                $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'month" name="'.$prefix.'month">';
5100 5100
                 if ($emptydate || $set_time == -1) {
5101 5101
                     $retstring .= '<option value="0" selected>&nbsp;</option>';
5102 5102
                 }
5103 5103
 
5104 5104
                 // Month
5105 5105
                 for ($month = 1; $month <= 12; $month++) {
5106
-                    $retstring .= '<option value="' . $month . '"' . ($month == $smonth ? ' selected' : '') . '>';
5106
+                    $retstring .= '<option value="'.$month.'"'.($month == $smonth ? ' selected' : '').'>';
5107 5107
                     $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b");
5108 5108
                     $retstring .= "</option>";
5109 5109
                 }
@@ -5111,12 +5111,12 @@  discard block
 block discarded – undo
5111 5111
 
5112 5112
                 // Year
5113 5113
                 if ($emptydate || $set_time == -1) {
5114
-                    $retstring .= '<input' . ($disabled ? ' disabled' : '') . ' placeholder="' . dol_escape_htmltag($langs->trans("Year")) . '" class="flat maxwidth50imp valignmiddle" type="number" min="0" max="3000" maxlength="4" id="' . $prefix . 'year" name="' . $prefix . 'year" value="' . $syear . '">';
5114
+                    $retstring .= '<input'.($disabled ? ' disabled' : '').' placeholder="'.dol_escape_htmltag($langs->trans("Year")).'" class="flat maxwidth50imp valignmiddle" type="number" min="0" max="3000" maxlength="4" id="'.$prefix.'year" name="'.$prefix.'year" value="'.$syear.'">';
5115 5115
                 } else {
5116
-                    $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth75imp" id="' . $prefix . 'year" name="' . $prefix . 'year">';
5116
+                    $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth75imp" id="'.$prefix.'year" name="'.$prefix.'year">';
5117 5117
 
5118 5118
                     for ($year = $syear - 10; $year < $syear + 10; $year++) {
5119
-                        $retstring .= '<option value="' . $year . '"' . ($year == $syear ? ' selected' : '') . '>' . $year . '</option>';
5119
+                        $retstring .= '<option value="'.$year.'"'.($year == $syear ? ' selected' : '').'>'.$year.'</option>';
5120 5120
                     }
5121 5121
                     $retstring .= "</select>\n";
5122 5122
                 }
@@ -5129,13 +5129,13 @@  discard block
 block discarded – undo
5129 5129
 
5130 5130
         if ($h) {
5131 5131
             // Show hour
5132
-            $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'hour' : '') . '" id="' . $prefix . 'hour" name="' . $prefix . 'hour">';
5132
+            $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'hour' : '').'" id="'.$prefix.'hour" name="'.$prefix.'hour">';
5133 5133
             if ($emptyhours)
5134 5134
                 $retstring .= '<option value="-1">&nbsp;</option>';
5135 5135
             for ($hour = 0; $hour < 24; $hour++) {
5136 5136
                 if (strlen($hour) < 2)
5137
-                    $hour = "0" . $hour;
5138
-                $retstring .= '<option value="' . $hour . '"' . (($hour == $shour) ? ' selected' : '') . '>' . $hour . (empty($conf->dol_optimize_smallscreen) ? '' : 'H') . '</option>';
5137
+                    $hour = "0".$hour;
5138
+                $retstring .= '<option value="'.$hour.'"'.(($hour == $shour) ? ' selected' : '').'>'.$hour.(empty($conf->dol_optimize_smallscreen) ? '' : 'H').'</option>';
5139 5139
             }
5140 5140
             $retstring .= '</select>';
5141 5141
             if ($m && empty($conf->dol_optimize_smallscreen))
@@ -5144,17 +5144,17 @@  discard block
 block discarded – undo
5144 5144
 
5145 5145
         if ($m) {
5146 5146
             // Show minutes
5147
-            $retstring .= '<select' . ($disabled ? ' disabled' : '') . ' class="flat valignmiddle maxwidth50 ' . ($fullday ? $fullday . 'min' : '') . '" id="' . $prefix . 'min" name="' . $prefix . 'min">';
5147
+            $retstring .= '<select'.($disabled ? ' disabled' : '').' class="flat valignmiddle maxwidth50 '.($fullday ? $fullday.'min' : '').'" id="'.$prefix.'min" name="'.$prefix.'min">';
5148 5148
             if ($emptyhours)
5149 5149
                 $retstring .= '<option value="-1">&nbsp;</option>';
5150 5150
             for ($min = 0; $min < 60; $min++) {
5151 5151
                 if (strlen($min) < 2)
5152
-                    $min = "0" . $min;
5153
-                $retstring .= '<option value="' . $min . '"' . (($min == $smin) ? ' selected' : '') . '>' . $min . (empty($conf->dol_optimize_smallscreen) ? '' : '') . '</option>';
5152
+                    $min = "0".$min;
5153
+                $retstring .= '<option value="'.$min.'"'.(($min == $smin) ? ' selected' : '').'>'.$min.(empty($conf->dol_optimize_smallscreen) ? '' : '').'</option>';
5154 5154
             }
5155 5155
             $retstring .= '</select>';
5156 5156
 
5157
-            $retstring .= '<input type="hidden" name="' . $prefix . 'sec" value="' . $ssec . '">';
5157
+            $retstring .= '<input type="hidden" name="'.$prefix.'sec" value="'.$ssec.'">';
5158 5158
         }
5159 5159
 
5160 5160
         // Add a "Now" link
@@ -5163,10 +5163,10 @@  discard block
 block discarded – undo
5163 5163
             $reset_scripts = "";
5164 5164
 
5165 5165
             // Generate the date part, depending on the use or not of the javascript calendar
5166
-            $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date(dol_now(), 'day') . '\');';
5167
-            $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date(dol_now(), '%d') . '\');';
5168
-            $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date(dol_now(), '%m') . '\');';
5169
-            $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date(dol_now(), '%Y') . '\');';
5166
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');';
5167
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');';
5168
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');';
5169
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');';
5170 5170
             /* if ($usecalendar == "eldy")
5171 5171
               {
5172 5172
               $base=DOL_URL_ROOT.'/core/';
@@ -5183,7 +5183,7 @@  discard block
 block discarded – undo
5183 5183
                 if ($fullday)
5184 5184
                     $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
5185 5185
                 //$reset_scripts .= 'this.form.elements[\''.$prefix.'hour\'].value=formatDate(new Date(), \'HH\'); ';
5186
-                $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date(dol_now(), '%H') . '\');';
5186
+                $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');';
5187 5187
                 if ($fullday)
5188 5188
                     $reset_scripts .= ' } ';
5189 5189
             }
@@ -5192,13 +5192,13 @@  discard block
 block discarded – undo
5192 5192
                 if ($fullday)
5193 5193
                     $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
5194 5194
                 //$reset_scripts .= 'this.form.elements[\''.$prefix.'min\'].value=formatDate(new Date(), \'mm\'); ';
5195
-                $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date(dol_now(), '%M') . '\');';
5195
+                $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');';
5196 5196
                 if ($fullday)
5197 5197
                     $reset_scripts .= ' } ';
5198 5198
             }
5199 5199
             // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
5200 5200
             if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
5201
-                $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="' . $prefix . 'ButtonNow" type="button" name="_useless" value="now" onClick="' . $reset_scripts . '">';
5201
+                $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="'.$prefix.'ButtonNow" type="button" name="_useless" value="now" onClick="'.$reset_scripts.'">';
5202 5202
                 $retstring .= $langs->trans("Now");
5203 5203
                 $retstring .= '</button> ';
5204 5204
             }
@@ -5210,15 +5210,15 @@  discard block
 block discarded – undo
5210 5210
             $reset_scripts = "";
5211 5211
 
5212 5212
             // Generate the date part, depending on the use or not of the javascript calendar
5213
-            $reset_scripts .= 'jQuery(\'#' . $prefix . '\').val(\'' . dol_print_date(dol_now(), 'day') . '\');';
5214
-            $reset_scripts .= 'jQuery(\'#' . $prefix . 'day\').val(\'' . dol_print_date(dol_now(), '%d') . '\');';
5215
-            $reset_scripts .= 'jQuery(\'#' . $prefix . 'month\').val(\'' . dol_print_date(dol_now(), '%m') . '\');';
5216
-            $reset_scripts .= 'jQuery(\'#' . $prefix . 'year\').val(\'' . dol_print_date(dol_now(), '%Y') . '\');';
5213
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'\').val(\''.dol_print_date(dol_now(), 'day').'\');';
5214
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'day\').val(\''.dol_print_date(dol_now(), '%d').'\');';
5215
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'month\').val(\''.dol_print_date(dol_now(), '%m').'\');';
5216
+            $reset_scripts .= 'jQuery(\'#'.$prefix.'year\').val(\''.dol_print_date(dol_now(), '%Y').'\');';
5217 5217
             // Update the hour part
5218 5218
             if ($h) {
5219 5219
                 if ($fullday)
5220 5220
                     $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
5221
-                $reset_scripts .= 'jQuery(\'#' . $prefix . 'hour\').val(\'' . dol_print_date(dol_now(), '%H') . '\');';
5221
+                $reset_scripts .= 'jQuery(\'#'.$prefix.'hour\').val(\''.dol_print_date(dol_now(), '%H').'\');';
5222 5222
                 if ($fullday)
5223 5223
                     $reset_scripts .= ' } ';
5224 5224
             }
@@ -5226,13 +5226,13 @@  discard block
 block discarded – undo
5226 5226
             if ($m) {
5227 5227
                 if ($fullday)
5228 5228
                     $reset_scripts .= " if (jQuery('#fullday:checked').val() == null) {";
5229
-                $reset_scripts .= 'jQuery(\'#' . $prefix . 'min\').val(\'' . dol_print_date(dol_now(), '%M') . '\');';
5229
+                $reset_scripts .= 'jQuery(\'#'.$prefix.'min\').val(\''.dol_print_date(dol_now(), '%M').'\');';
5230 5230
                 if ($fullday)
5231 5231
                     $reset_scripts .= ' } ';
5232 5232
             }
5233 5233
             // If reset_scripts is not empty, print the link with the reset_scripts in the onClick
5234 5234
             if ($reset_scripts && empty($conf->dol_optimize_smallscreen)) {
5235
-                $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="' . $prefix . 'ButtonPlusOne" type="button" name="_useless2" value="plusone" onClick="' . $reset_scripts . '">';
5235
+                $retstring .= ' <button class="dpInvisibleButtons datenowlink" id="'.$prefix.'ButtonPlusOne" type="button" name="_useless2" value="plusone" onClick="'.$reset_scripts.'">';
5236 5236
                 $retstring .= $langs->trans("DateStartPlusOne");
5237 5237
                 $retstring .= '</button> ';
5238 5238
             }
@@ -5241,7 +5241,7 @@  discard block
 block discarded – undo
5241 5241
         // Add a "Plus one hour" link
5242 5242
         if ($conf->use_javascript_ajax && $adddateof) {
5243 5243
             $tmparray = dol_getdate($adddateof);
5244
-            $retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\'' . dol_print_date($adddateof, 'day') . '\');jQuery(\'#reday\').val(\'' . $tmparray['mday'] . '\');jQuery(\'#remonth\').val(\'' . $tmparray['mon'] . '\');jQuery(\'#reyear\').val(\'' . $tmparray['year'] . '\');">' . $langs->trans("DateInvoice") . '</a>';
5244
+            $retstring .= ' - <button class="dpInvisibleButtons datenowlink" id="dateofinvoice" type="button" name="_dateofinvoice" value="now" onclick="jQuery(\'#re\').val(\''.dol_print_date($adddateof, 'day').'\');jQuery(\'#reday\').val(\''.$tmparray['mday'].'\');jQuery(\'#remonth\').val(\''.$tmparray['mon'].'\');jQuery(\'#reyear\').val(\''.$tmparray['year'].'\');">'.$langs->trans("DateInvoice").'</a>';
5245 5245
         }
5246 5246
 
5247 5247
         return $retstring;
@@ -5273,29 +5273,29 @@  discard block
 block discarded – undo
5273 5273
 
5274 5274
         // Hours
5275 5275
         if ($iSecond != '') {
5276
-            require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
5276
+            require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
5277 5277
 
5278 5278
             $hourSelected = convertSecondToTime($iSecond, 'allhour');
5279 5279
             $minSelected = convertSecondToTime($iSecond, 'min');
5280 5280
         }
5281 5281
 
5282 5282
         if ($typehour == 'select') {
5283
-            $retstring .= '<select class="flat" id="select_' . $prefix . 'hour" name="' . $prefix . 'hour"' . ($disabled ? ' disabled' : '') . '>';
5283
+            $retstring .= '<select class="flat" id="select_'.$prefix.'hour" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').'>';
5284 5284
             for ($hour = 0; $hour < 25; $hour++) { // For a duration, we allow 24 hours
5285
-                $retstring .= '<option value="' . $hour . '"';
5285
+                $retstring .= '<option value="'.$hour.'"';
5286 5286
                 if ($hourSelected == $hour) {
5287 5287
                     $retstring .= " selected";
5288 5288
                 }
5289
-                $retstring .= ">" . $hour . "</option>";
5289
+                $retstring .= ">".$hour."</option>";
5290 5290
             }
5291 5291
             $retstring .= "</select>";
5292 5292
         } elseif ($typehour == 'text' || $typehour == 'textselect') {
5293
-            $retstring .= '<input placeholder="' . $langs->trans('HourShort') . '" type="number" min="0" size="1" name="' . $prefix . 'hour"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputhour" value="' . (($hourSelected != '') ? ((int) $hourSelected) : '') . '">';
5293
+            $retstring .= '<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '') ? ((int) $hourSelected) : '').'">';
5294 5294
         } else
5295 5295
             return 'BadValueForParameterTypeHour';
5296 5296
 
5297 5297
         if ($typehour != 'text')
5298
-            $retstring .= ' ' . $langs->trans('HourShort');
5298
+            $retstring .= ' '.$langs->trans('HourShort');
5299 5299
         else
5300 5300
             $retstring .= '<span class="hideonsmartphone">:</span>';
5301 5301
 
@@ -5306,21 +5306,21 @@  discard block
 block discarded – undo
5306 5306
             $retstring .= '<span class="hideonsmartphone">&nbsp;</span>';
5307 5307
 
5308 5308
         if ($typehour == 'select' || $typehour == 'textselect') {
5309
-            $retstring .= '<select class="flat" id="select_' . $prefix . 'min" name="' . $prefix . 'min"' . ($disabled ? ' disabled' : '') . '>';
5309
+            $retstring .= '<select class="flat" id="select_'.$prefix.'min" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').'>';
5310 5310
             for ($min = 0; $min <= 55; $min = $min + 5) {
5311
-                $retstring .= '<option value="' . $min . '"';
5311
+                $retstring .= '<option value="'.$min.'"';
5312 5312
                 if ($minSelected == $min)
5313 5313
                     $retstring .= ' selected';
5314
-                $retstring .= '>' . $min . '</option>';
5314
+                $retstring .= '>'.$min.'</option>';
5315 5315
             }
5316 5316
             $retstring .= "</select>";
5317 5317
         }
5318 5318
         elseif ($typehour == 'text') {
5319
-            $retstring .= '<input placeholder="' . $langs->trans('MinuteShort') . '" type="number" min="0" size="1" name="' . $prefix . 'min"' . ($disabled ? ' disabled' : '') . ' class="flat maxwidth50 inputminute" value="' . (($minSelected != '') ? ((int) $minSelected) : '') . '">';
5319
+            $retstring .= '<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">';
5320 5320
         }
5321 5321
 
5322 5322
         if ($typehour != 'text')
5323
-            $retstring .= ' ' . $langs->trans('MinuteShort');
5323
+            $retstring .= ' '.$langs->trans('MinuteShort');
5324 5324
 
5325 5325
         //$retstring.="&nbsp;";
5326 5326
 
@@ -5363,30 +5363,30 @@  discard block
 block discarded – undo
5363 5363
             }
5364 5364
         }
5365 5365
         if (!is_object($objecttmp)) {
5366
-            dol_syslog('Error bad setup of type for field ' . $InfoFieldList, LOG_WARNING);
5367
-            return 'Error bad setup of type for field ' . join(',', $InfoFieldList);
5366
+            dol_syslog('Error bad setup of type for field '.$InfoFieldList, LOG_WARNING);
5367
+            return 'Error bad setup of type for field '.join(',', $InfoFieldList);
5368 5368
         }
5369 5369
 
5370 5370
         $prefixforautocompletemode = $objecttmp->element;
5371 5371
         if ($prefixforautocompletemode == 'societe')
5372 5372
             $prefixforautocompletemode = 'company';
5373
-        $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
5373
+        $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
5374 5374
 
5375
-        dol_syslog(get_class($this) . "::selectForForms", LOG_DEBUG);
5375
+        dol_syslog(get_class($this)."::selectForForms", LOG_DEBUG);
5376 5376
 
5377 5377
         $out = '';
5378 5378
         if (!empty($conf->use_javascript_ajax) && !empty($conf->global->$confkeyforautocompletemode) && !$forcecombo) {
5379
-            $objectdesc = $classname . ':' . $classpath;
5380
-            $urlforajaxcall = DOL_URL_ROOT . '/core/ajax/selectobject.php';
5379
+            $objectdesc = $classname.':'.$classpath;
5380
+            $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php';
5381 5381
             //if ($objecttmp->element == 'societe') $urlforajaxcall = DOL_URL_ROOT.'/societe/ajax/company.php';
5382 5382
             // No immediate load of all database
5383
-            $urloption = 'htmlname=' . $htmlname . '&outjson=1&objectdesc=' . $objectdesc . ($moreparams ? $moreparams : '');
5383
+            $urloption = 'htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.($moreparams ? $moreparams : '');
5384 5384
             // Activate the auto complete using ajax call.
5385 5385
             $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
5386 5386
             $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';
5387 5387
             if ($placeholder)
5388
-                $placeholder = ' placeholder="' . $placeholder . '"';
5389
-            $out .= '<input type="text" class="' . $morecss . '" name="search_' . $htmlname . '" id="search_' . $htmlname . '" value="' . $preselectedvalue . '"' . $placeholder . ' />';
5388
+                $placeholder = ' placeholder="'.$placeholder.'"';
5389
+            $out .= '<input type="text" class="'.$morecss.'" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$preselectedvalue.'"'.$placeholder.' />';
5390 5390
         }
5391 5391
         else {
5392 5392
             // Immediate load of all database
@@ -5420,14 +5420,14 @@  discard block
 block discarded – undo
5420 5420
         $prefixforautocompletemode = $objecttmp->element;
5421 5421
         if ($prefixforautocompletemode == 'societe')
5422 5422
             $prefixforautocompletemode = 'company';
5423
-        $confkeyforautocompletemode = strtoupper($prefixforautocompletemode) . '_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
5423
+        $confkeyforautocompletemode = strtoupper($prefixforautocompletemode).'_USE_SEARCH_TO_SELECT'; // For example COMPANY_USE_SEARCH_TO_SELECT
5424 5424
 
5425 5425
         $fieldstoshow = 't.ref';
5426 5426
         if (!empty($objecttmp->fields)) { // For object that declare it, it is better to use declared fields ( like societe, contact, ...)
5427 5427
             $tmpfieldstoshow = '';
5428 5428
             foreach ($objecttmp->fields as $key => $val) {
5429 5429
                 if ($val['showoncombobox'])
5430
-                    $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '') . 't.' . $key;
5430
+                    $tmpfieldstoshow .= ($tmpfieldstoshow ? ',' : '').'t.'.$key;
5431 5431
             }
5432 5432
             if ($tmpfieldstoshow)
5433 5433
                 $fieldstoshow = $tmpfieldstoshow;
@@ -5439,36 +5439,36 @@  discard block
 block discarded – undo
5439 5439
         $num = 0;
5440 5440
 
5441 5441
         // Search data
5442
-        $sql = "SELECT t.rowid, " . $fieldstoshow . " FROM " . MAIN_DB_PREFIX . $objecttmp->table_element . " as t";
5442
+        $sql = "SELECT t.rowid, ".$fieldstoshow." FROM ".MAIN_DB_PREFIX.$objecttmp->table_element." as t";
5443 5443
         if ($objecttmp->ismultientitymanaged == 2)
5444 5444
             if (!$user->rights->societe->client->voir && !$user->societe_id)
5445
-                $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
5445
+                $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
5446 5446
         $sql .= " WHERE 1=1";
5447 5447
         if (!empty($objecttmp->ismultientitymanaged))
5448
-            $sql .= " AND t.entity IN (" . getEntity($objecttmp->table_element) . ")";
5448
+            $sql .= " AND t.entity IN (".getEntity($objecttmp->table_element).")";
5449 5449
         if ($objecttmp->ismultientitymanaged == 1 && !empty($user->societe_id)) {
5450 5450
             if ($objecttmp->element == 'societe')
5451
-                $sql .= " AND t.rowid = " . $user->societe_id;
5451
+                $sql .= " AND t.rowid = ".$user->societe_id;
5452 5452
             else
5453
-                $sql .= " AND t.fk_soc = " . $user->societe_id;
5453
+                $sql .= " AND t.fk_soc = ".$user->societe_id;
5454 5454
         }
5455 5455
         if ($searchkey != '')
5456 5456
             $sql .= natural_search(explode(',', $fieldstoshow), $searchkey);
5457 5457
         if ($objecttmp->ismultientitymanaged == 2)
5458 5458
             if (!$user->rights->societe->client->voir && !$user->societe_id)
5459
-                $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = " . $user->id;
5459
+                $sql .= " AND t.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
5460 5460
         $sql .= $this->db->order($fieldstoshow, "ASC");
5461 5461
         //$sql.=$this->db->plimit($limit, 0);
5462 5462
         // Build output string
5463 5463
         $resql = $this->db->query($sql);
5464 5464
         if ($resql) {
5465 5465
             if (!$forcecombo) {
5466
-                include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
5466
+                include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
5467 5467
                 $out .= ajax_combobox($htmlname, null, $conf->global->$confkeyforautocompletemode);
5468 5468
             }
5469 5469
 
5470 5470
             // Construct $out and $outarray
5471
-            $out .= '<select id="' . $htmlname . '" class="flat' . ($morecss ? ' ' . $morecss : '') . '"' . ($moreparams ? ' ' . $moreparams : '') . ' name="' . $htmlname . '">' . "\n";
5471
+            $out .= '<select id="'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'"'.($moreparams ? ' '.$moreparams : '').' name="'.$htmlname.'">'."\n";
5472 5472
 
5473 5473
             // Warning: Do not use textifempty = ' ' or '&nbsp;' here, or search on key will search on ' key'. Seems it is no more true with selec2 v4
5474 5474
             $textifempty = '&nbsp;';
@@ -5481,7 +5481,7 @@  discard block
 block discarded – undo
5481 5481
                     $textifempty .= $langs->trans("All");
5482 5482
             }
5483 5483
             if ($showempty)
5484
-                $out .= '<option value="-1">' . $textifempty . '</option>' . "\n";
5484
+                $out .= '<option value="-1">'.$textifempty.'</option>'."\n";
5485 5485
 
5486 5486
             $num = $this->db->num_rows($resql);
5487 5487
             $i = 0;
@@ -5492,13 +5492,13 @@  discard block
 block discarded – undo
5492 5492
                     $tmparray = explode(',', $fieldstoshow);
5493 5493
                     foreach ($tmparray as $key => $val) {
5494 5494
                         $val = preg_replace('/t\./', '', $val);
5495
-                        $label .= (($label && $obj->$val) ? ' - ' : '') . $obj->$val;
5495
+                        $label .= (($label && $obj->$val) ? ' - ' : '').$obj->$val;
5496 5496
                     }
5497 5497
                     if (empty($outputmode)) {
5498 5498
                         if ($preselectedvalue > 0 && $preselectedvalue == $obj->rowid) {
5499
-                            $out .= '<option value="' . $obj->rowid . '" selected>' . $label . '</option>';
5499
+                            $out .= '<option value="'.$obj->rowid.'" selected>'.$label.'</option>';
5500 5500
                         } else {
5501
-                            $out .= '<option value="' . $obj->rowid . '">' . $label . '</option>';
5501
+                            $out .= '<option value="'.$obj->rowid.'">'.$label.'</option>';
5502 5502
                         }
5503 5503
                     } else {
5504 5504
                         array_push($outarray, array('key' => $obj->rowid, 'value' => $label, 'label' => $label));
@@ -5510,7 +5510,7 @@  discard block
 block discarded – undo
5510 5510
                 }
5511 5511
             }
5512 5512
 
5513
-            $out .= '</select>' . "\n";
5513
+            $out .= '</select>'."\n";
5514 5514
         }
5515 5515
         else {
5516 5516
             dol_print_error($this->db);
@@ -5566,12 +5566,12 @@  discard block
 block discarded – undo
5566 5566
             $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? (constant('REQUIRE_JQUERY_MULTISELECT') ? constant('REQUIRE_JQUERY_MULTISELECT') : 'select2') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
5567 5567
 
5568 5568
             // Enhance with select2
5569
-            include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
5569
+            include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
5570 5570
             $out .= ajax_combobox($htmlname);
5571 5571
         }
5572 5572
 
5573
-        $out .= '<select id="' . preg_replace('/^\./', '', $htmlname) . '" ' . ($disabled ? 'disabled ' : '') . 'class="flat ' . (preg_replace('/^\./', '', $htmlname)) . ($morecss ? ' ' . $morecss : '') . '"';
5574
-        $out .= ' name="' . preg_replace('/^\./', '', $htmlname) . '" ' . ($moreparam ? $moreparam : '');
5573
+        $out .= '<select id="'.preg_replace('/^\./', '', $htmlname).'" '.($disabled ? 'disabled ' : '').'class="flat '.(preg_replace('/^\./', '', $htmlname)).($morecss ? ' '.$morecss : '').'"';
5574
+        $out .= ' name="'.preg_replace('/^\./', '', $htmlname).'" '.($moreparam ? $moreparam : '');
5575 5575
         $out .= '>';
5576 5576
 
5577 5577
         if ($show_empty) {
@@ -5580,7 +5580,7 @@  discard block
 block discarded – undo
5580 5580
                 $textforempty = '&nbsp;'; // If we use ajaxcombo, we need &nbsp; here to avoid to have an empty element that is too small.
5581 5581
             if (!is_numeric($show_empty))
5582 5582
                 $textforempty = $show_empty;
5583
-            $out .= '<option class="optiongrey" ' . ($moreparamonempty ? $moreparamonempty . ' ' : '') . 'value="' . ($show_empty < 0 ? $show_empty : -1) . '"' . ($id == $show_empty ? ' selected' : '') . '>' . $textforempty . '</option>' . "\n";
5583
+            $out .= '<option class="optiongrey" '.($moreparamonempty ? $moreparamonempty.' ' : '').'value="'.($show_empty < 0 ? $show_empty : -1).'"'.($id == $show_empty ? ' selected' : '').'>'.$textforempty.'</option>'."\n";
5584 5584
         }
5585 5585
 
5586 5586
         if (is_array($array)) {
@@ -5610,9 +5610,9 @@  discard block
 block discarded – undo
5610 5610
 
5611 5611
                 if ($key_in_label) {
5612 5612
                     if (empty($nohtmlescape))
5613
-                        $selectOptionValue = dol_escape_htmltag($key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value));
5613
+                        $selectOptionValue = dol_escape_htmltag($key.' - '.($maxlen ? dol_trunc($value, $maxlen) : $value));
5614 5614
                     else
5615
-                        $selectOptionValue = $key . ' - ' . ($maxlen ? dol_trunc($value, $maxlen) : $value);
5615
+                        $selectOptionValue = $key.' - '.($maxlen ? dol_trunc($value, $maxlen) : $value);
5616 5616
                 }
5617 5617
                 else {
5618 5618
                     if (empty($nohtmlescape))
@@ -5623,12 +5623,12 @@  discard block
 block discarded – undo
5623 5623
                         $selectOptionValue = '&nbsp;';
5624 5624
                 }
5625 5625
 
5626
-                $out .= '<option value="' . $key . '"';
5627
-                $out .= $style . $disabled;
5626
+                $out .= '<option value="'.$key.'"';
5627
+                $out .= $style.$disabled;
5628 5628
                 if ($id != '' && $id == $key && !$disabled)
5629
-                    $out .= ' selected';  // To preselect a value
5629
+                    $out .= ' selected'; // To preselect a value
5630 5630
                 if ($nohtmlescape)
5631
-                    $out .= ' data-html="' . dol_escape_htmltag($selectOptionValue) . '"';
5631
+                    $out .= ' data-html="'.dol_escape_htmltag($selectOptionValue).'"';
5632 5632
                 $out .= '>';
5633 5633
                 //var_dump($selectOptionValue);
5634 5634
                 $out .= $selectOptionValue;
@@ -5667,19 +5667,19 @@  discard block
 block discarded – undo
5667 5667
         if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT'))
5668 5668
             return '';
5669 5669
 
5670
-        $out = '<select type="text" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"></select>';
5670
+        $out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"></select>';
5671 5671
 
5672 5672
         $tmpplugin = 'select2';
5673
-        $outdelayed = "\n" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' -->
5673
+        $outdelayed = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
5674 5674
 	    	<script type="text/javascript">
5675 5675
 	    	$(document).ready(function () {
5676 5676
 
5677
-    	        ' . ($callurlonselect ? 'var saveRemoteData = [];' : '') . '
5677
+    	        ' . ($callurlonselect ? 'var saveRemoteData = [];' : '').'
5678 5678
 
5679
-                $(".' . $htmlname . '").select2({
5679
+                $(".' . $htmlname.'").select2({
5680 5680
 			    	ajax: {
5681 5681
 				    	dir: "ltr",
5682
-				    	url: "' . $url . '",
5682
+				    	url: "' . $url.'",
5683 5683
 				    	dataType: \'json\',
5684 5684
 				    	delay: 250,
5685 5685
 				    	data: function (params) {
@@ -5706,9 +5706,9 @@  discard block
 block discarded – undo
5706 5706
 			    	},
5707 5707
 	 				language: select2arrayoflanguage,
5708 5708
 					containerCssClass: \':all:\',					/* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
5709
-				    placeholder: "' . dol_escape_js($placeholder) . '",
5709
+				    placeholder: "' . dol_escape_js($placeholder).'",
5710 5710
 			    	escapeMarkup: function (markup) { return markup; }, 	// let our custom formatter work
5711
-			    	minimumInputLength: ' . $minimumInputLength . ',
5711
+			    	minimumInputLength: ' . $minimumInputLength.',
5712 5712
 			        formatResult: function(result, container, query, escapeMarkup) {
5713 5713
                         return escapeMarkup(result.text);
5714 5714
                     },
@@ -5716,10 +5716,10 @@  discard block
 block discarded – undo
5716 5716
 
5717 5717
                 ' . ($callurlonselect ? '
5718 5718
                 /* Code to execute a GET when we select a value */
5719
-                $(".' . $htmlname . '").change(function() {
5720
-			    	var selected = $(".' . $htmlname . '").val();
5719
+                $(".' . $htmlname.'").change(function() {
5720
+			    	var selected = $(".' . $htmlname.'").val();
5721 5721
                 	console.log("We select in selectArrayAjax the entry "+selected)
5722
-			        $(".' . $htmlname . '").val("");  /* reset visible combo value */
5722
+			        $(".' . $htmlname.'").val("");  /* reset visible combo value */
5723 5723
     			    $.each( saveRemoteData, function( key, value ) {
5724 5724
     				        if (key == selected)
5725 5725
     			            {
@@ -5727,7 +5727,7 @@  discard block
 block discarded – undo
5727 5727
     			                 location.assign(value.url);
5728 5728
     			            }
5729 5729
                     });
5730
-    			});' : '' ) . '
5730
+    			});' : '').'
5731 5731
 
5732 5732
     	   });
5733 5733
 	       </script>';
@@ -5767,7 +5767,7 @@  discard block
 block discarded – undo
5767 5767
         if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && !defined('REQUIRE_JQUERY_MULTISELECT'))
5768 5768
             return '';
5769 5769
 
5770
-        $out = '<select type="text" class="' . $htmlname . ($morecss ? ' ' . $morecss : '') . '" ' . ($moreparam ? $moreparam . ' ' : '') . 'name="' . $htmlname . '"><option></option></select>';
5770
+        $out = '<select type="text" class="'.$htmlname.($morecss ? ' '.$morecss : '').'" '.($moreparam ? $moreparam.' ' : '').'name="'.$htmlname.'"><option></option></select>';
5771 5771
 
5772 5772
         $formattedarrayresult = array();
5773 5773
 
@@ -5780,20 +5780,20 @@  discard block
 block discarded – undo
5780 5780
         }
5781 5781
 
5782 5782
         $tmpplugin = 'select2';
5783
-        $outdelayed = "\n" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' -->
5783
+        $outdelayed = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
5784 5784
 			<script type="text/javascript">
5785 5785
 			$(document).ready(function () {
5786
-				var data = ' . json_encode($formattedarrayresult) . ';
5786
+				var data = ' . json_encode($formattedarrayresult).';
5787 5787
 
5788
-				' . ($callurlonselect ? 'var saveRemoteData = ' . json_encode($array) . ';' : '') . '
5788
+				' . ($callurlonselect ? 'var saveRemoteData = '.json_encode($array).';' : '').'
5789 5789
 
5790
-				$(".' . $htmlname . '").select2({
5790
+				$(".' . $htmlname.'").select2({
5791 5791
 					data: data,
5792 5792
 					language: select2arrayoflanguage,
5793 5793
 					containerCssClass: \':all:\',					/* Line to add class of origin SELECT propagated to the new <span class="select2-selection...> tag */
5794
-					placeholder: "' . dol_escape_js($placeholder) . '",
5794
+					placeholder: "' . dol_escape_js($placeholder).'",
5795 5795
 					escapeMarkup: function (markup) { return markup; }, 	// let our custom formatter work
5796
-					minimumInputLength: ' . $minimumInputLength . ',
5796
+					minimumInputLength: ' . $minimumInputLength.',
5797 5797
 					formatResult: function(result, container, query, escapeMarkup) {
5798 5798
 						return escapeMarkup(result.text);
5799 5799
 					},
@@ -5831,11 +5831,11 @@  discard block
 block discarded – undo
5831 5831
 
5832 5832
 				' . ($callurlonselect ? '
5833 5833
 				/* Code to execute a GET when we select a value */
5834
-				$(".' . $htmlname . '").change(function() {
5835
-					var selected = $(".' . $htmlname . '").val();
5834
+				$(".' . $htmlname.'").change(function() {
5835
+					var selected = $(".' . $htmlname.'").val();
5836 5836
 					console.log("We select "+selected)
5837 5837
 
5838
-					$(".' . $htmlname . '").val("");  /* reset visible combo value */
5838
+					$(".' . $htmlname.'").val("");  /* reset visible combo value */
5839 5839
 					$.each( saveRemoteData, function( key, value ) {
5840 5840
 						if (key == selected)
5841 5841
 						{
@@ -5843,7 +5843,7 @@  discard block
 block discarded – undo
5843 5843
 							location.assign(value.url);
5844 5844
 						}
5845 5845
 					});
5846
-				});' : '' ) . '
5846
+				});' : '').'
5847 5847
 
5848 5848
 			});
5849 5849
 			</script>';
@@ -5883,28 +5883,28 @@  discard block
 block discarded – undo
5883 5883
 
5884 5884
         // Add code for jquery to use multiselect
5885 5885
         if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) {
5886
-            $out .= "\n" . '<!-- JS CODE TO ENABLE ' . $tmpplugin . ' for id ' . $htmlname . ' -->
5886
+            $out .= "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id '.$htmlname.' -->
5887 5887
 						<script type="text/javascript">' . "\n";
5888 5888
             if ($addjscombo == 1) {
5889 5889
                 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
5890
-                $out .= 'function formatResult(record) {' . "\n";
5890
+                $out .= 'function formatResult(record) {'."\n";
5891 5891
                 if ($elemtype == 'category') {
5892
-                    $out .= '	//return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> <a href="' . DOL_URL_ROOT . '/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\';
5893
-									  	return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> \'+record.text+\'</span>\';';
5892
+                    $out .= '	//return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\';
5893
+									  	return \'<span><img src="' . DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> \'+record.text+\'</span>\';';
5894 5894
                 } else {
5895 5895
                     $out .= 'return record.text;';
5896 5896
                 }
5897
-                $out .= '};' . "\n";
5898
-                $out .= 'function formatSelection(record) {' . "\n";
5897
+                $out .= '};'."\n";
5898
+                $out .= 'function formatSelection(record) {'."\n";
5899 5899
                 if ($elemtype == 'category') {
5900
-                    $out .= '	//return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> <a href="' . DOL_URL_ROOT . '/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\';
5901
-									  	return \'<span><img src="' . DOL_URL_ROOT . '/theme/eldy/img/object_category.png' . '"> \'+record.text+\'</span>\';';
5900
+                    $out .= '	//return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> <a href="'.DOL_URL_ROOT.'/categories/viewcat.php?type=0&id=\'+record.id+\'">\'+record.text+\'</a></span>\';
5901
+									  	return \'<span><img src="' . DOL_URL_ROOT.'/theme/eldy/img/object_category.png'.'"> \'+record.text+\'</span>\';';
5902 5902
                 } else {
5903 5903
                     $out .= 'return record.text;';
5904 5904
                 }
5905
-                $out .= '};' . "\n";
5905
+                $out .= '};'."\n";
5906 5906
                 $out .= '$(document).ready(function () {
5907
-							$(\'#' . $htmlname . '\').' . $tmpplugin . '({
5907
+							$(\'#' . $htmlname.'\').'.$tmpplugin.'({
5908 5908
 								dir: \'ltr\',
5909 5909
 								// Specify format function for dropdown item
5910 5910
 								formatResult: formatResult,
@@ -5918,13 +5918,13 @@  discard block
 block discarded – undo
5918 5918
                 // Add other js lib
5919 5919
                 // ...
5920 5920
                 $out .= '$(document).ready(function () {
5921
-							$(\'#' . $htmlname . '\').multiSelect({
5921
+							$(\'#' . $htmlname.'\').multiSelect({
5922 5922
 								containerHTML: \'<div class="multi-select-container">\',
5923 5923
 								menuHTML: \'<div class="multi-select-menu">\',
5924
-								buttonHTML: \'<span class="multi-select-button ' . $morecss . '">\',
5924
+								buttonHTML: \'<span class="multi-select-button ' . $morecss.'">\',
5925 5925
 								menuItemHTML: \'<label class="multi-select-menuitem">\',
5926 5926
 								activeClass: \'multi-select-container--open\',
5927
-								noneText: \'' . $placeholder . '\'
5927
+								noneText: \'' . $placeholder.'\'
5928 5928
 							});
5929 5929
 						})';
5930 5930
             }
@@ -5933,27 +5933,27 @@  discard block
 block discarded – undo
5933 5933
 
5934 5934
         // Try also magic suggest
5935 5935
 
5936
-        $out .= '<select id="' . $htmlname . '" class="multiselect' . ($morecss ? ' ' . $morecss : '') . '" multiple name="' . $htmlname . '[]"' . ($moreattrib ? ' ' . $moreattrib : '') . ($width ? ' style="width: ' . (preg_match('/%/', $width) ? $width : $width . 'px') . '"' : '') . '>' . "\n";
5936
+        $out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n";
5937 5937
         if (is_array($array) && !empty($array)) {
5938 5938
             if ($value_as_key)
5939 5939
                 $array = array_combine($array, $array);
5940 5940
 
5941 5941
             if (!empty($array)) {
5942 5942
                 foreach ($array as $key => $value) {
5943
-                    $out .= '<option value="' . $key . '"';
5943
+                    $out .= '<option value="'.$key.'"';
5944 5944
                     if (is_array($selected) && !empty($selected) && in_array($key, $selected) && !empty($key)) {
5945 5945
                         $out .= ' selected';
5946 5946
                     }
5947 5947
                     $out .= '>';
5948 5948
 
5949 5949
                     $newval = ($translate ? $langs->trans($value) : $value);
5950
-                    $newval = ($key_in_label ? $key . ' - ' . $newval : $newval);
5950
+                    $newval = ($key_in_label ? $key.' - '.$newval : $newval);
5951 5951
                     $out .= dol_htmlentitiesbr($newval);
5952
-                    $out .= '</option>' . "\n";
5952
+                    $out .= '</option>'."\n";
5953 5953
                 }
5954 5954
             }
5955 5955
         }
5956
-        $out .= '</select>' . "\n";
5956
+        $out .= '</select>'."\n";
5957 5957
 
5958 5958
         return $out;
5959 5959
     }
@@ -5974,7 +5974,7 @@  discard block
 block discarded – undo
5974 5974
         if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
5975 5975
             return '';
5976 5976
 
5977
-        $tmpvar = "MAIN_SELECTEDFIELDS_" . $varpage;
5977
+        $tmpvar = "MAIN_SELECTEDFIELDS_".$varpage;
5978 5978
         if (!empty($user->conf->$tmpvar)) {
5979 5979
             $tmparray = explode(',', $user->conf->$tmpvar);
5980 5980
             foreach ($array as $key => $val) {
@@ -5996,28 +5996,28 @@  discard block
 block discarded – undo
5996 5996
               var_dump(array_key_exists('enabled', $val));
5997 5997
               var_dump(!$val['enabled']); */
5998 5998
             if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
5999
-                unset($array[$key]);     // We don't want this field
5999
+                unset($array[$key]); // We don't want this field
6000 6000
                 continue;
6001 6001
             }
6002 6002
             if ($val['label']) {
6003
-                $lis .= '<li><input type="checkbox" id="checkbox' . $key . '" value="' . $key . '"' . (empty($val['checked']) ? '' : ' checked="checked"') . '/><label for="checkbox' . $key . '">' . dol_escape_htmltag($langs->trans($val['label'])) . '</label></li>';
6004
-                $listcheckedstring .= (empty($val['checked']) ? '' : $key . ',');
6003
+                $lis .= '<li><input type="checkbox" id="checkbox'.$key.'" value="'.$key.'"'.(empty($val['checked']) ? '' : ' checked="checked"').'/><label for="checkbox'.$key.'">'.dol_escape_htmltag($langs->trans($val['label'])).'</label></li>';
6004
+                $listcheckedstring .= (empty($val['checked']) ? '' : $key.',');
6005 6005
             }
6006 6006
         }
6007 6007
 
6008
-        $out = '<!-- Component multiSelectArrayWithCheckbox ' . $htmlname . ' -->
6008
+        $out = '<!-- Component multiSelectArrayWithCheckbox '.$htmlname.' -->
6009 6009
 
6010 6010
         <dl class="dropdown">
6011 6011
             <dt>
6012 6012
             <a href="#">
6013
-              ' . img_picto('', 'list') . '
6013
+              ' . img_picto('', 'list').'
6014 6014
             </a>
6015
-            <input type="hidden" class="' . $htmlname . '" name="' . $htmlname . '" value="' . $listcheckedstring . '">
6015
+            <input type="hidden" class="' . $htmlname.'" name="'.$htmlname.'" value="'.$listcheckedstring.'">
6016 6016
             </dt>
6017 6017
             <dd class="dropdowndd">
6018
-                <div class="multiselectcheckbox' . $htmlname . '">
6019
-                    <ul class="ul' . $htmlname . '">
6020
-                    ' . $lis . '
6018
+                <div class="multiselectcheckbox' . $htmlname.'">
6019
+                    <ul class="ul' . $htmlname.'">
6020
+                    ' . $lis.'
6021 6021
                     </ul>
6022 6022
                 </div>
6023 6023
             </dd>
@@ -6025,15 +6025,15 @@  discard block
 block discarded – undo
6025 6025
 
6026 6026
         <script type="text/javascript">
6027 6027
           jQuery(document).ready(function () {
6028
-              $(\'.multiselectcheckbox' . $htmlname . ' input[type="checkbox"]\').on(\'click\', function () {
6028
+              $(\'.multiselectcheckbox' . $htmlname.' input[type="checkbox"]\').on(\'click\', function () {
6029 6029
                   console.log("A new field was added/removed")
6030 6030
                   $("input:hidden[name=formfilteraction]").val(\'listafterchangingselectedfields\')
6031 6031
                   var title = $(this).val() + ",";
6032 6032
                   if ($(this).is(\':checked\')) {
6033
-                      $(\'.' . $htmlname . '\').val(title + $(\'.' . $htmlname . '\').val());
6033
+                      $(\'.' . $htmlname.'\').val(title + $(\'.'.$htmlname.'\').val());
6034 6034
                   }
6035 6035
                   else {
6036
-                      $(\'.' . $htmlname . '\').val( $(\'.' . $htmlname . '\').val().replace(title, \'\') )
6036
+                      $(\'.' . $htmlname.'\').val( $(\'.'.$htmlname.'\').val().replace(title, \'\') )
6037 6037
                   }
6038 6038
                   // Now, we submit page
6039 6039
                   $(this).parents(\'form:first\').submit();
@@ -6057,7 +6057,7 @@  discard block
 block discarded – undo
6057 6057
     {
6058 6058
         global $db;
6059 6059
 
6060
-        include_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
6060
+        include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
6061 6061
 
6062 6062
         $cat = new Categorie($db);
6063 6063
         $categories = $cat->containing($id, $type);
@@ -6065,12 +6065,12 @@  discard block
 block discarded – undo
6065 6065
         if ($rendermode == 1) {
6066 6066
             $toprint = array();
6067 6067
             foreach ($categories as $c) {
6068
-                $ways = $c->print_all_ways();       // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
6068
+                $ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
6069 6069
                 foreach ($ways as $way) {
6070
-                    $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"' . ($c->color ? ' style="background: #' . $c->color . ';"' : ' style="background: #aaa"') . '>' . img_object('', 'category') . ' ' . $way . '</li>';
6070
+                    $toprint[] = '<li class="select2-search-choice-dolibarr noborderoncategories"'.($c->color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'</li>';
6071 6071
                 }
6072 6072
             }
6073
-            return '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">' . implode(' ', $toprint) . '</ul></div>';
6073
+            return '<div class="select2-container-multi-dolibarr" style="width: 90%;"><ul class="select2-choices-dolibarr">'.implode(' ', $toprint).'</ul></div>';
6074 6074
         }
6075 6075
 
6076 6076
         if ($rendermode == 0) {
@@ -6106,7 +6106,7 @@  discard block
 block discarded – undo
6106 6106
             'morehtmlright' => $morehtmlright,
6107 6107
             'compatibleImportElementsList' => & $compatibleImportElementsList,
6108 6108
         );
6109
-        $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
6109
+        $reshook = $hookmanager->executeHooks('showLinkedObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
6110 6110
 
6111 6111
         if (empty($reshook)) {
6112 6112
             $nbofdifferenttypes = count($object->linkedObjects);
@@ -6116,15 +6116,15 @@  discard block
 block discarded – undo
6116 6116
 
6117 6117
 
6118 6118
             print '<div class="div-table-responsive-no-min">';
6119
-            print '<table class="noborder allwidth" data-block="showLinkedObject" data-element="' . $object->element . '"  data-elementid="' . $object->id . '"   >';
6119
+            print '<table class="noborder allwidth" data-block="showLinkedObject" data-element="'.$object->element.'"  data-elementid="'.$object->id.'"   >';
6120 6120
 
6121 6121
             print '<tr class="liste_titre">';
6122
-            print '<td>' . $langs->trans("Type") . '</td>';
6123
-            print '<td>' . $langs->trans("Ref") . '</td>';
6122
+            print '<td>'.$langs->trans("Type").'</td>';
6123
+            print '<td>'.$langs->trans("Ref").'</td>';
6124 6124
             print '<td align="center"></td>';
6125
-            print '<td align="center">' . $langs->trans("Date") . '</td>';
6126
-            print '<td align="right">' . $langs->trans("AmountHTShort") . '</td>';
6127
-            print '<td align="right">' . $langs->trans("Status") . '</td>';
6125
+            print '<td align="center">'.$langs->trans("Date").'</td>';
6126
+            print '<td align="right">'.$langs->trans("AmountHTShort").'</td>';
6127
+            print '<td align="right">'.$langs->trans("Status").'</td>';
6128 6128
             print '<td></td>';
6129 6129
             print '</tr>';
6130 6130
 
@@ -6142,13 +6142,13 @@  discard block
 block discarded – undo
6142 6142
                 if ($objecttype != 'supplier_proposal' && preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs)) {
6143 6143
                     $element = $regs[1];
6144 6144
                     $subelement = $regs[2];
6145
-                    $tplpath = $element . '/' . $subelement;
6145
+                    $tplpath = $element.'/'.$subelement;
6146 6146
                 }
6147 6147
                 $tplname = 'linkedobjectblock';
6148 6148
 
6149 6149
                 // To work with non standard path
6150 6150
                 if ($objecttype == 'facture') {
6151
-                    $tplpath = 'compta/' . $element;
6151
+                    $tplpath = 'compta/'.$element;
6152 6152
                     if (empty($conf->facture->enabled))
6153 6153
                         continue; // Do not show if module disabled
6154 6154
                 }
@@ -6159,7 +6159,7 @@  discard block
 block discarded – undo
6159 6159
                         continue; // Do not show if module disabled
6160 6160
                 }
6161 6161
                 else if ($objecttype == 'propal') {
6162
-                    $tplpath = 'comm/' . $element;
6162
+                    $tplpath = 'comm/'.$element;
6163 6163
                     if (empty($conf->propal->enabled))
6164 6164
                         continue; // Do not show if module disabled
6165 6165
                 }
@@ -6197,14 +6197,14 @@  discard block
 block discarded – undo
6197 6197
 
6198 6198
 
6199 6199
                 // Output template part (modules that overwrite templates must declare this into descriptor)
6200
-                $dirtpls = array_merge($conf->modules_parts['tpl'], array('/' . $tplpath . '/tpl'));
6200
+                $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl'));
6201 6201
                 foreach ($dirtpls as $reldir) {
6202 6202
                     if ($nboftypesoutput == ($nbofdifferenttypes - 1)) {    // No more type to show after
6203 6203
                         global $noMoreLinkedObjectBlockAfter;
6204 6204
                         $noMoreLinkedObjectBlockAfter = 1;
6205 6205
                     }
6206 6206
 
6207
-                    $res = @include dol_buildpath($reldir . '/' . $tplname . '.tpl.php');
6207
+                    $res = @include dol_buildpath($reldir.'/'.$tplname.'.tpl.php');
6208 6208
                     if ($res) {
6209 6209
                         $nboftypesoutput++;
6210 6210
                         break;
@@ -6213,7 +6213,7 @@  discard block
 block discarded – undo
6213 6213
             }
6214 6214
 
6215 6215
             if (!$nboftypesoutput) {
6216
-                print '<tr><td class="impair opacitymedium" colspan="7">' . $langs->trans("None") . '</td></tr>';
6216
+                print '<tr><td class="impair opacitymedium" colspan="7">'.$langs->trans("None").'</td></tr>';
6217 6217
             }
6218 6218
 
6219 6219
             print '</table>';
@@ -6253,26 +6253,26 @@  discard block
 block discarded – undo
6253 6253
         if (is_object($object->thirdparty) && !empty($object->thirdparty->id) && $object->thirdparty->id > 0) {
6254 6254
             $listofidcompanytoscan = $object->thirdparty->id;
6255 6255
             if (($object->thirdparty->parent > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PARENT_IN_LINKTO))
6256
-                $listofidcompanytoscan .= ',' . $object->thirdparty->parent;
6256
+                $listofidcompanytoscan .= ','.$object->thirdparty->parent;
6257 6257
             if (($object->fk_project > 0) && !empty($conf->global->THIRDPARTY_INCLUDE_PROJECT_THIRDPARY_IN_LINKTO)) {
6258
-                include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
6258
+                include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
6259 6259
                 $tmpproject = new Project($this->db);
6260 6260
                 $tmpproject->fetch($object->fk_project);
6261 6261
                 if ($tmpproject->socid > 0 && ($tmpproject->socid != $object->thirdparty->id))
6262
-                    $listofidcompanytoscan .= ',' . $tmpproject->socid;
6262
+                    $listofidcompanytoscan .= ','.$tmpproject->socid;
6263 6263
                 unset($tmpproject);
6264 6264
             }
6265 6265
 
6266 6266
             $possiblelinks = array(
6267
-                'propal' => array('enabled' => $conf->propal->enabled, 'perms' => 1, 'label' => 'LinkToProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('propal') . ')'),
6268
-                'order' => array('enabled' => $conf->commande->enabled, 'perms' => 1, 'label' => 'LinkToOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('commande') . ')'),
6269
-                'invoice' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('invoice') . ')'),
6270
-                'invoice_template' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToTemplateInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('invoice') . ')'),
6271
-                'contrat' => array('enabled' => $conf->contrat->enabled, 'perms' => 1, 'label' => 'LinkToContract', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('contract') . ')'),
6272
-                'fichinter' => array('enabled' => $conf->ficheinter->enabled, 'perms' => 1, 'label' => 'LinkToIntervention', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('intervention') . ')'),
6273
-                'supplier_proposal' => array('enabled' => $conf->supplier_proposal->enabled, 'perms' => 1, 'label' => 'LinkToSupplierProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('supplier_proposal') . ')'),
6274
-                'order_supplier' => array('enabled' => $conf->supplier_order->enabled, 'perms' => 1, 'label' => 'LinkToSupplierOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('commande_fournisseur') . ')'),
6275
-                'invoice_supplier' => array('enabled' => $conf->supplier_invoice->enabled, 'perms' => 1, 'label' => 'LinkToSupplierInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (" . $listofidcompanytoscan . ') AND t.entity IN (' . getEntity('facture_fourn') . ')')
6267
+                'propal' => array('enabled' => $conf->propal->enabled, 'perms' => 1, 'label' => 'LinkToProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('propal').')'),
6268
+                'order' => array('enabled' => $conf->commande->enabled, 'perms' => 1, 'label' => 'LinkToOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'),
6269
+                'invoice' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
6270
+                'invoice_template' => array('enabled' => $conf->facture->enabled, 'perms' => 1, 'label' => 'LinkToTemplateInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
6271
+                'contrat' => array('enabled' => $conf->contrat->enabled, 'perms' => 1, 'label' => 'LinkToContract', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'),
6272
+                'fichinter' => array('enabled' => $conf->ficheinter->enabled, 'perms' => 1, 'label' => 'LinkToIntervention', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
6273
+                'supplier_proposal' => array('enabled' => $conf->supplier_proposal->enabled, 'perms' => 1, 'label' => 'LinkToSupplierProposal', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
6274
+                'order_supplier' => array('enabled' => $conf->supplier_order->enabled, 'perms' => 1, 'label' => 'LinkToSupplierOrder', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'),
6275
+                'invoice_supplier' => array('enabled' => $conf->supplier_invoice->enabled, 'perms' => 1, 'label' => 'LinkToSupplierInvoice', 'sql' => "SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('facture_fourn').')')
6276 6276
             );
6277 6277
         }
6278 6278
 
@@ -6281,7 +6281,7 @@  discard block
 block discarded – undo
6281 6281
         // Can complete the possiblelink array
6282 6282
         $hookmanager->initHooks(array('commonobject'));
6283 6283
         $parameters = array('listofidcompanytoscan' => $listofidcompanytoscan);
6284
-        $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
6284
+        $reshook = $hookmanager->executeHooks('showLinkToObjectBlock', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
6285 6285
         if (empty($reshook)) {
6286 6286
             if (is_array($hookmanager->resArray) && count($hookmanager->resArray)) {
6287 6287
                 $possiblelinks = array_merge($possiblelinks, $hookmanager->resArray);
@@ -6299,7 +6299,7 @@  discard block
 block discarded – undo
6299 6299
                 continue;
6300 6300
 
6301 6301
             if (!empty($possiblelink['perms']) && (empty($restrictlinksto) || in_array($key, $restrictlinksto)) && (empty($excludelinksto) || !in_array($key, $excludelinksto))) {
6302
-                print '<div id="' . $key . 'list"' . (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display:none"' : '') . '>';
6302
+                print '<div id="'.$key.'list"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' style="display:none"' : '').'>';
6303 6303
                 $sql = $possiblelink['sql'];
6304 6304
 
6305 6305
                 $resqllist = $this->db->query($sql);
@@ -6307,34 +6307,34 @@  discard block
 block discarded – undo
6307 6307
                     $num = $this->db->num_rows($resqllist);
6308 6308
                     $i = 0;
6309 6309
 
6310
-                    print '<br><form action="' . $_SERVER["PHP_SELF"] . '" method="POST" name="formlinked' . $key . '">';
6311
-                    print '<input type="hidden" name="id" value="' . $object->id . '">';
6310
+                    print '<br><form action="'.$_SERVER["PHP_SELF"].'" method="POST" name="formlinked'.$key.'">';
6311
+                    print '<input type="hidden" name="id" value="'.$object->id.'">';
6312 6312
                     print '<input type="hidden" name="action" value="addlink">';
6313
-                    print '<input type="hidden" name="addlink" value="' . $key . '">';
6313
+                    print '<input type="hidden" name="addlink" value="'.$key.'">';
6314 6314
                     print '<table class="noborder">';
6315 6315
                     print '<tr class="liste_titre">';
6316 6316
                     print '<td class="nowrap"></td>';
6317
-                    print '<td align="center">' . $langs->trans("Ref") . '</td>';
6318
-                    print '<td align="left">' . $langs->trans("RefCustomer") . '</td>';
6319
-                    print '<td align="right">' . $langs->trans("AmountHTShort") . '</td>';
6320
-                    print '<td align="left">' . $langs->trans("Company") . '</td>';
6317
+                    print '<td align="center">'.$langs->trans("Ref").'</td>';
6318
+                    print '<td align="left">'.$langs->trans("RefCustomer").'</td>';
6319
+                    print '<td align="right">'.$langs->trans("AmountHTShort").'</td>';
6320
+                    print '<td align="left">'.$langs->trans("Company").'</td>';
6321 6321
                     print '</tr>';
6322 6322
                     while ($i < $num) {
6323 6323
                         $objp = $this->db->fetch_object($resqllist);
6324 6324
 
6325 6325
                         print '<tr class="oddeven">';
6326 6326
                         print '<td aling="left">';
6327
-                        print '<input type="radio" name="idtolinkto" value=' . $objp->rowid . '>';
6327
+                        print '<input type="radio" name="idtolinkto" value='.$objp->rowid.'>';
6328 6328
                         print '</td>';
6329
-                        print '<td align="center">' . $objp->ref . '</td>';
6330
-                        print '<td>' . $objp->ref_client . '</td>';
6331
-                        print '<td align="right">' . price($objp->total_ht) . '</td>';
6332
-                        print '<td>' . $objp->name . '</td>';
6329
+                        print '<td align="center">'.$objp->ref.'</td>';
6330
+                        print '<td>'.$objp->ref_client.'</td>';
6331
+                        print '<td align="right">'.price($objp->total_ht).'</td>';
6332
+                        print '<td>'.$objp->name.'</td>';
6333 6333
                         print '</tr>';
6334 6334
                         $i++;
6335 6335
                     }
6336 6336
                     print '</table>';
6337
-                    print '<div class="center"><input type="submit" class="button valignmiddle" value="' . $langs->trans('ToLink') . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="cancel" value="' . $langs->trans('Cancel') . '"></div>';
6337
+                    print '<div class="center"><input type="submit" class="button valignmiddle" value="'.$langs->trans('ToLink').'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></div>';
6338 6338
 
6339 6339
                     print '</form>';
6340 6340
                     $this->db->free($resqllist);
@@ -6348,20 +6348,20 @@  discard block
 block discarded – undo
6348 6348
 
6349 6349
                 //$linktoelem.=($linktoelem?' &nbsp; ':'');
6350 6350
                 if ($num > 0)
6351
-                    $linktoelemlist .= '<li><a href="#linkto' . $key . '" class="linkto dropdowncloseonclick" rel="' . $key . '">' . $langs->trans($possiblelink['label']) . ' (' . $num . ')</a></li>';
6351
+                    $linktoelemlist .= '<li><a href="#linkto'.$key.'" class="linkto dropdowncloseonclick" rel="'.$key.'">'.$langs->trans($possiblelink['label']).' ('.$num.')</a></li>';
6352 6352
                 //else $linktoelem.=$langs->trans($possiblelink['label']);
6353 6353
                 else
6354
-                    $linktoelemlist .= '<li><span class="linktodisabled">' . $langs->trans($possiblelink['label']) . ' (0)</span></li>';
6354
+                    $linktoelemlist .= '<li><span class="linktodisabled">'.$langs->trans($possiblelink['label']).' (0)</span></li>';
6355 6355
             }
6356 6356
         }
6357 6357
 
6358 6358
         if ($linktoelemlist) {
6359 6359
             $linktoelem = '
6360 6360
     		<dl class="dropdown" id="linktoobjectname">
6361
-    		<dt><a href="#linktoobjectname">' . $langs->trans("LinkTo") . '...</a></dt>
6361
+    		<dt><a href="#linktoobjectname">' . $langs->trans("LinkTo").'...</a></dt>
6362 6362
     		<dd>
6363 6363
     		<div class="multiselectlinkto">
6364
-    		<ul class="ulselectedfields">' . $linktoelemlist . '
6364
+    		<ul class="ulselectedfields">' . $linktoelemlist.'
6365 6365
     		</ul>
6366 6366
     		</div>
6367 6367
     		</dd>
@@ -6408,18 +6408,18 @@  discard block
 block discarded – undo
6408 6408
 
6409 6409
         $disabled = ($disabled ? ' disabled' : '');
6410 6410
 
6411
-        $resultyesno = '<select class="flat width75" id="' . $htmlname . '" name="' . $htmlname . '"' . $disabled . '>' . "\n";
6411
+        $resultyesno = '<select class="flat width75" id="'.$htmlname.'" name="'.$htmlname.'"'.$disabled.'>'."\n";
6412 6412
         if ($useempty)
6413
-            $resultyesno .= '<option value="-1"' . (($value < 0) ? ' selected' : '') . '>&nbsp;</option>' . "\n";
6413
+            $resultyesno .= '<option value="-1"'.(($value < 0) ? ' selected' : '').'>&nbsp;</option>'."\n";
6414 6414
         if (("$value" == 'yes') || ($value == 1)) {
6415
-            $resultyesno .= '<option value="' . $yes . '" selected>' . $langs->trans("Yes") . '</option>' . "\n";
6416
-            $resultyesno .= '<option value="' . $no . '">' . $langs->trans("No") . '</option>' . "\n";
6415
+            $resultyesno .= '<option value="'.$yes.'" selected>'.$langs->trans("Yes").'</option>'."\n";
6416
+            $resultyesno .= '<option value="'.$no.'">'.$langs->trans("No").'</option>'."\n";
6417 6417
         } else {
6418 6418
             $selected = (($useempty && $value != '0' && $value != 'no') ? '' : ' selected');
6419
-            $resultyesno .= '<option value="' . $yes . '">' . $langs->trans("Yes") . '</option>' . "\n";
6420
-            $resultyesno .= '<option value="' . $no . '"' . $selected . '>' . $langs->trans("No") . '</option>' . "\n";
6419
+            $resultyesno .= '<option value="'.$yes.'">'.$langs->trans("Yes").'</option>'."\n";
6420
+            $resultyesno .= '<option value="'.$no.'"'.$selected.'>'.$langs->trans("No").'</option>'."\n";
6421 6421
         }
6422
-        $resultyesno .= '</select>' . "\n";
6422
+        $resultyesno .= '</select>'."\n";
6423 6423
         return $resultyesno;
6424 6424
     }
6425 6425
 
@@ -6437,12 +6437,12 @@  discard block
 block discarded – undo
6437 6437
     {
6438 6438
         // phpcs:enable
6439 6439
         $sql = "SELECT rowid, label";
6440
-        $sql .= " FROM " . MAIN_DB_PREFIX . "export_model";
6441
-        $sql .= " WHERE type = '" . $type . "'";
6440
+        $sql .= " FROM ".MAIN_DB_PREFIX."export_model";
6441
+        $sql .= " WHERE type = '".$type."'";
6442 6442
         $sql .= " ORDER BY rowid";
6443 6443
         $result = $this->db->query($sql);
6444 6444
         if ($result) {
6445
-            print '<select class="flat" id="select_' . $htmlname . '" name="' . $htmlname . '">';
6445
+            print '<select class="flat" id="select_'.$htmlname.'" name="'.$htmlname.'">';
6446 6446
             if ($useempty) {
6447 6447
                 print '<option value="-1">&nbsp;</option>';
6448 6448
             }
@@ -6452,9 +6452,9 @@  discard block
 block discarded – undo
6452 6452
             while ($i < $num) {
6453 6453
                 $obj = $this->db->fetch_object($result);
6454 6454
                 if ($selected == $obj->rowid) {
6455
-                    print '<option value="' . $obj->rowid . '" selected>';
6455
+                    print '<option value="'.$obj->rowid.'" selected>';
6456 6456
                 } else {
6457
-                    print '<option value="' . $obj->rowid . '">';
6457
+                    print '<option value="'.$obj->rowid.'">';
6458 6458
                 }
6459 6459
                 print $obj->label;
6460 6460
                 print '</option>';
@@ -6497,7 +6497,7 @@  discard block
 block discarded – undo
6497 6497
         // Add where from hooks
6498 6498
         if (is_object($hookmanager)) {
6499 6499
             $parameters = array();
6500
-            $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object);    // Note that $action and $object may have been modified by hook
6500
+            $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
6501 6501
             $object->next_prev_filter .= $hookmanager->resPrint;
6502 6502
         }
6503 6503
         $previous_ref = $next_ref = '';
@@ -6523,8 +6523,8 @@  discard block
 block discarded – undo
6523 6523
                 $stringforfirstkey .= ' CTL +';
6524 6524
             }
6525 6525
 
6526
-            $previous_ref = $object->ref_previous ? '<a accesskey="p" title="' . $stringforfirstkey . ' p" class="classfortooltip" href="' . $navurl . '?' . $paramid . '=' . urlencode($object->ref_previous) . $moreparam . '"><i class="fa fa-chevron-left"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
6527
-            $next_ref = $object->ref_next ? '<a accesskey="n" title="' . $stringforfirstkey . ' n" class="classfortooltip" href="' . $navurl . '?' . $paramid . '=' . urlencode($object->ref_next) . $moreparam . '"><i class="fa fa-chevron-right"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
6526
+            $previous_ref = $object->ref_previous ? '<a accesskey="p" title="'.$stringforfirstkey.' p" class="classfortooltip" href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_previous).$moreparam.'"><i class="fa fa-chevron-left"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-left opacitymedium"></i></span>';
6527
+            $next_ref = $object->ref_next ? '<a accesskey="n" title="'.$stringforfirstkey.' n" class="classfortooltip" href="'.$navurl.'?'.$paramid.'='.urlencode($object->ref_next).$moreparam.'"><i class="fa fa-chevron-right"></i></a>' : '<span class="inactive"><i class="fa fa-chevron-right opacitymedium"></i></span>';
6528 6528
         }
6529 6529
 
6530 6530
         //print "xx".$previous_ref."x".$next_ref;
@@ -6532,30 +6532,30 @@  discard block
 block discarded – undo
6532 6532
 
6533 6533
         // Right part of banner
6534 6534
         if ($morehtmlright)
6535
-            $ret .= '<div class="inline-block floatleft">' . $morehtmlright . '</div>';
6535
+            $ret .= '<div class="inline-block floatleft">'.$morehtmlright.'</div>';
6536 6536
 
6537 6537
         if ($previous_ref || $next_ref || $morehtml) {
6538 6538
             $ret .= '<div class="pagination paginationref"><ul class="right">';
6539 6539
         }
6540 6540
         if ($morehtml) {
6541
-            $ret .= '<li class="noborder litext">' . $morehtml . '</li>';
6541
+            $ret .= '<li class="noborder litext">'.$morehtml.'</li>';
6542 6542
         }
6543 6543
         if ($shownav && ($previous_ref || $next_ref)) {
6544
-            $ret .= '<li class="pagination">' . $previous_ref . '</li>';
6545
-            $ret .= '<li class="pagination">' . $next_ref . '</li>';
6544
+            $ret .= '<li class="pagination">'.$previous_ref.'</li>';
6545
+            $ret .= '<li class="pagination">'.$next_ref.'</li>';
6546 6546
         }
6547 6547
         if ($previous_ref || $next_ref || $morehtml) {
6548 6548
             $ret .= '</ul></div>';
6549 6549
         }
6550 6550
 
6551 6551
         $parameters = array();
6552
-        $reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object);    // Note that $action and $object may have been modified by hook
6552
+        $reshook = $hookmanager->executeHooks('moreHtmlStatus', $parameters, $object); // Note that $action and $object may have been modified by hook
6553 6553
         if (empty($reshook))
6554 6554
             $morehtmlstatus .= $hookmanager->resPrint;
6555 6555
         else
6556 6556
             $morehtmlstatus = $hookmanager->resPrint;
6557 6557
         if ($morehtmlstatus)
6558
-            $ret .= '<div class="statusref">' . $morehtmlstatus . '</div>';
6558
+            $ret .= '<div class="statusref">'.$morehtmlstatus.'</div>';
6559 6559
 
6560 6560
         $parameters = array();
6561 6561
         $reshook = $hookmanager->executeHooks('moreHtmlRef', $parameters, $object); // Note that $action and $object may have been modified by hook
@@ -6567,29 +6567,29 @@  discard block
 block discarded – undo
6567 6567
         // Left part of banner
6568 6568
         if ($morehtmlleft) {
6569 6569
             if ($conf->browser->layout == 'phone')
6570
-                $ret .= '<div class="floatleft">' . $morehtmlleft . '</div>';    // class="center" to have photo in middle
6570
+                $ret .= '<div class="floatleft">'.$morehtmlleft.'</div>'; // class="center" to have photo in middle
6571 6571
             else
6572
-                $ret .= '<div class="inline-block floatleft">' . $morehtmlleft . '</div>';
6572
+                $ret .= '<div class="inline-block floatleft">'.$morehtmlleft.'</div>';
6573 6573
         }
6574 6574
 
6575 6575
         //if ($conf->browser->layout == 'phone') $ret.='<div class="clearboth"></div>';
6576
-        $ret .= '<div class="inline-block floatleft valignmiddle refid' . (($shownav && ($previous_ref || $next_ref)) ? ' refidpadding' : '') . '">';
6576
+        $ret .= '<div class="inline-block floatleft valignmiddle refid'.(($shownav && ($previous_ref || $next_ref)) ? ' refidpadding' : '').'">';
6577 6577
 
6578 6578
         // For thirdparty, contact, user, member, the ref is the id, so we show something else
6579 6579
         if ($object->element == 'societe') {
6580 6580
             $ret .= dol_htmlentities($object->name);
6581 6581
         } else if ($object->element == 'member') {
6582
-            $ret .= $object->ref . '<br>';
6582
+            $ret .= $object->ref.'<br>';
6583 6583
             $fullname = $object->getFullName($langs);
6584 6584
             if ($object->morphy == 'mor' && $object->societe) {
6585
-                $ret .= dol_htmlentities($object->societe) . ((!empty($fullname) && $object->societe != $fullname) ? ' (' . dol_htmlentities($fullname) . ')' : '');
6585
+                $ret .= dol_htmlentities($object->societe).((!empty($fullname) && $object->societe != $fullname) ? ' ('.dol_htmlentities($fullname).')' : '');
6586 6586
             } else {
6587
-                $ret .= dol_htmlentities($fullname) . ((!empty($object->societe) && $object->societe != $fullname) ? ' (' . dol_htmlentities($object->societe) . ')' : '');
6587
+                $ret .= dol_htmlentities($fullname).((!empty($object->societe) && $object->societe != $fullname) ? ' ('.dol_htmlentities($object->societe).')' : '');
6588 6588
             }
6589 6589
         } else if (in_array($object->element, array('contact', 'user', 'usergroup'))) {
6590 6590
             $ret .= dol_htmlentities($object->getFullName($langs));
6591 6591
         } else if (in_array($object->element, array('action', 'agenda'))) {
6592
-            $ret .= $object->ref . '<br>' . $object->label;
6592
+            $ret .= $object->ref.'<br>'.$object->label;
6593 6593
         } else if (in_array($object->element, array('adherent_type'))) {
6594 6594
             $ret .= $object->label;
6595 6595
         } else if ($object->element == 'ecm_directories') {
@@ -6599,7 +6599,7 @@  discard block
 block discarded – undo
6599 6599
 
6600 6600
 
6601 6601
         if ($morehtmlref) {
6602
-            $ret .= ' ' . $morehtmlref;
6602
+            $ret .= ' '.$morehtmlref;
6603 6603
         }
6604 6604
         $ret .= '</div>';
6605 6605
 
@@ -6632,9 +6632,9 @@  discard block
 block discarded – undo
6632 6632
         }
6633 6633
 
6634 6634
         // Barcode image
6635
-        $url = DOL_URL_ROOT . '/viewimage.php?modulepart=barcode&generator=' . urlencode($object->barcode_type_coder) . '&code=' . urlencode($object->barcode) . '&encoding=' . urlencode($object->barcode_type_code);
6636
-        $out = '<!-- url barcode = ' . $url . ' -->';
6637
-        $out .= '<img src="' . $url . '">';
6635
+        $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).'&code='.urlencode($object->barcode).'&encoding='.urlencode($object->barcode_type_code);
6636
+        $out = '<!-- url barcode = '.$url.' -->';
6637
+        $out .= '<img src="'.$url.'">';
6638 6638
         return $out;
6639 6639
     }
6640 6640
 
@@ -6671,25 +6671,25 @@  discard block
 block discarded – undo
6671 6671
             $dir = $conf->societe->multidir_output[$entity];
6672 6672
             if (!empty($object->logo)) {
6673 6673
                 if ((string) $imagesize == 'mini')
6674
-                    $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_mini');             // getImageFileNameForSize include the thumbs
6674
+                    $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_mini'); // getImageFileNameForSize include the thumbs
6675 6675
                 else if ((string) $imagesize == 'small')
6676
-                    $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . getImageFileNameForSize($object->logo, '_small');
6676
+                    $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.getImageFileNameForSize($object->logo, '_small');
6677 6677
                 else
6678
-                    $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo;
6679
-                $originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty') . '/logos/' . $object->logo;
6678
+                    $file = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo;
6679
+                $originalfile = get_exdir(0, 0, 0, 0, $object, 'thirdparty').'/logos/'.$object->logo;
6680 6680
             }
6681 6681
             $email = $object->email;
6682 6682
         }
6683 6683
         else if ($modulepart == 'contact') {
6684
-            $dir = $conf->societe->multidir_output[$entity] . '/contact';
6684
+            $dir = $conf->societe->multidir_output[$entity].'/contact';
6685 6685
             if (!empty($object->photo)) {
6686 6686
                 if ((string) $imagesize == 'mini')
6687
-                    $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_mini');
6687
+                    $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_mini');
6688 6688
                 else if ((string) $imagesize == 'small')
6689
-                    $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . getImageFileNameForSize($object->photo, '_small');
6689
+                    $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.getImageFileNameForSize($object->photo, '_small');
6690 6690
                 else
6691
-                    $file = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo;
6692
-                $originalfile = get_exdir(0, 0, 0, 0, $object, 'contact') . '/photos/' . $object->photo;
6691
+                    $file = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo;
6692
+                $originalfile = get_exdir(0, 0, 0, 0, $object, 'contact').'/photos/'.$object->photo;
6693 6693
             }
6694 6694
             $email = $object->email;
6695 6695
             $capture = 'user';
@@ -6698,15 +6698,15 @@  discard block
 block discarded – undo
6698 6698
             $dir = $conf->user->dir_output;
6699 6699
             if (!empty($object->photo)) {
6700 6700
                 if ((string) $imagesize == 'mini')
6701
-                    $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_mini');
6701
+                    $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_mini');
6702 6702
                 else if ((string) $imagesize == 'small')
6703
-                    $file = get_exdir(0, 0, 0, 0, $object, 'user') . $object->id . '/' . getImageFileNameForSize($object->photo, '_small');
6703
+                    $file = get_exdir(0, 0, 0, 0, $object, 'user').$object->id.'/'.getImageFileNameForSize($object->photo, '_small');
6704 6704
                 else
6705
-                    $file = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo;
6706
-                $originalfile = get_exdir(0, 0, 0, 0, $object, 'user') . '/' . $object->id . '/' . $object->photo;
6705
+                    $file = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo;
6706
+                $originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'/'.$object->id.'/'.$object->photo;
6707 6707
             }
6708 6708
             if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS))
6709
-                $altfile = $object->id . ".jpg"; // For backward compatibility
6709
+                $altfile = $object->id.".jpg"; // For backward compatibility
6710 6710
             $email = $object->email;
6711 6711
             $capture = 'user';
6712 6712
         }
@@ -6714,15 +6714,15 @@  discard block
 block discarded – undo
6714 6714
             $dir = $conf->adherent->dir_output;
6715 6715
             if (!empty($object->photo)) {
6716 6716
                 if ((string) $imagesize == 'mini')
6717
-                    $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_mini');
6717
+                    $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_mini');
6718 6718
                 else if ((string) $imagesize == 'small')
6719
-                    $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . getImageFileNameForSize($object->photo, '_small');
6719
+                    $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.getImageFileNameForSize($object->photo, '_small');
6720 6720
                 else
6721
-                    $file = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo;
6722
-                $originalfile = get_exdir(0, 0, 0, 0, $object, 'member') . 'photos/' . $object->photo;
6721
+                    $file = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo;
6722
+                $originalfile = get_exdir(0, 0, 0, 0, $object, 'member').'photos/'.$object->photo;
6723 6723
             }
6724 6724
             if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS))
6725
-                $altfile = $object->id . ".jpg"; // For backward compatibility
6725
+                $altfile = $object->id.".jpg"; // For backward compatibility
6726 6726
             $email = $object->email;
6727 6727
             $capture = 'user';
6728 6728
         }
@@ -6731,15 +6731,15 @@  discard block
 block discarded – undo
6731 6731
             $dir = $conf->$modulepart->dir_output;
6732 6732
             if (!empty($object->photo)) {
6733 6733
                 if ((string) $imagesize == 'mini')
6734
-                    $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_mini');
6734
+                    $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_mini');
6735 6735
                 else if ((string) $imagesize == 'small')
6736
-                    $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_small');
6736
+                    $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.getImageFileNameForSize($object->photo, '_small');
6737 6737
                 else
6738
-                    $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo;
6739
-                $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo;
6738
+                    $file = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
6739
+                $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart).'photos/'.$object->photo;
6740 6740
             }
6741 6741
             if (!empty($conf->global->MAIN_OLD_IMAGE_LINKS))
6742
-                $altfile = $object->id . ".jpg"; // For backward compatibility
6742
+                $altfile = $object->id.".jpg"; // For backward compatibility
6743 6743
             $email = $object->email;
6744 6744
         }
6745 6745
 
@@ -6747,27 +6747,27 @@  discard block
 block discarded – undo
6747 6747
             $capture = $forcecapture;
6748 6748
 
6749 6749
         if ($dir) {
6750
-            if ($file && file_exists($dir . "/" . $file)) {
6750
+            if ($file && file_exists($dir."/".$file)) {
6751 6751
                 if ($addlinktofullsize) {
6752
-                    $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity=' . $entity);
6752
+                    $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity);
6753 6753
                     if ($urladvanced)
6754
-                        $ret .= '<a href="' . $urladvanced . '">';
6754
+                        $ret .= '<a href="'.$urladvanced.'">';
6755 6755
                     else
6756
-                        $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">';
6756
+                        $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
6757 6757
                 }
6758
-                $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Photo" id="photologo' . (preg_replace('/[^a-z]/i', '_', $file)) . '" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($file) . '&cache=' . $cache . '">';
6758
+                $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="Photo" id="photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($file).'&cache='.$cache.'">';
6759 6759
                 if ($addlinktofullsize)
6760 6760
                     $ret .= '</a>';
6761 6761
             }
6762
-            else if ($altfile && file_exists($dir . "/" . $altfile)) {
6762
+            else if ($altfile && file_exists($dir."/".$altfile)) {
6763 6763
                 if ($addlinktofullsize) {
6764
-                    $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity=' . $entity);
6764
+                    $urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 0, '&entity='.$entity);
6765 6765
                     if ($urladvanced)
6766
-                        $ret .= '<a href="' . $urladvanced . '">';
6766
+                        $ret .= '<a href="'.$urladvanced.'">';
6767 6767
                     else
6768
-                        $ret .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($originalfile) . '&cache=' . $cache . '">';
6768
+                        $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
6769 6769
                 }
6770
-                $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Photo alt" id="photologo' . (preg_replace('/[^a-z]/i', '_', $file)) . '" class="' . $cssclass . '" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=' . $modulepart . '&entity=' . $entity . '&file=' . urlencode($altfile) . '&cache=' . $cache . '">';
6770
+                $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="Photo alt" id="photologo'.(preg_replace('/[^a-z]/i', '_', $file)).'" class="'.$cssclass.'" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($altfile).'&cache='.$cache.'">';
6771 6771
                 if ($addlinktofullsize)
6772 6772
                     $ret .= '</a>';
6773 6773
             }
@@ -6791,10 +6791,10 @@  discard block
 block discarded – undo
6791 6791
                     $ret .= '<!-- Put link to gravatar -->';
6792 6792
                     //$defaultimg=urlencode(dol_buildpath($nophoto,3));
6793 6793
                     $defaultimg = 'mm';
6794
-                    $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="Gravatar avatar" title="' . $email . ' Gravatar avatar" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="https://www.gravatar.com/avatar/' . dol_hash(strtolower(trim($email)), 3) . '?s=' . $width . '&d=' . $defaultimg . '">'; // gravatar need md5 hash
6794
+                    $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="Gravatar avatar" title="'.$email.' Gravatar avatar" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="https://www.gravatar.com/avatar/'.dol_hash(strtolower(trim($email)), 3).'?s='.$width.'&d='.$defaultimg.'">'; // gravatar need md5 hash
6795 6795
                 } else {
6796 6796
                     //$ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '">';
6797
-                    $ret .= '<img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" ' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '">';
6797
+                    $ret .= '<img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" '.($width ? ' width="'.$width.'"' : '').($height ? ' height="'.$height.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'">';
6798 6798
                 }
6799 6799
             }
6800 6800
 
@@ -6804,13 +6804,13 @@  discard block
 block discarded – undo
6804 6804
                 }
6805 6805
                 $ret .= '<table class="nobordernopadding centpercent">';
6806 6806
                 if ($object->photo) {
6807
-                    $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> ' . $langs->trans("Delete") . '<br><br></td></tr>';
6807
+                    $ret .= '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
6808 6808
                 }
6809
-                $ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"' . ($capture ? ' capture="' . $capture . '"' : '') . '></td></tr>';
6809
+                $ret .= '<tr><td class="tdoverflow"><input type="file" class="flat maxwidth200onsmartphone" name="photo" id="photoinput"'.($capture ? ' capture="'.$capture.'"' : '').'></td></tr>';
6810 6810
                 $ret .= '</table>';
6811 6811
             }
6812 6812
         } else
6813
-            dol_print_error('', 'Call of showphoto with wrong parameters modulepart=' . $modulepart);
6813
+            dol_print_error('', 'Call of showphoto with wrong parameters modulepart='.$modulepart);
6814 6814
 
6815 6815
         return $ret;
6816 6816
     }
@@ -6853,37 +6853,37 @@  discard block
 block discarded – undo
6853 6853
         if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
6854 6854
             $sql .= ", e.label";
6855 6855
         }
6856
-        $sql .= " FROM " . MAIN_DB_PREFIX . "usergroup as ug ";
6856
+        $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug ";
6857 6857
         if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && $user->admin && !$user->entity) {
6858
-            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "entity as e ON e.rowid=ug.entity";
6858
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=ug.entity";
6859 6859
             if ($force_entity)
6860
-                $sql .= " WHERE ug.entity IN (0," . $force_entity . ")";
6860
+                $sql .= " WHERE ug.entity IN (0,".$force_entity.")";
6861 6861
             else
6862 6862
                 $sql .= " WHERE ug.entity IS NOT NULL";
6863 6863
         }
6864 6864
         else {
6865
-            $sql .= " WHERE ug.entity IN (0," . $conf->entity . ")";
6865
+            $sql .= " WHERE ug.entity IN (0,".$conf->entity.")";
6866 6866
         }
6867 6867
         if (is_array($exclude) && $excludeGroups)
6868
-            $sql .= " AND ug.rowid NOT IN ('" . $excludeGroups . "')";
6868
+            $sql .= " AND ug.rowid NOT IN ('".$excludeGroups."')";
6869 6869
         if (is_array($include) && $includeGroups)
6870
-            $sql .= " AND ug.rowid IN ('" . $includeGroups . "')";
6870
+            $sql .= " AND ug.rowid IN ('".$includeGroups."')";
6871 6871
         $sql .= " ORDER BY ug.nom ASC";
6872 6872
 
6873
-        dol_syslog(get_class($this) . "::select_dolgroups", LOG_DEBUG);
6873
+        dol_syslog(get_class($this)."::select_dolgroups", LOG_DEBUG);
6874 6874
         $resql = $this->db->query($sql);
6875 6875
         if ($resql) {
6876 6876
             // Enhance with select2
6877
-            include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php';
6877
+            include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
6878 6878
             $out .= ajax_combobox($htmlname);
6879 6879
 
6880
-            $out .= '<select class="flat minwidth200" id="' . $htmlname . '" name="' . $htmlname . ($multiple ? '[]' : '') . '" ' . ($multiple ? 'multiple' : '') . ' ' . ($disabled ? ' disabled' : '') . '>';
6880
+            $out .= '<select class="flat minwidth200" id="'.$htmlname.'" name="'.$htmlname.($multiple ? '[]' : '').'" '.($multiple ? 'multiple' : '').' '.($disabled ? ' disabled' : '').'>';
6881 6881
 
6882 6882
             $num = $this->db->num_rows($resql);
6883 6883
             $i = 0;
6884 6884
             if ($num) {
6885 6885
                 if ($show_empty && !$multiple)
6886
-                    $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '>&nbsp;</option>' . "\n";
6886
+                    $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'>&nbsp;</option>'."\n";
6887 6887
 
6888 6888
                 while ($i < $num) {
6889 6889
                     $obj = $this->db->fetch_object($resql);
@@ -6891,17 +6891,17 @@  discard block
 block discarded – undo
6891 6891
                     if (is_array($enableonly) && count($enableonly) && !in_array($obj->rowid, $enableonly))
6892 6892
                         $disableline = 1;
6893 6893
 
6894
-                    $out .= '<option value="' . $obj->rowid . '"';
6894
+                    $out .= '<option value="'.$obj->rowid.'"';
6895 6895
                     if ($disableline)
6896 6896
                         $out .= ' disabled';
6897
-                    if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected) )) {
6897
+                    if ((is_object($selected[0]) && $selected[0]->id == $obj->rowid) || (!is_object($selected[0]) && in_array($obj->rowid, $selected))) {
6898 6898
                         $out .= ' selected';
6899 6899
                     }
6900 6900
                     $out .= '>';
6901 6901
 
6902 6902
                     $out .= $obj->name;
6903 6903
                     if (!empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1) {
6904
-                        $out .= " (" . $obj->label . ")";
6904
+                        $out .= " (".$obj->label.")";
6905 6905
                     }
6906 6906
 
6907 6907
                     $out .= '</option>';
@@ -6909,8 +6909,8 @@  discard block
 block discarded – undo
6909 6909
                 }
6910 6910
             } else {
6911 6911
                 if ($show_empty)
6912
-                    $out .= '<option value="-1"' . (in_array(-1, $selected) ? ' selected' : '') . '></option>' . "\n";
6913
-                $out .= '<option value="" disabled>' . $langs->trans("NoUserGroupDefined") . '</option>';
6912
+                    $out .= '<option value="-1"'.(in_array(-1, $selected) ? ' selected' : '').'></option>'."\n";
6913
+                $out .= '<option value="" disabled>'.$langs->trans("NoUserGroupDefined").'</option>';
6914 6914
             }
6915 6915
             $out .= '</select>';
6916 6916
         }
@@ -6931,8 +6931,8 @@  discard block
 block discarded – undo
6931 6931
         global $conf, $langs;
6932 6932
 
6933 6933
         $out = '<div class="nowrap">';
6934
-        $out .= '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
6935
-        $out .= '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
6934
+        $out .= '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
6935
+        $out .= '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
6936 6936
         $out .= '</div>';
6937 6937
 
6938 6938
         return $out;
@@ -6957,12 +6957,12 @@  discard block
 block discarded – undo
6957 6957
             	$("#checkallactions").click(function() {
6958 6958
                     if($(this).is(\':checked\')){
6959 6959
                         console.log("We check all");
6960
-                		$(".' . $cssclass . '").prop(\'checked\', true).trigger(\'change\');
6960
+                		$(".' . $cssclass.'").prop(\'checked\', true).trigger(\'change\');
6961 6961
                     }
6962 6962
                     else
6963 6963
                     {
6964 6964
                         console.log("We uncheck all");
6965
-                		$(".' . $cssclass . '").prop(\'checked\', false).trigger(\'change\');
6965
+                		$(".' . $cssclass.'").prop(\'checked\', false).trigger(\'change\');
6966 6966
                     }' . "\n";
6967 6967
         if ($calljsfunction)
6968 6968
             $out .= 'if (typeof initCheckForSelect == \'function\') { initCheckForSelect(0); } else { console.log("No function initCheckForSelect found. Call won\'t be done."); }';
@@ -7011,64 +7011,64 @@  discard block
 block discarded – undo
7011 7011
     {
7012 7012
         global $db, $conf, $langs, $user;
7013 7013
 
7014
-        $sql = 'SELECT rowid, label FROM ' . MAIN_DB_PREFIX . 'c_exp_tax_cat WHERE active = 1';
7015
-        $sql .= ' AND entity IN (0,' . getEntity('exp_tax_cat') . ')';
7014
+        $sql = 'SELECT rowid, label FROM '.MAIN_DB_PREFIX.'c_exp_tax_cat WHERE active = 1';
7015
+        $sql .= ' AND entity IN (0,'.getEntity('exp_tax_cat').')';
7016 7016
         if (!empty($excludeid))
7017
-            $sql .= ' AND rowid NOT IN (' . implode(',', $excludeid) . ')';
7017
+            $sql .= ' AND rowid NOT IN ('.implode(',', $excludeid).')';
7018 7018
         $sql .= ' ORDER BY label';
7019 7019
 
7020 7020
         $resql = $db->query($sql);
7021 7021
         if ($resql) {
7022
-            $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">';
7022
+            $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
7023 7023
             if ($useempty)
7024 7024
                 $out .= '<option value="0">&nbsp;</option>';
7025 7025
 
7026 7026
             while ($obj = $db->fetch_object($resql)) {
7027
-                $out .= '<option ' . ($selected == $obj->rowid ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . $langs->trans($obj->label) . '</option>';
7027
+                $out .= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.$langs->trans($obj->label).'</option>';
7028 7028
             }
7029 7029
             $out .= '</select>';
7030 7030
             if (!empty($htmlname) && $user->admin)
7031
-                $out .= ' ' . info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
7031
+                $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
7032 7032
 
7033 7033
             if (!empty($target)) {
7034
-                $sql = "SELECT c.id FROM " . MAIN_DB_PREFIX . "c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
7034
+                $sql = "SELECT c.id FROM ".MAIN_DB_PREFIX."c_type_fees as c WHERE c.code = 'EX_KME' AND c.active = 1";
7035 7035
                 $resql = $db->query($sql);
7036 7036
                 if ($resql) {
7037 7037
                     if ($db->num_rows($resql) > 0) {
7038 7038
                         $obj = $db->fetch_object($resql);
7039 7039
                         $out .= '<script type="text/javascript">
7040 7040
 							$(function() {
7041
-								$("select[name=' . $target . ']").on("change", function() {
7041
+								$("select[name=' . $target.']").on("change", function() {
7042 7042
 									var current_val = $(this).val();
7043
-									if (current_val == ' . $obj->id . ') {';
7043
+									if (current_val == ' . $obj->id.') {';
7044 7044
                         if (!empty($default_selected) || !empty($selected))
7045
-                            $out .= '$("select[name=' . $htmlname . ']").val("' . ($default_selected > 0 ? $default_selected : $selected) . '");';
7045
+                            $out .= '$("select[name='.$htmlname.']").val("'.($default_selected > 0 ? $default_selected : $selected).'");';
7046 7046
 
7047 7047
                         $out .= '
7048
-										$("select[name=' . $htmlname . ']").change();
7048
+										$("select[name=' . $htmlname.']").change();
7049 7049
 									}
7050 7050
 								});
7051 7051
 
7052
-								$("select[name=' . $htmlname . ']").change(function() {
7052
+								$("select[name=' . $htmlname.']").change(function() {
7053 7053
 
7054
-									if ($("select[name=' . $target . ']").val() == ' . $obj->id . ') {
7054
+									if ($("select[name=' . $target.']").val() == '.$obj->id.') {
7055 7055
 										// get price of kilometer to fill the unit price
7056
-										var data = ' . json_encode($params) . ';
7056
+										var data = ' . json_encode($params).';
7057 7057
 										data.fk_c_exp_tax_cat = $(this).val();
7058 7058
 
7059 7059
 										$.ajax({
7060 7060
 											method: "POST",
7061 7061
 											dataType: "json",
7062 7062
 											data: data,
7063
-											url: "' . (DOL_URL_ROOT . '/expensereport/ajax/ajaxik.php') . '",
7063
+											url: "' . (DOL_URL_ROOT.'/expensereport/ajax/ajaxik.php').'",
7064 7064
 										}).done(function( data, textStatus, jqXHR ) {
7065 7065
 											console.log(data);
7066 7066
 											if (typeof data.up != "undefined") {
7067 7067
 												$("input[name=value_unit]").val(data.up);
7068
-												$("select[name=' . $htmlname . ']").attr("title", data.title);
7068
+												$("select[name=' . $htmlname.']").attr("title", data.title);
7069 7069
 											} else {
7070 7070
 												$("input[name=value_unit]").val("");
7071
-												$("select[name=' . $htmlname . ']").attr("title", "");
7071
+												$("select[name=' . $htmlname.']").attr("title", "");
7072 7072
 											}
7073 7073
 										});
7074 7074
 									}
@@ -7098,17 +7098,17 @@  discard block
 block discarded – undo
7098 7098
     {
7099 7099
         global $db, $conf, $langs;
7100 7100
 
7101
-        $sql = 'SELECT rowid, range_ik FROM ' . MAIN_DB_PREFIX . 'c_exp_tax_range';
7102
-        $sql .= ' WHERE entity = ' . $conf->entity . ' AND active = 1';
7101
+        $sql = 'SELECT rowid, range_ik FROM '.MAIN_DB_PREFIX.'c_exp_tax_range';
7102
+        $sql .= ' WHERE entity = '.$conf->entity.' AND active = 1';
7103 7103
 
7104 7104
         $resql = $db->query($sql);
7105 7105
         if ($resql) {
7106
-            $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">';
7106
+            $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
7107 7107
             if ($useempty)
7108 7108
                 $out .= '<option value="0"></option>';
7109 7109
 
7110 7110
             while ($obj = $db->fetch_object($resql)) {
7111
-                $out .= '<option ' . ($selected == $obj->rowid ? 'selected="selected"' : '') . ' value="' . $obj->rowid . '">' . price($obj->range_ik, 0, $langs, 1, 0) . '</option>';
7111
+                $out .= '<option '.($selected == $obj->rowid ? 'selected="selected"' : '').' value="'.$obj->rowid.'">'.price($obj->range_ik, 0, $langs, 1, 0).'</option>';
7112 7112
             }
7113 7113
             $out .= '</select>';
7114 7114
         } else {
@@ -7132,16 +7132,16 @@  discard block
 block discarded – undo
7132 7132
     {
7133 7133
         global $db, $langs;
7134 7134
 
7135
-        $sql = 'SELECT id, code, label FROM ' . MAIN_DB_PREFIX . 'c_type_fees';
7135
+        $sql = 'SELECT id, code, label FROM '.MAIN_DB_PREFIX.'c_type_fees';
7136 7136
         $sql .= ' WHERE active = 1';
7137 7137
 
7138 7138
         $resql = $db->query($sql);
7139 7139
         if ($resql) {
7140
-            $out = '<select id="select_' . $htmlname . '" name="' . $htmlname . '" class="' . $htmlname . ' flat minwidth75imp">';
7140
+            $out = '<select id="select_'.$htmlname.'" name="'.$htmlname.'" class="'.$htmlname.' flat minwidth75imp">';
7141 7141
             if ($useempty)
7142 7142
                 $out .= '<option value="0"></option>';
7143 7143
             if ($allchoice)
7144
-                $out .= '<option value="-1">' . $langs->trans('AllExpenseReport') . '</option>';
7144
+                $out .= '<option value="-1">'.$langs->trans('AllExpenseReport').'</option>';
7145 7145
 
7146 7146
             $field = 'code';
7147 7147
             if ($useid)
@@ -7149,7 +7149,7 @@  discard block
 block discarded – undo
7149 7149
 
7150 7150
             while ($obj = $db->fetch_object($resql)) {
7151 7151
                 $key = $langs->trans($obj->code);
7152
-                $out .= '<option ' . ($selected == $obj->{$field} ? 'selected="selected"' : '') . ' value="' . $obj->{$field} . '">' . ($key != $obj->code ? $key : $obj->label) . '</option>';
7152
+                $out .= '<option '.($selected == $obj->{$field} ? 'selected="selected"' : '').' value="'.$obj->{$field}.'">'.($key != $obj->code ? $key : $obj->label).'</option>';
7153 7153
             }
7154 7154
             $out .= '</select>';
7155 7155
         } else {
Please login to merge, or discard this patch.
Base/Interfaces.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 class Interfaces
25 25
 {
26 26
 
27
-    var $dir;    // Directory with all core and external triggers files
27
+    var $dir; // Directory with all core and external triggers files
28 28
 
29 29
     /**
30 30
      * @var string[] Error codes (or messages)
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
         // phpcs:enable
59 59
         // Check parameters
60 60
         if (!is_object($object) || !is_object($conf)) { // Error
61
-            $this->error = 'function run_triggers called with wrong parameters action=' . $action . ' object=' . is_object($object) . ' user=' . is_object($user) . ' langs=' . is_object($langs) . ' conf=' . is_object($conf);
62
-            DolUtils::dol_syslog(get_class($this) . '::run_triggers ' . $this->error, LOG_ERR);
61
+            $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf);
62
+            DolUtils::dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR);
63 63
             $this->errors[] = $this->error;
64 64
             return -1;
65 65
         }
66 66
         if (!is_object($langs)) { // Warning
67
-            DolUtils::dol_syslog(get_class($this) . '::run_triggers was called with wrong parameters action=' . $action . ' object=' . is_object($object) . ' user=' . is_object($user) . ' langs=' . is_object($langs) . ' conf=' . is_object($conf), LOG_WARNING);
67
+            DolUtils::dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING);
68 68
         }
69 69
         if (!is_object($user)) {     // Warning
70
-            DolUtils::dol_syslog(get_class($this) . '::run_triggers was called with wrong parameters action=' . $action . ' object=' . is_object($object) . ' user=' . is_object($user) . ' langs=' . is_object($langs) . ' conf=' . is_object($conf), LOG_WARNING);
70
+            DolUtils::dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING);
71 71
             global $db;
72 72
             $user = new User($db);
73 73
         }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $i = 0;
81 81
 
82 82
         // $dirtriggers = array_merge(array('/core/triggers'), $conf->modules_parts['triggers']);
83
-        $dirtriggers = array_merge(array(BASE_PATH . '/Helpers/triggers'), $conf->modules_parts['triggers']);
83
+        $dirtriggers = array_merge(array(BASE_PATH.'/Helpers/triggers'), $conf->modules_parts['triggers']);
84 84
         foreach ($dirtriggers as $reldir) {
85 85
             //$dir = DolUtils::dol_buildpath($reldir, 0);
86 86
             //$newdir = DolUtils::dol_osencode($dir);
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
             $handle = opendir($newdir);
94 94
             if (is_resource($handle)) {
95 95
                 while (($file = readdir($handle)) !== false) {
96
-                    if (is_readable($newdir . "/" . $file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) {
96
+                    if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) {
97 97
                         $part1 = $reg[1];
98 98
                         $part2 = $reg[2];
99 99
                         $part3 = $reg[3];
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                         $qualified = true;
108 108
                         if (strtolower($reg[2]) != 'all') {
109 109
                             $module = preg_replace('/^mod/i', '', $reg[2]);
110
-                            $constparam = 'MAIN_MODULE_' . strtoupper($module);
110
+                            $constparam = 'MAIN_MODULE_'.strtoupper($module);
111 111
                             if (empty($conf->global->$constparam))
112 112
                                 $qualified = false;
113 113
                         }
@@ -117,26 +117,26 @@  discard block
 block discarded – undo
117 117
                             continue;
118 118
                         }
119 119
 
120
-                        $modName = "Interface" . ucfirst($reg[3]);
120
+                        $modName = "Interface".ucfirst($reg[3]);
121 121
                         //print "file=$file - modName=$modName\n";
122 122
                         if (in_array($modName, $modules)) {    // $modules = list of modName already loaded
123 123
                             $langs->load("errors");
124
-                            DolUtils::dol_syslog(get_class($this) . "::run_triggers action=" . $action . " " . $langs->trans("ErrorDuplicateTrigger", $newdir . "/" . $file, $fullpathfiles[$modName]), LOG_WARNING);
124
+                            DolUtils::dol_syslog(get_class($this)."::run_triggers action=".$action." ".$langs->trans("ErrorDuplicateTrigger", $newdir."/".$file, $fullpathfiles[$modName]), LOG_WARNING);
125 125
                             continue;
126 126
                         }
127 127
 
128 128
                         try {
129 129
                             //print 'Todo for '.$modName." : ".$newdir.'/'.$file."\n";
130
-                            include_once $newdir . '/' . $file;
130
+                            include_once $newdir.'/'.$file;
131 131
                             //print 'Done for '.$modName."\n";
132 132
                         } catch (Exception $e) {
133
-                            DolUtils::dol_syslog('ko for ' . $modName . " " . $e->getMessage() . "\n", LOG_ERR);
133
+                            DolUtils::dol_syslog('ko for '.$modName." ".$e->getMessage()."\n", LOG_ERR);
134 134
                         }
135 135
 
136 136
                         $modules[$i] = $modName;
137 137
                         $files[$i] = $file;
138
-                        $fullpathfiles[$modName] = $newdir . '/' . $file;
139
-                        $orders[$i] = $part1 . '_' . $part2 . '_' . $part3;   // Set sort criteria value
138
+                        $fullpathfiles[$modName] = $newdir.'/'.$file;
139
+                        $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value
140 140
 
141 141
                         $i++;
142 142
                     }
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
                     //DolUtils::dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG);
161 161
                     $result = $objMod->runTrigger($action, $object, $user, $langs, $conf);
162 162
                 } elseif (method_exists($objMod, 'run_trigger')) { // Deprecated method
163
-                    DolUtils::dol_syslog(get_class($this) . "::run_triggers action=" . $action . " Launch old method run_trigger (rename your trigger into runTrigger) for file '" . $files[$key] . "'", LOG_WARNING);
163
+                    DolUtils::dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING);
164 164
                     $result = $objMod->run_trigger($action, $object, $user, $langs, $conf);
165 165
                 } else {
166
-                    DolUtils::dol_syslog(get_class($this) . "::run_triggers action=" . $action . " A trigger was declared for class " . get_class($objMod) . " but method runTrigger was not found", LOG_ERR);
166
+                    DolUtils::dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR);
167 167
                 }
168 168
 
169 169
                 if ($result > 0) {
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
                 }
189 189
             }
190 190
             else {
191
-                DolUtils::dol_syslog(get_class($this) . "::run_triggers action=" . $action . " Failed to instantiate trigger for file '" . $files[$key] . "'", LOG_ERR);
191
+                DolUtils::dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR);
192 192
             }
193 193
         }
194 194
 
195 195
         if ($nbko) {
196
-            DolUtils::dol_syslog(get_class($this) . "::run_triggers action=" . $action . " Files found: " . $nbfile . ", Files launched: " . $nbtotal . ", Done: " . $nbok . ", Failed: " . $nbko . " - Nb of error string returned in this->errors = " . count($this->errors), LOG_ERR);
196
+            DolUtils::dol_syslog(get_class($this)."::run_triggers action=".$action." Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko." - Nb of error string returned in this->errors = ".count($this->errors), LOG_ERR);
197 197
             return -$nbko;
198 198
         } else {
199 199
             //DolUtils::dol_syslog(get_class($this)."::run_triggers Files found: ".$nbfile.", Files launched: ".$nbtotal.", Done: ".$nbok.", Failed: ".$nbko, LOG_DEBUG);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             $handle = opendir($newdir);
237 237
             if (is_resource($handle)) {
238 238
                 while (($file = readdir($handle)) !== false) {
239
-                    if (is_readable($newdir . '/' . $file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) {
239
+                    if (is_readable($newdir.'/'.$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/', $file, $reg)) {
240 240
                         if (preg_match('/\.back$/', $file))
241 241
                             continue;
242 242
 
@@ -244,21 +244,21 @@  discard block
 block discarded – undo
244 244
                         $part2 = $reg[2];
245 245
                         $part3 = $reg[3];
246 246
 
247
-                        $modName = 'Interface' . ucfirst($reg[3]);
247
+                        $modName = 'Interface'.ucfirst($reg[3]);
248 248
                         //print "file=$file"; print "modName=$modName"; exit;
249 249
                         if (in_array($modName, $modules)) {
250 250
                             $langs->load("errors");
251
-                            print '<div class="error">' . $langs->trans("Error") . ' : ' . $langs->trans("ErrorDuplicateTrigger", $modName, "/htdocs/core/triggers/") . '</div>';
251
+                            print '<div class="error">'.$langs->trans("Error").' : '.$langs->trans("ErrorDuplicateTrigger", $modName, "/htdocs/core/triggers/").'</div>';
252 252
                         } else {
253
-                            include_once $newdir . '/' . $file;
253
+                            include_once $newdir.'/'.$file;
254 254
                         }
255 255
 
256 256
                         $files[$i] = $file;
257
-                        $fullpath[$i] = $dir . '/' . $file;
258
-                        $relpath[$i] = preg_replace('/^\//', '', $reldir) . '/' . $file;
257
+                        $fullpath[$i] = $dir.'/'.$file;
258
+                        $relpath[$i] = preg_replace('/^\//', '', $reldir).'/'.$file;
259 259
                         $iscoreorexternal[$i] = ($reldir == '/core/triggers/' ? 'internal' : 'external');
260 260
                         $modules[$i] = $modName;
261
-                        $orders[$i] = $part1 . '_' . $part2 . '_' . $part3;   // Set sort criteria value
261
+                        $orders[$i] = $part1.'_'.$part2.'_'.$part3; // Set sort criteria value
262 262
 
263 263
                         $i++;
264 264
                     }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                 continue;
280 280
 
281 281
             if (!class_exists($modName)) {
282
-                print 'Error: A trigger file was found but its class "' . $modName . '" was not found.' . "<br>\n";
282
+                print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."<br>\n";
283 283
                 continue;
284 284
             }
285 285
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
             // Check if trigger file is for a particular module
297 297
             if (preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php/i', $files[$key], $reg)) {
298 298
                 $module = preg_replace('/^mod/i', '', $reg[2]);
299
-                $constparam = 'MAIN_MODULE_' . strtoupper($module);
299
+                $constparam = 'MAIN_MODULE_'.strtoupper($module);
300 300
                 if (strtolower($module) == 'all')
301 301
                     $disabledbymodule = 0;
302 302
                 else if (empty($conf->global->$constparam))
@@ -315,21 +315,21 @@  discard block
 block discarded – undo
315 315
             if ($disabledbyname > 0 || $disabledbymodule > 1)
316 316
                 $triggers[$j]['status'] = '';
317 317
 
318
-            $text = '<b>' . $langs->trans("Description") . ':</b><br>';
319
-            $text .= $objMod->getDesc() . '<br>';
320
-            $text .= '<br><b>' . $langs->trans("Status") . ':</b><br>';
318
+            $text = '<b>'.$langs->trans("Description").':</b><br>';
319
+            $text .= $objMod->getDesc().'<br>';
320
+            $text .= '<br><b>'.$langs->trans("Status").':</b><br>';
321 321
             if ($disabledbyname == 1) {
322
-                $text .= $langs->trans("TriggerDisabledByName") . '<br>';
322
+                $text .= $langs->trans("TriggerDisabledByName").'<br>';
323 323
                 if ($disabledbymodule == 2)
324
-                    $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module) . '<br>';
324
+                    $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>';
325 325
             }
326 326
             else {
327 327
                 if ($disabledbymodule == 0)
328
-                    $text .= $langs->trans("TriggerAlwaysActive") . '<br>';
328
+                    $text .= $langs->trans("TriggerAlwaysActive").'<br>';
329 329
                 if ($disabledbymodule == 1)
330
-                    $text .= $langs->trans("TriggerActiveAsModuleActive", $module) . '<br>';
330
+                    $text .= $langs->trans("TriggerActiveAsModuleActive", $module).'<br>';
331 331
                 if ($disabledbymodule == 2)
332
-                    $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module) . '<br>';
332
+                    $text .= $langs->trans("TriggerDisabledAsModuleDisabled", $module).'<br>';
333 333
             }
334 334
 
335 335
             $triggers[$j]['info'] = $text;
Please login to merge, or discard this patch.
Base/Langs.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 class Langs
22 22
 {
23 23
 
24
-    public $dir;                          // Directories that contains /langs subdirectory
25
-    public $defaultlang;                  // Current language for current user
26
-    public $charset_output = 'UTF-8';       // Codage used by "trans" method outputs
27
-    public $tab_translate = array();        // Array of all translations key=>value
28
-    private $_tab_loaded = array();         // Array to store result after loading each language file
29
-    public $cache_labels = array();         // Cache for labels return by getLabelFromKey method
30
-    public $cache_currencies = array();     // Cache to store currency symbols
24
+    public $dir; // Directories that contains /langs subdirectory
25
+    public $defaultlang; // Current language for current user
26
+    public $charset_output = 'UTF-8'; // Codage used by "trans" method outputs
27
+    public $tab_translate = array(); // Array of all translations key=>value
28
+    private $_tab_loaded = array(); // Array to store result after loading each language file
29
+    public $cache_labels = array(); // Cache for labels return by getLabelFromKey method
30
+    public $cache_currencies = array(); // Cache to store currency symbols
31 31
     private $cache_currencies_all_loaded = false;
32 32
 
33 33
     /**
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
             $more = array();
61 61
             $i = 0;
62 62
             foreach ($conf->file->dol_document_root as $dir) {
63
-                $newdir = $dir . $conf->global->MAIN_FORCELANGDIR;    // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
63
+                $newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
64 64
                 if (!in_array($newdir, $this->dir)) {
65
-                    $more['module_' . $i] = $newdir;
66
-                    $i++;   // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
65
+                    $more['module_'.$i] = $newdir;
66
+                    $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
67 67
                 }
68 68
             }
69
-            $this->dir = array_merge($more, $this->dir);    // Forced dir ($more) are before standard dirs ($this->dir)
69
+            $this->dir = array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
70 70
         }
71 71
 
72 72
         $this->origlang = $srclang;
@@ -90,12 +90,12 @@  discard block
 block discarded – undo
90 90
             if (isset($longforshort[strtolower($langpart[0])]) && !in_array($codetouse, $longforshortexcep))
91 91
                 $srclang = $longforshort[strtolower($langpart[0])];
92 92
             else if (!is_numeric($langpart[1])) {  // Second part YY may be a numeric with some Chrome browser
93
-                $srclang = strtolower($langpart[0]) . "_" . strtoupper($langpart[1]);
93
+                $srclang = strtolower($langpart[0])."_".strtoupper($langpart[1]);
94 94
                 $longforlong = array('no_nb' => 'nb_NO');
95 95
                 if (isset($longforlong[strtolower($srclang)]))
96 96
                     $srclang = $longforlong[strtolower($srclang)];
97 97
             } else
98
-                $srclang = strtolower($langpart[0]) . "_" . strtoupper($langpart[0]);
98
+                $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
99 99
         }
100 100
         else {      // If it's for a codetouse that is a short code xx
101 101
             // Array to convert short lang code into long code.
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             if (isset($longforshort[strtolower($langpart[0])]))
104 104
                 $srclang = $longforshort[strtolower($langpart[0])];
105 105
             else if (!empty($langpart[0]))
106
-                $srclang = strtolower($langpart[0]) . "_" . strtoupper($langpart[0]);
106
+                $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
107 107
             else
108 108
                 $srclang = 'en_US';
109 109
         }
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
         //DolUtils::dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
168 168
         // Check parameters
169 169
         if (empty($domain)) {
170
-            dol_print_error('', get_class($this) . "::Load ErrorWrongParameters");
170
+            dol_print_error('', get_class($this)."::Load ErrorWrongParameters");
171 171
             return -1;
172 172
         }
173 173
         if ($this->defaultlang == 'none_NONE')
174
-            return 0;    // Special language code to not translate keys
174
+            return 0; // Special language code to not translate keys
175 175
 
176 176
 
177 177
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             
181 181
 // Load $this->tab_translate[] from database
182 182
         if (empty($loadfromfileonly) && count($this->tab_translate) == 0)
183
-            $this->loadFromDatabase($db);      // No translation was never loaded yet, so we load database.
183
+            $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
184 184
 
185 185
 
186 186
         $newdomain = $domain;
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
             $alt = 2;
210 210
 
211 211
         if (empty($langofdir)) { // This may occurs when load is called without setting the language and without providing a value for forcelangdir
212
-            DolUtils::dol_syslog("Error: " . get_class($this) . "::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
212
+            DolUtils::dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
213 213
             return -1;
214 214
         }
215 215
 
216 216
         foreach ($this->dir as $keydir => $searchdir) {
217 217
             // Directory of translation files
218
-            $file_lang = $searchdir . ($modulename ? '/' . $modulename : '') . "/langs/" . $langofdir . "/" . $newdomain . ".lang";
218
+            $file_lang = $searchdir.($modulename ? '/'.$modulename : '')."/langs/".$langofdir."/".$newdomain.".lang";
219 219
             $file_lang_osencoded = dol_osencode($file_lang);
220 220
 
221 221
             $filelangexists = is_file($file_lang_osencoded);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
                 $usecachekey = '';
232 232
                 // Using a memcached server
233 233
                 if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) {
234
-                    $usecachekey = $newdomain . '_' . $langofdir . '_' . md5($file_lang);    // Should not contains special chars
234
+                    $usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
235 235
                 }
236 236
                 // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
237 237
                 else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                     //DolUtils::dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
243 243
                     //global $aaa; $aaa+=1;
244 244
                     //print $aaa." ".$usecachekey."\n";
245
-                    require_once DOL_BASE_PATH . '/core/lib/memory.lib.php';
245
+                    require_once DOL_BASE_PATH.'/core/lib/memory.lib.php';
246 246
                     $tmparray = dol_getcache($usecachekey);
247 247
                     if (is_array($tmparray) && count($tmparray)) {
248 248
                         $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                         //var_dump($this->tab_translate);
251 251
                         if ($alt == 2)
252 252
                             $fileread = 1;
253
-                        $found = true;      // Found in dolibarr PHP cache
253
+                        $found = true; // Found in dolibarr PHP cache
254 254
                     }
255 255
                 }
256 256
 
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
                         if ($usecachekey && count($tabtranslatedomain)) {
301 301
                             $ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
302 302
                             if ($ressetcache < 0) {
303
-                                $error = 'Failed to set cache for usecachekey=' . $usecachekey . ' result=' . $ressetcache;
303
+                                $error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
304 304
                                 DolUtils::dol_syslog($error, LOG_ERR);
305 305
                             }
306 306
                         }
307 307
 
308 308
                         if (empty($conf->global->MAIN_FORCELANGDIR))
309
-                            break;  // Break loop on each root dir. If a module has forced dir, we do not stop loop.
309
+                            break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
310 310
                     }
311 311
                 }
312 312
             }
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
         if ($alt == 0) {
317 317
             // This function MUST NOT contains call to syslog
318 318
             //DolUtils::dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
319
-            $langofdir = strtolower($langarray[0]) . '_' . strtoupper($langarray[0]);
319
+            $langofdir = strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
320 320
             if ($langofdir == 'el_EL')
321
-                $langofdir = 'el_GR';                     // main parent for el_CY is not 'el_EL' but 'el_GR'
321
+                $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
322 322
             if ($langofdir == 'ar_AR')
323
-                $langofdir = 'ar_SA';                     // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
323
+                $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
324 324
             $this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
325 325
         }
326 326
 
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
         // We are in the pass of the reference file. No more files to scan to complete.
336 336
         if ($alt == 2) {
337 337
             if ($fileread)
338
-                $this->_tab_loaded[$newdomain] = 1;        // Set domain file as found so loaded
338
+                $this->_tab_loaded[$newdomain] = 1; // Set domain file as found so loaded
339 339
 
340 340
             if (empty($this->_tab_loaded[$newdomain]))
341 341
                 $this->_tab_loaded[$newdomain] = 2; // Set this file as not found
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
         // This part is deprecated and replaced with table llx_overwrite_trans
345 345
         // Kept for backward compatibility.
346 346
         if (empty($loadfromfileonly)) {
347
-            $overwritekey = 'MAIN_OVERWRITE_TRANS_' . $this->defaultlang;
347
+            $overwritekey = 'MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
348 348
             if (!empty($conf->global->$overwritekey)) {    // Overwrite translation with key1:newstring1,key2:newstring2
349 349
                 // Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX
350 350
                 $tmparray = explode(',', $conf->global->$overwritekey);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
         // Check parameters
385 385
         if (empty($db))
386
-            return 0;    // Database handler can't be used
386
+            return 0; // Database handler can't be used
387 387
 
388 388
 
389 389
 
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
             return 0;
401 401
         }
402 402
 
403
-        $this->_tab_loaded[$newdomain] = 1;   // We want to be sure this function is called once only for domain 'database'
403
+        $this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
404 404
 
405 405
         $fileread = 0;
406 406
         $langofdir = $this->defaultlang;
407 407
 
408 408
         if (empty($langofdir)) { // This may occurs when load is called without setting the language and without providing a value for forcelangdir
409
-            DolUtils::dol_syslog("Error: " . get_class($this) . "::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
409
+            DolUtils::dol_syslog("Error: ".get_class($this)."::Load was called but language was not set yet with langs->setDefaultLang(). Nothing will be loaded.", LOG_WARNING);
410 410
             return -1;
411 411
         }
412 412
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
         $usecachekey = '';
418 418
         // Using a memcached server
419 419
         if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER)) {
420
-            $usecachekey = $newdomain . '_' . $langofdir;    // Should not contains special chars
420
+            $usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars
421 421
         }
422 422
         // Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
423 423
         else if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
@@ -428,20 +428,20 @@  discard block
 block discarded – undo
428 428
             //DolUtils::dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
429 429
             //global $aaa; $aaa+=1;
430 430
             //print $aaa." ".$usecachekey."\n";
431
-            require_once DOL_BASE_PATH . '/core/lib/memory.lib.php';
431
+            require_once DOL_BASE_PATH.'/core/lib/memory.lib.php';
432 432
             $tmparray = dol_getcache($usecachekey);
433 433
             if (is_array($tmparray) && count($tmparray)) {
434 434
                 $this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
435 435
                 //print $newdomain."\n";
436 436
                 //var_dump($this->tab_translate);
437 437
                 $fileread = 1;
438
-                $found = true;      // Found in dolibarr PHP cache
438
+                $found = true; // Found in dolibarr PHP cache
439 439
             }
440 440
         }
441 441
 
442 442
         if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) {
443 443
             // Overwrite translation with database read
444
-            $sql = "SELECT transkey, transvalue FROM " . MAIN_DB_PREFIX . "overwrite_trans where lang='" . $db->escape($this->defaultlang) . "'";
444
+            $sql = "SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."'";
445 445
             $resql = $db->query($sql);
446 446
 
447 447
             if ($resql) {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
                     if ($usecachekey && count($tabtranslatedomain)) {
477 477
                         $ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
478 478
                         if ($ressetcache < 0) {
479
-                            $error = 'Failed to set cache for usecachekey=' . $usecachekey . ' result=' . $ressetcache;
479
+                            $error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
480 480
                             DolUtils::dol_syslog($error, LOG_ERR);
481 481
                         }
482 482
                     }
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
             $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded
491 491
 
492 492
         if (empty($this->_tab_loaded[$newdomain]))
493
-            $this->_tab_loaded[$newdomain] = 2;           // Marque ce cas comme non trouve (no lines found for language)
493
+            $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language)
494 494
 
495 495
         return 1;
496 496
     }
@@ -560,12 +560,12 @@  discard block
 block discarded – undo
560 560
             $str = $this->tab_translate[$key];
561 561
 
562 562
             // Make some string replacement after translation
563
-            $replacekey = 'MAIN_REPLACE_TRANS_' . $this->defaultlang;
563
+            $replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
564 564
             if (!empty($conf->global->$replacekey)) {    // Replacement translation variable with string1:newstring1;string2:newstring2
565 565
                 $tmparray = explode(';', $conf->global->$replacekey);
566 566
                 foreach ($tmparray as $tmp) {
567 567
                     $tmparray2 = explode(':', $tmp);
568
-                    $str = preg_replace('/' . preg_quote($tmparray2[0]) . '/', $tmparray2[1], $str);
568
+                    $str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
569 569
                 }
570 570
             }
571 571
 
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
             $str = $this->tab_translate[$key];
636 636
 
637 637
             // Make some string replacement after translation
638
-            $replacekey = 'MAIN_REPLACE_TRANS_' . $this->defaultlang;
638
+            $replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
639 639
             if (!empty($conf->global->$replacekey)) {    // Replacement translation variable with string1:newstring1;string2:newstring2
640 640
                 $tmparray = explode(';', $conf->global->$replacekey);
641 641
                 foreach ($tmparray as $tmp) {
642 642
                     $tmparray2 = explode(':', $tmp);
643
-                    $str = preg_replace('/' . preg_quote($tmparray2[0]) . '/', $tmparray2[1], $str);
643
+                    $str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
644 644
                 }
645 645
             }
646 646
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
         }
724 724
 
725 725
         // We scan directory langs to detect available languages
726
-        $handle = opendir($langdir . "/langs");
726
+        $handle = opendir($langdir."/langs");
727 727
         $langs_available = array();
728 728
         while ($dir = trim(readdir($handle))) {
729 729
             if (preg_match('/^[a-z]+_[A-Z]+/i', $dir)) {
@@ -733,9 +733,9 @@  discard block
 block discarded – undo
733 733
                     $langs_available[$dir] = $dir;
734 734
                 }
735 735
                 if ($usecode == 1 || !empty($conf->global->MAIN_SHOW_LANGUAGE_CODE)) {
736
-                    $langs_available[$dir] = $dir . ': ' . dol_trunc($this->trans('Language_' . $dir), $maxlength);
736
+                    $langs_available[$dir] = $dir.': '.dol_trunc($this->trans('Language_'.$dir), $maxlength);
737 737
                 } else {
738
-                    $langs_available[$dir] = $this->trans('Language_' . $dir);
738
+                    $langs_available[$dir] = $this->trans('Language_'.$dir);
739 739
                 }
740 740
             }
741 741
         }
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
         // phpcs:enable
756 756
         // Test si fichier dans repertoire de la langue
757 757
         foreach ($this->dir as $searchdir) {
758
-            if (is_readable(dol_osencode($searchdir . "/langs/" . $this->defaultlang . "/" . $filename)))
758
+            if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename)))
759 759
                 return true;
760 760
 
761 761
             if ($searchalt) {
762 762
                 // Test si fichier dans repertoire de la langue alternative
763 763
                 if ($this->defaultlang != "en_US")
764
-                    $filenamealt = $searchdir . "/langs/en_US/" . $filename;
764
+                    $filenamealt = $searchdir."/langs/en_US/".$filename;
765 765
                 //else $filenamealt = $searchdir."/langs/fr_FR/".$filename;
766 766
                 if (is_readable(dol_osencode($filenamealt)))
767 767
                     return true;
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
                 continue; // We must not use dol_is_dir here, function may not be loaded
799 799
 
800 800
             $fonc = 'numberwords';
801
-            if (file_exists($newdir . '/functions_' . $fonc . '.lib.php')) {
802
-                include_once $newdir . '/functions_' . $fonc . '.lib.php';
801
+            if (file_exists($newdir.'/functions_'.$fonc.'.lib.php')) {
802
+                include_once $newdir.'/functions_'.$fonc.'.lib.php';
803 803
                 $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount);
804 804
                 break;
805 805
             }
@@ -833,20 +833,20 @@  discard block
 block discarded – undo
833 833
         // Check if a translation is available (this can call getTradFromKey)
834 834
         $tmp = $this->transnoentitiesnoconv($key);
835 835
         if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString') {
836
-            return $tmp;    // Found in language array
836
+            return $tmp; // Found in language array
837 837
         }
838 838
 
839 839
         // Check in cache
840 840
         if (isset($this->cache_labels[$tablename][$key])) { // Can be defined to 0 or ''
841
-            return $this->cache_labels[$tablename][$key];   // Found in cache
841
+            return $this->cache_labels[$tablename][$key]; // Found in cache
842 842
         }
843 843
 
844
-        $sql = "SELECT " . $fieldlabel . " as label";
845
-        $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
846
-        $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($keyforselect ? $keyforselect : $key) . "'";
844
+        $sql = "SELECT ".$fieldlabel." as label";
845
+        $sql .= " FROM ".MAIN_DB_PREFIX.$tablename;
846
+        $sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'";
847 847
         if ($filteronentity)
848
-            $sql .= " AND entity IN (" . getEntity($tablename) . ')';
849
-        DolUtils::dol_syslog(get_class($this) . '::getLabelFromKey', LOG_DEBUG);
848
+            $sql .= " AND entity IN (".getEntity($tablename).')';
849
+        DolUtils::dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG);
850 850
         $resql = $db->query($sql);
851 851
         if ($resql) {
852 852
             $obj = $db->fetch_object($resql);
@@ -878,9 +878,9 @@  discard block
 block discarded – undo
878 878
         $symbol = $this->getCurrencySymbol($currency_code);
879 879
 
880 880
         if (in_array($currency_code, array('USD')))
881
-            return $symbol . $amount;
881
+            return $symbol.$amount;
882 882
         else
883
-            return $amount . $symbol;
883
+            return $amount.$symbol;
884 884
     }
885 885
 
886 886
     /**
@@ -919,18 +919,18 @@  discard block
 block discarded – undo
919 919
         global $db;
920 920
 
921 921
         if ($this->cache_currencies_all_loaded)
922
-            return 0;                                           // Cache already loaded for all
922
+            return 0; // Cache already loaded for all
923 923
         if (!empty($currency_code) && isset($this->cache_currencies[$currency_code]))
924
-            return 0;    // Cache already loaded for the currency
924
+            return 0; // Cache already loaded for the currency
925 925
 
926 926
         $sql = "SELECT code_iso, label, unicode";
927
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_currencies";
927
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_currencies";
928 928
         $sql .= " WHERE active = 1";
929 929
         if (!empty($currency_code))
930
-            $sql .= " AND code_iso = '" . $db->escape($currency_code) . "'";
930
+            $sql .= " AND code_iso = '".$db->escape($currency_code)."'";
931 931
         //$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later
932 932
 
933
-        DolUtils::dol_syslog(get_class($this) . '::loadCacheCurrencies', LOG_DEBUG);
933
+        DolUtils::dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG);
934 934
         $resql = $db->query($sql);
935 935
         if ($resql) {
936 936
             $this->load("dict");
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
                 $obj = $db->fetch_object($resql);
946 946
 
947 947
                 // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
948
-                $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency" . $obj->code_iso) != "Currency" . $obj->code_iso ? $this->trans("Currency" . $obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
948
+                $this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
949 949
                 $this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
950 950
                 $label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
951 951
                 $i++;
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
         $substitutionarray = array();
978 978
 
979 979
         foreach ($this->tab_translate as $code => $label) {
980
-            $substitutionarray['lang_' . $code] = $label;
981
-            $substitutionarray['__(' . $code . ')__'] = $label;
980
+            $substitutionarray['lang_'.$code] = $label;
981
+            $substitutionarray['__('.$code.')__'] = $label;
982 982
         }
983 983
 
984 984
         return $substitutionarray;
Please login to merge, or discard this patch.
Base/Categorie.php 1 patch
Spacing   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		'member'   => 'member',
109 109
 		'contact'  => 'socpeople',
110 110
 		'user'     => 'user',
111
-        'account'  => 'account',		// old for bank_account
111
+        'account'  => 'account', // old for bank_account
112 112
         'bank_account' => 'account',
113 113
         'project'  => 'project',
114 114
 	);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		'member'   => 'member',
126 126
 		'contact'  => 'contact',
127 127
 		'user'     => 'user',
128
-        'account'  => 'account',		// old for bank_account
128
+        'account'  => 'account', // old for bank_account
129 129
         'bank_account'=> 'account',
130 130
         'project'  => 'project',
131 131
 	);
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		'member'   => 'Adherent',
143 143
 		'contact'  => 'Contact',
144 144
 		'user'     => 'User',
145
-		'account'  => 'Account',		// old for bank account
145
+		'account'  => 'Account', // old for bank account
146 146
 		'bank_account'  => 'Account',
147 147
         'project'  => 'Project',
148 148
 	);
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	/**
167 167
 	 * @var string ID to identify managed object
168 168
 	 */
169
-	public $element='category';
169
+	public $element = 'category';
170 170
 
171 171
 	/**
172 172
 	 * @var string Name of table without prefix where object is stored
173 173
 	 */
174
-	public $table_element='categorie';
174
+	public $table_element = 'categorie';
175 175
 
176 176
 	/**
177 177
      * @var int ID
@@ -238,24 +238,24 @@  discard block
 block discarded – undo
238 238
 	 *  @param		string	$type	Type of category ('product', '...') or (0, 1, ...)
239 239
 	 * 	@return		int				<0 if KO, >0 if OK
240 240
 	 */
241
-	function fetch($id, $label='', $type=null)
241
+	function fetch($id, $label = '', $type = null)
242 242
 	{
243 243
 		global $conf;
244 244
 
245 245
 		// Check parameters
246 246
 		if (empty($id) && empty($label)) return -1;
247
-		if (! is_numeric($type)) $type=$this->MAP_ID[$type];
247
+		if (!is_numeric($type)) $type = $this->MAP_ID[$type];
248 248
 
249 249
 		$sql = "SELECT rowid, fk_parent, entity, label, description, color, fk_soc, visible, type";
250
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
250
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
251 251
 		if ($id > 0)
252 252
 		{
253
-			$sql.= " WHERE rowid = ".$id;
253
+			$sql .= " WHERE rowid = ".$id;
254 254
 		}
255 255
 		else
256 256
 		{
257
-			$sql.= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
258
-			if (! is_null($type)) $sql.= " AND type = ".$this->db->escape($type);
257
+			$sql .= " WHERE label = '".$this->db->escape($label)."' AND entity IN (".getEntity('category').")";
258
+			if (!is_null($type)) $sql .= " AND type = ".$this->db->escape($type);
259 259
 		}
260 260
 
261 261
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
@@ -266,16 +266,16 @@  discard block
 block discarded – undo
266 266
 			{
267 267
 				$res = $this->db->fetch_array($resql);
268 268
 
269
-				$this->id			= $res['rowid'];
269
+				$this->id = $res['rowid'];
270 270
 				//$this->ref			= $res['rowid'];
271 271
 				$this->fk_parent	= $res['fk_parent'];
272 272
 				$this->label		= $res['label'];
273
-				$this->description	= $res['description'];
273
+				$this->description = $res['description'];
274 274
 				$this->color    	= $res['color'];
275 275
 				$this->socid		= $res['fk_soc'];
276
-				$this->visible		= $res['visible'];
276
+				$this->visible = $res['visible'];
277 277
 				$this->type			= $res['type'];
278
-				$this->entity		= $res['entity'];
278
+				$this->entity = $res['entity'];
279 279
 
280 280
 				// Retreive all extrafield
281 281
 				// fetch optionals attributes and labels
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 				$this->db->free($resql);
285 285
 
286 286
 				// multilangs
287
-				if (! empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
287
+				if (!empty($conf->global->MAIN_MULTILANGS)) $this->getMultiLangs();
288 288
 
289 289
 				return 1;
290 290
 			}
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 	 */
312 312
 	function create($user)
313 313
 	{
314
-		global $conf,$langs,$hookmanager;
314
+		global $conf, $langs, $hookmanager;
315 315
 		$langs->load('categories');
316 316
 
317
-		$type=$this->type;
317
+		$type = $this->type;
318 318
 
319
-		if (! is_numeric($type)) $type=$this->MAP_ID[$type];
319
+		if (!is_numeric($type)) $type = $this->MAP_ID[$type];
320 320
 
321
-		$error=0;
321
+		$error = 0;
322 322
 
323 323
 		dol_syslog(get_class($this).'::create', LOG_DEBUG);
324 324
 
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
 		$this->description = trim($this->description);
328 328
 		$this->color = trim($this->color);
329 329
 		$this->import_key = trim($this->import_key);
330
-		if (empty($this->visible)) $this->visible=0;
330
+		if (empty($this->visible)) $this->visible = 0;
331 331
 		$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
332 332
 
333 333
 		if ($this->already_exists())
334 334
 		{
335
-			$this->error=$langs->trans("ImpossibleAddCat", $this->label);
336
-			$this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel");
335
+			$this->error = $langs->trans("ImpossibleAddCat", $this->label);
336
+			$this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel");
337 337
 			dol_syslog($this->error, LOG_WARNING);
338 338
 			return -4;
339 339
 		}
@@ -341,32 +341,32 @@  discard block
 block discarded – undo
341 341
 		$this->db->begin();
342 342
 
343 343
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (";
344
-		$sql.= "fk_parent,";
345
-		$sql.= " label,";
346
-		$sql.= " description,";
347
-		$sql.= " color,";
348
-		if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
344
+		$sql .= "fk_parent,";
345
+		$sql .= " label,";
346
+		$sql .= " description,";
347
+		$sql .= " color,";
348
+		if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
349 349
 		{
350
-			$sql.= "fk_soc,";
350
+			$sql .= "fk_soc,";
351 351
 		}
352
-		$sql.= " visible,";
353
-		$sql.= " type,";
354
-		$sql.= " import_key,";
355
-		$sql.= " entity";
356
-		$sql.= ") VALUES (";
357
-		$sql.= $this->db->escape($this->fk_parent).",";
358
-		$sql.= "'".$this->db->escape($this->label)."',";
359
-		$sql.= "'".$this->db->escape($this->description)."',";
360
-		$sql.= "'".$this->db->escape($this->color)."',";
361
-		if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
352
+		$sql .= " visible,";
353
+		$sql .= " type,";
354
+		$sql .= " import_key,";
355
+		$sql .= " entity";
356
+		$sql .= ") VALUES (";
357
+		$sql .= $this->db->escape($this->fk_parent).",";
358
+		$sql .= "'".$this->db->escape($this->label)."',";
359
+		$sql .= "'".$this->db->escape($this->description)."',";
360
+		$sql .= "'".$this->db->escape($this->color)."',";
361
+		if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
362 362
 		{
363
-			$sql.= ($this->socid != -1 ? $this->socid : 'null').",";
363
+			$sql .= ($this->socid != -1 ? $this->socid : 'null').",";
364 364
 		}
365
-		$sql.= "'".$this->db->escape($this->visible)."',";
366
-		$sql.= $this->db->escape($type).",";
367
-		$sql.= (! empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":'null').",";
368
-		$sql.= $this->db->escape($conf->entity);
369
-		$sql.= ")";
365
+		$sql .= "'".$this->db->escape($this->visible)."',";
366
+		$sql .= $this->db->escape($type).",";
367
+		$sql .= (!empty($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : 'null').",";
368
+		$sql .= $this->db->escape($conf->entity);
369
+		$sql .= ")";
370 370
 
371 371
 		$res = $this->db->query($sql);
372 372
 		if ($res)
@@ -377,27 +377,27 @@  discard block
 block discarded – undo
377 377
 			{
378 378
 				$this->id = $id;
379 379
 
380
-				$action='create';
380
+				$action = 'create';
381 381
 
382 382
 				// Actions on extra fields
383 383
 				if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
384 384
 				{
385
-					$result=$this->insertExtraFields();
385
+					$result = $this->insertExtraFields();
386 386
 					if ($result < 0)
387 387
 					{
388 388
 						$error++;
389 389
 					}
390 390
 				}
391 391
 
392
-				if (! $error)
392
+				if (!$error)
393 393
 				{
394 394
 	                // Call trigger
395
-    	            $result=$this->call_trigger('CATEGORY_CREATE',$user);
395
+    	            $result = $this->call_trigger('CATEGORY_CREATE', $user);
396 396
         	        if ($result < 0) { $error++; }
397 397
             	    // End call triggers
398 398
 				}
399 399
 
400
-                if ( ! $error )
400
+                if (!$error)
401 401
                 {
402 402
     				$this->db->commit();
403 403
     				return $id;
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 		}
417 417
 		else
418 418
 		{
419
-			$this->error=$this->db->error();
419
+			$this->error = $this->db->error();
420 420
 			$this->db->rollback();
421 421
 			return -1;
422 422
 		}
@@ -432,30 +432,30 @@  discard block
 block discarded – undo
432 432
 	 */
433 433
 	function update(User $user)
434 434
 	{
435
-		global $conf, $langs,$hookmanager;
435
+		global $conf, $langs, $hookmanager;
436 436
 
437
-		$error=0;
437
+		$error = 0;
438 438
 
439 439
 		// Clean parameters
440
-		$this->label=trim($this->label);
441
-		$this->description=trim($this->description);
440
+		$this->label = trim($this->label);
441
+		$this->description = trim($this->description);
442 442
 		$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
443 443
 		$this->visible = ($this->visible != "" ? intval($this->visible) : 0);
444 444
 
445 445
 		if ($this->already_exists())
446 446
 		{
447
-			$this->error=$langs->trans("ImpossibleUpdateCat");
448
-			$this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel");
447
+			$this->error = $langs->trans("ImpossibleUpdateCat");
448
+			$this->error .= " : ".$langs->trans("CategoryExistsAtSameLevel");
449 449
 			return -1;
450 450
 		}
451 451
 
452 452
 		$this->db->begin();
453 453
 
454 454
 		$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
455
-		$sql.= " SET label = '".$this->db->escape($this->label)."',";
456
-		$sql.= " description = '".$this->db->escape($this->description)."',";
457
-		$sql.= " color = '".$this->db->escape($this->color)."'";
458
-		if (! empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
455
+		$sql .= " SET label = '".$this->db->escape($this->label)."',";
456
+		$sql .= " description = '".$this->db->escape($this->description)."',";
457
+		$sql .= " color = '".$this->db->escape($this->color)."'";
458
+		if (!empty($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER))
459 459
 		{
460 460
 			$sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null');
461 461
 		}
@@ -466,22 +466,22 @@  discard block
 block discarded – undo
466 466
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
467 467
 		if ($this->db->query($sql))
468 468
 		{
469
-			$action='update';
469
+			$action = 'update';
470 470
 
471 471
 			// Actions on extra fields
472 472
 			if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
473 473
 			{
474
-				$result=$this->insertExtraFields();
474
+				$result = $this->insertExtraFields();
475 475
 				if ($result < 0)
476 476
 				{
477 477
 					$error++;
478 478
 				}
479 479
 			}
480 480
 
481
-			if (! $error)
481
+			if (!$error)
482 482
 			{
483 483
 	            // Call trigger
484
-    	        $result=$this->call_trigger('CATEGORY_MODIFY',$user);
484
+    	        $result = $this->call_trigger('CATEGORY_MODIFY', $user);
485 485
         	    if ($result < 0) { $error++; $this->db->rollback(); return -1; }
486 486
             	// End call triggers
487 487
 			}
@@ -505,11 +505,11 @@  discard block
 block discarded – undo
505 505
      *	@param	int		$notrigger	1=Does not execute triggers, 0= execute triggers
506 506
 	 *	@return	int                 <0 KO >0 OK
507 507
 	 */
508
-	function delete($user, $notrigger=0)
508
+	function delete($user, $notrigger = 0)
509 509
 	{
510
-		global $conf,$langs;
510
+		global $conf, $langs;
511 511
 
512
-		$error=0;
512
+		$error = 0;
513 513
 
514 514
         // Clean parameters
515 515
 		$this->fk_parent = ($this->fk_parent != "" ? intval($this->fk_parent) : 0);
@@ -518,24 +518,24 @@  discard block
 block discarded – undo
518 518
 
519 519
 		$this->db->begin();
520 520
 
521
-		if (! $error && ! $notrigger)
521
+		if (!$error && !$notrigger)
522 522
 		{
523 523
 		    // Call trigger
524
-		    $result=$this->call_trigger('CATEGORY_DELETE',$user);
524
+		    $result = $this->call_trigger('CATEGORY_DELETE', $user);
525 525
 		    if ($result < 0) $error++;
526 526
 		    // End call triggers
527 527
 		}
528 528
 
529 529
 		/* FIX #1317 : Check for child category and move up 1 level*/
530
-		if (! $error)
530
+		if (!$error)
531 531
 		{
532 532
 			$sql = "UPDATE ".MAIN_DB_PREFIX."categorie";
533
-			$sql.= " SET fk_parent = ".$this->fk_parent;
534
-			$sql.= " WHERE fk_parent = ".$this->id;
533
+			$sql .= " SET fk_parent = ".$this->fk_parent;
534
+			$sql .= " WHERE fk_parent = ".$this->id;
535 535
 
536 536
 			if (!$this->db->query($sql))
537 537
 			{
538
-				$this->error=$this->db->lasterror();
538
+				$this->error = $this->db->lasterror();
539 539
 				$error++;
540 540
 			}
541 541
 		}
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
             'categorie' => 'rowid',
553 553
         );
554 554
         foreach ($arraydelete as $key => $value) {
555
-            $sql  = "DELETE FROM " . MAIN_DB_PREFIX . $key;
555
+            $sql  = "DELETE FROM ".MAIN_DB_PREFIX.$key;
556 556
             $sql .= " WHERE ".$value." = ".$this->id;
557 557
             if (!$this->db->query($sql)) {
558 558
                 $this->errors[] = $this->db->lasterror();
@@ -562,9 +562,9 @@  discard block
 block discarded – undo
562 562
         }
563 563
 
564 564
 		// Removed extrafields
565
-		if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
565
+		if (!$error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
566 566
 		{
567
-			$result=$this->deleteExtraFields();
567
+			$result = $this->deleteExtraFields();
568 568
 			if ($result < 0)
569 569
 			{
570 570
 				$error++;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 			}
573 573
 		}
574 574
 
575
-		if (! $error)
575
+		if (!$error)
576 576
 		{
577 577
 			$this->db->commit();
578 578
 			return 1;
@@ -595,28 +595,28 @@  discard block
 block discarded – undo
595 595
 	function add_type($obj, $type)
596 596
 	{
597 597
         // phpcs:enable
598
-		global $user,$langs,$conf;
598
+		global $user, $langs, $conf;
599 599
 
600
-		$error=0;
600
+		$error = 0;
601 601
 
602 602
 		if ($this->id == -1) return -2;
603 603
 
604 604
         $this->db->begin();
605 605
 
606
-		$sql = "INSERT INTO " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
607
-		$sql .= " (fk_categorie, fk_" . $this->MAP_CAT_FK[$type] . ")";
608
-		$sql .= " VALUES (" . $this->id . ", " . $obj->id . ")";
606
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type];
607
+		$sql .= " (fk_categorie, fk_".$this->MAP_CAT_FK[$type].")";
608
+		$sql .= " VALUES (".$this->id.", ".$obj->id.")";
609 609
 
610 610
 		dol_syslog(get_class($this).'::add_type', LOG_DEBUG);
611 611
 		if ($this->db->query($sql))
612 612
 		{
613
-			if (! empty($conf->global->CATEGORIE_RECURSIV_ADD))
613
+			if (!empty($conf->global->CATEGORIE_RECURSIV_ADD))
614 614
 			{
615 615
 				$sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'categorie';
616
-				$sql.= " WHERE rowid = ".$this->id;
616
+				$sql .= " WHERE rowid = ".$this->id;
617 617
 
618 618
 				dol_syslog(get_class($this)."::add_type", LOG_DEBUG);
619
-				$resql=$this->db->query($sql);
619
+				$resql = $this->db->query($sql);
620 620
 				if ($resql)
621 621
 				{
622 622
 					if ($this->db->num_rows($resql) > 0)
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 				else
642 642
 				{
643 643
 					$error++;
644
-					$this->error=$this->db->lasterror();
644
+					$this->error = $this->db->lasterror();
645 645
 				}
646 646
 
647 647
 				if ($error)
@@ -654,12 +654,12 @@  discard block
 block discarded – undo
654 654
 
655 655
 
656 656
             // Call trigger
657
-			$this->context=array('linkto'=>$obj);	// Save object we want to link category to into category instance to provide information to trigger
658
-			$result=$this->call_trigger('CATEGORY_LINK',$user);
657
+			$this->context = array('linkto'=>$obj); // Save object we want to link category to into category instance to provide information to trigger
658
+			$result = $this->call_trigger('CATEGORY_LINK', $user);
659 659
             if ($result < 0) { $error++; }
660 660
             // End call triggers
661 661
 
662
-			if (! $error)
662
+			if (!$error)
663 663
 			{
664 664
 			    $this->db->commit();
665 665
 			    return 1;
@@ -675,12 +675,12 @@  discard block
 block discarded – undo
675 675
 		    $this->db->rollback();
676 676
 			if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
677 677
 			{
678
-				$this->error=$this->db->lasterrno();
678
+				$this->error = $this->db->lasterrno();
679 679
 				return -3;
680 680
 			}
681 681
 			else
682 682
 			{
683
-				$this->error=$this->db->lasterror();
683
+				$this->error = $this->db->lasterror();
684 684
 			}
685 685
 			return -1;
686 686
 		}
@@ -695,38 +695,38 @@  discard block
 block discarded – undo
695 695
 	 *
696 696
 	 * @return  int          1 if OK, -1 if KO
697 697
 	 */
698
-	function del_type($obj,$type)
698
+	function del_type($obj, $type)
699 699
 	{
700 700
         // phpcs:enable
701
-		global $user,$langs,$conf;
701
+		global $user, $langs, $conf;
702 702
 
703
-		$error=0;
703
+		$error = 0;
704 704
 
705 705
 		// For backward compatibility
706 706
 		if ($type == 'societe') {
707 707
 			$type = 'customer';
708
-			dol_syslog( get_class( $this ) . "::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
708
+			dol_syslog(get_class($this)."::del_type(): type 'societe' is deprecated, please use 'customer' instead", LOG_WARNING);
709 709
 		} elseif ($type == 'fournisseur') {
710 710
 			$type = 'supplier';
711
-			dol_syslog( get_class( $this ) . "::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
711
+			dol_syslog(get_class($this)."::del_type(): type 'fournisseur' is deprecated, please use 'supplier' instead", LOG_WARNING);
712 712
 		}
713 713
 
714 714
         $this->db->begin();
715 715
 
716
-		$sql = "DELETE FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
717
-		$sql .= " WHERE fk_categorie = " . $this->id;
718
-		$sql .= " AND   fk_" . $this->MAP_CAT_FK[$type] . "  = " . $obj->id;
716
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type];
717
+		$sql .= " WHERE fk_categorie = ".$this->id;
718
+		$sql .= " AND   fk_".$this->MAP_CAT_FK[$type]."  = ".$obj->id;
719 719
 
720 720
 		dol_syslog(get_class($this).'::del_type', LOG_DEBUG);
721 721
 		if ($this->db->query($sql))
722 722
 		{
723 723
             // Call trigger
724
-			$this->context=array('unlinkoff'=>$obj);	// Save object we want to link category to into category instance to provide information to trigger
725
-			$result=$this->call_trigger('CATEGORY_UNLINK',$user);
724
+			$this->context = array('unlinkoff'=>$obj); // Save object we want to link category to into category instance to provide information to trigger
725
+			$result = $this->call_trigger('CATEGORY_UNLINK', $user);
726 726
             if ($result < 0) { $error++; }
727 727
             // End call triggers
728 728
 
729
-			if (! $error)
729
+			if (!$error)
730 730
 			{
731 731
 			    $this->db->commit();
732 732
 			    return 1;
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
 		else
741 741
 		{
742 742
 		    $this->db->rollback();
743
-			$this->error=$this->db->lasterror();
743
+			$this->error = $this->db->lasterror();
744 744
 			return -1;
745 745
 		}
746 746
 	}
@@ -753,18 +753,18 @@  discard block
 block discarded – undo
753 753
 	 * @return  array|int              -1 if KO, array of instance of object if OK
754 754
 	 * @see containsObject
755 755
 	 */
756
-	function getObjectsInCateg($type, $onlyids=0)
756
+	function getObjectsInCateg($type, $onlyids = 0)
757 757
 	{
758 758
 		$objs = array();
759 759
 
760
-		$obj = new $this->MAP_OBJ_CLASS[$type]( $this->db );
760
+		$obj = new $this->MAP_OBJ_CLASS[$type]($this->db);
761 761
 
762
-		$sql = "SELECT c.fk_" . $this->MAP_CAT_FK[$type];
763
-		$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as c";
764
-		$sql .= ", " . MAIN_DB_PREFIX . $this->MAP_OBJ_TABLE[$type] . " as o";
765
-		$sql .= " WHERE o.entity IN (" . getEntity( $obj->element).")";
766
-		$sql.= " AND c.fk_categorie = ".$this->id;
767
-		$sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid";
762
+		$sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type];
763
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c";
764
+		$sql .= ", ".MAIN_DB_PREFIX.$this->MAP_OBJ_TABLE[$type]." as o";
765
+		$sql .= " WHERE o.entity IN (".getEntity($obj->element).")";
766
+		$sql .= " AND c.fk_categorie = ".$this->id;
767
+		$sql .= " AND c.fk_".$this->MAP_CAT_FK[$type]." = o.rowid";
768 768
 
769 769
 		dol_syslog(get_class($this)."::getObjectsInCateg", LOG_DEBUG);
770 770
 		$resql = $this->db->query($sql);
@@ -774,12 +774,12 @@  discard block
 block discarded – undo
774 774
 			{
775 775
 			    if ($onlyids)
776 776
 			    {
777
-			        $objs[] = $rec['fk_' . $this->MAP_CAT_FK[$type]];
777
+			        $objs[] = $rec['fk_'.$this->MAP_CAT_FK[$type]];
778 778
 			    }
779 779
 			    else
780 780
 			    {
781
-				    $obj = new $this->MAP_OBJ_CLASS[$type]( $this->db );
782
-				    $obj->fetch( $rec['fk_' . $this->MAP_CAT_FK[$type]]);
781
+				    $obj = new $this->MAP_OBJ_CLASS[$type]($this->db);
782
+				    $obj->fetch($rec['fk_'.$this->MAP_CAT_FK[$type]]);
783 783
 				    $objs[] = $obj;
784 784
 			    }
785 785
 			}
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 		}
788 788
 		else
789 789
 		{
790
-			$this->error=$this->db->error().' sql='.$sql;
790
+			$this->error = $this->db->error().' sql='.$sql;
791 791
 			return -1;
792 792
 		}
793 793
 	}
@@ -802,14 +802,14 @@  discard block
 block discarded – undo
802 802
 	 */
803 803
 	function containsObject($type, $object_id)
804 804
 	{
805
-		$sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type];
806
-		$sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id;
805
+		$sql = "SELECT COUNT(*) as nb FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type];
806
+		$sql .= " WHERE fk_categorie = ".$this->id." AND fk_".$this->MAP_CAT_FK[$type]." = ".$object_id;
807 807
 		dol_syslog(get_class($this)."::containsObject", LOG_DEBUG);
808 808
 		$resql = $this->db->query($sql);
809 809
 		if ($resql) {
810 810
 			return $this->db->fetch_object($resql)->nb;
811 811
 		} else {
812
-			$this->error=$this->db->error().' sql='.$sql;
812
+			$this->error = $this->db->error().' sql='.$sql;
813 813
 			return -1;
814 814
 		}
815 815
 	}
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 	 * @param	int		$page		Page number
826 826
 	 * @return	array|int			Array of categories, 0 if no cat, -1 on error
827 827
 	 */
828
-	function getListForItem($id, $type='customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
828
+	function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
829 829
 	{
830 830
 		global $conf;
831 831
 
@@ -833,26 +833,26 @@  discard block
 block discarded – undo
833 833
 
834 834
 		$sub_type = $type;
835 835
 		$subcol_name = "fk_".$type;
836
-		if ($type=="customer") {
837
-			$sub_type="societe";
838
-			$subcol_name="fk_soc";
836
+		if ($type == "customer") {
837
+			$sub_type = "societe";
838
+			$subcol_name = "fk_soc";
839 839
 		}
840
-		if ($type=="supplier") {
841
-			$sub_type="fournisseur";
842
-			$subcol_name="fk_soc";
840
+		if ($type == "supplier") {
841
+			$sub_type = "fournisseur";
842
+			$subcol_name = "fk_soc";
843 843
 		}
844
-		if ($type=="contact") {
845
-			$subcol_name="fk_socpeople";
844
+		if ($type == "contact") {
845
+			$subcol_name = "fk_socpeople";
846 846
 		}
847 847
 		$sql = "SELECT s.rowid";
848
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
849
-		$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
850
-		$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
851
-		$sql.= ' AND s.type='.array_search($type, self::$MAP_ID_TO_CODE);
852
-		$sql.= ' AND s.rowid = sub.fk_categorie';
853
-		$sql.= ' AND sub.'.$subcol_name.' = '.$id;
848
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie as s";
849
+		$sql .= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
850
+		$sql .= ' WHERE s.entity IN ('.getEntity('category').')';
851
+		$sql .= ' AND s.type='.array_search($type, self::$MAP_ID_TO_CODE);
852
+		$sql .= ' AND s.rowid = sub.fk_categorie';
853
+		$sql .= ' AND sub.'.$subcol_name.' = '.$id;
854 854
 
855
-		$sql.= $this->db->order($sortfield, $sortorder);
855
+		$sql .= $this->db->order($sortfield, $sortorder);
856 856
 
857 857
 		$offset = 0;
858 858
 		$nbtotalofrecords = '';
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
 			}
868 868
 		}
869 869
 
870
-		$sql.= $this->db->plimit($limit + 1, $offset);
870
+		$sql .= $this->db->plimit($limit + 1, $offset);
871 871
 
872 872
 		$result = $this->db->query($sql);
873 873
 		if ($result)
874 874
 		{
875
-			$i=0;
875
+			$i = 0;
876 876
 			$num = $this->db->num_rows($result);
877 877
 			$min = min($num, ($limit <= 0 ? $num : $limit));
878 878
 			while ($i < $min)
@@ -881,20 +881,20 @@  discard block
 block discarded – undo
881 881
 				$category_static = new Categorie($this->db);
882 882
 				if ($category_static->fetch($obj->rowid))
883 883
 				{
884
-					$categories[$i]['id'] 				= $category_static->id;
884
+					$categories[$i]['id'] = $category_static->id;
885 885
 					$categories[$i]['fk_parent']		= $category_static->fk_parent;
886 886
 					$categories[$i]['label']			= $category_static->label;
887
-					$categories[$i]['description']		= $category_static->description;
887
+					$categories[$i]['description'] = $category_static->description;
888 888
 					$categories[$i]['color']    		= $category_static->color;
889 889
 					$categories[$i]['socid']			= $category_static->socid;
890
-					$categories[$i]['visible']			= $category_static->visible;
891
-					$categories[$i]['type']			= $category_static->type;
892
-					$categories[$i]['entity']			= $category_static->entity;
893
-					$categories[$i]['array_options']	= $category_static->array_options;
890
+					$categories[$i]['visible'] = $category_static->visible;
891
+					$categories[$i]['type'] = $category_static->type;
892
+					$categories[$i]['entity'] = $category_static->entity;
893
+					$categories[$i]['array_options'] = $category_static->array_options;
894 894
 
895 895
 					// multilangs
896
-					if (! empty($conf->global->MAIN_MULTILANGS)) 	{
897
-						$categories[$i]['multilangs']	= $category_static->multilangs;
896
+					if (!empty($conf->global->MAIN_MULTILANGS)) {
897
+						$categories[$i]['multilangs'] = $category_static->multilangs;
898 898
 					}
899 899
 				}
900 900
 				$i++;
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 			$this->error = $this->db->lasterror();
905 905
 			return -1;
906 906
 		}
907
-		if ( ! count($categories)) {
907
+		if (!count($categories)) {
908 908
 			return 0;
909 909
 		}
910 910
 
@@ -921,12 +921,12 @@  discard block
 block discarded – undo
921 921
 	{
922 922
         // phpcs:enable
923 923
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
924
-		$sql.= " WHERE fk_parent = ".$this->id;
924
+		$sql .= " WHERE fk_parent = ".$this->id;
925 925
 
926
-		$res  = $this->db->query($sql);
926
+		$res = $this->db->query($sql);
927 927
 		if ($res)
928 928
 		{
929
-			$cats = array ();
929
+			$cats = array();
930 930
 			while ($rec = $this->db->fetch_array($res))
931 931
 			{
932 932
 				$cat = new Categorie($this->db);
@@ -953,21 +953,21 @@  discard block
 block discarded – undo
953 953
         // phpcs:enable
954 954
 		global $conf;
955 955
 
956
-		$this->motherof=array();
956
+		$this->motherof = array();
957 957
 
958 958
 		// Load array[child]=parent
959 959
 		$sql = "SELECT fk_parent as id_parent, rowid as id_son";
960
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie";
961
-		$sql.= " WHERE fk_parent != 0";
962
-		$sql.= " AND entity IN (".getEntity('category').")";
960
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie";
961
+		$sql .= " WHERE fk_parent != 0";
962
+		$sql .= " AND entity IN (".getEntity('category').")";
963 963
 
964 964
 		dol_syslog(get_class($this)."::load_motherof", LOG_DEBUG);
965 965
 		$resql = $this->db->query($sql);
966 966
 		if ($resql)
967 967
 		{
968
-			while ($obj= $this->db->fetch_object($resql))
968
+			while ($obj = $this->db->fetch_object($resql))
969 969
 			{
970
-				$this->motherof[$obj->id_son]=$obj->id_parent;
970
+				$this->motherof[$obj->id_son] = $obj->id_parent;
971 971
 			}
972 972
 			return 1;
973 973
 		}
@@ -994,12 +994,12 @@  discard block
 block discarded – undo
994 994
 	 *
995 995
 	 * @return  array|int               Array of categories. this->cats and this->motherof are set, -1 on error
996 996
 	 */
997
-	function get_full_arbo($type, $markafterid=0)
997
+	function get_full_arbo($type, $markafterid = 0)
998 998
 	{
999 999
         // phpcs:enable
1000 1000
 	    global $conf, $langs;
1001 1001
 
1002
-		if (! is_numeric($type)) $type = $this->MAP_ID[$type];
1002
+		if (!is_numeric($type)) $type = $this->MAP_ID[$type];
1003 1003
 
1004 1004
 		$this->cats = array();
1005 1005
 
@@ -1008,25 +1008,25 @@  discard block
 block discarded – undo
1008 1008
 		$current_lang = $langs->getDefaultLang();
1009 1009
 
1010 1010
 		// Init $this->cats array
1011
-		$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible";	// Distinct reduce pb with old tables with duplicates
1012
-		if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= ", t.label as label_trans, t.description as description_trans";
1013
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c";
1014
-		if (! empty($conf->global->MAIN_MULTILANGS)) $sql.= " LEFT  JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
1015
-		$sql .= " WHERE c.entity IN (" . getEntity( 'category') . ")";
1016
-		$sql .= " AND c.type = " . $type;
1011
+		$sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.color, c.fk_parent, c.visible"; // Distinct reduce pb with old tables with duplicates
1012
+		if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= ", t.label as label_trans, t.description as description_trans";
1013
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie as c";
1014
+		if (!empty($conf->global->MAIN_MULTILANGS)) $sql .= " LEFT  JOIN ".MAIN_DB_PREFIX."categorie_lang as t ON t.fk_category=c.rowid AND t.lang='".$current_lang."'";
1015
+		$sql .= " WHERE c.entity IN (".getEntity('category').")";
1016
+		$sql .= " AND c.type = ".$type;
1017 1017
 
1018 1018
 		dol_syslog(get_class($this)."::get_full_arbo get category list", LOG_DEBUG);
1019 1019
 		$resql = $this->db->query($sql);
1020 1020
 		if ($resql)
1021 1021
 		{
1022
-			$i=0;
1022
+			$i = 0;
1023 1023
 			while ($obj = $this->db->fetch_object($resql))
1024 1024
 			{
1025 1025
 				$this->cats[$obj->rowid]['rowid'] = $obj->rowid;
1026 1026
 				$this->cats[$obj->rowid]['id'] = $obj->rowid;
1027 1027
 				$this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent;
1028
-				$this->cats[$obj->rowid]['label'] = ! empty($obj->label_trans) ? $obj->label_trans : $obj->label;
1029
-				$this->cats[$obj->rowid]['description'] = ! empty($obj->description_trans) ? $obj->description_trans : $obj->description;
1028
+				$this->cats[$obj->rowid]['label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label;
1029
+				$this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description;
1030 1030
 				$this->cats[$obj->rowid]['color'] = $obj->color;
1031 1031
 				$this->cats[$obj->rowid]['visible'] = $obj->visible;
1032 1032
 				$i++;
@@ -1040,24 +1040,24 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 		// We add the fullpath property to each elements of first level (no parent exists)
1042 1042
 		dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG);
1043
-		foreach($this->cats as $key => $val)
1043
+		foreach ($this->cats as $key => $val)
1044 1044
 		{
1045 1045
 			//print 'key='.$key.'<br>'."\n";
1046
-			$this->build_path_from_id_categ($key,0);	// Process a branch from the root category key (this category has no parent)
1046
+			$this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent)
1047 1047
 		}
1048 1048
 
1049 1049
         // Exclude leaf including $markafterid from tree
1050 1050
         if ($markafterid)
1051 1051
         {
1052 1052
             //print "Look to discard category ".$markafterid."\n";
1053
-            $keyfilter1='^'.$markafterid.'$';
1054
-            $keyfilter2='_'.$markafterid.'$';
1055
-            $keyfilter3='^'.$markafterid.'_';
1056
-            $keyfilter4='_'.$markafterid.'_';
1057
-            foreach($this->cats as $key => $val)
1053
+            $keyfilter1 = '^'.$markafterid.'$';
1054
+            $keyfilter2 = '_'.$markafterid.'$';
1055
+            $keyfilter3 = '^'.$markafterid.'_';
1056
+            $keyfilter4 = '_'.$markafterid.'_';
1057
+            foreach ($this->cats as $key => $val)
1058 1058
             {
1059
-                if (preg_match('/'.$keyfilter1.'/',$val['fullpath']) || preg_match('/'.$keyfilter2.'/',$val['fullpath'])
1060
-                || preg_match('/'.$keyfilter3.'/',$val['fullpath']) || preg_match('/'.$keyfilter4.'/',$val['fullpath']))
1059
+                if (preg_match('/'.$keyfilter1.'/', $val['fullpath']) || preg_match('/'.$keyfilter2.'/', $val['fullpath'])
1060
+                || preg_match('/'.$keyfilter3.'/', $val['fullpath']) || preg_match('/'.$keyfilter4.'/', $val['fullpath']))
1061 1061
                 {
1062 1062
                     unset($this->cats[$key]);
1063 1063
                 }
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
         }
1066 1066
 
1067 1067
 		dol_syslog(get_class($this)."::get_full_arbo dol_sort_array", LOG_DEBUG);
1068
-		$this->cats=dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
1068
+		$this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
1069 1069
 
1070 1070
 		//$this->debug_cats();
1071 1071
 
@@ -1080,12 +1080,12 @@  discard block
 block discarded – undo
1080 1080
 	 * 	@param		int		$protection		Deep counter to avoid infinite loop
1081 1081
 	 *	@return		void
1082 1082
 	 */
1083
-	function build_path_from_id_categ($id_categ,$protection=1000)
1083
+	function build_path_from_id_categ($id_categ, $protection = 1000)
1084 1084
 	{
1085 1085
         // phpcs:enable
1086 1086
 		dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
1087 1087
 
1088
-		if (! empty($this->cats[$id_categ]['fullpath']))
1088
+		if (!empty($this->cats[$id_categ]['fullpath']))
1089 1089
 		{
1090 1090
 			// Already defined
1091 1091
 			dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING);
@@ -1098,20 +1098,20 @@  discard block
 block discarded – undo
1098 1098
 		// Define fullpath and fulllabel
1099 1099
 		$this->cats[$id_categ]['fullpath'] = '_'.$id_categ;
1100 1100
 		$this->cats[$id_categ]['fulllabel'] = $this->cats[$id_categ]['label'];
1101
-		$i=0; $cursor_categ=$id_categ;
1101
+		$i = 0; $cursor_categ = $id_categ;
1102 1102
 		//print 'Work for id_categ='.$id_categ.'<br>'."\n";
1103
-		while ((empty($protection) || $i < $protection) && ! empty($this->motherof[$cursor_categ]))
1103
+		while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ]))
1104 1104
 		{
1105 1105
 			//print '&nbsp; cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'<br>'."\n";
1106 1106
 			$this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath'];
1107 1107
 			$this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel'];
1108 1108
 			//print '&nbsp; Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].' '.$this->cats[$id_categ]['fulllabel'].'<br>'."\n";
1109
-			$i++; $cursor_categ=$this->motherof[$cursor_categ];
1109
+			$i++; $cursor_categ = $this->motherof[$cursor_categ];
1110 1110
 		}
1111 1111
 		//print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'<br>'."\n";
1112 1112
 
1113 1113
 		// We count number of _ to have level
1114
-		$this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i','',$this->cats[$id_categ]['fullpath']));
1114
+		$this->cats[$id_categ]['level'] = dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath']));
1115 1115
 
1116 1116
 		return;
1117 1117
 	}
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 	{
1127 1127
         // phpcs:enable
1128 1128
 		// Display $this->cats
1129
-		foreach($this->cats as $key => $val)
1129
+		foreach ($this->cats as $key => $val)
1130 1130
 		{
1131 1131
 			print 'id: '.$this->cats[$key]['id'];
1132 1132
 			print ' label: '.$this->cats[$key]['label'];
@@ -1147,22 +1147,22 @@  discard block
 block discarded – undo
1147 1147
 	 *	@param	boolean		$parent		Just parent categories if true
1148 1148
 	 *	@return	array|int				Table of Object Category, -1 on error
1149 1149
 	 */
1150
-	function get_all_categories($type=null, $parent=false)
1150
+	function get_all_categories($type = null, $parent = false)
1151 1151
 	{
1152 1152
         // phpcs:enable
1153
-		if (! is_numeric($type)) $type = $this->MAP_ID[$type];
1153
+		if (!is_numeric($type)) $type = $this->MAP_ID[$type];
1154 1154
 
1155 1155
 		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
1156
-		$sql.= " WHERE entity IN (".getEntity('category').")";
1157
-		if (! is_null($type))
1158
-			$sql.= " AND type = ".$type;
1156
+		$sql .= " WHERE entity IN (".getEntity('category').")";
1157
+		if (!is_null($type))
1158
+			$sql .= " AND type = ".$type;
1159 1159
 		if ($parent)
1160
-			$sql.= " AND fk_parent = 0";
1160
+			$sql .= " AND fk_parent = 0";
1161 1161
 
1162 1162
 		$res = $this->db->query($sql);
1163 1163
 		if ($res)
1164 1164
 		{
1165
-			$cats = array ();
1165
+			$cats = array();
1166 1166
 			while ($rec = $this->db->fetch_array($res))
1167 1167
 			{
1168 1168
 				$cat = new Categorie($this->db);
@@ -1187,19 +1187,19 @@  discard block
 block discarded – undo
1187 1187
 	function already_exists()
1188 1188
 	{
1189 1189
         // phpcs:enable
1190
-		$type=$this->type;
1190
+		$type = $this->type;
1191 1191
 
1192
-		if (! is_numeric($type)) $type=$this->MAP_ID[$type];
1192
+		if (!is_numeric($type)) $type = $this->MAP_ID[$type];
1193 1193
 
1194 1194
 		/* We have to select any rowid from llx_categorie which category's mother and label
1195 1195
 		 * are equals to those of the calling category
1196 1196
 		 */
1197 1197
 		$sql = "SELECT c.rowid";
1198
-		$sql.= " FROM ".MAIN_DB_PREFIX."categorie as c ";
1199
-		$sql.= " WHERE c.entity IN (".getEntity('category').")";
1200
-		$sql.= " AND c.type = ".$type;
1201
-		$sql.= " AND c.fk_parent = ".$this->fk_parent;
1202
-		$sql.= " AND c.label = '".$this->db->escape($this->label)."'";
1198
+		$sql .= " FROM ".MAIN_DB_PREFIX."categorie as c ";
1199
+		$sql .= " WHERE c.entity IN (".getEntity('category').")";
1200
+		$sql .= " AND c.type = ".$type;
1201
+		$sql .= " AND c.fk_parent = ".$this->fk_parent;
1202
+		$sql .= " AND c.label = '".$this->db->escape($this->label)."'";
1203 1203
 
1204 1204
 		dol_syslog(get_class($this)."::already_exists", LOG_DEBUG);
1205 1205
 		$resql = $this->db->query($sql);
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 				 * So if the result have the same id, update is not for label, and if result have an other one,
1214 1214
 				 * update may be for label.
1215 1215
 				 */
1216
-				if($obj[0] > 0 && $obj[0] != $this->id)
1216
+				if ($obj[0] > 0 && $obj[0] != $this->id)
1217 1217
 				{
1218 1218
 					dol_syslog(get_class($this)."::already_exists category with name=".$this->label." and parent ".$this->fk_parent." exists: rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG);
1219 1219
 					return 1;
@@ -1224,7 +1224,7 @@  discard block
 block discarded – undo
1224 1224
 		}
1225 1225
 		else
1226 1226
 		{
1227
-			$this->error=$this->db->error();
1227
+			$this->error = $this->db->error();
1228 1228
 			return -1;
1229 1229
 		}
1230 1230
 	}
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
 	 *	@param		int		$type		Type of category (0, 1, ...)
1237 1237
 	 *	@return		array
1238 1238
 	 */
1239
-	function get_main_categories($type=null)
1239
+	function get_main_categories($type = null)
1240 1240
 	{
1241 1241
         // phpcs:enable
1242 1242
 		return $this->get_all_categories($type, true);
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
 	 * @param   int     $nocolor     0
1253 1253
 	 * @return	array
1254 1254
 	 */
1255
-	function print_all_ways($sep = " &gt;&gt; ", $url='', $nocolor=0)
1255
+	function print_all_ways($sep = " &gt;&gt; ", $url = '', $nocolor = 0)
1256 1256
 	{
1257 1257
         // phpcs:enable
1258 1258
 		$ways = array();
@@ -1262,29 +1262,29 @@  discard block
 block discarded – undo
1262 1262
 		{
1263 1263
 			$w = array();
1264 1264
 			$i = 0;
1265
-			$forced_color='';
1265
+			$forced_color = '';
1266 1266
 			foreach ($way as $cat)
1267 1267
 			{
1268 1268
 			    $i++;
1269 1269
 
1270 1270
 			    if (empty($nocolor))
1271 1271
 			    {
1272
-    			    $forced_color='toreplace';
1272
+    			    $forced_color = 'toreplace';
1273 1273
     			    if ($i == count($way))
1274 1274
     			    {
1275 1275
     			        // Check contrast with background and correct text color
1276
-    			        $forced_color='categtextwhite';
1276
+    			        $forced_color = 'categtextwhite';
1277 1277
     			        if ($cat->color)
1278 1278
     			        {
1279
-    			            if (colorIsLight($cat->color)) $forced_color='categtextblack';
1279
+    			            if (colorIsLight($cat->color)) $forced_color = 'categtextblack';
1280 1280
     			        }
1281 1281
     			    }
1282 1282
 			    }
1283 1283
 
1284 1284
 				if ($url == '')
1285 1285
 				{
1286
-			        $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$cat->id.'&type='.$cat->type.'" class="'.$forced_color .'">';
1287
-			        $linkend='</a>';
1286
+			        $link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$cat->id.'&type='.$cat->type.'" class="'.$forced_color.'">';
1287
+			        $linkend = '</a>';
1288 1288
 				    $w[] = $link.$cat->label.$linkend;
1289 1289
 				}
1290 1290
 				else
@@ -1313,9 +1313,9 @@  discard block
 block discarded – undo
1313 1313
 		$parents = array();
1314 1314
 
1315 1315
 		$sql = "SELECT fk_parent FROM ".MAIN_DB_PREFIX."categorie";
1316
-		$sql.= " WHERE rowid = ".$this->id;
1316
+		$sql .= " WHERE rowid = ".$this->id;
1317 1317
 
1318
-		$res  = $this->db->query($sql);
1318
+		$res = $this->db->query($sql);
1319 1319
 
1320 1320
 		if ($res)
1321 1321
 		{
@@ -1349,17 +1349,17 @@  discard block
 block discarded – undo
1349 1349
         // phpcs:enable
1350 1350
 		$ways = array();
1351 1351
 
1352
-		$parents=$this->get_meres();
1353
-		if (! empty($parents))
1352
+		$parents = $this->get_meres();
1353
+		if (!empty($parents))
1354 1354
 		{
1355 1355
 			foreach ($parents as $parent)
1356 1356
 			{
1357
-				$allways=$parent->get_all_ways();
1357
+				$allways = $parent->get_all_ways();
1358 1358
 				foreach ($allways as $way)
1359 1359
 				{
1360
-					$w		= $way;
1361
-					$w[]	= $this;
1362
-					$ways[]	= $w;
1360
+					$w = $way;
1361
+					$w[] = $this;
1362
+					$ways[] = $w;
1363 1363
 				}
1364 1364
 			}
1365 1365
 		}
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 	 *                      	    labels, 'id'= Get array of category IDs
1381 1381
 	 * @return  array|int           Array of category objects or < 0 if KO
1382 1382
 	 */
1383
-	function containing($id, $type, $mode='object')
1383
+	function containing($id, $type, $mode = 'object')
1384 1384
 	{
1385 1385
 		$cats = array();
1386 1386
 
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 		{
1391 1391
 		    // Load bank groups
1392 1392
 		    $sql = "SELECT c.label, c.rowid";
1393
-		    $sql.= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
1394
-		    $sql.= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid";
1395
-		    $sql.= " ORDER BY c.label";
1393
+		    $sql .= " FROM ".MAIN_DB_PREFIX."bank_class as a, ".MAIN_DB_PREFIX."bank_categ as c";
1394
+		    $sql .= " WHERE a.lineid=".$id." AND a.fk_categ = c.rowid";
1395
+		    $sql .= " ORDER BY c.label";
1396 1396
 
1397 1397
 		    $res = $this->db->query($sql);
1398 1398
 		    if ($res)
@@ -1420,9 +1420,9 @@  discard block
 block discarded – undo
1420 1420
         else
1421 1421
         {
1422 1422
     		$sql = "SELECT ct.fk_categorie, c.label, c.rowid";
1423
-    		$sql .= " FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type] . " as ct, " . MAIN_DB_PREFIX . "categorie as c";
1424
-    		$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_" . $this->MAP_CAT_FK[$type] . " = " . (int) $id . " AND c.type = " . $this->MAP_ID[$type];
1425
-    		$sql .= " AND c.entity IN (" . getEntity( 'category') . ")";
1423
+    		$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as ct, ".MAIN_DB_PREFIX."categorie as c";
1424
+    		$sql .= " WHERE ct.fk_categorie = c.rowid AND ct.fk_".$this->MAP_CAT_FK[$type]." = ".(int) $id." AND c.type = ".$this->MAP_ID[$type];
1425
+    		$sql .= " AND c.entity IN (".getEntity('category').")";
1426 1426
 
1427 1427
     		$res = $this->db->query($sql);
1428 1428
     		if ($res)
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	{
1467 1467
 		// Deprecation warning
1468 1468
 		if (is_numeric($type)) {
1469
-			dol_syslog(__METHOD__ . ': using numeric types is deprecated.', LOG_WARNING);
1469
+			dol_syslog(__METHOD__.': using numeric types is deprecated.', LOG_WARNING);
1470 1470
 		}
1471 1471
 
1472 1472
 		$cats = array();
@@ -1474,28 +1474,28 @@  discard block
 block discarded – undo
1474 1474
 		// For backward compatibility
1475 1475
 		if (is_numeric($type)) {
1476 1476
 			// We want to reverse lookup
1477
-			$map_type = array_flip( $this->MAP_ID );
1477
+			$map_type = array_flip($this->MAP_ID);
1478 1478
 			$type = $map_type[$type];
1479
-			dol_syslog( get_class( $this ) . "::rechercher(): numeric types are deprecated, please use string instead",
1480
-				LOG_WARNING );
1479
+			dol_syslog(get_class($this)."::rechercher(): numeric types are deprecated, please use string instead",
1480
+				LOG_WARNING);
1481 1481
 		}
1482 1482
 
1483 1483
 		// Generation requete recherche
1484
-		$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie";
1485
-		$sql .= " WHERE type = " . $this->MAP_ID[$type];
1486
-		$sql .= " AND entity IN (" . getEntity( 'category') . ")";
1484
+		$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie";
1485
+		$sql .= " WHERE type = ".$this->MAP_ID[$type];
1486
+		$sql .= " AND entity IN (".getEntity('category').")";
1487 1487
 		if ($nom)
1488 1488
 		{
1489
-			if (! $exact)
1489
+			if (!$exact)
1490 1490
 				$nom = '%'.str_replace('*', '%', $nom).'%';
1491
-			if (! $case)
1492
-				$sql.= " AND label LIKE '".$this->db->escape($nom)."'";
1491
+			if (!$case)
1492
+				$sql .= " AND label LIKE '".$this->db->escape($nom)."'";
1493 1493
 			else
1494
-				$sql.= " AND label LIKE BINARY '".$this->db->escape($nom)."'";
1494
+				$sql .= " AND label LIKE BINARY '".$this->db->escape($nom)."'";
1495 1495
 		}
1496 1496
 		if ($id)
1497 1497
 		{
1498
-			$sql.=" AND rowid = '".$id."'";
1498
+			$sql .= " AND rowid = '".$id."'";
1499 1499
 		}
1500 1500
 
1501 1501
 		$res  = $this->db->query($sql);
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 		}
1513 1513
 		else
1514 1514
 		{
1515
-			$this->error=$this->db->error().' sql='.$sql;
1515
+			$this->error = $this->db->error().' sql='.$sql;
1516 1516
 			return -1;
1517 1517
 		}
1518 1518
 	}
@@ -1526,29 +1526,29 @@  discard block
 block discarded – undo
1526 1526
 	 * 	@param		int		$maxlength		Max length of text
1527 1527
 	 *	@return		string					Chaine avec URL
1528 1528
 	 */
1529
-	function getNomUrl($withpicto=0,$option='',$maxlength=0)
1529
+	function getNomUrl($withpicto = 0, $option = '', $maxlength = 0)
1530 1530
 	{
1531 1531
 		global $langs;
1532 1532
 
1533
-		$result='';
1534
-		$label=$langs->trans("ShowCategory").': '. ($this->ref?$this->ref:$this->label);
1533
+		$result = '';
1534
+		$label = $langs->trans("ShowCategory").': '.($this->ref ? $this->ref : $this->label);
1535 1535
 
1536 1536
 		// Check contrast with background and correct text color
1537
-		$forced_color='categtextwhite';
1537
+		$forced_color = 'categtextwhite';
1538 1538
 		if ($this->color)
1539 1539
 		{
1540
-			if (colorIsLight($this->color)) $forced_color='categtextblack';
1540
+			if (colorIsLight($this->color)) $forced_color = 'categtextblack';
1541 1541
 		}
1542 1542
 
1543
-		$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'&backtopage='.urlencode($_SERVER['PHP_SELF']).'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color .'">';
1544
-		$linkend='</a>';
1543
+		$link = '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$this->id.'&type='.$this->type.'&backtopage='.urlencode($_SERVER['PHP_SELF']).'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip '.$forced_color.'">';
1544
+		$linkend = '</a>';
1545 1545
 
1546
-		$picto='category';
1546
+		$picto = 'category';
1547 1547
 
1548 1548
 
1549
-        if ($withpicto) $result.=($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
1550
-		if ($withpicto && $withpicto != 2) $result.=' ';
1551
-		if ($withpicto != 2) $result.=$link.dol_trunc(($this->ref?$this->ref:$this->label),$maxlength).$linkend;
1549
+        if ($withpicto) $result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
1550
+		if ($withpicto && $withpicto != 2) $result .= ' ';
1551
+		if ($withpicto != 2) $result .= $link.dol_trunc(($this->ref ? $this->ref : $this->label), $maxlength).$linkend;
1552 1552
 		return $result;
1553 1553
 	}
1554 1554
 
@@ -1566,10 +1566,10 @@  discard block
 block discarded – undo
1566 1566
         // phpcs:enable
1567 1567
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1568 1568
 
1569
-		$dir = $sdir .'/'. get_exdir($this->id,2,0,0,$this,'category') . $this->id ."/";
1569
+		$dir = $sdir.'/'.get_exdir($this->id, 2, 0, 0, $this, 'category').$this->id."/";
1570 1570
 		$dir .= "photos/";
1571 1571
 
1572
-		if (! file_exists($dir))
1572
+		if (!file_exists($dir))
1573 1573
 		{
1574 1574
 			dol_mkdir($dir);
1575 1575
 		}
@@ -1578,9 +1578,9 @@  discard block
 block discarded – undo
1578 1578
 			if (is_array($file['name']) && count($file['name']) > 0)
1579 1579
 			{
1580 1580
 				$nbfile = count($file['name']);
1581
-				for ($i = 0; $i <= $nbfile; $i ++) {
1581
+				for ($i = 0; $i <= $nbfile; $i++) {
1582 1582
 
1583
-					$originImage = $dir . $file['name'][$i];
1583
+					$originImage = $dir.$file['name'][$i];
1584 1584
 
1585 1585
 					// Cree fichier en taille origine
1586 1586
 					dol_move_uploaded_file($file['tmp_name'][$i], $originImage, 1, 0, 0);
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 					}
1592 1592
 				}
1593 1593
 			} else {
1594
-				$originImage = $dir . $file['name'];
1594
+				$originImage = $dir.$file['name'];
1595 1595
 
1596 1596
 				// Cree fichier en taille origine
1597 1597
 				dol_move_uploaded_file($file['tmp_name'], $originImage, 1, 0, 0);
@@ -1612,42 +1612,42 @@  discard block
 block discarded – undo
1612 1612
 	 *    @param      int		$nbmax      Nombre maximum de photos (0=pas de max)
1613 1613
 	 *    @return     array       			Tableau de photos
1614 1614
 	 */
1615
-	function liste_photos($dir,$nbmax=0)
1615
+	function liste_photos($dir, $nbmax = 0)
1616 1616
 	{
1617 1617
         // phpcs:enable
1618
-		include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php';
1618
+		include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1619 1619
 
1620
-		$nbphoto=0;
1621
-		$tabobj=array();
1620
+		$nbphoto = 0;
1621
+		$tabobj = array();
1622 1622
 
1623 1623
 		$dirthumb = $dir.'thumbs/';
1624 1624
 
1625 1625
 		if (file_exists($dir))
1626 1626
 		{
1627
-			$handle=opendir($dir);
1627
+			$handle = opendir($dir);
1628 1628
             if (is_resource($handle))
1629 1629
             {
1630 1630
     			while (($file = readdir($handle)) !== false)
1631 1631
     			{
1632
-    				if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$dir.$file))
1632
+    				if (dol_is_file($dir.$file) && preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file))
1633 1633
     				{
1634 1634
     					$nbphoto++;
1635 1635
     					$photo = $file;
1636 1636
 
1637 1637
     					// On determine nom du fichier vignette
1638
-    					$photo_vignette='';
1639
-    					if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$photo,$regs))
1638
+    					$photo_vignette = '';
1639
+    					if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs))
1640 1640
     					{
1641
-    						$photo_vignette=preg_replace('/'.$regs[0].'/i','',$photo).'_small'.$regs[0];
1641
+    						$photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0];
1642 1642
     					}
1643 1643
 
1644 1644
     					// Objet
1645
-    					$obj=array();
1646
-    					$obj['photo']=$photo;
1647
-    					if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette']='thumbs/' . $photo_vignette;
1648
-    					else $obj['photo_vignette']="";
1645
+    					$obj = array();
1646
+    					$obj['photo'] = $photo;
1647
+    					if ($photo_vignette && is_file($dirthumb.$photo_vignette)) $obj['photo_vignette'] = 'thumbs/'.$photo_vignette;
1648
+    					else $obj['photo_vignette'] = "";
1649 1649
 
1650
-    					$tabobj[$nbphoto-1]=$obj;
1650
+    					$tabobj[$nbphoto - 1] = $obj;
1651 1651
 
1652 1652
     					// On continue ou on arrete de boucler
1653 1653
     					if ($nbmax && $nbphoto >= $nbmax) break;
@@ -1675,18 +1675,18 @@  discard block
 block discarded – undo
1675 1675
 
1676 1676
 	    $dir = dirname($file).'/'; // Chemin du dossier contenant l'image d'origine
1677 1677
 		$dirthumb = $dir.'/thumbs/'; // Chemin du dossier contenant la vignette
1678
-		$filename = preg_replace('/'.preg_quote($dir,'/').'/i','',$file); // Nom du fichier
1678
+		$filename = preg_replace('/'.preg_quote($dir, '/').'/i', '', $file); // Nom du fichier
1679 1679
 
1680 1680
 		// On efface l'image d'origine
1681
-		dol_delete_file($file,1);
1681
+		dol_delete_file($file, 1);
1682 1682
 
1683 1683
 		// Si elle existe, on efface la vignette
1684
-		if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i',$filename,$regs))
1684
+		if (preg_match('/(\.jpeg|\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $filename, $regs))
1685 1685
 		{
1686
-			$photo_vignette=preg_replace('/'.$regs[0].'/i','',$filename).'_small'.$regs[0];
1686
+			$photo_vignette = preg_replace('/'.$regs[0].'/i', '', $filename).'_small'.$regs[0];
1687 1687
 			if (file_exists($dirthumb.$photo_vignette))
1688 1688
 			{
1689
-				dol_delete_file($dirthumb.$photo_vignette,1);
1689
+				dol_delete_file($dirthumb.$photo_vignette, 1);
1690 1690
 			}
1691 1691
 		}
1692 1692
 	}
@@ -1723,9 +1723,9 @@  discard block
 block discarded – undo
1723 1723
 	    foreach ($langs_available as $key => $value)
1724 1724
 	    {
1725 1725
 	        $sql = "SELECT rowid";
1726
-	        $sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang";
1727
-	        $sql.= " WHERE fk_category=".$this->id;
1728
-	        $sql.= " AND lang='".$key."'";
1726
+	        $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang";
1727
+	        $sql .= " WHERE fk_category=".$this->id;
1728
+	        $sql .= " AND lang='".$key."'";
1729 1729
 
1730 1730
 	        $result = $this->db->query($sql);
1731 1731
 
@@ -1734,20 +1734,20 @@  discard block
 block discarded – undo
1734 1734
 	            if ($this->db->num_rows($result)) // si aucune ligne dans la base
1735 1735
 	            {
1736 1736
 	                $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
1737
-	                $sql2.= " SET label='".$this->db->escape($this->label)."',";
1738
-	                $sql2.= " description='".$this->db->escape($this->description)."'";
1739
-	                $sql2.= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
1737
+	                $sql2 .= " SET label='".$this->db->escape($this->label)."',";
1738
+	                $sql2 .= " description='".$this->db->escape($this->description)."'";
1739
+	                $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
1740 1740
 	            }
1741 1741
 	            else
1742 1742
 	            {
1743 1743
 	                $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
1744
-	                $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->label);
1745
-	                $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
1744
+	                $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->label);
1745
+	                $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
1746 1746
 	            }
1747 1747
 	            dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
1748
-	            if (! $this->db->query($sql2))
1748
+	            if (!$this->db->query($sql2))
1749 1749
 	            {
1750
-	                $this->error=$this->db->lasterror();
1750
+	                $this->error = $this->db->lasterror();
1751 1751
 	                return -1;
1752 1752
 	            }
1753 1753
 	        }
@@ -1756,30 +1756,30 @@  discard block
 block discarded – undo
1756 1756
 	            if ($this->db->num_rows($result)) // si aucune ligne dans la base
1757 1757
 	            {
1758 1758
 	                $sql2 = "UPDATE ".MAIN_DB_PREFIX."categorie_lang";
1759
-	                $sql2.= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
1760
-	                $sql2.= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
1761
-	                $sql2.= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
1759
+	                $sql2 .= " SET label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
1760
+	                $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
1761
+	                $sql2 .= " WHERE fk_category=".$this->id." AND lang='".$this->db->escape($key)."'";
1762 1762
 	            }
1763 1763
 	            else
1764 1764
 	            {
1765 1765
 	                $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."categorie_lang (fk_category, lang, label, description)";
1766
-	                $sql2.= " VALUES(".$this->id.",'".$key."','". $this->db->escape($this->multilangs["$key"]["label"]);
1767
-	                $sql2.= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
1766
+	                $sql2 .= " VALUES(".$this->id.",'".$key."','".$this->db->escape($this->multilangs["$key"]["label"]);
1767
+	                $sql2 .= "','".$this->db->escape($this->multilangs["$key"]["description"])."')";
1768 1768
 	            }
1769 1769
 
1770 1770
 	            // on ne sauvegarde pas des champs vides
1771
-	            if ( $this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"] )
1771
+	            if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"] || $this->multilangs["$key"]["note"])
1772 1772
 	                dol_syslog(get_class($this).'::setMultiLangs', LOG_DEBUG);
1773
-	            if (! $this->db->query($sql2))
1773
+	            if (!$this->db->query($sql2))
1774 1774
 	            {
1775
-	                $this->error=$this->db->lasterror();
1775
+	                $this->error = $this->db->lasterror();
1776 1776
 	                return -1;
1777 1777
 	            }
1778 1778
 	        }
1779 1779
 	    }
1780 1780
 
1781 1781
 			// Call trigger
1782
-			$result = $this->call_trigger('CATEGORY_SET_MULTILANGS',$user);
1782
+			$result = $this->call_trigger('CATEGORY_SET_MULTILANGS', $user);
1783 1783
 			if ($result < 0) {
1784 1784
 				$this->error = $this->db->lasterror();
1785 1785
 				return -1;
@@ -1801,28 +1801,28 @@  discard block
 block discarded – undo
1801 1801
 	    $current_lang = $langs->getDefaultLang();
1802 1802
 
1803 1803
 	    $sql = "SELECT lang, label, description";
1804
-	    $sql.= " FROM ".MAIN_DB_PREFIX."categorie_lang";
1805
-	    $sql.= " WHERE fk_category=".$this->id;
1804
+	    $sql .= " FROM ".MAIN_DB_PREFIX."categorie_lang";
1805
+	    $sql .= " WHERE fk_category=".$this->id;
1806 1806
 
1807 1807
 	    $result = $this->db->query($sql);
1808 1808
 	    if ($result)
1809 1809
 	    {
1810
-	        while ( $obj = $this->db->fetch_object($result) )
1810
+	        while ($obj = $this->db->fetch_object($result))
1811 1811
 	        {
1812 1812
 	            //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
1813
-	            if( $obj->lang == $current_lang ) // si on a les traduct. dans la langue courante on les charge en infos principales.
1813
+	            if ($obj->lang == $current_lang) // si on a les traduct. dans la langue courante on les charge en infos principales.
1814 1814
 	            {
1815
-	                $this->label		= $obj->label;
1816
-	                $this->description	= $obj->description;
1815
+	                $this->label = $obj->label;
1816
+	                $this->description = $obj->description;
1817 1817
 	            }
1818
-	            $this->multilangs["$obj->lang"]["label"]		= $obj->label;
1819
-	            $this->multilangs["$obj->lang"]["description"]	= $obj->description;
1818
+	            $this->multilangs["$obj->lang"]["label"] = $obj->label;
1819
+	            $this->multilangs["$obj->lang"]["description"] = $obj->description;
1820 1820
 	        }
1821 1821
 	        return 1;
1822 1822
 	    }
1823 1823
 	    else
1824 1824
 	    {
1825
-	        $this->error=$langs->trans("Error")." : ".$this->db->error()." - ".$sql;
1825
+	        $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
1826 1826
 	        return -1;
1827 1827
 	    }
1828 1828
 	}
@@ -1851,10 +1851,10 @@  discard block
 block discarded – undo
1851 1851
         dol_syslog(get_class($this)."::initAsSpecimen");
1852 1852
 
1853 1853
         // Initialise parametres
1854
-        $this->id=0;
1855
-        $this->fk_parent=0;
1854
+        $this->id = 0;
1855
+        $this->fk_parent = 0;
1856 1856
         $this->label = 'SPECIMEN';
1857
-        $this->specimen=1;
1857
+        $this->specimen = 1;
1858 1858
         $this->description = 'This is a description';
1859 1859
         $this->socid = 1;
1860 1860
         $this->type = self::TYPE_PRODUCT;
Please login to merge, or discard this patch.