Passed
Pull Request — master (#2)
by
unknown
26:19
created
dolibarr/htdocs/core/modules/modAdherent.class.php 1 patch
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
  *      \ingroup    member
30 30
  *      \brief      File descriptor or module Member
31 31
  */
32
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
32
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
33 33
 
34 34
 /**
35 35
  *  Class to describe and enable module Adherent
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
         $this->family = "hr";
53 53
         $this->module_position = '55';
54 54
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
55
-		$this->name = preg_replace('/^mod/i','',get_class($this));
55
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
56 56
         $this->description = "Management of members of a foundation or association";
57 57
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
58 58
         $this->version = 'dolibarr';
59 59
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-        $this->picto='user';
60
+        $this->picto = 'user';
61 61
 
62 62
         // Data directories to create when module is enabled
63 63
         $this->dirs = array("/adherent/temp");
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
         $this->config_page_url = array("adherent.php@adherents");
67 67
 
68 68
         // Dependencies
69
-        $this->hidden = false;			// A condition to hide module
70
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
71
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
72
-		$this->conflictwith = array('modMailmanSpip');	// List of module class names as string this module is in conflict with
73
-        $this->langfiles = array("members","companies");
74
-        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
69
+        $this->hidden = false; // A condition to hide module
70
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
71
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
72
+		$this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with
73
+        $this->langfiles = array("members", "companies");
74
+        $this->phpmin = array(5, 4); // Minimum version of PHP required by module
75 75
 
76 76
         // Constants
77 77
         $this->const = array();
78
-        $r=0;
78
+        $r = 0;
79 79
 
80 80
         $this->const[$r][0] = "ADHERENT_ADDON_PDF";
81 81
         $this->const[$r][1] = "chaine";
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 
182 182
         // Boxes
183 183
         //-------
184
-        $this->boxes = array(0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home'));
184
+        $this->boxes = array(0=>array('file'=>'box_members.php', 'enabledbydefaulton'=>'Home'));
185 185
 
186 186
         // Permissions
187 187
         //------------
188 188
         $this->rights = array();
189 189
         $this->rights_class = 'adherent';
190
-        $r=0;
190
+        $r = 0;
191 191
 
192 192
         // $this->rights[$r][0]     Id permission (unique tous modules confondus)
193 193
         // $this->rights[$r][1]     Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
@@ -250,12 +250,12 @@  discard block
 block discarded – undo
250 250
 
251 251
 		// Menus
252 252
 		//-------
253
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
253
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
254 254
 
255 255
 
256 256
         // Exports
257 257
         //--------
258
-        $r=0;
258
+        $r = 0;
259 259
 
260 260
         // $this->export_code[$r]          Code unique identifiant l'export (tous modules confondus)
261 261
         // $this->export_label[$r]         Libelle par defaut si traduction de cle "ExportXXX" non trouvee (XXX = Code)
@@ -265,91 +265,91 @@  discard block
 block discarded – undo
265 265
         // $this->export_sql[$r]           Requete sql qui offre les donnees a l'export
266 266
 
267 267
         $r++;
268
-        $this->export_code[$r]=$this->rights_class.'_'.$r;
269
-        $this->export_label[$r]='MembersAndSubscriptions';
270
-        $this->export_permission[$r]=array(array("adherent","export"));
271
-        $this->export_fields_array[$r]=array(
272
-			'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature',
273
-			'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country",
274
-			'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status",
275
-			'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation',
276
-			'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel',
277
-			'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount'
268
+        $this->export_code[$r] = $this->rights_class.'_'.$r;
269
+        $this->export_label[$r] = 'MembersAndSubscriptions';
270
+        $this->export_permission[$r] = array(array("adherent", "export"));
271
+        $this->export_fields_array[$r] = array(
272
+			'a.rowid'=>'Id', 'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname", 'a.firstname'=>"Firstname", 'a.login'=>"Login", 'a.gender'=>"Gender", 'a.morphy'=>'Nature',
273
+			'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town", 'd.nom'=>"State", 'co.code'=>"CountryCode", 'co.label'=>"Country",
274
+			'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile", 'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status",
275
+			'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate", 'a.datec'=>'DateCreation', 'a.datevalid'=>'DateValidation',
276
+			'a.tms'=>'DateLastModification', 'a.datefin'=>'DateEndSubscription', 'ta.rowid'=>'MemberTypeId', 'ta.libelle'=>'MemberTypeLabel',
277
+			'c.rowid'=>'SubscriptionId', 'c.dateadh'=>'DateSubscription', 'c.subscription'=>'Amount'
278 278
 		);
279
-        $this->export_TypeFields_array[$r]=array(
280
-			'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text",
281
-			'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text",
282
-			'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date',
283
-			'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric'
279
+        $this->export_TypeFields_array[$r] = array(
280
+			'a.civility'=>"Text", 'a.lastname'=>"Text", 'a.firstname'=>"Text", 'a.login'=>"Text", 'a.gender'=>'Text', 'a.morphy'=>'Text', 'a.societe'=>'Text', 'a.address'=>"Text",
281
+			'a.zip'=>"Text", 'a.town'=>"Text", 'd.nom'=>"Text", 'co.code'=>'Text', 'co.label'=>"Text", 'a.phone'=>"Text", 'a.phone_perso'=>"Text", 'a.phone_mobile'=>"Text",
282
+			'a.email'=>"Text", 'a.birth'=>"Date", 'a.statut'=>"Status", 'a.note_public'=>"Text", 'a.note_private'=>"Text", 'a.datec'=>'Date', 'a.datevalid'=>'Date',
283
+			'a.tms'=>'Date', 'a.datefin'=>'Date', 'ta.rowid'=>'List:adherent_type:libelle', 'ta.libelle'=>'Text', 'c.rowid'=>'Numeric', 'c.dateadh'=>'Date', 'c.subscription'=>'Numeric'
284 284
 		);
285
-        $this->export_entities_array[$r]=array(
286
-			'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member',
287
-			'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member",
288
-			'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member",
289
-			'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member',
290
-			'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription'
285
+        $this->export_entities_array[$r] = array(
286
+			'a.rowid'=>'member', 'a.civility'=>"member", 'a.lastname'=>"member", 'a.firstname'=>"member", 'a.login'=>"member", 'a.gender'=>'member', 'a.morphy'=>'member',
287
+			'a.societe'=>'member', 'a.address'=>"member", 'a.zip'=>"member", 'a.town'=>"member", 'd.nom'=>"member", 'co.code'=>"member", 'co.label'=>"member",
288
+			'a.phone'=>"member", 'a.phone_perso'=>"member", 'a.phone_mobile'=>"member", 'a.email'=>"member", 'a.birth'=>"member", 'a.statut'=>"member",
289
+			'a.photo'=>"member", 'a.note_public'=>"member", 'a.note_private'=>"member", 'a.datec'=>'member', 'a.datevalid'=>'member', 'a.tms'=>'member',
290
+			'a.datefin'=>'member', 'ta.rowid'=>'member_type', 'ta.libelle'=>'member_type', 'c.rowid'=>'subscription', 'c.dateadh'=>'subscription', 'c.subscription'=>'subscription'
291 291
 		);
292 292
         // Add extra fields
293
-        $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra';
293
+        $keyforselect = 'adherent'; $keyforelement = 'member'; $keyforaliasextra = 'extra';
294 294
         include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
295 295
 		// End add axtra fields
296
-        $this->export_sql_start[$r]='SELECT DISTINCT ';
297
-        $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';
298
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object';
299
-        $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid';
300
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid';
301
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid';
302
-        $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';
303
-        $this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
296
+        $this->export_sql_start[$r] = 'SELECT DISTINCT ';
297
+        $this->export_sql_end[$r]  = ' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';
298
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object';
299
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid';
300
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid';
301
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid';
302
+        $this->export_sql_end[$r] .= ' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';
303
+        $this->export_dependencies_array[$r] = array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
304 304
 
305 305
         // Imports
306 306
         //--------
307
-        $r=0;
307
+        $r = 0;
308 308
 
309
-        $now=dol_now();
309
+        $now = dol_now();
310 310
         require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
311 311
 
312 312
         $r++;
313
-        $this->import_code[$r]=$this->rights_class.'_'.$r;
314
-        $this->import_label[$r]="Members"; // Translation key
315
-        $this->import_icon[$r]=$this->picto;
316
-        $this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
317
-        $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
318
-        $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author');    // Fields to store import user id
319
-        $this->import_fields_array[$r]=array(
320
-			'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password",
321
-			"a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",
322
-			'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",
323
-			'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",
324
-			'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription'
313
+        $this->import_code[$r] = $this->rights_class.'_'.$r;
314
+        $this->import_label[$r] = "Members"; // Translation key
315
+        $this->import_icon[$r] = $this->picto;
316
+        $this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
317
+        $this->import_tables_array[$r] = array('a'=>MAIN_DB_PREFIX.'adherent', 'extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
318
+        $this->import_tables_creator_array[$r] = array('a'=>'fk_user_author'); // Fields to store import user id
319
+        $this->import_fields_array[$r] = array(
320
+			'a.civility'=>"UserTitle", 'a.lastname'=>"Lastname*", 'a.firstname'=>"Firstname", 'a.gender'=>"Gender", 'a.login'=>"Login*", "a.pass"=>"Password",
321
+			"a.fk_adherent_type"=>"MemberType*", 'a.morphy'=>'Nature*', 'a.societe'=>'Company', 'a.address'=>"Address", 'a.zip'=>"Zip", 'a.town'=>"Town",
322
+			'a.state_id'=>'StateId', 'a.country'=>"CountryId", 'a.phone'=>"PhonePro", 'a.phone_perso'=>"PhonePerso", 'a.phone_mobile'=>"PhoneMobile",
323
+			'a.email'=>"Email", 'a.birth'=>"Birthday", 'a.statut'=>"Status*", 'a.photo'=>"Photo", 'a.note_public'=>"NotePublic", 'a.note_private'=>"NotePrivate",
324
+			'a.datec'=>'DateCreation', 'a.datefin'=>'DateEndSubscription'
325 325
 		);
326 326
 		// Add extra fields
327
-		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";
328
-		$resql=$this->db->query($sql);
327
+		$sql = "SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";
328
+		$resql = $this->db->query($sql);
329 329
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
330 330
 		{
331
-		    while ($obj=$this->db->fetch_object($resql))
331
+		    while ($obj = $this->db->fetch_object($resql))
332 332
 		    {
333
-		        $fieldname='extra.'.$obj->name;
334
-		        $fieldlabel=ucfirst($obj->label);
335
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
333
+		        $fieldname = 'extra.'.$obj->name;
334
+		        $fieldlabel = ucfirst($obj->label);
335
+		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
336 336
 		    }
337 337
 		}
338 338
 		// End add extra fields
339
-		$this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent');    // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
340
-		$this->import_regex_array[$r]=array(
341
-			'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)',
342
-			'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
343
-        $this->import_examplevalues_array[$r]=array(
344
-			'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1',
345
-			'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1',
346
-			'a.email'=>'[email protected]','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member",
347
-			'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now,'%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'),'%Y-%m-%d')
339
+		$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
340
+		$this->import_regex_array[$r] = array(
341
+			'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility', 'a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type', 'a.morphy'=>'(phy|mor)',
342
+			'a.statut'=>'^[0|1]', 'a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
343
+        $this->import_examplevalues_array[$r] = array(
344
+			'a.civility'=>"MR", 'a.lastname'=>'Smith', 'a.firstname'=>'John', 'a.login'=>'jsmith', 'a.pass'=>'passofjsmith', 'a.fk_adherent_type'=>'1',
345
+			'a.morphy'=>'"mor" or "phy"', 'a.societe'=>'JS company', 'a.address'=>'21 jump street', 'a.zip'=>'55000', 'a.town'=>'New York', 'a.country'=>'1',
346
+			'a.email'=>'[email protected]', 'a.birth'=>'1972-10-10', 'a.statut'=>"0 or 1", 'a.note_public'=>"This is a public comment on member",
347
+			'a.note_private'=>"This is private comment on member", 'a.datec'=>dol_print_date($now, '%Y-%m__%d'), 'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d')
348 348
 		);
349 349
 
350 350
         // Cronjobs
351
-        $arraydate=dol_getdate(dol_now());
352
-        $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
351
+        $arraydate = dol_getdate(dol_now());
352
+        $datestart = dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
353 353
         $this->cronjobs = array(
354 354
 			0=>array(
355 355
 				'label'=>'SendReminderForExpiredSubscriptionTitle',
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
      *      @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
378 378
      *      @return     int             	1 if OK, 0 if KO
379 379
      */
380
-    function init($options='')
380
+    function init($options = '')
381 381
     {
382
-        global $conf,$langs;
382
+        global $conf, $langs;
383 383
 
384 384
         // Permissions
385 385
         $this->remove($options);
@@ -408,6 +408,6 @@  discard block
 block discarded – undo
408 408
             "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','member',".$conf->entity.")"
409 409
         );
410 410
 
411
-        return $this->_init($sql,$options);
411
+        return $this->_init($sql, $options);
412 412
     }
413 413
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modCategorie.class.php 1 patch
Spacing   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *      \ingroup    category
25 25
  *      \brief      Fichier de description et activation du module Categorie
26 26
  */
27
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
27
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
28 28
 
29 29
 
30 30
 /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		$this->family = "technic";
48 48
 		$this->module_position = '20';
49 49
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
50
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
51 51
 		$this->description = "Gestion des categories (produits, clients, fournisseurs...)";
52 52
 
53 53
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 
65 65
 		// Config pages
66 66
 		$this->config_page_url = array('categorie.php@categories');
67
-		$this->langfiles = array("products","companies","categories","members");
67
+		$this->langfiles = array("products", "companies", "categories", "members");
68 68
 
69 69
 		// Constants
70 70
 		$this->const = array();
71
-		$r=0;
71
+		$r = 0;
72 72
 		$this->const[$r][0] = "CATEGORIE_RECURSIV_ADD";
73 73
 		$this->const[$r][1] = "yesno";
74 74
 		$this->const[$r][2] = "0";
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$this->rights = array();
84 84
 		$this->rights_class = 'categorie';
85 85
 
86
-		$r=0;
86
+		$r = 0;
87 87
 
88 88
 		$this->rights[$r][0] = 241; // id de la permission
89 89
 		$this->rights[$r][1] = 'Lire les categories'; // libelle de la permission
@@ -109,115 +109,115 @@  discard block
 block discarded – undo
109 109
 
110 110
 		// Menus
111 111
 		//-------
112
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
112
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
113 113
 
114 114
 
115 115
 		// Exports
116 116
 		//--------
117
-		$r=0;
117
+		$r = 0;
118 118
 
119 119
 		$r++;
120
-		$this->export_code[$r]='category_'.$r;
121
-		$this->export_label[$r]='CatSupList';
122
-		$this->export_icon[$r]='category';
123
-		$this->export_enabled[$r]='$conf->fournisseur->enabled';
124
-		$this->export_permission[$r]=array(array("categorie","lire"),array("fournisseur","lire"));
125
-		$this->export_fields_array[$r]=array(
126
-			'u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",
127
-			's.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",
128
-			's.zip'=>"Zip",'s.town'=>"Town",'c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",
129
-			's.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",
120
+		$this->export_code[$r] = 'category_'.$r;
121
+		$this->export_label[$r] = 'CatSupList';
122
+		$this->export_icon[$r] = 'category';
123
+		$this->export_enabled[$r] = '$conf->fournisseur->enabled';
124
+		$this->export_permission[$r] = array(array("categorie", "lire"), array("fournisseur", "lire"));
125
+		$this->export_fields_array[$r] = array(
126
+			'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix",
127
+			's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address",
128
+			's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",
129
+			's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital",
130 130
 			's.note_public'=>"NotePublic"
131 131
 		);
132
-		$this->export_TypeFields_array[$r]=array(
133
-			'u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",'s.datec'=>"Date",
134
-			's.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",'c.code'=>"Text",
135
-			's.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",'s.idprof4'=>"Text",
136
-			's.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text"
132
+		$this->export_TypeFields_array[$r] = array(
133
+			'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text", 's.datec'=>"Date",
134
+			's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label", 'c.code'=>"Text",
135
+			's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text", 's.idprof4'=>"Text",
136
+			's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text"
137 137
 		);
138
-		$this->export_entities_array[$r]=array(
139
-			's.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",
140
-			's.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company",
141
-			's.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",
142
-			's.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company"
143
-		);	// We define here only fields that use another picto
144
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
145
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
138
+		$this->export_entities_array[$r] = array(
139
+			's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company",
140
+			's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",
141
+			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company",
142
+			's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company"
143
+		); // We define here only fields that use another picto
144
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
145
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
146 146
 		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, ';
147 147
 		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code';
148
-		$this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
149
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
150
-		$this->export_sql_end[$r] .=' AND u.type = 1';	// Supplier categories
148
+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
149
+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
150
+		$this->export_sql_end[$r] .= ' AND u.type = 1'; // Supplier categories
151 151
 
152 152
 		$r++;
153
-		$this->export_code[$r]='category_'.$r;
154
-		$this->export_label[$r]='CatCusList';
155
-		$this->export_icon[$r]='category';
156
-        $this->export_enabled[$r]='$conf->societe->enabled';
157
-		$this->export_permission[$r]=array(array("categorie","lire"),array("societe","lire"));
158
-		$this->export_fields_array[$r]=array(
159
-			'u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'s.rowid'=>'IdThirdParty','s.nom'=>'Name','s.prefix_comm'=>"Prefix",
160
-			's.client'=>"Customer",'s.datec'=>"DateCreation",'s.tms'=>"DateLastModification",'s.code_client'=>"CustomerCode",'s.address'=>"Address",
161
-			's.zip'=>"Zip",'s.town'=>"Town",'c.label'=>"Country",'c.code'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",
162
-			's.siret'=>"ProfId1",'s.siren'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",
163
-			's.note_public'=>"NotePublic",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus'
153
+		$this->export_code[$r] = 'category_'.$r;
154
+		$this->export_label[$r] = 'CatCusList';
155
+		$this->export_icon[$r] = 'category';
156
+        $this->export_enabled[$r] = '$conf->societe->enabled';
157
+		$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire"));
158
+		$this->export_fields_array[$r] = array(
159
+			'u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 's.rowid'=>'IdThirdParty', 's.nom'=>'Name', 's.prefix_comm'=>"Prefix",
160
+			's.client'=>"Customer", 's.datec'=>"DateCreation", 's.tms'=>"DateLastModification", 's.code_client'=>"CustomerCode", 's.address'=>"Address",
161
+			's.zip'=>"Zip", 's.town'=>"Town", 'c.label'=>"Country", 'c.code'=>"CountryCode", 's.phone'=>"Phone", 's.fax'=>"Fax", 's.url'=>"Url", 's.email'=>"Email",
162
+			's.siret'=>"ProfId1", 's.siren'=>"ProfId2", 's.ape'=>"ProfId3", 's.idprof4'=>"ProfId4", 's.tva_intra'=>"VATIntraShort", 's.capital'=>"Capital",
163
+			's.note_public'=>"NotePublic", 's.fk_prospectlevel'=>'ProspectLevel', 's.fk_stcomm'=>'ProspectStatus'
164 164
 		);
165
-		$this->export_TypeFields_array[$r]=array(
166
-			'u.label'=>"Text",'u.description'=>"Text",'s.rowid'=>'List:societe:nom','s.nom'=>'Text','s.prefix_comm'=>"Text",'s.client'=>"Text",
167
-			's.datec'=>"Date",'s.tms'=>"Date",'s.code_client'=>"Text",'s.address'=>"Text",'s.zip'=>"Text",'s.town'=>"Text",'c.label'=>"List:c_country:label:label",
168
-			'c.code'=>"Text",'s.phone'=>"Text",'s.fax'=>"Text",'s.url'=>"Text",'s.email'=>"Text",'s.siret'=>"Text",'s.siren'=>"Text",'s.ape'=>"Text",
169
-			's.idprof4'=>"Text",'s.tva_intra'=>"Text",'s.capital'=>"Numeric",'s.note_public'=>"Text",'s.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
165
+		$this->export_TypeFields_array[$r] = array(
166
+			'u.label'=>"Text", 'u.description'=>"Text", 's.rowid'=>'List:societe:nom', 's.nom'=>'Text', 's.prefix_comm'=>"Text", 's.client'=>"Text",
167
+			's.datec'=>"Date", 's.tms'=>"Date", 's.code_client'=>"Text", 's.address'=>"Text", 's.zip'=>"Text", 's.town'=>"Text", 'c.label'=>"List:c_country:label:label",
168
+			'c.code'=>"Text", 's.phone'=>"Text", 's.fax'=>"Text", 's.url'=>"Text", 's.email'=>"Text", 's.siret'=>"Text", 's.siren'=>"Text", 's.ape'=>"Text",
169
+			's.idprof4'=>"Text", 's.tva_intra'=>"Text", 's.capital'=>"Numeric", 's.note_public'=>"Text", 's.fk_prospectlevel'=>'List:c_prospectlevel:label:code',
170 170
 			's.fk_stcomm'=>'List:c_stcomm:libelle:code'
171 171
 		);
172
-		$this->export_entities_array[$r]=array(
173
-			's.rowid'=>'company','s.nom'=>'company','s.prefix_comm'=>"company",'s.client'=>"company",'s.datec'=>"company",'s.tms'=>"company",
174
-			's.code_client'=>"company",'s.address'=>"company",'s.zip'=>"company",'s.town'=>"company",'c.label'=>"company",'c.code'=>"company",
175
-			's.phone'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",
176
-			's.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note_public'=>"company",'s.fk_prospectlevel'=>'company',
172
+		$this->export_entities_array[$r] = array(
173
+			's.rowid'=>'company', 's.nom'=>'company', 's.prefix_comm'=>"company", 's.client'=>"company", 's.datec'=>"company", 's.tms'=>"company",
174
+			's.code_client'=>"company", 's.address'=>"company", 's.zip'=>"company", 's.town'=>"company", 'c.label'=>"company", 'c.code'=>"company",
175
+			's.phone'=>"company", 's.fax'=>"company", 's.url'=>"company", 's.email'=>"company", 's.siret'=>"company", 's.siren'=>"company", 's.ape'=>"company",
176
+			's.idprof4'=>"company", 's.tva_intra'=>"company", 's.capital'=>"company", 's.note_public'=>"company", 's.fk_prospectlevel'=>'company',
177 177
 			's.fk_stcomm'=>'company'
178
-		);	// We define here only fields that use another picto
179
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
180
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
178
+		); // We define here only fields that use another picto
179
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
180
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, ';
181 181
 		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';
182 182
 		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'societe as s LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as t ON s.fk_typent = t.id LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as ce ON s.fk_effectif = ce.id LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as cfj ON s.fk_forme_juridique = cfj.code LEFT JOIN '.MAIN_DB_PREFIX.'societe_extrafields as extra ON s.rowid = extra.fk_object ';
183
-		$this->export_sql_end[$r] .=' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
184
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
185
-		$this->export_sql_end[$r] .=' AND u.type = 2';	// Customer/Prospect categories
183
+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cf.fk_categorie AND cf.fk_soc = s.rowid';
184
+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
185
+		$this->export_sql_end[$r] .= ' AND u.type = 2'; // Customer/Prospect categories
186 186
 
187 187
         // Add extra fields
188
-        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
189
-        $resql=$this->db->query($sql);
188
+        $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
189
+        $resql = $this->db->query($sql);
190 190
         if ($resql)    // This can fail when class is used on old database (during migration for example)
191 191
         {
192
-            while ($obj=$this->db->fetch_object($resql))
192
+            while ($obj = $this->db->fetch_object($resql))
193 193
             {
194
-                $fieldname='extra.'.$obj->name;
195
-                $fieldlabel=ucfirst($obj->label);
196
-                $typeFilter="Text";
197
-                switch($obj->type)
194
+                $fieldname = 'extra.'.$obj->name;
195
+                $fieldlabel = ucfirst($obj->label);
196
+                $typeFilter = "Text";
197
+                switch ($obj->type)
198 198
                 {
199 199
                     case 'int':
200 200
                     case 'double':
201 201
                     case 'price':
202
-                        $typeFilter="Numeric";
202
+                        $typeFilter = "Numeric";
203 203
                         break;
204 204
                     case 'date':
205 205
                     case 'datetime':
206
-                        $typeFilter="Date";
206
+                        $typeFilter = "Date";
207 207
                         break;
208 208
                     case 'boolean':
209
-                        $typeFilter="Boolean";
209
+                        $typeFilter = "Boolean";
210 210
                         break;
211 211
                     case 'sellist':
212
-                        $typeFilter="List:".$obj->param;
212
+                        $typeFilter = "List:".$obj->param;
213 213
                         break;
214 214
                     case 'select':
215
-                        $typeFilter="Select:".$obj->param;
215
+                        $typeFilter = "Select:".$obj->param;
216 216
                         break;
217 217
                 }
218
-                $this->export_fields_array[$r][$fieldname]=$fieldlabel;
219
-                $this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
220
-                $this->export_entities_array[$r][$fieldname]='company';
218
+                $this->export_fields_array[$r][$fieldname] = $fieldlabel;
219
+                $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
220
+                $this->export_entities_array[$r][$fieldname] = 'company';
221 221
             }
222 222
         }
223 223
         // End add axtra fields
@@ -227,42 +227,42 @@  discard block
 block discarded – undo
227 227
 
228 228
 
229 229
 		$r++;
230
-		$this->export_code[$r]='category_'.$r;
231
-		$this->export_label[$r]='CatProdList';
232
-		$this->export_icon[$r]='category';
233
-        $this->export_enabled[$r]='$conf->produit->enabled';
234
-		$this->export_permission[$r]=array(array("categorie","lire"),array("produit","lire"));
235
-		$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'ProductId','p.ref'=>'Ref');
236
-		$this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.ref'=>'Text');
237
-		$this->export_entities_array[$r]=array('p.rowid'=>'product','p.ref'=>'product');	// We define here only fields that use another picto
238
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
239
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';
240
-		$this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid';
241
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
242
-		$this->export_sql_end[$r] .=' AND u.type = 0';	// Supplier categories
230
+		$this->export_code[$r] = 'category_'.$r;
231
+		$this->export_label[$r] = 'CatProdList';
232
+		$this->export_icon[$r] = 'category';
233
+        $this->export_enabled[$r] = '$conf->produit->enabled';
234
+		$this->export_permission[$r] = array(array("categorie", "lire"), array("produit", "lire"));
235
+		$this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'ProductId', 'p.ref'=>'Ref');
236
+		$this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.ref'=>'Text');
237
+		$this->export_entities_array[$r] = array('p.rowid'=>'product', 'p.ref'=>'product'); // We define here only fields that use another picto
238
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
239
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_product as cp, '.MAIN_DB_PREFIX.'product as p';
240
+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_product = p.rowid';
241
+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
242
+		$this->export_sql_end[$r] .= ' AND u.type = 0'; // Supplier categories
243 243
 
244 244
 		$r++;
245
-		$this->export_code[$r]='category_'.$r;
246
-		$this->export_label[$r]='CatMemberList';
247
-		$this->export_icon[$r]='category';
248
-        $this->export_enabled[$r]='$conf->adherent->enabled';
249
-		$this->export_permission[$r]=array(array("categorie","lire"),array("adherent","lire"));
250
-		$this->export_fields_array[$r]=array('u.rowid'=>"CategId",'u.label'=>"Label",'u.description'=>"Description",'p.rowid'=>'MemberId','p.lastname'=>'LastName','p.firstname'=>'Firstname');
251
-		$this->export_TypeFields_array[$r]=array('u.label'=>"Text",'u.description'=>"Text",'p.lastname'=>'Text','p.firstname'=>'Text');
252
-		$this->export_entities_array[$r]=array('p.rowid'=>'member','p.lastname'=>'member','p.firstname'=>'member');	// We define here only fields that use another picto
253
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
254
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p';
255
-		$this->export_sql_end[$r] .=' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';
256
-		$this->export_sql_end[$r] .=' AND u.entity IN ('.getEntity('category').')';
257
-		$this->export_sql_end[$r] .=' AND u.type = 3';	// Member categories
245
+		$this->export_code[$r] = 'category_'.$r;
246
+		$this->export_label[$r] = 'CatMemberList';
247
+		$this->export_icon[$r] = 'category';
248
+        $this->export_enabled[$r] = '$conf->adherent->enabled';
249
+		$this->export_permission[$r] = array(array("categorie", "lire"), array("adherent", "lire"));
250
+		$this->export_fields_array[$r] = array('u.rowid'=>"CategId", 'u.label'=>"Label", 'u.description'=>"Description", 'p.rowid'=>'MemberId', 'p.lastname'=>'LastName', 'p.firstname'=>'Firstname');
251
+		$this->export_TypeFields_array[$r] = array('u.label'=>"Text", 'u.description'=>"Text", 'p.lastname'=>'Text', 'p.firstname'=>'Text');
252
+		$this->export_entities_array[$r] = array('p.rowid'=>'member', 'p.lastname'=>'member', 'p.firstname'=>'member'); // We define here only fields that use another picto
253
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
254
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_member as cp, '.MAIN_DB_PREFIX.'adherent as p';
255
+		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_member = p.rowid';
256
+		$this->export_sql_end[$r] .= ' AND u.entity IN ('.getEntity('category').')';
257
+		$this->export_sql_end[$r] .= ' AND u.type = 3'; // Member categories
258 258
 
259 259
 		$r++;
260
-		$this->export_code[$r]='category_'.$r;
261
-		$this->export_label[$r]='CatContactList';
262
-		$this->export_icon[$r]='category';
263
-		$this->export_enabled[$r]='$conf->societe->enabled';
264
-		$this->export_permission[$r]=array(array("categorie", "lire"), array ("societe", "lire"));
265
-		$this->export_fields_array[$r]=array (
260
+		$this->export_code[$r] = 'category_'.$r;
261
+		$this->export_label[$r] = 'CatContactList';
262
+		$this->export_icon[$r] = 'category';
263
+		$this->export_enabled[$r] = '$conf->societe->enabled';
264
+		$this->export_permission[$r] = array(array("categorie", "lire"), array("societe", "lire"));
265
+		$this->export_fields_array[$r] = array(
266 266
 			'u.rowid' => "CategId",
267 267
 			'u.label' => "Label",
268 268
 			'u.description' => "Description",
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 			's.url'=>"Url",
298 298
 			's.email'=>"Email"
299 299
 		);
300
-		$this->export_TypeFields_array[$r] = array (
300
+		$this->export_TypeFields_array[$r] = array(
301 301
 			'u.label' => "Text",
302 302
 			'u.description' => "Text",
303 303
 			'p.lastname' => 'Text',
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 			's.url'=>"Text",
314 314
 			's.email'=>"Text"
315 315
 		);
316
-		$this->export_entities_array[$r] = array (
316
+		$this->export_entities_array[$r] = array(
317 317
 			'u.rowid' => "category",
318 318
 			'u.label' => "category",
319 319
 			'u.description' => "category",
@@ -350,127 +350,127 @@  discard block
 block discarded – undo
350 350
 		); // We define here only fields that use another picto
351 351
 
352 352
         // Add extra fields
353
-        $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'";
354
-        $resql=$this->db->query($sql);
353
+        $sql = "SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'";
354
+        $resql = $this->db->query($sql);
355 355
         if ($resql)    // This can fail when class is used on old database (during migration for example)
356 356
         {
357
-        	while ($obj=$this->db->fetch_object($resql))
357
+        	while ($obj = $this->db->fetch_object($resql))
358 358
         	{
359
-        		$fieldname='extra.'.$obj->name;
360
-        		$fieldlabel=ucfirst($obj->label);
361
-        		$typeFilter="Text";
362
-        		switch($obj->type)
359
+        		$fieldname = 'extra.'.$obj->name;
360
+        		$fieldlabel = ucfirst($obj->label);
361
+        		$typeFilter = "Text";
362
+        		switch ($obj->type)
363 363
         		{
364 364
         			case 'int':
365 365
         			case 'double':
366 366
         			case 'price':
367
-        				$typeFilter="Numeric";
367
+        				$typeFilter = "Numeric";
368 368
         				break;
369 369
         			case 'date':
370 370
         			case 'datetime':
371
-        				$typeFilter="Date";
371
+        				$typeFilter = "Date";
372 372
         				break;
373 373
         			case 'boolean':
374
-        				$typeFilter="Boolean";
374
+        				$typeFilter = "Boolean";
375 375
         				break;
376 376
         			case 'sellist':
377
-        				$typeFilter="List:".$obj->param;
377
+        				$typeFilter = "List:".$obj->param;
378 378
         				break;
379 379
 					case 'select':
380
-						$typeFilter="Select:".$obj->param;
380
+						$typeFilter = "Select:".$obj->param;
381 381
 						break;
382 382
         		}
383
-        		$this->export_fields_array[$r][$fieldname]=$fieldlabel;
384
-        		$this->export_TypeFields_array[$r][$fieldname]=$typeFilter;
385
-        		$this->export_entities_array[$r][$fieldname]='contact';
383
+        		$this->export_fields_array[$r][$fieldname] = $fieldlabel;
384
+        		$this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
385
+        		$this->export_entities_array[$r][$fieldname] = 'contact';
386 386
         	}
387 387
         }
388 388
         // End add axtra fields
389 389
 
390 390
 		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
391
-		$this->export_sql_end[$r]  = ' FROM ' . MAIN_DB_PREFIX . 'categorie as u, '.MAIN_DB_PREFIX . 'categorie_contact as cp, '.MAIN_DB_PREFIX . 'socpeople as p';
392
-		$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_country as country ON p.fk_pays = country.rowid';
393
-		$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'societe as s ON s.rowid = p.fk_soc';
394
-        $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
391
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'categorie as u, '.MAIN_DB_PREFIX.'categorie_contact as cp, '.MAIN_DB_PREFIX.'socpeople as p';
392
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as country ON p.fk_pays = country.rowid';
393
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
394
+        $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
395 395
 		$this->export_sql_end[$r] .= ' WHERE u.rowid = cp.fk_categorie AND cp.fk_socpeople = p.rowid AND u.entity IN ('.getEntity('category').')';
396 396
 		$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories
397 397
 
398 398
 		// Imports
399 399
 		//--------
400 400
 
401
-		$r=0;
401
+		$r = 0;
402 402
 
403 403
 		$r++;
404
-		$this->import_code[$r]=$this->rights_class.'_'.$r;
405
-		$this->import_label[$r]="CatList";	// Translation key
406
-		$this->import_icon[$r]=$this->picto;
407
-		$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
408
-		$this->import_tables_array[$r]=array('ca'=>MAIN_DB_PREFIX.'categorie');
409
-		$this->import_fields_array[$r]=array('ca.label'=>"Label*",'ca.type'=>"Type*",'ca.description'=>"Description");
410
-
411
-		$this->import_regex_array[$r]=array('ca.type'=>'^[0|1|2|3]');
412
-		$typeexample="";
413
-		if ($conf->product->enabled)     { $typeexample.=($typeexample?"/":"")."0=Product"; }
414
-		if ($conf->fournisseur->enabled) { $typeexample.=($typeexample?"/":"")."1=Supplier"; }
415
-		if ($conf->societe->enabled)     { $typeexample.=($typeexample?"/":"")."2=Customer-Prospect"; }
416
-		if ($conf->adherent->enabled)    { $typeexample.=($typeexample?"/":"")."3=Member"; }
417
-		$this->import_examplevalues_array[$r]=array('ca.label'=>"Supplier Category",'ca.type'=>$typeexample,'ca.description'=>"Imported category");
418
-
419
-		if (! empty($conf->product->enabled))
404
+		$this->import_code[$r] = $this->rights_class.'_'.$r;
405
+		$this->import_label[$r] = "CatList"; // Translation key
406
+		$this->import_icon[$r] = $this->picto;
407
+		$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
408
+		$this->import_tables_array[$r] = array('ca'=>MAIN_DB_PREFIX.'categorie');
409
+		$this->import_fields_array[$r] = array('ca.label'=>"Label*", 'ca.type'=>"Type*", 'ca.description'=>"Description");
410
+
411
+		$this->import_regex_array[$r] = array('ca.type'=>'^[0|1|2|3]');
412
+		$typeexample = "";
413
+		if ($conf->product->enabled) { $typeexample .= ($typeexample ? "/" : "")."0=Product"; }
414
+		if ($conf->fournisseur->enabled) { $typeexample .= ($typeexample ? "/" : "")."1=Supplier"; }
415
+		if ($conf->societe->enabled) { $typeexample .= ($typeexample ? "/" : "")."2=Customer-Prospect"; }
416
+		if ($conf->adherent->enabled) { $typeexample .= ($typeexample ? "/" : "")."3=Member"; }
417
+		$this->import_examplevalues_array[$r] = array('ca.label'=>"Supplier Category", 'ca.type'=>$typeexample, 'ca.description'=>"Imported category");
418
+
419
+		if (!empty($conf->product->enabled))
420 420
 		{
421 421
 			//Products
422 422
 			$r++;
423
-			$this->import_code[$r]=$this->rights_class.'_'.$r;
424
-			$this->import_label[$r]="CatProdLinks";	// Translation key
425
-			$this->import_icon[$r]=$this->picto;
426
-			$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
427
-			$this->import_tables_array[$r]=array('cp'=>MAIN_DB_PREFIX.'categorie_product');
428
-			$this->import_fields_array[$r]=array('cp.fk_categorie'=>"Category*",'cp.fk_product'=>"Product*"
423
+			$this->import_code[$r] = $this->rights_class.'_'.$r;
424
+			$this->import_label[$r] = "CatProdLinks"; // Translation key
425
+			$this->import_icon[$r] = $this->picto;
426
+			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
427
+			$this->import_tables_array[$r] = array('cp'=>MAIN_DB_PREFIX.'categorie_product');
428
+			$this->import_fields_array[$r] = array('cp.fk_categorie'=>"Category*", 'cp.fk_product'=>"Product*"
429 429
 			);
430 430
 
431
-			$this->import_convertvalue_array[$r]=array(
432
-					'cp.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
433
-					'cp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product')
431
+			$this->import_convertvalue_array[$r] = array(
432
+					'cp.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
433
+					'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'product')
434 434
 			);
435
-			$this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456");
435
+			$this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"Imported category", 'cp.fk_product'=>"PREF123456");
436 436
 		}
437 437
 
438
-		if (! empty($conf->societe->enabled))
438
+		if (!empty($conf->societe->enabled))
439 439
 		{
440 440
 			//Customers
441 441
 			$r++;
442
-			$this->import_code[$r]=$this->rights_class.'_'.$r;
443
-			$this->import_label[$r]="CatCusLinks";	// Translation key
444
-			$this->import_icon[$r]=$this->picto;
445
-			$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
446
-			$this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_societe');
447
-			$this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"ThirdParty*"
442
+			$this->import_code[$r] = $this->rights_class.'_'.$r;
443
+			$this->import_label[$r] = "CatCusLinks"; // Translation key
444
+			$this->import_icon[$r] = $this->picto;
445
+			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
446
+			$this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_societe');
447
+			$this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"ThirdParty*"
448 448
 			);
449 449
 
450
-			$this->import_convertvalue_array[$r]=array(
451
-					'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
452
-					'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
450
+			$this->import_convertvalue_array[$r] = array(
451
+					'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
452
+					'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')
453 453
 			);
454
-			$this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
454
+			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany");
455 455
 		}
456 456
 
457
-		if (! empty($conf->fournisseur->enabled))
457
+		if (!empty($conf->fournisseur->enabled))
458 458
 		{
459 459
 			// Suppliers
460 460
 			$r++;
461
-			$this->import_code[$r]=$this->rights_class.'_'.$r;
462
-			$this->import_label[$r]="CatSupLinks";	// Translation key
463
-			$this->import_icon[$r]=$this->picto;
464
-			$this->import_entities_array[$r]=array();		// We define here only fields that use another icon that the one defined into import_icon
465
-			$this->import_tables_array[$r]=array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur');
466
-			$this->import_fields_array[$r]=array('cs.fk_categorie'=>"Category*",'cs.fk_soc'=>"Supplier*"
461
+			$this->import_code[$r] = $this->rights_class.'_'.$r;
462
+			$this->import_label[$r] = "CatSupLinks"; // Translation key
463
+			$this->import_icon[$r] = $this->picto;
464
+			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
465
+			$this->import_tables_array[$r] = array('cs'=>MAIN_DB_PREFIX.'categorie_fournisseur');
466
+			$this->import_fields_array[$r] = array('cs.fk_categorie'=>"Category*", 'cs.fk_soc'=>"Supplier*"
467 467
 			);
468 468
 
469
-			$this->import_convertvalue_array[$r]=array(
470
-					'cs.fk_categorie'=>array('rule'=>'fetchidfromref','classfile'=>'/categories/class/categorie.class.php','class'=>'Categorie','method'=>'fetch','element'=>'category'),
471
-					'cs.fk_soc'=>array('rule'=>'fetchidfromref','classfile'=>'/societe/class/societe.class.php','class'=>'Societe','method'=>'fetch','element'=>'ThirdParty')
469
+			$this->import_convertvalue_array[$r] = array(
470
+					'cs.fk_categorie'=>array('rule'=>'fetchidfromref', 'classfile'=>'/categories/class/categorie.class.php', 'class'=>'Categorie', 'method'=>'fetch', 'element'=>'category'),
471
+					'cs.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty')
472 472
 			);
473
-			$this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
473
+			$this->import_examplevalues_array[$r] = array('cs.fk_categorie'=>"Imported category", 'cs.fk_soc'=>"MyBigCompany");
474 474
 		}
475 475
 	}
476 476
 
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
484 484
 	 *      @return     int             	1 if OK, 0 if KO
485 485
      */
486
-	function init($options='')
486
+	function init($options = '')
487 487
 	{
488 488
 		// Permissions
489 489
 		$this->remove($options);
490 490
 
491 491
 		$sql = array();
492 492
 
493
-		return $this->_init($sql,$options);
493
+		return $this->_init($sql, $options);
494 494
 	}
495 495
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modDocumentGeneration.class.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *	\brief      	Fichier de description et activation du module Generation document
26 26
  */
27 27
 
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 		$this->family = "technic";
48 48
 		$this->module_position = '80';
49 49
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
50
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
51 51
 		$this->description = "Direct mail document generation";
52 52
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53 53
 		$this->version = 'development';
54 54
 
55 55
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
-		$this->picto='email';
56
+		$this->picto = 'email';
57 57
 
58 58
 		// Data directories to create when module is enabled
59 59
 		$this->dirs = array("/documentgeneration/temp");
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$this->depends = array();
66 66
 		$this->requiredby = array();
67 67
 		$this->conflictwith = array();
68
-		$this->langfiles = array("orders","bills","companies","mails");
68
+		$this->langfiles = array("orders", "bills", "companies", "mails");
69 69
 
70 70
 		// Constants
71 71
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		$this->rights = array();
79 79
 		$this->rights_class = 'document';
80 80
 
81
-		$r=0;
81
+		$r = 0;
82 82
 
83 83
 		$this->rights[$r][0] = 1521;
84 84
 		$this->rights[$r][1] = 'Lire les documents';
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
104 104
 	 *      @return     int             	1 if OK, 0 if KO
105 105
 	 */
106
-	function init($options='')
106
+	function init($options = '')
107 107
 	{
108 108
 		global $conf;
109 109
 
@@ -112,6 +112,6 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$sql = array();
114 114
 
115
-		return $this->_init($sql,$options);
115
+		return $this->_init($sql, $options);
116 116
 	}
117 117
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modIncoterm.class.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *  \ingroup    mymodule
26 26
  *  \brief      Description and activation file for module MyModule
27 27
  */
28
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
28
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
29 29
 
30 30
 
31 31
 /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	function __construct($db)
42 42
 	{
43
-        global $langs,$conf;
43
+        global $langs, $conf;
44 44
 
45 45
         $this->db = $db;
46 46
 
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 
53 53
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
54 54
 		$this->family = "srm";
55
-		$this->name = preg_replace('/^mod/i','',get_class($this));
55
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
56 56
 		$this->description = "Incoterm management";
57 57
 		$this->version = 'dolibarr';
58 58
 		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
59 59
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='generic';
60
+		$this->picto = 'generic';
61 61
 
62 62
 		$this->module_parts = array();
63 63
 		$this->dirs = array();
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 		$this->config_page_url = array();
66 66
 
67 67
 		// Dependencies
68
-		$this->hidden = false;			// A condition to hide module
69
-		$this->depends = array();		// List of module class names as string that must be enabled if this module is enabled
70
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
71
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
72
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
73
-		$this->need_dolibarr_version = array(3,0);	// Minimum version of Dolibarr required by module
68
+		$this->hidden = false; // A condition to hide module
69
+		$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
70
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
71
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
72
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
73
+		$this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
74 74
 		$this->langfiles = array("incoterm");
75 75
 
76 76
 		$this->const = array(
@@ -80,33 +80,33 @@  discard block
 block discarded – undo
80 80
         $this->tabs = array();
81 81
 
82 82
         // Dictionaries
83
-		if (! isset($conf->incoterm->enabled))
83
+		if (!isset($conf->incoterm->enabled))
84 84
         {
85
-        	$conf->incoterm=new stdClass();
86
-        	$conf->incoterm->enabled=0;
85
+        	$conf->incoterm = new stdClass();
86
+        	$conf->incoterm->enabled = 0;
87 87
         }
88
-		$this->dictionaries=array(
88
+		$this->dictionaries = array(
89 89
 			'langs'=>'incoterm',
90
-            'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"),		// List of tables we want to see into dictonnary editor
91
-            'tablib'=>array("Incoterms"),													// Label of tables
92
-            'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'),	// Request to select fields
93
-            'tabsqlsort'=>array("rowid ASC"),															// Sort order
94
-            'tabfield'=>array("code,libelle"),															// List of fields (result of select to show dictionary)
95
-            'tabfieldvalue'=>array("code,libelle"),														// List of fields (list of fields to edit a record)
96
-            'tabfieldinsert'=>array("code,libelle"),													// List of fields (list of fields for insert)
97
-            'tabrowid'=>array("rowid"),																	// Name of columns with primary key (try to always name it 'rowid')
90
+            'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"), // List of tables we want to see into dictonnary editor
91
+            'tablib'=>array("Incoterms"), // Label of tables
92
+            'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'), // Request to select fields
93
+            'tabsqlsort'=>array("rowid ASC"), // Sort order
94
+            'tabfield'=>array("code,libelle"), // List of fields (result of select to show dictionary)
95
+            'tabfieldvalue'=>array("code,libelle"), // List of fields (list of fields to edit a record)
96
+            'tabfieldinsert'=>array("code,libelle"), // List of fields (list of fields for insert)
97
+            'tabrowid'=>array("rowid"), // Name of columns with primary key (try to always name it 'rowid')
98 98
             'tabcond'=>array($conf->incoterm->enabled)
99 99
 		);
100 100
 
101
-        $this->boxes = array();			// List of boxes
102
-		$r=0;
101
+        $this->boxes = array(); // List of boxes
102
+		$r = 0;
103 103
 
104 104
 		// Permissions
105
-		$this->rights = array();		// Permission array used by this module
106
-		$r=0;
105
+		$this->rights = array(); // Permission array used by this module
106
+		$r = 0;
107 107
 
108 108
 		// Main menu entries
109
-		$this->menus = array();			// List of menus to add
110
-		$r=0;
109
+		$this->menus = array(); // List of menus to add
110
+		$r = 0;
111 111
 	}
112 112
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modDynamicPrices.class.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
  *  \ingroup    produit
23 23
  *  \brief      File to describe module to manage dynamic prices in products
24 24
  */
25
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
25
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
26 26
 
27 27
 
28 28
 /**
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 
44 44
         $this->family = "products";
45 45
         // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
46
-        $this->name = preg_replace('/^mod/i','',get_class($this));
46
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
47 47
         $this->description = "Enable the usage of math expressions for prices";
48 48
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
49 49
         $this->version = 'experimental';
50 50
         // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
51 51
         $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
52 52
         // Name of image file used for this module.
53
-        $this->picto='technic';
53
+        $this->picto = 'technic';
54 54
 
55 55
         // Data directories to create when module is enabled
56 56
         $this->dirs = array();
@@ -81,6 +81,6 @@  discard block
 block discarded – undo
81 81
         //------------
82 82
         $this->rights = array();
83 83
         $this->rights_class = 'dynamicprices';
84
-        $r=0;
84
+        $r = 0;
85 85
     }
86 86
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php 1 patch
Spacing   +407 added lines, -407 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	public $marge_haute;
88 88
 	public $marge_basse;
89 89
 
90
-    public $emetteur;	// Objet societe qui emet
90
+    public $emetteur; // Objet societe qui emet
91 91
 
92 92
 
93 93
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function __construct($db)
99 99
 	{
100
-		global $conf,$langs,$mysoc;
100
+		global $conf, $langs, $mysoc;
101 101
 
102 102
 		// Translations
103 103
 		$langs->loadLangs(array("main", "bills", "products"));
@@ -105,45 +105,45 @@  discard block
 block discarded – undo
105 105
 		$this->db = $db;
106 106
 		$this->name = "eratosthene";
107 107
 		$this->description = $langs->trans('PDFEratostheneDescription');
108
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
108
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
109 109
 
110 110
 		// Dimension page
111 111
 		$this->type = 'pdf';
112
-		$formatarray=pdf_getFormat();
112
+		$formatarray = pdf_getFormat();
113 113
 		$this->page_largeur = $formatarray['width'];
114 114
 		$this->page_hauteur = $formatarray['height'];
115
-		$this->format = array($this->page_largeur,$this->page_hauteur);
116
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
117
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
118
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
119
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
120
-
121
-		$this->option_logo = 1;                    // Affiche logo
122
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
123
-		$this->option_modereg = 1;                 // Affiche mode reglement
124
-		$this->option_condreg = 1;                 // Affiche conditions reglement
125
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
126
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
127
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
128
-		$this->option_credit_note = 0;             // Support credit notes
129
-		$this->option_freetext = 1;				   // Support add of a personalised text
130
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
131
-
132
-		$this->franchise=!$mysoc->tva_assuj;
115
+		$this->format = array($this->page_largeur, $this->page_hauteur);
116
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
117
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
118
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
119
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
120
+
121
+		$this->option_logo = 1; // Affiche logo
122
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
123
+		$this->option_modereg = 1; // Affiche mode reglement
124
+		$this->option_condreg = 1; // Affiche conditions reglement
125
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
126
+		$this->option_multilang = 1; // Dispo en plusieurs langues
127
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
128
+		$this->option_credit_note = 0; // Support credit notes
129
+		$this->option_freetext = 1; // Support add of a personalised text
130
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
131
+
132
+		$this->franchise = !$mysoc->tva_assuj;
133 133
 
134 134
 		// Get source company
135
-		$this->emetteur=$mysoc;
136
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
135
+		$this->emetteur = $mysoc;
136
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
137 137
 
138 138
 		// Define position of columns
139
-		$this->posxdesc=$this->marge_gauche+1;
139
+		$this->posxdesc = $this->marge_gauche + 1;
140 140
 
141 141
 
142
-		$this->tva=array();
143
-		$this->localtax1=array();
144
-		$this->localtax2=array();
145
-		$this->atleastoneratenotnull=0;
146
-		$this->atleastonediscount=0;
142
+		$this->tva = array();
143
+		$this->localtax1 = array();
144
+		$this->localtax2 = array();
145
+		$this->atleastoneratenotnull = 0;
146
+		$this->atleastonediscount = 0;
147 147
 	}
148 148
 
149 149
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -158,14 +158,14 @@  discard block
 block discarded – undo
158 158
      *  @param		int			$hideref			Do not show ref
159 159
      *  @return     int             			    1=OK, 0=KO
160 160
 	 */
161
-	public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
161
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
162 162
 	{
163 163
 	    // phpcs:enable
164 164
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
165 165
 
166
-		if (! is_object($outputlangs)) $outputlangs=$langs;
166
+		if (!is_object($outputlangs)) $outputlangs = $langs;
167 167
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
168
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
168
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
169 169
 
170 170
 		// Translations
171 171
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
 			if ($object->specimen)
183 183
 			{
184 184
 				$dir = $conf->commande->dir_output;
185
-				$file = $dir . "/SPECIMEN.pdf";
185
+				$file = $dir."/SPECIMEN.pdf";
186 186
 			}
187 187
 			else
188 188
 			{
189 189
 				$objectref = dol_sanitizeFileName($object->ref);
190
-				$dir = $conf->commande->dir_output . "/" . $objectref;
191
-				$file = $dir . "/" . $objectref . ".pdf";
190
+				$dir = $conf->commande->dir_output."/".$objectref;
191
+				$file = $dir."/".$objectref.".pdf";
192 192
 			}
193 193
 
194
-			if (! file_exists($dir))
194
+			if (!file_exists($dir))
195 195
 			{
196 196
 				if (dol_mkdir($dir) < 0)
197 197
 				{
198
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
198
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
199 199
 					return 0;
200 200
 				}
201 201
 			}
@@ -203,24 +203,24 @@  discard block
 block discarded – undo
203 203
 			if (file_exists($dir))
204 204
 			{
205 205
 				// Add pdfgeneration hook
206
-				if (! is_object($hookmanager))
206
+				if (!is_object($hookmanager))
207 207
 				{
208 208
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209
-					$hookmanager=new HookManager($this->db);
209
+					$hookmanager = new HookManager($this->db);
210 210
 				}
211 211
 				$hookmanager->initHooks(array('pdfgeneration'));
212
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
212
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
213 213
 				global $action;
214
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
214
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
215 215
 
216 216
 				// Create pdf instance
217
-				$pdf=pdf_getInstance($this->format);
218
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
219
-				$pdf->SetAutoPageBreak(1,0);
217
+				$pdf = pdf_getInstance($this->format);
218
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
219
+				$pdf->SetAutoPageBreak(1, 0);
220 220
 
221
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
222
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
223
-		        $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22);	// Height reserved to output the footer (value include bottom margin)
221
+				$heightforinfotot = 40; // Height reserved to output the info and total part
222
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
223
+		        $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
224 224
 
225 225
                 if (class_exists('TCPDF'))
226 226
                 {
@@ -229,28 +229,28 @@  discard block
 block discarded – undo
229 229
                 }
230 230
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
231 231
                 // Set path to the background PDF File
232
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
232
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
233 233
                 {
234 234
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
235 235
                     $tplidx = $pdf->importPage(1);
236 236
                 }
237 237
 
238 238
 				$pdf->Open();
239
-				$pagenb=0;
240
-				$pdf->SetDrawColor(128,128,128);
239
+				$pagenb = 0;
240
+				$pdf->SetDrawColor(128, 128, 128);
241 241
 
242 242
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
243 243
 				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
244 244
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
245 245
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246 246
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
247
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
247
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
248 248
 
249
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
249
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
250 250
 
251 251
 				/// Does we have at least one line with discount $this->atleastonediscount
252 252
 				foreach ($object->lines as $line) {
253
-				    if ($line->remise_percent){
253
+				    if ($line->remise_percent) {
254 254
 				        $this->atleastonediscount = true;
255 255
 				        break;
256 256
 				    }
@@ -258,26 +258,26 @@  discard block
 block discarded – undo
258 258
 
259 259
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
260 260
 				{
261
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
262
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
263
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
264
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
265
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
261
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
262
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
263
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
264
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
265
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
266 266
 					//$this->postotalht;
267 267
 				}
268 268
 
269 269
 				// New page
270 270
 				$pdf->AddPage();
271
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
271
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
272 272
 				$pagenb++;
273 273
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
274
-				$pdf->SetFont('','', $default_font_size - 1);
275
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
276
-				$pdf->SetTextColor(0,0,0);
274
+				$pdf->SetFont('', '', $default_font_size - 1);
275
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
276
+				$pdf->SetTextColor(0, 0, 0);
277 277
 
278 278
 
279
-				$tab_top = 90+$top_shift;
280
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
279
+				$tab_top = 90 + $top_shift;
280
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
281 281
 
282 282
 				// Incoterm
283 283
 				if ($conf->incoterm->enabled)
@@ -287,40 +287,40 @@  discard block
 block discarded – undo
287 287
 					{
288 288
 						$tab_top -= 2;
289 289
 
290
-						$pdf->SetFont('','', $default_font_size - 1);
291
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
290
+						$pdf->SetFont('', '', $default_font_size - 1);
291
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
292 292
 						$nexY = $pdf->GetY();
293
-						$height_incoterms=$nexY-$tab_top;
293
+						$height_incoterms = $nexY - $tab_top;
294 294
 
295 295
 						// Rect prend une longueur en 3eme param
296
-						$pdf->SetDrawColor(192,192,192);
297
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
296
+						$pdf->SetDrawColor(192, 192, 192);
297
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
298 298
 
299
-						$tab_top = $nexY+6;
299
+						$tab_top = $nexY + 6;
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Affiche notes
304
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
305
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
304
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
305
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
306 306
 				{
307 307
 					// Get first sale rep
308 308
 					if (is_object($object->thirdparty))
309 309
 					{
310
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
311
-						$salerepobj=new User($this->db);
310
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
311
+						$salerepobj = new User($this->db);
312 312
 						$salerepobj->fetch($salereparray[0]['id']);
313
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
313
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
314 314
 					}
315 315
 				}
316 316
 
317 317
 				$pagenb = $pdf->getPage();
318 318
 				if ($notetoshow)
319 319
 				{
320
-				    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
320
+				    $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
321 321
 				    $pageposbeforenote = $pagenb;
322 322
 
323
-				    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
323
+				    $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
324 324
 				    complete_substitutions_array($substitutionarray, $outputlangs, $object);
325 325
 				    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
326 326
 
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 
329 329
 				    $pdf->startTransaction();
330 330
 
331
-				    $pdf->SetFont('','', $default_font_size - 1);
332
-				    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
331
+				    $pdf->SetFont('', '', $default_font_size - 1);
332
+				    $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
333 333
 				    // Description
334
-				    $pageposafternote=$pdf->getPage();
334
+				    $pageposafternote = $pdf->getPage();
335 335
 				    $posyafter = $pdf->GetY();
336 336
 
337
-				    if($pageposafternote>$pageposbeforenote )
337
+				    if ($pageposafternote > $pageposbeforenote)
338 338
 				    {
339 339
 				        $pdf->rollbackTransaction(true);
340 340
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				        while ($pagenb < $pageposafternote) {
343 343
 				            $pdf->AddPage();
344 344
 				            $pagenb++;
345
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
345
+				            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
346 346
 				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
347 347
 				            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348 348
 				            $pdf->setTopMargin($tab_top_newpage);
@@ -353,15 +353,15 @@  discard block
 block discarded – undo
353 353
 				        // back to start
354 354
 				        $pdf->setPage($pageposbeforenote);
355 355
 				        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
356
-				        $pdf->SetFont('','', $default_font_size - 1);
357
-				        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
358
-				        $pageposafternote=$pdf->getPage();
356
+				        $pdf->SetFont('', '', $default_font_size - 1);
357
+				        $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
358
+				        $pageposafternote = $pdf->getPage();
359 359
 
360 360
 				        $posyafter = $pdf->GetY();
361 361
 
362
-				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
362
+				        if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))	// There is no space left for total+free text
363 363
 				        {
364
-				            $pdf->AddPage('','',true);
364
+				            $pdf->AddPage('', '', true);
365 365
 				            $pagenb++;
366 366
 				            $pageposafternote++;
367 367
 				            $pdf->setPage($pageposafternote);
@@ -378,47 +378,47 @@  discard block
 block discarded – undo
378 378
 				            $pdf->setPage($i);
379 379
 
380 380
 
381
-				            $pdf->SetDrawColor(128,128,128);
381
+				            $pdf->SetDrawColor(128, 128, 128);
382 382
 				            // Draw note frame
383
-				            if($i>$pageposbeforenote){
383
+				            if ($i > $pageposbeforenote) {
384 384
 				                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
385
-				                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
385
+				                $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
386 386
 				            }
387
-				            else{
387
+				            else {
388 388
 				                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389
-				                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
389
+				                $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
390 390
 				            }
391 391
 
392 392
 				            // Add footer
393
-				            $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
394
-				            $this->_pagefoot($pdf,$object,$outputlangs,1);
393
+				            $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
394
+				            $this->_pagefoot($pdf, $object, $outputlangs, 1);
395 395
 
396 396
 				            $i++;
397 397
 				        }
398 398
 
399 399
 				        // apply note frame to last page
400 400
 				        $pdf->setPage($pageposafternote);
401
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
401
+				        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
402 402
 				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
403
-				        $height_note=$posyafter-$tab_top_newpage;
404
-				        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
403
+				        $height_note = $posyafter - $tab_top_newpage;
404
+				        $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
405 405
 				    }
406 406
 				    else // No pagebreak
407 407
 				    {
408 408
 				        $pdf->commitTransaction();
409 409
 				        $posyafter = $pdf->GetY();
410
-				        $height_note=$posyafter-$tab_top;
411
-				        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
410
+				        $height_note = $posyafter - $tab_top;
411
+				        $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
412 412
 
413 413
 
414
-				        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
414
+				        if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
415 415
 				        {
416 416
 				            // not enough space, need to add page
417
-				            $pdf->AddPage('','',true);
417
+				            $pdf->AddPage('', '', true);
418 418
 				            $pagenb++;
419 419
 				            $pageposafternote++;
420 420
 				            $pdf->setPage($pageposafternote);
421
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
421
+				            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
422 422
 				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423 423
 
424 424
 				            $posyafter = $tab_top_newpage;
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
 				    }
427 427
 
428 428
 				    $tab_height = $tab_height - $height_note;
429
-				    $tab_top = $posyafter +6;
429
+				    $tab_top = $posyafter + 6;
430 430
 				}
431 431
 				else
432 432
 				{
433
-					$height_note=0;
433
+					$height_note = 0;
434 434
 				}
435 435
 
436 436
 				$iniY = $tab_top + 7;
@@ -438,83 +438,83 @@  discard block
 block discarded – undo
438 438
 				$nexY = $tab_top + 7;
439 439
 
440 440
 				// Use new auto collum system
441
-				$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
441
+				$this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
442 442
 
443 443
 				// Loop on each lines
444
-				$pageposbeforeprintlines=$pdf->getPage();
444
+				$pageposbeforeprintlines = $pdf->getPage();
445 445
 				$pagenb = $pageposbeforeprintlines;
446
-				for ($i = 0 ; $i < $nblignes ; $i++)
446
+				for ($i = 0; $i < $nblignes; $i++)
447 447
 				{
448 448
 					$curY = $nexY;
449
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
450
-					$pdf->SetTextColor(0,0,0);
449
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
450
+					$pdf->SetTextColor(0, 0, 0);
451 451
 
452 452
 					$pdf->setTopMargin($tab_top_newpage);
453
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
454
-					$pageposbefore=$pdf->getPage();
453
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
454
+					$pageposbefore = $pdf->getPage();
455 455
 
456 456
 					// Description of product line
457
-					$curX = $this->posxdesc-1;
457
+					$curX = $this->posxdesc - 1;
458 458
 
459
-					$showpricebeforepagebreak=1;
459
+					$showpricebeforepagebreak = 1;
460 460
 
461
-					if($this->getColumnStatus('desc'))
461
+					if ($this->getColumnStatus('desc'))
462 462
 					{
463 463
     					$pdf->startTransaction();
464
-    					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465
-    					$pageposafter=$pdf->getPage();
464
+    					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
465
+    					$pageposafter = $pdf->getPage();
466 466
     					if ($pageposafter > $pageposbefore)	// There is a pagebreak
467 467
     					{
468 468
     						$pdf->rollbackTransaction(true);
469
-    						$pageposafter=$pageposbefore;
469
+    						$pageposafter = $pageposbefore;
470 470
     						//print $pageposafter.'-'.$pageposbefore;exit;
471
-    						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472
-    						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
473
-    						$pageposafter=$pdf->getPage();
474
-    						$posyafter=$pdf->GetY();
475
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
471
+    						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
472
+    						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc);
473
+    						$pageposafter = $pdf->getPage();
474
+    						$posyafter = $pdf->GetY();
475
+    						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
476 476
     						{
477
-    							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
477
+    							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
478 478
     							{
479
-    								$pdf->AddPage('','',true);
480
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
479
+    								$pdf->AddPage('', '', true);
480
+    								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
481 481
     								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482
-    								$pdf->setPage($pageposafter+1);
482
+    								$pdf->setPage($pageposafter + 1);
483 483
     							}
484 484
     						}
485 485
     						else
486 486
     						{
487 487
     							// We found a page break
488
-    							$showpricebeforepagebreak=0;
488
+    							$showpricebeforepagebreak = 0;
489 489
     						}
490 490
     					}
491 491
     					else	// No pagebreak
492 492
     					{
493 493
     						$pdf->commitTransaction();
494 494
     					}
495
-    					$posYAfterDescription=$pdf->GetY();
495
+    					$posYAfterDescription = $pdf->GetY();
496 496
 					}
497 497
 
498 498
 					$nexY = $pdf->GetY();
499
-					$pageposafter=$pdf->getPage();
499
+					$pageposafter = $pdf->getPage();
500 500
 
501 501
 					$pdf->setPage($pageposbefore);
502 502
 					$pdf->setTopMargin($this->marge_haute);
503
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
503
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
504 504
 
505 505
 					// We suppose that a too long description is moved completely on next page
506 506
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
507 507
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
508 508
 					}
509 509
 
510
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
510
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
511 511
 
512 512
 					// VAT Rate
513 513
 					if ($this->getColumnStatus('vat'))
514 514
 					{
515 515
 					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
516 516
 					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
517
-					    $nexY = max($pdf->GetY(),$nexY);
517
+					    $nexY = max($pdf->GetY(), $nexY);
518 518
 					}
519 519
 
520 520
 					// Unit price before discount
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 					{
523 523
 					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
524 524
 					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
525
-					    $nexY = max($pdf->GetY(),$nexY);
525
+					    $nexY = max($pdf->GetY(), $nexY);
526 526
 					}
527 527
 
528 528
 					// Quantity
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 					{
532 532
 					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
533 533
 					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
534
-					    $nexY = max($pdf->GetY(),$nexY);
534
+					    $nexY = max($pdf->GetY(), $nexY);
535 535
 					}
536 536
 
537 537
 
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 					{
541 541
 					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
542 542
 					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
543
-					    $nexY = max($pdf->GetY(),$nexY);
543
+					    $nexY = max($pdf->GetY(), $nexY);
544 544
 					}
545 545
 
546 546
 					// Discount on line
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 					{
549 549
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
550 550
 					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
551
-					    $nexY = max($pdf->GetY(),$nexY);
551
+					    $nexY = max($pdf->GetY(), $nexY);
552 552
 					}
553 553
 
554 554
 					// Total HT line
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
 					{
557 557
 					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
558 558
 					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
559
-					    $nexY = max($pdf->GetY(),$nexY);
559
+					    $nexY = max($pdf->GetY(), $nexY);
560 560
 					}
561 561
 
562 562
 
563
-					$parameters=array(
563
+					$parameters = array(
564 564
 					    'object' => $object,
565 565
 					    'i' => $i,
566 566
 					    'pdf' =>& $pdf,
@@ -569,56 +569,56 @@  discard block
 block discarded – undo
569 569
 					    'outputlangs' => $outputlangs,
570 570
 					    'hidedetails' => $hidedetails
571 571
 					);
572
-					$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
572
+					$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
573 573
 
574 574
 
575 575
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
576
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
577
-					else $tvaligne=$object->lines[$i]->total_tva;
576
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
577
+					else $tvaligne = $object->lines[$i]->total_tva;
578 578
 
579
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
580
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
581
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
582
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
583
-					$localtax1_type=$object->lines[$i]->localtax1_type;
584
-					$localtax2_type=$object->lines[$i]->localtax2_type;
579
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
580
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
581
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
582
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
583
+					$localtax1_type = $object->lines[$i]->localtax1_type;
584
+					$localtax2_type = $object->lines[$i]->localtax2_type;
585 585
 
586
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
587
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
588
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
586
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
587
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
588
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
589 589
 
590
-					$vatrate=(string) $object->lines[$i]->tva_tx;
590
+					$vatrate = (string) $object->lines[$i]->tva_tx;
591 591
 
592 592
 					// Retrieve type from database for backward compatibility with old records
593
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
594
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
593
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
594
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
595 595
 					{
596
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
596
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
597 597
 						$localtax1_type = $localtaxtmp_array[0];
598 598
 						$localtax2_type = $localtaxtmp_array[2];
599 599
 					}
600 600
 
601 601
 				    // retrieve global local tax
602 602
 					if ($localtax1_type && $localtax1ligne != 0)
603
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
603
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
604 604
 					if ($localtax2_type && $localtax2ligne != 0)
605
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
605
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
606 606
 
607
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
607
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
608
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
609 609
 					$this->tva[$vatrate] += $tvaligne;
610 610
 
611 611
 					// Add line
612
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
612
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
613 613
 					{
614 614
 						$pdf->setPage($pageposafter);
615
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
615
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
616 616
 						//$pdf->SetDrawColor(190,190,200);
617
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
617
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
618 618
 						$pdf->SetLineStyle(array('dash'=>0));
619 619
 					}
620 620
 
621
-					$nexY+=2;    // Passe espace entre les lignes
621
+					$nexY += 2; // Passe espace entre les lignes
622 622
 
623 623
 					// Detect if some page were added automatically and output _tableau for past pages
624 624
 					while ($pagenb < $pageposafter)
@@ -632,13 +632,13 @@  discard block
 block discarded – undo
632 632
 						{
633 633
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634 634
 						}
635
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
635
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
636 636
 						$pagenb++;
637 637
 						$pdf->setPage($pagenb);
638
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
638
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
639 639
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
640 640
 					}
641
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
641
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
642 642
 					{
643 643
 					    if ($pagenb == $pageposafter)
644 644
 						{
@@ -648,10 +648,10 @@  discard block
 block discarded – undo
648 648
 						{
649 649
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650 650
 						}
651
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
651
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
652 652
 						// New page
653 653
 						$pdf->AddPage();
654
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
654
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
655 655
 						$pagenb++;
656 656
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
657 657
 					}
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663 663
 				else
664 664
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
665
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
665
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 666
 
667 667
 				// Affiche zone infos
668
-				$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
668
+				$posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
669 669
 
670 670
 				// Affiche zone totaux
671
-				$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
671
+				$posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
672 672
 
673 673
 				// Affiche zone versements
674 674
 				/*
@@ -688,26 +688,26 @@  discard block
 block discarded – undo
688 688
 
689 689
 				// Add pdfgeneration hook
690 690
 				$hookmanager->initHooks(array('pdfgeneration'));
691
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
691
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
692 692
 				global $action;
693
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
693
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
694 694
 
695
-				if (! empty($conf->global->MAIN_UMASK))
695
+				if (!empty($conf->global->MAIN_UMASK))
696 696
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
697 697
 
698 698
 				$this->result = array('fullpath'=>$file);
699 699
 
700
-				return 1;   // Pas d'erreur
700
+				return 1; // Pas d'erreur
701 701
 			}
702 702
 			else
703 703
 			{
704
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
704
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
705 705
 				return 0;
706 706
 			}
707 707
 		}
708 708
 		else
709 709
 		{
710
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
710
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
711 711
 			return 0;
712 712
 		}
713 713
 	}
@@ -739,35 +739,35 @@  discard block
 block discarded – undo
739 739
 		global $conf;
740 740
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
741 741
 
742
-		$pdf->SetFont('','', $default_font_size - 1);
742
+		$pdf->SetFont('', '', $default_font_size - 1);
743 743
 
744 744
         // If France, show VAT mention if not applicable
745 745
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
746 746
 		{
747
-			$pdf->SetFont('','B', $default_font_size - 2);
747
+			$pdf->SetFont('', 'B', $default_font_size - 2);
748 748
 			$pdf->SetXY($this->marge_gauche, $posy);
749 749
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
750 750
 
751
-			$posy=$pdf->GetY()+4;
751
+			$posy = $pdf->GetY() + 4;
752 752
 		}
753 753
 
754
-		$posxval=52;
754
+		$posxval = 52;
755 755
 
756 756
 		// Show payments conditions
757 757
 		if ($object->cond_reglement_code || $object->cond_reglement)
758 758
 		{
759
-			$pdf->SetFont('','B', $default_font_size - 2);
759
+			$pdf->SetFont('', 'B', $default_font_size - 2);
760 760
 			$pdf->SetXY($this->marge_gauche, $posy);
761 761
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
762 762
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
763 763
 
764
-			$pdf->SetFont('','', $default_font_size - 2);
764
+			$pdf->SetFont('', '', $default_font_size - 2);
765 765
 			$pdf->SetXY($posxval, $posy);
766
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
767
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
768
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
766
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
767
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
768
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
769 769
 
770
-			$posy=$pdf->GetY()+3;
770
+			$posy = $pdf->GetY() + 3;
771 771
 		}
772 772
 
773 773
         // Check a payment mode is defined
@@ -798,34 +798,34 @@  discard block
 block discarded – undo
798 798
 		}*/
799 799
 
800 800
 	    // Show planed date of delivery
801
-        if (! empty($object->date_livraison))
801
+        if (!empty($object->date_livraison))
802 802
 		{
803 803
             $outputlangs->load("sendings");
804
-			$pdf->SetFont('','B', $default_font_size - 2);
804
+			$pdf->SetFont('', 'B', $default_font_size - 2);
805 805
 			$pdf->SetXY($this->marge_gauche, $posy);
806 806
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
807 807
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
808
-			$pdf->SetFont('','', $default_font_size - 2);
808
+			$pdf->SetFont('', '', $default_font_size - 2);
809 809
 			$pdf->SetXY($posxval, $posy);
810
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
810
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
811 811
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
812 812
 
813
-            $posy=$pdf->GetY()+1;
813
+            $posy = $pdf->GetY() + 1;
814 814
 		}
815 815
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
816 816
 		{
817
-			$pdf->SetFont('','B', $default_font_size - 2);
817
+			$pdf->SetFont('', 'B', $default_font_size - 2);
818 818
 			$pdf->SetXY($this->marge_gauche, $posy);
819 819
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820 820
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
821
-			$pdf->SetTextColor(0,0,0);
822
-			$pdf->SetFont('','', $default_font_size - 2);
821
+			$pdf->SetTextColor(0, 0, 0);
822
+			$pdf->SetFont('', '', $default_font_size - 2);
823 823
 			$pdf->SetXY($posxval, $posy);
824
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
825
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
824
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
825
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
826 826
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
827 827
 
828
-			$posy=$pdf->GetY()+1;
828
+			$posy = $pdf->GetY() + 1;
829 829
 		}
830 830
 
831 831
       	// Show payment mode
@@ -833,24 +833,24 @@  discard block
 block discarded – undo
833 833
         	 && $object->mode_reglement_code != 'CHQ'
834 834
            	 && $object->mode_reglement_code != 'VIR')
835 835
            	 {
836
-	            $pdf->SetFont('','B', $default_font_size - 2);
836
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
837 837
 	            $pdf->SetXY($this->marge_gauche, $posy);
838 838
 	            $titre = $outputlangs->transnoentities("PaymentMode").':';
839 839
 	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
840 840
 
841
-				$pdf->SetFont('','', $default_font_size - 2);
841
+				$pdf->SetFont('', '', $default_font_size - 2);
842 842
 	            $pdf->SetXY($posxval, $posy);
843
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
844
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
843
+	            $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
844
+	            $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
845 845
 
846
-	            $posy=$pdf->GetY()+2;
846
+	            $posy = $pdf->GetY() + 2;
847 847
            	 }
848 848
 
849 849
 		// Show payment mode CHQ
850 850
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
851 851
         {
852 852
         	// Si mode reglement non force ou si force a CHQ
853
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
853
+	        if (!empty($conf->global->FACTURE_CHQ_NUMBER))
854 854
 	        {
855 855
 	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
856 856
 	            {
@@ -858,31 +858,31 @@  discard block
 block discarded – undo
858 858
 	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
859 859
 
860 860
 	                $pdf->SetXY($this->marge_gauche, $posy);
861
-	                $pdf->SetFont('','B', $default_font_size - 3);
862
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
863
-		            $posy=$pdf->GetY()+1;
861
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
862
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
863
+		            $posy = $pdf->GetY() + 1;
864 864
 
865 865
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
866 866
 		            {
867 867
 		                $pdf->SetXY($this->marge_gauche, $posy);
868
-		                $pdf->SetFont('','', $default_font_size - 3);
868
+		                $pdf->SetFont('', '', $default_font_size - 3);
869 869
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
870
-			            $posy=$pdf->GetY()+2;
870
+			            $posy = $pdf->GetY() + 2;
871 871
 		            }
872 872
 	            }
873 873
 	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
874 874
 	            {
875 875
 	                $pdf->SetXY($this->marge_gauche, $posy);
876
-	                $pdf->SetFont('','B', $default_font_size - 3);
877
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
878
-		            $posy=$pdf->GetY()+1;
876
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
877
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
878
+		            $posy = $pdf->GetY() + 1;
879 879
 
880 880
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
881 881
 		            {
882 882
 			            $pdf->SetXY($this->marge_gauche, $posy);
883
-		                $pdf->SetFont('','', $default_font_size - 3);
883
+		                $pdf->SetFont('', '', $default_font_size - 3);
884 884
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
885
-			            $posy=$pdf->GetY()+2;
885
+			            $posy = $pdf->GetY() + 2;
886 886
 		            }
887 887
 	            }
888 888
 	        }
@@ -891,19 +891,19 @@  discard block
 block discarded – undo
891 891
         // If payment mode not forced or forced to VIR, show payment with BAN
892 892
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
893 893
         {
894
-			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
894
+			if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
895 895
 			{
896
-				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
897
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
896
+				$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
897
+				if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
898 898
 				$account = new Account($this->db);
899 899
 				$account->fetch($bankid);
900 900
 
901
-				$curx=$this->marge_gauche;
902
-				$cury=$posy;
901
+				$curx = $this->marge_gauche;
902
+				$cury = $posy;
903 903
 
904
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
904
+				$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
905 905
 
906
-				$posy+=2;
906
+				$posy += 2;
907 907
 			}
908 908
         }
909 909
 
@@ -923,44 +923,44 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
925 925
 	{
926
-	    global $conf,$mysoc;
926
+	    global $conf, $mysoc;
927 927
 
928 928
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
929 929
 
930 930
 		$tab2_top = $posy;
931 931
 		$tab2_hl = 4;
932
-		$pdf->SetFont('','', $default_font_size - 1);
932
+		$pdf->SetFont('', '', $default_font_size - 1);
933 933
 
934 934
 		// Tableau total
935 935
         $col1x = 120; $col2x = 170;
936 936
 		if ($this->page_largeur < 210) // To work with US executive format
937 937
 		{
938
-			$col2x-=20;
938
+			$col2x -= 20;
939 939
 		}
940 940
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941 941
 
942
-		$useborder=0;
942
+		$useborder = 0;
943 943
 		$index = 0;
944 944
 
945 945
 		// Total HT
946
-		$pdf->SetFillColor(255,255,255);
946
+		$pdf->SetFillColor(255, 255, 255);
947 947
 		$pdf->SetXY($col1x, $tab2_top + 0);
948
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
948
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
949 949
 
950 950
 		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
951 951
 		$pdf->SetXY($col2x, $tab2_top + 0);
952
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
952
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
953 953
 
954 954
 		// Show VAT by rates and total
955
-		$pdf->SetFillColor(248,248,248);
955
+		$pdf->SetFillColor(248, 248, 248);
956 956
 
957 957
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
958 958
 
959
-		$this->atleastoneratenotnull=0;
959
+		$this->atleastoneratenotnull = 0;
960 960
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
961 961
 		{
962
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
962
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
963
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
964 964
 			{
965 965
 				// Nothing to do
966 966
 			}
@@ -969,27 +969,27 @@  discard block
 block discarded – undo
969 969
 				//Local tax 1 before VAT
970 970
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971 971
 				//{
972
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
972
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
973 973
 					{
974
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
975
-						foreach( $localtax_rate as $tvakey => $tvaval )
974
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
975
+						foreach ($localtax_rate as $tvakey => $tvaval)
976 976
 						{
977
-							if ($tvakey!=0)    // On affiche pas taux 0
977
+							if ($tvakey != 0)    // On affiche pas taux 0
978 978
 							{
979 979
 								//$this->atleastoneratenotnull++;
980 980
 
981 981
 								$index++;
982 982
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 983
 
984
-								$tvacompl='';
985
-								if (preg_match('/\*/',$tvakey))
984
+								$tvacompl = '';
985
+								if (preg_match('/\*/', $tvakey))
986 986
 								{
987
-									$tvakey=str_replace('*','',$tvakey);
987
+									$tvakey = str_replace('*', '', $tvakey);
988 988
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
989 989
 								}
990
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
991
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
992
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
990
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
991
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
992
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
993 993
 
994 994
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995 995
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1000,12 +1000,12 @@  discard block
 block discarded – undo
1000 1000
 				//Local tax 2 before VAT
1001 1001
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1002 1002
 				//{
1003
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1003
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1004 1004
 					{
1005
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1006
-						foreach( $localtax_rate as $tvakey => $tvaval )
1005
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
1006
+						foreach ($localtax_rate as $tvakey => $tvaval)
1007 1007
 						{
1008
-							if ($tvakey!=0)    // On affiche pas taux 0
1008
+							if ($tvakey != 0)    // On affiche pas taux 0
1009 1009
 							{
1010 1010
 								//$this->atleastoneratenotnull++;
1011 1011
 
@@ -1014,15 +1014,15 @@  discard block
 block discarded – undo
1014 1014
 								$index++;
1015 1015
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 1016
 
1017
-								$tvacompl='';
1018
-								if (preg_match('/\*/',$tvakey))
1017
+								$tvacompl = '';
1018
+								if (preg_match('/\*/', $tvakey))
1019 1019
 								{
1020
-									$tvakey=str_replace('*','',$tvakey);
1020
+									$tvakey = str_replace('*', '', $tvakey);
1021 1021
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1022 1022
 								}
1023
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1023
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1024
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1025
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026 1026
 
1027 1027
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028 1028
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 					}
1032 1032
 				//}
1033 1033
 				// VAT
1034
-				foreach($this->tva as $tvakey => $tvaval)
1034
+				foreach ($this->tva as $tvakey => $tvaval)
1035 1035
 				{
1036 1036
 					if ($tvakey != 0)    // On affiche pas taux 0
1037 1037
 					{
@@ -1040,15 +1040,15 @@  discard block
 block discarded – undo
1040 1040
 						$index++;
1041 1041
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042 1042
 
1043
-						$tvacompl='';
1044
-						if (preg_match('/\*/',$tvakey))
1043
+						$tvacompl = '';
1044
+						if (preg_match('/\*/', $tvakey))
1045 1045
 						{
1046
-							$tvakey=str_replace('*','',$tvakey);
1046
+							$tvakey = str_replace('*', '', $tvakey);
1047 1047
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1048 1048
 						}
1049
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
1050
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
1051
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1049
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
1050
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
1051
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1052 1052
 
1053 1053
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054 1054
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1058,11 +1058,11 @@  discard block
 block discarded – undo
1058 1058
 				//Local tax 1 after VAT
1059 1059
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1060 1060
 				//{
1061
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1061
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1062 1062
 					{
1063
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1063
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1064 1064
 
1065
-						foreach( $localtax_rate as $tvakey => $tvaval )
1065
+						foreach ($localtax_rate as $tvakey => $tvaval)
1066 1066
 						{
1067 1067
 							if ($tvakey != 0)    // On affiche pas taux 0
1068 1068
 							{
@@ -1071,16 +1071,16 @@  discard block
 block discarded – undo
1071 1071
 								$index++;
1072 1072
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073 1073
 
1074
-								$tvacompl='';
1075
-								if (preg_match('/\*/',$tvakey))
1074
+								$tvacompl = '';
1075
+								if (preg_match('/\*/', $tvakey))
1076 1076
 								{
1077
-									$tvakey=str_replace('*','',$tvakey);
1077
+									$tvakey = str_replace('*', '', $tvakey);
1078 1078
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1079 1079
 								}
1080
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1080
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1081 1081
 
1082
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1083
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1082
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1083
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1084 1084
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085 1085
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1086 1086
 							}
@@ -1090,11 +1090,11 @@  discard block
 block discarded – undo
1090 1090
 				//Local tax 2 after VAT
1091 1091
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1092 1092
 				//{
1093
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1093
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1094 1094
 					{
1095
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1095
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1096 1096
 
1097
-						foreach( $localtax_rate as $tvakey => $tvaval )
1097
+						foreach ($localtax_rate as $tvakey => $tvaval)
1098 1098
 						{
1099 1099
 							if ($tvakey != 0)    // On affiche pas taux 0
1100 1100
 							{
@@ -1103,16 +1103,16 @@  discard block
 block discarded – undo
1103 1103
 								$index++;
1104 1104
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105 1105
 
1106
-								$tvacompl='';
1107
-								if (preg_match('/\*/',$tvakey))
1106
+								$tvacompl = '';
1107
+								if (preg_match('/\*/', $tvakey))
1108 1108
 								{
1109
-									$tvakey=str_replace('*','',$tvakey);
1109
+									$tvakey = str_replace('*', '', $tvakey);
1110 1110
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111 1111
 								}
1112
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1112
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1113 1113
 
1114
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1115
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1114
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1115
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116 1116
 
1117 1117
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1118 1118
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1124,24 +1124,24 @@  discard block
 block discarded – undo
1124 1124
 				// Total TTC
1125 1125
 				$index++;
1126 1126
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1127
-				$pdf->SetTextColor(0,0,60);
1128
-				$pdf->SetFillColor(224,224,224);
1129
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1127
+				$pdf->SetTextColor(0, 0, 60);
1128
+				$pdf->SetFillColor(224, 224, 224);
1129
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1130 1130
 
1131 1131
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132 1132
 				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1133 1133
 			}
1134 1134
 		}
1135 1135
 
1136
-		$pdf->SetTextColor(0,0,0);
1136
+		$pdf->SetTextColor(0, 0, 0);
1137 1137
 
1138
-        $creditnoteamount=0;
1139
-        $depositsamount=0;
1138
+        $creditnoteamount = 0;
1139
+        $depositsamount = 0;
1140 1140
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
1141 1141
 		//$depositsamount=$object->getSumDepositsUsed();
1142 1142
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1143 1143
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
-		if (! empty($object->paye)) $resteapayer=0;
1144
+		if (!empty($object->paye)) $resteapayer = 0;
1145 1145
 
1146 1146
 		if ($deja_regle > 0)
1147 1147
 		{
@@ -1149,21 +1149,21 @@  discard block
 block discarded – undo
1149 1149
 			$index++;
1150 1150
 
1151 1151
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1152
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1153 1153
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1154 1154
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1155 1155
 
1156 1156
 			$index++;
1157
-			$pdf->SetTextColor(0,0,60);
1158
-			$pdf->SetFillColor(224,224,224);
1157
+			$pdf->SetTextColor(0, 0, 60);
1158
+			$pdf->SetFillColor(224, 224, 224);
1159 1159
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1160
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1161 1161
 
1162 1162
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163 1163
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1164 1164
 
1165
-			$pdf->SetFont('','', $default_font_size - 1);
1166
-			$pdf->SetTextColor(0,0,0);
1165
+			$pdf->SetFont('', '', $default_font_size - 1);
1166
+			$pdf->SetTextColor(0, 0, 0);
1167 1167
 		}
1168 1168
 
1169 1169
 		$index++;
@@ -1183,61 +1183,61 @@  discard block
 block discarded – undo
1183 1183
 	 *   @param		string		$currency		Currency code
1184 1184
 	 *   @return	void
1185 1185
 	 */
1186
-	private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1186
+	private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1187 1187
 	{
1188 1188
 		global $conf;
1189 1189
 
1190 1190
 		// Force to disable hidetop and hidebottom
1191
-		$hidebottom=0;
1192
-		if ($hidetop) $hidetop=-1;
1191
+		$hidebottom = 0;
1192
+		if ($hidetop) $hidetop = -1;
1193 1193
 
1194 1194
 		$currency = !empty($currency) ? $currency : $conf->currency;
1195 1195
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1196 1196
 
1197 1197
 		// Amount in (at tab_top - 1)
1198
-		$pdf->SetTextColor(0,0,0);
1199
-		$pdf->SetFont('','', $default_font_size - 2);
1198
+		$pdf->SetTextColor(0, 0, 0);
1199
+		$pdf->SetFont('', '', $default_font_size - 2);
1200 1200
 
1201 1201
 		if (empty($hidetop))
1202 1202
 		{
1203
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1204
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1203
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1204
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1205 1205
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1206 1206
 
1207 1207
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1208
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1208
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1209 1209
 		}
1210 1210
 
1211
-		$pdf->SetDrawColor(128,128,128);
1212
-		$pdf->SetFont('','', $default_font_size - 1);
1211
+		$pdf->SetDrawColor(128, 128, 128);
1212
+		$pdf->SetFont('', '', $default_font_size - 1);
1213 1213
 
1214 1214
 		// Output Rect
1215
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1215
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
1216 1216
 
1217 1217
 
1218 1218
 		foreach ($this->cols as $colKey => $colDef)
1219 1219
 		{
1220
-		    if(!$this->getColumnStatus($colKey)) continue;
1220
+		    if (!$this->getColumnStatus($colKey)) continue;
1221 1221
 
1222 1222
 		    // get title label
1223
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1223
+		    $colDef['title']['label'] = !empty($colDef['title']['label']) ? $colDef['title']['label'] : $outputlangs->transnoentities($colDef['title']['textkey']);
1224 1224
 
1225 1225
 		    // Add column separator
1226
-		    if(!empty($colDef['border-left'])){
1226
+		    if (!empty($colDef['border-left'])) {
1227 1227
 		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1228 1228
 		    }
1229 1229
 
1230 1230
 		    if (empty($hidetop))
1231 1231
 		    {
1232
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1232
+		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]);
1233 1233
 
1234
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1235
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1234
+		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1];
1235
+		      $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']);
1236 1236
 		    }
1237 1237
 		}
1238 1238
 
1239
-		if (empty($hidetop)){
1240
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1239
+		if (empty($hidetop)) {
1240
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
1241 1241
 		}
1242 1242
 	}
1243 1243
 
@@ -1251,102 +1251,102 @@  discard block
 block discarded – undo
1251 1251
 	 *  @param	string		$titlekey		Translation key to show as title of document
1252 1252
 	 *  @return	void
1253 1253
 	 */
1254
-	private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1254
+	private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
1255 1255
 	{
1256
-		global $conf,$langs,$hookmanager;
1256
+		global $conf, $langs, $hookmanager;
1257 1257
 
1258 1258
 		// Translations
1259 1259
 		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1260 1260
 
1261 1261
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1262 1262
 
1263
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1263
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1264 1264
 
1265 1265
 		// Show Draft Watermark
1266
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1266
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1267 1267
 		{
1268
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1268
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1269 1269
 		}
1270 1270
 
1271
-		$pdf->SetTextColor(0,0,60);
1272
-		$pdf->SetFont('','B', $default_font_size + 3);
1271
+		$pdf->SetTextColor(0, 0, 60);
1272
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1273 1273
 
1274
-		$posy=$this->marge_haute;
1275
-		$posx=$this->page_largeur-$this->marge_droite-100;
1274
+		$posy = $this->marge_haute;
1275
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1276 1276
 
1277
-		$pdf->SetXY($this->marge_gauche,$posy);
1277
+		$pdf->SetXY($this->marge_gauche, $posy);
1278 1278
 
1279 1279
 		// Logo
1280 1280
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1281 1281
 		{
1282
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1282
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1283 1283
 			if ($this->emetteur->logo)
1284 1284
 			{
1285 1285
 				if (is_readable($logo))
1286 1286
 				{
1287
-				    $height=pdf_getHeightForLogo($logo);
1288
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1287
+				    $height = pdf_getHeightForLogo($logo);
1288
+				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1289 1289
 				}
1290 1290
 				else
1291 1291
 				{
1292
-					$pdf->SetTextColor(200,0,0);
1293
-					$pdf->SetFont('','B', $default_font_size -2);
1294
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1292
+					$pdf->SetTextColor(200, 0, 0);
1293
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1294
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1295 1295
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296 1296
 				}
1297 1297
 			}
1298 1298
 			else
1299 1299
 			{
1300
-				$text=$this->emetteur->name;
1300
+				$text = $this->emetteur->name;
1301 1301
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1302 1302
 			}
1303 1303
 		}
1304 1304
 
1305
-		$pdf->SetFont('','B', $default_font_size + 3);
1306
-		$pdf->SetXY($posx,$posy);
1307
-		$pdf->SetTextColor(0,0,60);
1308
-		$title=$outputlangs->transnoentities($titlekey);
1305
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1306
+		$pdf->SetXY($posx, $posy);
1307
+		$pdf->SetTextColor(0, 0, 60);
1308
+		$title = $outputlangs->transnoentities($titlekey);
1309 1309
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1310 1310
 
1311
-		$pdf->SetFont('','B',$default_font_size);
1311
+		$pdf->SetFont('', 'B', $default_font_size);
1312 1312
 
1313
-		$posy+=5;
1314
-		$pdf->SetXY($posx,$posy);
1315
-		$pdf->SetTextColor(0,0,60);
1316
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1313
+		$posy += 5;
1314
+		$pdf->SetXY($posx, $posy);
1315
+		$pdf->SetTextColor(0, 0, 60);
1316
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1317 1317
 
1318
-		$posy+=1;
1319
-		$pdf->SetFont('','', $default_font_size - 1);
1318
+		$posy += 1;
1319
+		$pdf->SetFont('', '', $default_font_size - 1);
1320 1320
 
1321 1321
 		if ($object->ref_client)
1322 1322
 		{
1323
-			$posy+=5;
1324
-			$pdf->SetXY($posx,$posy);
1325
-			$pdf->SetTextColor(0,0,60);
1326
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1323
+			$posy += 5;
1324
+			$pdf->SetXY($posx, $posy);
1325
+			$pdf->SetTextColor(0, 0, 60);
1326
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1327 1327
 		}
1328 1328
 
1329
-		$posy+=4;
1330
-		$pdf->SetXY($posx,$posy);
1331
-		$pdf->SetTextColor(0,0,60);
1332
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1329
+		$posy += 4;
1330
+		$pdf->SetXY($posx, $posy);
1331
+		$pdf->SetTextColor(0, 0, 60);
1332
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
1333 1333
 
1334 1334
 		// Get contact
1335 1335
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1336 1336
 		{
1337
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1337
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1338 1338
 		    if (count($arrayidcontact) > 0)
1339 1339
 		    {
1340
-                $usertmp=new User($this->db);
1340
+                $usertmp = new User($this->db);
1341 1341
 		        $usertmp->fetch($arrayidcontact[0]);
1342
-                $posy+=4;
1343
-                $pdf->SetXY($posx,$posy);
1344
-		        $pdf->SetTextColor(0,0,60);
1342
+                $posy += 4;
1343
+                $pdf->SetXY($posx, $posy);
1344
+		        $pdf->SetTextColor(0, 0, 60);
1345 1345
 		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1346 1346
 		    }
1347 1347
 		}
1348 1348
 
1349
-		$posy+=2;
1349
+		$posy += 2;
1350 1350
 
1351 1351
 		$top_shift = 0;
1352 1352
 		// Show list of linked objects
@@ -1360,54 +1360,54 @@  discard block
 block discarded – undo
1360 1360
 		if ($showaddress)
1361 1361
 		{
1362 1362
 			// Sender properties
1363
-			$carac_emetteur='';
1363
+			$carac_emetteur = '';
1364 1364
 		 	// Add internal contact of proposal if defined
1365
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1365
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1366 1366
 		 	if (count($arrayidcontact) > 0)
1367 1367
 		 	{
1368 1368
 		 		$object->fetch_user($arrayidcontact[0]);
1369
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1370
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1369
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1370
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1371 1371
 		 	}
1372 1372
 
1373 1373
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1374 1374
 
1375 1375
 			// Show sender
1376
-			$posy=42+$top_shift;
1377
-			$posx=$this->marge_gauche;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1379
-			$hautcadre=40;
1376
+			$posy = 42 + $top_shift;
1377
+			$posx = $this->marge_gauche;
1378
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1379
+			$hautcadre = 40;
1380 1380
 
1381 1381
 			// Show sender frame
1382
-			$pdf->SetTextColor(0,0,0);
1383
-			$pdf->SetFont('','', $default_font_size - 2);
1384
-			$pdf->SetXY($posx,$posy-5);
1385
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1386
-			$pdf->SetXY($posx,$posy);
1387
-			$pdf->SetFillColor(230,230,230);
1382
+			$pdf->SetTextColor(0, 0, 0);
1383
+			$pdf->SetFont('', '', $default_font_size - 2);
1384
+			$pdf->SetXY($posx, $posy - 5);
1385
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1386
+			$pdf->SetXY($posx, $posy);
1387
+			$pdf->SetFillColor(230, 230, 230);
1388 1388
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1389
-			$pdf->SetTextColor(0,0,60);
1389
+			$pdf->SetTextColor(0, 0, 60);
1390 1390
 
1391 1391
 			// Show sender name
1392
-			$pdf->SetXY($posx+2,$posy+3);
1393
-			$pdf->SetFont('','B', $default_font_size);
1392
+			$pdf->SetXY($posx + 2, $posy + 3);
1393
+			$pdf->SetFont('', 'B', $default_font_size);
1394 1394
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1395
-			$posy=$pdf->getY();
1395
+			$posy = $pdf->getY();
1396 1396
 
1397 1397
 			// Show sender information
1398
-			$pdf->SetXY($posx+2,$posy);
1399
-			$pdf->SetFont('','', $default_font_size - 1);
1398
+			$pdf->SetXY($posx + 2, $posy);
1399
+			$pdf->SetFont('', '', $default_font_size - 1);
1400 1400
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1401 1401
 
1402 1402
 
1403 1403
 
1404 1404
 			// If CUSTOMER contact defined on order, we use it
1405
-			$usecontact=false;
1406
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1405
+			$usecontact = false;
1406
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1407 1407
 			if (count($arrayidcontact) > 0)
1408 1408
 			{
1409
-				$usecontact=true;
1410
-				$result=$object->fetch_contact($arrayidcontact[0]);
1409
+				$usecontact = true;
1410
+				$result = $object->fetch_contact($arrayidcontact[0]);
1411 1411
 			}
1412 1412
 
1413 1413
 			//Recipient name
@@ -1418,38 +1418,38 @@  discard block
 block discarded – undo
1418 1418
 				$thirdparty = $object->thirdparty;
1419 1419
 			}
1420 1420
 
1421
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1421
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1422 1422
 
1423
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1423
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1424 1424
 
1425 1425
 			// Show recipient
1426
-			$widthrecbox=100;
1427
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1428
-			$posy=42+$top_shift;
1429
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1430
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1426
+			$widthrecbox = 100;
1427
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1428
+			$posy = 42 + $top_shift;
1429
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1430
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1431 1431
 
1432 1432
 			// Show recipient frame
1433
-			$pdf->SetTextColor(0,0,0);
1434
-			$pdf->SetFont('','', $default_font_size - 2);
1435
-			$pdf->SetXY($posx+2,$posy-5);
1436
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1433
+			$pdf->SetTextColor(0, 0, 0);
1434
+			$pdf->SetFont('', '', $default_font_size - 2);
1435
+			$pdf->SetXY($posx + 2, $posy - 5);
1436
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1437 1437
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1438 1438
 
1439 1439
 			// Show recipient name
1440
-			$pdf->SetXY($posx+2,$posy+3);
1441
-			$pdf->SetFont('','B', $default_font_size);
1440
+			$pdf->SetXY($posx + 2, $posy + 3);
1441
+			$pdf->SetFont('', 'B', $default_font_size);
1442 1442
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1443 1443
 
1444 1444
 			$posy = $pdf->getY();
1445 1445
 
1446 1446
 			// Show recipient information
1447
-			$pdf->SetFont('','', $default_font_size - 1);
1448
-			$pdf->SetXY($posx+2,$posy);
1447
+			$pdf->SetFont('', '', $default_font_size - 1);
1448
+			$pdf->SetXY($posx + 2, $posy);
1449 1449
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1450 1450
 		}
1451 1451
 
1452
-		$pdf->SetTextColor(0,0,0);
1452
+		$pdf->SetTextColor(0, 0, 0);
1453 1453
 		return $top_shift;
1454 1454
 	}
1455 1455
 
@@ -1462,11 +1462,11 @@  discard block
 block discarded – undo
1462 1462
 	 *      @param	int			$hidefreetext		1=Hide free text
1463 1463
 	 *      @return	int								Return height of bottom margin including footer text
1464 1464
 	 */
1465
-	private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1465
+	private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1466 1466
 	{
1467 1467
 		global $conf;
1468
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1469
-		return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1468
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1469
+		return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1470 1470
 	}
1471 1471
 
1472 1472
 
@@ -1481,20 +1481,20 @@  discard block
 block discarded – undo
1481 1481
 	 *      @param	int				$hideref		Do not show ref
1482 1482
 	 *      @return	null
1483 1483
 	 */
1484
-    public function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1484
+    public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1485 1485
     {
1486 1486
 	    global $conf, $hookmanager;
1487 1487
 
1488 1488
 	    // Default field style for content
1489 1489
 	    $this->defaultContentsFieldsStyle = array(
1490 1490
 	        'align' => 'R', // R,C,L
1491
-	        'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1491
+	        'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1492 1492
 	    );
1493 1493
 
1494 1494
 	    // Default field style for content
1495 1495
 	    $this->defaultTitlesFieldsStyle = array(
1496 1496
 	        'align' => 'C', // R,C,L
1497
-	        'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1497
+	        'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1498 1498
 	    );
1499 1499
 
1500 1500
 	    /*
@@ -1515,7 +1515,7 @@  discard block
 block discarded – undo
1515 1515
 	     );
1516 1516
 	     */
1517 1517
 
1518
-	    $rank=0; // do not use negative rank
1518
+	    $rank = 0; // do not use negative rank
1519 1519
 	    $this->cols['desc'] = array(
1520 1520
 	        'rank' => $rank,
1521 1521
 	        'width' => false, // only for desc
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
 	            'align' => 'L',
1526 1526
 	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
1527 1527
 	            // 'label' => ' ', // the final label
1528
-	            'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1528
+	            'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1529 1529
 	        ),
1530 1530
 	        'content' => array(
1531 1531
 	            'align' => 'L',
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
 	    $rank = $rank + 10;
1536 1536
 	    $this->cols['photo'] = array(
1537 1537
 	        'rank' => $rank,
1538
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1538
+	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1539 1539
 	        'status' => false,
1540 1540
 	        'title' => array(
1541 1541
 	            'textkey' => 'Photo',
1542 1542
 	            'label' => ' '
1543 1543
 	        ),
1544 1544
 	        'content' => array(
1545
-	            'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1545
+	            'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1546 1546
 	        ),
1547 1547
 	        'border-left' => false, // remove left line separator
1548 1548
 	    );
1549 1549
 
1550
-	    if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1550
+	    if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1551 1551
 	    {
1552 1552
 	        $this->cols['photo']['status'] = true;
1553 1553
 	    }
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 	        'border-left' => false, // add left line separator
1603 1603
 	    );
1604 1604
 
1605
-	    if($this->situationinvoice)
1605
+	    if ($this->situationinvoice)
1606 1606
 	    {
1607 1607
 	        $this->cols['progress']['status'] = true;
1608 1608
 	    }
@@ -1617,7 +1617,7 @@  discard block
 block discarded – undo
1617 1617
 	        ),
1618 1618
 	        'border-left' => true, // add left line separator
1619 1619
 	    );
1620
-	    if($conf->global->PRODUCT_USE_UNITS){
1620
+	    if ($conf->global->PRODUCT_USE_UNITS) {
1621 1621
 	        $this->cols['unit']['status'] = true;
1622 1622
 	    }
1623 1623
 
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 	        ),
1632 1632
 	        'border-left' => true, // add left line separator
1633 1633
 	    );
1634
-	    if ($this->atleastonediscount){
1634
+	    if ($this->atleastonediscount) {
1635 1635
 	        $this->cols['discount']['status'] = true;
1636 1636
 	    }
1637 1637
 
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 	    );
1648 1648
 
1649 1649
 
1650
-	    $parameters=array(
1650
+	    $parameters = array(
1651 1651
 	        'object' => $object,
1652 1652
 	        'outputlangs' => $outputlangs,
1653 1653
 	        'hidedetails' => $hidedetails,
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 	        'hideref' => $hideref
1656 1656
 	    );
1657 1657
 
1658
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1658
+	    $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
1659 1659
 	    if ($reshook < 0)
1660 1660
 	    {
1661 1661
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 		global $conf, $langs, $mysoc;
70 70
 
71 71
 		// Load translation files required by the page
72
-        $langs->loadLangs(array("main","companies"));
72
+        $langs->loadLangs(array("main", "companies"));
73 73
 
74 74
 		$this->db = $db;
75 75
 		$this->name = "ODT templates";
76 76
 		$this->description = $langs->trans("DocumentModelOdt");
77
-		$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH';	// Name of constant that is used to save list of directories to scan
77
+		$this->scandir = 'COMMANDE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
78 78
 
79 79
 		// Dimension page pour format A4
80 80
 		$this->type = 'odt';
81 81
 		$this->page_largeur = 0;
82 82
 		$this->page_hauteur = 0;
83
-		$this->format = array($this->page_largeur,$this->page_hauteur);
84
-		$this->marge_gauche=0;
85
-		$this->marge_droite=0;
86
-		$this->marge_haute=0;
87
-		$this->marge_basse=0;
88
-
89
-		$this->option_logo = 1;                    // Affiche logo
90
-		$this->option_tva = 0;                     // Gere option tva COMMANDE_TVAOPTION
91
-		$this->option_modereg = 0;                 // Affiche mode reglement
92
-		$this->option_condreg = 0;                 // Affiche conditions reglement
93
-		$this->option_codeproduitservice = 0;      // Affiche code produit-service
94
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
95
-		$this->option_escompte = 0;                // Affiche si il y a eu escompte
96
-		$this->option_credit_note = 0;             // Support credit notes
97
-		$this->option_freetext = 1;				   // Support add of a personalised text
98
-		$this->option_draft_watermark = 0;		   // Support add of a watermark on drafts
83
+		$this->format = array($this->page_largeur, $this->page_hauteur);
84
+		$this->marge_gauche = 0;
85
+		$this->marge_droite = 0;
86
+		$this->marge_haute = 0;
87
+		$this->marge_basse = 0;
88
+
89
+		$this->option_logo = 1; // Affiche logo
90
+		$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
91
+		$this->option_modereg = 0; // Affiche mode reglement
92
+		$this->option_condreg = 0; // Affiche conditions reglement
93
+		$this->option_codeproduitservice = 0; // Affiche code produit-service
94
+		$this->option_multilang = 1; // Dispo en plusieurs langues
95
+		$this->option_escompte = 0; // Affiche si il y a eu escompte
96
+		$this->option_credit_note = 0; // Support credit notes
97
+		$this->option_freetext = 1; // Support add of a personalised text
98
+		$this->option_draft_watermark = 0; // Support add of a watermark on drafts
99 99
 
100 100
 		// Recupere emetteur
101
-		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
101
+		$this->emetteur = $mysoc;
102
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
103 103
 	}
104 104
 
105 105
 
@@ -111,83 +111,83 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	function info($langs)
113 113
 	{
114
-		global $conf,$langs;
114
+		global $conf, $langs;
115 115
 
116 116
 		// Load translation files required by the page
117
-        $langs->loadLangs(array("errors","companies"));
117
+        $langs->loadLangs(array("errors", "companies"));
118 118
 
119 119
 		$form = new Form($this->db);
120 120
 
121 121
 		$texte = $this->description.".<br>\n";
122
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
-		$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
125
-		$texte.= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
126
-		$texte.= '<table class="nobordernopadding" width="100%">';
122
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
123
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
124
+		$texte .= '<input type="hidden" name="action" value="setModuleOptions">';
125
+		$texte .= '<input type="hidden" name="param1" value="COMMANDE_ADDON_PDF_ODT_PATH">';
126
+		$texte .= '<table class="nobordernopadding" width="100%">';
127 127
 
128 128
 		// List of directories area
129
-		$texte.= '<tr><td>';
130
-		$texttitle=$langs->trans("ListOfDirectories");
131
-		$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
132
-		$listoffiles=array();
133
-		foreach($listofdir as $key=>$tmpdir)
129
+		$texte .= '<tr><td>';
130
+		$texttitle = $langs->trans("ListOfDirectories");
131
+		$listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)));
132
+		$listoffiles = array();
133
+		foreach ($listofdir as $key=>$tmpdir)
134 134
 		{
135
-			$tmpdir=trim($tmpdir);
136
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
-			if (! $tmpdir) {
135
+			$tmpdir = trim($tmpdir);
136
+			$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
137
+			if (!$tmpdir) {
138 138
 				unset($listofdir[$key]); continue;
139 139
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
140
+			if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
141 141
 			else
142 142
 			{
143
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
143
+				$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
144
+				if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
145 145
 			}
146 146
 		}
147
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
147
+		$texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
148 148
 		// Add list of substitution keys
149
-		$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
-		$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation");    // This contains an url, we don't modify it
151
-
152
-		$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
153
-		$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
-		$texte.= '<textarea class="flat" cols="60" name="value1">';
155
-		$texte.=$conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
156
-		$texte.= '</textarea>';
157
-		$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
158
-		$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
-		$texte.= '<br></div></div>';
149
+		$texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
150
+		$texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
151
+
152
+		$texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
153
+		$texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
154
+		$texte .= '<textarea class="flat" cols="60" name="value1">';
155
+		$texte .= $conf->global->COMMANDE_ADDON_PDF_ODT_PATH;
156
+		$texte .= '</textarea>';
157
+		$texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
158
+		$texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
159
+		$texte .= '<br></div></div>';
160 160
 
161 161
 		// Scan directories
162
-		$nbofiles=count($listoffiles);
163
-		if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
162
+		$nbofiles = count($listoffiles);
163
+		if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
164 164
 		{
165
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
165
+			$texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
166 166
 			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
-			$texte.=count($listoffiles);
167
+			$texte .= count($listoffiles);
168 168
 			//$texte.=$nbofiles?'</a>':'';
169
-			$texte.='</b>';
169
+			$texte .= '</b>';
170 170
 		}
171 171
 
172 172
 		if ($nbofiles)
173 173
 		{
174
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
175
-   			foreach($listoffiles as $file)
174
+   			$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
175
+   			foreach ($listoffiles as $file)
176 176
    			{
177
-                $texte.=$file['name'].'<br>';
177
+                $texte .= $file['name'].'<br>';
178 178
    			}
179
-   			$texte.='<div id="div_'.get_class($this).'">';
179
+   			$texte .= '<div id="div_'.get_class($this).'">';
180 180
 		}
181 181
 
182
-		$texte.= '</td>';
182
+		$texte .= '</td>';
183 183
 
184
-		$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
185
-		$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
186
-		$texte.= '</td>';
187
-		$texte.= '</tr>';
184
+		$texte .= '<td valign="top" rowspan="2" class="hideonsmartphone">';
185
+		$texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
186
+		$texte .= '</td>';
187
+		$texte .= '</tr>';
188 188
 
189
-		$texte.= '</table>';
190
-		$texte.= '</form>';
189
+		$texte .= '</table>';
190
+		$texte .= '</form>';
191 191
 
192 192
 		return $texte;
193 193
 	}
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 	 *  @param		int			$hideref			Do not show ref
205 205
 	 *	@return		int         					1 if OK, <=0 if KO
206 206
 	 */
207
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
207
+	function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
208 208
 	{
209 209
         // phpcs:enable
210
-		global $user,$langs,$conf,$mysoc,$hookmanager;
210
+		global $user, $langs, $conf, $mysoc, $hookmanager;
211 211
 
212 212
 		if (empty($srctemplatepath))
213 213
 		{
@@ -216,45 +216,45 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 
218 218
 		// Add odtgeneration hook
219
-		if (! is_object($hookmanager))
219
+		if (!is_object($hookmanager))
220 220
 		{
221 221
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
222
-			$hookmanager=new HookManager($this->db);
222
+			$hookmanager = new HookManager($this->db);
223 223
 		}
224 224
 		$hookmanager->initHooks(array('odtgeneration'));
225 225
 		global $action;
226 226
 
227
-		if (! is_object($outputlangs)) $outputlangs=$langs;
228
-		$sav_charset_output=$outputlangs->charset_output;
229
-		$outputlangs->charset_output='UTF-8';
227
+		if (!is_object($outputlangs)) $outputlangs = $langs;
228
+		$sav_charset_output = $outputlangs->charset_output;
229
+		$outputlangs->charset_output = 'UTF-8';
230 230
 
231 231
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232 232
 
233 233
 		if ($conf->commande->dir_output)
234 234
 		{
235 235
 			// If $object is id instead of object
236
-			if (! is_object($object))
236
+			if (!is_object($object))
237 237
 			{
238 238
 				$id = $object;
239 239
 				$object = new Commande($this->db);
240
-				$result=$object->fetch($id);
240
+				$result = $object->fetch($id);
241 241
 				if ($result < 0)
242 242
 				{
243
-					dol_print_error($this->db,$object->error);
243
+					dol_print_error($this->db, $object->error);
244 244
 					return -1;
245 245
 				}
246 246
 			}
247 247
 
248 248
 			$dir = $conf->commande->dir_output;
249 249
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
-			$file = $dir . "/" . $objectref . ".odt";
250
+			if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
251
+			$file = $dir."/".$objectref.".odt";
252 252
 
253
-			if (! file_exists($dir))
253
+			if (!file_exists($dir))
254 254
 			{
255 255
 				if (dol_mkdir($dir) < 0)
256 256
 				{
257
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
257
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
258 258
 					return -1;
259 259
 				}
260 260
 			}
@@ -262,25 +262,25 @@  discard block
 block discarded – undo
262 262
 			if (file_exists($dir))
263 263
 			{
264 264
 				//print "srctemplatepath=".$srctemplatepath;	// Src filename
265
-				$newfile=basename($srctemplatepath);
266
-				$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
267
-				$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
268
-				$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
269
-				$newfiletmp=$objectref.'_'.$newfiletmp;
265
+				$newfile = basename($srctemplatepath);
266
+				$newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
267
+				$newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
268
+				$newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
269
+				$newfiletmp = $objectref.'_'.$newfiletmp;
270 270
 				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271 271
 				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
272
+				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
273
+				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
274 274
 				{
275
-				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
277
-					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
275
+				    $format = $conf->global->MAIN_DOC_USE_TIMING;
276
+				    if ($format == '1') $format = '%Y%m%d%H%M%S';
277
+					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
278 278
 				}
279 279
 				else
280 280
 				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
281
+					$filename = $newfiletmp.'.'.$newfileformat;
282 282
 				}
283
-				$file=$dir.'/'.$filename;
283
+				$file = $dir.'/'.$filename;
284 284
 				//print "newdir=".$dir;
285 285
 				//print "newfile=".$newfile;
286 286
 				//print "file=".$file;
@@ -290,20 +290,20 @@  discard block
 block discarded – undo
290 290
 
291 291
 
292 292
 				// If CUSTOMER contact defined on order, we use it
293
-				$usecontact=false;
294
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
293
+				$usecontact = false;
294
+				$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
295 295
 				if (count($arrayidcontact) > 0)
296 296
 				{
297
-					$usecontact=true;
298
-					$result=$object->fetch_contact($arrayidcontact[0]);
297
+					$usecontact = true;
298
+					$result = $object->fetch_contact($arrayidcontact[0]);
299 299
 				}
300 300
 
301 301
 				// Recipient name
302
-				$contactobject=null;
303
-				if (! empty($usecontact))
302
+				$contactobject = null;
303
+				if (!empty($usecontact))
304 304
 				{
305 305
 					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
306
+					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
307 307
 					else {
308 308
                         $socobject = $object->thirdparty;
309 309
                			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 				}
313 313
 				else
314 314
 				{
315
-					$socobject=$object->thirdparty;
315
+					$socobject = $object->thirdparty;
316 316
 				}
317 317
 
318 318
 				// Make substitution
319
-				$substitutionarray=array(
319
+				$substitutionarray = array(
320 320
 				'__FROM_NAME__' => $this->emetteur->name,
321 321
 				'__FROM_EMAIL__' => $this->emetteur->email,
322 322
 				'__TOTAL_TTC__' => $object->total_ttc,
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 				);
326 326
 				complete_substitutions_array($substitutionarray, $langs, $object);
327 327
 				// Call the ODTSubstitution hook
328
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
329
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
328
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
329
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
330 330
 
331 331
 				// Line of free text
332
-				$newfreetext='';
333
-				$paramfreetext='ORDER_FREE_TEXT';
334
-				if (! empty($conf->global->$paramfreetext))
332
+				$newfreetext = '';
333
+				$paramfreetext = 'ORDER_FREE_TEXT';
334
+				if (!empty($conf->global->$paramfreetext))
335 335
 				{
336
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
336
+					$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
337 337
 				}
338 338
 
339 339
 				// Open and load template
@@ -343,15 +343,15 @@  discard block
 block discarded – undo
343 343
 						$srctemplatepath,
344 344
 						array(
345 345
 						'PATH_TO_TMP'	  => $conf->commande->dir_temp,
346
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
346
+						'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
347 347
 						'DELIMITER_LEFT'  => '{',
348 348
 						'DELIMITER_RIGHT' => '}'
349 349
 						)
350 350
 					);
351 351
 				}
352
-				catch(Exception $e)
352
+				catch (Exception $e)
353 353
 				{
354
-					$this->error=$e->getMessage();
354
+					$this->error = $e->getMessage();
355 355
 					dol_syslog($e->getMessage(), LOG_INFO);
356 356
 					return -1;
357 357
 				}
@@ -366,34 +366,34 @@  discard block
 block discarded – undo
366 366
 				try {
367 367
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368 368
 				}
369
-				catch(OdfException $e)
369
+				catch (OdfException $e)
370 370
 				{
371 371
                     dol_syslog($e->getMessage(), LOG_INFO);
372 372
 				}
373 373
 
374 374
 				// Define substitution array
375 375
 				$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
376
-				$array_object_from_properties=$this->get_substitutionarray_each_var_object($object, $outputlangs);
377
-				$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
378
-				$array_user=$this->get_substitutionarray_user($user,$outputlangs);
379
-				$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
380
-				$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
381
-				$array_other=$this->get_substitutionarray_other($outputlangs);
376
+				$array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
377
+				$array_objet = $this->get_substitutionarray_object($object, $outputlangs);
378
+				$array_user = $this->get_substitutionarray_user($user, $outputlangs);
379
+				$array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
380
+				$array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
381
+				$array_other = $this->get_substitutionarray_other($outputlangs);
382 382
 				// retrieve contact information for use in object as contact_xxx tags
383 383
 				$array_thirdparty_contact = array();
384
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
384
+				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
385 385
 
386
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
386
+				$tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
387 387
 				complete_substitutions_array($tmparray, $outputlangs, $object);
388 388
 
389 389
 				// Call the ODTSubstitution hook
390
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
391
-				$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
390
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
391
+				$reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
392 392
 
393
-				foreach($tmparray as $key=>$value)
393
+				foreach ($tmparray as $key=>$value)
394 394
 				{
395 395
 					try {
396
-						if (preg_match('/logo$/',$key)) // Image
396
+						if (preg_match('/logo$/', $key)) // Image
397 397
 						{
398 398
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
399 399
 							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
404 404
 						}
405 405
 					}
406
-					catch(OdfException $e)
406
+					catch (OdfException $e)
407 407
 					{
408 408
                         dol_syslog($e->getMessage(), LOG_INFO);
409 409
 					}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 					try {
416 416
 						$listlines = $odfHandler->setSegment('lines');
417 417
 					}
418
-					catch(OdfException $e)
418
+					catch (OdfException $e)
419 419
 					{
420 420
 						// We may arrive here if tags for lines not present into template
421 421
 						$foundtagforlines = 0;
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 					{
426 426
 						foreach ($object->lines as $line)
427 427
 						{
428
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
428
+							$tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
429 429
 							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
430 430
 							// Call the ODTSubstitutionLine hook
431
-							$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
432
-							$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
433
-							foreach($tmparray as $key => $val)
431
+							$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
432
+							$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
433
+							foreach ($tmparray as $key => $val)
434 434
 							{
435 435
 								try
436 436
 								{
437 437
 									$listlines->setVars($key, $val, true, 'UTF-8');
438 438
 								}
439
-								catch(OdfException $e)
439
+								catch (OdfException $e)
440 440
 								{
441 441
                                     dol_syslog($e->getMessage(), LOG_INFO);
442 442
 								}
443
-								catch(SegmentException $e)
443
+								catch (SegmentException $e)
444 444
 								{
445 445
                                     dol_syslog($e->getMessage(), LOG_INFO);
446 446
 								}
@@ -450,21 +450,21 @@  discard block
 block discarded – undo
450 450
 						$odfHandler->mergeSegment($listlines);
451 451
 					}
452 452
 				}
453
-				catch(OdfException $e)
453
+				catch (OdfException $e)
454 454
 				{
455
-					$this->error=$e->getMessage();
455
+					$this->error = $e->getMessage();
456 456
 					dol_syslog($this->error, LOG_WARNING);
457 457
 					return -1;
458 458
 				}
459 459
 
460 460
 				// Replace labels translated
461
-				$tmparray=$outputlangs->get_translations_for_substitutions();
462
-				foreach($tmparray as $key=>$value)
461
+				$tmparray = $outputlangs->get_translations_for_substitutions();
462
+				foreach ($tmparray as $key=>$value)
463 463
 				{
464 464
 					try {
465 465
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
466 466
 					}
467
-					catch(OdfException $e)
467
+					catch (OdfException $e)
468 468
 					{
469 469
                         dol_syslog($e->getMessage(), LOG_INFO);
470 470
 					}
@@ -472,15 +472,15 @@  discard block
 block discarded – undo
472 472
 
473 473
 				// Call the beforeODTSave hook
474 474
 
475
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
476
-				$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
475
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
476
+				$reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
477 477
 
478 478
 				// Write new file
479 479
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480 480
 					try {
481 481
 						$odfHandler->exportAsAttachedPDF($file);
482
-					}catch (Exception $e){
483
-                        $this->error=$e->getMessage();
482
+					} catch (Exception $e) {
483
+                        $this->error = $e->getMessage();
484 484
                         dol_syslog($e->getMessage(), LOG_INFO);
485 485
 						return -1;
486 486
 					}
@@ -489,27 +489,27 @@  discard block
 block discarded – undo
489 489
 					try {
490 490
 					$odfHandler->saveToDisk($file);
491 491
 					} catch (Exception $e) {
492
-                        $this->error=$e->getMessage();
492
+                        $this->error = $e->getMessage();
493 493
                         dol_syslog($e->getMessage(), LOG_INFO);
494 494
 						return -1;
495 495
 					}
496 496
 				}
497 497
 
498
-				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
499
-				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
498
+				$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
499
+				$reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
500 500
 
501
-				if (! empty($conf->global->MAIN_UMASK))
501
+				if (!empty($conf->global->MAIN_UMASK))
502 502
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
503 503
 
504
-				$odfHandler=null;	// Destroy object
504
+				$odfHandler = null; // Destroy object
505 505
 
506 506
 				$this->result = array('fullpath'=>$file);
507 507
 
508
-				return 1;   // Success
508
+				return 1; // Success
509 509
 			}
510 510
 			else
511 511
 			{
512
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
512
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
513 513
 				return -1;
514 514
 			}
515 515
 		}
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/pdf_einstein.modules.php 1 patch
Spacing   +403 added lines, -403 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function __construct($db)
130 130
 	{
131
-		global $conf,$langs,$mysoc;
131
+		global $conf, $langs, $mysoc;
132 132
 
133 133
 		// Translations
134 134
 		$langs->loadLangs(array("main", "bills", "products"));
@@ -136,71 +136,71 @@  discard block
 block discarded – undo
136 136
 		$this->db = $db;
137 137
 		$this->name = "einstein";
138 138
 		$this->description = $langs->trans('PDFEinsteinDescription');
139
-		$this->update_main_doc_field = 1;		// Save the name of generated file as the main doc when generating a doc with this template
139
+		$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
140 140
 
141 141
 		// Dimension page
142 142
 		$this->type = 'pdf';
143
-		$formatarray=pdf_getFormat();
143
+		$formatarray = pdf_getFormat();
144 144
 		$this->page_largeur = $formatarray['width'];
145 145
 		$this->page_hauteur = $formatarray['height'];
146
-		$this->format = array($this->page_largeur,$this->page_hauteur);
147
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
148
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
149
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
150
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
151
-
152
-		$this->option_logo = 1;                    // Display logo
153
-		$this->option_tva = 1;                     // Manage the vat option FACTURE_TVAOPTION
154
-		$this->option_modereg = 1;                 // Display payment mode
155
-		$this->option_condreg = 1;                 // Display payment terms
156
-		$this->option_codeproduitservice = 1;      // Display product-service code
157
-		$this->option_multilang = 1;               // Available in several languages
158
-		$this->option_escompte = 0;                // Displays if there has been a discount
159
-		$this->option_credit_note = 0;             // Support credit notes
160
-		$this->option_freetext = 1;				   // Support add of a personalised text
161
-		$this->option_draft_watermark = 1;		   // Support add of a watermark on drafts
162
-
163
-		$this->franchise=!$mysoc->tva_assuj;
146
+		$this->format = array($this->page_largeur, $this->page_hauteur);
147
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
148
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
149
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
150
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
151
+
152
+		$this->option_logo = 1; // Display logo
153
+		$this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION
154
+		$this->option_modereg = 1; // Display payment mode
155
+		$this->option_condreg = 1; // Display payment terms
156
+		$this->option_codeproduitservice = 1; // Display product-service code
157
+		$this->option_multilang = 1; // Available in several languages
158
+		$this->option_escompte = 0; // Displays if there has been a discount
159
+		$this->option_credit_note = 0; // Support credit notes
160
+		$this->option_freetext = 1; // Support add of a personalised text
161
+		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
162
+
163
+		$this->franchise = !$mysoc->tva_assuj;
164 164
 
165 165
 		// Get source company
166
-		$this->emetteur=$mysoc;
167
-		if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
166
+		$this->emetteur = $mysoc;
167
+		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
168 168
 
169 169
 		// Define position of columns
170
-		$this->posxdesc=$this->marge_gauche+1;
171
-		if($conf->global->PRODUCT_USE_UNITS)
170
+		$this->posxdesc = $this->marge_gauche + 1;
171
+		if ($conf->global->PRODUCT_USE_UNITS)
172 172
 		{
173
-			$this->posxtva=101;
174
-			$this->posxup=118;
175
-			$this->posxqty=135;
176
-			$this->posxunit=151;
173
+			$this->posxtva = 101;
174
+			$this->posxup = 118;
175
+			$this->posxqty = 135;
176
+			$this->posxunit = 151;
177 177
 		}
178 178
 		else
179 179
 		{
180
-			$this->posxtva=110;
181
-			$this->posxup=126;
182
-			$this->posxqty=145;
180
+			$this->posxtva = 110;
181
+			$this->posxup = 126;
182
+			$this->posxqty = 145;
183 183
 		}
184
-		$this->posxdiscount=162;
185
-		$this->postotalht=174;
186
-		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup;
187
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
184
+		$this->posxdiscount = 162;
185
+		$this->postotalht = 174;
186
+		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
187
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
188 188
 		if ($this->page_largeur < 210) // To work with US executive format
189 189
 		{
190
-			$this->posxpicture-=20;
191
-			$this->posxtva-=20;
192
-			$this->posxup-=20;
193
-			$this->posxqty-=20;
194
-			$this->posxunit-=20;
195
-			$this->posxdiscount-=20;
196
-			$this->postotalht-=20;
190
+			$this->posxpicture -= 20;
191
+			$this->posxtva -= 20;
192
+			$this->posxup -= 20;
193
+			$this->posxqty -= 20;
194
+			$this->posxunit -= 20;
195
+			$this->posxdiscount -= 20;
196
+			$this->postotalht -= 20;
197 197
 		}
198 198
 
199
-		$this->tva=array();
200
-		$this->localtax1=array();
201
-		$this->localtax2=array();
202
-		$this->atleastoneratenotnull=0;
203
-		$this->atleastonediscount=0;
199
+		$this->tva = array();
200
+		$this->localtax1 = array();
201
+		$this->localtax2 = array();
202
+		$this->atleastoneratenotnull = 0;
203
+		$this->atleastonediscount = 0;
204 204
 	}
205 205
 
206 206
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
      *  @param		int			$hideref			Do not show ref
216 216
      *  @return     int             			    1=OK, 0=KO
217 217
 	 */
218
-	function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
218
+	function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
219 219
 	{
220 220
         // phpcs:enable
221 221
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
222 222
 
223
-		if (! is_object($outputlangs)) $outputlangs=$langs;
223
+		if (!is_object($outputlangs)) $outputlangs = $langs;
224 224
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
225
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
225
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
226 226
 
227 227
 		// Load translation files required by the page
228 228
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
 			if ($object->specimen)
240 240
 			{
241 241
 				$dir = $conf->commande->dir_output;
242
-				$file = $dir . "/SPECIMEN.pdf";
242
+				$file = $dir."/SPECIMEN.pdf";
243 243
 			}
244 244
 			else
245 245
 			{
246 246
 				$objectref = dol_sanitizeFileName($object->ref);
247
-				$dir = $conf->commande->dir_output . "/" . $objectref;
248
-				$file = $dir . "/" . $objectref . ".pdf";
247
+				$dir = $conf->commande->dir_output."/".$objectref;
248
+				$file = $dir."/".$objectref.".pdf";
249 249
 			}
250 250
 
251
-			if (! file_exists($dir))
251
+			if (!file_exists($dir))
252 252
 			{
253 253
 				if (dol_mkdir($dir) < 0)
254 254
 				{
255
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
255
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
256 256
 					return 0;
257 257
 				}
258 258
 			}
@@ -260,25 +260,25 @@  discard block
 block discarded – undo
260 260
 			if (file_exists($dir))
261 261
 			{
262 262
 				// Add pdfgeneration hook
263
-				if (! is_object($hookmanager))
263
+				if (!is_object($hookmanager))
264 264
 				{
265 265
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
266
-					$hookmanager=new HookManager($this->db);
266
+					$hookmanager = new HookManager($this->db);
267 267
 				}
268 268
 				$hookmanager->initHooks(array('pdfgeneration'));
269
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
269
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
270 270
 				global $action;
271
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
271
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
272 272
 
273 273
 				// Create pdf instance
274
-				$pdf=pdf_getInstance($this->format);
275
-				$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
276
-				$pdf->SetAutoPageBreak(1,0);
274
+				$pdf = pdf_getInstance($this->format);
275
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
276
+				$pdf->SetAutoPageBreak(1, 0);
277 277
 
278
-				$heightforinfotot = 40;	// Height reserved to output the info and total part
279
-		        $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5);	// Height reserved to output the free text on last page
280
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
281
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
278
+				$heightforinfotot = 40; // Height reserved to output the info and total part
279
+		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
280
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
281
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
282 282
 
283 283
                 if (class_exists('TCPDF'))
284 284
                 {
@@ -287,27 +287,27 @@  discard block
 block discarded – undo
287 287
                 }
288 288
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
289 289
                 // Set path to the background PDF File
290
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
290
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
291 291
                 {
292 292
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
293 293
                     $tplidx = $pdf->importPage(1);
294 294
                 }
295 295
 
296 296
 				$pdf->Open();
297
-				$pagenb=0;
298
-				$pdf->SetDrawColor(128,128,128);
297
+				$pagenb = 0;
298
+				$pdf->SetDrawColor(128, 128, 128);
299 299
 
300 300
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
301 301
 				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
302 302
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
303 303
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
304 304
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
305
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
305
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
306 306
 
307
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
307
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
308 308
 
309 309
 				// Positionne $this->atleastonediscount si on a au moins une remise
310
-				for ($i = 0 ; $i < $nblignes ; $i++)
310
+				for ($i = 0; $i < $nblignes; $i++)
311 311
 				{
312 312
 					if ($object->lines[$i]->remise_percent)
313 313
 					{
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
 				}
317 317
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
318 318
 				{
319
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
320
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
321
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
322
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
323
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
319
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
320
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
321
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
322
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
323
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
324 324
 					//$this->postotalht;
325 325
 				}
326 326
 
327 327
 				// New page
328 328
 				$pdf->AddPage();
329
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
329
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
330 330
 				$pagenb++;
331 331
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
332
-				$pdf->SetFont('','', $default_font_size - 1);
333
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
334
-				$pdf->SetTextColor(0,0,0);
332
+				$pdf->SetFont('', '', $default_font_size - 1);
333
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
334
+				$pdf->SetTextColor(0, 0, 0);
335 335
 
336 336
 
337
-				$tab_top = 90+$top_shift;
338
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
337
+				$tab_top = 90 + $top_shift;
338
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
339 339
 
340 340
 				// Incoterm
341 341
 				if ($conf->incoterm->enabled)
@@ -345,50 +345,50 @@  discard block
 block discarded – undo
345 345
 					{
346 346
 						$tab_top -= 2;
347 347
 
348
-						$pdf->SetFont('','', $default_font_size - 1);
349
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
348
+						$pdf->SetFont('', '', $default_font_size - 1);
349
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
350 350
 						$nexY = $pdf->GetY();
351
-						$height_incoterms=$nexY-$tab_top;
351
+						$height_incoterms = $nexY - $tab_top;
352 352
 
353 353
 						// Rect prend une longueur en 3eme param
354
-						$pdf->SetDrawColor(192,192,192);
355
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
354
+						$pdf->SetDrawColor(192, 192, 192);
355
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
356 356
 
357
-						$tab_top = $nexY+6;
357
+						$tab_top = $nexY + 6;
358 358
 					}
359 359
 				}
360 360
 
361 361
 				// Affiche notes
362
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
363
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
362
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
363
+				if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
364 364
 				{
365 365
 					// Get first sale rep
366 366
 					if (is_object($object->thirdparty))
367 367
 					{
368
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
369
-						$salerepobj=new User($this->db);
368
+						$salereparray = $object->thirdparty->getSalesRepresentatives($user);
369
+						$salerepobj = new User($this->db);
370 370
 						$salerepobj->fetch($salereparray[0]['id']);
371
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
371
+						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
372 372
 					}
373 373
 				}
374 374
 				if ($notetoshow)
375 375
 				{
376 376
 					$tab_top -= 2;
377 377
 
378
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
378
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
379 379
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
380 380
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
381 381
 
382
-					$pdf->SetFont('','', $default_font_size - 1);
383
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
382
+					$pdf->SetFont('', '', $default_font_size - 1);
383
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($notetoshow), 0, 1);
384 384
 					$nexY = $pdf->GetY();
385
-					$height_note=$nexY-$tab_top;
385
+					$height_note = $nexY - $tab_top;
386 386
 
387 387
 					// Rect prend une longueur en 3eme param
388
-					$pdf->SetDrawColor(192,192,192);
389
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
388
+					$pdf->SetDrawColor(192, 192, 192);
389
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
390 390
 
391
-					$tab_top = $nexY+6;
391
+					$tab_top = $nexY + 6;
392 392
 				}
393 393
 
394 394
 				$iniY = $tab_top + 7;
@@ -396,164 +396,164 @@  discard block
 block discarded – undo
396 396
 				$nexY = $tab_top + 7;
397 397
 
398 398
 				// Loop on each lines
399
-				for ($i = 0 ; $i < $nblignes ; $i++)
399
+				for ($i = 0; $i < $nblignes; $i++)
400 400
 				{
401 401
 					$curY = $nexY;
402
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
403
-					$pdf->SetTextColor(0,0,0);
402
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
403
+					$pdf->SetTextColor(0, 0, 0);
404 404
 
405 405
 					$pdf->setTopMargin($tab_top_newpage);
406
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
407
-					$pageposbefore=$pdf->getPage();
406
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
407
+					$pageposbefore = $pdf->getPage();
408 408
 
409 409
 					// Description of product line
410
-					$curX = $this->posxdesc-1;
410
+					$curX = $this->posxdesc - 1;
411 411
 
412
-					$showpricebeforepagebreak=1;
412
+					$showpricebeforepagebreak = 1;
413 413
 
414 414
 					$pdf->startTransaction();
415
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416
-					$pageposafter=$pdf->getPage();
415
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
416
+					$pageposafter = $pdf->getPage();
417 417
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
418 418
 					{
419 419
 						$pdf->rollbackTransaction(true);
420
-						$pageposafter=$pageposbefore;
420
+						$pageposafter = $pageposbefore;
421 421
 						//print $pageposafter.'-'.$pageposbefore;exit;
422
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
423
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
424
-						$pageposafter=$pdf->getPage();
425
-						$posyafter=$pdf->GetY();
426
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
422
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
423
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
424
+						$pageposafter = $pdf->getPage();
425
+						$posyafter = $pdf->GetY();
426
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
427 427
 						{
428
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
428
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
429 429
 							{
430
-								$pdf->AddPage('','',true);
431
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
430
+								$pdf->AddPage('', '', true);
431
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
432 432
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
433
-								$pdf->setPage($pageposafter+1);
433
+								$pdf->setPage($pageposafter + 1);
434 434
 							}
435 435
 						}
436 436
 						else
437 437
 						{
438 438
 							// We found a page break
439
-							$showpricebeforepagebreak=0;
439
+							$showpricebeforepagebreak = 0;
440 440
 						}
441 441
 					}
442 442
 					else	// No pagebreak
443 443
 					{
444 444
 						$pdf->commitTransaction();
445 445
 					}
446
-					$posYAfterDescription=$pdf->GetY();
446
+					$posYAfterDescription = $pdf->GetY();
447 447
 
448 448
 					$nexY = $pdf->GetY();
449
-					$pageposafter=$pdf->getPage();
449
+					$pageposafter = $pdf->getPage();
450 450
 
451 451
 					$pdf->setPage($pageposbefore);
452 452
 					$pdf->setTopMargin($this->marge_haute);
453
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
453
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
454 454
 
455 455
 					// We suppose that a too long description is moved completely on next page
456 456
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457 457
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
458 458
 					}
459 459
 
460
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
460
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
461 461
 
462 462
 					// VAT Rate
463 463
 					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
464 464
 					{
465 465
 						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
466
-						$pdf->SetXY($this->posxtva-5, $curY);
467
-						$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
466
+						$pdf->SetXY($this->posxtva - 5, $curY);
467
+						$pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0, 'R');
468 468
 					}
469 469
 
470 470
 					// Unit price before discount
471 471
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
472 472
 					$pdf->SetXY($this->posxup, $curY);
473
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
473
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
474 474
 
475 475
 					// Quantity
476 476
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
477 477
 					$pdf->SetXY($this->posxqty, $curY);
478 478
 					// Enough for 6 chars
479
-					if($conf->global->PRODUCT_USE_UNITS)
479
+					if ($conf->global->PRODUCT_USE_UNITS)
480 480
 					{
481
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
481
+						$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
482 482
 					}
483 483
 					else
484 484
 					{
485
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
485
+						$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
486 486
 					}
487 487
 
488 488
 					// Unit
489
-					if($conf->global->PRODUCT_USE_UNITS)
489
+					if ($conf->global->PRODUCT_USE_UNITS)
490 490
 					{
491 491
 						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
492 492
 						$pdf->SetXY($this->posxunit, $curY);
493
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
493
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
494 494
 					}
495 495
 
496 496
 					// Discount on line
497 497
 					$pdf->SetXY($this->posxdiscount, $curY);
498 498
 					if ($object->lines[$i]->remise_percent)
499 499
 					{
500
-						$pdf->SetXY($this->posxdiscount-2, $curY);
500
+						$pdf->SetXY($this->posxdiscount - 2, $curY);
501 501
 						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
502
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
502
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
503 503
 					}
504 504
 
505 505
 					// Total HT line
506 506
 					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
507 507
 					$pdf->SetXY($this->postotalht, $curY);
508
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
508
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509 509
 
510 510
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
511
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
512
-					else $tvaligne=$object->lines[$i]->total_tva;
511
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
512
+					else $tvaligne = $object->lines[$i]->total_tva;
513 513
 
514
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
515
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
516
-					$localtax1_rate=$object->lines[$i]->localtax1_tx;
517
-					$localtax2_rate=$object->lines[$i]->localtax2_tx;
518
-					$localtax1_type=$object->lines[$i]->localtax1_type;
519
-					$localtax2_type=$object->lines[$i]->localtax2_type;
514
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
515
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
516
+					$localtax1_rate = $object->lines[$i]->localtax1_tx;
517
+					$localtax2_rate = $object->lines[$i]->localtax2_tx;
518
+					$localtax1_type = $object->lines[$i]->localtax1_type;
519
+					$localtax2_type = $object->lines[$i]->localtax2_type;
520 520
 
521
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
522
-					if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
523
-					if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
521
+					if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
522
+					if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
523
+					if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
524 524
 
525
-					$vatrate=(string) $object->lines[$i]->tva_tx;
525
+					$vatrate = (string) $object->lines[$i]->tva_tx;
526 526
 
527 527
 					// Retrieve type from database for backward compatibility with old records
528
-					if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
529
-					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
528
+					if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
529
+					&& (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
530 530
 					{
531
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
531
+						$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
532 532
 						$localtax1_type = $localtaxtmp_array[0];
533 533
 						$localtax2_type = $localtaxtmp_array[2];
534 534
 					}
535 535
 
536 536
 				    // retrieve global local tax
537 537
 					if ($localtax1_type && $localtax1ligne != 0)
538
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
538
+						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
539 539
 					if ($localtax2_type && $localtax2ligne != 0)
540
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
540
+						$this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
541 541
 
542
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
542
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
543
+					if (!isset($this->tva[$vatrate])) 				$this->tva[$vatrate] = 0;
544 544
 					$this->tva[$vatrate] += $tvaligne;
545 545
 
546 546
 					// Add line
547
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
547
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548 548
 					{
549 549
 						$pdf->setPage($pageposafter);
550
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
550
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
551 551
 						//$pdf->SetDrawColor(190,190,200);
552
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
552
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
553 553
 						$pdf->SetLineStyle(array('dash'=>0));
554 554
 					}
555 555
 
556
-					$nexY+=2;    // Passe espace entre les lignes
556
+					$nexY += 2; // Passe espace entre les lignes
557 557
 
558 558
 					// Detect if some page were added automatically and output _tableau for past pages
559 559
 					while ($pagenb < $pageposafter)
@@ -567,13 +567,13 @@  discard block
 block discarded – undo
567 567
 						{
568 568
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569 569
 						}
570
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
570
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
571 571
 						$pagenb++;
572 572
 						$pdf->setPage($pagenb);
573
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
573
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
574 574
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
575 575
 					}
576
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
576
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
577 577
 					{
578 578
 						if ($pagenb == 1)
579 579
 						{
@@ -583,10 +583,10 @@  discard block
 block discarded – undo
583 583
 						{
584 584
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585 585
 						}
586
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
586
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
587 587
 						// New page
588 588
 						$pdf->AddPage();
589
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
589
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
590 590
 						$pagenb++;
591 591
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
592 592
 					}
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598 598
 				else
599 599
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
600
-				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
600
+				$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601 601
 
602 602
 				// Affiche zone infos
603
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
603
+				$posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
604 604
 
605 605
 				// Affiche zone totaux
606
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
606
+				$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
607 607
 
608 608
 				// Affiche zone versements
609 609
 				/*
@@ -623,26 +623,26 @@  discard block
 block discarded – undo
623 623
 
624 624
 				// Add pdfgeneration hook
625 625
 				$hookmanager->initHooks(array('pdfgeneration'));
626
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
626
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
627 627
 				global $action;
628
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
628
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
629 629
 
630
-				if (! empty($conf->global->MAIN_UMASK))
630
+				if (!empty($conf->global->MAIN_UMASK))
631 631
 					@chmod($file, octdec($conf->global->MAIN_UMASK));
632 632
 
633 633
 				$this->result = array('fullpath'=>$file);
634 634
 
635
-				return 1;   // Pas d'erreur
635
+				return 1; // Pas d'erreur
636 636
 			}
637 637
 			else
638 638
 			{
639
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
639
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
640 640
 				return 0;
641 641
 			}
642 642
 		}
643 643
 		else
644 644
 		{
645
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
645
+			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "COMMANDE_OUTPUTDIR");
646 646
 			return 0;
647 647
 		}
648 648
 	}
@@ -679,35 +679,35 @@  discard block
 block discarded – undo
679 679
 		global $conf;
680 680
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
681 681
 
682
-		$pdf->SetFont('','', $default_font_size - 1);
682
+		$pdf->SetFont('', '', $default_font_size - 1);
683 683
 
684 684
         // If France, show VAT mention if not applicable
685 685
 		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
686 686
 		{
687
-			$pdf->SetFont('','B', $default_font_size - 2);
687
+			$pdf->SetFont('', 'B', $default_font_size - 2);
688 688
 			$pdf->SetXY($this->marge_gauche, $posy);
689 689
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
690 690
 
691
-			$posy=$pdf->GetY()+4;
691
+			$posy = $pdf->GetY() + 4;
692 692
 		}
693 693
 
694
-		$posxval=52;
694
+		$posxval = 52;
695 695
 
696 696
 		// Show payments conditions
697 697
 		if ($object->cond_reglement_code || $object->cond_reglement)
698 698
 		{
699
-			$pdf->SetFont('','B', $default_font_size - 2);
699
+			$pdf->SetFont('', 'B', $default_font_size - 2);
700 700
 			$pdf->SetXY($this->marge_gauche, $posy);
701 701
 			$titre = $outputlangs->transnoentities("PaymentConditions").':';
702 702
 			$pdf->MultiCell(43, 4, $titre, 0, 'L');
703 703
 
704
-			$pdf->SetFont('','', $default_font_size - 2);
704
+			$pdf->SetFont('', '', $default_font_size - 2);
705 705
 			$pdf->SetXY($posxval, $posy);
706
-			$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
707
-			$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
708
-			$pdf->MultiCell(67, 4, $lib_condition_paiement,0,'L');
706
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
707
+			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
708
+			$pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
709 709
 
710
-			$posy=$pdf->GetY()+3;
710
+			$posy = $pdf->GetY() + 3;
711 711
 		}
712 712
 
713 713
         // Check a payment mode is defined
@@ -738,34 +738,34 @@  discard block
 block discarded – undo
738 738
 		}*/
739 739
 
740 740
 	    // Show planed date of delivery
741
-        if (! empty($object->date_livraison))
741
+        if (!empty($object->date_livraison))
742 742
 		{
743 743
             $outputlangs->load("sendings");
744
-			$pdf->SetFont('','B', $default_font_size - 2);
744
+			$pdf->SetFont('', 'B', $default_font_size - 2);
745 745
 			$pdf->SetXY($this->marge_gauche, $posy);
746 746
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
747 747
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
748
-			$pdf->SetFont('','', $default_font_size - 2);
748
+			$pdf->SetFont('', '', $default_font_size - 2);
749 749
 			$pdf->SetXY($posxval, $posy);
750
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
750
+			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
751 751
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
752 752
 
753
-            $posy=$pdf->GetY()+1;
753
+            $posy = $pdf->GetY() + 1;
754 754
 		}
755 755
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
756 756
 		{
757
-			$pdf->SetFont('','B', $default_font_size - 2);
757
+			$pdf->SetFont('', 'B', $default_font_size - 2);
758 758
 			$pdf->SetXY($this->marge_gauche, $posy);
759 759
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760 760
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
761
-			$pdf->SetTextColor(0,0,0);
762
-			$pdf->SetFont('','', $default_font_size - 2);
761
+			$pdf->SetTextColor(0, 0, 0);
762
+			$pdf->SetFont('', '', $default_font_size - 2);
763 763
 			$pdf->SetXY($posxval, $posy);
764
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
765
-			$lib_availability=str_replace('\n',"\n",$lib_availability);
764
+			$lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability : '');
765
+			$lib_availability = str_replace('\n', "\n", $lib_availability);
766 766
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
767 767
 
768
-			$posy=$pdf->GetY()+1;
768
+			$posy = $pdf->GetY() + 1;
769 769
 		}
770 770
 
771 771
       	// Show payment mode
@@ -773,24 +773,24 @@  discard block
 block discarded – undo
773 773
         	 && $object->mode_reglement_code != 'CHQ'
774 774
            	 && $object->mode_reglement_code != 'VIR')
775 775
            	 {
776
-	            $pdf->SetFont('','B', $default_font_size - 2);
776
+	            $pdf->SetFont('', 'B', $default_font_size - 2);
777 777
 	            $pdf->SetXY($this->marge_gauche, $posy);
778 778
 	            $titre = $outputlangs->transnoentities("PaymentMode").':';
779 779
 	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
780 780
 
781
-				$pdf->SetFont('','', $default_font_size - 2);
781
+				$pdf->SetFont('', '', $default_font_size - 2);
782 782
 	            $pdf->SetXY($posxval, $posy);
783
-	            $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
784
-	            $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
783
+	            $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
784
+	            $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
785 785
 
786
-	            $posy=$pdf->GetY()+2;
786
+	            $posy = $pdf->GetY() + 2;
787 787
            	 }
788 788
 
789 789
 		// Show payment mode CHQ
790 790
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
791 791
         {
792 792
         	// Si mode reglement non force ou si force a CHQ
793
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
793
+	        if (!empty($conf->global->FACTURE_CHQ_NUMBER))
794 794
 	        {
795 795
 	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
796 796
 	            {
@@ -798,31 +798,31 @@  discard block
 block discarded – undo
798 798
 	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
799 799
 
800 800
 	                $pdf->SetXY($this->marge_gauche, $posy);
801
-	                $pdf->SetFont('','B', $default_font_size - 3);
802
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio),0,'L',0);
803
-		            $posy=$pdf->GetY()+1;
801
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
802
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
803
+		            $posy = $pdf->GetY() + 1;
804 804
 
805 805
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
806 806
 		            {
807 807
 		                $pdf->SetXY($this->marge_gauche, $posy);
808
-		                $pdf->SetFont('','', $default_font_size - 3);
808
+		                $pdf->SetFont('', '', $default_font_size - 3);
809 809
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
810
-			            $posy=$pdf->GetY()+2;
810
+			            $posy = $pdf->GetY() + 2;
811 811
 		            }
812 812
 	            }
813 813
 	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
814 814
 	            {
815 815
 	                $pdf->SetXY($this->marge_gauche, $posy);
816
-	                $pdf->SetFont('','B', $default_font_size - 3);
817
-	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$this->emetteur->name),0,'L',0);
818
-		            $posy=$pdf->GetY()+1;
816
+	                $pdf->SetFont('', 'B', $default_font_size - 3);
817
+	                $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
818
+		            $posy = $pdf->GetY() + 1;
819 819
 
820 820
 		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
821 821
 		            {
822 822
 			            $pdf->SetXY($this->marge_gauche, $posy);
823
-		                $pdf->SetFont('','', $default_font_size - 3);
823
+		                $pdf->SetFont('', '', $default_font_size - 3);
824 824
 		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
825
-			            $posy=$pdf->GetY()+2;
825
+			            $posy = $pdf->GetY() + 2;
826 826
 		            }
827 827
 	            }
828 828
 	        }
@@ -831,19 +831,19 @@  discard block
 block discarded – undo
831 831
         // If payment mode not forced or forced to VIR, show payment with BAN
832 832
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
833 833
         {
834
-			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
834
+			if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
835 835
 			{
836
-				$bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account);
837
-				if (! empty($object->fk_bank)) $bankid=$object->fk_bank;   // For backward compatibility when object->fk_account is forced with object->fk_bank
836
+				$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
837
+				if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
838 838
 				$account = new Account($this->db);
839 839
 				$account->fetch($bankid);
840 840
 
841
-				$curx=$this->marge_gauche;
842
-				$cury=$posy;
841
+				$curx = $this->marge_gauche;
842
+				$cury = $posy;
843 843
 
844
-				$posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size);
844
+				$posy = pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
845 845
 
846
-				$posy+=2;
846
+				$posy += 2;
847 847
 			}
848 848
         }
849 849
 
@@ -865,44 +865,44 @@  discard block
 block discarded – undo
865 865
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
866 866
 	{
867 867
         // phpcs:enable
868
-	    global $conf,$mysoc;
868
+	    global $conf, $mysoc;
869 869
 
870 870
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
871 871
 
872 872
 		$tab2_top = $posy;
873 873
 		$tab2_hl = 4;
874
-		$pdf->SetFont('','', $default_font_size - 1);
874
+		$pdf->SetFont('', '', $default_font_size - 1);
875 875
 
876 876
 		// Tableau total
877 877
         $col1x = 120; $col2x = 170;
878 878
 		if ($this->page_largeur < 210) // To work with US executive format
879 879
 		{
880
-			$col2x-=20;
880
+			$col2x -= 20;
881 881
 		}
882 882
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 883
 
884
-		$useborder=0;
884
+		$useborder = 0;
885 885
 		$index = 0;
886 886
 
887 887
 		// Total HT
888
-		$pdf->SetFillColor(255,255,255);
888
+		$pdf->SetFillColor(255, 255, 255);
889 889
 		$pdf->SetXY($col1x, $tab2_top + 0);
890
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
890
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
891 891
 
892 892
 		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
893 893
 		$pdf->SetXY($col2x, $tab2_top + 0);
894
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (! empty($object->remise)?$object->remise:0), 0, $outputlangs), 0, 'R', 1);
894
+		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0, 'R', 1);
895 895
 
896 896
 		// Show VAT by rates and total
897
-		$pdf->SetFillColor(248,248,248);
897
+		$pdf->SetFillColor(248, 248, 248);
898 898
 
899 899
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
900 900
 
901
-		$this->atleastoneratenotnull=0;
901
+		$this->atleastoneratenotnull = 0;
902 902
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
903 903
 		{
904
-			$tvaisnull=((! empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
905
-			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
904
+			$tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva['0.000']) && is_float($this->tva['0.000'])) ? true : false);
905
+			if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
906 906
 			{
907 907
 				// Nothing to do
908 908
 			}
@@ -911,27 +911,27 @@  discard block
 block discarded – undo
911 911
 				//Local tax 1 before VAT
912 912
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913 913
 				//{
914
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
914
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
915 915
 					{
916
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
917
-						foreach( $localtax_rate as $tvakey => $tvaval )
916
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
917
+						foreach ($localtax_rate as $tvakey => $tvaval)
918 918
 						{
919
-							if ($tvakey!=0)    // On affiche pas taux 0
919
+							if ($tvakey != 0)    // On affiche pas taux 0
920 920
 							{
921 921
 								//$this->atleastoneratenotnull++;
922 922
 
923 923
 								$index++;
924 924
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925 925
 
926
-								$tvacompl='';
927
-								if (preg_match('/\*/',$tvakey))
926
+								$tvacompl = '';
927
+								if (preg_match('/\*/', $tvakey))
928 928
 								{
929
-									$tvakey=str_replace('*','',$tvakey);
929
+									$tvakey = str_replace('*', '', $tvakey);
930 930
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
931 931
 								}
932
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
933
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
934
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
932
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
933
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
934
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
935 935
 
936 936
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
937 937
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -942,12 +942,12 @@  discard block
 block discarded – undo
942 942
 				//Local tax 2 before VAT
943 943
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
944 944
 				//{
945
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
945
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
946 946
 					{
947
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
948
-						foreach( $localtax_rate as $tvakey => $tvaval )
947
+						if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
948
+						foreach ($localtax_rate as $tvakey => $tvaval)
949 949
 						{
950
-							if ($tvakey!=0)    // On affiche pas taux 0
950
+							if ($tvakey != 0)    // On affiche pas taux 0
951 951
 							{
952 952
 								//$this->atleastoneratenotnull++;
953 953
 
@@ -956,15 +956,15 @@  discard block
 block discarded – undo
956 956
 								$index++;
957 957
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958 958
 
959
-								$tvacompl='';
960
-								if (preg_match('/\*/',$tvakey))
959
+								$tvacompl = '';
960
+								if (preg_match('/\*/', $tvakey))
961 961
 								{
962
-									$tvakey=str_replace('*','',$tvakey);
962
+									$tvakey = str_replace('*', '', $tvakey);
963 963
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
964 964
 								}
965
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
966
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
967
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
965
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
966
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
967
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
968 968
 
969 969
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970 970
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 					}
974 974
 				//}
975 975
 				// VAT
976
-				foreach($this->tva as $tvakey => $tvaval)
976
+				foreach ($this->tva as $tvakey => $tvaval)
977 977
 				{
978 978
 					if ($tvakey != 0)    // On affiche pas taux 0
979 979
 					{
@@ -982,15 +982,15 @@  discard block
 block discarded – undo
982 982
 						$index++;
983 983
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984 984
 
985
-						$tvacompl='';
986
-						if (preg_match('/\*/',$tvakey))
985
+						$tvacompl = '';
986
+						if (preg_match('/\*/', $tvakey))
987 987
 						{
988
-							$tvakey=str_replace('*','',$tvakey);
988
+							$tvakey = str_replace('*', '', $tvakey);
989 989
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
990 990
 						}
991
-						$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
992
-						$totalvat.=vatrate($tvakey,1).$tvacompl;
993
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
991
+						$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
992
+						$totalvat .= vatrate($tvakey, 1).$tvacompl;
993
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
994 994
 
995 995
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996 996
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 				//Local tax 1 after VAT
1001 1001
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1002 1002
 				//{
1003
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1003
+					foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1004 1004
 					{
1005
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1005
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1006 1006
 
1007
-						foreach( $localtax_rate as $tvakey => $tvaval )
1007
+						foreach ($localtax_rate as $tvakey => $tvaval)
1008 1008
 						{
1009 1009
 							if ($tvakey != 0)    // On affiche pas taux 0
1010 1010
 							{
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
 								$index++;
1014 1014
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015 1015
 
1016
-								$tvacompl='';
1017
-								if (preg_match('/\*/',$tvakey))
1016
+								$tvacompl = '';
1017
+								if (preg_match('/\*/', $tvakey))
1018 1018
 								{
1019
-									$tvakey=str_replace('*','',$tvakey);
1019
+									$tvakey = str_replace('*', '', $tvakey);
1020 1020
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1021 1021
 								}
1022
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1022
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
1023 1023
 
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1024
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1025
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026 1026
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027 1027
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1028 1028
 							}
@@ -1032,11 +1032,11 @@  discard block
 block discarded – undo
1032 1032
 				//Local tax 2 after VAT
1033 1033
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1034 1034
 				//{
1035
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1035
+					foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1036 1036
 					{
1037
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1037
+						if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
1038 1038
 
1039
-						foreach( $localtax_rate as $tvakey => $tvaval )
1039
+						foreach ($localtax_rate as $tvakey => $tvaval)
1040 1040
 						{
1041 1041
 							if ($tvakey != 0)    // On affiche pas taux 0
1042 1042
 							{
@@ -1045,16 +1045,16 @@  discard block
 block discarded – undo
1045 1045
 								$index++;
1046 1046
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047 1047
 
1048
-								$tvacompl='';
1049
-								if (preg_match('/\*/',$tvakey))
1048
+								$tvacompl = '';
1049
+								if (preg_match('/\*/', $tvakey))
1050 1050
 								{
1051
-									$tvakey=str_replace('*','',$tvakey);
1051
+									$tvakey = str_replace('*', '', $tvakey);
1052 1052
 									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1053 1053
 								}
1054
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1054
+								$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
1055 1055
 
1056
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1057
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1056
+								$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
1057
+								$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1058 1058
 
1059 1059
 								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060 1060
 								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1066,24 +1066,24 @@  discard block
 block discarded – undo
1066 1066
 				// Total TTC
1067 1067
 				$index++;
1068 1068
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1069
-				$pdf->SetTextColor(0,0,60);
1070
-				$pdf->SetFillColor(224,224,224);
1071
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1069
+				$pdf->SetTextColor(0, 0, 60);
1070
+				$pdf->SetFillColor(224, 224, 224);
1071
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1072 1072
 
1073 1073
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074 1074
 				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1075 1075
 			}
1076 1076
 		}
1077 1077
 
1078
-		$pdf->SetTextColor(0,0,0);
1078
+		$pdf->SetTextColor(0, 0, 0);
1079 1079
 
1080
-        $creditnoteamount=0;
1081
-        $depositsamount=0;
1080
+        $creditnoteamount = 0;
1081
+        $depositsamount = 0;
1082 1082
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
1083 1083
 		//$depositsamount=$object->getSumDepositsUsed();
1084 1084
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1085 1085
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
-		if (! empty($object->paye)) $resteapayer=0;
1086
+		if (!empty($object->paye)) $resteapayer = 0;
1087 1087
 
1088 1088
 		if ($deja_regle > 0)
1089 1089
 		{
@@ -1091,21 +1091,21 @@  discard block
 block discarded – undo
1091 1091
 			$index++;
1092 1092
 
1093 1093
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1094
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1095 1095
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096 1096
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1097 1097
 
1098 1098
 			$index++;
1099
-			$pdf->SetTextColor(0,0,60);
1100
-			$pdf->SetFillColor(224,224,224);
1099
+			$pdf->SetTextColor(0, 0, 60);
1100
+			$pdf->SetFillColor(224, 224, 224);
1101 1101
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1102
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1103 1103
 
1104 1104
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105 1105
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1106 1106
 
1107
-			$pdf->SetFont('','', $default_font_size - 1);
1108
-			$pdf->SetTextColor(0,0,0);
1107
+			$pdf->SetFont('', '', $default_font_size - 1);
1108
+			$pdf->SetTextColor(0, 0, 0);
1109 1109
 		}
1110 1110
 
1111 1111
 		$index++;
@@ -1125,77 +1125,77 @@  discard block
 block discarded – undo
1125 1125
 	 *   @param		string		$currency		Currency code
1126 1126
 	 *   @return	void
1127 1127
 	 */
1128
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1128
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1129 1129
 	{
1130 1130
 		global $conf;
1131 1131
 
1132 1132
 		// Force to disable hidetop and hidebottom
1133
-		$hidebottom=0;
1134
-		if ($hidetop) $hidetop=-1;
1133
+		$hidebottom = 0;
1134
+		if ($hidetop) $hidetop = -1;
1135 1135
 
1136 1136
 		$currency = !empty($currency) ? $currency : $conf->currency;
1137 1137
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1138 1138
 
1139 1139
 		// Amount in (at tab_top - 1)
1140
-		$pdf->SetTextColor(0,0,0);
1141
-		$pdf->SetFont('','', $default_font_size - 2);
1140
+		$pdf->SetTextColor(0, 0, 0);
1141
+		$pdf->SetFont('', '', $default_font_size - 2);
1142 1142
 
1143 1143
 		if (empty($hidetop))
1144 1144
 		{
1145
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1146
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
1145
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1146
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1147 1147
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1148 1148
 
1149 1149
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
1150
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1150
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1151 1151
 		}
1152 1152
 
1153
-		$pdf->SetDrawColor(128,128,128);
1154
-		$pdf->SetFont('','', $default_font_size - 1);
1153
+		$pdf->SetDrawColor(128, 128, 128);
1154
+		$pdf->SetFont('', '', $default_font_size - 1);
1155 1155
 
1156 1156
 		// Output Rect
1157
-		$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect prend une longueur en 3eme param et 4eme param
1157
+		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
1158 1158
 
1159 1159
 		if (empty($hidetop))
1160 1160
 		{
1161
-			$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line prend une position y en 2eme param et 4eme param
1161
+			$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line prend une position y en 2eme param et 4eme param
1162 1162
 
1163
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1164
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1163
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1164
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1165 1165
 		}
1166 1166
 
1167 1167
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1168 1168
 		{
1169
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1169
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1170 1170
 			if (empty($hidetop))
1171 1171
 			{
1172
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1173
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1172
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1173
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
1174 1174
 			}
1175 1175
 		}
1176 1176
 
1177
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1177
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1178 1178
 		if (empty($hidetop))
1179 1179
 		{
1180
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1181
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1180
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
1181
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
1182 1182
 		}
1183 1183
 
1184
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1184
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1185 1185
 		if (empty($hidetop))
1186 1186
 		{
1187
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1188
-			if($conf->global->PRODUCT_USE_UNITS)
1187
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1188
+			if ($conf->global->PRODUCT_USE_UNITS)
1189 1189
 			{
1190
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1190
+				$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1191 1191
 			}
1192 1192
 			else
1193 1193
 			{
1194
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1194
+				$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
1195 1195
 			}
1196 1196
 		}
1197 1197
 
1198
-		if($conf->global->PRODUCT_USE_UNITS) {
1198
+		if ($conf->global->PRODUCT_USE_UNITS) {
1199 1199
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1200 1200
 			if (empty($hidetop)) {
1201 1201
 				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -1204,13 +1204,13 @@  discard block
 block discarded – undo
1204 1204
 			}
1205 1205
 		}
1206 1206
 
1207
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1207
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1208 1208
 		if (empty($hidetop))
1209 1209
 		{
1210 1210
 			if ($this->atleastonediscount)
1211 1211
 			{
1212
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1213
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1212
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1213
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
1214 1214
 			}
1215 1215
 		}
1216 1216
 
@@ -1220,8 +1220,8 @@  discard block
 block discarded – undo
1220 1220
 		}
1221 1221
 		if (empty($hidetop))
1222 1222
 		{
1223
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1224
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1223
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1224
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
1225 1225
 		}
1226 1226
 	}
1227 1227
 
@@ -1235,102 +1235,102 @@  discard block
 block discarded – undo
1235 1235
 	 *  @param	string		$titlekey		Translation key to show as title of document
1236 1236
 	 *  @return	void
1237 1237
 	 */
1238
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1238
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle")
1239 1239
 	{
1240
-		global $conf,$langs,$hookmanager;
1240
+		global $conf, $langs, $hookmanager;
1241 1241
 
1242 1242
 		// Load traductions files requiredby by page
1243 1243
 		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1244 1244
 
1245 1245
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1246 1246
 
1247
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1247
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
1248 1248
 
1249 1249
 		// Show Draft Watermark
1250
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1250
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1251 1251
 		{
1252
-            pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
1252
+            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1253 1253
 		}
1254 1254
 
1255
-		$pdf->SetTextColor(0,0,60);
1256
-		$pdf->SetFont('','B', $default_font_size + 3);
1255
+		$pdf->SetTextColor(0, 0, 60);
1256
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1257 1257
 
1258
-		$posy=$this->marge_haute;
1259
-		$posx=$this->page_largeur-$this->marge_droite-100;
1258
+		$posy = $this->marge_haute;
1259
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1260 1260
 
1261
-		$pdf->SetXY($this->marge_gauche,$posy);
1261
+		$pdf->SetXY($this->marge_gauche, $posy);
1262 1262
 
1263 1263
 		// Logo
1264 1264
 		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1265 1265
 		{
1266
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1266
+			$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1267 1267
 			if ($this->emetteur->logo)
1268 1268
 			{
1269 1269
 				if (is_readable($logo))
1270 1270
 				{
1271
-				    $height=pdf_getHeightForLogo($logo);
1272
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1271
+				    $height = pdf_getHeightForLogo($logo);
1272
+				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
1273 1273
 				}
1274 1274
 				else
1275 1275
 				{
1276
-					$pdf->SetTextColor(200,0,0);
1277
-					$pdf->SetFont('','B', $default_font_size -2);
1278
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1276
+					$pdf->SetTextColor(200, 0, 0);
1277
+					$pdf->SetFont('', 'B', $default_font_size - 2);
1278
+					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1279 1279
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280 1280
 				}
1281 1281
 			}
1282 1282
 			else
1283 1283
 			{
1284
-				$text=$this->emetteur->name;
1284
+				$text = $this->emetteur->name;
1285 1285
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1286 1286
 			}
1287 1287
 		}
1288 1288
 
1289
-		$pdf->SetFont('','B', $default_font_size + 3);
1290
-		$pdf->SetXY($posx,$posy);
1291
-		$pdf->SetTextColor(0,0,60);
1292
-		$title=$outputlangs->transnoentities($titlekey);
1289
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1290
+		$pdf->SetXY($posx, $posy);
1291
+		$pdf->SetTextColor(0, 0, 60);
1292
+		$title = $outputlangs->transnoentities($titlekey);
1293 1293
 		$pdf->MultiCell(100, 3, $title, '', 'R');
1294 1294
 
1295
-		$pdf->SetFont('','B',$default_font_size);
1295
+		$pdf->SetFont('', 'B', $default_font_size);
1296 1296
 
1297
-		$posy+=5;
1298
-		$pdf->SetXY($posx,$posy);
1299
-		$pdf->SetTextColor(0,0,60);
1300
-		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
1297
+		$posy += 5;
1298
+		$pdf->SetXY($posx, $posy);
1299
+		$pdf->SetTextColor(0, 0, 60);
1300
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1301 1301
 
1302
-		$posy+=1;
1303
-		$pdf->SetFont('','', $default_font_size - 1);
1302
+		$posy += 1;
1303
+		$pdf->SetFont('', '', $default_font_size - 1);
1304 1304
 
1305 1305
 		if ($object->ref_client)
1306 1306
 		{
1307
-			$posy+=5;
1308
-			$pdf->SetXY($posx,$posy);
1309
-			$pdf->SetTextColor(0,0,60);
1310
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1307
+			$posy += 5;
1308
+			$pdf->SetXY($posx, $posy);
1309
+			$pdf->SetTextColor(0, 0, 60);
1310
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1311 1311
 		}
1312 1312
 
1313
-		$posy+=4;
1314
-		$pdf->SetXY($posx,$posy);
1315
-		$pdf->SetTextColor(0,0,60);
1316
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1313
+		$posy += 4;
1314
+		$pdf->SetXY($posx, $posy);
1315
+		$pdf->SetTextColor(0, 0, 60);
1316
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : ".dol_print_date($object->date, "%d %b %Y", false, $outputlangs, true), '', 'R');
1317 1317
 
1318 1318
 		// Get contact
1319 1319
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1320 1320
 		{
1321
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1321
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1322 1322
 		    if (count($arrayidcontact) > 0)
1323 1323
 		    {
1324
-                $usertmp=new User($this->db);
1324
+                $usertmp = new User($this->db);
1325 1325
 		        $usertmp->fetch($arrayidcontact[0]);
1326
-                $posy+=4;
1327
-                $pdf->SetXY($posx,$posy);
1328
-		        $pdf->SetTextColor(0,0,60);
1326
+                $posy += 4;
1327
+                $pdf->SetXY($posx, $posy);
1328
+		        $pdf->SetTextColor(0, 0, 60);
1329 1329
 		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1330 1330
 		    }
1331 1331
 		}
1332 1332
 
1333
-		$posy+=2;
1333
+		$posy += 2;
1334 1334
 
1335 1335
 		$top_shift = 0;
1336 1336
 		// Show list of linked objects
@@ -1344,54 +1344,54 @@  discard block
 block discarded – undo
1344 1344
 		if ($showaddress)
1345 1345
 		{
1346 1346
 			// Sender properties
1347
-			$carac_emetteur='';
1347
+			$carac_emetteur = '';
1348 1348
 		 	// Add internal contact of proposal if defined
1349
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1349
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1350 1350
 		 	if (count($arrayidcontact) > 0)
1351 1351
 		 	{
1352 1352
 		 		$object->fetch_user($arrayidcontact[0]);
1353
-		 		$labelbeforecontactname=($outputlangs->transnoentities("FromContactName")!='FromContactName'?$outputlangs->transnoentities("FromContactName"):$outputlangs->transnoentities("Name"));
1354
-		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1353
+		 		$labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
1354
+		 		$carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1355 1355
 		 	}
1356 1356
 
1357 1357
 		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1358 1358
 
1359 1359
 			// Show sender
1360
-			$posy=42+$top_shift;
1361
-			$posx=$this->marge_gauche;
1362
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1363
-			$hautcadre=40;
1360
+			$posy = 42 + $top_shift;
1361
+			$posx = $this->marge_gauche;
1362
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1363
+			$hautcadre = 40;
1364 1364
 
1365 1365
 			// Show sender frame
1366
-			$pdf->SetTextColor(0,0,0);
1367
-			$pdf->SetFont('','', $default_font_size - 2);
1368
-			$pdf->SetXY($posx,$posy-5);
1369
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1370
-			$pdf->SetXY($posx,$posy);
1371
-			$pdf->SetFillColor(230,230,230);
1366
+			$pdf->SetTextColor(0, 0, 0);
1367
+			$pdf->SetFont('', '', $default_font_size - 2);
1368
+			$pdf->SetXY($posx, $posy - 5);
1369
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1370
+			$pdf->SetXY($posx, $posy);
1371
+			$pdf->SetFillColor(230, 230, 230);
1372 1372
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1373
-			$pdf->SetTextColor(0,0,60);
1373
+			$pdf->SetTextColor(0, 0, 60);
1374 1374
 
1375 1375
 			// Show sender name
1376
-			$pdf->SetXY($posx+2,$posy+3);
1377
-			$pdf->SetFont('','B', $default_font_size);
1376
+			$pdf->SetXY($posx + 2, $posy + 3);
1377
+			$pdf->SetFont('', 'B', $default_font_size);
1378 1378
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1379
-			$posy=$pdf->getY();
1379
+			$posy = $pdf->getY();
1380 1380
 
1381 1381
 			// Show sender information
1382
-			$pdf->SetXY($posx+2,$posy);
1383
-			$pdf->SetFont('','', $default_font_size - 1);
1382
+			$pdf->SetXY($posx + 2, $posy);
1383
+			$pdf->SetFont('', '', $default_font_size - 1);
1384 1384
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1385 1385
 
1386 1386
 
1387 1387
 
1388 1388
 			// If CUSTOMER contact defined on order, we use it
1389
-			$usecontact=false;
1390
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1389
+			$usecontact = false;
1390
+			$arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
1391 1391
 			if (count($arrayidcontact) > 0)
1392 1392
 			{
1393
-				$usecontact=true;
1394
-				$result=$object->fetch_contact($arrayidcontact[0]);
1393
+				$usecontact = true;
1394
+				$result = $object->fetch_contact($arrayidcontact[0]);
1395 1395
 			}
1396 1396
 
1397 1397
 			//Recipient name
@@ -1402,38 +1402,38 @@  discard block
 block discarded – undo
1402 1402
 				$thirdparty = $object->thirdparty;
1403 1403
 			}
1404 1404
 
1405
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1405
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1406 1406
 
1407
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1407
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
1408 1408
 
1409 1409
 			// Show recipient
1410
-			$widthrecbox=100;
1411
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1412
-			$posy=42+$top_shift;
1413
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1414
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1410
+			$widthrecbox = 100;
1411
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1412
+			$posy = 42 + $top_shift;
1413
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1414
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1415 1415
 
1416 1416
 			// Show recipient frame
1417
-			$pdf->SetTextColor(0,0,0);
1418
-			$pdf->SetFont('','', $default_font_size - 2);
1419
-			$pdf->SetXY($posx+2,$posy-5);
1420
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1417
+			$pdf->SetTextColor(0, 0, 0);
1418
+			$pdf->SetFont('', '', $default_font_size - 2);
1419
+			$pdf->SetXY($posx + 2, $posy - 5);
1420
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1421 1421
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1422 1422
 
1423 1423
 			// Show recipient name
1424
-			$pdf->SetXY($posx+2,$posy+3);
1425
-			$pdf->SetFont('','B', $default_font_size);
1424
+			$pdf->SetXY($posx + 2, $posy + 3);
1425
+			$pdf->SetFont('', 'B', $default_font_size);
1426 1426
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1427 1427
 
1428 1428
 			$posy = $pdf->getY();
1429 1429
 
1430 1430
 			// Show recipient information
1431
-			$pdf->SetFont('','', $default_font_size - 1);
1432
-			$pdf->SetXY($posx+2,$posy);
1431
+			$pdf->SetFont('', '', $default_font_size - 1);
1432
+			$pdf->SetXY($posx + 2, $posy);
1433 1433
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1434 1434
 		}
1435 1435
 
1436
-		$pdf->SetTextColor(0,0,0);
1436
+		$pdf->SetTextColor(0, 0, 0);
1437 1437
 		return $top_shift;
1438 1438
 	}
1439 1439
 
@@ -1446,10 +1446,10 @@  discard block
 block discarded – undo
1446 1446
 	 *      @param	int			$hidefreetext		1=Hide free text
1447 1447
 	 *      @return	int								Return height of bottom margin including footer text
1448 1448
 	 */
1449
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1449
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1450 1450
 	{
1451 1451
 		global $conf;
1452
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1453
-		return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1452
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1453
+		return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1454 1454
 	}
1455 1455
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/pdf_proforma.modules.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	function __construct($db)
50 50
 	{
51
-		global $conf,$langs,$mysoc;
51
+		global $conf, $langs, $mysoc;
52 52
 
53 53
 		parent::__construct($db);
54 54
 
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 *  @param	string		$titlekey		Translation key to show as title of document
68 68
 	 *  @return	void
69 69
 	 */
70
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="InvoiceProForma")
70
+	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma")
71 71
 	{
72
-		global $conf,$langs,$hookmanager;
72
+		global $conf, $langs, $hookmanager;
73 73
 
74 74
 		parent::_pagehead($pdf, $object, $showaddress, $outputlangs, $titlekey);
75 75
 	}
Please login to merge, or discard this patch.