Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/modAdherent.class.php 3 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -38,23 +38,23 @@  discard block
 block discarded – undo
38 38
 {
39 39
 
40 40
     /**
41
-	 *   Constructor. Define names, constants, directories, boxes, permissions
42
-	 *
43
-	 *   @param      DoliDB		$db      Database handler
41
+     *   Constructor. Define names, constants, directories, boxes, permissions
42
+     *
43
+     *   @param      DoliDB		$db      Database handler
44 44
      */
45 45
     function __construct($db)
46 46
     {
47
-    	global $conf;
47
+        global $conf;
48 48
 
49 49
         $this->db = $db;
50 50
         $this->numero = 310;
51 51
 
52 52
         $this->family = "hr";
53 53
         $this->module_position = '55';
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));
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));
56 56
         $this->description = "Management of members of a foundation or association";
57
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
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 60
         $this->picto='user';
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 
68 68
         // Dependencies
69 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
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 73
         $this->langfiles = array("members","companies");
74 74
         $this->phpmin = array(5,4);		// Minimum version of PHP required by module
75 75
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
         $this->rights[$r][5] = 'creer';
249 249
 
250 250
 
251
-		// Menus
252
-		//-------
253
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
251
+        // Menus
252
+        //-------
253
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
254 254
 
255 255
 
256 256
         // Exports
@@ -269,36 +269,36 @@  discard block
 block discarded – undo
269 269
         $this->export_label[$r]='MembersAndSubscriptions';
270 270
         $this->export_permission[$r]=array(array("adherent","export"));
271 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
-		);
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
+        );
279 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
-		);
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
+        );
285 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
-		);
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
+        );
292 292
         // Add extra fields
293 293
         $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra';
294 294
         include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
295
-		// End add axtra fields
295
+        // End add axtra fields
296 296
         $this->export_sql_start[$r]='SELECT DISTINCT ';
297 297
         $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)';
298 298
         $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object';
299 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';
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 302
         $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') ';
303 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
 
@@ -317,54 +317,54 @@  discard block
 block discarded – undo
317 317
         $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields');
318 318
         $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author');    // Fields to store import user id
319 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
-		);
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);
329
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
330
-		{
331
-		    while ($obj=$this->db->fetch_object($resql))
332
-		    {
333
-		        $fieldname='extra.'.$obj->name;
334
-		        $fieldlabel=ucfirst($obj->label);
335
-		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
336
-		    }
337
-		}
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]$');
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
+        );
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);
329
+        if ($resql)    // This can fail when class is used on old database (during migration for example)
330
+        {
331
+            while ($obj=$this->db->fetch_object($resql))
332
+            {
333
+                $fieldname='extra.'.$obj->name;
334
+                $fieldlabel=ucfirst($obj->label);
335
+                $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
336
+            }
337
+        }
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 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
-		);
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
+        );
349 349
 
350 350
         // Cronjobs
351 351
         $arraydate=dol_getdate(dol_now());
352 352
         $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
353 353
         $this->cronjobs = array(
354
-			0=>array(
355
-				'label'=>'SendReminderForExpiredSubscriptionTitle',
356
-				'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php',
357
-				'objectname'=>'Adherent',
358
-				'method'=>'sendReminderForExpiredSubscription',
359
-				'parameters'=>'10;0',
360
-				'comment'=>'SendReminderForExpiredSubscription',
361
-				'frequency'=>1,
362
-				'unitfrequency'=> 3600 * 24,
363
-				'priority'=>50,
364
-				'status'=>1,
365
-				'test'=>'$conf->adherent->enabled',
366
-				'datestart'=>$datestart
367
-			),
354
+            0=>array(
355
+                'label'=>'SendReminderForExpiredSubscriptionTitle',
356
+                'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php',
357
+                'objectname'=>'Adherent',
358
+                'method'=>'sendReminderForExpiredSubscription',
359
+                'parameters'=>'10;0',
360
+                'comment'=>'SendReminderForExpiredSubscription',
361
+                'frequency'=>1,
362
+                'unitfrequency'=> 3600 * 24,
363
+                'priority'=>50,
364
+                'status'=>1,
365
+                'test'=>'$conf->adherent->enabled',
366
+                'datestart'=>$datestart
367
+            ),
368 368
         );
369 369
     }
370 370
 
Please login to merge, or discard this 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.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -326,11 +326,13 @@
 block discarded – undo
326 326
 		// Add extra fields
327 327
 		$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")";
328 328
 		$resql=$this->db->query($sql);
329
-		if ($resql)    // This can fail when class is used on old database (during migration for example)
329
+		if ($resql) {
330
+		    // This can fail when class is used on old database (during migration for example)
330 331
 		{
331 332
 		    while ($obj=$this->db->fetch_object($resql))
332 333
 		    {
333 334
 		        $fieldname='extra.'.$obj->name;
335
+		}
334 336
 		        $fieldlabel=ucfirst($obj->label);
335 337
 		        $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':'');
336 338
 		    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modCategorie.class.php 3 patches
Indentation   +394 added lines, -394 removed lines patch added patch discarded remove patch
@@ -32,157 +32,157 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class modCategorie extends DolibarrModules
34 34
 {
35
-	/**
36
-	 *   Constructor. Define names, constants, directories, boxes, permissions
37
-	 *
38
-	 *   @param      DoliDB		$db      Database handler
39
-	 */
40
-	function __construct($db)
41
-	{
42
-	    global $conf;
43
-
44
-		$this->db = $db;
45
-		$this->numero = 1780;
46
-
47
-		$this->family = "technic";
48
-		$this->module_position = '20';
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));
51
-		$this->description = "Gestion des categories (produits, clients, fournisseurs...)";
52
-
53
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
54
-		$this->version = 'dolibarr';
55
-
56
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
57
-		$this->picto = 'category';
58
-
59
-		// Data directories to create when module is enabled
60
-		$this->dirs = array();
61
-
62
-		// Dependencies
63
-		$this->depends = array();
64
-
65
-		// Config pages
66
-		$this->config_page_url = array('categorie.php@categories');
67
-		$this->langfiles = array("products","companies","categories","members");
68
-
69
-		// Constants
70
-		$this->const = array();
71
-		$r=0;
72
-		$this->const[$r][0] = "CATEGORIE_RECURSIV_ADD";
73
-		$this->const[$r][1] = "yesno";
74
-		$this->const[$r][2] = "0";
75
-		$this->const[$r][3] = 'Affect parent categories';
76
-		$this->const[$r][4] = 0;
77
-		$r++;
78
-
79
-		// Boxes
80
-		$this->boxes = array();
81
-
82
-		// Permissions
83
-		$this->rights = array();
84
-		$this->rights_class = 'categorie';
85
-
86
-		$r=0;
87
-
88
-		$this->rights[$r][0] = 241; // id de la permission
89
-		$this->rights[$r][1] = 'Lire les categories'; // libelle de la permission
90
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecated)
91
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
92
-		$this->rights[$r][4] = 'lire';
93
-		$r++;
94
-
95
-		$this->rights[$r][0] = 242; // id de la permission
96
-		$this->rights[$r][1] = 'Creer/modifier les categories'; // libelle de la permission
97
-		$this->rights[$r][2] = 'w'; // type de la permission (deprecated)
98
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
99
-		$this->rights[$r][4] = 'creer';
100
-		$r++;
101
-
102
-		$this->rights[$r][0] = 243; // id de la permission
103
-		$this->rights[$r][1] = 'Supprimer les categories'; // libelle de la permission
104
-		$this->rights[$r][2] = 'd'; // type de la permission (deprecated)
105
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
106
-		$this->rights[$r][4] = 'supprimer';
107
-		$r++;
108
-
109
-
110
-		// Menus
111
-		//-------
112
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
113
-
114
-
115
-		// Exports
116
-		//--------
117
-		$r=0;
118
-
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",
130
-			's.note_public'=>"NotePublic"
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"
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, ';
146
-		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, ';
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
151
-
152
-		$r++;
153
-		$this->export_code[$r]='category_'.$r;
154
-		$this->export_label[$r]='CatCusList';
155
-		$this->export_icon[$r]='category';
35
+    /**
36
+     *   Constructor. Define names, constants, directories, boxes, permissions
37
+     *
38
+     *   @param      DoliDB		$db      Database handler
39
+     */
40
+    function __construct($db)
41
+    {
42
+        global $conf;
43
+
44
+        $this->db = $db;
45
+        $this->numero = 1780;
46
+
47
+        $this->family = "technic";
48
+        $this->module_position = '20';
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));
51
+        $this->description = "Gestion des categories (produits, clients, fournisseurs...)";
52
+
53
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
54
+        $this->version = 'dolibarr';
55
+
56
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
57
+        $this->picto = 'category';
58
+
59
+        // Data directories to create when module is enabled
60
+        $this->dirs = array();
61
+
62
+        // Dependencies
63
+        $this->depends = array();
64
+
65
+        // Config pages
66
+        $this->config_page_url = array('categorie.php@categories');
67
+        $this->langfiles = array("products","companies","categories","members");
68
+
69
+        // Constants
70
+        $this->const = array();
71
+        $r=0;
72
+        $this->const[$r][0] = "CATEGORIE_RECURSIV_ADD";
73
+        $this->const[$r][1] = "yesno";
74
+        $this->const[$r][2] = "0";
75
+        $this->const[$r][3] = 'Affect parent categories';
76
+        $this->const[$r][4] = 0;
77
+        $r++;
78
+
79
+        // Boxes
80
+        $this->boxes = array();
81
+
82
+        // Permissions
83
+        $this->rights = array();
84
+        $this->rights_class = 'categorie';
85
+
86
+        $r=0;
87
+
88
+        $this->rights[$r][0] = 241; // id de la permission
89
+        $this->rights[$r][1] = 'Lire les categories'; // libelle de la permission
90
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecated)
91
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
92
+        $this->rights[$r][4] = 'lire';
93
+        $r++;
94
+
95
+        $this->rights[$r][0] = 242; // id de la permission
96
+        $this->rights[$r][1] = 'Creer/modifier les categories'; // libelle de la permission
97
+        $this->rights[$r][2] = 'w'; // type de la permission (deprecated)
98
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
99
+        $this->rights[$r][4] = 'creer';
100
+        $r++;
101
+
102
+        $this->rights[$r][0] = 243; // id de la permission
103
+        $this->rights[$r][1] = 'Supprimer les categories'; // libelle de la permission
104
+        $this->rights[$r][2] = 'd'; // type de la permission (deprecated)
105
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
106
+        $this->rights[$r][4] = 'supprimer';
107
+        $r++;
108
+
109
+
110
+        // Menus
111
+        //-------
112
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
113
+
114
+
115
+        // Exports
116
+        //--------
117
+        $r=0;
118
+
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",
130
+            's.note_public'=>"NotePublic"
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"
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, ';
146
+        $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_fournisseur as cf, ';
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
151
+
152
+        $r++;
153
+        $this->export_code[$r]='category_'.$r;
154
+        $this->export_label[$r]='CatCusList';
155
+        $this->export_icon[$r]='category';
156 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
-		);
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
-			's.fk_stcomm'=>'List:c_stcomm:libelle:code'
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',
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, ';
181
-		$this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';
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
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
+        );
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
+            's.fk_stcomm'=>'List:c_stcomm:libelle:code'
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',
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, ';
181
+        $this->export_sql_end[$r] .= MAIN_DB_PREFIX.'categorie_societe as cf, ';
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
186 186
 
187 187
         // Add extra fields
188 188
         $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
@@ -226,270 +226,270 @@  discard block
 block discarded – undo
226 226
 
227 227
 
228 228
 
229
-		$r++;
230
-		$this->export_code[$r]='category_'.$r;
231
-		$this->export_label[$r]='CatProdList';
232
-		$this->export_icon[$r]='category';
229
+        $r++;
230
+        $this->export_code[$r]='category_'.$r;
231
+        $this->export_label[$r]='CatProdList';
232
+        $this->export_icon[$r]='category';
233 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
-
244
-		$r++;
245
-		$this->export_code[$r]='category_'.$r;
246
-		$this->export_label[$r]='CatMemberList';
247
-		$this->export_icon[$r]='category';
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
+
244
+        $r++;
245
+        $this->export_code[$r]='category_'.$r;
246
+        $this->export_label[$r]='CatMemberList';
247
+        $this->export_icon[$r]='category';
248 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
-
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 (
266
-			'u.rowid' => "CategId",
267
-			'u.label' => "Label",
268
-			'u.description' => "Description",
269
-			'p.rowid' => 'ContactId',
270
-			'p.civility' => 'UserTitle',
271
-			'p.lastname' => 'LastName',
272
-			'p.firstname' => 'Firstname',
273
-			'p.address' => 'Address',
274
-			'p.zip' => 'Zip',
275
-			'p.town' => 'Town',
276
-			'country.code' => 'CountryCode',
277
-			'country.label' => 'Country',
278
-			'p.birthday' => 'DateToBirth',
279
-			'p.poste' => 'PostOrFunction',
280
-			'p.phone' => 'Phone',
281
-			'p.phone_perso' => 'PhonePerso',
282
-			'p.phone_mobile' => 'PhoneMobile',
283
-			'p.fax' => 'Fax',
284
-			'p.email' => 'Email',
285
-			'p.note_private' => 'NotePrivate',
286
-			'p.note_public' => 'NotePublic',
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
+
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 (
266
+            'u.rowid' => "CategId",
267
+            'u.label' => "Label",
268
+            'u.description' => "Description",
269
+            'p.rowid' => 'ContactId',
270
+            'p.civility' => 'UserTitle',
271
+            'p.lastname' => 'LastName',
272
+            'p.firstname' => 'Firstname',
273
+            'p.address' => 'Address',
274
+            'p.zip' => 'Zip',
275
+            'p.town' => 'Town',
276
+            'country.code' => 'CountryCode',
277
+            'country.label' => 'Country',
278
+            'p.birthday' => 'DateToBirth',
279
+            'p.poste' => 'PostOrFunction',
280
+            'p.phone' => 'Phone',
281
+            'p.phone_perso' => 'PhonePerso',
282
+            'p.phone_mobile' => 'PhoneMobile',
283
+            'p.fax' => 'Fax',
284
+            'p.email' => 'Email',
285
+            'p.note_private' => 'NotePrivate',
286
+            'p.note_public' => 'NotePublic',
287 287
             'p.statut' => 'Status',
288
-			's.nom'=>"Name",
289
-			's.client'=>"Customer",
290
-			's.fournisseur'=>"Supplier",
291
-			's.status'=>"Status",
292
-			's.address'=>"Address",
293
-			's.zip'=>"Zip",
294
-			's.town'=>"Town",
295
-			's.phone'=>"Phone",
296
-			's.fax'=>"Fax",
297
-			's.url'=>"Url",
298
-			's.email'=>"Email"
299
-		);
300
-		$this->export_TypeFields_array[$r] = array (
301
-			'u.label' => "Text",
302
-			'u.description' => "Text",
303
-			'p.lastname' => 'Text',
304
-			'p.firstname' => 'Text',
288
+            's.nom'=>"Name",
289
+            's.client'=>"Customer",
290
+            's.fournisseur'=>"Supplier",
291
+            's.status'=>"Status",
292
+            's.address'=>"Address",
293
+            's.zip'=>"Zip",
294
+            's.town'=>"Town",
295
+            's.phone'=>"Phone",
296
+            's.fax'=>"Fax",
297
+            's.url'=>"Url",
298
+            's.email'=>"Email"
299
+        );
300
+        $this->export_TypeFields_array[$r] = array (
301
+            'u.label' => "Text",
302
+            'u.description' => "Text",
303
+            'p.lastname' => 'Text',
304
+            'p.firstname' => 'Text',
305 305
             'p.statut'=>"Numeric",
306
-			's.nom'=>"Text",
307
-			's.status'=>"Text",
308
-			's.address'=>"Text",
309
-			's.zip'=>"Text",
310
-			's.town'=>"Text",
311
-			's.phone'=>"Text",
312
-			's.fax'=>"Text",
313
-			's.url'=>"Text",
314
-			's.email'=>"Text"
315
-		);
316
-		$this->export_entities_array[$r] = array (
317
-			'u.rowid' => "category",
318
-			'u.label' => "category",
319
-			'u.description' => "category",
320
-			'p.rowid' => 'contact',
321
-			'p.civility' => 'contact',
322
-			'p.lastname' => 'contact',
323
-			'p.firstname' => 'contact',
324
-			'p.address' => 'contact',
325
-			'p.zip' => 'contact',
326
-			'p.town' => 'contact',
327
-			'country.code' => 'contact',
328
-			'country.label' => 'contact',
329
-			'p.birthday' => 'contact',
330
-			'p.poste' => 'contact',
331
-			'p.phone' => 'contact',
332
-			'p.phone_perso' => 'contact',
333
-			'p.phone_mobile' => 'contact',
334
-			'p.fax' => 'contact',
335
-			'p.email' => 'contact',
336
-			'p.note_private' => 'contact',
337
-			'p.note_public' => 'contact',
306
+            's.nom'=>"Text",
307
+            's.status'=>"Text",
308
+            's.address'=>"Text",
309
+            's.zip'=>"Text",
310
+            's.town'=>"Text",
311
+            's.phone'=>"Text",
312
+            's.fax'=>"Text",
313
+            's.url'=>"Text",
314
+            's.email'=>"Text"
315
+        );
316
+        $this->export_entities_array[$r] = array (
317
+            'u.rowid' => "category",
318
+            'u.label' => "category",
319
+            'u.description' => "category",
320
+            'p.rowid' => 'contact',
321
+            'p.civility' => 'contact',
322
+            'p.lastname' => 'contact',
323
+            'p.firstname' => 'contact',
324
+            'p.address' => 'contact',
325
+            'p.zip' => 'contact',
326
+            'p.town' => 'contact',
327
+            'country.code' => 'contact',
328
+            'country.label' => 'contact',
329
+            'p.birthday' => 'contact',
330
+            'p.poste' => 'contact',
331
+            'p.phone' => 'contact',
332
+            'p.phone_perso' => 'contact',
333
+            'p.phone_mobile' => 'contact',
334
+            'p.fax' => 'contact',
335
+            'p.email' => 'contact',
336
+            'p.note_private' => 'contact',
337
+            'p.note_public' => 'contact',
338 338
             'p.statut' => 'contact',
339
-			's.nom'=>"company",
340
-			's.client'=>"company",
341
-			's.fournisseur'=>"company",
342
-			's.status'=>"company",
343
-			's.address'=>"company",
344
-			's.zip'=>"company",
345
-			's.town'=>"company",
346
-			's.phone'=>"company",
347
-			's.fax'=>"company",
348
-			's.url'=>"company",
349
-			's.email'=>"company"
350
-		); // We define here only fields that use another picto
339
+            's.nom'=>"company",
340
+            's.client'=>"company",
341
+            's.fournisseur'=>"company",
342
+            's.status'=>"company",
343
+            's.address'=>"company",
344
+            's.zip'=>"company",
345
+            's.town'=>"company",
346
+            's.phone'=>"company",
347
+            's.fax'=>"company",
348
+            's.url'=>"company",
349
+            's.email'=>"company"
350
+        ); // We define here only fields that use another picto
351 351
 
352 352
         // Add extra fields
353 353
         $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'";
354 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))
358
-        	{
359
-        		$fieldname='extra.'.$obj->name;
360
-        		$fieldlabel=ucfirst($obj->label);
361
-        		$typeFilter="Text";
362
-        		switch($obj->type)
363
-        		{
364
-        			case 'int':
365
-        			case 'double':
366
-        			case 'price':
367
-        				$typeFilter="Numeric";
368
-        				break;
369
-        			case 'date':
370
-        			case 'datetime':
371
-        				$typeFilter="Date";
372
-        				break;
373
-        			case 'boolean':
374
-        				$typeFilter="Boolean";
375
-        				break;
376
-        			case 'sellist':
377
-        				$typeFilter="List:".$obj->param;
378
-        				break;
379
-					case 'select':
380
-						$typeFilter="Select:".$obj->param;
381
-						break;
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';
386
-        	}
357
+            while ($obj=$this->db->fetch_object($resql))
358
+            {
359
+                $fieldname='extra.'.$obj->name;
360
+                $fieldlabel=ucfirst($obj->label);
361
+                $typeFilter="Text";
362
+                switch($obj->type)
363
+                {
364
+                    case 'int':
365
+                    case 'double':
366
+                    case 'price':
367
+                        $typeFilter="Numeric";
368
+                        break;
369
+                    case 'date':
370
+                    case 'datetime':
371
+                        $typeFilter="Date";
372
+                        break;
373
+                    case 'boolean':
374
+                        $typeFilter="Boolean";
375
+                        break;
376
+                    case 'sellist':
377
+                        $typeFilter="List:".$obj->param;
378
+                        break;
379
+                    case 'select':
380
+                        $typeFilter="Select:".$obj->param;
381
+                        break;
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';
386
+            }
387 387
         }
388 388
         // End add axtra fields
389 389
 
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';
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 394
         $this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'socpeople_extrafields as extra ON extra.fk_object = p.rowid';
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
-		$this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories
397
-
398
-		// Imports
399
-		//--------
400
-
401
-		$r=0;
402
-
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))
420
-		{
421
-			//Products
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*"
429
-			);
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')
434
-			);
435
-			$this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456");
436
-		}
437
-
438
-		if (! empty($conf->societe->enabled))
439
-		{
440
-			//Customers
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*"
448
-			);
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')
453
-			);
454
-			$this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
455
-		}
456
-
457
-		if (! empty($conf->fournisseur->enabled))
458
-		{
459
-			// Suppliers
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*"
467
-			);
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')
472
-			);
473
-			$this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
474
-		}
475
-	}
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
+        $this->export_sql_end[$r] .= ' AND u.type = 4'; // contact categories
397
+
398
+        // Imports
399
+        //--------
400
+
401
+        $r=0;
402
+
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))
420
+        {
421
+            //Products
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*"
429
+            );
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')
434
+            );
435
+            $this->import_examplevalues_array[$r]=array('cp.fk_categorie'=>"Imported category",'cp.fk_product'=>"PREF123456");
436
+        }
437
+
438
+        if (! empty($conf->societe->enabled))
439
+        {
440
+            //Customers
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*"
448
+            );
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')
453
+            );
454
+            $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
455
+        }
456
+
457
+        if (! empty($conf->fournisseur->enabled))
458
+        {
459
+            // Suppliers
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*"
467
+            );
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')
472
+            );
473
+            $this->import_examplevalues_array[$r]=array('cs.fk_categorie'=>"Imported category",'cs.fk_soc'=>"MyBigCompany");
474
+        }
475
+    }
476 476
 
477 477
 
478 478
     /**
479
-	 *		Function called when module is enabled.
480
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
481
-	 *		It also creates data directories
482
-	 *
479
+     *		Function called when module is enabled.
480
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
481
+     *		It also creates data directories
482
+     *
483 483
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
484
-	 *      @return     int             	1 if OK, 0 if KO
484
+     *      @return     int             	1 if OK, 0 if KO
485 485
      */
486
-	function init($options='')
487
-	{
488
-		// Permissions
489
-		$this->remove($options);
486
+    function init($options='')
487
+    {
488
+        // Permissions
489
+        $this->remove($options);
490 490
 
491
-		$sql = array();
491
+        $sql = array();
492 492
 
493
-		return $this->_init($sql,$options);
494
-	}
493
+        return $this->_init($sql,$options);
494
+    }
495 495
 }
Please login to merge, or discard this 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.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -187,11 +187,13 @@  discard block
 block discarded – undo
187 187
         // Add extra fields
188 188
         $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'";
189 189
         $resql=$this->db->query($sql);
190
-        if ($resql)    // This can fail when class is used on old database (during migration for example)
190
+        if ($resql) {
191
+            // This can fail when class is used on old database (during migration for example)
191 192
         {
192 193
             while ($obj=$this->db->fetch_object($resql))
193 194
             {
194 195
                 $fieldname='extra.'.$obj->name;
196
+        }
195 197
                 $fieldlabel=ucfirst($obj->label);
196 198
                 $typeFilter="Text";
197 199
                 switch($obj->type)
@@ -352,11 +354,13 @@  discard block
 block discarded – undo
352 354
         // Add extra fields
353 355
         $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'";
354 356
         $resql=$this->db->query($sql);
355
-        if ($resql)    // This can fail when class is used on old database (during migration for example)
357
+        if ($resql) {
358
+            // This can fail when class is used on old database (during migration for example)
356 359
         {
357 360
         	while ($obj=$this->db->fetch_object($resql))
358 361
         	{
359 362
         		$fieldname='extra.'.$obj->name;
363
+        }
360 364
         		$fieldlabel=ucfirst($obj->label);
361 365
         		$typeFilter="Text";
362 366
         		switch($obj->type)
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modDocumentGeneration.class.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -34,84 +34,84 @@
 block discarded – undo
34 34
 class modDocumentGeneration extends DolibarrModules
35 35
 {
36 36
 
37
-	/**
38
-	 *   Constructor. Define names, constants, directories, boxes, permissions
39
-	 *
40
-	 *   @param      DoliDB		$db      Database handler
41
-	 */
42
-	function __construct($db)
43
-	{
44
-		$this->db = $db;
45
-		$this->numero = 1520;
46
-
47
-		$this->family = "technic";
48
-		$this->module_position = '80';
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));
51
-		$this->description = "Direct mail document generation";
52
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
-		$this->version = 'development';
54
-
55
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
-		$this->picto='email';
57
-
58
-		// Data directories to create when module is enabled
59
-		$this->dirs = array("/documentgeneration/temp");
60
-
61
-		// Config pages
62
-		//$this->config_page_url = array("document.php");
63
-
64
-		// Dependencies
65
-		$this->depends = array();
66
-		$this->requiredby = array();
67
-		$this->conflictwith = array();
68
-		$this->langfiles = array("orders","bills","companies","mails");
69
-
70
-		// Constants
71
-
72
-		$this->const = array();
73
-
74
-		// Boxes
75
-		$this->boxes = array();
76
-
77
-		// Permissions
78
-		$this->rights = array();
79
-		$this->rights_class = 'document';
80
-
81
-		$r=0;
82
-
83
-		$this->rights[$r][0] = 1521;
84
-		$this->rights[$r][1] = 'Lire les documents';
85
-		$this->rights[$r][2] = 'r';
86
-		$this->rights[$r][3] = 0;
87
-		$this->rights[$r][4] = 'lire';
88
-
89
-		$r++;
90
-		$this->rights[$r][0] = 1522;
91
-		$this->rights[$r][1] = 'Supprimer les documents clients';
92
-		$this->rights[$r][2] = 'd';
93
-		$this->rights[$r][3] = 0;
94
-		$this->rights[$r][4] = 'supprimer';
95
-	}
96
-
97
-
98
-	/**
99
-	 *		Function called when module is enabled.
100
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
101
-	 *		It also creates data directories
102
-	 *
37
+    /**
38
+     *   Constructor. Define names, constants, directories, boxes, permissions
39
+     *
40
+     *   @param      DoliDB		$db      Database handler
41
+     */
42
+    function __construct($db)
43
+    {
44
+        $this->db = $db;
45
+        $this->numero = 1520;
46
+
47
+        $this->family = "technic";
48
+        $this->module_position = '80';
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));
51
+        $this->description = "Direct mail document generation";
52
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
53
+        $this->version = 'development';
54
+
55
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
56
+        $this->picto='email';
57
+
58
+        // Data directories to create when module is enabled
59
+        $this->dirs = array("/documentgeneration/temp");
60
+
61
+        // Config pages
62
+        //$this->config_page_url = array("document.php");
63
+
64
+        // Dependencies
65
+        $this->depends = array();
66
+        $this->requiredby = array();
67
+        $this->conflictwith = array();
68
+        $this->langfiles = array("orders","bills","companies","mails");
69
+
70
+        // Constants
71
+
72
+        $this->const = array();
73
+
74
+        // Boxes
75
+        $this->boxes = array();
76
+
77
+        // Permissions
78
+        $this->rights = array();
79
+        $this->rights_class = 'document';
80
+
81
+        $r=0;
82
+
83
+        $this->rights[$r][0] = 1521;
84
+        $this->rights[$r][1] = 'Lire les documents';
85
+        $this->rights[$r][2] = 'r';
86
+        $this->rights[$r][3] = 0;
87
+        $this->rights[$r][4] = 'lire';
88
+
89
+        $r++;
90
+        $this->rights[$r][0] = 1522;
91
+        $this->rights[$r][1] = 'Supprimer les documents clients';
92
+        $this->rights[$r][2] = 'd';
93
+        $this->rights[$r][3] = 0;
94
+        $this->rights[$r][4] = 'supprimer';
95
+    }
96
+
97
+
98
+    /**
99
+     *		Function called when module is enabled.
100
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
101
+     *		It also creates data directories
102
+     *
103 103
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
104
-	 *      @return     int             	1 if OK, 0 if KO
105
-	 */
106
-	function init($options='')
107
-	{
108
-		global $conf;
104
+     *      @return     int             	1 if OK, 0 if KO
105
+     */
106
+    function init($options='')
107
+    {
108
+        global $conf;
109 109
 
110
-		// Permissions
111
-		$this->remove($options);
110
+        // Permissions
111
+        $this->remove($options);
112 112
 
113
-		$sql = array();
113
+        $sql = array();
114 114
 
115
-		return $this->_init($sql,$options);
116
-	}
115
+        return $this->_init($sql,$options);
116
+    }
117 117
 }
Please login to merge, or discard this 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/modMultiCurrency.class.php 2 patches
Indentation   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -33,105 +33,105 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class modMultiCurrency extends DolibarrModules
35 35
 {
36
-	/**
37
-	 * Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 * @param DoliDB $db Database handler
40
-	 */
41
-	public function __construct($db)
42
-	{
36
+    /**
37
+     * Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     * @param DoliDB $db Database handler
40
+     */
41
+    public function __construct($db)
42
+    {
43 43
         global $langs, $conf;
44 44
 
45 45
         $this->db = $db;
46 46
 
47
-		// Id for module (must be unique).
48
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
49
-		$this->numero = 40000;
50
-		// Key text used to identify module (for permissions, menus, etc...)
51
-		$this->rights_class = 'multicurrency';
52
-
53
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
54
-		// It is used to group modules in module setup page
55
-		$this->family = "technic";
56
-		// Module position in the family
57
-		$this->module_position = '40';
58
-
59
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
60
-		$this->name = preg_replace('/^mod/i', '', get_class($this));
61
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
62
-		$this->description = "Module to manage several foreign currencies in prices and documents";
63
-
64
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
65
-		$this->version = 'dolibarr';
66
-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
67
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
68
-		// Name of image file used for this module.
69
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
70
-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
71
-		$this->picto = 'multicurrency';
72
-
73
-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
74
-		// for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable)
75
-		// for specific path of parts (eg: /multicurrency/core/modules/barcode)
76
-		// for specific css file (eg: /multicurrency/css/multicurrency.css.php)
77
-		$this->module_parts = array();
78
-
79
-		// Data directories to create when module is enabled.
80
-		// Example: this->dirs = array("/multicurrency/temp");
81
-		$this->dirs = array();
82
-
83
-		// Config pages. Put here list of php page, stored into multicurrency/admin directory, to use to setup module.
84
-		$this->config_page_url = array("multicurrency.php");
85
-
86
-		// Dependencies
87
-		$this->hidden = false; // A condition to hide module
88
-		$this->depends = array(); // List of modules id that must be enabled if this module is enabled
89
-		$this->requiredby = array(); // List of modules id to disable if this one is disabled
90
-		$this->conflictwith = array(); // List of modules id this module is in conflict with
91
-		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
92
-		$this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
93
-		$this->langfiles = array("multicurrency");
94
-
95
-		// Constants
96
-		// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
97
-		// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
98
-		//                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
99
-		// );
100
-		$this->const = array();
101
-
102
-		// Array to add new pages in new tabs
103
-		// Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@multicurrency:$user->rights->multicurrency->read:/multicurrency/mynewtab1.php?id=__ID__',  					// To add a new tab identified by code tabname1
47
+        // Id for module (must be unique).
48
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
49
+        $this->numero = 40000;
50
+        // Key text used to identify module (for permissions, menus, etc...)
51
+        $this->rights_class = 'multicurrency';
52
+
53
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
54
+        // It is used to group modules in module setup page
55
+        $this->family = "technic";
56
+        // Module position in the family
57
+        $this->module_position = '40';
58
+
59
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
60
+        $this->name = preg_replace('/^mod/i', '', get_class($this));
61
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
62
+        $this->description = "Module to manage several foreign currencies in prices and documents";
63
+
64
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
65
+        $this->version = 'dolibarr';
66
+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
67
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
68
+        // Name of image file used for this module.
69
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
70
+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
71
+        $this->picto = 'multicurrency';
72
+
73
+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
74
+        // for default path (eg: /multicurrency/core/xxxxx) (0=disable, 1=enable)
75
+        // for specific path of parts (eg: /multicurrency/core/modules/barcode)
76
+        // for specific css file (eg: /multicurrency/css/multicurrency.css.php)
77
+        $this->module_parts = array();
78
+
79
+        // Data directories to create when module is enabled.
80
+        // Example: this->dirs = array("/multicurrency/temp");
81
+        $this->dirs = array();
82
+
83
+        // Config pages. Put here list of php page, stored into multicurrency/admin directory, to use to setup module.
84
+        $this->config_page_url = array("multicurrency.php");
85
+
86
+        // Dependencies
87
+        $this->hidden = false; // A condition to hide module
88
+        $this->depends = array(); // List of modules id that must be enabled if this module is enabled
89
+        $this->requiredby = array(); // List of modules id to disable if this one is disabled
90
+        $this->conflictwith = array(); // List of modules id this module is in conflict with
91
+        $this->phpmin = array(5, 4); // Minimum version of PHP required by module
92
+        $this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
93
+        $this->langfiles = array("multicurrency");
94
+
95
+        // Constants
96
+        // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
97
+        // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
98
+        //                             1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
99
+        // );
100
+        $this->const = array();
101
+
102
+        // Array to add new pages in new tabs
103
+        // Example: $this->tabs = array('objecttype:+tabname1:Title1:mylangfile@multicurrency:$user->rights->multicurrency->read:/multicurrency/mynewtab1.php?id=__ID__',  					// To add a new tab identified by code tabname1
104 104
         //                              'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@multicurrency:$user->rights->othermodule->read:/multicurrency/mynewtab2.php?id=__ID__',  	// To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
105 105
         //                              'objecttype:-tabname:NU:conditiontoremove');                                                     										// To remove an existing tab identified by code tabname
106
-		// where objecttype can be
107
-		// 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
108
-		// 'contact'          to add a tab in contact view
109
-		// 'contract'         to add a tab in contract view
110
-		// 'group'            to add a tab in group view
111
-		// 'intervention'     to add a tab in intervention view
112
-		// 'invoice'          to add a tab in customer invoice view
113
-		// 'invoice_supplier' to add a tab in supplier invoice view
114
-		// 'member'           to add a tab in fundation member view
115
-		// 'opensurveypoll'	  to add a tab in opensurvey poll view
116
-		// 'order'            to add a tab in customer order view
117
-		// 'order_supplier'   to add a tab in supplier order view
118
-		// 'payment'		  to add a tab in payment view
119
-		// 'payment_supplier' to add a tab in supplier payment view
120
-		// 'product'          to add a tab in product view
121
-		// 'propal'           to add a tab in propal view
122
-		// 'project'          to add a tab in project view
123
-		// 'stock'            to add a tab in stock view
124
-		// 'thirdparty'       to add a tab in third party view
125
-		// 'user'             to add a tab in user view
106
+        // where objecttype can be
107
+        // 'categories_x'	  to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
108
+        // 'contact'          to add a tab in contact view
109
+        // 'contract'         to add a tab in contract view
110
+        // 'group'            to add a tab in group view
111
+        // 'intervention'     to add a tab in intervention view
112
+        // 'invoice'          to add a tab in customer invoice view
113
+        // 'invoice_supplier' to add a tab in supplier invoice view
114
+        // 'member'           to add a tab in fundation member view
115
+        // 'opensurveypoll'	  to add a tab in opensurvey poll view
116
+        // 'order'            to add a tab in customer order view
117
+        // 'order_supplier'   to add a tab in supplier order view
118
+        // 'payment'		  to add a tab in payment view
119
+        // 'payment_supplier' to add a tab in supplier payment view
120
+        // 'product'          to add a tab in product view
121
+        // 'propal'           to add a tab in propal view
122
+        // 'project'          to add a tab in project view
123
+        // 'stock'            to add a tab in stock view
124
+        // 'thirdparty'       to add a tab in third party view
125
+        // 'user'             to add a tab in user view
126 126
         $this->tabs = array();
127 127
 
128 128
         // Dictionaries
129
-	    if (!isset($conf->multicurrency->enabled))
129
+        if (!isset($conf->multicurrency->enabled))
130 130
         {
131
-        	$conf->multicurrency = new stdClass();
132
-        	$conf->multicurrency->enabled = 0;
131
+            $conf->multicurrency = new stdClass();
132
+            $conf->multicurrency->enabled = 0;
133 133
         }
134
-		$this->dictionaries = array();
134
+        $this->dictionaries = array();
135 135
         /* Example:
136 136
         if (! isset($conf->multicurrency->enabled)) $conf->multicurrency->enabled=0;	// This is to avoid warnings
137 137
         $this->dictionaries=array(
@@ -150,169 +150,169 @@  discard block
 block discarded – undo
150 150
         */
151 151
 
152 152
         // Boxes
153
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
153
+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
154 154
         $this->boxes = array(); // List of boxes
155
-		// Example:
156
-		//$this->boxes=array(
157
-		//    0=>array('file'=>'myboxa.php@multicurrency','note'=>'','enabledbydefaulton'=>'Home'),
158
-		//    1=>array('file'=>'myboxb.php@multicurrency','note'=>''),
159
-		//    2=>array('file'=>'myboxc.php@multicurrency','note'=>'')
160
-		//);
161
-
162
-		// Permissions
163
-		$this->rights = array(); // Permission array used by this module
164
-		$r = 0;
165
-
166
-		// Add here list of permission defined by an id, a label, a boolean and two constant strings.
167
-		// Example:
168
-		// $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
169
-		// $this->rights[$r][1] = 'Permision label';	// Permission label
170
-		// $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)
171
-		// $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
172
-		// $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
173
-		// $r++;
174
-
175
-		// Main menu entries
176
-		$this->menu = array(); // List of menus to add
177
-		$r = 0;
178
-
179
-		// Add here entries to declare new menus
180
-		//
181
-		// Example to declare a new Top Menu entry and its Left menu entry:
182
-		// $this->menu[$r]=array(	'fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
183
-		//							'type'=>'top',			                // This is a Top menu entry
184
-		//							'titre'=>'MyModule top menu',
185
-		//							'mainmenu'=>'multicurrency',
186
-		//							'leftmenu'=>'multicurrency',
187
-		//							'url'=>'/multicurrency/pagetop.php',
188
-		//							'langs'=>'mylangfile@multicurrency',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
189
-		//							'position'=>100,
190
-		//							'enabled'=>'$conf->multicurrency->enabled',	// Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled.
191
-		//							'perms'=>'1',			                // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules
192
-		//							'target'=>'',
193
-		//							'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
194
-		// $r++;
195
-		//
196
-		// Example to declare a Left Menu entry into an existing Top menu entry:
197
-		// $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=xxx',		    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
198
-		//							'type'=>'left',			                // This is a Left menu entry
199
-		//							'titre'=>'MyModule left menu',
200
-		//							'mainmenu'=>'xxx',
201
-		//							'leftmenu'=>'multicurrency',
202
-		//							'url'=>'/multicurrency/pagelevel2.php',
203
-		//							'langs'=>'mylangfile@multicurrency',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
204
-		//							'position'=>100,
205
-		//							'enabled'=>'$conf->multicurrency->enabled',  // Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
206
-		//							'perms'=>'1',			                // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules
207
-		//							'target'=>'',
208
-		//							'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
209
-		// $r++;
210
-
211
-
212
-		// Exports
213
-		$r = 1;
214
-
215
-		// Example:
216
-		// $this->export_code[$r]=$this->rights_class.'_'.$r;
217
-		// $this->export_label[$r]='MyModule';	// Translation key (used only if key ExportDataset_xxx_z not found)
155
+        // Example:
156
+        //$this->boxes=array(
157
+        //    0=>array('file'=>'myboxa.php@multicurrency','note'=>'','enabledbydefaulton'=>'Home'),
158
+        //    1=>array('file'=>'myboxb.php@multicurrency','note'=>''),
159
+        //    2=>array('file'=>'myboxc.php@multicurrency','note'=>'')
160
+        //);
161
+
162
+        // Permissions
163
+        $this->rights = array(); // Permission array used by this module
164
+        $r = 0;
165
+
166
+        // Add here list of permission defined by an id, a label, a boolean and two constant strings.
167
+        // Example:
168
+        // $this->rights[$r][0] = $this->numero + $r;	// Permission id (must not be already used)
169
+        // $this->rights[$r][1] = 'Permision label';	// Permission label
170
+        // $this->rights[$r][3] = 0; 					// Permission by default for new user (0/1)
171
+        // $this->rights[$r][4] = 'level1';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
172
+        // $this->rights[$r][5] = 'level2';				// In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
173
+        // $r++;
174
+
175
+        // Main menu entries
176
+        $this->menu = array(); // List of menus to add
177
+        $r = 0;
178
+
179
+        // Add here entries to declare new menus
180
+        //
181
+        // Example to declare a new Top Menu entry and its Left menu entry:
182
+        // $this->menu[$r]=array(	'fk_menu'=>'',			                // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
183
+        //							'type'=>'top',			                // This is a Top menu entry
184
+        //							'titre'=>'MyModule top menu',
185
+        //							'mainmenu'=>'multicurrency',
186
+        //							'leftmenu'=>'multicurrency',
187
+        //							'url'=>'/multicurrency/pagetop.php',
188
+        //							'langs'=>'mylangfile@multicurrency',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
189
+        //							'position'=>100,
190
+        //							'enabled'=>'$conf->multicurrency->enabled',	// Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled.
191
+        //							'perms'=>'1',			                // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules
192
+        //							'target'=>'',
193
+        //							'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
194
+        // $r++;
195
+        //
196
+        // Example to declare a Left Menu entry into an existing Top menu entry:
197
+        // $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=xxx',		    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
198
+        //							'type'=>'left',			                // This is a Left menu entry
199
+        //							'titre'=>'MyModule left menu',
200
+        //							'mainmenu'=>'xxx',
201
+        //							'leftmenu'=>'multicurrency',
202
+        //							'url'=>'/multicurrency/pagelevel2.php',
203
+        //							'langs'=>'mylangfile@multicurrency',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
204
+        //							'position'=>100,
205
+        //							'enabled'=>'$conf->multicurrency->enabled',  // Define condition to show or hide menu entry. Use '$conf->multicurrency->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
206
+        //							'perms'=>'1',			                // Use 'perms'=>'$user->rights->multicurrency->level1->level2' if you want your menu with a permission rules
207
+        //							'target'=>'',
208
+        //							'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
209
+        // $r++;
210
+
211
+
212
+        // Exports
213
+        $r = 1;
214
+
215
+        // Example:
216
+        // $this->export_code[$r]=$this->rights_class.'_'.$r;
217
+        // $this->export_label[$r]='MyModule';	// Translation key (used only if key ExportDataset_xxx_z not found)
218 218
         // $this->export_enabled[$r]='1';                               // Condition to show export in list (ie: '$user->id==3'). Set to 1 to always show when module is enabled.
219 219
         // $this->export_icon[$r]='generic:MyModule';
220
-		// $this->export_permission[$r]=array(array("multicurrency","level1","level2"));
221
-		// $this->export_fields_array[$r]=array(
222
-		//	's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',
223
-		//	's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
224
-		//	's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",
225
-		//	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',
226
-		//	'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",
227
-		//	'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",
228
-		//	'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'
229
-		//);
230
-		// $this->export_TypeFields_array[$r]=array(
231
-		//	't.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric',
232
-		//	't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
233
-		//	's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
234
-		//	'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
235
-		//	'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",
236
-		//	'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",
237
-		//	'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text',
238
-		//	'p.accountancy_code_sell'=>'Text'
239
-		//);
240
-		// $this->export_entities_array[$r]=array(
241
-		//	's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',
242
-		//	's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
243
-		//	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",
244
-		//	'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",
245
-		//	'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",
246
-		//	'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'
247
-		//);
248
-		// $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
249
-		// $this->export_sql_start[$r]='SELECT DISTINCT ';
250
-		// $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
251
-		// $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
252
-		// $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
253
-		// $this->export_sql_order[$r] .=' ORDER BY s.nom';
254
-		// $r++;
255
-	}
256
-
257
-	/**
258
-	 *		Function called when module is enabled.
259
-	 *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
260
-	 *		It also creates data directories
261
-	 *
220
+        // $this->export_permission[$r]=array(array("multicurrency","level1","level2"));
221
+        // $this->export_fields_array[$r]=array(
222
+        //	's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','s.fk_pays'=>'Country','s.phone'=>'Phone',
223
+        //	's.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.code_compta'=>'CustomerAccountancyCode',
224
+        //	's.code_compta_fournisseur'=>'SupplierAccountancyCode','f.rowid'=>"InvoiceId",'f.ref'=>"InvoiceRef",'f.datec'=>"InvoiceDateCreation",
225
+        //	'f.datef'=>"DateInvoice",'f.total'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.paye'=>"InvoicePaid",'f.fk_statut'=>'InvoiceStatus',
226
+        //	'f.note'=>"InvoiceNote",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.price'=>"LineUnitPrice",'fd.tva_tx'=>"LineVATRate",
227
+        //	'fd.qty'=>"LineQty",'fd.total_ht'=>"LineTotalHT",'fd.total_tva'=>"LineTotalTVA",'fd.total_ttc'=>"LineTotalTTC",'fd.date_start'=>"DateStart",
228
+        //	'fd.date_end'=>"DateEnd",'fd.fk_product'=>'ProductId','p.ref'=>'ProductRef'
229
+        //);
230
+        // $this->export_TypeFields_array[$r]=array(
231
+        //	't.date'=>'Date', 't.qte'=>'Numeric', 't.poids'=>'Numeric', 't.fad'=>'Numeric', 't.paq'=>'Numeric', 't.stockage'=>'Numeric', 't.fadparliv'=>'Numeric',
232
+        //	't.livau100'=>'Numeric', 't.forfait'=>'Numeric', 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text',
233
+        //	's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
234
+        //	'f.ref'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.date_lim_reglement'=>"Date",'f.total'=>"Numeric",'f.total_ttc'=>"Numeric",'f.tva'=>"Numeric",
235
+        //	'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_private'=>"Text",'f.note_public'=>"Text",'fd.description'=>"Text",'fd.subprice'=>"Numeric",
236
+        //	'fd.tva_tx'=>"Numeric",'fd.qty'=>"Numeric",'fd.total_ht'=>"Numeric",'fd.total_tva'=>"Numeric",'fd.total_ttc'=>"Numeric",'fd.date_start'=>"Date",
237
+        //	'fd.date_end'=>"Date",'fd.special_code'=>'Numeric','fd.product_type'=>"Numeric",'fd.fk_product'=>'List:product:label','p.ref'=>'Text','p.label'=>'Text',
238
+        //	'p.accountancy_code_sell'=>'Text'
239
+        //);
240
+        // $this->export_entities_array[$r]=array(
241
+        //	's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company','s.phone'=>'company',
242
+        //	's.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.code_compta'=>'company','s.code_compta_fournisseur'=>'company',
243
+        //	'f.rowid'=>"invoice",'f.ref'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total'=>"invoice",'f.total_ttc'=>"invoice",
244
+        //	'f.tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",
245
+        //	'fd.price'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_tva'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva_tx'=>"invoice_line",
246
+        //	'fd.qty'=>"invoice_line",'fd.date_start'=>"invoice_line",'fd.date_end'=>"invoice_line",'fd.fk_product'=>'product','p.ref'=>'product'
247
+        //);
248
+        // $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
249
+        // $this->export_sql_start[$r]='SELECT DISTINCT ';
250
+        // $this->export_sql_end[$r]  =' FROM ('.MAIN_DB_PREFIX.'facture as f, '.MAIN_DB_PREFIX.'facturedet as fd, '.MAIN_DB_PREFIX.'societe as s)';
251
+        // $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)';
252
+        // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture';
253
+        // $this->export_sql_order[$r] .=' ORDER BY s.nom';
254
+        // $r++;
255
+    }
256
+
257
+    /**
258
+     *		Function called when module is enabled.
259
+     *		The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
260
+     *		It also creates data directories
261
+     *
262 262
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
263
-	 *      @return     int             	1 if OK, 0 if KO
264
-	 */
265
-	public function init($options = '')
266
-	{
267
-		$sql = array();
268
-
269
-		//$this->_load_tables('/multicurrency/sql/');
270
-		$res = $this->_init($sql, $options);
271
-
272
-		if ($res)
273
-		{
274
-			$this->createFirstCurrency();
275
-		}
276
-
277
-		return $res;
278
-	}
279
-
280
-	/**
281
-	 * Function called when module is disabled.
282
-	 * Remove from database constants, boxes and permissions from Dolibarr database.
283
-	 * Data directories are not deleted
284
-	 *
285
-	 * @param      string	$options    Options when enabling module ('', 'noboxes')
286
-	 * @return     int             	1 if OK, 0 if KO
287
-	 */
288
-	public function remove($options = '')
289
-	{
290
-		$sql = array();
291
-
292
-		return $this->_remove($sql, $options);
293
-	}
294
-
295
-	/**
296
-	 * Function called when module is enabled
297
-	 * Create the currency from general setting
298
-	 *
299
-	 * @return 	int		1 if OK, 0 if KO
300
-	 */
301
-	private function createFirstCurrency()
302
-	{
303
-		global $conf, $user, $langs;
304
-
305
-		if (!MultiCurrency::checkCodeAlreadyExists($conf->currency))
306
-		{
307
-			$langs->loadCacheCurrencies('');
308
-
309
-			$multicurrency = new MultiCurrency($this->db);
310
-			$multicurrency->code = $conf->currency;
311
-			$multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')';
312
-			$r = $multicurrency->create($user);
313
-
314
-			if ($r > 0)	$multicurrency->addRate(1);
315
-		}
316
-	}
263
+     *      @return     int             	1 if OK, 0 if KO
264
+     */
265
+    public function init($options = '')
266
+    {
267
+        $sql = array();
268
+
269
+        //$this->_load_tables('/multicurrency/sql/');
270
+        $res = $this->_init($sql, $options);
271
+
272
+        if ($res)
273
+        {
274
+            $this->createFirstCurrency();
275
+        }
276
+
277
+        return $res;
278
+    }
279
+
280
+    /**
281
+     * Function called when module is disabled.
282
+     * Remove from database constants, boxes and permissions from Dolibarr database.
283
+     * Data directories are not deleted
284
+     *
285
+     * @param      string	$options    Options when enabling module ('', 'noboxes')
286
+     * @return     int             	1 if OK, 0 if KO
287
+     */
288
+    public function remove($options = '')
289
+    {
290
+        $sql = array();
291
+
292
+        return $this->_remove($sql, $options);
293
+    }
294
+
295
+    /**
296
+     * Function called when module is enabled
297
+     * Create the currency from general setting
298
+     *
299
+     * @return 	int		1 if OK, 0 if KO
300
+     */
301
+    private function createFirstCurrency()
302
+    {
303
+        global $conf, $user, $langs;
304
+
305
+        if (!MultiCurrency::checkCodeAlreadyExists($conf->currency))
306
+        {
307
+            $langs->loadCacheCurrencies('');
308
+
309
+            $multicurrency = new MultiCurrency($this->db);
310
+            $multicurrency->code = $conf->currency;
311
+            $multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')';
312
+            $r = $multicurrency->create($user);
313
+
314
+            if ($r > 0)	$multicurrency->addRate(1);
315
+        }
316
+    }
317 317
 }
318 318
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -311,7 +311,9 @@
 block discarded – undo
311 311
 			$multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')';
312 312
 			$r = $multicurrency->create($user);
313 313
 
314
-			if ($r > 0)	$multicurrency->addRate(1);
314
+			if ($r > 0) {
315
+			    $multicurrency->addRate(1);
316
+			}
315 317
 		}
316 318
 	}
317 319
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modIncoterm.class.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -33,60 +33,60 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class modIncoterm extends DolibarrModules
35 35
 {
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43 43
         global $langs,$conf;
44 44
 
45 45
         $this->db = $db;
46 46
 
47
-		// Id for module (must be unique).
48
-		// Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
49
-		$this->numero = 62000;
50
-		// Key text used to identify module (for permissions, menus, etc...)
51
-		$this->rights_class = 'incoterm';
47
+        // Id for module (must be unique).
48
+        // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
49
+        $this->numero = 62000;
50
+        // Key text used to identify module (for permissions, menus, etc...)
51
+        $this->rights_class = 'incoterm';
52 52
 
53
-		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
54
-		$this->family = "srm";
55
-		$this->name = preg_replace('/^mod/i','',get_class($this));
56
-		$this->description = "Incoterm management";
57
-		$this->version = 'dolibarr';
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
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
-		$this->picto='generic';
53
+        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
54
+        $this->family = "srm";
55
+        $this->name = preg_replace('/^mod/i','',get_class($this));
56
+        $this->description = "Incoterm management";
57
+        $this->version = 'dolibarr';
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
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
60
+        $this->picto='generic';
61 61
 
62
-		$this->module_parts = array();
63
-		$this->dirs = array();
62
+        $this->module_parts = array();
63
+        $this->dirs = array();
64 64
 
65
-		$this->config_page_url = array();
65
+        $this->config_page_url = array();
66 66
 
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
74
-		$this->langfiles = array("incoterm");
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
74
+        $this->langfiles = array("incoterm");
75 75
 
76
-		$this->const = array(
77
-			array('INCOTERM_ACTIVATE', 'chaine', 0, 'Description de INCOTERM_ACTIVATE')
78
-		);
76
+        $this->const = array(
77
+            array('INCOTERM_ACTIVATE', 'chaine', 0, 'Description de INCOTERM_ACTIVATE')
78
+        );
79 79
 
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(
89
-			'langs'=>'incoterm',
88
+        $this->dictionaries=array(
89
+            'langs'=>'incoterm',
90 90
             'tabname'=>array(MAIN_DB_PREFIX."c_incoterms"),		// List of tables we want to see into dictonnary editor
91 91
             'tablib'=>array("Incoterms"),													// Label of tables
92 92
             'tabsql'=>array('SELECT rowid, code, libelle, active FROM '.MAIN_DB_PREFIX.'c_incoterms'),	// Request to select fields
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
             'tabfieldinsert'=>array("code,libelle"),													// List of fields (list of fields for insert)
97 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 101
         $this->boxes = array();			// List of boxes
102
-		$r=0;
102
+        $r=0;
103 103
 
104
-		// Permissions
105
-		$this->rights = array();		// Permission array used by this module
106
-		$r=0;
104
+        // Permissions
105
+        $this->rights = array();		// Permission array used by this module
106
+        $r=0;
107 107
 
108
-		// Main menu entries
109
-		$this->menus = array();			// List of menus to add
110
-		$r=0;
111
-	}
108
+        // Main menu entries
109
+        $this->menus = array();			// List of menus to add
110
+        $r=0;
111
+    }
112 112
 }
Please login to merge, or discard this 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 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 {
33 33
 
34 34
     /**
35
-	 *   Constructor. Define names, constants, directories, boxes, permissions
36
-	 *
37
-	 *   @param      DoliDB		$db      Database handler
35
+     *   Constructor. Define names, constants, directories, boxes, permissions
36
+     *
37
+     *   @param      DoliDB		$db      Database handler
38 38
      */
39 39
     function __construct($db)
40 40
     {
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
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 46
         $this->name = preg_replace('/^mod/i','',get_class($this));
47 47
         $this->description = "Enable the usage of math expressions for prices";
48
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
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);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         // Config pages
59 59
         //-------------
60
-		$this->config_page_url = array("dynamic_prices.php@product");
60
+        $this->config_page_url = array("dynamic_prices.php@product");
61 61
 
62 62
         // Dependancies
63 63
         //-------------
Please login to merge, or discard this 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 3 patches
Indentation   +1422 added lines, -1422 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public $db;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model name
52 52
      */
53 53
     public $name;
54 54
 
55
-	/**
55
+    /**
56 56
      * @var string model description (short text)
57 57
      */
58 58
     public $description;
@@ -62,89 +62,89 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public $update_main_doc_field;
64 64
 
65
-	/**
65
+    /**
66 66
      * @var string document type
67 67
      */
68 68
     public $type;
69 69
 
70
-	/**
70
+    /**
71 71
      * @var array Minimum version of PHP required by module.
72
-	 * e.g.: PHP ≥ 5.3 = array(5, 3)
72
+     * e.g.: PHP ≥ 5.3 = array(5, 3)
73 73
      */
74
-	public $phpmin = array(5, 2);
74
+    public $phpmin = array(5, 2);
75 75
 
76
-	/**
76
+    /**
77 77
      * Dolibarr version of the loaded document
78 78
      * @public string
79 79
      */
80
-	public $version = 'development';
80
+    public $version = 'development';
81 81
 
82 82
     public $page_largeur;
83 83
     public $page_hauteur;
84 84
     public $format;
85
-	public $marge_gauche;
86
-	public $marge_droite;
87
-	public $marge_haute;
88
-	public $marge_basse;
85
+    public $marge_gauche;
86
+    public $marge_droite;
87
+    public $marge_haute;
88
+    public $marge_basse;
89 89
 
90 90
     public $emetteur;	// Objet societe qui emet
91 91
 
92 92
 
93
-	/**
94
-	 *	Constructor
95
-	 *
96
-	 *  @param		DoliDB		$db      Database handler
97
-	 */
98
-	public function __construct($db)
99
-	{
100
-		global $conf,$langs,$mysoc;
101
-
102
-		// Translations
103
-		$langs->loadLangs(array("main", "bills", "products"));
104
-
105
-		$this->db = $db;
106
-		$this->name = "eratosthene";
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
109
-
110
-		// Dimension page
111
-		$this->type = 'pdf';
112
-		$formatarray=pdf_getFormat();
113
-		$this->page_largeur = $formatarray['width'];
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;
133
-
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
137
-
138
-		// Define position of columns
139
-		$this->posxdesc=$this->marge_gauche+1;
140
-
141
-
142
-		$this->tva=array();
143
-		$this->localtax1=array();
144
-		$this->localtax2=array();
145
-		$this->atleastoneratenotnull=0;
146
-		$this->atleastonediscount=0;
147
-	}
93
+    /**
94
+     *	Constructor
95
+     *
96
+     *  @param		DoliDB		$db      Database handler
97
+     */
98
+    public function __construct($db)
99
+    {
100
+        global $conf,$langs,$mysoc;
101
+
102
+        // Translations
103
+        $langs->loadLangs(array("main", "bills", "products"));
104
+
105
+        $this->db = $db;
106
+        $this->name = "eratosthene";
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
109
+
110
+        // Dimension page
111
+        $this->type = 'pdf';
112
+        $formatarray=pdf_getFormat();
113
+        $this->page_largeur = $formatarray['width'];
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;
133
+
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
137
+
138
+        // Define position of columns
139
+        $this->posxdesc=$this->marge_gauche+1;
140
+
141
+
142
+        $this->tva=array();
143
+        $this->localtax1=array();
144
+        $this->localtax2=array();
145
+        $this->atleastoneratenotnull=0;
146
+        $this->atleastonediscount=0;
147
+    }
148 148
 
149 149
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
150 150
     /**
@@ -157,70 +157,70 @@  discard block
 block discarded – undo
157 157
      *  @param		int			$hidedesc			Do not show desc
158 158
      *  @param		int			$hideref			Do not show ref
159 159
      *  @return     int             			    1=OK, 0=KO
160
-	 */
161
-	public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
162
-	{
163
-	    // phpcs:enable
164
-		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
160
+     */
161
+    public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
162
+    {
163
+        // phpcs:enable
164
+        global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
165 165
 
166
-		if (! is_object($outputlangs)) $outputlangs=$langs;
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';
166
+        if (! is_object($outputlangs)) $outputlangs=$langs;
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';
169 169
 
170
-		// Translations
171
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
170
+        // Translations
171
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
172 172
 
173
-		$nblignes = count($object->lines);
173
+        $nblignes = count($object->lines);
174 174
 
175
-		if ($conf->commande->dir_output)
176
-		{
175
+        if ($conf->commande->dir_output)
176
+        {
177 177
             $object->fetch_thirdparty();
178 178
 
179 179
             $deja_regle = 0;
180 180
 
181 181
             // Definition of $dir and $file
182
-			if ($object->specimen)
183
-			{
184
-				$dir = $conf->commande->dir_output;
185
-				$file = $dir . "/SPECIMEN.pdf";
186
-			}
187
-			else
188
-			{
189
-				$objectref = dol_sanitizeFileName($object->ref);
190
-				$dir = $conf->commande->dir_output . "/" . $objectref;
191
-				$file = $dir . "/" . $objectref . ".pdf";
192
-			}
193
-
194
-			if (! file_exists($dir))
195
-			{
196
-				if (dol_mkdir($dir) < 0)
197
-				{
198
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
199
-					return 0;
200
-				}
201
-			}
182
+            if ($object->specimen)
183
+            {
184
+                $dir = $conf->commande->dir_output;
185
+                $file = $dir . "/SPECIMEN.pdf";
186
+            }
187
+            else
188
+            {
189
+                $objectref = dol_sanitizeFileName($object->ref);
190
+                $dir = $conf->commande->dir_output . "/" . $objectref;
191
+                $file = $dir . "/" . $objectref . ".pdf";
192
+            }
193
+
194
+            if (! file_exists($dir))
195
+            {
196
+                if (dol_mkdir($dir) < 0)
197
+                {
198
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
199
+                    return 0;
200
+                }
201
+            }
202 202
 
203
-			if (file_exists($dir))
204
-			{
205
-				// Add pdfgeneration hook
206
-				if (! is_object($hookmanager))
207
-				{
208
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209
-					$hookmanager=new HookManager($this->db);
210
-				}
211
-				$hookmanager->initHooks(array('pdfgeneration'));
212
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
213
-				global $action;
214
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
203
+            if (file_exists($dir))
204
+            {
205
+                // Add pdfgeneration hook
206
+                if (! is_object($hookmanager))
207
+                {
208
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
209
+                    $hookmanager=new HookManager($this->db);
210
+                }
211
+                $hookmanager->initHooks(array('pdfgeneration'));
212
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
213
+                global $action;
214
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
215 215
 
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);
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);
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
                 {
@@ -235,540 +235,540 @@  discard block
 block discarded – undo
235 235
                     $tplidx = $pdf->importPage(1);
236 236
                 }
237 237
 
238
-				$pdf->Open();
239
-				$pagenb=0;
240
-				$pdf->SetDrawColor(128,128,128);
241
-
242
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
243
-				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
244
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
245
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
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);
248
-
249
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
250
-
251
-				/// Does we have at least one line with discount $this->atleastonediscount
252
-				foreach ($object->lines as $line) {
253
-				    if ($line->remise_percent){
254
-				        $this->atleastonediscount = true;
255
-				        break;
256
-				    }
257
-				}
238
+                $pdf->Open();
239
+                $pagenb=0;
240
+                $pdf->SetDrawColor(128,128,128);
241
+
242
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
243
+                $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
244
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
245
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
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);
248
+
249
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
250
+
251
+                /// Does we have at least one line with discount $this->atleastonediscount
252
+                foreach ($object->lines as $line) {
253
+                    if ($line->remise_percent){
254
+                        $this->atleastonediscount = true;
255
+                        break;
256
+                    }
257
+                }
258 258
 
259
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
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);
266
-					//$this->postotalht;
267
-				}
259
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
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);
266
+                    //$this->postotalht;
267
+                }
268 268
 
269
-				// New page
270
-				$pdf->AddPage();
271
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
272
-				$pagenb++;
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);
269
+                // New page
270
+                $pdf->AddPage();
271
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
272
+                $pagenb++;
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);
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
-				// Incoterm
283
-				if ($conf->incoterm->enabled)
284
-				{
285
-					$desc_incoterms = $object->getIncotermsForPDF();
286
-					if ($desc_incoterms)
287
-					{
288
-						$tab_top -= 2;
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);
292
-						$nexY = $pdf->GetY();
293
-						$height_incoterms=$nexY-$tab_top;
294
-
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);
298
-
299
-						$tab_top = $nexY+6;
300
-					}
301
-				}
282
+                // Incoterm
283
+                if ($conf->incoterm->enabled)
284
+                {
285
+                    $desc_incoterms = $object->getIncotermsForPDF();
286
+                    if ($desc_incoterms)
287
+                    {
288
+                        $tab_top -= 2;
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);
292
+                        $nexY = $pdf->GetY();
293
+                        $height_incoterms=$nexY-$tab_top;
294
+
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);
298
+
299
+                        $tab_top = $nexY+6;
300
+                    }
301
+                }
302 302
 
303
-				// Affiche notes
304
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
305
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
306
-				{
307
-					// Get first sale rep
308
-					if (is_object($object->thirdparty))
309
-					{
310
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
311
-						$salerepobj=new User($this->db);
312
-						$salerepobj->fetch($salereparray[0]['id']);
313
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
314
-					}
315
-				}
303
+                // Affiche notes
304
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
305
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
306
+                {
307
+                    // Get first sale rep
308
+                    if (is_object($object->thirdparty))
309
+                    {
310
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
311
+                        $salerepobj=new User($this->db);
312
+                        $salerepobj->fetch($salereparray[0]['id']);
313
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
314
+                    }
315
+                }
316 316
 
317
-				$pagenb = $pdf->getPage();
318
-				if ($notetoshow)
319
-				{
320
-				    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
321
-				    $pageposbeforenote = $pagenb;
322
-
323
-				    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
324
-				    complete_substitutions_array($substitutionarray, $outputlangs, $object);
325
-				    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
326
-
327
-					$tab_top -= 2;
328
-
329
-				    $pdf->startTransaction();
330
-
331
-				    $pdf->SetFont('','', $default_font_size - 1);
332
-				    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
333
-				    // Description
334
-				    $pageposafternote=$pdf->getPage();
335
-				    $posyafter = $pdf->GetY();
336
-
337
-				    if($pageposafternote>$pageposbeforenote )
338
-				    {
339
-				        $pdf->rollbackTransaction(true);
340
-
341
-				        // prepar pages to receive notes
342
-				        while ($pagenb < $pageposafternote) {
343
-				            $pdf->AddPage();
344
-				            $pagenb++;
345
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
346
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
347
-				            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348
-				            $pdf->setTopMargin($tab_top_newpage);
349
-				            // The only function to edit the bottom margin of current page to set it.
350
-				            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
351
-				        }
352
-
353
-				        // back to start
354
-				        $pdf->setPage($pageposbeforenote);
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();
359
-
360
-				        $posyafter = $pdf->GetY();
361
-
362
-				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
363
-				        {
364
-				            $pdf->AddPage('','',true);
365
-				            $pagenb++;
366
-				            $pageposafternote++;
367
-				            $pdf->setPage($pageposafternote);
368
-				            $pdf->setTopMargin($tab_top_newpage);
369
-				            // The only function to edit the bottom margin of current page to set it.
370
-				            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
371
-				            //$posyafter = $tab_top_newpage;
372
-				        }
373
-
374
-
375
-				        // apply note frame to previus pages
376
-				        $i = $pageposbeforenote;
377
-				        while ($i < $pageposafternote) {
378
-				            $pdf->setPage($i);
379
-
380
-
381
-				            $pdf->SetDrawColor(128,128,128);
382
-				            // Draw note frame
383
-				            if($i>$pageposbeforenote){
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);
386
-				            }
387
-				            else{
388
-				                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389
-				                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
390
-				            }
391
-
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);
395
-
396
-				            $i++;
397
-				        }
398
-
399
-				        // apply note frame to last page
400
-				        $pdf->setPage($pageposafternote);
401
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
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);
405
-				    }
406
-				    else // No pagebreak
407
-				    {
408
-				        $pdf->commitTransaction();
409
-				        $posyafter = $pdf->GetY();
410
-				        $height_note=$posyafter-$tab_top;
411
-				        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
412
-
413
-
414
-				        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
415
-				        {
416
-				            // not enough space, need to add page
417
-				            $pdf->AddPage('','',true);
418
-				            $pagenb++;
419
-				            $pageposafternote++;
420
-				            $pdf->setPage($pageposafternote);
421
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423
-
424
-				            $posyafter = $tab_top_newpage;
425
-				        }
426
-				    }
427
-
428
-				    $tab_height = $tab_height - $height_note;
429
-				    $tab_top = $posyafter +6;
430
-				}
431
-				else
432
-				{
433
-					$height_note=0;
434
-				}
317
+                $pagenb = $pdf->getPage();
318
+                if ($notetoshow)
319
+                {
320
+                    $tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
321
+                    $pageposbeforenote = $pagenb;
322
+
323
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
324
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
325
+                    $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
326
+
327
+                    $tab_top -= 2;
328
+
329
+                    $pdf->startTransaction();
330
+
331
+                    $pdf->SetFont('','', $default_font_size - 1);
332
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
333
+                    // Description
334
+                    $pageposafternote=$pdf->getPage();
335
+                    $posyafter = $pdf->GetY();
336
+
337
+                    if($pageposafternote>$pageposbeforenote )
338
+                    {
339
+                        $pdf->rollbackTransaction(true);
340
+
341
+                        // prepar pages to receive notes
342
+                        while ($pagenb < $pageposafternote) {
343
+                            $pdf->AddPage();
344
+                            $pagenb++;
345
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
346
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
347
+                            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348
+                            $pdf->setTopMargin($tab_top_newpage);
349
+                            // The only function to edit the bottom margin of current page to set it.
350
+                            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
351
+                        }
352
+
353
+                        // back to start
354
+                        $pdf->setPage($pageposbeforenote);
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();
359
+
360
+                        $posyafter = $pdf->GetY();
361
+
362
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
363
+                        {
364
+                            $pdf->AddPage('','',true);
365
+                            $pagenb++;
366
+                            $pageposafternote++;
367
+                            $pdf->setPage($pageposafternote);
368
+                            $pdf->setTopMargin($tab_top_newpage);
369
+                            // The only function to edit the bottom margin of current page to set it.
370
+                            $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
371
+                            //$posyafter = $tab_top_newpage;
372
+                        }
373
+
374
+
375
+                        // apply note frame to previus pages
376
+                        $i = $pageposbeforenote;
377
+                        while ($i < $pageposafternote) {
378
+                            $pdf->setPage($i);
379
+
380
+
381
+                            $pdf->SetDrawColor(128,128,128);
382
+                            // Draw note frame
383
+                            if($i>$pageposbeforenote){
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);
386
+                            }
387
+                            else{
388
+                                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389
+                                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
390
+                            }
391
+
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);
395
+
396
+                            $i++;
397
+                        }
398
+
399
+                        // apply note frame to last page
400
+                        $pdf->setPage($pageposafternote);
401
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
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);
405
+                    }
406
+                    else // No pagebreak
407
+                    {
408
+                        $pdf->commitTransaction();
409
+                        $posyafter = $pdf->GetY();
410
+                        $height_note=$posyafter-$tab_top;
411
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
412
+
413
+
414
+                        if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
415
+                        {
416
+                            // not enough space, need to add page
417
+                            $pdf->AddPage('','',true);
418
+                            $pagenb++;
419
+                            $pageposafternote++;
420
+                            $pdf->setPage($pageposafternote);
421
+                            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
+                            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
423
+
424
+                            $posyafter = $tab_top_newpage;
425
+                        }
426
+                    }
427
+
428
+                    $tab_height = $tab_height - $height_note;
429
+                    $tab_top = $posyafter +6;
430
+                }
431
+                else
432
+                {
433
+                    $height_note=0;
434
+                }
435 435
 
436
-				$iniY = $tab_top + 7;
437
-				$curY = $tab_top + 7;
438
-				$nexY = $tab_top + 7;
436
+                $iniY = $tab_top + 7;
437
+                $curY = $tab_top + 7;
438
+                $nexY = $tab_top + 7;
439 439
 
440
-				// Use new auto collum system
441
-				$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
440
+                // Use new auto collum system
441
+                $this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
442 442
 
443
-				// Loop on each lines
444
-				$pageposbeforeprintlines=$pdf->getPage();
445
-				$pagenb = $pageposbeforeprintlines;
446
-				for ($i = 0 ; $i < $nblignes ; $i++)
447
-				{
448
-					$curY = $nexY;
449
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
450
-					$pdf->SetTextColor(0,0,0);
451
-
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();
455
-
456
-					// Description of product line
457
-					$curX = $this->posxdesc-1;
458
-
459
-					$showpricebeforepagebreak=1;
460
-
461
-					if($this->getColumnStatus('desc'))
462
-					{
463
-    					$pdf->startTransaction();
464
-    					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465
-    					$pageposafter=$pdf->getPage();
466
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
467
-    					{
468
-    						$pdf->rollbackTransaction(true);
469
-    						$pageposafter=$pageposbefore;
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
476
-    						{
477
-    							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
478
-    							{
479
-    								$pdf->AddPage('','',true);
480
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
481
-    								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482
-    								$pdf->setPage($pageposafter+1);
483
-    							}
484
-    						}
485
-    						else
486
-    						{
487
-    							// We found a page break
488
-    							$showpricebeforepagebreak=0;
489
-    						}
490
-    					}
491
-    					else	// No pagebreak
492
-    					{
493
-    						$pdf->commitTransaction();
494
-    					}
495
-    					$posYAfterDescription=$pdf->GetY();
496
-					}
497
-
498
-					$nexY = $pdf->GetY();
499
-					$pageposafter=$pdf->getPage();
500
-
501
-					$pdf->setPage($pageposbefore);
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.
504
-
505
-					// We suppose that a too long description is moved completely on next page
506
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
507
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
508
-					}
509
-
510
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
511
-
512
-					// VAT Rate
513
-					if ($this->getColumnStatus('vat'))
514
-					{
515
-					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
516
-					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
517
-					    $nexY = max($pdf->GetY(),$nexY);
518
-					}
519
-
520
-					// Unit price before discount
521
-					if ($this->getColumnStatus('subprice'))
522
-					{
523
-					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
524
-					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
525
-					    $nexY = max($pdf->GetY(),$nexY);
526
-					}
527
-
528
-					// Quantity
529
-					// Enough for 6 chars
530
-					if ($this->getColumnStatus('qty'))
531
-					{
532
-					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
533
-					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
534
-					    $nexY = max($pdf->GetY(),$nexY);
535
-					}
536
-
537
-
538
-					// Unit
539
-					if ($this->getColumnStatus('unit'))
540
-					{
541
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
542
-					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
543
-					    $nexY = max($pdf->GetY(),$nexY);
544
-					}
545
-
546
-					// Discount on line
547
-					if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
548
-					{
549
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
550
-					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
551
-					    $nexY = max($pdf->GetY(),$nexY);
552
-					}
553
-
554
-					// Total HT line
555
-					if ($this->getColumnStatus('totalexcltax'))
556
-					{
557
-					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
558
-					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
559
-					    $nexY = max($pdf->GetY(),$nexY);
560
-					}
561
-
562
-
563
-					$parameters=array(
564
-					    'object' => $object,
565
-					    'i' => $i,
566
-					    'pdf' =>& $pdf,
567
-					    'curY' =>& $curY,
568
-					    'nexY' =>& $nexY,
569
-					    'outputlangs' => $outputlangs,
570
-					    'hidedetails' => $hidedetails
571
-					);
572
-					$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
573
-
574
-
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;
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;
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;
589
-
590
-					$vatrate=(string) $object->lines[$i]->tva_tx;
591
-
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
595
-					{
596
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
597
-						$localtax1_type = $localtaxtmp_array[0];
598
-						$localtax2_type = $localtaxtmp_array[2];
599
-					}
600
-
601
-				    // retrieve global local tax
602
-					if ($localtax1_type && $localtax1ligne != 0)
603
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
604
-					if ($localtax2_type && $localtax2ligne != 0)
605
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
606
-
607
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
609
-					$this->tva[$vatrate] += $tvaligne;
610
-
611
-					// Add line
612
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
613
-					{
614
-						$pdf->setPage($pageposafter);
615
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
616
-						//$pdf->SetDrawColor(190,190,200);
617
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
618
-						$pdf->SetLineStyle(array('dash'=>0));
619
-					}
620
-
621
-					$nexY+=2;    // Passe espace entre les lignes
622
-
623
-					// Detect if some page were added automatically and output _tableau for past pages
624
-					while ($pagenb < $pageposafter)
625
-					{
626
-						$pdf->setPage($pagenb);
627
-						if ($pagenb == $pageposbeforeprintlines)
628
-						{
629
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
630
-						}
631
-						else
632
-						{
633
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634
-						}
635
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
636
-						$pagenb++;
637
-						$pdf->setPage($pagenb);
638
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
639
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
640
-					}
641
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
642
-					{
643
-					    if ($pagenb == $pageposafter)
644
-						{
645
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
646
-						}
647
-						else
648
-						{
649
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650
-						}
651
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
652
-						// New page
653
-						$pdf->AddPage();
654
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
655
-						$pagenb++;
656
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
657
-					}
658
-				}
443
+                // Loop on each lines
444
+                $pageposbeforeprintlines=$pdf->getPage();
445
+                $pagenb = $pageposbeforeprintlines;
446
+                for ($i = 0 ; $i < $nblignes ; $i++)
447
+                {
448
+                    $curY = $nexY;
449
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
450
+                    $pdf->SetTextColor(0,0,0);
451
+
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();
455
+
456
+                    // Description of product line
457
+                    $curX = $this->posxdesc-1;
458
+
459
+                    $showpricebeforepagebreak=1;
460
+
461
+                    if($this->getColumnStatus('desc'))
462
+                    {
463
+                        $pdf->startTransaction();
464
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465
+                        $pageposafter=$pdf->getPage();
466
+                        if ($pageposafter > $pageposbefore)	// There is a pagebreak
467
+                        {
468
+                            $pdf->rollbackTransaction(true);
469
+                            $pageposafter=$pageposbefore;
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
476
+                            {
477
+                                if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
478
+                                {
479
+                                    $pdf->AddPage('','',true);
480
+                                    if (! empty($tplidx)) $pdf->useTemplate($tplidx);
481
+                                    //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482
+                                    $pdf->setPage($pageposafter+1);
483
+                                }
484
+                            }
485
+                            else
486
+                            {
487
+                                // We found a page break
488
+                                $showpricebeforepagebreak=0;
489
+                            }
490
+                        }
491
+                        else	// No pagebreak
492
+                        {
493
+                            $pdf->commitTransaction();
494
+                        }
495
+                        $posYAfterDescription=$pdf->GetY();
496
+                    }
497
+
498
+                    $nexY = $pdf->GetY();
499
+                    $pageposafter=$pdf->getPage();
500
+
501
+                    $pdf->setPage($pageposbefore);
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.
504
+
505
+                    // We suppose that a too long description is moved completely on next page
506
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
507
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
508
+                    }
509
+
510
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
511
+
512
+                    // VAT Rate
513
+                    if ($this->getColumnStatus('vat'))
514
+                    {
515
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
516
+                        $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
517
+                        $nexY = max($pdf->GetY(),$nexY);
518
+                    }
519
+
520
+                    // Unit price before discount
521
+                    if ($this->getColumnStatus('subprice'))
522
+                    {
523
+                        $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
524
+                        $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
525
+                        $nexY = max($pdf->GetY(),$nexY);
526
+                    }
527
+
528
+                    // Quantity
529
+                    // Enough for 6 chars
530
+                    if ($this->getColumnStatus('qty'))
531
+                    {
532
+                        $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
533
+                        $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
534
+                        $nexY = max($pdf->GetY(),$nexY);
535
+                    }
536
+
537
+
538
+                    // Unit
539
+                    if ($this->getColumnStatus('unit'))
540
+                    {
541
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
542
+                        $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
543
+                        $nexY = max($pdf->GetY(),$nexY);
544
+                    }
545
+
546
+                    // Discount on line
547
+                    if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
548
+                    {
549
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
550
+                        $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
551
+                        $nexY = max($pdf->GetY(),$nexY);
552
+                    }
553
+
554
+                    // Total HT line
555
+                    if ($this->getColumnStatus('totalexcltax'))
556
+                    {
557
+                        $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
558
+                        $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
559
+                        $nexY = max($pdf->GetY(),$nexY);
560
+                    }
561
+
562
+
563
+                    $parameters=array(
564
+                        'object' => $object,
565
+                        'i' => $i,
566
+                        'pdf' =>& $pdf,
567
+                        'curY' =>& $curY,
568
+                        'nexY' =>& $nexY,
569
+                        'outputlangs' => $outputlangs,
570
+                        'hidedetails' => $hidedetails
571
+                    );
572
+                    $reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this);    // Note that $object may have been modified by hook
573
+
574
+
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;
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;
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;
589
+
590
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
591
+
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
595
+                    {
596
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
597
+                        $localtax1_type = $localtaxtmp_array[0];
598
+                        $localtax2_type = $localtaxtmp_array[2];
599
+                    }
600
+
601
+                    // retrieve global local tax
602
+                    if ($localtax1_type && $localtax1ligne != 0)
603
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
604
+                    if ($localtax2_type && $localtax2ligne != 0)
605
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
606
+
607
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
+                    if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
609
+                    $this->tva[$vatrate] += $tvaligne;
610
+
611
+                    // Add line
612
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
613
+                    {
614
+                        $pdf->setPage($pageposafter);
615
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
616
+                        //$pdf->SetDrawColor(190,190,200);
617
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
618
+                        $pdf->SetLineStyle(array('dash'=>0));
619
+                    }
620
+
621
+                    $nexY+=2;    // Passe espace entre les lignes
622
+
623
+                    // Detect if some page were added automatically and output _tableau for past pages
624
+                    while ($pagenb < $pageposafter)
625
+                    {
626
+                        $pdf->setPage($pagenb);
627
+                        if ($pagenb == $pageposbeforeprintlines)
628
+                        {
629
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
630
+                        }
631
+                        else
632
+                        {
633
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634
+                        }
635
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
636
+                        $pagenb++;
637
+                        $pdf->setPage($pagenb);
638
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
639
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
640
+                    }
641
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
642
+                    {
643
+                        if ($pagenb == $pageposafter)
644
+                        {
645
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
646
+                        }
647
+                        else
648
+                        {
649
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650
+                        }
651
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
652
+                        // New page
653
+                        $pdf->AddPage();
654
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
655
+                        $pagenb++;
656
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
657
+                    }
658
+                }
659 659
 
660
-				// Show square
661
-				if ($pagenb == $pageposbeforeprintlines)
662
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663
-				else
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;
660
+                // Show square
661
+                if ($pagenb == $pageposbeforeprintlines)
662
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663
+                else
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;
666 666
 
667
-				// Affiche zone infos
668
-				$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
667
+                // Affiche zone infos
668
+                $posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
669 669
 
670
-				// Affiche zone totaux
671
-				$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
670
+                // Affiche zone totaux
671
+                $posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
672 672
 
673
-				// Affiche zone versements
674
-				/*
673
+                // Affiche zone versements
674
+                /*
675 675
 				if ($deja_regle)
676 676
 				{
677 677
 					$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
678 678
 				}
679 679
 				*/
680 680
 
681
-				// Pied de page
682
-				$this->_pagefoot($pdf, $object, $outputlangs);
683
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
681
+                // Pied de page
682
+                $this->_pagefoot($pdf, $object, $outputlangs);
683
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
684 684
 
685
-				$pdf->Close();
685
+                $pdf->Close();
686 686
 
687
-				$pdf->Output($file, 'F');
687
+                $pdf->Output($file, 'F');
688 688
 
689
-				// Add pdfgeneration hook
690
-				$hookmanager->initHooks(array('pdfgeneration'));
691
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
692
-				global $action;
693
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
689
+                // Add pdfgeneration hook
690
+                $hookmanager->initHooks(array('pdfgeneration'));
691
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
692
+                global $action;
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))
696
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
695
+                if (! empty($conf->global->MAIN_UMASK))
696
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
697 697
 
698
-				$this->result = array('fullpath'=>$file);
698
+                $this->result = array('fullpath'=>$file);
699 699
 
700
-				return 1;   // Pas d'erreur
701
-			}
702
-			else
703
-			{
704
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
705
-				return 0;
706
-			}
707
-		}
708
-		else
709
-		{
710
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
711
-			return 0;
712
-		}
713
-	}
714
-
715
-	/**
716
-	 *  Show payments table
717
-   *
718
-	 *  @param	TCPDF		$pdf     		Object PDF
719
-	 *  @param  Object		$object			Object order
720
-	 *	@param	int			$posy			Position y in PDF
721
-	 *	@param	Translate	$outputlangs	Object langs for output
722
-	 *	@return int							<0 if KO, >0 if OK
723
-	 */
724
-	private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
725
-	{
726
-	}
727
-
728
-	/**
729
-	 *   Show miscellaneous information (payment mode, payment term, ...)
730
-	 *
731
-	 *   @param		TCPDF		$pdf     		Object PDF
732
-	 *   @param		Object		$object			Object to show
733
-	 *   @param		int			$posy			Y
734
-	 *   @param		Translate	$outputlangs	Langs object
735
-	 *   @return	void
736
-	 */
737
-	private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
738
-	{
739
-		global $conf;
740
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
741
-
742
-		$pdf->SetFont('','', $default_font_size - 1);
700
+                return 1;   // Pas d'erreur
701
+            }
702
+            else
703
+            {
704
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
705
+                return 0;
706
+            }
707
+        }
708
+        else
709
+        {
710
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
711
+            return 0;
712
+        }
713
+    }
714
+
715
+    /**
716
+     *  Show payments table
717
+     *
718
+     *  @param	TCPDF		$pdf     		Object PDF
719
+     *  @param  Object		$object			Object order
720
+     *	@param	int			$posy			Position y in PDF
721
+     *	@param	Translate	$outputlangs	Object langs for output
722
+     *	@return int							<0 if KO, >0 if OK
723
+     */
724
+    private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
725
+    {
726
+    }
727
+
728
+    /**
729
+     *   Show miscellaneous information (payment mode, payment term, ...)
730
+     *
731
+     *   @param		TCPDF		$pdf     		Object PDF
732
+     *   @param		Object		$object			Object to show
733
+     *   @param		int			$posy			Y
734
+     *   @param		Translate	$outputlangs	Langs object
735
+     *   @return	void
736
+     */
737
+    private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
738
+    {
739
+        global $conf;
740
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
741
+
742
+        $pdf->SetFont('','', $default_font_size - 1);
743 743
 
744 744
         // If France, show VAT mention if not applicable
745
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
746
-		{
747
-			$pdf->SetFont('','B', $default_font_size - 2);
748
-			$pdf->SetXY($this->marge_gauche, $posy);
749
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
745
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
746
+        {
747
+            $pdf->SetFont('','B', $default_font_size - 2);
748
+            $pdf->SetXY($this->marge_gauche, $posy);
749
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
750 750
 
751
-			$posy=$pdf->GetY()+4;
752
-		}
751
+            $posy=$pdf->GetY()+4;
752
+        }
753 753
 
754
-		$posxval=52;
754
+        $posxval=52;
755 755
 
756
-		// Show payments conditions
757
-		if ($object->cond_reglement_code || $object->cond_reglement)
758
-		{
759
-			$pdf->SetFont('','B', $default_font_size - 2);
760
-			$pdf->SetXY($this->marge_gauche, $posy);
761
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
762
-			$pdf->MultiCell(43, 4, $titre, 0, 'L');
756
+        // Show payments conditions
757
+        if ($object->cond_reglement_code || $object->cond_reglement)
758
+        {
759
+            $pdf->SetFont('','B', $default_font_size - 2);
760
+            $pdf->SetXY($this->marge_gauche, $posy);
761
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
762
+            $pdf->MultiCell(43, 4, $titre, 0, 'L');
763 763
 
764
-			$pdf->SetFont('','', $default_font_size - 2);
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');
764
+            $pdf->SetFont('','', $default_font_size - 2);
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');
769 769
 
770
-			$posy=$pdf->GetY()+3;
771
-		}
770
+            $posy=$pdf->GetY()+3;
771
+        }
772 772
 
773 773
         // Check a payment mode is defined
774 774
         /* Not used with orders
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
             $posy=$pdf->GetY()+1;
786 786
         }
787 787
 		*/
788
-		/* TODO
788
+        /* TODO
789 789
 		else if (! empty($object->availability_code))
790 790
 		{
791 791
             $pdf->SetXY($this->marge_gauche, $posy);
@@ -797,707 +797,707 @@  discard block
 block discarded – undo
797 797
             $posy=$pdf->GetY()+1;
798 798
 		}*/
799 799
 
800
-	    // Show planed date of delivery
800
+        // Show planed date of delivery
801 801
         if (! empty($object->date_livraison))
802
-		{
802
+        {
803 803
             $outputlangs->load("sendings");
804
-			$pdf->SetFont('','B', $default_font_size - 2);
805
-			$pdf->SetXY($this->marge_gauche, $posy);
806
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
807
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
808
-			$pdf->SetFont('','', $default_font_size - 2);
809
-			$pdf->SetXY($posxval, $posy);
810
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
811
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
804
+            $pdf->SetFont('','B', $default_font_size - 2);
805
+            $pdf->SetXY($this->marge_gauche, $posy);
806
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
807
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
808
+            $pdf->SetFont('','', $default_font_size - 2);
809
+            $pdf->SetXY($posxval, $posy);
810
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
811
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
812 812
 
813 813
             $posy=$pdf->GetY()+1;
814
-		}
814
+        }
815 815
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
816
-		{
817
-			$pdf->SetFont('','B', $default_font_size - 2);
818
-			$pdf->SetXY($this->marge_gauche, $posy);
819
-			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
821
-			$pdf->SetTextColor(0,0,0);
822
-			$pdf->SetFont('','', $default_font_size - 2);
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);
826
-			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
827
-
828
-			$posy=$pdf->GetY()+1;
829
-		}
830
-
831
-      	// Show payment mode
816
+        {
817
+            $pdf->SetFont('','B', $default_font_size - 2);
818
+            $pdf->SetXY($this->marge_gauche, $posy);
819
+            $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
821
+            $pdf->SetTextColor(0,0,0);
822
+            $pdf->SetFont('','', $default_font_size - 2);
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);
826
+            $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
827
+
828
+            $posy=$pdf->GetY()+1;
829
+        }
830
+
831
+            // Show payment mode
832 832
         if ($object->mode_reglement_code
833
-        	 && $object->mode_reglement_code != 'CHQ'
834
-           	 && $object->mode_reglement_code != 'VIR')
835
-           	 {
836
-	            $pdf->SetFont('','B', $default_font_size - 2);
837
-	            $pdf->SetXY($this->marge_gauche, $posy);
838
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
839
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
840
-
841
-				$pdf->SetFont('','', $default_font_size - 2);
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');
845
-
846
-	            $posy=$pdf->GetY()+2;
847
-           	 }
848
-
849
-		// Show payment mode CHQ
833
+             && $object->mode_reglement_code != 'CHQ'
834
+                && $object->mode_reglement_code != 'VIR')
835
+                {
836
+                $pdf->SetFont('','B', $default_font_size - 2);
837
+                $pdf->SetXY($this->marge_gauche, $posy);
838
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
839
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
840
+
841
+                $pdf->SetFont('','', $default_font_size - 2);
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');
845
+
846
+                $posy=$pdf->GetY()+2;
847
+                }
848
+
849
+        // Show payment mode CHQ
850 850
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
851 851
         {
852
-        	// Si mode reglement non force ou si force a CHQ
853
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
854
-	        {
855
-	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
856
-	            {
857
-	                $account = new Account($this->db);
858
-	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
859
-
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;
864
-
865
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
866
-		            {
867
-		                $pdf->SetXY($this->marge_gauche, $posy);
868
-		                $pdf->SetFont('','', $default_font_size - 3);
869
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
870
-			            $posy=$pdf->GetY()+2;
871
-		            }
872
-	            }
873
-	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
874
-	            {
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;
879
-
880
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
881
-		            {
882
-			            $pdf->SetXY($this->marge_gauche, $posy);
883
-		                $pdf->SetFont('','', $default_font_size - 3);
884
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
885
-			            $posy=$pdf->GetY()+2;
886
-		            }
887
-	            }
888
-	        }
889
-		}
852
+            // Si mode reglement non force ou si force a CHQ
853
+            if (! empty($conf->global->FACTURE_CHQ_NUMBER))
854
+            {
855
+                if ($conf->global->FACTURE_CHQ_NUMBER > 0)
856
+                {
857
+                    $account = new Account($this->db);
858
+                    $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
859
+
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;
864
+
865
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
866
+                    {
867
+                        $pdf->SetXY($this->marge_gauche, $posy);
868
+                        $pdf->SetFont('','', $default_font_size - 3);
869
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
870
+                        $posy=$pdf->GetY()+2;
871
+                    }
872
+                }
873
+                if ($conf->global->FACTURE_CHQ_NUMBER == -1)
874
+                {
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;
879
+
880
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
881
+                    {
882
+                        $pdf->SetXY($this->marge_gauche, $posy);
883
+                        $pdf->SetFont('','', $default_font_size - 3);
884
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
885
+                        $posy=$pdf->GetY()+2;
886
+                    }
887
+                }
888
+            }
889
+        }
890 890
 
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))
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
898
-				$account = new Account($this->db);
899
-				$account->fetch($bankid);
894
+            if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
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
898
+                $account = new Account($this->db);
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;
907
-			}
906
+                $posy+=2;
907
+            }
908 908
         }
909 909
 
910
-		return $posy;
911
-	}
910
+        return $posy;
911
+    }
912 912
 
913 913
 
914
-	/**
915
-	 *	Show total to pay
916
-	 *
917
-	 *	@param	TCPDF		$pdf           Object PDF
918
-	 *	@param  Facture		$object         Object invoice
919
-	 *	@param  int			$deja_regle     Montant deja regle
920
-	 *	@param	int			$posy			Position depart
921
-	 *	@param	Translate	$outputlangs	Objet langs
922
-	 *	@return int							Position pour suite
923
-	 */
924
-	private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
925
-	{
926
-	    global $conf,$mysoc;
914
+    /**
915
+     *	Show total to pay
916
+     *
917
+     *	@param	TCPDF		$pdf           Object PDF
918
+     *	@param  Facture		$object         Object invoice
919
+     *	@param  int			$deja_regle     Montant deja regle
920
+     *	@param	int			$posy			Position depart
921
+     *	@param	Translate	$outputlangs	Objet langs
922
+     *	@return int							Position pour suite
923
+     */
924
+    private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
925
+    {
926
+        global $conf,$mysoc;
927 927
 
928
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
928
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
929 929
 
930
-		$tab2_top = $posy;
931
-		$tab2_hl = 4;
932
-		$pdf->SetFont('','', $default_font_size - 1);
930
+        $tab2_top = $posy;
931
+        $tab2_hl = 4;
932
+        $pdf->SetFont('','', $default_font_size - 1);
933 933
 
934
-		// Tableau total
934
+        // Tableau total
935 935
         $col1x = 120; $col2x = 170;
936
-		if ($this->page_largeur < 210) // To work with US executive format
937
-		{
938
-			$col2x-=20;
939
-		}
940
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
936
+        if ($this->page_largeur < 210) // To work with US executive format
937
+        {
938
+            $col2x-=20;
939
+        }
940
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941 941
 
942
-		$useborder=0;
943
-		$index = 0;
942
+        $useborder=0;
943
+        $index = 0;
944 944
 
945
-		// Total HT
946
-		$pdf->SetFillColor(255,255,255);
947
-		$pdf->SetXY($col1x, $tab2_top + 0);
948
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
945
+        // Total HT
946
+        $pdf->SetFillColor(255,255,255);
947
+        $pdf->SetXY($col1x, $tab2_top + 0);
948
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
949 949
 
950
-		$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
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);
950
+        $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
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);
953 953
 
954
-		// Show VAT by rates and total
955
-		$pdf->SetFillColor(248,248,248);
954
+        // Show VAT by rates and total
955
+        $pdf->SetFillColor(248,248,248);
956 956
 
957
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
957
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
958 958
 
959
-		$this->atleastoneratenotnull=0;
960
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
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)
964
-			{
965
-				// Nothing to do
966
-			}
967
-			else
968
-			{
969
-				//Local tax 1 before VAT
970
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971
-				//{
972
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
973
-					{
974
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
975
-						foreach( $localtax_rate as $tvakey => $tvaval )
976
-						{
977
-							if ($tvakey!=0)    // On affiche pas taux 0
978
-							{
979
-								//$this->atleastoneratenotnull++;
980
-
981
-								$index++;
982
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983
-
984
-								$tvacompl='';
985
-								if (preg_match('/\*/',$tvakey))
986
-								{
987
-									$tvakey=str_replace('*','',$tvakey);
988
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
993
-
994
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
996
-							}
997
-						}
998
-					}
999
-	      		//}
1000
-				//Local tax 2 before VAT
1001
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1002
-				//{
1003
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1004
-					{
1005
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1006
-						foreach( $localtax_rate as $tvakey => $tvaval )
1007
-						{
1008
-							if ($tvakey!=0)    // On affiche pas taux 0
1009
-							{
1010
-								//$this->atleastoneratenotnull++;
1011
-
1012
-
1013
-
1014
-								$index++;
1015
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016
-
1017
-								$tvacompl='';
1018
-								if (preg_match('/\*/',$tvakey))
1019
-								{
1020
-									$tvakey=str_replace('*','',$tvakey);
1021
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
1026
-
1027
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1029
-							}
1030
-						}
1031
-					}
1032
-				//}
1033
-				// VAT
1034
-				foreach($this->tva as $tvakey => $tvaval)
1035
-				{
1036
-					if ($tvakey != 0)    // On affiche pas taux 0
1037
-					{
1038
-						$this->atleastoneratenotnull++;
1039
-
1040
-						$index++;
1041
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042
-
1043
-						$tvacompl='';
1044
-						if (preg_match('/\*/',$tvakey))
1045
-						{
1046
-							$tvakey=str_replace('*','',$tvakey);
1047
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
1052
-
1053
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1055
-					}
1056
-				}
959
+        $this->atleastoneratenotnull=0;
960
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
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)
964
+            {
965
+                // Nothing to do
966
+            }
967
+            else
968
+            {
969
+                //Local tax 1 before VAT
970
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971
+                //{
972
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
973
+                    {
974
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
975
+                        foreach( $localtax_rate as $tvakey => $tvaval )
976
+                        {
977
+                            if ($tvakey!=0)    // On affiche pas taux 0
978
+                            {
979
+                                //$this->atleastoneratenotnull++;
980
+
981
+                                $index++;
982
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983
+
984
+                                $tvacompl='';
985
+                                if (preg_match('/\*/',$tvakey))
986
+                                {
987
+                                    $tvakey=str_replace('*','',$tvakey);
988
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
993
+
994
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
996
+                            }
997
+                        }
998
+                    }
999
+                    //}
1000
+                //Local tax 2 before VAT
1001
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1002
+                //{
1003
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1004
+                    {
1005
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1006
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1007
+                        {
1008
+                            if ($tvakey!=0)    // On affiche pas taux 0
1009
+                            {
1010
+                                //$this->atleastoneratenotnull++;
1011
+
1012
+
1013
+
1014
+                                $index++;
1015
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016
+
1017
+                                $tvacompl='';
1018
+                                if (preg_match('/\*/',$tvakey))
1019
+                                {
1020
+                                    $tvakey=str_replace('*','',$tvakey);
1021
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
1026
+
1027
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1028
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1029
+                            }
1030
+                        }
1031
+                    }
1032
+                //}
1033
+                // VAT
1034
+                foreach($this->tva as $tvakey => $tvaval)
1035
+                {
1036
+                    if ($tvakey != 0)    // On affiche pas taux 0
1037
+                    {
1038
+                        $this->atleastoneratenotnull++;
1039
+
1040
+                        $index++;
1041
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1042
+
1043
+                        $tvacompl='';
1044
+                        if (preg_match('/\*/',$tvakey))
1045
+                        {
1046
+                            $tvakey=str_replace('*','',$tvakey);
1047
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
1052
+
1053
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1055
+                    }
1056
+                }
1057 1057
 
1058
-				//Local tax 1 after VAT
1059
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1060
-				//{
1061
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062
-					{
1063
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1064
-
1065
-						foreach( $localtax_rate as $tvakey => $tvaval )
1066
-						{
1067
-							if ($tvakey != 0)    // On affiche pas taux 0
1068
-							{
1069
-								//$this->atleastoneratenotnull++;
1070
-
1071
-								$index++;
1072
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073
-
1074
-								$tvacompl='';
1075
-								if (preg_match('/\*/',$tvakey))
1076
-								{
1077
-									$tvakey=str_replace('*','',$tvakey);
1078
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1079
-								}
1080
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1081
-
1082
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1083
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1084
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1086
-							}
1087
-						}
1088
-					}
1089
-	      		//}
1090
-				//Local tax 2 after VAT
1091
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1092
-				//{
1093
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1094
-					{
1095
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1096
-
1097
-						foreach( $localtax_rate as $tvakey => $tvaval )
1098
-						{
1099
-							if ($tvakey != 0)    // On affiche pas taux 0
1100
-							{
1101
-								//$this->atleastoneratenotnull++;
1102
-
1103
-								$index++;
1104
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105
-
1106
-								$tvacompl='';
1107
-								if (preg_match('/\*/',$tvakey))
1108
-								{
1109
-									$tvakey=str_replace('*','',$tvakey);
1110
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111
-								}
1112
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1113
-
1114
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1115
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116
-
1117
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1118
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1119
-							}
1120
-						}
1121
-					}
1122
-				//}
1123
-
1124
-				// Total TTC
1125
-				$index++;
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);
1130
-
1131
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132
-				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1133
-			}
1134
-		}
1135
-
1136
-		$pdf->SetTextColor(0,0,0);
1058
+                //Local tax 1 after VAT
1059
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1060
+                //{
1061
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062
+                    {
1063
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1064
+
1065
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1066
+                        {
1067
+                            if ($tvakey != 0)    // On affiche pas taux 0
1068
+                            {
1069
+                                //$this->atleastoneratenotnull++;
1070
+
1071
+                                $index++;
1072
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073
+
1074
+                                $tvacompl='';
1075
+                                if (preg_match('/\*/',$tvakey))
1076
+                                {
1077
+                                    $tvakey=str_replace('*','',$tvakey);
1078
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1079
+                                }
1080
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1081
+
1082
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1083
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1084
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1085
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1086
+                            }
1087
+                        }
1088
+                    }
1089
+                    //}
1090
+                //Local tax 2 after VAT
1091
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1092
+                //{
1093
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1094
+                    {
1095
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1096
+
1097
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1098
+                        {
1099
+                            if ($tvakey != 0)    // On affiche pas taux 0
1100
+                            {
1101
+                                //$this->atleastoneratenotnull++;
1102
+
1103
+                                $index++;
1104
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105
+
1106
+                                $tvacompl='';
1107
+                                if (preg_match('/\*/',$tvakey))
1108
+                                {
1109
+                                    $tvakey=str_replace('*','',$tvakey);
1110
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1111
+                                }
1112
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1113
+
1114
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1115
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1116
+
1117
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1118
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1119
+                            }
1120
+                        }
1121
+                    }
1122
+                //}
1123
+
1124
+                // Total TTC
1125
+                $index++;
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);
1130
+
1131
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132
+                $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1133
+            }
1134
+        }
1135
+
1136
+        $pdf->SetTextColor(0,0,0);
1137 1137
 
1138 1138
         $creditnoteamount=0;
1139 1139
         $depositsamount=0;
1140
-		//$creditnoteamount=$object->getSumCreditNotesUsed();
1141
-		//$depositsamount=$object->getSumDepositsUsed();
1142
-		//print "x".$creditnoteamount."-".$depositsamount;exit;
1143
-		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
-		if (! empty($object->paye)) $resteapayer=0;
1140
+        //$creditnoteamount=$object->getSumCreditNotesUsed();
1141
+        //$depositsamount=$object->getSumDepositsUsed();
1142
+        //print "x".$creditnoteamount."-".$depositsamount;exit;
1143
+        $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
+        if (! empty($object->paye)) $resteapayer=0;
1145 1145
 
1146
-		if ($deja_regle > 0)
1147
-		{
1148
-			// Already paid + Deposits
1149
-			$index++;
1150
-
1151
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1153
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1154
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1155
-
1156
-			$index++;
1157
-			$pdf->SetTextColor(0,0,60);
1158
-			$pdf->SetFillColor(224,224,224);
1159
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1161
-
1162
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1164
-
1165
-			$pdf->SetFont('','', $default_font_size - 1);
1166
-			$pdf->SetTextColor(0,0,0);
1167
-		}
1168
-
1169
-		$index++;
1170
-		return ($tab2_top + ($tab2_hl * $index));
1171
-	}
1172
-
1173
-	/**
1174
-	 *   Show table for lines
1175
-	 *
1176
-	 *   @param		TCPDF		$pdf     		Object PDF
1177
-	 *   @param		string		$tab_top		Top position of table
1178
-	 *   @param		string		$tab_height		Height of table (rectangle)
1179
-	 *   @param		int			$nexY			Y (not used)
1180
-	 *   @param		Translate	$outputlangs	Langs object
1181
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1182
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1183
-	 *   @param		string		$currency		Currency code
1184
-	 *   @return	void
1185
-	 */
1186
-	private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1187
-	{
1188
-		global $conf;
1189
-
1190
-		// Force to disable hidetop and hidebottom
1191
-		$hidebottom=0;
1192
-		if ($hidetop) $hidetop=-1;
1193
-
1194
-		$currency = !empty($currency) ? $currency : $conf->currency;
1195
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1196
-
1197
-		// Amount in (at tab_top - 1)
1198
-		$pdf->SetTextColor(0,0,0);
1199
-		$pdf->SetFont('','', $default_font_size - 2);
1200
-
1201
-		if (empty($hidetop))
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);
1205
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1146
+        if ($deja_regle > 0)
1147
+        {
1148
+            // Already paid + Deposits
1149
+            $index++;
1206 1150
 
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));
1209
-		}
1151
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1152
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1153
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1154
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1210 1155
 
1211
-		$pdf->SetDrawColor(128,128,128);
1212
-		$pdf->SetFont('','', $default_font_size - 1);
1156
+            $index++;
1157
+            $pdf->SetTextColor(0,0,60);
1158
+            $pdf->SetFillColor(224,224,224);
1159
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1213 1161
 
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
1162
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1216 1164
 
1165
+            $pdf->SetFont('','', $default_font_size - 1);
1166
+            $pdf->SetTextColor(0,0,0);
1167
+        }
1217 1168
 
1218
-		foreach ($this->cols as $colKey => $colDef)
1219
-		{
1220
-		    if(!$this->getColumnStatus($colKey)) continue;
1221
-
1222
-		    // get title label
1223
-		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1224
-
1225
-		    // Add column separator
1226
-		    if(!empty($colDef['border-left'])){
1227
-		        $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1228
-		    }
1229
-
1230
-		    if (empty($hidetop))
1231
-		    {
1232
-		      $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1233
-
1234
-		      $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1235
-		      $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1236
-		    }
1237
-		}
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
1241
-		}
1242
-	}
1243
-
1244
-	/**
1245
-	 *  Show top header of page.
1246
-	 *
1247
-	 *  @param	TCPDF		$pdf     		Object PDF
1248
-	 *  @param  Object		$object     	Object to show
1249
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1250
-	 *  @param  Translate	$outputlangs	Object lang for output
1251
-	 *  @param	string		$titlekey		Translation key to show as title of document
1252
-	 *  @return	void
1253
-	 */
1254
-	private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1255
-	{
1256
-		global $conf,$langs,$hookmanager;
1257
-
1258
-		// Translations
1259
-		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1260
-
1261
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1262
-
1263
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1264
-
1265
-		// Show Draft Watermark
1266
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1267
-		{
1169
+        $index++;
1170
+        return ($tab2_top + ($tab2_hl * $index));
1171
+    }
1172
+
1173
+    /**
1174
+     *   Show table for lines
1175
+     *
1176
+     *   @param		TCPDF		$pdf     		Object PDF
1177
+     *   @param		string		$tab_top		Top position of table
1178
+     *   @param		string		$tab_height		Height of table (rectangle)
1179
+     *   @param		int			$nexY			Y (not used)
1180
+     *   @param		Translate	$outputlangs	Langs object
1181
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1182
+     *   @param		int			$hidebottom		Hide bottom bar of array
1183
+     *   @param		string		$currency		Currency code
1184
+     *   @return	void
1185
+     */
1186
+    private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1187
+    {
1188
+        global $conf;
1189
+
1190
+        // Force to disable hidetop and hidebottom
1191
+        $hidebottom=0;
1192
+        if ($hidetop) $hidetop=-1;
1193
+
1194
+        $currency = !empty($currency) ? $currency : $conf->currency;
1195
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1196
+
1197
+        // Amount in (at tab_top - 1)
1198
+        $pdf->SetTextColor(0,0,0);
1199
+        $pdf->SetFont('','', $default_font_size - 2);
1200
+
1201
+        if (empty($hidetop))
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);
1205
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1206
+
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));
1209
+        }
1210
+
1211
+        $pdf->SetDrawColor(128,128,128);
1212
+        $pdf->SetFont('','', $default_font_size - 1);
1213
+
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
1216
+
1217
+
1218
+        foreach ($this->cols as $colKey => $colDef)
1219
+        {
1220
+            if(!$this->getColumnStatus($colKey)) continue;
1221
+
1222
+            // get title label
1223
+            $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
1224
+
1225
+            // Add column separator
1226
+            if(!empty($colDef['border-left'])){
1227
+                $pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
1228
+            }
1229
+
1230
+            if (empty($hidetop))
1231
+            {
1232
+                $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
1233
+
1234
+                $textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
1235
+                $pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
1236
+            }
1237
+        }
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
1241
+        }
1242
+    }
1243
+
1244
+    /**
1245
+     *  Show top header of page.
1246
+     *
1247
+     *  @param	TCPDF		$pdf     		Object PDF
1248
+     *  @param  Object		$object     	Object to show
1249
+     *  @param  int	    	$showaddress    0=no, 1=yes
1250
+     *  @param  Translate	$outputlangs	Object lang for output
1251
+     *  @param	string		$titlekey		Translation key to show as title of document
1252
+     *  @return	void
1253
+     */
1254
+    private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1255
+    {
1256
+        global $conf,$langs,$hookmanager;
1257
+
1258
+        // Translations
1259
+        $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1260
+
1261
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1262
+
1263
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1264
+
1265
+        // Show Draft Watermark
1266
+        if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1267
+        {
1268 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
-		// Logo
1280
-		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1281
-		{
1282
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1283
-			if ($this->emetteur->logo)
1284
-			{
1285
-				if (is_readable($logo))
1286
-				{
1287
-				    $height=pdf_getHeightForLogo($logo);
1288
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1289
-				}
1290
-				else
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');
1295
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296
-				}
1297
-			}
1298
-			else
1299
-			{
1300
-				$text=$this->emetteur->name;
1301
-				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1302
-			}
1303
-		}
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);
1309
-		$pdf->MultiCell(100, 3, $title, '', 'R');
1310
-
1311
-		$pdf->SetFont('','B',$default_font_size);
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');
1317
-
1318
-		$posy+=1;
1319
-		$pdf->SetFont('','', $default_font_size - 1);
1320
-
1321
-		if ($object->ref_client)
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');
1327
-		}
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');
1333
-
1334
-		// Get contact
1335
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1336
-		{
1337
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1338
-		    if (count($arrayidcontact) > 0)
1339
-		    {
1279
+        // Logo
1280
+        if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1281
+        {
1282
+            $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1283
+            if ($this->emetteur->logo)
1284
+            {
1285
+                if (is_readable($logo))
1286
+                {
1287
+                    $height=pdf_getHeightForLogo($logo);
1288
+                    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1289
+                }
1290
+                else
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');
1295
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296
+                }
1297
+            }
1298
+            else
1299
+            {
1300
+                $text=$this->emetteur->name;
1301
+                $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1302
+            }
1303
+        }
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);
1309
+        $pdf->MultiCell(100, 3, $title, '', 'R');
1310
+
1311
+        $pdf->SetFont('','B',$default_font_size);
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');
1317
+
1318
+        $posy+=1;
1319
+        $pdf->SetFont('','', $default_font_size - 1);
1320
+
1321
+        if ($object->ref_client)
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');
1327
+        }
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');
1333
+
1334
+        // Get contact
1335
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1336
+        {
1337
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1338
+            if (count($arrayidcontact) > 0)
1339
+            {
1340 1340
                 $usertmp=new User($this->db);
1341
-		        $usertmp->fetch($arrayidcontact[0]);
1341
+                $usertmp->fetch($arrayidcontact[0]);
1342 1342
                 $posy+=4;
1343 1343
                 $pdf->SetXY($posx,$posy);
1344
-		        $pdf->SetTextColor(0,0,60);
1345
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1346
-		    }
1347
-		}
1348
-
1349
-		$posy+=2;
1350
-
1351
-		$top_shift = 0;
1352
-		// Show list of linked objects
1353
-		$current_y = $pdf->getY();
1354
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1355
-		if ($current_y < $pdf->getY())
1356
-		{
1357
-			$top_shift = $pdf->getY() - $current_y;
1358
-		}
1344
+                $pdf->SetTextColor(0,0,60);
1345
+                $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1346
+            }
1347
+        }
1359 1348
 
1360
-		if ($showaddress)
1361
-		{
1362
-			// Sender properties
1363
-			$carac_emetteur='';
1364
-		 	// Add internal contact of proposal if defined
1365
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1366
-		 	if (count($arrayidcontact) > 0)
1367
-		 	{
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";
1371
-		 	}
1372
-
1373
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1374
-
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;
1380
-
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);
1388
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1389
-			$pdf->SetTextColor(0,0,60);
1390
-
1391
-			// Show sender name
1392
-			$pdf->SetXY($posx+2,$posy+3);
1393
-			$pdf->SetFont('','B', $default_font_size);
1394
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1395
-			$posy=$pdf->getY();
1396
-
1397
-			// Show sender information
1398
-			$pdf->SetXY($posx+2,$posy);
1399
-			$pdf->SetFont('','', $default_font_size - 1);
1400
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1401
-
1402
-
1403
-
1404
-			// If CUSTOMER contact defined on order, we use it
1405
-			$usecontact=false;
1406
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1407
-			if (count($arrayidcontact) > 0)
1408
-			{
1409
-				$usecontact=true;
1410
-				$result=$object->fetch_contact($arrayidcontact[0]);
1411
-			}
1412
-
1413
-			//Recipient name
1414
-			// On peut utiliser le nom de la societe du contact
1415
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1416
-				$thirdparty = $object->contact;
1417
-			} else {
1418
-				$thirdparty = $object->thirdparty;
1419
-			}
1420
-
1421
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1422
-
1423
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1424
-
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;
1431
-
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');
1437
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1438
-
1439
-			// Show recipient name
1440
-			$pdf->SetXY($posx+2,$posy+3);
1441
-			$pdf->SetFont('','B', $default_font_size);
1442
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1443
-
1444
-			$posy = $pdf->getY();
1445
-
1446
-			// Show recipient information
1447
-			$pdf->SetFont('','', $default_font_size - 1);
1448
-			$pdf->SetXY($posx+2,$posy);
1449
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1450
-		}
1451
-
1452
-		$pdf->SetTextColor(0,0,0);
1453
-		return $top_shift;
1454
-	}
1455
-
1456
-	/**
1457
-	 *   	Show footer of page. Need this->emetteur object
1349
+        $posy+=2;
1350
+
1351
+        $top_shift = 0;
1352
+        // Show list of linked objects
1353
+        $current_y = $pdf->getY();
1354
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1355
+        if ($current_y < $pdf->getY())
1356
+        {
1357
+            $top_shift = $pdf->getY() - $current_y;
1358
+        }
1359
+
1360
+        if ($showaddress)
1361
+        {
1362
+            // Sender properties
1363
+            $carac_emetteur='';
1364
+                // Add internal contact of proposal if defined
1365
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1366
+                if (count($arrayidcontact) > 0)
1367
+                {
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";
1371
+                }
1372
+
1373
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1374
+
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;
1380
+
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);
1388
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1389
+            $pdf->SetTextColor(0,0,60);
1390
+
1391
+            // Show sender name
1392
+            $pdf->SetXY($posx+2,$posy+3);
1393
+            $pdf->SetFont('','B', $default_font_size);
1394
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1395
+            $posy=$pdf->getY();
1396
+
1397
+            // Show sender information
1398
+            $pdf->SetXY($posx+2,$posy);
1399
+            $pdf->SetFont('','', $default_font_size - 1);
1400
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1401
+
1402
+
1403
+
1404
+            // If CUSTOMER contact defined on order, we use it
1405
+            $usecontact=false;
1406
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1407
+            if (count($arrayidcontact) > 0)
1408
+            {
1409
+                $usecontact=true;
1410
+                $result=$object->fetch_contact($arrayidcontact[0]);
1411
+            }
1412
+
1413
+            //Recipient name
1414
+            // On peut utiliser le nom de la societe du contact
1415
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1416
+                $thirdparty = $object->contact;
1417
+            } else {
1418
+                $thirdparty = $object->thirdparty;
1419
+            }
1420
+
1421
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1422
+
1423
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1424
+
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;
1431
+
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');
1437
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1438
+
1439
+            // Show recipient name
1440
+            $pdf->SetXY($posx+2,$posy+3);
1441
+            $pdf->SetFont('','B', $default_font_size);
1442
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1443
+
1444
+            $posy = $pdf->getY();
1445
+
1446
+            // Show recipient information
1447
+            $pdf->SetFont('','', $default_font_size - 1);
1448
+            $pdf->SetXY($posx+2,$posy);
1449
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1450
+        }
1451
+
1452
+        $pdf->SetTextColor(0,0,0);
1453
+        return $top_shift;
1454
+    }
1455
+
1456
+    /**
1457
+     *   	Show footer of page. Need this->emetteur object
1458
+     *
1459
+     *   	@param	TCPDF		$pdf     			PDF
1460
+     * 		@param	Object		$object				Object to show
1461
+     *      @param	Translate	$outputlangs		Object lang for output
1462
+     *      @param	int			$hidefreetext		1=Hide free text
1463
+     *      @return	int								Return height of bottom margin including footer text
1464
+     */
1465
+    private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1466
+    {
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);
1470
+    }
1471
+
1472
+
1473
+
1474
+    /**
1475
+     *   	Define Array Column Field
1458 1476
      *
1459
-	 *   	@param	TCPDF		$pdf     			PDF
1460
-	 * 		@param	Object		$object				Object to show
1461
-	 *      @param	Translate	$outputlangs		Object lang for output
1462
-	 *      @param	int			$hidefreetext		1=Hide free text
1463
-	 *      @return	int								Return height of bottom margin including footer text
1464
-	 */
1465
-	private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1466
-	{
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);
1470
-	}
1471
-
1472
-
1473
-
1474
-	/**
1475
-	 *   	Define Array Column Field
1476
-	 *
1477
-	 *   	@param	object			$object    		common object
1478
-	 *   	@param	Translate		$outputlangs    langs
1479
-	 *      @param	int				$hidedetails	Do not show line details
1480
-	 *      @param	int				$hidedesc		Do not show desc
1481
-	 *      @param	int				$hideref		Do not show ref
1482
-	 *      @return	null
1483
-	 */
1477
+     *   	@param	object			$object    		common object
1478
+     *   	@param	Translate		$outputlangs    langs
1479
+     *      @param	int				$hidedetails	Do not show line details
1480
+     *      @param	int				$hidedesc		Do not show desc
1481
+     *      @param	int				$hideref		Do not show ref
1482
+     *      @return	null
1483
+     */
1484 1484
     public function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
1485 1485
     {
1486
-	    global $conf, $hookmanager;
1486
+        global $conf, $hookmanager;
1487 1487
 
1488
-	    // Default field style for content
1489
-	    $this->defaultContentsFieldsStyle = array(
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
1492
-	    );
1488
+        // Default field style for content
1489
+        $this->defaultContentsFieldsStyle = array(
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
1492
+        );
1493 1493
 
1494
-	    // Default field style for content
1495
-	    $this->defaultTitlesFieldsStyle = array(
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
1498
-	    );
1494
+        // Default field style for content
1495
+        $this->defaultTitlesFieldsStyle = array(
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
1498
+        );
1499 1499
 
1500
-	    /*
1500
+        /*
1501 1501
 	     * For exemple
1502 1502
 	     $this->cols['theColKey'] = array(
1503 1503
 	     'rank' => $rank, // int : use for ordering columns
@@ -1515,158 +1515,158 @@  discard block
 block discarded – undo
1515 1515
 	     );
1516 1516
 	     */
1517 1517
 
1518
-	    $rank=0; // do not use negative rank
1519
-	    $this->cols['desc'] = array(
1520
-	        'rank' => $rank,
1521
-	        'width' => false, // only for desc
1522
-	        'status' => true,
1523
-	        'title' => array(
1524
-	            'textkey' => 'Designation', // use lang key is usefull in somme case with module
1525
-	            'align' => 'L',
1526
-	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
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
1529
-	        ),
1530
-	        'content' => array(
1531
-	            'align' => 'L',
1532
-	        ),
1533
-	    );
1534
-
1535
-	    $rank = $rank + 10;
1536
-	    $this->cols['photo'] = array(
1537
-	        'rank' => $rank,
1538
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1539
-	        'status' => false,
1540
-	        'title' => array(
1541
-	            'textkey' => 'Photo',
1542
-	            'label' => ' '
1543
-	        ),
1544
-	        'content' => array(
1545
-	            'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1546
-	        ),
1547
-	        'border-left' => false, // remove left line separator
1548
-	    );
1549
-
1550
-	    if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1551
-	    {
1552
-	        $this->cols['photo']['status'] = true;
1553
-	    }
1554
-
1555
-
1556
-	    $rank = $rank + 10;
1557
-	    $this->cols['vat'] = array(
1558
-	        'rank' => $rank,
1559
-	        'status' => false,
1560
-	        'width' => 16, // in mm
1561
-	        'title' => array(
1562
-	            'textkey' => 'VAT'
1563
-	        ),
1564
-	        'border-left' => true, // add left line separator
1565
-	    );
1566
-
1567
-	    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1568
-	    {
1569
-	        $this->cols['vat']['status'] = true;
1570
-	    }
1571
-
1572
-	    $rank = $rank + 10;
1573
-	    $this->cols['subprice'] = array(
1574
-	        'rank' => $rank,
1575
-	        'width' => 19, // in mm
1576
-	        'status' => true,
1577
-	        'title' => array(
1578
-	            'textkey' => 'PriceUHT'
1579
-	        ),
1580
-	        'border-left' => true, // add left line separator
1581
-	    );
1582
-
1583
-	    $rank = $rank + 10;
1584
-	    $this->cols['qty'] = array(
1585
-	        'rank' => $rank,
1586
-	        'width' => 16, // in mm
1587
-	        'status' => true,
1588
-	        'title' => array(
1589
-	            'textkey' => 'Qty'
1590
-	        ),
1591
-	        'border-left' => true, // add left line separator
1592
-	    );
1593
-
1594
-	    $rank = $rank + 10;
1595
-	    $this->cols['progress'] = array(
1596
-	        'rank' => $rank,
1597
-	        'width' => 19, // in mm
1598
-	        'status' => false,
1599
-	        'title' => array(
1600
-	            'textkey' => 'Progress'
1601
-	        ),
1602
-	        'border-left' => false, // add left line separator
1603
-	    );
1604
-
1605
-	    if($this->situationinvoice)
1606
-	    {
1607
-	        $this->cols['progress']['status'] = true;
1608
-	    }
1609
-
1610
-	    $rank = $rank + 10;
1611
-	    $this->cols['unit'] = array(
1612
-	        'rank' => $rank,
1613
-	        'width' => 11, // in mm
1614
-	        'status' => false,
1615
-	        'title' => array(
1616
-	            'textkey' => 'Unit'
1617
-	        ),
1618
-	        'border-left' => true, // add left line separator
1619
-	    );
1620
-	    if($conf->global->PRODUCT_USE_UNITS){
1621
-	        $this->cols['unit']['status'] = true;
1622
-	    }
1623
-
1624
-	    $rank = $rank + 10;
1625
-	    $this->cols['discount'] = array(
1626
-	        'rank' => $rank,
1627
-	        'width' => 13, // in mm
1628
-	        'status' => false,
1629
-	        'title' => array(
1630
-	            'textkey' => 'ReductionShort'
1631
-	        ),
1632
-	        'border-left' => true, // add left line separator
1633
-	    );
1634
-	    if ($this->atleastonediscount){
1635
-	        $this->cols['discount']['status'] = true;
1636
-	    }
1637
-
1638
-	    $rank = $rank + 10;
1639
-	    $this->cols['totalexcltax'] = array(
1640
-	        'rank' => $rank,
1641
-	        'width' => 26, // in mm
1642
-	        'status' => true,
1643
-	        'title' => array(
1644
-	            'textkey' => 'TotalHT'
1645
-	        ),
1646
-	        'border-left' => true, // add left line separator
1647
-	    );
1648
-
1649
-
1650
-	    $parameters=array(
1651
-	        'object' => $object,
1652
-	        'outputlangs' => $outputlangs,
1653
-	        'hidedetails' => $hidedetails,
1654
-	        'hidedesc' => $hidedesc,
1655
-	        'hideref' => $hideref
1656
-	    );
1657
-
1658
-	    $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1659
-	    if ($reshook < 0)
1660
-	    {
1661
-	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1662
-	    }
1663
-	    elseif (empty($reshook))
1664
-	    {
1665
-	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1666
-	    }
1667
-	    else
1668
-	    {
1669
-	        $this->cols = $hookmanager->resArray;
1670
-	    }
1671
-	}
1518
+        $rank=0; // do not use negative rank
1519
+        $this->cols['desc'] = array(
1520
+            'rank' => $rank,
1521
+            'width' => false, // only for desc
1522
+            'status' => true,
1523
+            'title' => array(
1524
+                'textkey' => 'Designation', // use lang key is usefull in somme case with module
1525
+                'align' => 'L',
1526
+                // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
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
1529
+            ),
1530
+            'content' => array(
1531
+                'align' => 'L',
1532
+            ),
1533
+        );
1534
+
1535
+        $rank = $rank + 10;
1536
+        $this->cols['photo'] = array(
1537
+            'rank' => $rank,
1538
+            'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
1539
+            'status' => false,
1540
+            'title' => array(
1541
+                'textkey' => 'Photo',
1542
+                'label' => ' '
1543
+            ),
1544
+            'content' => array(
1545
+                'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
1546
+            ),
1547
+            'border-left' => false, // remove left line separator
1548
+        );
1549
+
1550
+        if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
1551
+        {
1552
+            $this->cols['photo']['status'] = true;
1553
+        }
1554
+
1555
+
1556
+        $rank = $rank + 10;
1557
+        $this->cols['vat'] = array(
1558
+            'rank' => $rank,
1559
+            'status' => false,
1560
+            'width' => 16, // in mm
1561
+            'title' => array(
1562
+                'textkey' => 'VAT'
1563
+            ),
1564
+            'border-left' => true, // add left line separator
1565
+        );
1566
+
1567
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1568
+        {
1569
+            $this->cols['vat']['status'] = true;
1570
+        }
1571
+
1572
+        $rank = $rank + 10;
1573
+        $this->cols['subprice'] = array(
1574
+            'rank' => $rank,
1575
+            'width' => 19, // in mm
1576
+            'status' => true,
1577
+            'title' => array(
1578
+                'textkey' => 'PriceUHT'
1579
+            ),
1580
+            'border-left' => true, // add left line separator
1581
+        );
1582
+
1583
+        $rank = $rank + 10;
1584
+        $this->cols['qty'] = array(
1585
+            'rank' => $rank,
1586
+            'width' => 16, // in mm
1587
+            'status' => true,
1588
+            'title' => array(
1589
+                'textkey' => 'Qty'
1590
+            ),
1591
+            'border-left' => true, // add left line separator
1592
+        );
1593
+
1594
+        $rank = $rank + 10;
1595
+        $this->cols['progress'] = array(
1596
+            'rank' => $rank,
1597
+            'width' => 19, // in mm
1598
+            'status' => false,
1599
+            'title' => array(
1600
+                'textkey' => 'Progress'
1601
+            ),
1602
+            'border-left' => false, // add left line separator
1603
+        );
1604
+
1605
+        if($this->situationinvoice)
1606
+        {
1607
+            $this->cols['progress']['status'] = true;
1608
+        }
1609
+
1610
+        $rank = $rank + 10;
1611
+        $this->cols['unit'] = array(
1612
+            'rank' => $rank,
1613
+            'width' => 11, // in mm
1614
+            'status' => false,
1615
+            'title' => array(
1616
+                'textkey' => 'Unit'
1617
+            ),
1618
+            'border-left' => true, // add left line separator
1619
+        );
1620
+        if($conf->global->PRODUCT_USE_UNITS){
1621
+            $this->cols['unit']['status'] = true;
1622
+        }
1623
+
1624
+        $rank = $rank + 10;
1625
+        $this->cols['discount'] = array(
1626
+            'rank' => $rank,
1627
+            'width' => 13, // in mm
1628
+            'status' => false,
1629
+            'title' => array(
1630
+                'textkey' => 'ReductionShort'
1631
+            ),
1632
+            'border-left' => true, // add left line separator
1633
+        );
1634
+        if ($this->atleastonediscount){
1635
+            $this->cols['discount']['status'] = true;
1636
+        }
1637
+
1638
+        $rank = $rank + 10;
1639
+        $this->cols['totalexcltax'] = array(
1640
+            'rank' => $rank,
1641
+            'width' => 26, // in mm
1642
+            'status' => true,
1643
+            'title' => array(
1644
+                'textkey' => 'TotalHT'
1645
+            ),
1646
+            'border-left' => true, // add left line separator
1647
+        );
1648
+
1649
+
1650
+        $parameters=array(
1651
+            'object' => $object,
1652
+            'outputlangs' => $outputlangs,
1653
+            'hidedetails' => $hidedetails,
1654
+            'hidedesc' => $hidedesc,
1655
+            'hideref' => $hideref
1656
+        );
1657
+
1658
+        $reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this);    // Note that $object may have been modified by hook
1659
+        if ($reshook < 0)
1660
+        {
1661
+            setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1662
+        }
1663
+        elseif (empty($reshook))
1664
+        {
1665
+            $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1666
+        }
1667
+        else
1668
+        {
1669
+            $this->cols = $hookmanager->resArray;
1670
+        }
1671
+    }
1672 1672
 }
Please login to merge, or discard this 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.
Braces   +172 added lines, -88 removed lines patch added patch discarded remove patch
@@ -133,7 +133,10 @@  discard block
 block discarded – undo
133 133
 
134 134
 		// Get source company
135 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
136
+		if (empty($this->emetteur->country_code)) {
137
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
138
+		}
139
+		// By default, if was not defined
137 140
 
138 141
 		// Define position of columns
139 142
 		$this->posxdesc=$this->marge_gauche+1;
@@ -163,9 +166,13 @@  discard block
 block discarded – undo
163 166
 	    // phpcs:enable
164 167
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
165 168
 
166
-		if (! is_object($outputlangs)) $outputlangs=$langs;
169
+		if (! is_object($outputlangs)) {
170
+		    $outputlangs=$langs;
171
+		}
167 172
 		// 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';
173
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
174
+		    $outputlangs->charset_output='ISO-8859-1';
175
+		}
169 176
 
170 177
 		// Translations
171 178
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -183,8 +190,7 @@  discard block
 block discarded – undo
183 190
 			{
184 191
 				$dir = $conf->commande->dir_output;
185 192
 				$file = $dir . "/SPECIMEN.pdf";
186
-			}
187
-			else
193
+			} else
188 194
 			{
189 195
 				$objectref = dol_sanitizeFileName($object->ref);
190 196
 				$dir = $conf->commande->dir_output . "/" . $objectref;
@@ -244,7 +250,9 @@  discard block
 block discarded – undo
244 250
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
245 251
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
246 252
 				$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);
253
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
254
+				    $pdf->SetCompression(false);
255
+				}
248 256
 
249 257
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
250 258
 
@@ -268,7 +276,9 @@  discard block
 block discarded – undo
268 276
 
269 277
 				// New page
270 278
 				$pdf->AddPage();
271
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
279
+				if (! empty($tplidx)) {
280
+				    $pdf->useTemplate($tplidx);
281
+				}
272 282
 				$pagenb++;
273 283
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
274 284
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -310,7 +320,9 @@  discard block
 block discarded – undo
310 320
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
311 321
 						$salerepobj=new User($this->db);
312 322
 						$salerepobj->fetch($salereparray[0]['id']);
313
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
323
+						if (! empty($salerepobj->signature)) {
324
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
325
+						}
314 326
 					}
315 327
 				}
316 328
 
@@ -342,8 +354,12 @@  discard block
 block discarded – undo
342 354
 				        while ($pagenb < $pageposafternote) {
343 355
 				            $pdf->AddPage();
344 356
 				            $pagenb++;
345
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
346
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
357
+				            if (! empty($tplidx)) {
358
+				                $pdf->useTemplate($tplidx);
359
+				            }
360
+				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
361
+				                $this->_pagehead($pdf, $object, 0, $outputlangs);
362
+				            }
347 363
 				            // $this->_pagefoot($pdf,$object,$outputlangs,1);
348 364
 				            $pdf->setTopMargin($tab_top_newpage);
349 365
 				            // The only function to edit the bottom margin of current page to set it.
@@ -359,9 +375,11 @@  discard block
 block discarded – undo
359 375
 
360 376
 				        $posyafter = $pdf->GetY();
361 377
 
362
-				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)))	// There is no space left for total+free text
378
+				        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) {
379
+				            // There is no space left for total+free text
363 380
 				        {
364 381
 				            $pdf->AddPage('','',true);
382
+				        }
365 383
 				            $pagenb++;
366 384
 				            $pageposafternote++;
367 385
 				            $pdf->setPage($pageposafternote);
@@ -383,8 +401,7 @@  discard block
 block discarded – undo
383 401
 				            if($i>$pageposbeforenote){
384 402
 				                $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
385 403
 				                $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1);
386
-				            }
387
-				            else{
404
+				            } else{
388 405
 				                $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
389 406
 				                $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
390 407
 				            }
@@ -398,12 +415,15 @@  discard block
 block discarded – undo
398 415
 
399 416
 				        // apply note frame to last page
400 417
 				        $pdf->setPage($pageposafternote);
401
-				        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
402
-				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
418
+				        if (! empty($tplidx)) {
419
+				            $pdf->useTemplate($tplidx);
420
+				        }
421
+				        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
422
+				            $this->_pagehead($pdf, $object, 0, $outputlangs);
423
+				        }
403 424
 				        $height_note=$posyafter-$tab_top_newpage;
404 425
 				        $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
405
-				    }
406
-				    else // No pagebreak
426
+				    } else // No pagebreak
407 427
 				    {
408 428
 				        $pdf->commitTransaction();
409 429
 				        $posyafter = $pdf->GetY();
@@ -418,8 +438,12 @@  discard block
 block discarded – undo
418 438
 				            $pagenb++;
419 439
 				            $pageposafternote++;
420 440
 				            $pdf->setPage($pageposafternote);
421
-				            if (! empty($tplidx)) $pdf->useTemplate($tplidx);
422
-				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
441
+				            if (! empty($tplidx)) {
442
+				                $pdf->useTemplate($tplidx);
443
+				            }
444
+				            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
445
+				                $this->_pagehead($pdf, $object, 0, $outputlangs);
446
+				            }
423 447
 
424 448
 				            $posyafter = $tab_top_newpage;
425 449
 				        }
@@ -427,8 +451,7 @@  discard block
 block discarded – undo
427 451
 
428 452
 				    $tab_height = $tab_height - $height_note;
429 453
 				    $tab_top = $posyafter +6;
430
-				}
431
-				else
454
+				} else
432 455
 				{
433 456
 					$height_note=0;
434 457
 				}
@@ -463,32 +486,36 @@  discard block
 block discarded – undo
463 486
     					$pdf->startTransaction();
464 487
     					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
465 488
     					$pageposafter=$pdf->getPage();
466
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
489
+    					if ($pageposafter > $pageposbefore) {
490
+    					    // There is a pagebreak
467 491
     					{
468 492
     						$pdf->rollbackTransaction(true);
493
+    					}
469 494
     						$pageposafter=$pageposbefore;
470 495
     						//print $pageposafter.'-'.$pageposbefore;exit;
471 496
     						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
472 497
     						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
473 498
     						$pageposafter=$pdf->getPage();
474 499
     						$posyafter=$pdf->GetY();
475
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
500
+    						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
501
+    						    // There is no space left for total+free text
476 502
     						{
477 503
     							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
478 504
     							{
479 505
     								$pdf->AddPage('','',true);
480
-    								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
506
+    						}
507
+    								if (! empty($tplidx)) {
508
+    								    $pdf->useTemplate($tplidx);
509
+    								}
481 510
     								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
482 511
     								$pdf->setPage($pageposafter+1);
483 512
     							}
484
-    						}
485
-    						else
513
+    						} else
486 514
     						{
487 515
     							// We found a page break
488 516
     							$showpricebeforepagebreak=0;
489 517
     						}
490
-    					}
491
-    					else	// No pagebreak
518
+    					} else	// No pagebreak
492 519
     					{
493 520
     						$pdf->commitTransaction();
494 521
     					}
@@ -573,8 +600,11 @@  discard block
 block discarded – undo
573 600
 
574 601
 
575 602
 					// 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;
603
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
604
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
605
+					} else {
606
+					    $tvaligne=$object->lines[$i]->total_tva;
607
+					}
578 608
 
579 609
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
580 610
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -583,29 +613,43 @@  discard block
 block discarded – undo
583 613
 					$localtax1_type=$object->lines[$i]->localtax1_type;
584 614
 					$localtax2_type=$object->lines[$i]->localtax2_type;
585 615
 
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;
616
+					if ($object->remise_percent) {
617
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
618
+					}
619
+					if ($object->remise_percent) {
620
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
621
+					}
622
+					if ($object->remise_percent) {
623
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
624
+					}
589 625
 
590 626
 					$vatrate=(string) $object->lines[$i]->tva_tx;
591 627
 
592 628
 					// Retrieve type from database for backward compatibility with old records
593 629
 					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
630
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
631
+					    // and there is local tax
595 632
 					{
596 633
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
634
+					}
597 635
 						$localtax1_type = $localtaxtmp_array[0];
598 636
 						$localtax2_type = $localtaxtmp_array[2];
599 637
 					}
600 638
 
601 639
 				    // retrieve global local tax
602
-					if ($localtax1_type && $localtax1ligne != 0)
603
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
604
-					if ($localtax2_type && $localtax2ligne != 0)
605
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
640
+					if ($localtax1_type && $localtax1ligne != 0) {
641
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
642
+					}
643
+					if ($localtax2_type && $localtax2ligne != 0) {
644
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
645
+					}
606 646
 
607
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
608
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
647
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
648
+					    $vatrate.='*';
649
+					}
650
+					if (! isset($this->tva[$vatrate])) {
651
+					    $this->tva[$vatrate]=0;
652
+					}
609 653
 					$this->tva[$vatrate] += $tvaligne;
610 654
 
611 655
 					// Add line
@@ -627,8 +671,7 @@  discard block
 block discarded – undo
627 671
 						if ($pagenb == $pageposbeforeprintlines)
628 672
 						{
629 673
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
630
-						}
631
-						else
674
+						} else
632 675
 						{
633 676
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634 677
 						}
@@ -636,32 +679,38 @@  discard block
 block discarded – undo
636 679
 						$pagenb++;
637 680
 						$pdf->setPage($pagenb);
638 681
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
639
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
682
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
683
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
684
+						}
640 685
 					}
641 686
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
642 687
 					{
643 688
 					    if ($pagenb == $pageposafter)
644 689
 						{
645 690
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
646
-						}
647
-						else
691
+						} else
648 692
 						{
649 693
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
650 694
 						}
651 695
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
652 696
 						// New page
653 697
 						$pdf->AddPage();
654
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
698
+						if (! empty($tplidx)) {
699
+						    $pdf->useTemplate($tplidx);
700
+						}
655 701
 						$pagenb++;
656
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
702
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
703
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
704
+						}
657 705
 					}
658 706
 				}
659 707
 
660 708
 				// Show square
661
-				if ($pagenb == $pageposbeforeprintlines)
662
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
663
-				else
664
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
709
+				if ($pagenb == $pageposbeforeprintlines) {
710
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
711
+				} else {
712
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
713
+				}
665 714
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 715
 
667 716
 				// Affiche zone infos
@@ -680,7 +729,9 @@  discard block
 block discarded – undo
680 729
 
681 730
 				// Pied de page
682 731
 				$this->_pagefoot($pdf, $object, $outputlangs);
683
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
732
+				if (method_exists($pdf, 'AliasNbPages')) {
733
+				    $pdf->AliasNbPages();
734
+				}
684 735
 
685 736
 				$pdf->Close();
686 737
 
@@ -692,20 +743,19 @@  discard block
 block discarded – undo
692 743
 				global $action;
693 744
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
694 745
 
695
-				if (! empty($conf->global->MAIN_UMASK))
696
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
746
+				if (! empty($conf->global->MAIN_UMASK)) {
747
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
748
+				}
697 749
 
698 750
 				$this->result = array('fullpath'=>$file);
699 751
 
700 752
 				return 1;   // Pas d'erreur
701
-			}
702
-			else
753
+			} else
703 754
 			{
704 755
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
705 756
 				return 0;
706 757
 			}
707
-		}
708
-		else
758
+		} else
709 759
 		{
710 760
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
711 761
 			return 0;
@@ -811,10 +861,11 @@  discard block
 block discarded – undo
811 861
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
812 862
 
813 863
             $posy=$pdf->GetY()+1;
814
-		}
815
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
864
+		} elseif ($object->availability_code || $object->availability) {
865
+            // Show availability conditions
816 866
 		{
817 867
 			$pdf->SetFont('','B', $default_font_size - 2);
868
+        }
818 869
 			$pdf->SetXY($this->marge_gauche, $posy);
819 870
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
820 871
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -894,7 +945,10 @@  discard block
 block discarded – undo
894 945
 			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
895 946
 			{
896 947
 				$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
948
+				if (! empty($object->fk_bank)) {
949
+				    $bankid=$object->fk_bank;
950
+				}
951
+				// For backward compatibility when object->fk_account is forced with object->fk_bank
898 952
 				$account = new Account($this->db);
899 953
 				$account->fetch($bankid);
900 954
 
@@ -933,10 +987,12 @@  discard block
 block discarded – undo
933 987
 
934 988
 		// Tableau total
935 989
         $col1x = 120; $col2x = 170;
936
-		if ($this->page_largeur < 210) // To work with US executive format
990
+		if ($this->page_largeur < 210) {
991
+		    // To work with US executive format
937 992
 		{
938 993
 			$col2x-=20;
939 994
 		}
995
+		}
940 996
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
941 997
 
942 998
 		$useborder=0;
@@ -963,22 +1019,25 @@  discard block
 block discarded – undo
963 1019
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
964 1020
 			{
965 1021
 				// Nothing to do
966
-			}
967
-			else
1022
+			} else
968 1023
 			{
969 1024
 				//Local tax 1 before VAT
970 1025
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
971 1026
 				//{
972 1027
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
973 1028
 					{
974
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1029
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1030
+						    continue;
1031
+						}
975 1032
 						foreach( $localtax_rate as $tvakey => $tvaval )
976 1033
 						{
977
-							if ($tvakey!=0)    // On affiche pas taux 0
1034
+							if ($tvakey!=0) {
1035
+							    // On affiche pas taux 0
978 1036
 							{
979 1037
 								//$this->atleastoneratenotnull++;
980 1038
 
981 1039
 								$index++;
1040
+							}
982 1041
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
983 1042
 
984 1043
 								$tvacompl='';
@@ -1002,16 +1061,20 @@  discard block
 block discarded – undo
1002 1061
 				//{
1003 1062
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1004 1063
 					{
1005
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1064
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1065
+						    continue;
1066
+						}
1006 1067
 						foreach( $localtax_rate as $tvakey => $tvaval )
1007 1068
 						{
1008
-							if ($tvakey!=0)    // On affiche pas taux 0
1069
+							if ($tvakey!=0) {
1070
+							    // On affiche pas taux 0
1009 1071
 							{
1010 1072
 								//$this->atleastoneratenotnull++;
1011 1073
 
1012 1074
 
1013 1075
 
1014 1076
 								$index++;
1077
+							}
1015 1078
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 1079
 
1017 1080
 								$tvacompl='';
@@ -1033,9 +1096,11 @@  discard block
 block discarded – undo
1033 1096
 				// VAT
1034 1097
 				foreach($this->tva as $tvakey => $tvaval)
1035 1098
 				{
1036
-					if ($tvakey != 0)    // On affiche pas taux 0
1099
+					if ($tvakey != 0) {
1100
+					    // On affiche pas taux 0
1037 1101
 					{
1038 1102
 						$this->atleastoneratenotnull++;
1103
+					}
1039 1104
 
1040 1105
 						$index++;
1041 1106
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1060,15 +1125,19 @@  discard block
 block discarded – undo
1060 1125
 				//{
1061 1126
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1062 1127
 					{
1063
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1128
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1129
+						    continue;
1130
+						}
1064 1131
 
1065 1132
 						foreach( $localtax_rate as $tvakey => $tvaval )
1066 1133
 						{
1067
-							if ($tvakey != 0)    // On affiche pas taux 0
1134
+							if ($tvakey != 0) {
1135
+							    // On affiche pas taux 0
1068 1136
 							{
1069 1137
 								//$this->atleastoneratenotnull++;
1070 1138
 
1071 1139
 								$index++;
1140
+							}
1072 1141
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073 1142
 
1074 1143
 								$tvacompl='';
@@ -1092,15 +1161,19 @@  discard block
 block discarded – undo
1092 1161
 				//{
1093 1162
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1094 1163
 					{
1095
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1164
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1165
+						    continue;
1166
+						}
1096 1167
 
1097 1168
 						foreach( $localtax_rate as $tvakey => $tvaval )
1098 1169
 						{
1099
-							if ($tvakey != 0)    // On affiche pas taux 0
1170
+							if ($tvakey != 0) {
1171
+							    // On affiche pas taux 0
1100 1172
 							{
1101 1173
 								//$this->atleastoneratenotnull++;
1102 1174
 
1103 1175
 								$index++;
1176
+							}
1104 1177
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105 1178
 
1106 1179
 								$tvacompl='';
@@ -1141,7 +1214,9 @@  discard block
 block discarded – undo
1141 1214
 		//$depositsamount=$object->getSumDepositsUsed();
1142 1215
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1143 1216
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1144
-		if (! empty($object->paye)) $resteapayer=0;
1217
+		if (! empty($object->paye)) {
1218
+		    $resteapayer=0;
1219
+		}
1145 1220
 
1146 1221
 		if ($deja_regle > 0)
1147 1222
 		{
@@ -1189,7 +1264,9 @@  discard block
 block discarded – undo
1189 1264
 
1190 1265
 		// Force to disable hidetop and hidebottom
1191 1266
 		$hidebottom=0;
1192
-		if ($hidetop) $hidetop=-1;
1267
+		if ($hidetop) {
1268
+		    $hidetop=-1;
1269
+		}
1193 1270
 
1194 1271
 		$currency = !empty($currency) ? $currency : $conf->currency;
1195 1272
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1205,7 +1282,9 @@  discard block
 block discarded – undo
1205 1282
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1206 1283
 
1207 1284
 			//$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));
1285
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1286
+			    $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));
1287
+			}
1209 1288
 		}
1210 1289
 
1211 1290
 		$pdf->SetDrawColor(128,128,128);
@@ -1217,7 +1296,9 @@  discard block
 block discarded – undo
1217 1296
 
1218 1297
 		foreach ($this->cols as $colKey => $colDef)
1219 1298
 		{
1220
-		    if(!$this->getColumnStatus($colKey)) continue;
1299
+		    if(!$this->getColumnStatus($colKey)) {
1300
+		        continue;
1301
+		    }
1221 1302
 
1222 1303
 		    // get title label
1223 1304
 		    $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
@@ -1286,16 +1367,14 @@  discard block
 block discarded – undo
1286 1367
 				{
1287 1368
 				    $height=pdf_getHeightForLogo($logo);
1288 1369
 				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1289
-				}
1290
-				else
1370
+				} else
1291 1371
 				{
1292 1372
 					$pdf->SetTextColor(200,0,0);
1293 1373
 					$pdf->SetFont('','B', $default_font_size -2);
1294 1374
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1295 1375
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1296 1376
 				}
1297
-			}
1298
-			else
1377
+			} else
1299 1378
 			{
1300 1379
 				$text=$this->emetteur->name;
1301 1380
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1375,7 +1454,9 @@  discard block
 block discarded – undo
1375 1454
 			// Show sender
1376 1455
 			$posy=42+$top_shift;
1377 1456
 			$posx=$this->marge_gauche;
1378
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1457
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1458
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1459
+			}
1379 1460
 			$hautcadre=40;
1380 1461
 
1381 1462
 			// Show sender frame
@@ -1424,10 +1505,15 @@  discard block
 block discarded – undo
1424 1505
 
1425 1506
 			// Show recipient
1426 1507
 			$widthrecbox=100;
1427
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1508
+			if ($this->page_largeur < 210) {
1509
+			    $widthrecbox=84;
1510
+			}
1511
+			// To work with US executive format
1428 1512
 			$posy=42+$top_shift;
1429 1513
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1430
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1514
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1515
+			    $posx=$this->marge_gauche;
1516
+			}
1431 1517
 
1432 1518
 			// Show recipient frame
1433 1519
 			$pdf->SetTextColor(0,0,0);
@@ -1659,12 +1745,10 @@  discard block
 block discarded – undo
1659 1745
 	    if ($reshook < 0)
1660 1746
 	    {
1661 1747
 	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
1662
-	    }
1663
-	    elseif (empty($reshook))
1748
+	    } elseif (empty($reshook))
1664 1749
 	    {
1665 1750
 	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
1666
-	    }
1667
-	    else
1751
+	    } else
1668 1752
 	    {
1669 1753
 	        $this->cols = $hookmanager->resArray;
1670 1754
 	    }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php 3 patches
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -40,480 +40,480 @@
 block discarded – undo
40 40
  */
41 41
 class doc_generic_order_odt extends ModelePDFCommandes
42 42
 {
43
-	/**
44
-	 * Issuer
45
-	 * @var Societe
46
-	 */
47
-	public $emetteur;
48
-
49
-	/**
50
-   * @var array Minimum version of PHP required by module.
51
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
52
-   */
53
-	public $phpmin = array(5, 4);
54
-
55
-	/**
43
+    /**
44
+     * Issuer
45
+     * @var Societe
46
+     */
47
+    public $emetteur;
48
+
49
+    /**
50
+     * @var array Minimum version of PHP required by module.
51
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
52
+     */
53
+    public $phpmin = array(5, 4);
54
+
55
+    /**
56 56
      * Dolibarr version of the loaded document
57 57
      * @public string
58 58
      */
59
-	public $version = 'dolibarr';
59
+    public $version = 'dolibarr';
60 60
 
61 61
 
62
-	/**
63
-	 *	Constructor
64
-	 *
65
-	 *  @param		DoliDB		$db      Database handler
66
-	 */
67
-	function __construct($db)
68
-	{
69
-		global $conf, $langs, $mysoc;
62
+    /**
63
+     *	Constructor
64
+     *
65
+     *  @param		DoliDB		$db      Database handler
66
+     */
67
+    function __construct($db)
68
+    {
69
+        global $conf, $langs, $mysoc;
70 70
 
71
-		// Load translation files required by the page
71
+        // Load translation files required by the page
72 72
         $langs->loadLangs(array("main","companies"));
73 73
 
74
-		$this->db = $db;
75
-		$this->name = "ODT templates";
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
78
-
79
-		// Dimension page pour format A4
80
-		$this->type = 'odt';
81
-		$this->page_largeur = 0;
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
99
-
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
103
-	}
104
-
105
-
106
-	/**
107
-	 *	Return description of a module
108
-	 *
109
-	 *	@param	Translate	$langs      Lang object to use for output
110
-	 *	@return string       			Description
111
-	 */
112
-	function info($langs)
113
-	{
114
-		global $conf,$langs;
115
-
116
-		// Load translation files required by the page
74
+        $this->db = $db;
75
+        $this->name = "ODT templates";
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
78
+
79
+        // Dimension page pour format A4
80
+        $this->type = 'odt';
81
+        $this->page_largeur = 0;
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
99
+
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
103
+    }
104
+
105
+
106
+    /**
107
+     *	Return description of a module
108
+     *
109
+     *	@param	Translate	$langs      Lang object to use for output
110
+     *	@return string       			Description
111
+     */
112
+    function info($langs)
113
+    {
114
+        global $conf,$langs;
115
+
116
+        // Load translation files required by the page
117 117
         $langs->loadLangs(array("errors","companies"));
118 118
 
119
-		$form = new Form($this->db);
120
-
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%">';
127
-
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)
134
-		{
135
-			$tmpdir=trim($tmpdir);
136
-			$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
-			if (! $tmpdir) {
138
-				unset($listofdir[$key]); continue;
139
-			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
142
-			{
143
-				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
-			}
146
-		}
147
-		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
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>';
160
-
161
-		// Scan directories
162
-		$nbofiles=count($listoffiles);
163
-		if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
164
-		{
165
-			$texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
166
-			//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
-			$texte.=count($listoffiles);
168
-			//$texte.=$nbofiles?'</a>':'';
169
-			$texte.='</b>';
170
-		}
171
-
172
-		if ($nbofiles)
173
-		{
174
-   			$texte.='<div id="div_'.get_class($this).'" class="hidden">';
175
-   			foreach($listoffiles as $file)
176
-   			{
119
+        $form = new Form($this->db);
120
+
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%">';
127
+
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)
134
+        {
135
+            $tmpdir=trim($tmpdir);
136
+            $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
137
+            if (! $tmpdir) {
138
+                unset($listofdir[$key]); continue;
139
+            }
140
+            if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
+            else
142
+            {
143
+                $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
+                if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
145
+            }
146
+        }
147
+        $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
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>';
160
+
161
+        // Scan directories
162
+        $nbofiles=count($listoffiles);
163
+        if (! empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH))
164
+        {
165
+            $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
166
+            //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
167
+            $texte.=count($listoffiles);
168
+            //$texte.=$nbofiles?'</a>':'';
169
+            $texte.='</b>';
170
+        }
171
+
172
+        if ($nbofiles)
173
+        {
174
+                $texte.='<div id="div_'.get_class($this).'" class="hidden">';
175
+                foreach($listoffiles as $file)
176
+                {
177 177
                 $texte.=$file['name'].'<br>';
178
-   			}
179
-   			$texte.='<div id="div_'.get_class($this).'">';
180
-		}
178
+                }
179
+                $texte.='<div id="div_'.get_class($this).'">';
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
-		return $texte;
193
-	}
192
+        return $texte;
193
+    }
194 194
 
195 195
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
196
-	/**
197
-	 *	Function to build a document on disk using the generic odt module.
198
-	 *
199
-	 *	@param		Commande	$object				Object source to build document
200
-	 *	@param		Translate	$outputlangs		Lang output object
201
-	 * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
202
-	 *  @param		int			$hidedetails		Do not show line details
203
-	 *  @param		int			$hidedesc			Do not show desc
204
-	 *  @param		int			$hideref			Do not show ref
205
-	 *	@return		int         					1 if OK, <=0 if KO
206
-	 */
207
-	function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
208
-	{
196
+    /**
197
+     *	Function to build a document on disk using the generic odt module.
198
+     *
199
+     *	@param		Commande	$object				Object source to build document
200
+     *	@param		Translate	$outputlangs		Lang output object
201
+     * 	@param		string		$srctemplatepath	Full path of source filename for generator using a template file
202
+     *  @param		int			$hidedetails		Do not show line details
203
+     *  @param		int			$hidedesc			Do not show desc
204
+     *  @param		int			$hideref			Do not show ref
205
+     *	@return		int         					1 if OK, <=0 if KO
206
+     */
207
+    function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
208
+    {
209 209
         // phpcs:enable
210
-		global $user,$langs,$conf,$mysoc,$hookmanager;
211
-
212
-		if (empty($srctemplatepath))
213
-		{
214
-			dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
215
-			return -1;
216
-		}
217
-
218
-		// Add odtgeneration hook
219
-		if (! is_object($hookmanager))
220
-		{
221
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
222
-			$hookmanager=new HookManager($this->db);
223
-		}
224
-		$hookmanager->initHooks(array('odtgeneration'));
225
-		global $action;
226
-
227
-		if (! is_object($outputlangs)) $outputlangs=$langs;
228
-		$sav_charset_output=$outputlangs->charset_output;
229
-		$outputlangs->charset_output='UTF-8';
230
-
231
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232
-
233
-		if ($conf->commande->dir_output)
234
-		{
235
-			// If $object is id instead of object
236
-			if (! is_object($object))
237
-			{
238
-				$id = $object;
239
-				$object = new Commande($this->db);
240
-				$result=$object->fetch($id);
241
-				if ($result < 0)
242
-				{
243
-					dol_print_error($this->db,$object->error);
244
-					return -1;
245
-				}
246
-			}
247
-
248
-			$dir = $conf->commande->dir_output;
249
-			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
-			$file = $dir . "/" . $objectref . ".odt";
252
-
253
-			if (! file_exists($dir))
254
-			{
255
-				if (dol_mkdir($dir) < 0)
256
-				{
257
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
258
-					return -1;
259
-				}
260
-			}
261
-
262
-			if (file_exists($dir))
263
-			{
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;
270
-				//$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271
-				// Get extension (ods or odt)
272
-				$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
-				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
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;
278
-				}
279
-				else
280
-				{
281
-					$filename=$newfiletmp.'.'.$newfileformat;
282
-				}
283
-				$file=$dir.'/'.$filename;
284
-				//print "newdir=".$dir;
285
-				//print "newfile=".$newfile;
286
-				//print "file=".$file;
287
-				//print "conf->societe->dir_temp=".$conf->societe->dir_temp;
288
-
289
-				dol_mkdir($conf->commande->dir_temp);
290
-
291
-
292
-				// If CUSTOMER contact defined on order, we use it
293
-				$usecontact=false;
294
-				$arrayidcontact=$object->getIdContact('external','CUSTOMER');
295
-				if (count($arrayidcontact) > 0)
296
-				{
297
-					$usecontact=true;
298
-					$result=$object->fetch_contact($arrayidcontact[0]);
299
-				}
300
-
301
-				// Recipient name
302
-				$contactobject=null;
303
-				if (! empty($usecontact))
304
-				{
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;
307
-					else {
210
+        global $user,$langs,$conf,$mysoc,$hookmanager;
211
+
212
+        if (empty($srctemplatepath))
213
+        {
214
+            dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
215
+            return -1;
216
+        }
217
+
218
+        // Add odtgeneration hook
219
+        if (! is_object($hookmanager))
220
+        {
221
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
222
+            $hookmanager=new HookManager($this->db);
223
+        }
224
+        $hookmanager->initHooks(array('odtgeneration'));
225
+        global $action;
226
+
227
+        if (! is_object($outputlangs)) $outputlangs=$langs;
228
+        $sav_charset_output=$outputlangs->charset_output;
229
+        $outputlangs->charset_output='UTF-8';
230
+
231
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
232
+
233
+        if ($conf->commande->dir_output)
234
+        {
235
+            // If $object is id instead of object
236
+            if (! is_object($object))
237
+            {
238
+                $id = $object;
239
+                $object = new Commande($this->db);
240
+                $result=$object->fetch($id);
241
+                if ($result < 0)
242
+                {
243
+                    dol_print_error($this->db,$object->error);
244
+                    return -1;
245
+                }
246
+            }
247
+
248
+            $dir = $conf->commande->dir_output;
249
+            $objectref = dol_sanitizeFileName($object->ref);
250
+            if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
251
+            $file = $dir . "/" . $objectref . ".odt";
252
+
253
+            if (! file_exists($dir))
254
+            {
255
+                if (dol_mkdir($dir) < 0)
256
+                {
257
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
258
+                    return -1;
259
+                }
260
+            }
261
+
262
+            if (file_exists($dir))
263
+            {
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;
270
+                //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
271
+                // Get extension (ods or odt)
272
+                $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
273
+                if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
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;
278
+                }
279
+                else
280
+                {
281
+                    $filename=$newfiletmp.'.'.$newfileformat;
282
+                }
283
+                $file=$dir.'/'.$filename;
284
+                //print "newdir=".$dir;
285
+                //print "newfile=".$newfile;
286
+                //print "file=".$file;
287
+                //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
288
+
289
+                dol_mkdir($conf->commande->dir_temp);
290
+
291
+
292
+                // If CUSTOMER contact defined on order, we use it
293
+                $usecontact=false;
294
+                $arrayidcontact=$object->getIdContact('external','CUSTOMER');
295
+                if (count($arrayidcontact) > 0)
296
+                {
297
+                    $usecontact=true;
298
+                    $result=$object->fetch_contact($arrayidcontact[0]);
299
+                }
300
+
301
+                // Recipient name
302
+                $contactobject=null;
303
+                if (! empty($usecontact))
304
+                {
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;
307
+                    else {
308 308
                         $socobject = $object->thirdparty;
309
-               			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
310
-            			$contactobject = $object->contact;
309
+                            // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
310
+                        $contactobject = $object->contact;
311 311
                     }
312
-				}
313
-				else
314
-				{
315
-					$socobject=$object->thirdparty;
316
-				}
317
-
318
-				// Make substitution
319
-				$substitutionarray=array(
320
-				'__FROM_NAME__' => $this->emetteur->name,
321
-				'__FROM_EMAIL__' => $this->emetteur->email,
322
-				'__TOTAL_TTC__' => $object->total_ttc,
323
-				'__TOTAL_HT__' => $object->total_ht,
324
-				'__TOTAL_VAT__' => $object->total_vat
325
-				);
326
-				complete_substitutions_array($substitutionarray, $langs, $object);
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
330
-
331
-				// Line of free text
332
-				$newfreetext='';
333
-				$paramfreetext='ORDER_FREE_TEXT';
334
-				if (! empty($conf->global->$paramfreetext))
335
-				{
336
-					$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
337
-				}
338
-
339
-				// Open and load template
340
-				require_once ODTPHP_PATH.'odf.php';
341
-				try {
342
-					$odfHandler = new odf(
343
-						$srctemplatepath,
344
-						array(
345
-						'PATH_TO_TMP'	  => $conf->commande->dir_temp,
346
-						'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
347
-						'DELIMITER_LEFT'  => '{',
348
-						'DELIMITER_RIGHT' => '}'
349
-						)
350
-					);
351
-				}
352
-				catch(Exception $e)
353
-				{
354
-					$this->error=$e->getMessage();
355
-					dol_syslog($e->getMessage(), LOG_INFO);
356
-					return -1;
357
-				}
358
-				// After construction $odfHandler->contentXml contains content and
359
-				// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
360
-				// [!-- BEGIN lines --]*[!-- END lines --]
361
-				//print html_entity_decode($odfHandler->__toString());
362
-				//print exit;
363
-
364
-
365
-				// Make substitutions into odt of freetext
366
-				try {
367
-					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368
-				}
369
-				catch(OdfException $e)
370
-				{
312
+                }
313
+                else
314
+                {
315
+                    $socobject=$object->thirdparty;
316
+                }
317
+
318
+                // Make substitution
319
+                $substitutionarray=array(
320
+                '__FROM_NAME__' => $this->emetteur->name,
321
+                '__FROM_EMAIL__' => $this->emetteur->email,
322
+                '__TOTAL_TTC__' => $object->total_ttc,
323
+                '__TOTAL_HT__' => $object->total_ht,
324
+                '__TOTAL_VAT__' => $object->total_vat
325
+                );
326
+                complete_substitutions_array($substitutionarray, $langs, $object);
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
330
+
331
+                // Line of free text
332
+                $newfreetext='';
333
+                $paramfreetext='ORDER_FREE_TEXT';
334
+                if (! empty($conf->global->$paramfreetext))
335
+                {
336
+                    $newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
337
+                }
338
+
339
+                // Open and load template
340
+                require_once ODTPHP_PATH.'odf.php';
341
+                try {
342
+                    $odfHandler = new odf(
343
+                        $srctemplatepath,
344
+                        array(
345
+                        'PATH_TO_TMP'	  => $conf->commande->dir_temp,
346
+                        'ZIP_PROXY'		  => 'PclZipProxy',	// PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
347
+                        'DELIMITER_LEFT'  => '{',
348
+                        'DELIMITER_RIGHT' => '}'
349
+                        )
350
+                    );
351
+                }
352
+                catch(Exception $e)
353
+                {
354
+                    $this->error=$e->getMessage();
371 355
                     dol_syslog($e->getMessage(), LOG_INFO);
372
-				}
373
-
374
-				// Define substitution array
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);
382
-				// retrieve contact information for use in object as contact_xxx tags
383
-				$array_thirdparty_contact = array();
384
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
385
-
386
-				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
387
-				complete_substitutions_array($tmparray, $outputlangs, $object);
388
-
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
392
-
393
-				foreach($tmparray as $key=>$value)
394
-				{
395
-					try {
396
-						if (preg_match('/logo$/',$key)) // Image
397
-						{
398
-							if (file_exists($value)) $odfHandler->setImage($key, $value);
399
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
400
-						}
401
-						else    // Text
402
-						{
403
-							$odfHandler->setVars($key, $value, true, 'UTF-8');
404
-						}
405
-					}
406
-					catch(OdfException $e)
407
-					{
356
+                    return -1;
357
+                }
358
+                // After construction $odfHandler->contentXml contains content and
359
+                // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
360
+                // [!-- BEGIN lines --]*[!-- END lines --]
361
+                //print html_entity_decode($odfHandler->__toString());
362
+                //print exit;
363
+
364
+
365
+                // Make substitutions into odt of freetext
366
+                try {
367
+                    $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368
+                }
369
+                catch(OdfException $e)
370
+                {
371
+                    dol_syslog($e->getMessage(), LOG_INFO);
372
+                }
373
+
374
+                // Define substitution array
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);
382
+                // retrieve contact information for use in object as contact_xxx tags
383
+                $array_thirdparty_contact = array();
384
+                if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
385
+
386
+                $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
387
+                complete_substitutions_array($tmparray, $outputlangs, $object);
388
+
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
392
+
393
+                foreach($tmparray as $key=>$value)
394
+                {
395
+                    try {
396
+                        if (preg_match('/logo$/',$key)) // Image
397
+                        {
398
+                            if (file_exists($value)) $odfHandler->setImage($key, $value);
399
+                            else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
400
+                        }
401
+                        else    // Text
402
+                        {
403
+                            $odfHandler->setVars($key, $value, true, 'UTF-8');
404
+                        }
405
+                    }
406
+                    catch(OdfException $e)
407
+                    {
408 408
                         dol_syslog($e->getMessage(), LOG_INFO);
409
-					}
410
-				}
411
-				// Replace tags of lines
412
-				try
413
-				{
414
-					$foundtagforlines = 1;
415
-					try {
416
-						$listlines = $odfHandler->setSegment('lines');
417
-					}
418
-					catch(OdfException $e)
419
-					{
420
-						// We may arrive here if tags for lines not present into template
421
-						$foundtagforlines = 0;
422
-						dol_syslog($e->getMessage(), LOG_INFO);
423
-					}
424
-					if ($foundtagforlines)
425
-					{
426
-						foreach ($object->lines as $line)
427
-						{
428
-							$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
429
-							complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
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)
434
-							{
435
-								try
436
-								{
437
-									$listlines->setVars($key, $val, true, 'UTF-8');
438
-								}
439
-								catch(OdfException $e)
440
-								{
409
+                    }
410
+                }
411
+                // Replace tags of lines
412
+                try
413
+                {
414
+                    $foundtagforlines = 1;
415
+                    try {
416
+                        $listlines = $odfHandler->setSegment('lines');
417
+                    }
418
+                    catch(OdfException $e)
419
+                    {
420
+                        // We may arrive here if tags for lines not present into template
421
+                        $foundtagforlines = 0;
422
+                        dol_syslog($e->getMessage(), LOG_INFO);
423
+                    }
424
+                    if ($foundtagforlines)
425
+                    {
426
+                        foreach ($object->lines as $line)
427
+                        {
428
+                            $tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
429
+                            complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
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)
434
+                            {
435
+                                try
436
+                                {
437
+                                    $listlines->setVars($key, $val, true, 'UTF-8');
438
+                                }
439
+                                catch(OdfException $e)
440
+                                {
441 441
                                     dol_syslog($e->getMessage(), LOG_INFO);
442
-								}
443
-								catch(SegmentException $e)
444
-								{
442
+                                }
443
+                                catch(SegmentException $e)
444
+                                {
445 445
                                     dol_syslog($e->getMessage(), LOG_INFO);
446
-								}
447
-							}
448
-							$listlines->merge();
449
-						}
450
-						$odfHandler->mergeSegment($listlines);
451
-					}
452
-				}
453
-				catch(OdfException $e)
454
-				{
455
-					$this->error=$e->getMessage();
456
-					dol_syslog($this->error, LOG_WARNING);
457
-					return -1;
458
-				}
459
-
460
-				// Replace labels translated
461
-				$tmparray=$outputlangs->get_translations_for_substitutions();
462
-				foreach($tmparray as $key=>$value)
463
-				{
464
-					try {
465
-						$odfHandler->setVars($key, $value, true, 'UTF-8');
466
-					}
467
-					catch(OdfException $e)
468
-					{
446
+                                }
447
+                            }
448
+                            $listlines->merge();
449
+                        }
450
+                        $odfHandler->mergeSegment($listlines);
451
+                    }
452
+                }
453
+                catch(OdfException $e)
454
+                {
455
+                    $this->error=$e->getMessage();
456
+                    dol_syslog($this->error, LOG_WARNING);
457
+                    return -1;
458
+                }
459
+
460
+                // Replace labels translated
461
+                $tmparray=$outputlangs->get_translations_for_substitutions();
462
+                foreach($tmparray as $key=>$value)
463
+                {
464
+                    try {
465
+                        $odfHandler->setVars($key, $value, true, 'UTF-8');
466
+                    }
467
+                    catch(OdfException $e)
468
+                    {
469 469
                         dol_syslog($e->getMessage(), LOG_INFO);
470
-					}
471
-				}
470
+                    }
471
+                }
472 472
 
473
-				// Call the beforeODTSave hook
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
-				// Write new file
479
-				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480
-					try {
481
-						$odfHandler->exportAsAttachedPDF($file);
482
-					}catch (Exception $e){
478
+                // Write new file
479
+                if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480
+                    try {
481
+                        $odfHandler->exportAsAttachedPDF($file);
482
+                    }catch (Exception $e){
483 483
                         $this->error=$e->getMessage();
484 484
                         dol_syslog($e->getMessage(), LOG_INFO);
485
-						return -1;
486
-					}
487
-				}
488
-				else {
489
-					try {
490
-					$odfHandler->saveToDisk($file);
491
-					} catch (Exception $e) {
485
+                        return -1;
486
+                    }
487
+                }
488
+                else {
489
+                    try {
490
+                    $odfHandler->saveToDisk($file);
491
+                    } catch (Exception $e) {
492 492
                         $this->error=$e->getMessage();
493 493
                         dol_syslog($e->getMessage(), LOG_INFO);
494
-						return -1;
495
-					}
496
-				}
494
+                        return -1;
495
+                    }
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))
502
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
501
+                if (! empty($conf->global->MAIN_UMASK))
502
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
503 503
 
504
-				$odfHandler=null;	// Destroy object
504
+                $odfHandler=null;	// Destroy object
505 505
 
506
-				$this->result = array('fullpath'=>$file);
506
+                $this->result = array('fullpath'=>$file);
507 507
 
508
-				return 1;   // Success
509
-			}
510
-			else
511
-			{
512
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
513
-				return -1;
514
-			}
515
-		}
508
+                return 1;   // Success
509
+            }
510
+            else
511
+            {
512
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
513
+                return -1;
514
+            }
515
+        }
516 516
 
517
-		return -1;
518
-	}
517
+        return -1;
518
+    }
519 519
 }
Please login to merge, or discard this 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.
Braces   +47 added lines, -41 removed lines patch added patch discarded remove patch
@@ -99,7 +99,10 @@  discard block
 block discarded – undo
99 99
 
100 100
 		// Recupere emetteur
101 101
 		$this->emetteur=$mysoc;
102
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default if not defined
102
+		if (! $this->emetteur->country_code) {
103
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
104
+		}
105
+		// By default if not defined
103 106
 	}
104 107
 
105 108
 
@@ -137,11 +140,14 @@  discard block
 block discarded – undo
137 140
 			if (! $tmpdir) {
138 141
 				unset($listofdir[$key]); continue;
139 142
 			}
140
-			if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
141
-			else
143
+			if (! is_dir($tmpdir)) {
144
+			    $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
145
+			} else
142 146
 			{
143 147
 				$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
144
-				if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
148
+				if (count($tmpfiles)) {
149
+				    $listoffiles=array_merge($listoffiles,$tmpfiles);
150
+				}
145 151
 			}
146 152
 		}
147 153
 		$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
@@ -224,7 +230,9 @@  discard block
 block discarded – undo
224 230
 		$hookmanager->initHooks(array('odtgeneration'));
225 231
 		global $action;
226 232
 
227
-		if (! is_object($outputlangs)) $outputlangs=$langs;
233
+		if (! is_object($outputlangs)) {
234
+		    $outputlangs=$langs;
235
+		}
228 236
 		$sav_charset_output=$outputlangs->charset_output;
229 237
 		$outputlangs->charset_output='UTF-8';
230 238
 
@@ -247,7 +255,9 @@  discard block
 block discarded – undo
247 255
 
248 256
 			$dir = $conf->commande->dir_output;
249 257
 			$objectref = dol_sanitizeFileName($object->ref);
250
-			if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
258
+			if (! preg_match('/specimen/i',$objectref)) {
259
+			    $dir.= "/" . $objectref;
260
+			}
251 261
 			$file = $dir . "/" . $objectref . ".odt";
252 262
 
253 263
 			if (! file_exists($dir))
@@ -273,10 +283,11 @@  discard block
 block discarded – undo
273 283
 				if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
274 284
 				{
275 285
 				    $format=$conf->global->MAIN_DOC_USE_TIMING;
276
-				    if ($format == '1') $format='%Y%m%d%H%M%S';
286
+				    if ($format == '1') {
287
+				        $format='%Y%m%d%H%M%S';
288
+				    }
277 289
 					$filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
278
-				}
279
-				else
290
+				} else
280 291
 				{
281 292
 					$filename=$newfiletmp.'.'.$newfileformat;
282 293
 				}
@@ -303,14 +314,14 @@  discard block
 block discarded – undo
303 314
 				if (! empty($usecontact))
304 315
 				{
305 316
 					// On peut utiliser le nom de la societe du contact
306
-					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
307
-					else {
317
+					if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
318
+					    $socobject = $object->contact;
319
+					} else {
308 320
                         $socobject = $object->thirdparty;
309 321
                			// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
310 322
             			$contactobject = $object->contact;
311 323
                     }
312
-				}
313
-				else
324
+				} else
314 325
 				{
315 326
 					$socobject=$object->thirdparty;
316 327
 				}
@@ -348,8 +359,7 @@  discard block
 block discarded – undo
348 359
 						'DELIMITER_RIGHT' => '}'
349 360
 						)
350 361
 					);
351
-				}
352
-				catch(Exception $e)
362
+				} catch(Exception $e)
353 363
 				{
354 364
 					$this->error=$e->getMessage();
355 365
 					dol_syslog($e->getMessage(), LOG_INFO);
@@ -365,8 +375,7 @@  discard block
 block discarded – undo
365 375
 				// Make substitutions into odt of freetext
366 376
 				try {
367 377
 					$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
368
-				}
369
-				catch(OdfException $e)
378
+				} catch(OdfException $e)
370 379
 				{
371 380
                     dol_syslog($e->getMessage(), LOG_INFO);
372 381
 				}
@@ -381,7 +390,9 @@  discard block
 block discarded – undo
381 390
 				$array_other=$this->get_substitutionarray_other($outputlangs);
382 391
 				// retrieve contact information for use in object as contact_xxx tags
383 392
 				$array_thirdparty_contact = array();
384
-				if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
393
+				if ($usecontact && is_object($contactobject)) {
394
+				    $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
395
+				}
385 396
 
386 397
 				$tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact);
387 398
 				complete_substitutions_array($tmparray, $outputlangs, $object);
@@ -393,17 +404,18 @@  discard block
 block discarded – undo
393 404
 				foreach($tmparray as $key=>$value)
394 405
 				{
395 406
 					try {
396
-						if (preg_match('/logo$/',$key)) // Image
407
+						if (preg_match('/logo$/',$key)) {
408
+						    // Image
397 409
 						{
398 410
 							if (file_exists($value)) $odfHandler->setImage($key, $value);
399
-							else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
400
-						}
401
-						else    // Text
411
+						} else {
412
+							    $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
413
+							}
414
+						} else    // Text
402 415
 						{
403 416
 							$odfHandler->setVars($key, $value, true, 'UTF-8');
404 417
 						}
405
-					}
406
-					catch(OdfException $e)
418
+					} catch(OdfException $e)
407 419
 					{
408 420
                         dol_syslog($e->getMessage(), LOG_INFO);
409 421
 					}
@@ -414,8 +426,7 @@  discard block
 block discarded – undo
414 426
 					$foundtagforlines = 1;
415 427
 					try {
416 428
 						$listlines = $odfHandler->setSegment('lines');
417
-					}
418
-					catch(OdfException $e)
429
+					} catch(OdfException $e)
419 430
 					{
420 431
 						// We may arrive here if tags for lines not present into template
421 432
 						$foundtagforlines = 0;
@@ -435,12 +446,10 @@  discard block
 block discarded – undo
435 446
 								try
436 447
 								{
437 448
 									$listlines->setVars($key, $val, true, 'UTF-8');
438
-								}
439
-								catch(OdfException $e)
449
+								} catch(OdfException $e)
440 450
 								{
441 451
                                     dol_syslog($e->getMessage(), LOG_INFO);
442
-								}
443
-								catch(SegmentException $e)
452
+								} catch(SegmentException $e)
444 453
 								{
445 454
                                     dol_syslog($e->getMessage(), LOG_INFO);
446 455
 								}
@@ -449,8 +458,7 @@  discard block
 block discarded – undo
449 458
 						}
450 459
 						$odfHandler->mergeSegment($listlines);
451 460
 					}
452
-				}
453
-				catch(OdfException $e)
461
+				} catch(OdfException $e)
454 462
 				{
455 463
 					$this->error=$e->getMessage();
456 464
 					dol_syslog($this->error, LOG_WARNING);
@@ -463,8 +471,7 @@  discard block
 block discarded – undo
463 471
 				{
464 472
 					try {
465 473
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
466
-					}
467
-					catch(OdfException $e)
474
+					} catch(OdfException $e)
468 475
 					{
469 476
                         dol_syslog($e->getMessage(), LOG_INFO);
470 477
 					}
@@ -479,13 +486,12 @@  discard block
 block discarded – undo
479 486
 				if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
480 487
 					try {
481 488
 						$odfHandler->exportAsAttachedPDF($file);
482
-					}catch (Exception $e){
489
+					} catch (Exception $e){
483 490
                         $this->error=$e->getMessage();
484 491
                         dol_syslog($e->getMessage(), LOG_INFO);
485 492
 						return -1;
486 493
 					}
487
-				}
488
-				else {
494
+				} else {
489 495
 					try {
490 496
 					$odfHandler->saveToDisk($file);
491 497
 					} catch (Exception $e) {
@@ -498,16 +504,16 @@  discard block
 block discarded – undo
498 504
 				$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
499 505
 				$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
500 506
 
501
-				if (! empty($conf->global->MAIN_UMASK))
502
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
507
+				if (! empty($conf->global->MAIN_UMASK)) {
508
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
509
+				}
503 510
 
504 511
 				$odfHandler=null;	// Destroy object
505 512
 
506 513
 				$this->result = array('fullpath'=>$file);
507 514
 
508 515
 				return 1;   // Success
509
-			}
510
-			else
516
+			} else
511 517
 			{
512 518
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
513 519
 				return -1;
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/commande/doc/pdf_einstein.modules.php 3 patches
Indentation   +1186 added lines, -1186 removed lines patch added patch discarded remove patch
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public $db;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model name
52 52
      */
53 53
     public $name;
54 54
 
55
-	/**
55
+    /**
56 56
      * @var string model description (short text)
57 57
      */
58 58
     public $description;
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
      */
63 63
     public $update_main_doc_field;
64 64
 
65
-	/**
65
+    /**
66 66
      * @var string document type
67 67
      */
68 68
     public $type;
69 69
 
70
-	/**
70
+    /**
71 71
      * @var array() Minimum version of PHP required by module.
72
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
72
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
73 73
      */
74
-	public $phpmin = array(5, 4);
74
+    public $phpmin = array(5, 4);
75 75
 
76
-	/**
76
+    /**
77 77
      * Dolibarr version of the loaded document
78 78
      * @public string
79 79
      */
80
-	public $version = 'dolibarr';
80
+    public $version = 'dolibarr';
81 81
 
82
-	/**
82
+    /**
83 83
      * @var int page_largeur
84 84
      */
85 85
     public $page_largeur;
@@ -97,111 +97,111 @@  discard block
 block discarded – undo
97 97
     /**
98 98
      * @var int marge_gauche
99 99
      */
100
-	public $marge_gauche;
100
+    public $marge_gauche;
101 101
 
102
-	/**
102
+    /**
103 103
      * @var int marge_droite
104 104
      */
105
-	public $marge_droite;
105
+    public $marge_droite;
106 106
 
107
-	/**
107
+    /**
108 108
      * @var int marge_haute
109 109
      */
110
-	public $marge_haute;
110
+    public $marge_haute;
111 111
 
112
-	/**
112
+    /**
113 113
      * @var int marge_basse
114 114
      */
115
-	public $marge_basse;
115
+    public $marge_basse;
116 116
 
117
-	/**
118
-	 * Issuer
119
-	 * @var Company object that emits
120
-	 */
117
+    /**
118
+     * Issuer
119
+     * @var Company object that emits
120
+     */
121 121
     public $emetteur;
122 122
 
123 123
 
124
-	/**
125
-	 *	Constructor
126
-	 *
127
-	 *  @param		DoliDB		$db      Database handler
128
-	 */
129
-	public function __construct($db)
130
-	{
131
-		global $conf,$langs,$mysoc;
132
-
133
-		// Translations
134
-		$langs->loadLangs(array("main", "bills", "products"));
135
-
136
-		$this->db = $db;
137
-		$this->name = "einstein";
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
140
-
141
-		// Dimension page
142
-		$this->type = 'pdf';
143
-		$formatarray=pdf_getFormat();
144
-		$this->page_largeur = $formatarray['width'];
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;
164
-
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
168
-
169
-		// Define position of columns
170
-		$this->posxdesc=$this->marge_gauche+1;
171
-		if($conf->global->PRODUCT_USE_UNITS)
172
-		{
173
-			$this->posxtva=101;
174
-			$this->posxup=118;
175
-			$this->posxqty=135;
176
-			$this->posxunit=151;
177
-		}
178
-		else
179
-		{
180
-			$this->posxtva=110;
181
-			$this->posxup=126;
182
-			$this->posxqty=145;
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
188
-		if ($this->page_largeur < 210) // To work with US executive format
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;
197
-		}
198
-
199
-		$this->tva=array();
200
-		$this->localtax1=array();
201
-		$this->localtax2=array();
202
-		$this->atleastoneratenotnull=0;
203
-		$this->atleastonediscount=0;
204
-	}
124
+    /**
125
+     *	Constructor
126
+     *
127
+     *  @param		DoliDB		$db      Database handler
128
+     */
129
+    public function __construct($db)
130
+    {
131
+        global $conf,$langs,$mysoc;
132
+
133
+        // Translations
134
+        $langs->loadLangs(array("main", "bills", "products"));
135
+
136
+        $this->db = $db;
137
+        $this->name = "einstein";
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
140
+
141
+        // Dimension page
142
+        $this->type = 'pdf';
143
+        $formatarray=pdf_getFormat();
144
+        $this->page_largeur = $formatarray['width'];
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;
164
+
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
168
+
169
+        // Define position of columns
170
+        $this->posxdesc=$this->marge_gauche+1;
171
+        if($conf->global->PRODUCT_USE_UNITS)
172
+        {
173
+            $this->posxtva=101;
174
+            $this->posxup=118;
175
+            $this->posxqty=135;
176
+            $this->posxunit=151;
177
+        }
178
+        else
179
+        {
180
+            $this->posxtva=110;
181
+            $this->posxup=126;
182
+            $this->posxqty=145;
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
188
+        if ($this->page_largeur < 210) // To work with US executive format
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;
197
+        }
198
+
199
+        $this->tva=array();
200
+        $this->localtax1=array();
201
+        $this->localtax2=array();
202
+        $this->atleastoneratenotnull=0;
203
+        $this->atleastonediscount=0;
204
+    }
205 205
 
206 206
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
207 207
     /**
@@ -214,71 +214,71 @@  discard block
 block discarded – undo
214 214
      *  @param		int			$hidedesc			Do not show desc
215 215
      *  @param		int			$hideref			Do not show ref
216 216
      *  @return     int             			    1=OK, 0=KO
217
-	 */
218
-	function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
219
-	{
217
+     */
218
+    function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
219
+    {
220 220
         // phpcs:enable
221
-		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
221
+        global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
222 222
 
223
-		if (! is_object($outputlangs)) $outputlangs=$langs;
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';
223
+        if (! is_object($outputlangs)) $outputlangs=$langs;
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';
226 226
 
227
-		// Load translation files required by the page
228
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
227
+        // Load translation files required by the page
228
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
229 229
 
230
-		$nblignes = count($object->lines);
230
+        $nblignes = count($object->lines);
231 231
 
232
-		if ($conf->commande->dir_output)
233
-		{
232
+        if ($conf->commande->dir_output)
233
+        {
234 234
             $object->fetch_thirdparty();
235 235
 
236 236
             $deja_regle = 0;
237 237
 
238 238
             // Definition of $dir and $file
239
-			if ($object->specimen)
240
-			{
241
-				$dir = $conf->commande->dir_output;
242
-				$file = $dir . "/SPECIMEN.pdf";
243
-			}
244
-			else
245
-			{
246
-				$objectref = dol_sanitizeFileName($object->ref);
247
-				$dir = $conf->commande->dir_output . "/" . $objectref;
248
-				$file = $dir . "/" . $objectref . ".pdf";
249
-			}
250
-
251
-			if (! file_exists($dir))
252
-			{
253
-				if (dol_mkdir($dir) < 0)
254
-				{
255
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
256
-					return 0;
257
-				}
258
-			}
239
+            if ($object->specimen)
240
+            {
241
+                $dir = $conf->commande->dir_output;
242
+                $file = $dir . "/SPECIMEN.pdf";
243
+            }
244
+            else
245
+            {
246
+                $objectref = dol_sanitizeFileName($object->ref);
247
+                $dir = $conf->commande->dir_output . "/" . $objectref;
248
+                $file = $dir . "/" . $objectref . ".pdf";
249
+            }
250
+
251
+            if (! file_exists($dir))
252
+            {
253
+                if (dol_mkdir($dir) < 0)
254
+                {
255
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
256
+                    return 0;
257
+                }
258
+            }
259 259
 
260
-			if (file_exists($dir))
261
-			{
262
-				// Add pdfgeneration hook
263
-				if (! is_object($hookmanager))
264
-				{
265
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
266
-					$hookmanager=new HookManager($this->db);
267
-				}
268
-				$hookmanager->initHooks(array('pdfgeneration'));
269
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
270
-				global $action;
271
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
260
+            if (file_exists($dir))
261
+            {
262
+                // Add pdfgeneration hook
263
+                if (! is_object($hookmanager))
264
+                {
265
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
266
+                    $hookmanager=new HookManager($this->db);
267
+                }
268
+                $hookmanager->initHooks(array('pdfgeneration'));
269
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
270
+                global $action;
271
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
272 272
 
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);
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);
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
                 {
@@ -293,422 +293,422 @@  discard block
 block discarded – undo
293 293
                     $tplidx = $pdf->importPage(1);
294 294
                 }
295 295
 
296
-				$pdf->Open();
297
-				$pagenb=0;
298
-				$pdf->SetDrawColor(128,128,128);
296
+                $pdf->Open();
297
+                $pagenb=0;
298
+                $pdf->SetDrawColor(128,128,128);
299 299
 
300
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
301
-				$pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
302
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
303
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
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);
300
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
301
+                $pdf->SetSubject($outputlangs->transnoentities("PdfOrderTitle"));
302
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
303
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
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);
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
-				// Positionne $this->atleastonediscount si on a au moins une remise
310
-				for ($i = 0 ; $i < $nblignes ; $i++)
311
-				{
312
-					if ($object->lines[$i]->remise_percent)
313
-					{
314
-						$this->atleastonediscount++;
315
-					}
316
-				}
317
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
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);
324
-					//$this->postotalht;
325
-				}
309
+                // Positionne $this->atleastonediscount si on a au moins une remise
310
+                for ($i = 0 ; $i < $nblignes ; $i++)
311
+                {
312
+                    if ($object->lines[$i]->remise_percent)
313
+                    {
314
+                        $this->atleastonediscount++;
315
+                    }
316
+                }
317
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
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);
324
+                    //$this->postotalht;
325
+                }
326 326
 
327
-				// New page
328
-				$pdf->AddPage();
329
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
330
-				$pagenb++;
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);
327
+                // New page
328
+                $pdf->AddPage();
329
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
330
+                $pagenb++;
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);
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
-				// Incoterm
341
-				if ($conf->incoterm->enabled)
342
-				{
343
-					$desc_incoterms = $object->getIncotermsForPDF();
344
-					if ($desc_incoterms)
345
-					{
346
-						$tab_top -= 2;
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);
350
-						$nexY = $pdf->GetY();
351
-						$height_incoterms=$nexY-$tab_top;
352
-
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);
356
-
357
-						$tab_top = $nexY+6;
358
-					}
359
-				}
340
+                // Incoterm
341
+                if ($conf->incoterm->enabled)
342
+                {
343
+                    $desc_incoterms = $object->getIncotermsForPDF();
344
+                    if ($desc_incoterms)
345
+                    {
346
+                        $tab_top -= 2;
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);
350
+                        $nexY = $pdf->GetY();
351
+                        $height_incoterms=$nexY-$tab_top;
352
+
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);
356
+
357
+                        $tab_top = $nexY+6;
358
+                    }
359
+                }
360 360
 
361
-				// Affiche notes
362
-				$notetoshow=empty($object->note_public)?'':$object->note_public;
363
-				if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
364
-				{
365
-					// Get first sale rep
366
-					if (is_object($object->thirdparty))
367
-					{
368
-						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
369
-						$salerepobj=new User($this->db);
370
-						$salerepobj->fetch($salereparray[0]['id']);
371
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
372
-					}
373
-				}
374
-				if ($notetoshow)
375
-				{
376
-					$tab_top -= 2;
361
+                // Affiche notes
362
+                $notetoshow=empty($object->note_public)?'':$object->note_public;
363
+                if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
364
+                {
365
+                    // Get first sale rep
366
+                    if (is_object($object->thirdparty))
367
+                    {
368
+                        $salereparray=$object->thirdparty->getSalesRepresentatives($user);
369
+                        $salerepobj=new User($this->db);
370
+                        $salerepobj->fetch($salereparray[0]['id']);
371
+                        if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
372
+                    }
373
+                }
374
+                if ($notetoshow)
375
+                {
376
+                    $tab_top -= 2;
377 377
 
378
-					$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
379
-					complete_substitutions_array($substitutionarray, $outputlangs, $object);
380
-					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
378
+                    $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
379
+                    complete_substitutions_array($substitutionarray, $outputlangs, $object);
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);
384
-					$nexY = $pdf->GetY();
385
-					$height_note=$nexY-$tab_top;
382
+                    $pdf->SetFont('','', $default_font_size - 1);
383
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
384
+                    $nexY = $pdf->GetY();
385
+                    $height_note=$nexY-$tab_top;
386 386
 
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);
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);
390 390
 
391
-					$tab_top = $nexY+6;
392
-				}
391
+                    $tab_top = $nexY+6;
392
+                }
393 393
 
394
-				$iniY = $tab_top + 7;
395
-				$curY = $tab_top + 7;
396
-				$nexY = $tab_top + 7;
394
+                $iniY = $tab_top + 7;
395
+                $curY = $tab_top + 7;
396
+                $nexY = $tab_top + 7;
397 397
 
398
-				// Loop on each lines
399
-				for ($i = 0 ; $i < $nblignes ; $i++)
400
-				{
401
-					$curY = $nexY;
402
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
403
-					$pdf->SetTextColor(0,0,0);
404
-
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();
408
-
409
-					// Description of product line
410
-					$curX = $this->posxdesc-1;
411
-
412
-					$showpricebeforepagebreak=1;
413
-
414
-					$pdf->startTransaction();
415
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416
-					$pageposafter=$pdf->getPage();
417
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
418
-					{
419
-						$pdf->rollbackTransaction(true);
420
-						$pageposafter=$pageposbefore;
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
427
-						{
428
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
429
-							{
430
-								$pdf->AddPage('','',true);
431
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
433
-								$pdf->setPage($pageposafter+1);
434
-							}
435
-						}
436
-						else
437
-						{
438
-							// We found a page break
439
-							$showpricebeforepagebreak=0;
440
-						}
441
-					}
442
-					else	// No pagebreak
443
-					{
444
-						$pdf->commitTransaction();
445
-					}
446
-					$posYAfterDescription=$pdf->GetY();
447
-
448
-					$nexY = $pdf->GetY();
449
-					$pageposafter=$pdf->getPage();
450
-
451
-					$pdf->setPage($pageposbefore);
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.
454
-
455
-					// We suppose that a too long description is moved completely on next page
456
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
458
-					}
459
-
460
-					$pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
461
-
462
-					// VAT Rate
463
-					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
464
-					{
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');
468
-					}
469
-
470
-					// Unit price before discount
471
-					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
472
-					$pdf->SetXY($this->posxup, $curY);
473
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
474
-
475
-					// Quantity
476
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
477
-					$pdf->SetXY($this->posxqty, $curY);
478
-					// Enough for 6 chars
479
-					if($conf->global->PRODUCT_USE_UNITS)
480
-					{
481
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
482
-					}
483
-					else
484
-					{
485
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
486
-					}
487
-
488
-					// Unit
489
-					if($conf->global->PRODUCT_USE_UNITS)
490
-					{
491
-						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
492
-						$pdf->SetXY($this->posxunit, $curY);
493
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
494
-					}
495
-
496
-					// Discount on line
497
-					$pdf->SetXY($this->posxdiscount, $curY);
498
-					if ($object->lines[$i]->remise_percent)
499
-					{
500
-						$pdf->SetXY($this->posxdiscount-2, $curY);
501
-						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
502
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
503
-					}
504
-
505
-					// Total HT line
506
-					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
507
-					$pdf->SetXY($this->postotalht, $curY);
508
-					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509
-
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;
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;
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;
524
-
525
-					$vatrate=(string) $object->lines[$i]->tva_tx;
526
-
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
530
-					{
531
-						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
532
-						$localtax1_type = $localtaxtmp_array[0];
533
-						$localtax2_type = $localtaxtmp_array[2];
534
-					}
535
-
536
-				    // retrieve global local tax
537
-					if ($localtax1_type && $localtax1ligne != 0)
538
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
539
-					if ($localtax2_type && $localtax2ligne != 0)
540
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
541
-
542
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
544
-					$this->tva[$vatrate] += $tvaligne;
545
-
546
-					// Add line
547
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548
-					{
549
-						$pdf->setPage($pageposafter);
550
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
551
-						//$pdf->SetDrawColor(190,190,200);
552
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
553
-						$pdf->SetLineStyle(array('dash'=>0));
554
-					}
555
-
556
-					$nexY+=2;    // Passe espace entre les lignes
557
-
558
-					// Detect if some page were added automatically and output _tableau for past pages
559
-					while ($pagenb < $pageposafter)
560
-					{
561
-						$pdf->setPage($pagenb);
562
-						if ($pagenb == 1)
563
-						{
564
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
565
-						}
566
-						else
567
-						{
568
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569
-						}
570
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
571
-						$pagenb++;
572
-						$pdf->setPage($pagenb);
573
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
575
-					}
576
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577
-					{
578
-						if ($pagenb == 1)
579
-						{
580
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
581
-						}
582
-						else
583
-						{
584
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585
-						}
586
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
587
-						// New page
588
-						$pdf->AddPage();
589
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
590
-						$pagenb++;
591
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
592
-					}
593
-				}
398
+                // Loop on each lines
399
+                for ($i = 0 ; $i < $nblignes ; $i++)
400
+                {
401
+                    $curY = $nexY;
402
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
403
+                    $pdf->SetTextColor(0,0,0);
404
+
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();
408
+
409
+                    // Description of product line
410
+                    $curX = $this->posxdesc-1;
411
+
412
+                    $showpricebeforepagebreak=1;
413
+
414
+                    $pdf->startTransaction();
415
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416
+                    $pageposafter=$pdf->getPage();
417
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
418
+                    {
419
+                        $pdf->rollbackTransaction(true);
420
+                        $pageposafter=$pageposbefore;
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
427
+                        {
428
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
429
+                            {
430
+                                $pdf->AddPage('','',true);
431
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
433
+                                $pdf->setPage($pageposafter+1);
434
+                            }
435
+                        }
436
+                        else
437
+                        {
438
+                            // We found a page break
439
+                            $showpricebeforepagebreak=0;
440
+                        }
441
+                    }
442
+                    else	// No pagebreak
443
+                    {
444
+                        $pdf->commitTransaction();
445
+                    }
446
+                    $posYAfterDescription=$pdf->GetY();
447
+
448
+                    $nexY = $pdf->GetY();
449
+                    $pageposafter=$pdf->getPage();
450
+
451
+                    $pdf->setPage($pageposbefore);
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.
454
+
455
+                    // We suppose that a too long description is moved completely on next page
456
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
458
+                    }
459
+
460
+                    $pdf->SetFont('','',  $default_font_size - 1);   // On repositionne la police par defaut
461
+
462
+                    // VAT Rate
463
+                    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
464
+                    {
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');
468
+                    }
469
+
470
+                    // Unit price before discount
471
+                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
472
+                    $pdf->SetXY($this->posxup, $curY);
473
+                    $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
474
+
475
+                    // Quantity
476
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
477
+                    $pdf->SetXY($this->posxqty, $curY);
478
+                    // Enough for 6 chars
479
+                    if($conf->global->PRODUCT_USE_UNITS)
480
+                    {
481
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
482
+                    }
483
+                    else
484
+                    {
485
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
486
+                    }
487
+
488
+                    // Unit
489
+                    if($conf->global->PRODUCT_USE_UNITS)
490
+                    {
491
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
492
+                        $pdf->SetXY($this->posxunit, $curY);
493
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
494
+                    }
495
+
496
+                    // Discount on line
497
+                    $pdf->SetXY($this->posxdiscount, $curY);
498
+                    if ($object->lines[$i]->remise_percent)
499
+                    {
500
+                        $pdf->SetXY($this->posxdiscount-2, $curY);
501
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
502
+                        $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
503
+                    }
504
+
505
+                    // Total HT line
506
+                    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
507
+                    $pdf->SetXY($this->postotalht, $curY);
508
+                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509
+
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;
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;
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;
524
+
525
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
526
+
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
530
+                    {
531
+                        $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
532
+                        $localtax1_type = $localtaxtmp_array[0];
533
+                        $localtax2_type = $localtaxtmp_array[2];
534
+                    }
535
+
536
+                    // retrieve global local tax
537
+                    if ($localtax1_type && $localtax1ligne != 0)
538
+                        $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
539
+                    if ($localtax2_type && $localtax2ligne != 0)
540
+                        $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
541
+
542
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
+                    if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
544
+                    $this->tva[$vatrate] += $tvaligne;
545
+
546
+                    // Add line
547
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
548
+                    {
549
+                        $pdf->setPage($pageposafter);
550
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
551
+                        //$pdf->SetDrawColor(190,190,200);
552
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
553
+                        $pdf->SetLineStyle(array('dash'=>0));
554
+                    }
555
+
556
+                    $nexY+=2;    // Passe espace entre les lignes
557
+
558
+                    // Detect if some page were added automatically and output _tableau for past pages
559
+                    while ($pagenb < $pageposafter)
560
+                    {
561
+                        $pdf->setPage($pagenb);
562
+                        if ($pagenb == 1)
563
+                        {
564
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
565
+                        }
566
+                        else
567
+                        {
568
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569
+                        }
570
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
571
+                        $pagenb++;
572
+                        $pdf->setPage($pagenb);
573
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
575
+                    }
576
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577
+                    {
578
+                        if ($pagenb == 1)
579
+                        {
580
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
581
+                        }
582
+                        else
583
+                        {
584
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585
+                        }
586
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
587
+                        // New page
588
+                        $pdf->AddPage();
589
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
590
+                        $pagenb++;
591
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
592
+                    }
593
+                }
594 594
 
595
-				// Show square
596
-				if ($pagenb == 1)
597
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598
-				else
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;
595
+                // Show square
596
+                if ($pagenb == 1)
597
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598
+                else
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;
601 601
 
602
-				// Affiche zone infos
603
-				$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
602
+                // Affiche zone infos
603
+                $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
604 604
 
605
-				// Affiche zone totaux
606
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
605
+                // Affiche zone totaux
606
+                $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
607 607
 
608
-				// Affiche zone versements
609
-				/*
608
+                // Affiche zone versements
609
+                /*
610 610
 				if ($deja_regle)
611 611
 				{
612 612
 					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
613 613
 				}
614 614
 				*/
615 615
 
616
-				// Pied de page
617
-				$this->_pagefoot($pdf, $object, $outputlangs);
618
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
616
+                // Pied de page
617
+                $this->_pagefoot($pdf, $object, $outputlangs);
618
+                if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
619 619
 
620
-				$pdf->Close();
620
+                $pdf->Close();
621 621
 
622
-				$pdf->Output($file, 'F');
622
+                $pdf->Output($file, 'F');
623 623
 
624
-				// Add pdfgeneration hook
625
-				$hookmanager->initHooks(array('pdfgeneration'));
626
-				$parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
627
-				global $action;
628
-				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
624
+                // Add pdfgeneration hook
625
+                $hookmanager->initHooks(array('pdfgeneration'));
626
+                $parameters=array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
627
+                global $action;
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))
631
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
630
+                if (! empty($conf->global->MAIN_UMASK))
631
+                    @chmod($file, octdec($conf->global->MAIN_UMASK));
632 632
 
633
-				$this->result = array('fullpath'=>$file);
633
+                $this->result = array('fullpath'=>$file);
634 634
 
635
-				return 1;   // Pas d'erreur
636
-			}
637
-			else
638
-			{
639
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
640
-				return 0;
641
-			}
642
-		}
643
-		else
644
-		{
645
-			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
646
-			return 0;
647
-		}
648
-	}
635
+                return 1;   // Pas d'erreur
636
+            }
637
+            else
638
+            {
639
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
640
+                return 0;
641
+            }
642
+        }
643
+        else
644
+        {
645
+            $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
646
+            return 0;
647
+        }
648
+    }
649 649
 
650 650
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
651
-	/**
652
-	 *  Show payments table
651
+    /**
652
+     *  Show payments table
653 653
      *
654
-	 *  @param	TCPDF		$pdf     		Object PDF
655
-	 *  @param  Object		$object			Object order
656
-	 *	@param	int			$posy			Position y in PDF
657
-	 *	@param	Translate	$outputlangs	Object langs for output
658
-	 *	@return int							<0 if KO, >0 if OK
659
-	 */
660
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
661
-	{
654
+     *  @param	TCPDF		$pdf     		Object PDF
655
+     *  @param  Object		$object			Object order
656
+     *	@param	int			$posy			Position y in PDF
657
+     *	@param	Translate	$outputlangs	Object langs for output
658
+     *	@return int							<0 if KO, >0 if OK
659
+     */
660
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
661
+    {
662 662
         // phpcs:enable
663
-	}
663
+    }
664 664
 
665 665
 
666 666
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
667
-	/**
668
-	 *   Show miscellaneous information (payment mode, payment term, ...)
669
-	 *
670
-	 *   @param		TCPDF		$pdf     		Object PDF
671
-	 *   @param		Object		$object			Object to show
672
-	 *   @param		int			$posy			Y
673
-	 *   @param		Translate	$outputlangs	Langs object
674
-	 *   @return	void
675
-	 */
676
-	function _tableau_info(&$pdf, $object, $posy, $outputlangs)
677
-	{
667
+    /**
668
+     *   Show miscellaneous information (payment mode, payment term, ...)
669
+     *
670
+     *   @param		TCPDF		$pdf     		Object PDF
671
+     *   @param		Object		$object			Object to show
672
+     *   @param		int			$posy			Y
673
+     *   @param		Translate	$outputlangs	Langs object
674
+     *   @return	void
675
+     */
676
+    function _tableau_info(&$pdf, $object, $posy, $outputlangs)
677
+    {
678 678
         // phpcs:enable
679
-		global $conf;
680
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
679
+        global $conf;
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
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
686
-		{
687
-			$pdf->SetFont('','B', $default_font_size - 2);
688
-			$pdf->SetXY($this->marge_gauche, $posy);
689
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
685
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
686
+        {
687
+            $pdf->SetFont('','B', $default_font_size - 2);
688
+            $pdf->SetXY($this->marge_gauche, $posy);
689
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
690 690
 
691
-			$posy=$pdf->GetY()+4;
692
-		}
691
+            $posy=$pdf->GetY()+4;
692
+        }
693 693
 
694
-		$posxval=52;
694
+        $posxval=52;
695 695
 
696
-		// Show payments conditions
697
-		if ($object->cond_reglement_code || $object->cond_reglement)
698
-		{
699
-			$pdf->SetFont('','B', $default_font_size - 2);
700
-			$pdf->SetXY($this->marge_gauche, $posy);
701
-			$titre = $outputlangs->transnoentities("PaymentConditions").':';
702
-			$pdf->MultiCell(43, 4, $titre, 0, 'L');
696
+        // Show payments conditions
697
+        if ($object->cond_reglement_code || $object->cond_reglement)
698
+        {
699
+            $pdf->SetFont('','B', $default_font_size - 2);
700
+            $pdf->SetXY($this->marge_gauche, $posy);
701
+            $titre = $outputlangs->transnoentities("PaymentConditions").':';
702
+            $pdf->MultiCell(43, 4, $titre, 0, 'L');
703 703
 
704
-			$pdf->SetFont('','', $default_font_size - 2);
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');
704
+            $pdf->SetFont('','', $default_font_size - 2);
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');
709 709
 
710
-			$posy=$pdf->GetY()+3;
711
-		}
710
+            $posy=$pdf->GetY()+3;
711
+        }
712 712
 
713 713
         // Check a payment mode is defined
714 714
         /* Not used with orders
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
             $posy=$pdf->GetY()+1;
726 726
         }
727 727
 		*/
728
-		/* TODO
728
+        /* TODO
729 729
 		else if (! empty($object->availability_code))
730 730
 		{
731 731
             $pdf->SetXY($this->marge_gauche, $posy);
@@ -737,719 +737,719 @@  discard block
 block discarded – undo
737 737
             $posy=$pdf->GetY()+1;
738 738
 		}*/
739 739
 
740
-	    // Show planed date of delivery
740
+        // Show planed date of delivery
741 741
         if (! empty($object->date_livraison))
742
-		{
742
+        {
743 743
             $outputlangs->load("sendings");
744
-			$pdf->SetFont('','B', $default_font_size - 2);
745
-			$pdf->SetXY($this->marge_gauche, $posy);
746
-			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
747
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
748
-			$pdf->SetFont('','', $default_font_size - 2);
749
-			$pdf->SetXY($posxval, $posy);
750
-			$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
751
-			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
744
+            $pdf->SetFont('','B', $default_font_size - 2);
745
+            $pdf->SetXY($this->marge_gauche, $posy);
746
+            $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
747
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
748
+            $pdf->SetFont('','', $default_font_size - 2);
749
+            $pdf->SetXY($posxval, $posy);
750
+            $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
751
+            $pdf->MultiCell(80, 4, $dlp, 0, 'L');
752 752
 
753 753
             $posy=$pdf->GetY()+1;
754
-		}
754
+        }
755 755
         elseif ($object->availability_code || $object->availability)    // Show availability conditions
756
-		{
757
-			$pdf->SetFont('','B', $default_font_size - 2);
758
-			$pdf->SetXY($this->marge_gauche, $posy);
759
-			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760
-			$pdf->MultiCell(80, 4, $titre, 0, 'L');
761
-			$pdf->SetTextColor(0,0,0);
762
-			$pdf->SetFont('','', $default_font_size - 2);
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);
766
-			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
767
-
768
-			$posy=$pdf->GetY()+1;
769
-		}
770
-
771
-      	// Show payment mode
756
+        {
757
+            $pdf->SetFont('','B', $default_font_size - 2);
758
+            $pdf->SetXY($this->marge_gauche, $posy);
759
+            $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760
+            $pdf->MultiCell(80, 4, $titre, 0, 'L');
761
+            $pdf->SetTextColor(0,0,0);
762
+            $pdf->SetFont('','', $default_font_size - 2);
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);
766
+            $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
767
+
768
+            $posy=$pdf->GetY()+1;
769
+        }
770
+
771
+            // Show payment mode
772 772
         if ($object->mode_reglement_code
773
-        	 && $object->mode_reglement_code != 'CHQ'
774
-           	 && $object->mode_reglement_code != 'VIR')
775
-           	 {
776
-	            $pdf->SetFont('','B', $default_font_size - 2);
777
-	            $pdf->SetXY($this->marge_gauche, $posy);
778
-	            $titre = $outputlangs->transnoentities("PaymentMode").':';
779
-	            $pdf->MultiCell(80, 5, $titre, 0, 'L');
780
-
781
-				$pdf->SetFont('','', $default_font_size - 2);
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');
785
-
786
-	            $posy=$pdf->GetY()+2;
787
-           	 }
788
-
789
-		// Show payment mode CHQ
773
+             && $object->mode_reglement_code != 'CHQ'
774
+                && $object->mode_reglement_code != 'VIR')
775
+                {
776
+                $pdf->SetFont('','B', $default_font_size - 2);
777
+                $pdf->SetXY($this->marge_gauche, $posy);
778
+                $titre = $outputlangs->transnoentities("PaymentMode").':';
779
+                $pdf->MultiCell(80, 5, $titre, 0, 'L');
780
+
781
+                $pdf->SetFont('','', $default_font_size - 2);
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');
785
+
786
+                $posy=$pdf->GetY()+2;
787
+                }
788
+
789
+        // Show payment mode CHQ
790 790
         if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
791 791
         {
792
-        	// Si mode reglement non force ou si force a CHQ
793
-	        if (! empty($conf->global->FACTURE_CHQ_NUMBER))
794
-	        {
795
-	            if ($conf->global->FACTURE_CHQ_NUMBER > 0)
796
-	            {
797
-	                $account = new Account($this->db);
798
-	                $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
799
-
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;
804
-
805
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
806
-		            {
807
-		                $pdf->SetXY($this->marge_gauche, $posy);
808
-		                $pdf->SetFont('','', $default_font_size - 3);
809
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
810
-			            $posy=$pdf->GetY()+2;
811
-		            }
812
-	            }
813
-	            if ($conf->global->FACTURE_CHQ_NUMBER == -1)
814
-	            {
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;
819
-
820
-		            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
821
-		            {
822
-			            $pdf->SetXY($this->marge_gauche, $posy);
823
-		                $pdf->SetFont('','', $default_font_size - 3);
824
-		                $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
825
-			            $posy=$pdf->GetY()+2;
826
-		            }
827
-	            }
828
-	        }
829
-		}
792
+            // Si mode reglement non force ou si force a CHQ
793
+            if (! empty($conf->global->FACTURE_CHQ_NUMBER))
794
+            {
795
+                if ($conf->global->FACTURE_CHQ_NUMBER > 0)
796
+                {
797
+                    $account = new Account($this->db);
798
+                    $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
799
+
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;
804
+
805
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
806
+                    {
807
+                        $pdf->SetXY($this->marge_gauche, $posy);
808
+                        $pdf->SetFont('','', $default_font_size - 3);
809
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
810
+                        $posy=$pdf->GetY()+2;
811
+                    }
812
+                }
813
+                if ($conf->global->FACTURE_CHQ_NUMBER == -1)
814
+                {
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;
819
+
820
+                    if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
821
+                    {
822
+                        $pdf->SetXY($this->marge_gauche, $posy);
823
+                        $pdf->SetFont('','', $default_font_size - 3);
824
+                        $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
825
+                        $posy=$pdf->GetY()+2;
826
+                    }
827
+                }
828
+            }
829
+        }
830 830
 
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))
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
838
-				$account = new Account($this->db);
839
-				$account->fetch($bankid);
834
+            if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
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
838
+                $account = new Account($this->db);
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;
847
-			}
846
+                $posy+=2;
847
+            }
848 848
         }
849 849
 
850
-		return $posy;
851
-	}
850
+        return $posy;
851
+    }
852 852
 
853 853
 
854 854
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
855
-	/**
856
-	 *	Show total to pay
857
-	 *
858
-	 *	@param	TCPDF		$pdf           Object PDF
859
-	 *	@param  Facture		$object         Object invoice
860
-	 *	@param  int			$deja_regle     Montant deja regle
861
-	 *	@param	int			$posy			Position depart
862
-	 *	@param	Translate	$outputlangs	Objet langs
863
-	 *	@return int							Position pour suite
864
-	 */
865
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
866
-	{
855
+    /**
856
+     *	Show total to pay
857
+     *
858
+     *	@param	TCPDF		$pdf           Object PDF
859
+     *	@param  Facture		$object         Object invoice
860
+     *	@param  int			$deja_regle     Montant deja regle
861
+     *	@param	int			$posy			Position depart
862
+     *	@param	Translate	$outputlangs	Objet langs
863
+     *	@return int							Position pour suite
864
+     */
865
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
866
+    {
867 867
         // phpcs:enable
868
-	    global $conf,$mysoc;
868
+        global $conf,$mysoc;
869 869
 
870
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
870
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
871 871
 
872
-		$tab2_top = $posy;
873
-		$tab2_hl = 4;
874
-		$pdf->SetFont('','', $default_font_size - 1);
872
+        $tab2_top = $posy;
873
+        $tab2_hl = 4;
874
+        $pdf->SetFont('','', $default_font_size - 1);
875 875
 
876
-		// Tableau total
876
+        // Tableau total
877 877
         $col1x = 120; $col2x = 170;
878
-		if ($this->page_largeur < 210) // To work with US executive format
879
-		{
880
-			$col2x-=20;
881
-		}
882
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
878
+        if ($this->page_largeur < 210) // To work with US executive format
879
+        {
880
+            $col2x-=20;
881
+        }
882
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 883
 
884
-		$useborder=0;
885
-		$index = 0;
884
+        $useborder=0;
885
+        $index = 0;
886 886
 
887
-		// Total HT
888
-		$pdf->SetFillColor(255,255,255);
889
-		$pdf->SetXY($col1x, $tab2_top + 0);
890
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
887
+        // Total HT
888
+        $pdf->SetFillColor(255,255,255);
889
+        $pdf->SetXY($col1x, $tab2_top + 0);
890
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
891 891
 
892
-		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
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);
892
+        $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
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);
895 895
 
896
-		// Show VAT by rates and total
897
-		$pdf->SetFillColor(248,248,248);
896
+        // Show VAT by rates and total
897
+        $pdf->SetFillColor(248,248,248);
898 898
 
899
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
899
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
900 900
 
901
-		$this->atleastoneratenotnull=0;
902
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
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)
906
-			{
907
-				// Nothing to do
908
-			}
909
-			else
910
-			{
911
-				//Local tax 1 before VAT
912
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913
-				//{
914
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
915
-					{
916
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
917
-						foreach( $localtax_rate as $tvakey => $tvaval )
918
-						{
919
-							if ($tvakey!=0)    // On affiche pas taux 0
920
-							{
921
-								//$this->atleastoneratenotnull++;
922
-
923
-								$index++;
924
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925
-
926
-								$tvacompl='';
927
-								if (preg_match('/\*/',$tvakey))
928
-								{
929
-									$tvakey=str_replace('*','',$tvakey);
930
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
935
-
936
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
937
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
938
-							}
939
-						}
940
-					}
941
-	      		//}
942
-				//Local tax 2 before VAT
943
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
944
-				//{
945
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
946
-					{
947
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
948
-						foreach( $localtax_rate as $tvakey => $tvaval )
949
-						{
950
-							if ($tvakey!=0)    // On affiche pas taux 0
951
-							{
952
-								//$this->atleastoneratenotnull++;
953
-
954
-
955
-
956
-								$index++;
957
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958
-
959
-								$tvacompl='';
960
-								if (preg_match('/\*/',$tvakey))
961
-								{
962
-									$tvakey=str_replace('*','',$tvakey);
963
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
968
-
969
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
971
-							}
972
-						}
973
-					}
974
-				//}
975
-				// VAT
976
-				foreach($this->tva as $tvakey => $tvaval)
977
-				{
978
-					if ($tvakey != 0)    // On affiche pas taux 0
979
-					{
980
-						$this->atleastoneratenotnull++;
981
-
982
-						$index++;
983
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984
-
985
-						$tvacompl='';
986
-						if (preg_match('/\*/',$tvakey))
987
-						{
988
-							$tvakey=str_replace('*','',$tvakey);
989
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
994
-
995
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
997
-					}
998
-				}
901
+        $this->atleastoneratenotnull=0;
902
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
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)
906
+            {
907
+                // Nothing to do
908
+            }
909
+            else
910
+            {
911
+                //Local tax 1 before VAT
912
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913
+                //{
914
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
915
+                    {
916
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
917
+                        foreach( $localtax_rate as $tvakey => $tvaval )
918
+                        {
919
+                            if ($tvakey!=0)    // On affiche pas taux 0
920
+                            {
921
+                                //$this->atleastoneratenotnull++;
922
+
923
+                                $index++;
924
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925
+
926
+                                $tvacompl='';
927
+                                if (preg_match('/\*/',$tvakey))
928
+                                {
929
+                                    $tvakey=str_replace('*','',$tvakey);
930
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
935
+
936
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
937
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
938
+                            }
939
+                        }
940
+                    }
941
+                    //}
942
+                //Local tax 2 before VAT
943
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
944
+                //{
945
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
946
+                    {
947
+                        if (in_array((string) $localtax_type, array('1','3','5'))) continue;
948
+                        foreach( $localtax_rate as $tvakey => $tvaval )
949
+                        {
950
+                            if ($tvakey!=0)    // On affiche pas taux 0
951
+                            {
952
+                                //$this->atleastoneratenotnull++;
953
+
954
+
955
+
956
+                                $index++;
957
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958
+
959
+                                $tvacompl='';
960
+                                if (preg_match('/\*/',$tvakey))
961
+                                {
962
+                                    $tvakey=str_replace('*','',$tvakey);
963
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
968
+
969
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
971
+                            }
972
+                        }
973
+                    }
974
+                //}
975
+                // VAT
976
+                foreach($this->tva as $tvakey => $tvaval)
977
+                {
978
+                    if ($tvakey != 0)    // On affiche pas taux 0
979
+                    {
980
+                        $this->atleastoneratenotnull++;
981
+
982
+                        $index++;
983
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984
+
985
+                        $tvacompl='';
986
+                        if (preg_match('/\*/',$tvakey))
987
+                        {
988
+                            $tvakey=str_replace('*','',$tvakey);
989
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
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);
994
+
995
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
997
+                    }
998
+                }
999
+
1000
+                //Local tax 1 after VAT
1001
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1002
+                //{
1003
+                    foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1004
+                    {
1005
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1006
+
1007
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1008
+                        {
1009
+                            if ($tvakey != 0)    // On affiche pas taux 0
1010
+                            {
1011
+                                //$this->atleastoneratenotnull++;
1012
+
1013
+                                $index++;
1014
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015
+
1016
+                                $tvacompl='';
1017
+                                if (preg_match('/\*/',$tvakey))
1018
+                                {
1019
+                                    $tvakey=str_replace('*','',$tvakey);
1020
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1021
+                                }
1022
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1023
+
1024
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1028
+                            }
1029
+                        }
1030
+                    }
1031
+                    //}
1032
+                //Local tax 2 after VAT
1033
+                //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1034
+                //{
1035
+                    foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1036
+                    {
1037
+                        if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1038
+
1039
+                        foreach( $localtax_rate as $tvakey => $tvaval )
1040
+                        {
1041
+                            if ($tvakey != 0)    // On affiche pas taux 0
1042
+                            {
1043
+                                //$this->atleastoneratenotnull++;
1044
+
1045
+                                $index++;
1046
+                                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047
+
1048
+                                $tvacompl='';
1049
+                                if (preg_match('/\*/',$tvakey))
1050
+                                {
1051
+                                    $tvakey=str_replace('*','',$tvakey);
1052
+                                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1053
+                                }
1054
+                                $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1055
+
1056
+                                $totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1057
+                                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1058
+
1059
+                                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060
+                                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1061
+                            }
1062
+                        }
1063
+                    }
1064
+                //}
1065
+
1066
+                // Total TTC
1067
+                $index++;
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);
1072
+
1073
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074
+                $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1075
+            }
1076
+        }
999 1077
 
1000
-				//Local tax 1 after VAT
1001
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
1002
-				//{
1003
-					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1004
-					{
1005
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1006
-
1007
-						foreach( $localtax_rate as $tvakey => $tvaval )
1008
-						{
1009
-							if ($tvakey != 0)    // On affiche pas taux 0
1010
-							{
1011
-								//$this->atleastoneratenotnull++;
1012
-
1013
-								$index++;
1014
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015
-
1016
-								$tvacompl='';
1017
-								if (preg_match('/\*/',$tvakey))
1018
-								{
1019
-									$tvakey=str_replace('*','',$tvakey);
1020
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1021
-								}
1022
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
1023
-
1024
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1025
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1026
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1027
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1028
-							}
1029
-						}
1030
-					}
1031
-	      		//}
1032
-				//Local tax 2 after VAT
1033
-				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
1034
-				//{
1035
-					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1036
-					{
1037
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1038
-
1039
-						foreach( $localtax_rate as $tvakey => $tvaval )
1040
-						{
1041
-							if ($tvakey != 0)    // On affiche pas taux 0
1042
-							{
1043
-								//$this->atleastoneratenotnull++;
1044
-
1045
-								$index++;
1046
-								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047
-
1048
-								$tvacompl='';
1049
-								if (preg_match('/\*/',$tvakey))
1050
-								{
1051
-									$tvakey=str_replace('*','',$tvakey);
1052
-									$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1053
-								}
1054
-								$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
1055
-
1056
-								$totalvat.=vatrate(abs($tvakey),1).$tvacompl;
1057
-								$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1058
-
1059
-								$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1060
-								$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
1061
-							}
1062
-						}
1063
-					}
1064
-				//}
1065
-
1066
-				// Total TTC
1067
-				$index++;
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);
1072
-
1073
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074
-				$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1075
-			}
1076
-		}
1077
-
1078
-		$pdf->SetTextColor(0,0,0);
1078
+        $pdf->SetTextColor(0,0,0);
1079 1079
 
1080 1080
         $creditnoteamount=0;
1081 1081
         $depositsamount=0;
1082
-		//$creditnoteamount=$object->getSumCreditNotesUsed();
1083
-		//$depositsamount=$object->getSumDepositsUsed();
1084
-		//print "x".$creditnoteamount."-".$depositsamount;exit;
1085
-		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
-		if (! empty($object->paye)) $resteapayer=0;
1082
+        //$creditnoteamount=$object->getSumCreditNotesUsed();
1083
+        //$depositsamount=$object->getSumDepositsUsed();
1084
+        //print "x".$creditnoteamount."-".$depositsamount;exit;
1085
+        $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
+        if (! empty($object->paye)) $resteapayer=0;
1087 1087
 
1088
-		if ($deja_regle > 0)
1089
-		{
1090
-			// Already paid + Deposits
1091
-			$index++;
1092
-
1093
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1095
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1097
-
1098
-			$index++;
1099
-			$pdf->SetTextColor(0,0,60);
1100
-			$pdf->SetFillColor(224,224,224);
1101
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1103
-
1104
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1106
-
1107
-			$pdf->SetFont('','', $default_font_size - 1);
1108
-			$pdf->SetTextColor(0,0,0);
1109
-		}
1110
-
1111
-		$index++;
1112
-		return ($tab2_top + ($tab2_hl * $index));
1113
-	}
1114
-
1115
-	/**
1116
-	 *   Show table for lines
1117
-	 *
1118
-	 *   @param		TCPDF		$pdf     		Object PDF
1119
-	 *   @param		string		$tab_top		Top position of table
1120
-	 *   @param		string		$tab_height		Height of table (rectangle)
1121
-	 *   @param		int			$nexY			Y (not used)
1122
-	 *   @param		Translate	$outputlangs	Langs object
1123
-	 *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1124
-	 *   @param		int			$hidebottom		Hide bottom bar of array
1125
-	 *   @param		string		$currency		Currency code
1126
-	 *   @return	void
1127
-	 */
1128
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1129
-	{
1130
-		global $conf;
1131
-
1132
-		// Force to disable hidetop and hidebottom
1133
-		$hidebottom=0;
1134
-		if ($hidetop) $hidetop=-1;
1135
-
1136
-		$currency = !empty($currency) ? $currency : $conf->currency;
1137
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1138
-
1139
-		// Amount in (at tab_top - 1)
1140
-		$pdf->SetTextColor(0,0,0);
1141
-		$pdf->SetFont('','', $default_font_size - 2);
1142
-
1143
-		if (empty($hidetop))
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);
1147
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1088
+        if ($deja_regle > 0)
1089
+        {
1090
+            // Already paid + Deposits
1091
+            $index++;
1148 1092
 
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));
1151
-		}
1093
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
1095
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1096
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle, 0, $outputlangs), 0, 'R', 0);
1152 1097
 
1153
-		$pdf->SetDrawColor(128,128,128);
1154
-		$pdf->SetFont('','', $default_font_size - 1);
1098
+            $index++;
1099
+            $pdf->SetTextColor(0,0,60);
1100
+            $pdf->SetFillColor(224,224,224);
1101
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1102
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
1155 1103
 
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
1104
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer, 0, $outputlangs), $useborder, 'R', 1);
1158 1106
 
1159
-		if (empty($hidetop))
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
1107
+            $pdf->SetFont('','', $default_font_size - 1);
1108
+            $pdf->SetTextColor(0,0,0);
1109
+        }
1162 1110
 
1163
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
1164
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1165
-		}
1111
+        $index++;
1112
+        return ($tab2_top + ($tab2_hl * $index));
1113
+    }
1166 1114
 
1167
-		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1168
-		{
1169
-			$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1170
-			if (empty($hidetop))
1171
-			{
1172
-				$pdf->SetXY($this->posxtva-3, $tab_top+1);
1173
-				$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1174
-			}
1175
-		}
1176
-
1177
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1178
-		if (empty($hidetop))
1179
-		{
1180
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
1181
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1182
-		}
1115
+    /**
1116
+     *   Show table for lines
1117
+     *
1118
+     *   @param		TCPDF		$pdf     		Object PDF
1119
+     *   @param		string		$tab_top		Top position of table
1120
+     *   @param		string		$tab_height		Height of table (rectangle)
1121
+     *   @param		int			$nexY			Y (not used)
1122
+     *   @param		Translate	$outputlangs	Langs object
1123
+     *   @param		int			$hidetop		1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
1124
+     *   @param		int			$hidebottom		Hide bottom bar of array
1125
+     *   @param		string		$currency		Currency code
1126
+     *   @return	void
1127
+     */
1128
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1129
+    {
1130
+        global $conf;
1183 1131
 
1184
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1185
-		if (empty($hidetop))
1186
-		{
1187
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
1188
-			if($conf->global->PRODUCT_USE_UNITS)
1189
-			{
1190
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1191
-			}
1192
-			else
1193
-			{
1194
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1195
-			}
1196
-		}
1197
-
1198
-		if($conf->global->PRODUCT_USE_UNITS) {
1199
-			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1200
-			if (empty($hidetop)) {
1201
-				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1202
-				$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1203
-					'C');
1204
-			}
1205
-		}
1206
-
1207
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1208
-		if (empty($hidetop))
1209
-		{
1210
-			if ($this->atleastonediscount)
1211
-			{
1212
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1213
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1214
-			}
1215
-		}
1216
-
1217
-		if ($this->atleastonediscount)
1218
-		{
1219
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1220
-		}
1221
-		if (empty($hidetop))
1222
-		{
1223
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
1224
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1225
-		}
1226
-	}
1227
-
1228
-	/**
1229
-	 *  Show top header of page.
1230
-	 *
1231
-	 *  @param	TCPDF		$pdf     		Object PDF
1232
-	 *  @param  Object		$object     	Object to show
1233
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1234
-	 *  @param  Translate	$outputlangs	Object lang for output
1235
-	 *  @param	string		$titlekey		Translation key to show as title of document
1236
-	 *  @return	void
1237
-	 */
1238
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1239
-	{
1240
-		global $conf,$langs,$hookmanager;
1241
-
1242
-		// Load traductions files requiredby by page
1243
-		$outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1244
-
1245
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1246
-
1247
-		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1248
-
1249
-		// Show Draft Watermark
1250
-		if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1251
-		{
1132
+        // Force to disable hidetop and hidebottom
1133
+        $hidebottom=0;
1134
+        if ($hidetop) $hidetop=-1;
1135
+
1136
+        $currency = !empty($currency) ? $currency : $conf->currency;
1137
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1138
+
1139
+        // Amount in (at tab_top - 1)
1140
+        $pdf->SetTextColor(0,0,0);
1141
+        $pdf->SetFont('','', $default_font_size - 2);
1142
+
1143
+        if (empty($hidetop))
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);
1147
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1148
+
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));
1151
+        }
1152
+
1153
+        $pdf->SetDrawColor(128,128,128);
1154
+        $pdf->SetFont('','', $default_font_size - 1);
1155
+
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
1158
+
1159
+        if (empty($hidetop))
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
1162
+
1163
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
1164
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
1165
+        }
1166
+
1167
+        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1168
+        {
1169
+            $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
1170
+            if (empty($hidetop))
1171
+            {
1172
+                $pdf->SetXY($this->posxtva-3, $tab_top+1);
1173
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
1174
+            }
1175
+        }
1176
+
1177
+        $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
1178
+        if (empty($hidetop))
1179
+        {
1180
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
1181
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
1182
+        }
1183
+
1184
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
1185
+        if (empty($hidetop))
1186
+        {
1187
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
1188
+            if($conf->global->PRODUCT_USE_UNITS)
1189
+            {
1190
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1191
+            }
1192
+            else
1193
+            {
1194
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1195
+            }
1196
+        }
1197
+
1198
+        if($conf->global->PRODUCT_USE_UNITS) {
1199
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1200
+            if (empty($hidetop)) {
1201
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1202
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
1203
+                    'C');
1204
+            }
1205
+        }
1206
+
1207
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
1208
+        if (empty($hidetop))
1209
+        {
1210
+            if ($this->atleastonediscount)
1211
+            {
1212
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
1213
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
1214
+            }
1215
+        }
1216
+
1217
+        if ($this->atleastonediscount)
1218
+        {
1219
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1220
+        }
1221
+        if (empty($hidetop))
1222
+        {
1223
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
1224
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C');
1225
+        }
1226
+    }
1227
+
1228
+    /**
1229
+     *  Show top header of page.
1230
+     *
1231
+     *  @param	TCPDF		$pdf     		Object PDF
1232
+     *  @param  Object		$object     	Object to show
1233
+     *  @param  int	    	$showaddress    0=no, 1=yes
1234
+     *  @param  Translate	$outputlangs	Object lang for output
1235
+     *  @param	string		$titlekey		Translation key to show as title of document
1236
+     *  @return	void
1237
+     */
1238
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
1239
+    {
1240
+        global $conf,$langs,$hookmanager;
1241
+
1242
+        // Load traductions files requiredby by page
1243
+        $outputlangs->loadLangs(array("main", "bills", "propal", "orders", "companies"));
1244
+
1245
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1246
+
1247
+        pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1248
+
1249
+        // Show Draft Watermark
1250
+        if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
1251
+        {
1252 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
-		// Logo
1264
-		if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1265
-		{
1266
-			$logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1267
-			if ($this->emetteur->logo)
1268
-			{
1269
-				if (is_readable($logo))
1270
-				{
1271
-				    $height=pdf_getHeightForLogo($logo);
1272
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1273
-				}
1274
-				else
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');
1279
-					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280
-				}
1281
-			}
1282
-			else
1283
-			{
1284
-				$text=$this->emetteur->name;
1285
-				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1286
-			}
1287
-		}
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);
1293
-		$pdf->MultiCell(100, 3, $title, '', 'R');
1294
-
1295
-		$pdf->SetFont('','B',$default_font_size);
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');
1301
-
1302
-		$posy+=1;
1303
-		$pdf->SetFont('','', $default_font_size - 1);
1304
-
1305
-		if ($object->ref_client)
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');
1311
-		}
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');
1317
-
1318
-		// Get contact
1319
-		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1320
-		{
1321
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1322
-		    if (count($arrayidcontact) > 0)
1323
-		    {
1263
+        // Logo
1264
+        if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1265
+        {
1266
+            $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
1267
+            if ($this->emetteur->logo)
1268
+            {
1269
+                if (is_readable($logo))
1270
+                {
1271
+                    $height=pdf_getHeightForLogo($logo);
1272
+                    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1273
+                }
1274
+                else
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');
1279
+                    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280
+                }
1281
+            }
1282
+            else
1283
+            {
1284
+                $text=$this->emetteur->name;
1285
+                $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1286
+            }
1287
+        }
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);
1293
+        $pdf->MultiCell(100, 3, $title, '', 'R');
1294
+
1295
+        $pdf->SetFont('','B',$default_font_size);
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');
1301
+
1302
+        $posy+=1;
1303
+        $pdf->SetFont('','', $default_font_size - 1);
1304
+
1305
+        if ($object->ref_client)
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');
1311
+        }
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');
1317
+
1318
+        // Get contact
1319
+        if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1320
+        {
1321
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1322
+            if (count($arrayidcontact) > 0)
1323
+            {
1324 1324
                 $usertmp=new User($this->db);
1325
-		        $usertmp->fetch($arrayidcontact[0]);
1325
+                $usertmp->fetch($arrayidcontact[0]);
1326 1326
                 $posy+=4;
1327 1327
                 $pdf->SetXY($posx,$posy);
1328
-		        $pdf->SetTextColor(0,0,60);
1329
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1330
-		    }
1331
-		}
1332
-
1333
-		$posy+=2;
1334
-
1335
-		$top_shift = 0;
1336
-		// Show list of linked objects
1337
-		$current_y = $pdf->getY();
1338
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1339
-		if ($current_y < $pdf->getY())
1340
-		{
1341
-			$top_shift = $pdf->getY() - $current_y;
1342
-		}
1328
+                $pdf->SetTextColor(0,0,60);
1329
+                $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1330
+            }
1331
+        }
1343 1332
 
1344
-		if ($showaddress)
1345
-		{
1346
-			// Sender properties
1347
-			$carac_emetteur='';
1348
-		 	// Add internal contact of proposal if defined
1349
-			$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1350
-		 	if (count($arrayidcontact) > 0)
1351
-		 	{
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";
1355
-		 	}
1356
-
1357
-		 	$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1358
-
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;
1364
-
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);
1372
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1373
-			$pdf->SetTextColor(0,0,60);
1374
-
1375
-			// Show sender name
1376
-			$pdf->SetXY($posx+2,$posy+3);
1377
-			$pdf->SetFont('','B', $default_font_size);
1378
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1379
-			$posy=$pdf->getY();
1380
-
1381
-			// Show sender information
1382
-			$pdf->SetXY($posx+2,$posy);
1383
-			$pdf->SetFont('','', $default_font_size - 1);
1384
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1385
-
1386
-
1387
-
1388
-			// If CUSTOMER contact defined on order, we use it
1389
-			$usecontact=false;
1390
-			$arrayidcontact=$object->getIdContact('external','CUSTOMER');
1391
-			if (count($arrayidcontact) > 0)
1392
-			{
1393
-				$usecontact=true;
1394
-				$result=$object->fetch_contact($arrayidcontact[0]);
1395
-			}
1396
-
1397
-			//Recipient name
1398
-			// On peut utiliser le nom de la societe du contact
1399
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1400
-				$thirdparty = $object->contact;
1401
-			} else {
1402
-				$thirdparty = $object->thirdparty;
1403
-			}
1404
-
1405
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1406
-
1407
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1408
-
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;
1415
-
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');
1421
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1422
-
1423
-			// Show recipient name
1424
-			$pdf->SetXY($posx+2,$posy+3);
1425
-			$pdf->SetFont('','B', $default_font_size);
1426
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1427
-
1428
-			$posy = $pdf->getY();
1429
-
1430
-			// Show recipient information
1431
-			$pdf->SetFont('','', $default_font_size - 1);
1432
-			$pdf->SetXY($posx+2,$posy);
1433
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1434
-		}
1435
-
1436
-		$pdf->SetTextColor(0,0,0);
1437
-		return $top_shift;
1438
-	}
1439
-
1440
-	/**
1441
-	 *   	Show footer of page. Need this->emetteur object
1333
+        $posy+=2;
1334
+
1335
+        $top_shift = 0;
1336
+        // Show list of linked objects
1337
+        $current_y = $pdf->getY();
1338
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1339
+        if ($current_y < $pdf->getY())
1340
+        {
1341
+            $top_shift = $pdf->getY() - $current_y;
1342
+        }
1343
+
1344
+        if ($showaddress)
1345
+        {
1346
+            // Sender properties
1347
+            $carac_emetteur='';
1348
+                // Add internal contact of proposal if defined
1349
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1350
+                if (count($arrayidcontact) > 0)
1351
+                {
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";
1355
+                }
1356
+
1357
+                $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1358
+
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;
1364
+
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);
1372
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1373
+            $pdf->SetTextColor(0,0,60);
1374
+
1375
+            // Show sender name
1376
+            $pdf->SetXY($posx+2,$posy+3);
1377
+            $pdf->SetFont('','B', $default_font_size);
1378
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1379
+            $posy=$pdf->getY();
1380
+
1381
+            // Show sender information
1382
+            $pdf->SetXY($posx+2,$posy);
1383
+            $pdf->SetFont('','', $default_font_size - 1);
1384
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1385
+
1386
+
1387
+
1388
+            // If CUSTOMER contact defined on order, we use it
1389
+            $usecontact=false;
1390
+            $arrayidcontact=$object->getIdContact('external','CUSTOMER');
1391
+            if (count($arrayidcontact) > 0)
1392
+            {
1393
+                $usecontact=true;
1394
+                $result=$object->fetch_contact($arrayidcontact[0]);
1395
+            }
1396
+
1397
+            //Recipient name
1398
+            // On peut utiliser le nom de la societe du contact
1399
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1400
+                $thirdparty = $object->contact;
1401
+            } else {
1402
+                $thirdparty = $object->thirdparty;
1403
+            }
1404
+
1405
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1406
+
1407
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target', $object);
1408
+
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;
1415
+
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');
1421
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1422
+
1423
+            // Show recipient name
1424
+            $pdf->SetXY($posx+2,$posy+3);
1425
+            $pdf->SetFont('','B', $default_font_size);
1426
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1427
+
1428
+            $posy = $pdf->getY();
1429
+
1430
+            // Show recipient information
1431
+            $pdf->SetFont('','', $default_font_size - 1);
1432
+            $pdf->SetXY($posx+2,$posy);
1433
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1434
+        }
1435
+
1436
+        $pdf->SetTextColor(0,0,0);
1437
+        return $top_shift;
1438
+    }
1439
+
1440
+    /**
1441
+     *   	Show footer of page. Need this->emetteur object
1442 1442
      *
1443
-	 *   	@param	TCPDF		$pdf     			PDF
1444
-	 * 		@param	Object		$object				Object to show
1445
-	 *      @param	Translate	$outputlangs		Object lang for output
1446
-	 *      @param	int			$hidefreetext		1=Hide free text
1447
-	 *      @return	int								Return height of bottom margin including footer text
1448
-	 */
1449
-	function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1450
-	{
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);
1454
-	}
1443
+     *   	@param	TCPDF		$pdf     			PDF
1444
+     * 		@param	Object		$object				Object to show
1445
+     *      @param	Translate	$outputlangs		Object lang for output
1446
+     *      @param	int			$hidefreetext		1=Hide free text
1447
+     *      @return	int								Return height of bottom margin including footer text
1448
+     */
1449
+    function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
1450
+    {
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);
1454
+    }
1455 1455
 }
Please login to merge, or discard this 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.
Braces   +158 added lines, -80 removed lines patch added patch discarded remove patch
@@ -164,7 +164,10 @@  discard block
 block discarded – undo
164 164
 
165 165
 		// Get source company
166 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
167
+		if (empty($this->emetteur->country_code)) {
168
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
169
+		}
170
+		// By default, if was not defined
168 171
 
169 172
 		// Define position of columns
170 173
 		$this->posxdesc=$this->marge_gauche+1;
@@ -174,8 +177,7 @@  discard block
 block discarded – undo
174 177
 			$this->posxup=118;
175 178
 			$this->posxqty=135;
176 179
 			$this->posxunit=151;
177
-		}
178
-		else
180
+		} else
179 181
 		{
180 182
 			$this->posxtva=110;
181 183
 			$this->posxup=126;
@@ -183,11 +185,15 @@  discard block
 block discarded – undo
183 185
 		}
184 186
 		$this->posxdiscount=162;
185 187
 		$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;
188
+		if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
189
+		    $this->posxtva=$this->posxup;
190
+		}
187 191
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
188
-		if ($this->page_largeur < 210) // To work with US executive format
192
+		if ($this->page_largeur < 210) {
193
+		    // To work with US executive format
189 194
 		{
190 195
 			$this->posxpicture-=20;
196
+		}
191 197
 			$this->posxtva-=20;
192 198
 			$this->posxup-=20;
193 199
 			$this->posxqty-=20;
@@ -220,9 +226,13 @@  discard block
 block discarded – undo
220 226
         // phpcs:enable
221 227
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
222 228
 
223
-		if (! is_object($outputlangs)) $outputlangs=$langs;
229
+		if (! is_object($outputlangs)) {
230
+		    $outputlangs=$langs;
231
+		}
224 232
 		// 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';
233
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
234
+		    $outputlangs->charset_output='ISO-8859-1';
235
+		}
226 236
 
227 237
 		// Load translation files required by the page
228 238
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries"));
@@ -240,8 +250,7 @@  discard block
 block discarded – undo
240 250
 			{
241 251
 				$dir = $conf->commande->dir_output;
242 252
 				$file = $dir . "/SPECIMEN.pdf";
243
-			}
244
-			else
253
+			} else
245 254
 			{
246 255
 				$objectref = dol_sanitizeFileName($object->ref);
247 256
 				$dir = $conf->commande->dir_output . "/" . $objectref;
@@ -278,7 +287,9 @@  discard block
 block discarded – undo
278 287
 				$heightforinfotot = 40;	// Height reserved to output the info and total part
279 288
 		        $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 289
 	            $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;
290
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
291
+	                $heightforfooter+= 6;
292
+	            }
282 293
 
283 294
                 if (class_exists('TCPDF'))
284 295
                 {
@@ -302,7 +313,9 @@  discard block
 block discarded – undo
302 313
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
303 314
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
304 315
 				$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);
316
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
317
+				    $pdf->SetCompression(false);
318
+				}
306 319
 
307 320
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
308 321
 
@@ -326,7 +339,9 @@  discard block
 block discarded – undo
326 339
 
327 340
 				// New page
328 341
 				$pdf->AddPage();
329
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
342
+				if (! empty($tplidx)) {
343
+				    $pdf->useTemplate($tplidx);
344
+				}
330 345
 				$pagenb++;
331 346
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
332 347
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -368,7 +383,9 @@  discard block
 block discarded – undo
368 383
 						$salereparray=$object->thirdparty->getSalesRepresentatives($user);
369 384
 						$salerepobj=new User($this->db);
370 385
 						$salerepobj->fetch($salereparray[0]['id']);
371
-						if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
386
+						if (! empty($salerepobj->signature)) {
387
+						    $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
388
+						}
372 389
 					}
373 390
 				}
374 391
 				if ($notetoshow)
@@ -414,32 +431,38 @@  discard block
 block discarded – undo
414 431
 					$pdf->startTransaction();
415 432
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc);
416 433
 					$pageposafter=$pdf->getPage();
417
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
434
+					if ($pageposafter > $pageposbefore) {
435
+					    // There is a pagebreak
418 436
 					{
419 437
 						$pdf->rollbackTransaction(true);
438
+					}
420 439
 						$pageposafter=$pageposbefore;
421 440
 						//print $pageposafter.'-'.$pageposbefore;exit;
422 441
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
423 442
 						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc);
424 443
 						$pageposafter=$pdf->getPage();
425 444
 						$posyafter=$pdf->GetY();
426
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
445
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
446
+						    // There is no space left for total+free text
427 447
 						{
428 448
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
429 449
 							{
430 450
 								$pdf->AddPage('','',true);
431
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
432
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
451
+						}
452
+								if (! empty($tplidx)) {
453
+								    $pdf->useTemplate($tplidx);
454
+								}
455
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
456
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
457
+								}
433 458
 								$pdf->setPage($pageposafter+1);
434 459
 							}
435
-						}
436
-						else
460
+						} else
437 461
 						{
438 462
 							// We found a page break
439 463
 							$showpricebeforepagebreak=0;
440 464
 						}
441
-					}
442
-					else	// No pagebreak
465
+					} else	// No pagebreak
443 466
 					{
444 467
 						$pdf->commitTransaction();
445 468
 					}
@@ -479,8 +502,7 @@  discard block
 block discarded – undo
479 502
 					if($conf->global->PRODUCT_USE_UNITS)
480 503
 					{
481 504
 						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
482
-					}
483
-					else
505
+					} else
484 506
 					{
485 507
 						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
486 508
 					}
@@ -508,8 +530,11 @@  discard block
 block discarded – undo
508 530
 					$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
509 531
 
510 532
 					// 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;
533
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
534
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
535
+					} else {
536
+					    $tvaligne=$object->lines[$i]->total_tva;
537
+					}
513 538
 
514 539
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
515 540
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
@@ -518,29 +543,43 @@  discard block
 block discarded – undo
518 543
 					$localtax1_type=$object->lines[$i]->localtax1_type;
519 544
 					$localtax2_type=$object->lines[$i]->localtax2_type;
520 545
 
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;
546
+					if ($object->remise_percent) {
547
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
548
+					}
549
+					if ($object->remise_percent) {
550
+					    $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
551
+					}
552
+					if ($object->remise_percent) {
553
+					    $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
554
+					}
524 555
 
525 556
 					$vatrate=(string) $object->lines[$i]->tva_tx;
526 557
 
527 558
 					// Retrieve type from database for backward compatibility with old records
528 559
 					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
560
+					&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) {
561
+					    // and there is local tax
530 562
 					{
531 563
 						$localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc);
564
+					}
532 565
 						$localtax1_type = $localtaxtmp_array[0];
533 566
 						$localtax2_type = $localtaxtmp_array[2];
534 567
 					}
535 568
 
536 569
 				    // retrieve global local tax
537
-					if ($localtax1_type && $localtax1ligne != 0)
538
-						$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
539
-					if ($localtax2_type && $localtax2ligne != 0)
540
-						$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
570
+					if ($localtax1_type && $localtax1ligne != 0) {
571
+											$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
572
+					}
573
+					if ($localtax2_type && $localtax2ligne != 0) {
574
+											$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
575
+					}
541 576
 
542
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
543
-					if (! isset($this->tva[$vatrate])) 				$this->tva[$vatrate]=0;
577
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
578
+					    $vatrate.='*';
579
+					}
580
+					if (! isset($this->tva[$vatrate])) {
581
+					    $this->tva[$vatrate]=0;
582
+					}
544 583
 					$this->tva[$vatrate] += $tvaligne;
545 584
 
546 585
 					// Add line
@@ -562,8 +601,7 @@  discard block
 block discarded – undo
562 601
 						if ($pagenb == 1)
563 602
 						{
564 603
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
565
-						}
566
-						else
604
+						} else
567 605
 						{
568 606
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
569 607
 						}
@@ -571,32 +609,38 @@  discard block
 block discarded – undo
571 609
 						$pagenb++;
572 610
 						$pdf->setPage($pagenb);
573 611
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
574
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
612
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
613
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
614
+						}
575 615
 					}
576 616
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
577 617
 					{
578 618
 						if ($pagenb == 1)
579 619
 						{
580 620
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
581
-						}
582
-						else
621
+						} else
583 622
 						{
584 623
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
585 624
 						}
586 625
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
587 626
 						// New page
588 627
 						$pdf->AddPage();
589
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
628
+						if (! empty($tplidx)) {
629
+						    $pdf->useTemplate($tplidx);
630
+						}
590 631
 						$pagenb++;
591
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
632
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
633
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
634
+						}
592 635
 					}
593 636
 				}
594 637
 
595 638
 				// Show square
596
-				if ($pagenb == 1)
597
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
598
-				else
599
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
639
+				if ($pagenb == 1) {
640
+									$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
641
+				} else {
642
+									$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
643
+				}
600 644
 				$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
601 645
 
602 646
 				// Affiche zone infos
@@ -615,7 +659,9 @@  discard block
 block discarded – undo
615 659
 
616 660
 				// Pied de page
617 661
 				$this->_pagefoot($pdf, $object, $outputlangs);
618
-				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
662
+				if (method_exists($pdf, 'AliasNbPages')) {
663
+				    $pdf->AliasNbPages();
664
+				}
619 665
 
620 666
 				$pdf->Close();
621 667
 
@@ -627,20 +673,19 @@  discard block
 block discarded – undo
627 673
 				global $action;
628 674
 				$reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action);    // Note that $action and $object may have been modified by some hooks
629 675
 
630
-				if (! empty($conf->global->MAIN_UMASK))
631
-					@chmod($file, octdec($conf->global->MAIN_UMASK));
676
+				if (! empty($conf->global->MAIN_UMASK)) {
677
+									@chmod($file, octdec($conf->global->MAIN_UMASK));
678
+				}
632 679
 
633 680
 				$this->result = array('fullpath'=>$file);
634 681
 
635 682
 				return 1;   // Pas d'erreur
636
-			}
637
-			else
683
+			} else
638 684
 			{
639 685
 				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
640 686
 				return 0;
641 687
 			}
642
-		}
643
-		else
688
+		} else
644 689
 		{
645 690
 			$this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR");
646 691
 			return 0;
@@ -751,10 +796,11 @@  discard block
 block discarded – undo
751 796
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
752 797
 
753 798
             $posy=$pdf->GetY()+1;
754
-		}
755
-        elseif ($object->availability_code || $object->availability)    // Show availability conditions
799
+		} elseif ($object->availability_code || $object->availability) {
800
+            // Show availability conditions
756 801
 		{
757 802
 			$pdf->SetFont('','B', $default_font_size - 2);
803
+        }
758 804
 			$pdf->SetXY($this->marge_gauche, $posy);
759 805
 			$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
760 806
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
@@ -834,7 +880,10 @@  discard block
 block discarded – undo
834 880
 			if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER))
835 881
 			{
836 882
 				$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
883
+				if (! empty($object->fk_bank)) {
884
+				    $bankid=$object->fk_bank;
885
+				}
886
+				// For backward compatibility when object->fk_account is forced with object->fk_bank
838 887
 				$account = new Account($this->db);
839 888
 				$account->fetch($bankid);
840 889
 
@@ -875,10 +924,12 @@  discard block
 block discarded – undo
875 924
 
876 925
 		// Tableau total
877 926
         $col1x = 120; $col2x = 170;
878
-		if ($this->page_largeur < 210) // To work with US executive format
927
+		if ($this->page_largeur < 210) {
928
+		    // To work with US executive format
879 929
 		{
880 930
 			$col2x-=20;
881 931
 		}
932
+		}
882 933
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
883 934
 
884 935
 		$useborder=0;
@@ -905,22 +956,25 @@  discard block
 block discarded – undo
905 956
 			if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
906 957
 			{
907 958
 				// Nothing to do
908
-			}
909
-			else
959
+			} else
910 960
 			{
911 961
 				//Local tax 1 before VAT
912 962
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
913 963
 				//{
914 964
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
915 965
 					{
916
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
966
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
967
+						    continue;
968
+						}
917 969
 						foreach( $localtax_rate as $tvakey => $tvaval )
918 970
 						{
919
-							if ($tvakey!=0)    // On affiche pas taux 0
971
+							if ($tvakey!=0) {
972
+							    // On affiche pas taux 0
920 973
 							{
921 974
 								//$this->atleastoneratenotnull++;
922 975
 
923 976
 								$index++;
977
+							}
924 978
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
925 979
 
926 980
 								$tvacompl='';
@@ -944,16 +998,20 @@  discard block
 block discarded – undo
944 998
 				//{
945 999
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
946 1000
 					{
947
-						if (in_array((string) $localtax_type, array('1','3','5'))) continue;
1001
+						if (in_array((string) $localtax_type, array('1','3','5'))) {
1002
+						    continue;
1003
+						}
948 1004
 						foreach( $localtax_rate as $tvakey => $tvaval )
949 1005
 						{
950
-							if ($tvakey!=0)    // On affiche pas taux 0
1006
+							if ($tvakey!=0) {
1007
+							    // On affiche pas taux 0
951 1008
 							{
952 1009
 								//$this->atleastoneratenotnull++;
953 1010
 
954 1011
 
955 1012
 
956 1013
 								$index++;
1014
+							}
957 1015
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
958 1016
 
959 1017
 								$tvacompl='';
@@ -975,9 +1033,11 @@  discard block
 block discarded – undo
975 1033
 				// VAT
976 1034
 				foreach($this->tva as $tvakey => $tvaval)
977 1035
 				{
978
-					if ($tvakey != 0)    // On affiche pas taux 0
1036
+					if ($tvakey != 0) {
1037
+					    // On affiche pas taux 0
979 1038
 					{
980 1039
 						$this->atleastoneratenotnull++;
1040
+					}
981 1041
 
982 1042
 						$index++;
983 1043
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1002,15 +1062,19 @@  discard block
 block discarded – undo
1002 1062
 				//{
1003 1063
 					foreach( $this->localtax1 as $localtax_type => $localtax_rate )
1004 1064
 					{
1005
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1065
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1066
+						    continue;
1067
+						}
1006 1068
 
1007 1069
 						foreach( $localtax_rate as $tvakey => $tvaval )
1008 1070
 						{
1009
-							if ($tvakey != 0)    // On affiche pas taux 0
1071
+							if ($tvakey != 0) {
1072
+							    // On affiche pas taux 0
1010 1073
 							{
1011 1074
 								//$this->atleastoneratenotnull++;
1012 1075
 
1013 1076
 								$index++;
1077
+							}
1014 1078
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1015 1079
 
1016 1080
 								$tvacompl='';
@@ -1034,15 +1098,19 @@  discard block
 block discarded – undo
1034 1098
 				//{
1035 1099
 					foreach( $this->localtax2 as $localtax_type => $localtax_rate )
1036 1100
 					{
1037
-						if (in_array((string) $localtax_type, array('2','4','6'))) continue;
1101
+						if (in_array((string) $localtax_type, array('2','4','6'))) {
1102
+						    continue;
1103
+						}
1038 1104
 
1039 1105
 						foreach( $localtax_rate as $tvakey => $tvaval )
1040 1106
 						{
1041
-							if ($tvakey != 0)    // On affiche pas taux 0
1107
+							if ($tvakey != 0) {
1108
+							    // On affiche pas taux 0
1042 1109
 							{
1043 1110
 								//$this->atleastoneratenotnull++;
1044 1111
 
1045 1112
 								$index++;
1113
+							}
1046 1114
 								$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047 1115
 
1048 1116
 								$tvacompl='';
@@ -1083,7 +1151,9 @@  discard block
 block discarded – undo
1083 1151
 		//$depositsamount=$object->getSumDepositsUsed();
1084 1152
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
1085 1153
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
1086
-		if (! empty($object->paye)) $resteapayer=0;
1154
+		if (! empty($object->paye)) {
1155
+		    $resteapayer=0;
1156
+		}
1087 1157
 
1088 1158
 		if ($deja_regle > 0)
1089 1159
 		{
@@ -1131,7 +1201,9 @@  discard block
 block discarded – undo
1131 1201
 
1132 1202
 		// Force to disable hidetop and hidebottom
1133 1203
 		$hidebottom=0;
1134
-		if ($hidetop) $hidetop=-1;
1204
+		if ($hidetop) {
1205
+		    $hidetop=-1;
1206
+		}
1135 1207
 
1136 1208
 		$currency = !empty($currency) ? $currency : $conf->currency;
1137 1209
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1147,7 +1219,9 @@  discard block
 block discarded – undo
1147 1219
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1148 1220
 
1149 1221
 			//$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));
1222
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1223
+			    $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));
1224
+			}
1151 1225
 		}
1152 1226
 
1153 1227
 		$pdf->SetDrawColor(128,128,128);
@@ -1188,8 +1262,7 @@  discard block
 block discarded – undo
1188 1262
 			if($conf->global->PRODUCT_USE_UNITS)
1189 1263
 			{
1190 1264
 				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1191
-			}
1192
-			else
1265
+			} else
1193 1266
 			{
1194 1267
 				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
1195 1268
 			}
@@ -1270,16 +1343,14 @@  discard block
 block discarded – undo
1270 1343
 				{
1271 1344
 				    $height=pdf_getHeightForLogo($logo);
1272 1345
 				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1273
-				}
1274
-				else
1346
+				} else
1275 1347
 				{
1276 1348
 					$pdf->SetTextColor(200,0,0);
1277 1349
 					$pdf->SetFont('','B', $default_font_size -2);
1278 1350
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1279 1351
 					$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1280 1352
 				}
1281
-			}
1282
-			else
1353
+			} else
1283 1354
 			{
1284 1355
 				$text=$this->emetteur->name;
1285 1356
 				$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1359,7 +1430,9 @@  discard block
 block discarded – undo
1359 1430
 			// Show sender
1360 1431
 			$posy=42+$top_shift;
1361 1432
 			$posx=$this->marge_gauche;
1362
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1433
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1434
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1435
+			}
1363 1436
 			$hautcadre=40;
1364 1437
 
1365 1438
 			// Show sender frame
@@ -1408,10 +1481,15 @@  discard block
 block discarded – undo
1408 1481
 
1409 1482
 			// Show recipient
1410 1483
 			$widthrecbox=100;
1411
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1484
+			if ($this->page_largeur < 210) {
1485
+			    $widthrecbox=84;
1486
+			}
1487
+			// To work with US executive format
1412 1488
 			$posy=42+$top_shift;
1413 1489
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1414
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1490
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1491
+			    $posx=$this->marge_gauche;
1492
+			}
1415 1493
 
1416 1494
 			// Show recipient frame
1417 1495
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.