Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
dolibarr/htdocs/core/modules/modBookmark.class.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -33,73 +33,73 @@
 block discarded – undo
33 33
 class modBookmark extends DolibarrModules
34 34
 {
35 35
 
36
-	/**
37
-	 *   Constructor. Define names, constants, directories, boxes, permissions
38
-	 *
39
-	 *   @param      DoliDB		$db      Database handler
40
-	 */
41
-	function __construct($db)
42
-	{
43
-		$this->db = $db;
44
-		$this->numero = 330;
45
-
46
-		$this->family = "technic";
47
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
48
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
-		$this->description = "Gestion des Bookmarks";
50
-
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
-		$this->version = 'dolibarr';
53
-
54
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55
-		$this->picto='bookmark';
56
-
57
-		// Data directories to create when module is enabled
58
-		$this->dirs = array();
59
-
60
-		// Dependancies
61
-		$this->depends = array();
62
-		$this->requiredby = array();
63
-		$this->langfiles = array("bookmarks");
64
-
65
-		// Config pages
66
-		$this->config_page_url = array('bookmark.php@bookmarks');
67
-
68
-		// Constants
69
-		$this->const = array();
70
-
71
-		// Boxes
72
-		$this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home'));
73
-
74
-		// Permissions
75
-		$this->rights = array();
76
-		$this->rights_class = 'bookmark';
77
-		$r=0;
78
-
79
-		$r++;
80
-		$this->rights[$r][0] = 331; // id de la permission
81
-		$this->rights[$r][1] = 'Lire les bookmarks'; // libelle de la permission
82
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
83
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
84
-		$this->rights[$r][4] = 'lire';
85
-
86
-		$r++;
87
-		$this->rights[$r][0] = 332; // id de la permission
88
-		$this->rights[$r][1] = 'Creer/modifier les bookmarks'; // libelle de la permission
89
-		$this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
90
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
91
-		$this->rights[$r][4] = 'creer';
92
-
93
-		$r++;
94
-		$this->rights[$r][0] = 333; // id de la permission
95
-		$this->rights[$r][1] = 'Supprimer les bookmarks'; // libelle de la permission
96
-		$this->rights[$r][2] = 'r'; // type de la permission (d�pr�ci� � ce jour)
97
-		$this->rights[$r][3] = 0; // La permission est-elle une permission par d�faut
98
-		$this->rights[$r][4] = 'supprimer';
99
-
100
-
101
-		// Menus
102
-		//-------
103
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
104
-	}
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    function __construct($db)
42
+    {
43
+        $this->db = $db;
44
+        $this->numero = 330;
45
+
46
+        $this->family = "technic";
47
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
48
+        $this->name = preg_replace('/^mod/i','',get_class($this));
49
+        $this->description = "Gestion des Bookmarks";
50
+
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
+        $this->version = 'dolibarr';
53
+
54
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55
+        $this->picto='bookmark';
56
+
57
+        // Data directories to create when module is enabled
58
+        $this->dirs = array();
59
+
60
+        // Dependancies
61
+        $this->depends = array();
62
+        $this->requiredby = array();
63
+        $this->langfiles = array("bookmarks");
64
+
65
+        // Config pages
66
+        $this->config_page_url = array('bookmark.php@bookmarks');
67
+
68
+        // Constants
69
+        $this->const = array();
70
+
71
+        // Boxes
72
+        $this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home'));
73
+
74
+        // Permissions
75
+        $this->rights = array();
76
+        $this->rights_class = 'bookmark';
77
+        $r=0;
78
+
79
+        $r++;
80
+        $this->rights[$r][0] = 331; // id de la permission
81
+        $this->rights[$r][1] = 'Lire les bookmarks'; // libelle de la permission
82
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
83
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
84
+        $this->rights[$r][4] = 'lire';
85
+
86
+        $r++;
87
+        $this->rights[$r][0] = 332; // id de la permission
88
+        $this->rights[$r][1] = 'Creer/modifier les bookmarks'; // libelle de la permission
89
+        $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour)
90
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
91
+        $this->rights[$r][4] = 'creer';
92
+
93
+        $r++;
94
+        $this->rights[$r][0] = 333; // id de la permission
95
+        $this->rights[$r][1] = 'Supprimer les bookmarks'; // libelle de la permission
96
+        $this->rights[$r][2] = 'r'; // type de la permission (d�pr�ci� � ce jour)
97
+        $this->rights[$r][3] = 0; // La permission est-elle une permission par d�faut
98
+        $this->rights[$r][4] = 'supprimer';
99
+
100
+
101
+        // Menus
102
+        //-------
103
+        $this->menu = 1;        // This module add menu entries. They are coded into menu manager.
104
+    }
105 105
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  *	\brief      Fichier de description et activation du module Bookmarks
25 25
  */
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
 /**
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 
46 46
 		$this->family = "technic";
47 47
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
48
-		$this->name = preg_replace('/^mod/i','',get_class($this));
48
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
49 49
 		$this->description = "Gestion des Bookmarks";
50 50
 
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
 		$this->version = 'dolibarr';
53 53
 
54 54
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
55
-		$this->picto='bookmark';
55
+		$this->picto = 'bookmark';
56 56
 
57 57
 		// Data directories to create when module is enabled
58 58
 		$this->dirs = array();
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 		$this->const = array();
70 70
 
71 71
 		// Boxes
72
-		$this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home'));
72
+		$this->boxes = array(0=>array('file'=>'box_bookmarks.php', 'enabledbydefaulton'=>'Home'));
73 73
 
74 74
 		// Permissions
75 75
 		$this->rights = array();
76 76
 		$this->rights_class = 'bookmark';
77
-		$r=0;
77
+		$r = 0;
78 78
 
79 79
 		$r++;
80 80
 		$this->rights[$r][0] = 331; // id de la permission
@@ -100,6 +100,6 @@  discard block
 block discarded – undo
100 100
 
101 101
 		// Menus
102 102
 		//-------
103
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
103
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
104 104
 	}
105 105
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modBarcode.class.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -34,91 +34,91 @@  discard block
 block discarded – undo
34 34
 class modBarcode 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 = 55;
46
-
47
-		$this->family = "technic";
48
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
50
-		$this->description = "Gestion des codes barres";
51
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
-		$this->version = 'dolibarr';
53
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto='barcode';
55
-
56
-		// Data directories to create when module is enabled
57
-		$this->dirs = array("/barcode/temp");
58
-
59
-		// Dependencies
60
-		$this->depends = array();        // May be used for product or service or third party module
61
-		$this->requiredby = array();
62
-
63
-		// Config pages
64
-		$this->config_page_url = array("barcode.php");
65
-
66
-		// Constants
67
-		// Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
68
-		//							  1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
69
-		$this->const = array();
70
-		//$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
71
-		//$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
72
-		//$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
73
-		//$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
74
-
75
-		// Boxes
76
-		$this->boxes = array();
77
-
78
-		// Permissions
79
-		$this->rights = array();
80
-		$this->rights_class = 'barcode';
81
-
82
-		$this->rights[1][0] = 300; // id de la permission
83
-		$this->rights[1][1] = 'Read barcodes'; // libelle de la permission
84
-		$this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)
85
-		$this->rights[1][3] = 1; // La permission est-elle une permission par defaut
86
-		$this->rights[1][4] = 'lire_advance';
87
-
88
-		$this->rights[2][0] = 301; // id de la permission
89
-		$this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission
90
-		$this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)
91
-		$this->rights[2][3] = 0; // La permission est-elle une permission par defaut
92
-		$this->rights[2][4] = 'creer_advance';
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 = 55;
46
+
47
+        $this->family = "technic";
48
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
+        $this->name = preg_replace('/^mod/i','',get_class($this));
50
+        $this->description = "Gestion des codes barres";
51
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52
+        $this->version = 'dolibarr';
53
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
+        $this->picto='barcode';
55
+
56
+        // Data directories to create when module is enabled
57
+        $this->dirs = array("/barcode/temp");
58
+
59
+        // Dependencies
60
+        $this->depends = array();        // May be used for product or service or third party module
61
+        $this->requiredby = array();
62
+
63
+        // Config pages
64
+        $this->config_page_url = array("barcode.php");
65
+
66
+        // Constants
67
+        // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0),
68
+        //							  1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) );
69
+        $this->const = array();
70
+        //$this->const[0] = array('BARCODE_LABEL_LEFT_TEXT','chaine','%BARCODE%','Print barcode on left side of label',1);
71
+        //$this->const[1] = array('BARCODE_LABEL_RIGHT_TEXT','chaine','%LOGO%','Print Company logo on right side',1);
72
+        //$this->const[2] = array('BARCODE_LABEL_HEADER_TEXT','chaine','My header','Print header text on label',1);
73
+        //$this->const[3] = array('BARCODE_LABEL_FOOTER_TEXT','chaine','My footer','Print footer text on label',1);
74
+
75
+        // Boxes
76
+        $this->boxes = array();
77
+
78
+        // Permissions
79
+        $this->rights = array();
80
+        $this->rights_class = 'barcode';
81
+
82
+        $this->rights[1][0] = 300; // id de la permission
83
+        $this->rights[1][1] = 'Read barcodes'; // libelle de la permission
84
+        $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour)
85
+        $this->rights[1][3] = 1; // La permission est-elle une permission par defaut
86
+        $this->rights[1][4] = 'lire_advance';
87
+
88
+        $this->rights[2][0] = 301; // id de la permission
89
+        $this->rights[2][1] = 'Create/modify barcodes'; // libelle de la permission
90
+        $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour)
91
+        $this->rights[2][3] = 0; // La permission est-elle une permission par defaut
92
+        $this->rights[2][4] = 'creer_advance';
93 93
 
94 94
         // Main menu entries
95 95
         $r=0;
96 96
         $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=tools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
97
-						        'mainmenu'=>'tools',
98
-        						'leftmenu'=>'barcodeprint',
99
-        						'type'=>'left',			                // This is a Left menu entry
100
-						        'titre'=>'BarCodePrintsheet',
101
-						        'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
102
-						        'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
103
-						        'position'=>200,
104
-						        'enabled'=>'$conf->barcode->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
105
-        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
106
-						        'target'=>'',
107
-						        'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
108
-		$r++;
109
-
110
-		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
111
-								'type'=>'left',			                // This is a Left menu entry
112
-								'titre'=>'MassBarcodeInit',
113
-								'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
114
-								'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115
-								'position'=>300,
116
-								'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
117
-								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			                // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
118
-								'target'=>'',
119
-								'user'=>0);				                // 0=Menu for internal users, 1=external users, 2=both
120
-		$r++;
121
-	}
97
+                                'mainmenu'=>'tools',
98
+                                'leftmenu'=>'barcodeprint',
99
+                                'type'=>'left',			                // This is a Left menu entry
100
+                                'titre'=>'BarCodePrintsheet',
101
+                                'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
102
+                                'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
103
+                                'position'=>200,
104
+                                'enabled'=>'$conf->barcode->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
105
+                                'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
106
+                                'target'=>'',
107
+                                'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
108
+        $r++;
109
+
110
+        $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
111
+                                'type'=>'left',			                // This is a Left menu entry
112
+                                'titre'=>'MassBarcodeInit',
113
+                                'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
114
+                                'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115
+                                'position'=>300,
116
+                                'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
117
+                                'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			                // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
118
+                                'target'=>'',
119
+                                'user'=>0);				                // 0=Menu for internal users, 1=external users, 2=both
120
+        $r++;
121
+    }
122 122
 
123 123
 
124 124
     /**
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
      *      It also creates data directories.
128 128
      *
129 129
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
130
-	 *      @return     int             	1 if OK, 0 if KO
131
-	 */
132
-	function init($options='')
133
-	{
134
-		// Permissions
135
-		$this->remove($options);
136
-
137
-		$sql = array(
138
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
139
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
140
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
141
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
142
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
143
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1),
144
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
145
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1)
146
-		);
147
-
148
-		return $this->_init($sql, $options);
149
-	}
130
+     *      @return     int             	1 if OK, 0 if KO
131
+     */
132
+    function init($options='')
133
+    {
134
+        // Permissions
135
+        $this->remove($options);
136
+
137
+        $sql = array(
138
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
139
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
140
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
141
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
142
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
143
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1),
144
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
145
+                array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1)
146
+        );
147
+
148
+        return $this->_init($sql, $options);
149
+    }
150 150
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *	\brief      Fichier de description et activation du module Barcode
27 27
  */
28 28
 
29
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
29
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
30 30
 
31 31
 /**
32 32
  *	Class to describe Barcode
@@ -46,18 +46,18 @@  discard block
 block discarded – undo
46 46
 
47 47
 		$this->family = "technic";
48 48
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
49
-		$this->name = preg_replace('/^mod/i','',get_class($this));
49
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
50 50
 		$this->description = "Gestion des codes barres";
51 51
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
52 52
 		$this->version = 'dolibarr';
53 53
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
54
-		$this->picto='barcode';
54
+		$this->picto = 'barcode';
55 55
 
56 56
 		// Data directories to create when module is enabled
57 57
 		$this->dirs = array("/barcode/temp");
58 58
 
59 59
 		// Dependencies
60
-		$this->depends = array();        // May be used for product or service or third party module
60
+		$this->depends = array(); // May be used for product or service or third party module
61 61
 		$this->requiredby = array();
62 62
 
63 63
 		// Config pages
@@ -92,31 +92,31 @@  discard block
 block discarded – undo
92 92
 		$this->rights[2][4] = 'creer_advance';
93 93
 
94 94
         // Main menu entries
95
-        $r=0;
96
-        $this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=tools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
95
+        $r = 0;
96
+        $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
97 97
 						        'mainmenu'=>'tools',
98 98
         						'leftmenu'=>'barcodeprint',
99
-        						'type'=>'left',			                // This is a Left menu entry
99
+        						'type'=>'left', // This is a Left menu entry
100 100
 						        'titre'=>'BarCodePrintsheet',
101 101
 						        'url'=>'/barcode/printsheet.php?mainmenu=tools&leftmenu=barcodeprint',
102
-						        'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
102
+						        'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
103 103
 						        'position'=>200,
104
-						        'enabled'=>'$conf->barcode->enabled',  // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
105
-        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			    // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
104
+						        'enabled'=>'$conf->barcode->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
105
+        				        'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->lire_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
106 106
 						        'target'=>'',
107
-						        'user'=>2);				                // 0=Menu for internal users, 1=external users, 2=both
107
+						        'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
108 108
 		$r++;
109 109
 
110
-		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
111
-								'type'=>'left',			                // This is a Left menu entry
110
+		$this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
111
+								'type'=>'left', // This is a Left menu entry
112 112
 								'titre'=>'MassBarcodeInit',
113 113
 								'url'=>'/barcode/codeinit.php?mainmenu=home&leftmenu=admintools',
114
-								'langs'=>'products',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
114
+								'langs'=>'products', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
115 115
 								'position'=>300,
116
-								'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)',   // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
117
-								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)',			                // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
116
+								'enabled'=>'$conf->barcode->enabled && preg_match(\'/^(admintools|all)/\',$leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
117
+								'perms'=>'($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->barcode->creer_advance) || (! $conf->global->MAIN_USE_ADVANCED_PERMS)', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
118 118
 								'target'=>'',
119
-								'user'=>0);				                // 0=Menu for internal users, 1=external users, 2=both
119
+								'user'=>0); // 0=Menu for internal users, 1=external users, 2=both
120 120
 		$r++;
121 121
 	}
122 122
 
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
      *      @param      string	$options    Options when enabling module ('', 'noboxes')
130 130
 	 *      @return     int             	1 if OK, 0 if KO
131 131
 	 */
132
-	function init($options='')
132
+	function init($options = '')
133 133
 	{
134 134
 		// Permissions
135 135
 		$this->remove($options);
136 136
 
137 137
 		$sql = array(
138
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)",'ignoreerror'=>1),
139
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
140
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)",'ignoreerror'=>1),
141
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)",'ignoreerror'=>1),
142
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)",'ignoreerror'=>1),
143
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)",'ignoreerror'=>1),
144
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)",'ignoreerror'=>1),
145
-				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)",'ignoreerror'=>1)
138
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN8', 'EAN8', 0, '1234567', __ENTITY__)", 'ignoreerror'=>1),
139
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('EAN13', 'EAN13', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
140
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('UPC', 'UPC', 0, '123456789012', __ENTITY__)", 'ignoreerror'=>1),
141
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('ISBN', 'ISBN', 0, '123456789', __ENTITY__)", 'ignoreerror'=>1),
142
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C39', 'Code 39', 0, '1234567890', __ENTITY__)", 'ignoreerror'=>1),
143
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('C128', 'Code 128', 0, 'ABCD1234567890', __ENTITY__)", 'ignoreerror'=>1),
144
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('DATAMATRIX', 'Datamatrix', 0, '1234567xyz', __ENTITY__)", 'ignoreerror'=>1),
145
+				array('sql'=>"INSERT INTO ".MAIN_DB_PREFIX."c_barcode_type (code, libelle, coder, example, entity) VALUES ('QRCODE', 'Qr Code', 0, 'www.dolibarr.org', __ENTITY__)", 'ignoreerror'=>1)
146 146
 		);
147 147
 
148 148
 		return $this->_init($sql, $options);
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php 3 patches
Indentation   +989 added lines, -989 removed lines patch added patch discarded remove patch
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public $db;
44 44
 
45
-	/**
45
+    /**
46 46
      * @var string model name
47 47
      */
48 48
     public $name;
49 49
 
50
-	/**
50
+    /**
51 51
      * @var string model description (short text)
52 52
      */
53 53
     public $description;
@@ -59,132 +59,132 @@  discard block
 block discarded – undo
59 59
 
60 60
     /**
61 61
      * @var array() Minimum version of PHP required by module.
62
-	 * e.g.: PHP ≥ 5.4 = array(5, 4)
62
+     * e.g.: PHP ≥ 5.4 = array(5, 4)
63 63
      */
64
-	public $phpmin = array(5, 4);
64
+    public $phpmin = array(5, 4);
65 65
 
66
-	/**
66
+    /**
67 67
      * Dolibarr version of the loaded document
68 68
      * @public string
69 69
      */
70
-	public $version = 'dolibarr';
70
+    public $version = 'dolibarr';
71 71
 
72
-	/**
72
+    /**
73 73
      * @var int page_largeur
74 74
      */
75 75
     public $page_largeur;
76 76
 
77
-	/**
77
+    /**
78 78
      * @var int page_hauteur
79 79
      */
80 80
     public $page_hauteur;
81 81
 
82
-	/**
82
+    /**
83 83
      * @var array format
84 84
      */
85 85
     public $format;
86 86
 
87
-	/**
87
+    /**
88 88
      * @var int marge_gauche
89 89
      */
90
-	public $marge_gauche;
90
+    public $marge_gauche;
91 91
 
92
-	/**
92
+    /**
93 93
      * @var int marge_droite
94 94
      */
95
-	public $marge_droite;
95
+    public $marge_droite;
96 96
 
97
-	/**
97
+    /**
98 98
      * @var int marge_haute
99 99
      */
100
-	public $marge_haute;
100
+    public $marge_haute;
101 101
 
102
-	/**
102
+    /**
103 103
      * @var int marge_basse
104 104
      */
105
-	public $marge_basse;
106
-
107
-	/**
108
-	 * Issuer
109
-	 * @var Company object that emits
110
-	 */
111
-	public $emetteur;
112
-
113
-
114
-
115
-	/**
116
-	 *	Constructor
117
-	 *
118
-	 *  @param	DoliDB		$db     	Database handler
119
-	 */
120
-	function __construct($db)
121
-	{
122
-		global $conf, $langs, $mysoc;
123
-
124
-		// Load translation files required by the page
125
-		$langs->loadLangs(array("main", "bills"));
126
-
127
-		$this->db = $db;
128
-		$this->name = "canelle";
129
-		$this->description = $langs->trans('SuppliersInvoiceModel');
130
-
131
-		// Dimension page pour format A4
132
-		$this->type = 'pdf';
133
-		$formatarray=pdf_getFormat();
134
-		$this->page_largeur = $formatarray['width'];
135
-		$this->page_hauteur = $formatarray['height'];
136
-		$this->format = array($this->page_largeur,$this->page_hauteur);
137
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
-
142
-		$this->option_logo = 1;                    // Affiche logo
143
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
-		$this->option_modereg = 1;                 // Affiche mode reglement
145
-		$this->option_condreg = 1;                 // Affiche conditions reglement
146
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
147
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
148
-
149
-		$this->franchise=!$mysoc->tva_assuj;
105
+    public $marge_basse;
106
+
107
+    /**
108
+     * Issuer
109
+     * @var Company object that emits
110
+     */
111
+    public $emetteur;
112
+
113
+
114
+
115
+    /**
116
+     *	Constructor
117
+     *
118
+     *  @param	DoliDB		$db     	Database handler
119
+     */
120
+    function __construct($db)
121
+    {
122
+        global $conf, $langs, $mysoc;
123
+
124
+        // Load translation files required by the page
125
+        $langs->loadLangs(array("main", "bills"));
126
+
127
+        $this->db = $db;
128
+        $this->name = "canelle";
129
+        $this->description = $langs->trans('SuppliersInvoiceModel');
130
+
131
+        // Dimension page pour format A4
132
+        $this->type = 'pdf';
133
+        $formatarray=pdf_getFormat();
134
+        $this->page_largeur = $formatarray['width'];
135
+        $this->page_hauteur = $formatarray['height'];
136
+        $this->format = array($this->page_largeur,$this->page_hauteur);
137
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
141
+
142
+        $this->option_logo = 1;                    // Affiche logo
143
+        $this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
+        $this->option_modereg = 1;                 // Affiche mode reglement
145
+        $this->option_condreg = 1;                 // Affiche conditions reglement
146
+        $this->option_codeproduitservice = 1;      // Affiche code produit-service
147
+        $this->option_multilang = 1;               // Dispo en plusieurs langues
148
+
149
+        $this->franchise=!$mysoc->tva_assuj;
150 150
 
151 151
         // Defini position des colonnes
152
-		$this->posxdesc=$this->marge_gauche+1;
153
-		$this->posxtva=112;
154
-		$this->posxup=126;
155
-		$this->posxqty=145;
156
-		$this->posxdiscount=162;
157
-		$this->postotalht=174;
158
-
159
-		if($conf->global->PRODUCT_USE_UNITS) {
160
-			$this->posxtva=99;
161
-			$this->posxup=114;
162
-			$this->posxqty=130;
163
-			$this->posxunit=147;
164
-		}
165
-		//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
166
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
167
-		if ($this->page_largeur < 210) // To work with US executive format
168
-		{
169
-			$this->posxpicture-=20;
170
-			$this->posxtva-=20;
171
-			$this->posxup-=20;
172
-			$this->posxqty-=20;
173
-			$this->posxunit-=20;
174
-			$this->posxdiscount-=20;
175
-			$this->postotalht-=20;
176
-		}
152
+        $this->posxdesc=$this->marge_gauche+1;
153
+        $this->posxtva=112;
154
+        $this->posxup=126;
155
+        $this->posxqty=145;
156
+        $this->posxdiscount=162;
157
+        $this->postotalht=174;
158
+
159
+        if($conf->global->PRODUCT_USE_UNITS) {
160
+            $this->posxtva=99;
161
+            $this->posxup=114;
162
+            $this->posxqty=130;
163
+            $this->posxunit=147;
164
+        }
165
+        //if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
166
+        $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
167
+        if ($this->page_largeur < 210) // To work with US executive format
168
+        {
169
+            $this->posxpicture-=20;
170
+            $this->posxtva-=20;
171
+            $this->posxup-=20;
172
+            $this->posxqty-=20;
173
+            $this->posxunit-=20;
174
+            $this->posxdiscount-=20;
175
+            $this->postotalht-=20;
176
+        }
177 177
 
178
-		$this->tva=array();
178
+        $this->tva=array();
179 179
         $this->localtax1=array();
180 180
         $this->localtax2=array();
181
-		$this->atleastoneratenotnull=0;
182
-		$this->atleastonediscount=0;
183
-	}
181
+        $this->atleastoneratenotnull=0;
182
+        $this->atleastonediscount=0;
183
+    }
184 184
 
185 185
 
186 186
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
187
-	/**
187
+    /**
188 188
      *  Function to build pdf onto disk
189 189
      *
190 190
      *  @param		FactureFournisseur	$object				Id of object to generate
@@ -195,77 +195,77 @@  discard block
 block discarded – undo
195 195
      *  @param		int					$hideref			Do not show ref
196 196
      *  @return		int										1=OK, 0=KO
197 197
      */
198
-	function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
199
-	{
198
+    function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
199
+    {
200 200
         // phpcs:enable
201
-		global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes;
201
+        global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes;
202 202
 
203
-		// Get source company
204
-		if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
205
-		if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc;	// If fetch_thirdparty fails, object has no socid (specimen)
206
-		$this->emetteur=$object->thirdparty;
207
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
203
+        // Get source company
204
+        if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
205
+        if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc;	// If fetch_thirdparty fails, object has no socid (specimen)
206
+        $this->emetteur=$object->thirdparty;
207
+        if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
208 208
 
209
-		if (! is_object($outputlangs)) $outputlangs=$langs;
210
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
211
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
209
+        if (! is_object($outputlangs)) $outputlangs=$langs;
210
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
211
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
212 212
 
213
-		// Load translation files required by the page
214
-		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products"));
213
+        // Load translation files required by the page
214
+        $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products"));
215 215
 
216
-		if ($conf->fournisseur->facture->dir_output)
217
-		{
218
-			$object->fetch_thirdparty();
216
+        if ($conf->fournisseur->facture->dir_output)
217
+        {
218
+            $object->fetch_thirdparty();
219 219
 
220
-			$deja_regle = $object->getSommePaiement();
220
+            $deja_regle = $object->getSommePaiement();
221 221
             //$amount_credit_notes_included = $object->getSumCreditNotesUsed();
222 222
             //$amount_deposits_included = $object->getSumDepositsUsed();
223 223
 
224
-			// Definition of $dir and $file
225
-			if ($object->specimen)
226
-			{
227
-				$dir = $conf->fournisseur->facture->dir_output;
228
-				$file = $dir . "/SPECIMEN.pdf";
229
-			}
230
-			else
231
-			{
232
-				$objectref = dol_sanitizeFileName($object->ref);
233
-				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
224
+            // Definition of $dir and $file
225
+            if ($object->specimen)
226
+            {
227
+                $dir = $conf->fournisseur->facture->dir_output;
228
+                $file = $dir . "/SPECIMEN.pdf";
229
+            }
230
+            else
231
+            {
232
+                $objectref = dol_sanitizeFileName($object->ref);
233
+                $objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
234 234
                 $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$objectref;
235
-				$file = $dir . "/" . $objectref . ".pdf";
236
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
237
-			}
235
+                $file = $dir . "/" . $objectref . ".pdf";
236
+                if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
237
+            }
238 238
 
239
-			if (! file_exists($dir))
240
-			{
241
-				if (dol_mkdir($dir) < 0)
242
-				{
243
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
244
-					return 0;
245
-				}
246
-			}
239
+            if (! file_exists($dir))
240
+            {
241
+                if (dol_mkdir($dir) < 0)
242
+                {
243
+                    $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
244
+                    return 0;
245
+                }
246
+            }
247 247
 
248
-			if (file_exists($dir))
249
-			{
250
-				// Add pdfgeneration hook
251
-				if (! is_object($hookmanager))
252
-				{
253
-					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
254
-					$hookmanager=new HookManager($this->db);
255
-				}
256
-				$hookmanager->initHooks(array('pdfgeneration'));
257
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
258
-				global $action;
259
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
260
-
261
-				$nblignes = count($object->lines);
248
+            if (file_exists($dir))
249
+            {
250
+                // Add pdfgeneration hook
251
+                if (! is_object($hookmanager))
252
+                {
253
+                    include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
254
+                    $hookmanager=new HookManager($this->db);
255
+                }
256
+                $hookmanager->initHooks(array('pdfgeneration'));
257
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
258
+                global $action;
259
+                $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
260
+
261
+                $nblignes = count($object->lines);
262 262
 
263 263
                 $pdf=pdf_getInstance($this->format);
264 264
                 $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
265 265
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
266
-		        $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
267
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
268
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
266
+                $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
267
+                $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
268
+                if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
269 269
                 $pdf->SetAutoPageBreak(1,0);
270 270
 
271 271
                 if (class_exists('TCPDF'))
@@ -281,20 +281,20 @@  discard block
 block discarded – undo
281 281
                     $tplidx = $pdf->importPage(1);
282 282
                 }
283 283
 
284
-				$pdf->Open();
285
-				$pagenb=0;
286
-				$pdf->SetDrawColor(128,128,128);
284
+                $pdf->Open();
285
+                $pagenb=0;
286
+                $pdf->SetDrawColor(128,128,128);
287 287
 
288
-				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
289
-				$pdf->SetSubject($outputlangs->transnoentities("Invoice"));
290
-				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
291
-				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
292
-				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
293
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
288
+                $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
289
+                $pdf->SetSubject($outputlangs->transnoentities("Invoice"));
290
+                $pdf->SetCreator("Dolibarr ".DOL_VERSION);
291
+                $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
292
+                $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
293
+                if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
294 294
 
295
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
295
+                $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
296 296
 
297
-			    // Positionne $this->atleastonediscount si on a au moins une remise
297
+                // Positionne $this->atleastonediscount si on a au moins une remise
298 298
                 for ($i = 0 ; $i < $nblignes ; $i++)
299 299
                 {
300 300
                     if ($object->lines[$i]->remise_percent)
@@ -302,755 +302,755 @@  discard block
 block discarded – undo
302 302
                         $this->atleastonediscount++;
303 303
                     }
304 304
                 }
305
-				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
306
-				{
307
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
308
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
309
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
310
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
311
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
312
-					//$this->postotalht;
313
-				}
305
+                if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
306
+                {
307
+                    $this->posxpicture+=($this->postotalht - $this->posxdiscount);
308
+                    $this->posxtva+=($this->postotalht - $this->posxdiscount);
309
+                    $this->posxup+=($this->postotalht - $this->posxdiscount);
310
+                    $this->posxqty+=($this->postotalht - $this->posxdiscount);
311
+                    $this->posxdiscount+=($this->postotalht - $this->posxdiscount);
312
+                    //$this->postotalht;
313
+                }
314 314
 
315 315
                 // New page
316
-				$pdf->AddPage();
317
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
318
-				$pagenb++;
319
-				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
320
-				$pdf->SetFont('','', $default_font_size - 1);
321
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
322
-				$pdf->SetTextColor(0,0,0);
323
-
324
-				$tab_top = 90+$top_shift;
325
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
326
-
327
-				// Incoterm
328
-				if ($conf->incoterm->enabled)
329
-				{
330
-					$desc_incoterms = $object->getIncotermsForPDF();
331
-					if ($desc_incoterms)
332
-					{
333
-						$tab_top -= 2;
334
-
335
-						$pdf->SetFont('','', $default_font_size - 1);
336
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
337
-						$nexY = $pdf->GetY();
338
-						$height_incoterms=$nexY-$tab_top;
339
-
340
-						// Rect prend une longueur en 3eme param
341
-						$pdf->SetDrawColor(192,192,192);
342
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
343
-
344
-						$tab_top = $nexY+6;
345
-					}
346
-				}
347
-
348
-				// Affiche notes
349
-				if (! empty($object->note_public))
350
-				{
351
-					$tab_top -= 2;
352
-
353
-					$pdf->SetFont('','', $default_font_size - 1);
354
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
355
-					$nexY = $pdf->GetY();
356
-					$height_note=$nexY-$tab_top;
357
-
358
-					// Rect prend une longueur en 3eme param
359
-					$pdf->SetDrawColor(192,192,192);
360
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
361
-
362
-					$tab_top = $nexY+6;
363
-				}
364
-
365
-				$iniY = $tab_top + 7;
366
-				$curY = $tab_top + 7;
367
-				$nexY = $tab_top + 7;
368
-
369
-				// Loop on each lines
370
-				for ($i = 0 ; $i < $nblignes ; $i++)
371
-				{
372
-					$curY = $nexY;
373
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
374
-					$pdf->SetTextColor(0,0,0);
375
-
376
-					$pdf->setTopMargin($tab_top_newpage);
377
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
378
-					$pageposbefore=$pdf->getPage();
379
-
380
-					// Description of product line
381
-					$curX = $this->posxdesc-1;
382
-					$showpricebeforepagebreak=1;
383
-
384
-					$pdf->startTransaction();
385
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
386
-					$pageposafter=$pdf->getPage();
387
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
388
-					{
389
-						$pdf->rollbackTransaction(true);
390
-						$pageposafter=$pageposbefore;
391
-						//print $pageposafter.'-'.$pageposbefore;exit;
392
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
393
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
394
-						$posyafter=$pdf->GetY();
395
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
396
-						{
397
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
398
-							{
399
-								$pdf->AddPage('','',true);
400
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
401
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
402
-								$pdf->setPage($pageposafter+1);
403
-							}
404
-						}
405
-						else
406
-						{
407
-							// We found a page break
408
-							$showpricebeforepagebreak=0;
409
-						}
410
-					}
411
-					else	// No pagebreak
412
-					{
413
-						$pdf->commitTransaction();
414
-					}
415
-
416
-					$nexY = $pdf->GetY();
316
+                $pdf->AddPage();
317
+                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
318
+                $pagenb++;
319
+                $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
320
+                $pdf->SetFont('','', $default_font_size - 1);
321
+                $pdf->MultiCell(0, 3, '');		// Set interline to 3
322
+                $pdf->SetTextColor(0,0,0);
323
+
324
+                $tab_top = 90+$top_shift;
325
+                $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
326
+
327
+                // Incoterm
328
+                if ($conf->incoterm->enabled)
329
+                {
330
+                    $desc_incoterms = $object->getIncotermsForPDF();
331
+                    if ($desc_incoterms)
332
+                    {
333
+                        $tab_top -= 2;
334
+
335
+                        $pdf->SetFont('','', $default_font_size - 1);
336
+                        $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
337
+                        $nexY = $pdf->GetY();
338
+                        $height_incoterms=$nexY-$tab_top;
339
+
340
+                        // Rect prend une longueur en 3eme param
341
+                        $pdf->SetDrawColor(192,192,192);
342
+                        $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
343
+
344
+                        $tab_top = $nexY+6;
345
+                    }
346
+                }
347
+
348
+                // Affiche notes
349
+                if (! empty($object->note_public))
350
+                {
351
+                    $tab_top -= 2;
352
+
353
+                    $pdf->SetFont('','', $default_font_size - 1);
354
+                    $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
355
+                    $nexY = $pdf->GetY();
356
+                    $height_note=$nexY-$tab_top;
357
+
358
+                    // Rect prend une longueur en 3eme param
359
+                    $pdf->SetDrawColor(192,192,192);
360
+                    $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
361
+
362
+                    $tab_top = $nexY+6;
363
+                }
364
+
365
+                $iniY = $tab_top + 7;
366
+                $curY = $tab_top + 7;
367
+                $nexY = $tab_top + 7;
368
+
369
+                // Loop on each lines
370
+                for ($i = 0 ; $i < $nblignes ; $i++)
371
+                {
372
+                    $curY = $nexY;
373
+                    $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
374
+                    $pdf->SetTextColor(0,0,0);
375
+
376
+                    $pdf->setTopMargin($tab_top_newpage);
377
+                    $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
378
+                    $pageposbefore=$pdf->getPage();
379
+
380
+                    // Description of product line
381
+                    $curX = $this->posxdesc-1;
382
+                    $showpricebeforepagebreak=1;
383
+
384
+                    $pdf->startTransaction();
385
+                    pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
417 386
                     $pageposafter=$pdf->getPage();
418
-					$pdf->setPage($pageposbefore);
419
-					$pdf->setTopMargin($this->marge_haute);
420
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
387
+                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
388
+                    {
389
+                        $pdf->rollbackTransaction(true);
390
+                        $pageposafter=$pageposbefore;
391
+                        //print $pageposafter.'-'.$pageposbefore;exit;
392
+                        $pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
393
+                        pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
394
+                        $posyafter=$pdf->GetY();
395
+                        if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
396
+                        {
397
+                            if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
398
+                            {
399
+                                $pdf->AddPage('','',true);
400
+                                if (! empty($tplidx)) $pdf->useTemplate($tplidx);
401
+                                if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
402
+                                $pdf->setPage($pageposafter+1);
403
+                            }
404
+                        }
405
+                        else
406
+                        {
407
+                            // We found a page break
408
+                            $showpricebeforepagebreak=0;
409
+                        }
410
+                    }
411
+                    else	// No pagebreak
412
+                    {
413
+                        $pdf->commitTransaction();
414
+                    }
421 415
 
422
-					// We suppose that a too long description is moved completely on next page
423
-					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
424
-						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
425
-					}
416
+                    $nexY = $pdf->GetY();
417
+                    $pageposafter=$pdf->getPage();
418
+                    $pdf->setPage($pageposbefore);
419
+                    $pdf->setTopMargin($this->marge_haute);
420
+                    $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
421
+
422
+                    // We suppose that a too long description is moved completely on next page
423
+                    if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
424
+                        $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
425
+                    }
426 426
 
427
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
427
+                    $pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
428 428
 
429
-					// VAT Rate
429
+                    // VAT Rate
430 430
                     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
431 431
                     {
432
-    					$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
432
+                        $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
433 433
                         $pdf->SetXY($this->posxtva, $curY);
434
-	       				$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
434
+                            $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
435 435
                     }
436 436
 
437
-					// Unit price before discount
438
-					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
439
-					$pdf->SetXY($this->posxup, $curY);
440
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
441
-
442
-					// Unit price before discount
443
-					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
444
-					$pdf->SetXY($this->posxup, $curY);
445
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
446
-
447
-					// Quantity
448
-					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
449
-					$pdf->SetXY($this->posxqty, $curY);
450
-					// Enough for 6 chars
451
-					if($conf->global->PRODUCT_USE_UNITS)
452
-					{
453
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
454
-					}
455
-					else
456
-					{
457
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
458
-					}
459
-
460
-					// Unit
461
-					if($conf->global->PRODUCT_USE_UNITS)
462
-					{
463
-						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
464
-						$pdf->SetXY($this->posxunit, $curY);
465
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
466
-					}
467
-
468
-					// Discount on line
469
-					$pdf->SetXY($this->posxdiscount, $curY);
470
-					if ($object->lines[$i]->remise_percent)
471
-					{
472
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
473
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R');
474
-					}
475
-
476
-					// Total HT line
437
+                    // Unit price before discount
438
+                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
439
+                    $pdf->SetXY($this->posxup, $curY);
440
+                    $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
441
+
442
+                    // Unit price before discount
443
+                    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
444
+                    $pdf->SetXY($this->posxup, $curY);
445
+                    $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
446
+
447
+                    // Quantity
448
+                    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
449
+                    $pdf->SetXY($this->posxqty, $curY);
450
+                    // Enough for 6 chars
451
+                    if($conf->global->PRODUCT_USE_UNITS)
452
+                    {
453
+                        $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
454
+                    }
455
+                    else
456
+                    {
457
+                        $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
458
+                    }
459
+
460
+                    // Unit
461
+                    if($conf->global->PRODUCT_USE_UNITS)
462
+                    {
463
+                        $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
464
+                        $pdf->SetXY($this->posxunit, $curY);
465
+                        $pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
466
+                    }
467
+
468
+                    // Discount on line
469
+                    $pdf->SetXY($this->posxdiscount, $curY);
470
+                    if ($object->lines[$i]->remise_percent)
471
+                    {
472
+                        $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
473
+                        $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R');
474
+                    }
475
+
476
+                    // Total HT line
477 477
                     $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
478 478
                     $pdf->SetXY($this->postotalht, $curY);
479 479
                     $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
480 480
 
481
-					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
482
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
483
-					else $tvaligne=$object->lines[$i]->total_tva;
484
-
485
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
486
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
487
-
488
-					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
489
-
490
-					$vatrate=(string) $object->lines[$i]->tva_tx;
491
-					$localtax1rate=(string) $object->lines[$i]->localtax1_tx;
492
-					$localtax2rate=(string) $object->lines[$i]->localtax2_tx;
493
-
494
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
495
-					if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0;
496
-					if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0;
497
-					if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0;
498
-					$this->tva[$vatrate] += $tvaligne;
499
-					$this->localtax1[$localtax1rate]+=$localtax1ligne;
500
-					$this->localtax2[$localtax2rate]+=$localtax2ligne;
501
-
502
-					// Add line
503
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
504
-					{
505
-						$pdf->setPage($pageposafter);
506
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
507
-						//$pdf->SetDrawColor(190,190,200);
508
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
509
-						$pdf->SetLineStyle(array('dash'=>0));
510
-					}
511
-
512
-					$nexY+=2;    // Passe espace entre les lignes
513
-
514
-					// Detect if some page were added automatically and output _tableau for past pages
515
-					while ($pagenb < $pageposafter)
516
-					{
517
-						$pdf->setPage($pagenb);
518
-						if ($pagenb == 1)
519
-						{
520
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
521
-						}
522
-						else
523
-						{
524
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
525
-						}
526
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
527
-						$pagenb++;
528
-						$pdf->setPage($pagenb);
529
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
530
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
-					}
532
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
533
-					{
534
-						if ($pagenb == 1)
535
-						{
536
-							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
537
-						}
538
-						else
539
-						{
540
-							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
541
-						}
542
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
543
-						// New page
544
-						$pdf->AddPage();
545
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
546
-						$pagenb++;
547
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
548
-					}
549
-				}
550
-
551
-				// Show square
552
-				if ($pagenb == 1)
553
-				{
554
-					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
555
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
556
-				}
557
-				else
558
-				{
559
-					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
560
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
561
-				}
562
-
563
-				// Affiche zone totaux
564
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
565
-
566
-				$amount_credit_notes_included=0;
567
-				$amount_deposits_included=0;
568
-
569
-				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
570
-				{
571
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
572
-				}
573
-
574
-				// Pied de page
575
-				$this->_pagefoot($pdf, $object, $outputlangs);
576
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
577
-
578
-				$pdf->Close();
579
-
580
-				$pdf->Output($file,'F');
581
-
582
-				// Add pdfgeneration hook
583
-				$hookmanager->initHooks(array('pdfgeneration'));
584
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
585
-				global $action;
586
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587
-
588
-				if (! empty($conf->global->MAIN_UMASK))
589
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
590
-
591
-				$this->result = array('fullpath'=>$file);
592
-
593
-				return 1;   // Pas d'erreur
594
-			}
595
-			else
596
-			{
597
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
598
-				return 0;
599
-			}
600
-		}
601
-		else
602
-		{
603
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
604
-			return 0;
605
-		}
606
-	}
481
+                    // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
482
+                    if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
483
+                    else $tvaligne=$object->lines[$i]->total_tva;
484
+
485
+                    $localtax1ligne=$object->lines[$i]->total_localtax1;
486
+                    $localtax2ligne=$object->lines[$i]->total_localtax2;
487
+
488
+                    if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
489
+
490
+                    $vatrate=(string) $object->lines[$i]->tva_tx;
491
+                    $localtax1rate=(string) $object->lines[$i]->localtax1_tx;
492
+                    $localtax2rate=(string) $object->lines[$i]->localtax2_tx;
493
+
494
+                    if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
495
+                    if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0;
496
+                    if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0;
497
+                    if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0;
498
+                    $this->tva[$vatrate] += $tvaligne;
499
+                    $this->localtax1[$localtax1rate]+=$localtax1ligne;
500
+                    $this->localtax2[$localtax2rate]+=$localtax2ligne;
501
+
502
+                    // Add line
503
+                    if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
504
+                    {
505
+                        $pdf->setPage($pageposafter);
506
+                        $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
507
+                        //$pdf->SetDrawColor(190,190,200);
508
+                        $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
509
+                        $pdf->SetLineStyle(array('dash'=>0));
510
+                    }
511
+
512
+                    $nexY+=2;    // Passe espace entre les lignes
513
+
514
+                    // Detect if some page were added automatically and output _tableau for past pages
515
+                    while ($pagenb < $pageposafter)
516
+                    {
517
+                        $pdf->setPage($pagenb);
518
+                        if ($pagenb == 1)
519
+                        {
520
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
521
+                        }
522
+                        else
523
+                        {
524
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
525
+                        }
526
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
527
+                        $pagenb++;
528
+                        $pdf->setPage($pagenb);
529
+                        $pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
530
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531
+                    }
532
+                    if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
533
+                    {
534
+                        if ($pagenb == 1)
535
+                        {
536
+                            $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
537
+                        }
538
+                        else
539
+                        {
540
+                            $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
541
+                        }
542
+                        $this->_pagefoot($pdf,$object,$outputlangs,1);
543
+                        // New page
544
+                        $pdf->AddPage();
545
+                        if (! empty($tplidx)) $pdf->useTemplate($tplidx);
546
+                        $pagenb++;
547
+                        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
548
+                    }
549
+                }
550
+
551
+                // Show square
552
+                if ($pagenb == 1)
553
+                {
554
+                    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
555
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
556
+                }
557
+                else
558
+                {
559
+                    $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
560
+                    $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
561
+                }
562
+
563
+                // Affiche zone totaux
564
+                $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
565
+
566
+                $amount_credit_notes_included=0;
567
+                $amount_deposits_included=0;
568
+
569
+                if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
570
+                {
571
+                    $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
572
+                }
573
+
574
+                // Pied de page
575
+                $this->_pagefoot($pdf, $object, $outputlangs);
576
+                if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
577
+
578
+                $pdf->Close();
579
+
580
+                $pdf->Output($file,'F');
581
+
582
+                // Add pdfgeneration hook
583
+                $hookmanager->initHooks(array('pdfgeneration'));
584
+                $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
585
+                global $action;
586
+                $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587
+
588
+                if (! empty($conf->global->MAIN_UMASK))
589
+                @chmod($file, octdec($conf->global->MAIN_UMASK));
590
+
591
+                $this->result = array('fullpath'=>$file);
592
+
593
+                return 1;   // Pas d'erreur
594
+            }
595
+            else
596
+            {
597
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
598
+                return 0;
599
+            }
600
+        }
601
+        else
602
+        {
603
+            $this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
604
+            return 0;
605
+        }
606
+    }
607 607
 
608 608
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
609
-	/**
610
-	 *	Show total to pay
611
-	 *
612
-	 *	@param	PDF			$pdf           Object PDF
613
-	 *	@param  Facture		$object         Object invoice
614
-	 *	@param  int			$deja_regle     Montant deja regle
615
-	 *	@param	int			$posy			Position depart
616
-	 *	@param	Translate	$outputlangs	Objet langs
617
-	 *	@return int							Position pour suite
618
-	 */
619
-	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
620
-	{
609
+    /**
610
+     *	Show total to pay
611
+     *
612
+     *	@param	PDF			$pdf           Object PDF
613
+     *	@param  Facture		$object         Object invoice
614
+     *	@param  int			$deja_regle     Montant deja regle
615
+     *	@param	int			$posy			Position depart
616
+     *	@param	Translate	$outputlangs	Objet langs
617
+     *	@return int							Position pour suite
618
+     */
619
+    function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
620
+    {
621 621
         // phpcs:enable
622
-		global $conf,$mysoc;
622
+        global $conf,$mysoc;
623 623
 
624 624
         $default_font_size = pdf_getPDFFontSize($outputlangs);
625 625
 
626 626
         $tab2_top = $posy;
627
-		$tab2_hl = 4;
628
-		$pdf->SetFont('','', $default_font_size - 1);
627
+        $tab2_hl = 4;
628
+        $pdf->SetFont('','', $default_font_size - 1);
629 629
 
630
-		$pdf->SetXY($this->marge_gauche, $tab2_top + 0);
631
-		// If France, show VAT mention if not applicable
632
-		if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
633
-		{
634
-			$pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
635
-		}
630
+        $pdf->SetXY($this->marge_gauche, $tab2_top + 0);
631
+        // If France, show VAT mention if not applicable
632
+        if ($this->emetteur->country_code == 'FR' && $this->franchise == 1)
633
+        {
634
+            $pdf->MultiCell(100, $tab2_hl, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
635
+        }
636 636
 
637
-		// Tableau total
638
-		$col1x = 120; $col2x = 170;
639
-		if ($this->page_largeur < 210) // To work with US executive format
640
-		{
641
-			$col2x-=20;
642
-		}
643
-		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
637
+        // Tableau total
638
+        $col1x = 120; $col2x = 170;
639
+        if ($this->page_largeur < 210) // To work with US executive format
640
+        {
641
+            $col2x-=20;
642
+        }
643
+        $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
644 644
 
645
-		$index=0;
645
+        $index=0;
646 646
 
647
-		// Total HT
648
-		$pdf->SetFillColor(255,255,255);
649
-		$pdf->SetXY($col1x, $tab2_top + 0);
650
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
647
+        // Total HT
648
+        $pdf->SetFillColor(255,255,255);
649
+        $pdf->SetXY($col1x, $tab2_top + 0);
650
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
651 651
 
652
-		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
653
-		$pdf->SetXY($col2x, $tab2_top + 0);
654
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1);
652
+        $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
653
+        $pdf->SetXY($col2x, $tab2_top + 0);
654
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1);
655 655
 
656
-		// Show VAT by rates and total
657
-		$pdf->SetFillColor(248,248,248);
656
+        // Show VAT by rates and total
657
+        $pdf->SetFillColor(248,248,248);
658 658
 
659
-		foreach( $this->tva as $tvakey => $tvaval )
660
-		{
661
-			if ($tvakey > 0)    // On affiche pas taux 0
662
-			{
663
-				$this->atleastoneratenotnull++;
659
+        foreach( $this->tva as $tvakey => $tvaval )
660
+        {
661
+            if ($tvakey > 0)    // On affiche pas taux 0
662
+            {
663
+                $this->atleastoneratenotnull++;
664 664
 
665
-				$index++;
666
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
665
+                $index++;
666
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
667 667
 
668
-				$tvacompl='';
668
+                $tvacompl='';
669 669
 
670
-				if (preg_match('/\*/',$tvakey))
671
-				{
672
-					$tvakey=str_replace('*','',$tvakey);
673
-					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
674
-				}
670
+                if (preg_match('/\*/',$tvakey))
671
+                {
672
+                    $tvakey=str_replace('*','',$tvakey);
673
+                    $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
674
+                }
675 675
 
676
-				$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
677
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
678
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
676
+                $totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
677
+                $totalvat.=vatrate($tvakey,1).$tvacompl;
678
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
679 679
 
680
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
681
-				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
682
-			}
683
-		}
684
-		if (! $this->atleastoneratenotnull) // If no vat at all
685
-		{
686
-			$index++;
687
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
688
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
689
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
690
-			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
691
-
692
-			// Total LocalTax1
693
-			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
694
-			{
695
-				$index++;
696
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
697
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
698
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
699
-				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1);
700
-			}
680
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
681
+                $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
682
+            }
683
+        }
684
+        if (! $this->atleastoneratenotnull) // If no vat at all
685
+        {
686
+            $index++;
687
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
688
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
689
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
690
+            $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
691
+
692
+            // Total LocalTax1
693
+            if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
694
+            {
695
+                $index++;
696
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
697
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
698
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
699
+                $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1);
700
+            }
701
+
702
+            // Total LocalTax2
703
+            if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
704
+            {
705
+                $index++;
706
+                $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
707
+                $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1);
708
+                $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
709
+                $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1);
710
+            }
711
+        }
712
+        else
713
+        {
714
+            //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
715
+            //{
716
+                //Local tax 1
717
+                foreach( $this->localtax1 as $tvakey => $tvaval )
718
+                {
719
+                    if ($tvakey != 0)    // On affiche pas taux 0
720
+                    {
721
+                        //$this->atleastoneratenotnull++;
722
+
723
+                        $index++;
724
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
725
+
726
+                        $tvacompl='';
727
+                        if (preg_match('/\*/',$tvakey))
728
+                        {
729
+                            $tvakey=str_replace('*','',$tvakey);
730
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
731
+                        }
732
+                        $totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
733
+                        $totalvat.= vatrate(abs($tvakey),1).$tvacompl;
734
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
735
+
736
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
737
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
738
+                    }
739
+                }
740
+            //}
701 741
 
702
-			// Total LocalTax2
703
-			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
704
-			{
705
-				$index++;
706
-				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
707
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1);
708
-				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
709
-				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1);
710
-			}
711
-		}
712
-		else
713
-		{
714
-			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
715
-			//{
716
-				//Local tax 1
717
-				foreach( $this->localtax1 as $tvakey => $tvaval )
718
-				{
719
-					if ($tvakey != 0)    // On affiche pas taux 0
720
-					{
721
-						//$this->atleastoneratenotnull++;
722
-
723
-						$index++;
724
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
725
-
726
-						$tvacompl='';
727
-						if (preg_match('/\*/',$tvakey))
728
-						{
729
-							$tvakey=str_replace('*','',$tvakey);
730
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
731
-						}
732
-						$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
733
-						$totalvat.= vatrate(abs($tvakey),1).$tvacompl;
734
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
735
-
736
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
737
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
738
-					}
739
-				}
740
-			//}
741
-
742
-			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
743
-			//{
744
-				//Local tax 2
745
-				foreach( $this->localtax2 as $tvakey => $tvaval )
746
-				{
747
-					if ($tvakey != 0)    // On affiche pas taux 0
748
-					{
749
-						//$this->atleastoneratenotnull++;
750
-
751
-						$index++;
752
-						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
753
-
754
-						$tvacompl='';
755
-						if (preg_match('/\*/',$tvakey))
756
-						{
757
-							$tvakey=str_replace('*','',$tvakey);
758
-							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
759
-						}
760
-						$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
761
-						$totalvat.= vatrate(abs($tvakey),1).$tvacompl;
762
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
763
-
764
-						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
765
-						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
766
-					}
767
-				}
768
-			//}
769
-		}
742
+            //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
743
+            //{
744
+                //Local tax 2
745
+                foreach( $this->localtax2 as $tvakey => $tvaval )
746
+                {
747
+                    if ($tvakey != 0)    // On affiche pas taux 0
748
+                    {
749
+                        //$this->atleastoneratenotnull++;
750
+
751
+                        $index++;
752
+                        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
753
+
754
+                        $tvacompl='';
755
+                        if (preg_match('/\*/',$tvakey))
756
+                        {
757
+                            $tvakey=str_replace('*','',$tvakey);
758
+                            $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
759
+                        }
760
+                        $totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
761
+                        $totalvat.= vatrate(abs($tvakey),1).$tvacompl;
762
+                        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
763
+
764
+                        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
765
+                        $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
766
+                    }
767
+                }
768
+            //}
769
+        }
770 770
 
771
-		$useborder=0;
771
+        $useborder=0;
772 772
 
773
-		// Total TTC
774
-		$index++;
775
-		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
776
-		$pdf->SetTextColor(0,0,60);
777
-		$pdf->SetFillColor(224,224,224);
778
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
773
+        // Total TTC
774
+        $index++;
775
+        $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
776
+        $pdf->SetTextColor(0,0,60);
777
+        $pdf->SetFillColor(224,224,224);
778
+        $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
779 779
 
780
-		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
781
-		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
782
-		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
780
+        $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
781
+        $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
782
+        $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
783 783
 
784
-		$creditnoteamount=0;
785
-		$depositsamount=0;
786
-		//$creditnoteamount=$object->getSumCreditNotesUsed();
787
-		//$depositsamount=$object->getSumDepositsUsed();
788
-		//print "x".$creditnoteamount."-".$depositsamount;exit;
789
-		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
790
-		if (! empty($object->paye)) $resteapayer=0;
784
+        $creditnoteamount=0;
785
+        $depositsamount=0;
786
+        //$creditnoteamount=$object->getSumCreditNotesUsed();
787
+        //$depositsamount=$object->getSumDepositsUsed();
788
+        //print "x".$creditnoteamount."-".$depositsamount;exit;
789
+        $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
790
+        if (! empty($object->paye)) $resteapayer=0;
791 791
 
792
-		if ($deja_regle > 0)
793
-		{
794
-			$index++;
792
+        if ($deja_regle > 0)
793
+        {
794
+            $index++;
795 795
 
796
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
797
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
796
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
797
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
798 798
 
799
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
800
-			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
799
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
800
+            $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
801 801
 
802
-			$index++;
803
-			$pdf->SetTextColor(0,0,60);
804
-			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
805
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
802
+            $index++;
803
+            $pdf->SetTextColor(0,0,60);
804
+            $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
805
+            $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
806 806
 
807
-			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
808
-			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
809
-			$pdf->SetFont('','', $default_font_size - 1);
810
-			$pdf->SetTextColor(0,0,0);
811
-		}
807
+            $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
808
+            $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
809
+            $pdf->SetFont('','', $default_font_size - 1);
810
+            $pdf->SetTextColor(0,0,0);
811
+        }
812 812
 
813
-		$index++;
814
-		return ($tab2_top + ($tab2_hl * $index));
815
-	}
816
-
817
-	/**
818
-	 *   Show table for lines
819
-	 *
820
-	 *   @param		PDF			$pdf     		Object PDF
821
-	 *   @param		string		$tab_top		Top position of table
822
-	 *   @param		string		$tab_height		Height of table (rectangle)
823
-	 *   @param		int			$nexY			Y (not used)
824
-	 *   @param		Translate	$outputlangs	Langs object
825
-	 *   @param		int			$hidetop		Hide top bar of array
826
-	 *   @param		int			$hidebottom		Hide bottom bar of array
827
-	 *   @param		string		$currency		Currency code
828
-	 *   @return	void
829
-	 */
830
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
831
-	{
832
-		global $conf;
833
-
834
-		// Force to disable hidetop and hidebottom
835
-		$hidebottom=0;
836
-		if ($hidetop) $hidetop=-1;
837
-
838
-		$currency = !empty($currency) ? $currency : $conf->currency;
839
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
813
+        $index++;
814
+        return ($tab2_top + ($tab2_hl * $index));
815
+    }
816
+
817
+    /**
818
+     *   Show table for lines
819
+     *
820
+     *   @param		PDF			$pdf     		Object PDF
821
+     *   @param		string		$tab_top		Top position of table
822
+     *   @param		string		$tab_height		Height of table (rectangle)
823
+     *   @param		int			$nexY			Y (not used)
824
+     *   @param		Translate	$outputlangs	Langs object
825
+     *   @param		int			$hidetop		Hide top bar of array
826
+     *   @param		int			$hidebottom		Hide bottom bar of array
827
+     *   @param		string		$currency		Currency code
828
+     *   @return	void
829
+     */
830
+    function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
831
+    {
832
+        global $conf;
833
+
834
+        // Force to disable hidetop and hidebottom
835
+        $hidebottom=0;
836
+        if ($hidetop) $hidetop=-1;
837
+
838
+        $currency = !empty($currency) ? $currency : $conf->currency;
839
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
840 840
 
841 841
         // Amount in (at tab_top - 1)
842
-		$pdf->SetTextColor(0,0,0);
843
-		$pdf->SetFont('','',$default_font_size - 2);
842
+        $pdf->SetTextColor(0,0,0);
843
+        $pdf->SetFont('','',$default_font_size - 2);
844 844
 
845
-		if (empty($hidetop))
846
-		{
847
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
848
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
849
-			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
845
+        if (empty($hidetop))
846
+        {
847
+            $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
848
+            $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
849
+            $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
850 850
 
851
-			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
852
-			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));
853
-		}
851
+            //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
852
+            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));
853
+        }
854 854
 
855
-		$pdf->SetDrawColor(128,128,128);
856
-		$pdf->SetFont('','', $default_font_size - 1);
855
+        $pdf->SetDrawColor(128,128,128);
856
+        $pdf->SetFont('','', $default_font_size - 1);
857 857
 
858
-		// Output Rect
859
-		$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
858
+        // Output Rect
859
+        $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
860 860
 
861
-		if (empty($hidetop))
862
-		{
863
-			$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
861
+        if (empty($hidetop))
862
+        {
863
+            $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
864 864
 
865
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
866
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
867
-		}
865
+            $pdf->SetXY($this->posxdesc-1, $tab_top+1);
866
+            $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
867
+        }
868 868
 
869 869
         if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
870 870
         {
871
-    		$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
872
-			if (empty($hidetop))
873
-			{
874
-    			$pdf->SetXY($this->posxtva-3, $tab_top+1);
875
-    			$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
876
-			}
871
+            $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
872
+            if (empty($hidetop))
873
+            {
874
+                $pdf->SetXY($this->posxtva-3, $tab_top+1);
875
+                $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
876
+            }
877 877
         }
878 878
 
879
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
880
-		if (empty($hidetop))
881
-		{
882
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
883
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
884
-		}
879
+        $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
880
+        if (empty($hidetop))
881
+        {
882
+            $pdf->SetXY($this->posxup-1, $tab_top+1);
883
+            $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
884
+        }
885 885
 
886
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
887
-		if (empty($hidetop))
888
-		{
889
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
890
-			if($conf->global->PRODUCT_USE_UNITS)
891
-			{
892
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
893
-			}
894
-			else
895
-			{
896
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
897
-			}
898
-		}
886
+        $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
887
+        if (empty($hidetop))
888
+        {
889
+            $pdf->SetXY($this->posxqty-1, $tab_top+1);
890
+            if($conf->global->PRODUCT_USE_UNITS)
891
+            {
892
+                $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
893
+            }
894
+            else
895
+            {
896
+                $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
897
+            }
898
+        }
899 899
 
900
-		if($conf->global->PRODUCT_USE_UNITS) {
901
-			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
902
-			if (empty($hidetop)) {
903
-				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
904
-				$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
905
-					'C');
906
-			}
907
-		}
900
+        if($conf->global->PRODUCT_USE_UNITS) {
901
+            $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
902
+            if (empty($hidetop)) {
903
+                $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
904
+                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
905
+                    'C');
906
+            }
907
+        }
908 908
 
909
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
910
-		if (empty($hidetop))
911
-		{
912
-			if ($this->atleastonediscount)
913
-			{
914
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
915
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
916
-			}
917
-		}
909
+        $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
910
+        if (empty($hidetop))
911
+        {
912
+            if ($this->atleastonediscount)
913
+            {
914
+                $pdf->SetXY($this->posxdiscount-1, $tab_top+1);
915
+                $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
916
+            }
917
+        }
918 918
 
919
-		if ($this->atleastonediscount)
920
-		{
921
-			$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
922
-		}
923
-		if (empty($hidetop))
924
-		{
925
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
926
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C');
927
-		}
928
-	}
919
+        if ($this->atleastonediscount)
920
+        {
921
+            $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
922
+        }
923
+        if (empty($hidetop))
924
+        {
925
+            $pdf->SetXY($this->postotalht-1, $tab_top+1);
926
+            $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C');
927
+        }
928
+    }
929 929
 
930 930
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
931
-	/**
932
-	 *  Show payments table
933
-	 *
934
-	 *  @param	PDF			$pdf     		Object PDF
935
-	 *  @param  FactureFournisseur		$object     	Object invoice
936
-	 *	@param	int			$posy			Position y in PDF
937
-	 *	@param	Translate	$outputlangs	Object langs for output
938
-	 *	@return int							<0 if KO, >0 if OK
939
-	 */
940
-	function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
941
-	{
931
+    /**
932
+     *  Show payments table
933
+     *
934
+     *  @param	PDF			$pdf     		Object PDF
935
+     *  @param  FactureFournisseur		$object     	Object invoice
936
+     *	@param	int			$posy			Position y in PDF
937
+     *	@param	Translate	$outputlangs	Object langs for output
938
+     *	@return int							<0 if KO, >0 if OK
939
+     */
940
+    function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
941
+    {
942 942
         // phpcs:enable
943
-		global $conf;
943
+        global $conf;
944 944
 
945
-		$sign=1;
946
-		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
945
+        $sign=1;
946
+        if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
947 947
 
948
-		$tab3_posx = 120;
949
-		$tab3_top = $posy + 8;
950
-		$tab3_width = 80;
951
-		$tab3_height = 4;
952
-		if ($this->page_largeur < 210) // To work with US executive format
953
-		{
954
-			$tab3_posx -= 20;
955
-		}
948
+        $tab3_posx = 120;
949
+        $tab3_top = $posy + 8;
950
+        $tab3_width = 80;
951
+        $tab3_height = 4;
952
+        if ($this->page_largeur < 210) // To work with US executive format
953
+        {
954
+            $tab3_posx -= 20;
955
+        }
956 956
 
957
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
957
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
958 958
 
959
-		$pdf->SetFont('','', $default_font_size - 3);
960
-		$pdf->SetXY($tab3_posx, $tab3_top - 4);
961
-		$pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
959
+        $pdf->SetFont('','', $default_font_size - 3);
960
+        $pdf->SetXY($tab3_posx, $tab3_top - 4);
961
+        $pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
962 962
 
963
-		$pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
963
+        $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
964 964
 
965
-		$pdf->SetFont('','', $default_font_size - 4);
966
-		$pdf->SetXY($tab3_posx, $tab3_top);
967
-		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
968
-		$pdf->SetXY($tab3_posx+21, $tab3_top);
969
-		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
970
-		$pdf->SetXY($tab3_posx+40, $tab3_top);
971
-		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
972
-		$pdf->SetXY($tab3_posx+58, $tab3_top);
973
-		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
965
+        $pdf->SetFont('','', $default_font_size - 4);
966
+        $pdf->SetXY($tab3_posx, $tab3_top);
967
+        $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
968
+        $pdf->SetXY($tab3_posx+21, $tab3_top);
969
+        $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
970
+        $pdf->SetXY($tab3_posx+40, $tab3_top);
971
+        $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
972
+        $pdf->SetXY($tab3_posx+58, $tab3_top);
973
+        $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
974 974
 
975
-		$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
975
+        $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
976 976
 
977
-		$y=0;
977
+        $y=0;
978 978
 
979
-		$pdf->SetFont('','', $default_font_size - 4);
979
+        $pdf->SetFont('','', $default_font_size - 4);
980 980
 
981
-		// Loop on each deposits and credit notes included
982
-		//
981
+        // Loop on each deposits and credit notes included
982
+        //
983 983
 
984
-		// Loop on each payment
985
-		$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
986
-		$sql.= " cp.code";
987
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
988
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
989
-		$sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
990
-		$sql.= " ORDER BY p.datep";
991
-		$resql=$this->db->query($sql);
992
-		if ($resql)
993
-		{
994
-		    $num = $this->db->num_rows($resql);
995
-			$i=0;
996
-			while ($i < $num) {
997
-			    $y+=3;
998
-				$row = $this->db->fetch_object($resql);
999
-
1000
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
1001
-				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
1002
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
1003
-				$pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
1004
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
1005
-				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
1006
-
1007
-				$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
1008
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
1009
-				$pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
1010
-
1011
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
1012
-
1013
-				$i++;
1014
-			}
1015
-		}
1016
-		else
1017
-		{
1018
-			$this->error=$this->db->lasterror();
1019
-			return -1;
1020
-		}
1021
-	}
984
+        // Loop on each payment
985
+        $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
986
+        $sql.= " cp.code";
987
+        $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
988
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
989
+        $sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
990
+        $sql.= " ORDER BY p.datep";
991
+        $resql=$this->db->query($sql);
992
+        if ($resql)
993
+        {
994
+            $num = $this->db->num_rows($resql);
995
+            $i=0;
996
+            while ($i < $num) {
997
+                $y+=3;
998
+                $row = $this->db->fetch_object($resql);
999
+
1000
+                $pdf->SetXY($tab3_posx, $tab3_top+$y);
1001
+                $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
1002
+                $pdf->SetXY($tab3_posx+21, $tab3_top+$y);
1003
+                $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
1004
+                $pdf->SetXY($tab3_posx+40, $tab3_top+$y);
1005
+                $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
1006
+
1007
+                $pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
1008
+                $pdf->SetXY($tab3_posx+58, $tab3_top+$y);
1009
+                $pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
1010
+
1011
+                $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
1012
+
1013
+                $i++;
1014
+            }
1015
+        }
1016
+        else
1017
+        {
1018
+            $this->error=$this->db->lasterror();
1019
+            return -1;
1020
+        }
1021
+    }
1022 1022
 
1023
-	/**
1024
-	 *  Show top header of page.
1025
-	 *
1026
-	 *  @param	PDF			$pdf     		Object PDF
1027
-	 *  @param  FactureFournisseur		$object     	Object to show
1028
-	 *  @param  int	    	$showaddress    0=no, 1=yes
1029
-	 *  @param  Translate	$outputlangs	Object lang for output
1030
-	 *  @return	void
1031
-	 */
1032
-	function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1033
-	{
1034
-		global $langs, $conf, $mysoc;
1023
+    /**
1024
+     *  Show top header of page.
1025
+     *
1026
+     *  @param	PDF			$pdf     		Object PDF
1027
+     *  @param  FactureFournisseur		$object     	Object to show
1028
+     *  @param  int	    	$showaddress    0=no, 1=yes
1029
+     *  @param  Translate	$outputlangs	Object lang for output
1030
+     *  @return	void
1031
+     */
1032
+    function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1033
+    {
1034
+        global $langs, $conf, $mysoc;
1035 1035
 
1036
-		// Load translation files required by the page
1037
-		$outputlangs->loadLangs(array("main", "orders", "companies", "bills"));
1036
+        // Load translation files required by the page
1037
+        $outputlangs->loadLangs(array("main", "orders", "companies", "bills"));
1038 1038
 
1039
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
1039
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
1040 1040
 
1041
-		// Do not add the BACKGROUND as this is for suppliers
1042
-		//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1041
+        // Do not add the BACKGROUND as this is for suppliers
1042
+        //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1043 1043
 
1044
-		$pdf->SetTextColor(0,0,60);
1045
-		$pdf->SetFont('','B', $default_font_size + 3);
1044
+        $pdf->SetTextColor(0,0,60);
1045
+        $pdf->SetFont('','B', $default_font_size + 3);
1046 1046
 
1047
-		$posy=$this->marge_haute;
1048
-		$posx=$this->page_largeur-$this->marge_droite-100;
1047
+        $posy=$this->marge_haute;
1048
+        $posx=$this->page_largeur-$this->marge_droite-100;
1049 1049
 
1050
-		$pdf->SetXY($this->marge_gauche,$posy);
1050
+        $pdf->SetXY($this->marge_gauche,$posy);
1051 1051
 
1052
-		// Logo
1053
-		/*
1052
+        // Logo
1053
+        /*
1054 1054
 		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1055 1055
 		if ($mysoc->logo)
1056 1056
 		{
@@ -1069,183 +1069,183 @@  discard block
 block discarded – undo
1069 1069
 		}
1070 1070
 		else
1071 1071
 		{*/
1072
-			$text=$this->emetteur->name;
1073
-			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1074
-		//}
1075
-
1076
-		$pdf->SetFont('','B', $default_font_size + 3);
1077
-		$pdf->SetXY($posx,$posy);
1078
-		$pdf->SetTextColor(0,0,60);
1079
-		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1080
-		$posy+=1;
1081
-
1082
-		if ($object->ref_supplier)
1083
-		{
1084
-    		$posy+=4;
1085
-			$pdf->SetFont('','B', $default_font_size);
1086
-    		$pdf->SetXY($posx,$posy);
1087
-			$pdf->SetTextColor(0,0,60);
1088
-    		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
1089
-			$posy+=1;
1090
-		}
1091
-
1092
-		$pdf->SetFont('','', $default_font_size - 1);
1093
-
1094
-		if (! empty($conf->global->PDF_SHOW_PROJECT))
1095
-		{
1096
-			$object->fetch_projet();
1097
-			if (! empty($object->project->ref))
1098
-			{
1099
-        		$posy+=4;
1100
-				$pdf->SetXY($posx,$posy);
1101
-        		$langs->load("projects");
1102
-				$pdf->SetTextColor(0,0,60);
1103
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
1104
-			}
1105
-		}
1106
-
1107
-		if ($object->date)
1108
-		{
1109
-			$posy+=4;
1110
-			$pdf->SetXY($posx,$posy);
1111
-			$pdf->SetTextColor(0,0,60);
1112
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1113
-		}
1114
-		else
1115
-		{
1116
-			$posy+=4;
1117
-			$pdf->SetXY($posx,$posy);
1118
-			$pdf->SetTextColor(255,0,0);
1119
-			$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
1120
-		}
1121
-
1122
-		if ($object->thirdparty->code_fournisseur)
1123
-		{
1124
-			$posy+=4;
1125
-			$pdf->SetXY($posx,$posy);
1126
-			$pdf->SetTextColor(0,0,60);
1127
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1128
-		}
1072
+            $text=$this->emetteur->name;
1073
+            $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1074
+        //}
1129 1075
 
1130
-		$posy+=1;
1131
-		$pdf->SetTextColor(0,0,60);
1076
+        $pdf->SetFont('','B', $default_font_size + 3);
1077
+        $pdf->SetXY($posx,$posy);
1078
+        $pdf->SetTextColor(0,0,60);
1079
+        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1080
+        $posy+=1;
1132 1081
 
1133
-		$top_shift = 0;
1134
-		// Show list of linked objects
1135
-		$current_y = $pdf->getY();
1136
-		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1137
-		if ($current_y < $pdf->getY())
1138
-		{
1139
-			$top_shift = $pdf->getY() - $current_y;
1140
-		}
1141
-
1142
-		if ($showaddress)
1143
-		{
1144
-			// Sender properties
1145
-		    $carac_emetteur='';
1146
-		    // Add internal contact of proposal if defined
1147
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1148
-		    if (count($arrayidcontact) > 0)
1149
-		    {
1150
-		        $object->fetch_user($arrayidcontact[0]);
1151
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1152
-		    }
1153
-
1154
-		    $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1155
-
1156
-			// Show sender
1157
-			$posy=42+$top_shift;
1158
-			$posx=$this->marge_gauche;
1159
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1160
-			$hautcadre=40;
1161
-
1162
-			// Show sender frame
1163
-			$pdf->SetTextColor(0,0,0);
1164
-			$pdf->SetFont('','', $default_font_size - 2);
1165
-			$pdf->SetXY($posx,$posy-5);
1166
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1167
-			$pdf->SetXY($posx,$posy);
1168
-			$pdf->SetFillColor(230,230,230);
1169
-			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1170
-			$pdf->SetTextColor(0,0,60);
1171
-
1172
-			// Show sender name
1173
-			$pdf->SetXY($posx+2,$posy+3);
1174
-			$pdf->SetFont('','B', $default_font_size);
1175
-			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1176
-			$posy=$pdf->getY();
1177
-
1178
-			// Show sender information
1179
-			$pdf->SetXY($posx+2,$posy);
1180
-			$pdf->SetFont('','', $default_font_size - 1);
1181
-			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1182
-
1183
-
1184
-
1185
-			// If BILLING contact defined on invoice, we use it
1186
-			$usecontact=false;
1187
-			$arrayidcontact=$object->getIdContact('internal','BILLING');
1188
-			if (count($arrayidcontact) > 0)
1189
-			{
1190
-				$usecontact=true;
1191
-				$result=$object->fetch_contact($arrayidcontact[0]);
1192
-			}
1193
-
1194
-			//Recipient name
1195
-			// On peut utiliser le nom de la societe du contact
1196
-			if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1197
-				$thirdparty = $object->contact;
1198
-			} else {
1199
-				$thirdparty = $mysoc;
1200
-			}
1082
+        if ($object->ref_supplier)
1083
+        {
1084
+            $posy+=4;
1085
+            $pdf->SetFont('','B', $default_font_size);
1086
+            $pdf->SetXY($posx,$posy);
1087
+            $pdf->SetTextColor(0,0,60);
1088
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
1089
+            $posy+=1;
1090
+        }
1201 1091
 
1202
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1092
+        $pdf->SetFont('','', $default_font_size - 1);
1203 1093
 
1204
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
1094
+        if (! empty($conf->global->PDF_SHOW_PROJECT))
1095
+        {
1096
+            $object->fetch_projet();
1097
+            if (! empty($object->project->ref))
1098
+            {
1099
+                $posy+=4;
1100
+                $pdf->SetXY($posx,$posy);
1101
+                $langs->load("projects");
1102
+                $pdf->SetTextColor(0,0,60);
1103
+                $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
1104
+            }
1105
+        }
1205 1106
 
1206
-			// Show recipient
1207
-			$widthrecbox=100;
1208
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1209
-			$posy=42+$top_shift;
1210
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1211
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1107
+        if ($object->date)
1108
+        {
1109
+            $posy+=4;
1110
+            $pdf->SetXY($posx,$posy);
1111
+            $pdf->SetTextColor(0,0,60);
1112
+            $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1113
+        }
1114
+        else
1115
+        {
1116
+            $posy+=4;
1117
+            $pdf->SetXY($posx,$posy);
1118
+            $pdf->SetTextColor(255,0,0);
1119
+            $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
1120
+        }
1212 1121
 
1213
-			// Show recipient frame
1214
-			$pdf->SetTextColor(0,0,0);
1215
-			$pdf->SetFont('','', $default_font_size - 2);
1216
-			$pdf->SetXY($posx+2,$posy-5);
1217
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1218
-			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1122
+        if ($object->thirdparty->code_fournisseur)
1123
+        {
1124
+            $posy+=4;
1125
+            $pdf->SetXY($posx,$posy);
1126
+            $pdf->SetTextColor(0,0,60);
1127
+            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1128
+        }
1219 1129
 
1220
-			// Show recipient name
1221
-			$pdf->SetXY($posx+2,$posy+3);
1222
-			$pdf->SetFont('','B', $default_font_size);
1223
-			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1130
+        $posy+=1;
1131
+        $pdf->SetTextColor(0,0,60);
1224 1132
 
1225
-			$posy = $pdf->getY();
1133
+        $top_shift = 0;
1134
+        // Show list of linked objects
1135
+        $current_y = $pdf->getY();
1136
+        $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1137
+        if ($current_y < $pdf->getY())
1138
+        {
1139
+            $top_shift = $pdf->getY() - $current_y;
1140
+        }
1226 1141
 
1227
-			// Show recipient information
1228
-			$pdf->SetFont('','', $default_font_size - 1);
1229
-			$pdf->SetXY($posx+2,$posy);
1230
-			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1231
-		}
1142
+        if ($showaddress)
1143
+        {
1144
+            // Sender properties
1145
+            $carac_emetteur='';
1146
+            // Add internal contact of proposal if defined
1147
+            $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1148
+            if (count($arrayidcontact) > 0)
1149
+            {
1150
+                $object->fetch_user($arrayidcontact[0]);
1151
+                $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1152
+            }
1153
+
1154
+            $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1155
+
1156
+            // Show sender
1157
+            $posy=42+$top_shift;
1158
+            $posx=$this->marge_gauche;
1159
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1160
+            $hautcadre=40;
1161
+
1162
+            // Show sender frame
1163
+            $pdf->SetTextColor(0,0,0);
1164
+            $pdf->SetFont('','', $default_font_size - 2);
1165
+            $pdf->SetXY($posx,$posy-5);
1166
+            $pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1167
+            $pdf->SetXY($posx,$posy);
1168
+            $pdf->SetFillColor(230,230,230);
1169
+            $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1170
+            $pdf->SetTextColor(0,0,60);
1171
+
1172
+            // Show sender name
1173
+            $pdf->SetXY($posx+2,$posy+3);
1174
+            $pdf->SetFont('','B', $default_font_size);
1175
+            $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1176
+            $posy=$pdf->getY();
1177
+
1178
+            // Show sender information
1179
+            $pdf->SetXY($posx+2,$posy);
1180
+            $pdf->SetFont('','', $default_font_size - 1);
1181
+            $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1182
+
1183
+
1184
+
1185
+            // If BILLING contact defined on invoice, we use it
1186
+            $usecontact=false;
1187
+            $arrayidcontact=$object->getIdContact('internal','BILLING');
1188
+            if (count($arrayidcontact) > 0)
1189
+            {
1190
+                $usecontact=true;
1191
+                $result=$object->fetch_contact($arrayidcontact[0]);
1192
+            }
1193
+
1194
+            //Recipient name
1195
+            // On peut utiliser le nom de la societe du contact
1196
+            if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
1197
+                $thirdparty = $object->contact;
1198
+            } else {
1199
+                $thirdparty = $mysoc;
1200
+            }
1201
+
1202
+            $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1203
+
1204
+            $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
1205
+
1206
+            // Show recipient
1207
+            $widthrecbox=100;
1208
+            if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1209
+            $posy=42+$top_shift;
1210
+            $posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1211
+            if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1212
+
1213
+            // Show recipient frame
1214
+            $pdf->SetTextColor(0,0,0);
1215
+            $pdf->SetFont('','', $default_font_size - 2);
1216
+            $pdf->SetXY($posx+2,$posy-5);
1217
+            $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1218
+            $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1219
+
1220
+            // Show recipient name
1221
+            $pdf->SetXY($posx+2,$posy+3);
1222
+            $pdf->SetFont('','B', $default_font_size);
1223
+            $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1224
+
1225
+            $posy = $pdf->getY();
1226
+
1227
+            // Show recipient information
1228
+            $pdf->SetFont('','', $default_font_size - 1);
1229
+            $pdf->SetXY($posx+2,$posy);
1230
+            $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1231
+        }
1232 1232
 
1233
-		return $top_shift;
1234
-	}
1233
+        return $top_shift;
1234
+    }
1235 1235
 
1236
-	/**
1237
-	 *   	Show footer of page. Need this->emetteur object
1236
+    /**
1237
+     *   	Show footer of page. Need this->emetteur object
1238 1238
      *
1239
-	 *   	@param	PDF			$pdf     			PDF
1240
-	 * 		@param	FactureFournisseur		$object				Object to show
1241
-	 *      @param	Translate	$outputlangs		Object lang for output
1242
-	 *      @param	int			$hidefreetext		1=Hide free text
1243
-	 *      @return	int								Return height of bottom margin including footer text
1244
-	 */
1245
-	function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
1246
-	{
1247
-		global $conf;
1248
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1249
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1250
-	}
1239
+     *   	@param	PDF			$pdf     			PDF
1240
+     * 		@param	FactureFournisseur		$object				Object to show
1241
+     *      @param	Translate	$outputlangs		Object lang for output
1242
+     *      @param	int			$hidefreetext		1=Hide free text
1243
+     *      @return	int								Return height of bottom margin including footer text
1244
+     */
1245
+    function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
1246
+    {
1247
+        global $conf;
1248
+        $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1249
+        return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1250
+    }
1251 1251
 }
Please login to merge, or discard this patch.
Spacing   +343 added lines, -343 removed lines patch added patch discarded remove patch
@@ -130,56 +130,56 @@  discard block
 block discarded – undo
130 130
 
131 131
 		// Dimension page pour format A4
132 132
 		$this->type = 'pdf';
133
-		$formatarray=pdf_getFormat();
133
+		$formatarray = pdf_getFormat();
134 134
 		$this->page_largeur = $formatarray['width'];
135 135
 		$this->page_hauteur = $formatarray['height'];
136
-		$this->format = array($this->page_largeur,$this->page_hauteur);
137
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
138
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
139
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
140
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
136
+		$this->format = array($this->page_largeur, $this->page_hauteur);
137
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
138
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
139
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
140
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
141 141
 
142
-		$this->option_logo = 1;                    // Affiche logo
143
-		$this->option_tva = 1;                     // Gere option tva FACTURE_TVAOPTION
144
-		$this->option_modereg = 1;                 // Affiche mode reglement
145
-		$this->option_condreg = 1;                 // Affiche conditions reglement
146
-		$this->option_codeproduitservice = 1;      // Affiche code produit-service
147
-		$this->option_multilang = 1;               // Dispo en plusieurs langues
142
+		$this->option_logo = 1; // Affiche logo
143
+		$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
144
+		$this->option_modereg = 1; // Affiche mode reglement
145
+		$this->option_condreg = 1; // Affiche conditions reglement
146
+		$this->option_codeproduitservice = 1; // Affiche code produit-service
147
+		$this->option_multilang = 1; // Dispo en plusieurs langues
148 148
 
149
-		$this->franchise=!$mysoc->tva_assuj;
149
+		$this->franchise = !$mysoc->tva_assuj;
150 150
 
151 151
         // Defini position des colonnes
152
-		$this->posxdesc=$this->marge_gauche+1;
153
-		$this->posxtva=112;
154
-		$this->posxup=126;
155
-		$this->posxqty=145;
156
-		$this->posxdiscount=162;
157
-		$this->postotalht=174;
158
-
159
-		if($conf->global->PRODUCT_USE_UNITS) {
160
-			$this->posxtva=99;
161
-			$this->posxup=114;
162
-			$this->posxqty=130;
163
-			$this->posxunit=147;
152
+		$this->posxdesc = $this->marge_gauche + 1;
153
+		$this->posxtva = 112;
154
+		$this->posxup = 126;
155
+		$this->posxqty = 145;
156
+		$this->posxdiscount = 162;
157
+		$this->postotalht = 174;
158
+
159
+		if ($conf->global->PRODUCT_USE_UNITS) {
160
+			$this->posxtva = 99;
161
+			$this->posxup = 114;
162
+			$this->posxqty = 130;
163
+			$this->posxunit = 147;
164 164
 		}
165 165
 		//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
166
-		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
166
+		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
167 167
 		if ($this->page_largeur < 210) // To work with US executive format
168 168
 		{
169
-			$this->posxpicture-=20;
170
-			$this->posxtva-=20;
171
-			$this->posxup-=20;
172
-			$this->posxqty-=20;
173
-			$this->posxunit-=20;
174
-			$this->posxdiscount-=20;
175
-			$this->postotalht-=20;
169
+			$this->posxpicture -= 20;
170
+			$this->posxtva -= 20;
171
+			$this->posxup -= 20;
172
+			$this->posxqty -= 20;
173
+			$this->posxunit -= 20;
174
+			$this->posxdiscount -= 20;
175
+			$this->postotalht -= 20;
176 176
 		}
177 177
 
178
-		$this->tva=array();
179
-        $this->localtax1=array();
180
-        $this->localtax2=array();
181
-		$this->atleastoneratenotnull=0;
182
-		$this->atleastonediscount=0;
178
+		$this->tva = array();
179
+        $this->localtax1 = array();
180
+        $this->localtax2 = array();
181
+		$this->atleastoneratenotnull = 0;
182
+		$this->atleastonediscount = 0;
183 183
 	}
184 184
 
185 185
 
@@ -195,20 +195,20 @@  discard block
 block discarded – undo
195 195
      *  @param		int					$hideref			Do not show ref
196 196
      *  @return		int										1=OK, 0=KO
197 197
      */
198
-	function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
198
+	function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
199 199
 	{
200 200
         // phpcs:enable
201
-		global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes;
201
+		global $user, $langs, $conf, $mysoc, $hookmanager, $nblignes;
202 202
 
203 203
 		// Get source company
204
-		if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
205
-		if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc;	// If fetch_thirdparty fails, object has no socid (specimen)
206
-		$this->emetteur=$object->thirdparty;
207
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
204
+		if (!is_object($object->thirdparty)) $object->fetch_thirdparty();
205
+		if (!is_object($object->thirdparty)) $object->thirdparty = $mysoc; // If fetch_thirdparty fails, object has no socid (specimen)
206
+		$this->emetteur = $object->thirdparty;
207
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
208 208
 
209
-		if (! is_object($outputlangs)) $outputlangs=$langs;
209
+		if (!is_object($outputlangs)) $outputlangs = $langs;
210 210
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
211
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
211
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
212 212
 
213 213
 		// Load translation files required by the page
214 214
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products"));
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
 			if ($object->specimen)
226 226
 			{
227 227
 				$dir = $conf->fournisseur->facture->dir_output;
228
-				$file = $dir . "/SPECIMEN.pdf";
228
+				$file = $dir."/SPECIMEN.pdf";
229 229
 			}
230 230
 			else
231 231
 			{
232 232
 				$objectref = dol_sanitizeFileName($object->ref);
233 233
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
234
-                $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$objectref;
235
-				$file = $dir . "/" . $objectref . ".pdf";
236
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
234
+                $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$objectref;
235
+				$file = $dir."/".$objectref.".pdf";
236
+				if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
237 237
 			}
238 238
 
239
-			if (! file_exists($dir))
239
+			if (!file_exists($dir))
240 240
 			{
241 241
 				if (dol_mkdir($dir) < 0)
242 242
 				{
243
-					$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
243
+					$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
244 244
 					return 0;
245 245
 				}
246 246
 			}
@@ -248,25 +248,25 @@  discard block
 block discarded – undo
248 248
 			if (file_exists($dir))
249 249
 			{
250 250
 				// Add pdfgeneration hook
251
-				if (! is_object($hookmanager))
251
+				if (!is_object($hookmanager))
252 252
 				{
253 253
 					include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
254
-					$hookmanager=new HookManager($this->db);
254
+					$hookmanager = new HookManager($this->db);
255 255
 				}
256 256
 				$hookmanager->initHooks(array('pdfgeneration'));
257
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
257
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
258 258
 				global $action;
259
-				$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
259
+				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
260 260
 
261 261
 				$nblignes = count($object->lines);
262 262
 
263
-                $pdf=pdf_getInstance($this->format);
264
-                $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
265
-                $heightforinfotot = 50;	// Height reserved to output the info and total part
266
-		        $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
267
-	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
268
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
269
-                $pdf->SetAutoPageBreak(1,0);
263
+                $pdf = pdf_getInstance($this->format);
264
+                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
265
+                $heightforinfotot = 50; // Height reserved to output the info and total part
266
+		        $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
267
+	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
268
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
269
+                $pdf->SetAutoPageBreak(1, 0);
270 270
 
271 271
                 if (class_exists('TCPDF'))
272 272
                 {
@@ -275,27 +275,27 @@  discard block
 block discarded – undo
275 275
                 }
276 276
                 $pdf->SetFont(pdf_getPDFFont($outputlangs));
277 277
                 // Set path to the background PDF File
278
-                if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
278
+                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
279 279
                 {
280 280
                     $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
281 281
                     $tplidx = $pdf->importPage(1);
282 282
                 }
283 283
 
284 284
 				$pdf->Open();
285
-				$pagenb=0;
286
-				$pdf->SetDrawColor(128,128,128);
285
+				$pagenb = 0;
286
+				$pdf->SetDrawColor(128, 128, 128);
287 287
 
288 288
 				$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
289 289
 				$pdf->SetSubject($outputlangs->transnoentities("Invoice"));
290 290
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
291 291
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
292 292
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
293
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
293
+				if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
294 294
 
295
-				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
295
+				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
296 296
 
297 297
 			    // Positionne $this->atleastonediscount si on a au moins une remise
298
-                for ($i = 0 ; $i < $nblignes ; $i++)
298
+                for ($i = 0; $i < $nblignes; $i++)
299 299
                 {
300 300
                     if ($object->lines[$i]->remise_percent)
301 301
                     {
@@ -304,25 +304,25 @@  discard block
 block discarded – undo
304 304
                 }
305 305
 				if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
306 306
 				{
307
-					$this->posxpicture+=($this->postotalht - $this->posxdiscount);
308
-					$this->posxtva+=($this->postotalht - $this->posxdiscount);
309
-					$this->posxup+=($this->postotalht - $this->posxdiscount);
310
-					$this->posxqty+=($this->postotalht - $this->posxdiscount);
311
-					$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
307
+					$this->posxpicture += ($this->postotalht - $this->posxdiscount);
308
+					$this->posxtva += ($this->postotalht - $this->posxdiscount);
309
+					$this->posxup += ($this->postotalht - $this->posxdiscount);
310
+					$this->posxqty += ($this->postotalht - $this->posxdiscount);
311
+					$this->posxdiscount += ($this->postotalht - $this->posxdiscount);
312 312
 					//$this->postotalht;
313 313
 				}
314 314
 
315 315
                 // New page
316 316
 				$pdf->AddPage();
317
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
317
+				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
318 318
 				$pagenb++;
319 319
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
320
-				$pdf->SetFont('','', $default_font_size - 1);
321
-				$pdf->MultiCell(0, 3, '');		// Set interline to 3
322
-				$pdf->SetTextColor(0,0,0);
320
+				$pdf->SetFont('', '', $default_font_size - 1);
321
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
322
+				$pdf->SetTextColor(0, 0, 0);
323 323
 
324
-				$tab_top = 90+$top_shift;
325
-				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
324
+				$tab_top = 90 + $top_shift;
325
+				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
326 326
 
327 327
 				// Incoterm
328 328
 				if ($conf->incoterm->enabled)
@@ -332,34 +332,34 @@  discard block
 block discarded – undo
332 332
 					{
333 333
 						$tab_top -= 2;
334 334
 
335
-						$pdf->SetFont('','', $default_font_size - 1);
336
-						$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
335
+						$pdf->SetFont('', '', $default_font_size - 1);
336
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
337 337
 						$nexY = $pdf->GetY();
338
-						$height_incoterms=$nexY-$tab_top;
338
+						$height_incoterms = $nexY - $tab_top;
339 339
 
340 340
 						// Rect prend une longueur en 3eme param
341
-						$pdf->SetDrawColor(192,192,192);
342
-						$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
341
+						$pdf->SetDrawColor(192, 192, 192);
342
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
343 343
 
344
-						$tab_top = $nexY+6;
344
+						$tab_top = $nexY + 6;
345 345
 					}
346 346
 				}
347 347
 
348 348
 				// Affiche notes
349
-				if (! empty($object->note_public))
349
+				if (!empty($object->note_public))
350 350
 				{
351 351
 					$tab_top -= 2;
352 352
 
353
-					$pdf->SetFont('','', $default_font_size - 1);
354
-					$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
353
+					$pdf->SetFont('', '', $default_font_size - 1);
354
+					$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($object->note_public), 0, 1);
355 355
 					$nexY = $pdf->GetY();
356
-					$height_note=$nexY-$tab_top;
356
+					$height_note = $nexY - $tab_top;
357 357
 
358 358
 					// Rect prend une longueur en 3eme param
359
-					$pdf->SetDrawColor(192,192,192);
360
-					$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
359
+					$pdf->SetDrawColor(192, 192, 192);
360
+					$pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
361 361
 
362
-					$tab_top = $nexY+6;
362
+					$tab_top = $nexY + 6;
363 363
 				}
364 364
 
365 365
 				$iniY = $tab_top + 7;
@@ -367,45 +367,45 @@  discard block
 block discarded – undo
367 367
 				$nexY = $tab_top + 7;
368 368
 
369 369
 				// Loop on each lines
370
-				for ($i = 0 ; $i < $nblignes ; $i++)
370
+				for ($i = 0; $i < $nblignes; $i++)
371 371
 				{
372 372
 					$curY = $nexY;
373
-					$pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
374
-					$pdf->SetTextColor(0,0,0);
373
+					$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
374
+					$pdf->SetTextColor(0, 0, 0);
375 375
 
376 376
 					$pdf->setTopMargin($tab_top_newpage);
377
-					$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
378
-					$pageposbefore=$pdf->getPage();
377
+					$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
378
+					$pageposbefore = $pdf->getPage();
379 379
 
380 380
 					// Description of product line
381
-					$curX = $this->posxdesc-1;
382
-					$showpricebeforepagebreak=1;
381
+					$curX = $this->posxdesc - 1;
382
+					$showpricebeforepagebreak = 1;
383 383
 
384 384
 					$pdf->startTransaction();
385
-					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
386
-					$pageposafter=$pdf->getPage();
385
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc, 1);
386
+					$pageposafter = $pdf->getPage();
387 387
 					if ($pageposafter > $pageposbefore)	// There is a pagebreak
388 388
 					{
389 389
 						$pdf->rollbackTransaction(true);
390
-						$pageposafter=$pageposbefore;
390
+						$pageposafter = $pageposbefore;
391 391
 						//print $pageposafter.'-'.$pageposbefore;exit;
392
-						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
393
-						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
394
-						$posyafter=$pdf->GetY();
395
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
392
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
393
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc, 1);
394
+						$posyafter = $pdf->GetY();
395
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
396 396
 						{
397
-							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
397
+							if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
398 398
 							{
399
-								$pdf->AddPage('','',true);
400
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
399
+								$pdf->AddPage('', '', true);
400
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
401 401
 								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
402
-								$pdf->setPage($pageposafter+1);
402
+								$pdf->setPage($pageposafter + 1);
403 403
 							}
404 404
 						}
405 405
 						else
406 406
 						{
407 407
 							// We found a page break
408
-							$showpricebeforepagebreak=0;
408
+							$showpricebeforepagebreak = 0;
409 409
 						}
410 410
 					}
411 411
 					else	// No pagebreak
@@ -414,55 +414,55 @@  discard block
 block discarded – undo
414 414
 					}
415 415
 
416 416
 					$nexY = $pdf->GetY();
417
-                    $pageposafter=$pdf->getPage();
417
+                    $pageposafter = $pdf->getPage();
418 418
 					$pdf->setPage($pageposbefore);
419 419
 					$pdf->setTopMargin($this->marge_haute);
420
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
420
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
421 421
 
422 422
 					// We suppose that a too long description is moved completely on next page
423 423
 					if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
424 424
 						$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
425 425
 					}
426 426
 
427
-					$pdf->SetFont('','', $default_font_size - 1);   // On repositionne la police par defaut
427
+					$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
428 428
 
429 429
 					// VAT Rate
430 430
                     if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
431 431
                     {
432 432
     					$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
433 433
                         $pdf->SetXY($this->posxtva, $curY);
434
-	       				$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
434
+	       				$pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
435 435
                     }
436 436
 
437 437
 					// Unit price before discount
438 438
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
439 439
 					$pdf->SetXY($this->posxup, $curY);
440
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
440
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
441 441
 
442 442
 					// Unit price before discount
443 443
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
444 444
 					$pdf->SetXY($this->posxup, $curY);
445
-					$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
445
+					$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0, 'R', 0);
446 446
 
447 447
 					// Quantity
448 448
 					$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
449 449
 					$pdf->SetXY($this->posxqty, $curY);
450 450
 					// Enough for 6 chars
451
-					if($conf->global->PRODUCT_USE_UNITS)
451
+					if ($conf->global->PRODUCT_USE_UNITS)
452 452
 					{
453
-						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
453
+						$pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0, 'R');
454 454
 					}
455 455
 					else
456 456
 					{
457
-						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
457
+						$pdf->MultiCell($this->posxdiscount - $this->posxqty - 0.8, 4, $qty, 0, 'R');
458 458
 					}
459 459
 
460 460
 					// Unit
461
-					if($conf->global->PRODUCT_USE_UNITS)
461
+					if ($conf->global->PRODUCT_USE_UNITS)
462 462
 					{
463 463
 						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
464 464
 						$pdf->SetXY($this->posxunit, $curY);
465
-						$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
465
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
466 466
 					}
467 467
 
468 468
 					// Discount on line
@@ -470,46 +470,46 @@  discard block
 block discarded – undo
470 470
 					if ($object->lines[$i]->remise_percent)
471 471
 					{
472 472
 					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
473
-						$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent."%", 0, 'R');
473
+						$pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent."%", 0, 'R');
474 474
 					}
475 475
 
476 476
 					// Total HT line
477 477
                     $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
478 478
                     $pdf->SetXY($this->postotalht, $curY);
479
-                    $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
479
+                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
480 480
 
481 481
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
482
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
483
-					else $tvaligne=$object->lines[$i]->total_tva;
482
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
483
+					else $tvaligne = $object->lines[$i]->total_tva;
484 484
 
485
-					$localtax1ligne=$object->lines[$i]->total_localtax1;
486
-					$localtax2ligne=$object->lines[$i]->total_localtax2;
485
+					$localtax1ligne = $object->lines[$i]->total_localtax1;
486
+					$localtax2ligne = $object->lines[$i]->total_localtax2;
487 487
 
488
-					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
488
+					if (!empty($object->remise_percent)) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
489 489
 
490
-					$vatrate=(string) $object->lines[$i]->tva_tx;
491
-					$localtax1rate=(string) $object->lines[$i]->localtax1_tx;
492
-					$localtax2rate=(string) $object->lines[$i]->localtax2_tx;
490
+					$vatrate = (string) $object->lines[$i]->tva_tx;
491
+					$localtax1rate = (string) $object->lines[$i]->localtax1_tx;
492
+					$localtax2rate = (string) $object->lines[$i]->localtax2_tx;
493 493
 
494
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
495
-					if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0;
496
-					if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0;
497
-					if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0;
494
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
495
+					if (empty($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
496
+					if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate] = 0;
497
+					if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate] = 0;
498 498
 					$this->tva[$vatrate] += $tvaligne;
499
-					$this->localtax1[$localtax1rate]+=$localtax1ligne;
500
-					$this->localtax2[$localtax2rate]+=$localtax2ligne;
499
+					$this->localtax1[$localtax1rate] += $localtax1ligne;
500
+					$this->localtax2[$localtax2rate] += $localtax2ligne;
501 501
 
502 502
 					// Add line
503
-					if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
503
+					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
504 504
 					{
505 505
 						$pdf->setPage($pageposafter);
506
-						$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80)));
506
+						$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
507 507
 						//$pdf->SetDrawColor(190,190,200);
508
-						$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
508
+						$pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
509 509
 						$pdf->SetLineStyle(array('dash'=>0));
510 510
 					}
511 511
 
512
-					$nexY+=2;    // Passe espace entre les lignes
512
+					$nexY += 2; // Passe espace entre les lignes
513 513
 
514 514
 					// Detect if some page were added automatically and output _tableau for past pages
515 515
 					while ($pagenb < $pageposafter)
@@ -523,13 +523,13 @@  discard block
 block discarded – undo
523 523
 						{
524 524
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
525 525
 						}
526
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
526
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
527 527
 						$pagenb++;
528 528
 						$pdf->setPage($pagenb);
529
-						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
529
+						$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
530 530
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
531 531
 					}
532
-					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
532
+					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
533 533
 					{
534 534
 						if ($pagenb == 1)
535 535
 						{
@@ -539,10 +539,10 @@  discard block
 block discarded – undo
539 539
 						{
540 540
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
541 541
 						}
542
-						$this->_pagefoot($pdf,$object,$outputlangs,1);
542
+						$this->_pagefoot($pdf, $object, $outputlangs, 1);
543 543
 						// New page
544 544
 						$pdf->AddPage();
545
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
545
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
546 546
 						$pagenb++;
547 547
 						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
548 548
 					}
@@ -552,55 +552,55 @@  discard block
 block discarded – undo
552 552
 				if ($pagenb == 1)
553 553
 				{
554 554
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
555
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
555
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
556 556
 				}
557 557
 				else
558 558
 				{
559 559
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
560
-					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
560
+					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
561 561
 				}
562 562
 
563 563
 				// Affiche zone totaux
564
-				$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
564
+				$posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
565 565
 
566
-				$amount_credit_notes_included=0;
567
-				$amount_deposits_included=0;
566
+				$amount_credit_notes_included = 0;
567
+				$amount_deposits_included = 0;
568 568
 
569 569
 				if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
570 570
 				{
571
-					$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
571
+					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
572 572
 				}
573 573
 
574 574
 				// Pied de page
575 575
 				$this->_pagefoot($pdf, $object, $outputlangs);
576
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
576
+				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
577 577
 
578 578
 				$pdf->Close();
579 579
 
580
-				$pdf->Output($file,'F');
580
+				$pdf->Output($file, 'F');
581 581
 
582 582
 				// Add pdfgeneration hook
583 583
 				$hookmanager->initHooks(array('pdfgeneration'));
584
-				$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
584
+				$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
585 585
 				global $action;
586
-				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
586
+				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
587 587
 
588
-				if (! empty($conf->global->MAIN_UMASK))
588
+				if (!empty($conf->global->MAIN_UMASK))
589 589
 				@chmod($file, octdec($conf->global->MAIN_UMASK));
590 590
 
591 591
 				$this->result = array('fullpath'=>$file);
592 592
 
593
-				return 1;   // Pas d'erreur
593
+				return 1; // Pas d'erreur
594 594
 			}
595 595
 			else
596 596
 			{
597
-				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
597
+				$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
598 598
 				return 0;
599 599
 			}
600 600
 		}
601 601
 		else
602 602
 		{
603
-			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
603
+			$this->error = $langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
604 604
 			return 0;
605 605
 		}
606 606
 	}
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 	function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
620 620
 	{
621 621
         // phpcs:enable
622
-		global $conf,$mysoc;
622
+		global $conf, $mysoc;
623 623
 
624 624
         $default_font_size = pdf_getPDFFontSize($outputlangs);
625 625
 
626 626
         $tab2_top = $posy;
627 627
 		$tab2_hl = 4;
628
-		$pdf->SetFont('','', $default_font_size - 1);
628
+		$pdf->SetFont('', '', $default_font_size - 1);
629 629
 
630 630
 		$pdf->SetXY($this->marge_gauche, $tab2_top + 0);
631 631
 		// If France, show VAT mention if not applicable
@@ -638,25 +638,25 @@  discard block
 block discarded – undo
638 638
 		$col1x = 120; $col2x = 170;
639 639
 		if ($this->page_largeur < 210) // To work with US executive format
640 640
 		{
641
-			$col2x-=20;
641
+			$col2x -= 20;
642 642
 		}
643 643
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
644 644
 
645
-		$index=0;
645
+		$index = 0;
646 646
 
647 647
 		// Total HT
648
-		$pdf->SetFillColor(255,255,255);
648
+		$pdf->SetFillColor(255, 255, 255);
649 649
 		$pdf->SetXY($col1x, $tab2_top + 0);
650
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
650
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
651 651
 
652 652
 		$total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
653 653
 		$pdf->SetXY($col2x, $tab2_top + 0);
654 654
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht + $object->remise), 0, 'R', 1);
655 655
 
656 656
 		// Show VAT by rates and total
657
-		$pdf->SetFillColor(248,248,248);
657
+		$pdf->SetFillColor(248, 248, 248);
658 658
 
659
-		foreach( $this->tva as $tvakey => $tvaval )
659
+		foreach ($this->tva as $tvakey => $tvaval)
660 660
 		{
661 661
 			if ($tvakey > 0)    // On affiche pas taux 0
662 662
 			{
@@ -665,46 +665,46 @@  discard block
 block discarded – undo
665 665
 				$index++;
666 666
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
667 667
 
668
-				$tvacompl='';
668
+				$tvacompl = '';
669 669
 
670
-				if (preg_match('/\*/',$tvakey))
670
+				if (preg_match('/\*/', $tvakey))
671 671
 				{
672
-					$tvakey=str_replace('*','',$tvakey);
672
+					$tvakey = str_replace('*', '', $tvakey);
673 673
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
674 674
 				}
675 675
 
676
-				$totalvat =$outputlangs->transcountrynoentities("TotalVAT",$mysoc->country_code).' ';
677
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
678
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
676
+				$totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
677
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
678
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
679 679
 
680 680
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
681 681
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
682 682
 			}
683 683
 		}
684
-		if (! $this->atleastoneratenotnull) // If no vat at all
684
+		if (!$this->atleastoneratenotnull) // If no vat at all
685 685
 		{
686 686
 			$index++;
687 687
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
688
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
688
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
689 689
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
690 690
 			$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
691 691
 
692 692
 			// Total LocalTax1
693
-			if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on' && $object->total_localtax1>0)
693
+			if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION == 'localtax1on' && $object->total_localtax1 > 0)
694 694
 			{
695 695
 				$index++;
696 696
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
697
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code), 0, 'L', 1);
697
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code), 0, 'L', 1);
698 698
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
699 699
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1);
700 700
 			}
701 701
 
702 702
 			// Total LocalTax2
703
-			if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on' && $object->total_localtax2>0)
703
+			if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION == 'localtax2on' && $object->total_localtax2 > 0)
704 704
 			{
705 705
 				$index++;
706 706
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
707
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code), 0, 'L', 1);
707
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code), 0, 'L', 1);
708 708
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
709 709
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1);
710 710
 			}
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
715 715
 			//{
716 716
 				//Local tax 1
717
-				foreach( $this->localtax1 as $tvakey => $tvaval )
717
+				foreach ($this->localtax1 as $tvakey => $tvaval)
718 718
 				{
719 719
 					if ($tvakey != 0)    // On affiche pas taux 0
720 720
 					{
@@ -723,15 +723,15 @@  discard block
 block discarded – undo
723 723
 						$index++;
724 724
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
725 725
 
726
-						$tvacompl='';
727
-						if (preg_match('/\*/',$tvakey))
726
+						$tvacompl = '';
727
+						if (preg_match('/\*/', $tvakey))
728 728
 						{
729
-							$tvakey=str_replace('*','',$tvakey);
729
+							$tvakey = str_replace('*', '', $tvakey);
730 730
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
731 731
 						}
732
-						$totalvat = $outputlangs->transcountrynoentities("TotalLT1",$mysoc->country_code).' ';
733
-						$totalvat.= vatrate(abs($tvakey),1).$tvacompl;
734
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
732
+						$totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
733
+						$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
734
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
735 735
 
736 736
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
737 737
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
743 743
 			//{
744 744
 				//Local tax 2
745
-				foreach( $this->localtax2 as $tvakey => $tvaval )
745
+				foreach ($this->localtax2 as $tvakey => $tvaval)
746 746
 				{
747 747
 					if ($tvakey != 0)    // On affiche pas taux 0
748 748
 					{
@@ -751,15 +751,15 @@  discard block
 block discarded – undo
751 751
 						$index++;
752 752
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
753 753
 
754
-						$tvacompl='';
755
-						if (preg_match('/\*/',$tvakey))
754
+						$tvacompl = '';
755
+						if (preg_match('/\*/', $tvakey))
756 756
 						{
757
-							$tvakey=str_replace('*','',$tvakey);
757
+							$tvakey = str_replace('*', '', $tvakey);
758 758
 							$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
759 759
 						}
760
-						$totalvat = $outputlangs->transcountrynoentities("TotalLT2",$mysoc->country_code).' ';
761
-						$totalvat.= vatrate(abs($tvakey),1).$tvacompl;
762
-						$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
760
+						$totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
761
+						$totalvat .= vatrate(abs($tvakey), 1).$tvacompl;
762
+						$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
763 763
 
764 764
 						$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
765 765
 						$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
@@ -768,46 +768,46 @@  discard block
 block discarded – undo
768 768
 			//}
769 769
 		}
770 770
 
771
-		$useborder=0;
771
+		$useborder = 0;
772 772
 
773 773
 		// Total TTC
774 774
 		$index++;
775 775
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
776
-		$pdf->SetTextColor(0,0,60);
777
-		$pdf->SetFillColor(224,224,224);
778
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
776
+		$pdf->SetTextColor(0, 0, 60);
777
+		$pdf->SetFillColor(224, 224, 224);
778
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
779 779
 
780 780
 		$total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
781 781
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
782 782
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1);
783 783
 
784
-		$creditnoteamount=0;
785
-		$depositsamount=0;
784
+		$creditnoteamount = 0;
785
+		$depositsamount = 0;
786 786
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
787 787
 		//$depositsamount=$object->getSumDepositsUsed();
788 788
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
789 789
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
790
-		if (! empty($object->paye)) $resteapayer=0;
790
+		if (!empty($object->paye)) $resteapayer = 0;
791 791
 
792 792
 		if ($deja_regle > 0)
793 793
 		{
794 794
 			$index++;
795 795
 
796 796
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
797
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
797
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
798 798
 
799 799
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
800 800
 			$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
801 801
 
802 802
 			$index++;
803
-			$pdf->SetTextColor(0,0,60);
803
+			$pdf->SetTextColor(0, 0, 60);
804 804
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
805
-			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
805
+			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1);
806 806
 
807 807
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
808 808
 			$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
809
-			$pdf->SetFont('','', $default_font_size - 1);
810
-			$pdf->SetTextColor(0,0,0);
809
+			$pdf->SetFont('', '', $default_font_size - 1);
810
+			$pdf->SetTextColor(0, 0, 0);
811 811
 		}
812 812
 
813 813
 		$index++;
@@ -827,77 +827,77 @@  discard block
 block discarded – undo
827 827
 	 *   @param		string		$currency		Currency code
828 828
 	 *   @return	void
829 829
 	 */
830
-	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
830
+	function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
831 831
 	{
832 832
 		global $conf;
833 833
 
834 834
 		// Force to disable hidetop and hidebottom
835
-		$hidebottom=0;
836
-		if ($hidetop) $hidetop=-1;
835
+		$hidebottom = 0;
836
+		if ($hidetop) $hidetop = -1;
837 837
 
838 838
 		$currency = !empty($currency) ? $currency : $conf->currency;
839 839
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
840 840
 
841 841
         // Amount in (at tab_top - 1)
842
-		$pdf->SetTextColor(0,0,0);
843
-		$pdf->SetFont('','',$default_font_size - 2);
842
+		$pdf->SetTextColor(0, 0, 0);
843
+		$pdf->SetFont('', '', $default_font_size - 2);
844 844
 
845 845
 		if (empty($hidetop))
846 846
 		{
847
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
848
-			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4);
847
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
848
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
849 849
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
850 850
 
851 851
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
852
-			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));
852
+			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));
853 853
 		}
854 854
 
855
-		$pdf->SetDrawColor(128,128,128);
856
-		$pdf->SetFont('','', $default_font_size - 1);
855
+		$pdf->SetDrawColor(128, 128, 128);
856
+		$pdf->SetFont('', '', $default_font_size - 1);
857 857
 
858 858
 		// Output Rect
859
-		$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
859
+		$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
860 860
 
861 861
 		if (empty($hidetop))
862 862
 		{
863
-			$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
863
+			$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
864 864
 
865
-			$pdf->SetXY($this->posxdesc-1, $tab_top+1);
866
-			$pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L');
865
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
866
+			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
867 867
 		}
868 868
 
869 869
         if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
870 870
         {
871
-    		$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
871
+    		$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
872 872
 			if (empty($hidetop))
873 873
 			{
874
-    			$pdf->SetXY($this->posxtva-3, $tab_top+1);
875
-    			$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
874
+    			$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
875
+    			$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
876 876
 			}
877 877
         }
878 878
 
879
-		$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
879
+		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
880 880
 		if (empty($hidetop))
881 881
 		{
882
-			$pdf->SetXY($this->posxup-1, $tab_top+1);
883
-			$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C');
882
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
883
+			$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C');
884 884
 		}
885 885
 
886
-		$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
886
+		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
887 887
 		if (empty($hidetop))
888 888
 		{
889
-			$pdf->SetXY($this->posxqty-1, $tab_top+1);
890
-			if($conf->global->PRODUCT_USE_UNITS)
889
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
890
+			if ($conf->global->PRODUCT_USE_UNITS)
891 891
 			{
892
-				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
892
+				$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
893 893
 			}
894 894
 			else
895 895
 			{
896
-				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
896
+				$pdf->MultiCell($this->posxdiscount - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
897 897
 			}
898 898
 		}
899 899
 
900
-		if($conf->global->PRODUCT_USE_UNITS) {
900
+		if ($conf->global->PRODUCT_USE_UNITS) {
901 901
 			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
902 902
 			if (empty($hidetop)) {
903 903
 				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
@@ -906,13 +906,13 @@  discard block
 block discarded – undo
906 906
 			}
907 907
 		}
908 908
 
909
-		$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
909
+		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
910 910
 		if (empty($hidetop))
911 911
 		{
912 912
 			if ($this->atleastonediscount)
913 913
 			{
914
-				$pdf->SetXY($this->posxdiscount-1, $tab_top+1);
915
-				$pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C');
914
+				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
915
+				$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
916 916
 			}
917 917
 		}
918 918
 
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 		}
923 923
 		if (empty($hidetop))
924 924
 		{
925
-			$pdf->SetXY($this->postotalht-1, $tab_top+1);
926
-			$pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHTShort"),'','C');
925
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
926
+			$pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
927 927
 		}
928 928
 	}
929 929
 
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
         // phpcs:enable
943 943
 		global $conf;
944 944
 
945
-		$sign=1;
946
-		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
945
+		$sign = 1;
946
+		if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
947 947
 
948 948
 		$tab3_posx = 120;
949 949
 		$tab3_top = $posy + 8;
@@ -956,66 +956,66 @@  discard block
 block discarded – undo
956 956
 
957 957
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
958 958
 
959
-		$pdf->SetFont('','', $default_font_size - 3);
959
+		$pdf->SetFont('', '', $default_font_size - 3);
960 960
 		$pdf->SetXY($tab3_posx, $tab3_top - 4);
961 961
 		$pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
962 962
 
963
-		$pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
963
+		$pdf->line($tab3_posx, $tab3_top, $tab3_posx + $tab3_width, $tab3_top);
964 964
 
965
-		$pdf->SetFont('','', $default_font_size - 4);
965
+		$pdf->SetFont('', '', $default_font_size - 4);
966 966
 		$pdf->SetXY($tab3_posx, $tab3_top);
967 967
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0);
968
-		$pdf->SetXY($tab3_posx+21, $tab3_top);
968
+		$pdf->SetXY($tab3_posx + 21, $tab3_top);
969 969
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0);
970
-		$pdf->SetXY($tab3_posx+40, $tab3_top);
970
+		$pdf->SetXY($tab3_posx + 40, $tab3_top);
971 971
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0);
972
-		$pdf->SetXY($tab3_posx+58, $tab3_top);
972
+		$pdf->SetXY($tab3_posx + 58, $tab3_top);
973 973
 		$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
974 974
 
975
-		$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
975
+		$pdf->line($tab3_posx, $tab3_top - 1 + $tab3_height, $tab3_posx + $tab3_width, $tab3_top - 1 + $tab3_height);
976 976
 
977
-		$y=0;
977
+		$y = 0;
978 978
 
979
-		$pdf->SetFont('','', $default_font_size - 4);
979
+		$pdf->SetFont('', '', $default_font_size - 4);
980 980
 
981 981
 		// Loop on each deposits and credit notes included
982 982
 		//
983 983
 
984 984
 		// Loop on each payment
985 985
 		$sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
986
-		$sql.= " cp.code";
987
-		$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
988
-		$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
989
-		$sql.= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
990
-		$sql.= " ORDER BY p.datep";
991
-		$resql=$this->db->query($sql);
986
+		$sql .= " cp.code";
987
+		$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p";
988
+		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id";
989
+		$sql .= " WHERE pf.fk_paiementfourn = p.rowid and pf.fk_facturefourn = ".$object->id;
990
+		$sql .= " ORDER BY p.datep";
991
+		$resql = $this->db->query($sql);
992 992
 		if ($resql)
993 993
 		{
994 994
 		    $num = $this->db->num_rows($resql);
995
-			$i=0;
995
+			$i = 0;
996 996
 			while ($i < $num) {
997
-			    $y+=3;
997
+			    $y += 3;
998 998
 				$row = $this->db->fetch_object($resql);
999 999
 
1000
-				$pdf->SetXY($tab3_posx, $tab3_top+$y);
1001
-				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0);
1002
-				$pdf->SetXY($tab3_posx+21, $tab3_top+$y);
1000
+				$pdf->SetXY($tab3_posx, $tab3_top + $y);
1001
+				$pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date), 'day', false, $outputlangs, true), 0, 'L', 0);
1002
+				$pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1003 1003
 				$pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0);
1004
-				$pdf->SetXY($tab3_posx+40, $tab3_top+$y);
1005
-				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code);
1004
+				$pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1005
+				$oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort".$row->code);
1006 1006
 
1007 1007
 				$pdf->MultiCell(20, 3, $oper, 0, 'L', 0);
1008
-				$pdf->SetXY($tab3_posx+58, $tab3_top+$y);
1008
+				$pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1009 1009
 				$pdf->MultiCell(30, 3, $row->num, 0, 'L', 0);
1010 1010
 
1011
-				$pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3);
1011
+				$pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1012 1012
 
1013 1013
 				$i++;
1014 1014
 			}
1015 1015
 		}
1016 1016
 		else
1017 1017
 		{
1018
-			$this->error=$this->db->lasterror();
1018
+			$this->error = $this->db->lasterror();
1019 1019
 			return -1;
1020 1020
 		}
1021 1021
 	}
@@ -1041,13 +1041,13 @@  discard block
 block discarded – undo
1041 1041
 		// Do not add the BACKGROUND as this is for suppliers
1042 1042
 		//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
1043 1043
 
1044
-		$pdf->SetTextColor(0,0,60);
1045
-		$pdf->SetFont('','B', $default_font_size + 3);
1044
+		$pdf->SetTextColor(0, 0, 60);
1045
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1046 1046
 
1047
-		$posy=$this->marge_haute;
1048
-		$posx=$this->page_largeur-$this->marge_droite-100;
1047
+		$posy = $this->marge_haute;
1048
+		$posx = $this->page_largeur - $this->marge_droite - 100;
1049 1049
 
1050
-		$pdf->SetXY($this->marge_gauche,$posy);
1050
+		$pdf->SetXY($this->marge_gauche, $posy);
1051 1051
 
1052 1052
 		// Logo
1053 1053
 		/*
@@ -1069,66 +1069,66 @@  discard block
 block discarded – undo
1069 1069
 		}
1070 1070
 		else
1071 1071
 		{*/
1072
-			$text=$this->emetteur->name;
1072
+			$text = $this->emetteur->name;
1073 1073
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1074 1074
 		//}
1075 1075
 
1076
-		$pdf->SetFont('','B', $default_font_size + 3);
1077
-		$pdf->SetXY($posx,$posy);
1078
-		$pdf->SetTextColor(0,0,60);
1076
+		$pdf->SetFont('', 'B', $default_font_size + 3);
1077
+		$pdf->SetXY($posx, $posy);
1078
+		$pdf->SetTextColor(0, 0, 60);
1079 1079
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
1080
-		$posy+=1;
1080
+		$posy += 1;
1081 1081
 
1082 1082
 		if ($object->ref_supplier)
1083 1083
 		{
1084
-    		$posy+=4;
1085
-			$pdf->SetFont('','B', $default_font_size);
1086
-    		$pdf->SetXY($posx,$posy);
1087
-			$pdf->SetTextColor(0,0,60);
1088
-    		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R');
1089
-			$posy+=1;
1084
+    		$posy += 4;
1085
+			$pdf->SetFont('', 'B', $default_font_size);
1086
+    		$pdf->SetXY($posx, $posy);
1087
+			$pdf->SetTextColor(0, 0, 60);
1088
+    		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : ".$object->ref_supplier, '', 'R');
1089
+			$posy += 1;
1090 1090
 		}
1091 1091
 
1092
-		$pdf->SetFont('','', $default_font_size - 1);
1092
+		$pdf->SetFont('', '', $default_font_size - 1);
1093 1093
 
1094
-		if (! empty($conf->global->PDF_SHOW_PROJECT))
1094
+		if (!empty($conf->global->PDF_SHOW_PROJECT))
1095 1095
 		{
1096 1096
 			$object->fetch_projet();
1097
-			if (! empty($object->project->ref))
1097
+			if (!empty($object->project->ref))
1098 1098
 			{
1099
-        		$posy+=4;
1100
-				$pdf->SetXY($posx,$posy);
1099
+        		$posy += 4;
1100
+				$pdf->SetXY($posx, $posy);
1101 1101
         		$langs->load("projects");
1102
-				$pdf->SetTextColor(0,0,60);
1103
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R');
1102
+				$pdf->SetTextColor(0, 0, 60);
1103
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
1104 1104
 			}
1105 1105
 		}
1106 1106
 
1107 1107
 		if ($object->date)
1108 1108
 		{
1109
-			$posy+=4;
1110
-			$pdf->SetXY($posx,$posy);
1111
-			$pdf->SetTextColor(0,0,60);
1112
-			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1109
+			$posy += 4;
1110
+			$pdf->SetXY($posx, $posy);
1111
+			$pdf->SetTextColor(0, 0, 60);
1112
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
1113 1113
 		}
1114 1114
 		else
1115 1115
 		{
1116
-			$posy+=4;
1117
-			$pdf->SetXY($posx,$posy);
1118
-			$pdf->SetTextColor(255,0,0);
1116
+			$posy += 4;
1117
+			$pdf->SetXY($posx, $posy);
1118
+			$pdf->SetTextColor(255, 0, 0);
1119 1119
 			$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
1120 1120
 		}
1121 1121
 
1122 1122
 		if ($object->thirdparty->code_fournisseur)
1123 1123
 		{
1124
-			$posy+=4;
1125
-			$pdf->SetXY($posx,$posy);
1126
-			$pdf->SetTextColor(0,0,60);
1127
-			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1124
+			$posy += 4;
1125
+			$pdf->SetXY($posx, $posy);
1126
+			$pdf->SetTextColor(0, 0, 60);
1127
+			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R');
1128 1128
 		}
1129 1129
 
1130
-		$posy+=1;
1131
-		$pdf->SetTextColor(0,0,60);
1130
+		$posy += 1;
1131
+		$pdf->SetTextColor(0, 0, 60);
1132 1132
 
1133 1133
 		$top_shift = 0;
1134 1134
 		// Show list of linked objects
@@ -1142,53 +1142,53 @@  discard block
 block discarded – undo
1142 1142
 		if ($showaddress)
1143 1143
 		{
1144 1144
 			// Sender properties
1145
-		    $carac_emetteur='';
1145
+		    $carac_emetteur = '';
1146 1146
 		    // Add internal contact of proposal if defined
1147
-		    $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1147
+		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
1148 1148
 		    if (count($arrayidcontact) > 0)
1149 1149
 		    {
1150 1150
 		        $object->fetch_user($arrayidcontact[0]);
1151
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1151
+		        $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
1152 1152
 		    }
1153 1153
 
1154 1154
 		    $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
1155 1155
 
1156 1156
 			// Show sender
1157
-			$posy=42+$top_shift;
1158
-			$posx=$this->marge_gauche;
1159
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1160
-			$hautcadre=40;
1157
+			$posy = 42 + $top_shift;
1158
+			$posx = $this->marge_gauche;
1159
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1160
+			$hautcadre = 40;
1161 1161
 
1162 1162
 			// Show sender frame
1163
-			$pdf->SetTextColor(0,0,0);
1164
-			$pdf->SetFont('','', $default_font_size - 2);
1165
-			$pdf->SetXY($posx,$posy-5);
1166
-			$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1167
-			$pdf->SetXY($posx,$posy);
1168
-			$pdf->SetFillColor(230,230,230);
1163
+			$pdf->SetTextColor(0, 0, 0);
1164
+			$pdf->SetFont('', '', $default_font_size - 2);
1165
+			$pdf->SetXY($posx, $posy - 5);
1166
+			$pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
1167
+			$pdf->SetXY($posx, $posy);
1168
+			$pdf->SetFillColor(230, 230, 230);
1169 1169
 			$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1170
-			$pdf->SetTextColor(0,0,60);
1170
+			$pdf->SetTextColor(0, 0, 60);
1171 1171
 
1172 1172
 			// Show sender name
1173
-			$pdf->SetXY($posx+2,$posy+3);
1174
-			$pdf->SetFont('','B', $default_font_size);
1173
+			$pdf->SetXY($posx + 2, $posy + 3);
1174
+			$pdf->SetFont('', 'B', $default_font_size);
1175 1175
 			$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1176
-			$posy=$pdf->getY();
1176
+			$posy = $pdf->getY();
1177 1177
 
1178 1178
 			// Show sender information
1179
-			$pdf->SetXY($posx+2,$posy);
1180
-			$pdf->SetFont('','', $default_font_size - 1);
1179
+			$pdf->SetXY($posx + 2, $posy);
1180
+			$pdf->SetFont('', '', $default_font_size - 1);
1181 1181
 			$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1182 1182
 
1183 1183
 
1184 1184
 
1185 1185
 			// If BILLING contact defined on invoice, we use it
1186
-			$usecontact=false;
1187
-			$arrayidcontact=$object->getIdContact('internal','BILLING');
1186
+			$usecontact = false;
1187
+			$arrayidcontact = $object->getIdContact('internal', 'BILLING');
1188 1188
 			if (count($arrayidcontact) > 0)
1189 1189
 			{
1190
-				$usecontact=true;
1191
-				$result=$object->fetch_contact($arrayidcontact[0]);
1190
+				$usecontact = true;
1191
+				$result = $object->fetch_contact($arrayidcontact[0]);
1192 1192
 			}
1193 1193
 
1194 1194
 			//Recipient name
@@ -1199,34 +1199,34 @@  discard block
 block discarded – undo
1199 1199
 				$thirdparty = $mysoc;
1200 1200
 			}
1201 1201
 
1202
-			$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
1202
+			$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
1203 1203
 
1204
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object);
1204
+			$carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object);
1205 1205
 
1206 1206
 			// Show recipient
1207
-			$widthrecbox=100;
1208
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1209
-			$posy=42+$top_shift;
1210
-			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1211
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1207
+			$widthrecbox = 100;
1208
+			if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
1209
+			$posy = 42 + $top_shift;
1210
+			$posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1211
+			if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1212 1212
 
1213 1213
 			// Show recipient frame
1214
-			$pdf->SetTextColor(0,0,0);
1215
-			$pdf->SetFont('','', $default_font_size - 2);
1216
-			$pdf->SetXY($posx+2,$posy-5);
1217
-			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
1214
+			$pdf->SetTextColor(0, 0, 0);
1215
+			$pdf->SetFont('', '', $default_font_size - 2);
1216
+			$pdf->SetXY($posx + 2, $posy - 5);
1217
+			$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
1218 1218
 			$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1219 1219
 
1220 1220
 			// Show recipient name
1221
-			$pdf->SetXY($posx+2,$posy+3);
1222
-			$pdf->SetFont('','B', $default_font_size);
1221
+			$pdf->SetXY($posx + 2, $posy + 3);
1222
+			$pdf->SetFont('', 'B', $default_font_size);
1223 1223
 			$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
1224 1224
 
1225 1225
 			$posy = $pdf->getY();
1226 1226
 
1227 1227
 			// Show recipient information
1228
-			$pdf->SetFont('','', $default_font_size - 1);
1229
-			$pdf->SetXY($posx+2,$posy);
1228
+			$pdf->SetFont('', '', $default_font_size - 1);
1229
+			$pdf->SetXY($posx + 2, $posy);
1230 1230
 			$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
1231 1231
 		}
1232 1232
 
@@ -1242,10 +1242,10 @@  discard block
 block discarded – undo
1242 1242
 	 *      @param	int			$hidefreetext		1=Hide free text
1243 1243
 	 *      @return	int								Return height of bottom margin including footer text
1244 1244
 	 */
1245
-	function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
1245
+	function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1246 1246
 	{
1247 1247
 		global $conf;
1248
-		$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1249
-		return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
1248
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1249
+		return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1250 1250
 	}
1251 1251
 }
Please login to merge, or discard this patch.
Braces   +132 added lines, -66 removed lines patch added patch discarded remove patch
@@ -164,9 +164,11 @@  discard block
 block discarded – undo
164 164
 		}
165 165
 		//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
166 166
 		$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);	// width of images
167
-		if ($this->page_largeur < 210) // To work with US executive format
167
+		if ($this->page_largeur < 210) {
168
+		    // To work with US executive format
168 169
 		{
169 170
 			$this->posxpicture-=20;
171
+		}
170 172
 			$this->posxtva-=20;
171 173
 			$this->posxup-=20;
172 174
 			$this->posxqty-=20;
@@ -201,14 +203,26 @@  discard block
 block discarded – undo
201 203
 		global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes;
202 204
 
203 205
 		// Get source company
204
-		if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
205
-		if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc;	// If fetch_thirdparty fails, object has no socid (specimen)
206
+		if (! is_object($object->thirdparty)) {
207
+		    $object->fetch_thirdparty();
208
+		}
209
+		if (! is_object($object->thirdparty)) {
210
+		    $object->thirdparty=$mysoc;
211
+		}
212
+		// If fetch_thirdparty fails, object has no socid (specimen)
206 213
 		$this->emetteur=$object->thirdparty;
207
-		if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2);    // By default, if was not defined
214
+		if (! $this->emetteur->country_code) {
215
+		    $this->emetteur->country_code=substr($langs->defaultlang,-2);
216
+		}
217
+		// By default, if was not defined
208 218
 
209
-		if (! is_object($outputlangs)) $outputlangs=$langs;
219
+		if (! is_object($outputlangs)) {
220
+		    $outputlangs=$langs;
221
+		}
210 222
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
211
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
223
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
224
+		    $outputlangs->charset_output='ISO-8859-1';
225
+		}
212 226
 
213 227
 		// Load translation files required by the page
214 228
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products"));
@@ -226,14 +240,15 @@  discard block
 block discarded – undo
226 240
 			{
227 241
 				$dir = $conf->fournisseur->facture->dir_output;
228 242
 				$file = $dir . "/SPECIMEN.pdf";
229
-			}
230
-			else
243
+			} else
231 244
 			{
232 245
 				$objectref = dol_sanitizeFileName($object->ref);
233 246
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
234 247
                 $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'invoice_supplier').$objectref;
235 248
 				$file = $dir . "/" . $objectref . ".pdf";
236
-				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
249
+				if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) {
250
+				    $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
251
+				}
237 252
 			}
238 253
 
239 254
 			if (! file_exists($dir))
@@ -265,7 +280,9 @@  discard block
 block discarded – undo
265 280
                 $heightforinfotot = 50;	// Height reserved to output the info and total part
266 281
 		        $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
267 282
 	            $heightforfooter = $this->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
268
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6;
283
+	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) {
284
+	                $heightforfooter+= 6;
285
+	            }
269 286
                 $pdf->SetAutoPageBreak(1,0);
270 287
 
271 288
                 if (class_exists('TCPDF'))
@@ -290,7 +307,9 @@  discard block
 block discarded – undo
290 307
 				$pdf->SetCreator("Dolibarr ".DOL_VERSION);
291 308
 				$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
292 309
 				$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
293
-				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
310
+				if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
311
+				    $pdf->SetCompression(false);
312
+				}
294 313
 
295 314
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
296 315
 
@@ -314,7 +333,9 @@  discard block
 block discarded – undo
314 333
 
315 334
                 // New page
316 335
 				$pdf->AddPage();
317
-				if (! empty($tplidx)) $pdf->useTemplate($tplidx);
336
+				if (! empty($tplidx)) {
337
+				    $pdf->useTemplate($tplidx);
338
+				}
318 339
 				$pagenb++;
319 340
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
320 341
 				$pdf->SetFont('','', $default_font_size - 1);
@@ -384,31 +405,37 @@  discard block
 block discarded – undo
384 405
 					$pdf->startTransaction();
385 406
 					pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1);
386 407
 					$pageposafter=$pdf->getPage();
387
-					if ($pageposafter > $pageposbefore)	// There is a pagebreak
408
+					if ($pageposafter > $pageposbefore) {
409
+					    // There is a pagebreak
388 410
 					{
389 411
 						$pdf->rollbackTransaction(true);
412
+					}
390 413
 						$pageposafter=$pageposbefore;
391 414
 						//print $pageposafter.'-'.$pageposbefore;exit;
392 415
 						$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
393 416
 						pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1);
394 417
 						$posyafter=$pdf->GetY();
395
-						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot)))	// There is no space left for total+free text
418
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) {
419
+						    // There is no space left for total+free text
396 420
 						{
397 421
 							if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
398 422
 							{
399 423
 								$pdf->AddPage('','',true);
400
-								if (! empty($tplidx)) $pdf->useTemplate($tplidx);
401
-								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
424
+						}
425
+								if (! empty($tplidx)) {
426
+								    $pdf->useTemplate($tplidx);
427
+								}
428
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
429
+								    $this->_pagehead($pdf, $object, 0, $outputlangs);
430
+								}
402 431
 								$pdf->setPage($pageposafter+1);
403 432
 							}
404
-						}
405
-						else
433
+						} else
406 434
 						{
407 435
 							// We found a page break
408 436
 							$showpricebeforepagebreak=0;
409 437
 						}
410
-					}
411
-					else	// No pagebreak
438
+					} else	// No pagebreak
412 439
 					{
413 440
 						$pdf->commitTransaction();
414 441
 					}
@@ -451,8 +478,7 @@  discard block
 block discarded – undo
451 478
 					if($conf->global->PRODUCT_USE_UNITS)
452 479
 					{
453 480
 						$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R');
454
-					}
455
-					else
481
+					} else
456 482
 					{
457 483
 						$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R');
458 484
 					}
@@ -479,22 +505,35 @@  discard block
 block discarded – undo
479 505
                     $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
480 506
 
481 507
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
482
-					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
483
-					else $tvaligne=$object->lines[$i]->total_tva;
508
+					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) {
509
+					    $tvaligne=$object->lines[$i]->multicurrency_total_tva;
510
+					} else {
511
+					    $tvaligne=$object->lines[$i]->total_tva;
512
+					}
484 513
 
485 514
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
486 515
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
487 516
 
488
-					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
517
+					if (! empty($object->remise_percent)) {
518
+					    $tvaligne-=($tvaligne*$object->remise_percent)/100;
519
+					}
489 520
 
490 521
 					$vatrate=(string) $object->lines[$i]->tva_tx;
491 522
 					$localtax1rate=(string) $object->lines[$i]->localtax1_tx;
492 523
 					$localtax2rate=(string) $object->lines[$i]->localtax2_tx;
493 524
 
494
-					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
495
-					if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0;
496
-					if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0;
497
-					if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0;
525
+					if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
526
+					    $vatrate.='*';
527
+					}
528
+					if (empty($this->tva[$vatrate])) {
529
+					    $this->tva[$vatrate]=0;
530
+					}
531
+					if (empty($this->localtax1[$localtax1rate])) {
532
+					    $this->localtax1[$localtax1rate]=0;
533
+					}
534
+					if (empty($this->localtax2[$localtax2rate])) {
535
+					    $this->localtax2[$localtax2rate]=0;
536
+					}
498 537
 					$this->tva[$vatrate] += $tvaligne;
499 538
 					$this->localtax1[$localtax1rate]+=$localtax1ligne;
500 539
 					$this->localtax2[$localtax2rate]+=$localtax2ligne;
@@ -518,8 +557,7 @@  discard block
 block discarded – undo
518 557
 						if ($pagenb == 1)
519 558
 						{
520 559
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
521
-						}
522
-						else
560
+						} else
523 561
 						{
524 562
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
525 563
 						}
@@ -527,24 +565,29 @@  discard block
 block discarded – undo
527 565
 						$pagenb++;
528 566
 						$pdf->setPage($pagenb);
529 567
 						$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
530
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
568
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
569
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
570
+						}
531 571
 					}
532 572
 					if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
533 573
 					{
534 574
 						if ($pagenb == 1)
535 575
 						{
536 576
 							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
537
-						}
538
-						else
577
+						} else
539 578
 						{
540 579
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
541 580
 						}
542 581
 						$this->_pagefoot($pdf,$object,$outputlangs,1);
543 582
 						// New page
544 583
 						$pdf->AddPage();
545
-						if (! empty($tplidx)) $pdf->useTemplate($tplidx);
584
+						if (! empty($tplidx)) {
585
+						    $pdf->useTemplate($tplidx);
586
+						}
546 587
 						$pagenb++;
547
-						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
588
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
589
+						    $this->_pagehead($pdf, $object, 0, $outputlangs);
590
+						}
548 591
 					}
549 592
 				}
550 593
 
@@ -553,8 +596,7 @@  discard block
 block discarded – undo
553 596
 				{
554 597
 					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
555 598
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
556
-				}
557
-				else
599
+				} else
558 600
 				{
559 601
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
560 602
 					$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
@@ -573,7 +615,9 @@  discard block
 block discarded – undo
573 615
 
574 616
 				// Pied de page
575 617
 				$this->_pagefoot($pdf, $object, $outputlangs);
576
-				if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
618
+				if (method_exists($pdf,'AliasNbPages')) {
619
+				    $pdf->AliasNbPages();
620
+				}
577 621
 
578 622
 				$pdf->Close();
579 623
 
@@ -585,20 +629,19 @@  discard block
 block discarded – undo
585 629
 				global $action;
586 630
 				$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
587 631
 
588
-				if (! empty($conf->global->MAIN_UMASK))
589
-				@chmod($file, octdec($conf->global->MAIN_UMASK));
632
+				if (! empty($conf->global->MAIN_UMASK)) {
633
+								@chmod($file, octdec($conf->global->MAIN_UMASK));
634
+				}
590 635
 
591 636
 				$this->result = array('fullpath'=>$file);
592 637
 
593 638
 				return 1;   // Pas d'erreur
594
-			}
595
-			else
639
+			} else
596 640
 			{
597 641
 				$this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
598 642
 				return 0;
599 643
 			}
600
-		}
601
-		else
644
+		} else
602 645
 		{
603 646
 			$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR");
604 647
 			return 0;
@@ -636,10 +679,12 @@  discard block
 block discarded – undo
636 679
 
637 680
 		// Tableau total
638 681
 		$col1x = 120; $col2x = 170;
639
-		if ($this->page_largeur < 210) // To work with US executive format
682
+		if ($this->page_largeur < 210) {
683
+		    // To work with US executive format
640 684
 		{
641 685
 			$col2x-=20;
642 686
 		}
687
+		}
643 688
 		$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
644 689
 
645 690
 		$index=0;
@@ -658,9 +703,11 @@  discard block
 block discarded – undo
658 703
 
659 704
 		foreach( $this->tva as $tvakey => $tvaval )
660 705
 		{
661
-			if ($tvakey > 0)    // On affiche pas taux 0
706
+			if ($tvakey > 0) {
707
+			    // On affiche pas taux 0
662 708
 			{
663 709
 				$this->atleastoneratenotnull++;
710
+			}
664 711
 
665 712
 				$index++;
666 713
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -681,9 +728,11 @@  discard block
 block discarded – undo
681 728
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
682 729
 			}
683 730
 		}
684
-		if (! $this->atleastoneratenotnull) // If no vat at all
731
+		if (! $this->atleastoneratenotnull) {
732
+		    // If no vat at all
685 733
 		{
686 734
 			$index++;
735
+		}
687 736
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
688 737
 			$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code), 0, 'L', 1);
689 738
 			$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
@@ -708,19 +757,20 @@  discard block
 block discarded – undo
708 757
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
709 758
 				$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1);
710 759
 			}
711
-		}
712
-		else
760
+		} else
713 761
 		{
714 762
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
715 763
 			//{
716 764
 				//Local tax 1
717 765
 				foreach( $this->localtax1 as $tvakey => $tvaval )
718 766
 				{
719
-					if ($tvakey != 0)    // On affiche pas taux 0
767
+					if ($tvakey != 0) {
768
+					    // On affiche pas taux 0
720 769
 					{
721 770
 						//$this->atleastoneratenotnull++;
722 771
 
723 772
 						$index++;
773
+					}
724 774
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
725 775
 
726 776
 						$tvacompl='';
@@ -744,11 +794,13 @@  discard block
 block discarded – undo
744 794
 				//Local tax 2
745 795
 				foreach( $this->localtax2 as $tvakey => $tvaval )
746 796
 				{
747
-					if ($tvakey != 0)    // On affiche pas taux 0
797
+					if ($tvakey != 0) {
798
+					    // On affiche pas taux 0
748 799
 					{
749 800
 						//$this->atleastoneratenotnull++;
750 801
 
751 802
 						$index++;
803
+					}
752 804
 						$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
753 805
 
754 806
 						$tvacompl='';
@@ -787,7 +839,9 @@  discard block
 block discarded – undo
787 839
 		//$depositsamount=$object->getSumDepositsUsed();
788 840
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
789 841
 		$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
790
-		if (! empty($object->paye)) $resteapayer=0;
842
+		if (! empty($object->paye)) {
843
+		    $resteapayer=0;
844
+		}
791 845
 
792 846
 		if ($deja_regle > 0)
793 847
 		{
@@ -833,7 +887,9 @@  discard block
 block discarded – undo
833 887
 
834 888
 		// Force to disable hidetop and hidebottom
835 889
 		$hidebottom=0;
836
-		if ($hidetop) $hidetop=-1;
890
+		if ($hidetop) {
891
+		    $hidetop=-1;
892
+		}
837 893
 
838 894
 		$currency = !empty($currency) ? $currency : $conf->currency;
839 895
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
850 906
 
851 907
 			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
852
-			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));
908
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
909
+			    $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));
910
+			}
853 911
 		}
854 912
 
855 913
 		$pdf->SetDrawColor(128,128,128);
@@ -890,8 +948,7 @@  discard block
 block discarded – undo
890 948
 			if($conf->global->PRODUCT_USE_UNITS)
891 949
 			{
892 950
 				$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
893
-			}
894
-			else
951
+			} else
895 952
 			{
896 953
 				$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
897 954
 			}
@@ -943,16 +1000,20 @@  discard block
 block discarded – undo
943 1000
 		global $conf;
944 1001
 
945 1002
 		$sign=1;
946
-		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
1003
+		if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
1004
+		    $sign=-1;
1005
+		}
947 1006
 
948 1007
 		$tab3_posx = 120;
949 1008
 		$tab3_top = $posy + 8;
950 1009
 		$tab3_width = 80;
951 1010
 		$tab3_height = 4;
952
-		if ($this->page_largeur < 210) // To work with US executive format
1011
+		if ($this->page_largeur < 210) {
1012
+		    // To work with US executive format
953 1013
 		{
954 1014
 			$tab3_posx -= 20;
955 1015
 		}
1016
+		}
956 1017
 
957 1018
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
958 1019
 
@@ -1012,8 +1073,7 @@  discard block
 block discarded – undo
1012 1073
 
1013 1074
 				$i++;
1014 1075
 			}
1015
-		}
1016
-		else
1076
+		} else
1017 1077
 		{
1018 1078
 			$this->error=$this->db->lasterror();
1019 1079
 			return -1;
@@ -1110,8 +1170,7 @@  discard block
 block discarded – undo
1110 1170
 			$pdf->SetXY($posx,$posy);
1111 1171
 			$pdf->SetTextColor(0,0,60);
1112 1172
 			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R');
1113
-		}
1114
-		else
1173
+		} else
1115 1174
 		{
1116 1175
 			$posy+=4;
1117 1176
 			$pdf->SetXY($posx,$posy);
@@ -1156,7 +1215,9 @@  discard block
 block discarded – undo
1156 1215
 			// Show sender
1157 1216
 			$posy=42+$top_shift;
1158 1217
 			$posx=$this->marge_gauche;
1159
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1218
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1219
+			    $posx=$this->page_largeur-$this->marge_droite-80;
1220
+			}
1160 1221
 			$hautcadre=40;
1161 1222
 
1162 1223
 			// Show sender frame
@@ -1205,10 +1266,15 @@  discard block
 block discarded – undo
1205 1266
 
1206 1267
 			// Show recipient
1207 1268
 			$widthrecbox=100;
1208
-			if ($this->page_largeur < 210) $widthrecbox=84;	// To work with US executive format
1269
+			if ($this->page_largeur < 210) {
1270
+			    $widthrecbox=84;
1271
+			}
1272
+			// To work with US executive format
1209 1273
 			$posy=42+$top_shift;
1210 1274
 			$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
1211
-			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
1275
+			if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1276
+			    $posx=$this->marge_gauche;
1277
+			}
1212 1278
 
1213 1279
 			// Show recipient frame
1214 1280
 			$pdf->SetTextColor(0,0,0);
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php 3 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -33,34 +33,34 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
35 35
 {
36
-	/**
36
+    /**
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
41 41
 
42
-	/**
42
+    /**
43 43
      * @var string Error code (or message)
44 44
      */
45 45
     public $error = '';
46 46
 
47
-	/**
48
-	 * @var string Nom du modele
49
-	 * @deprecated
50
-	 * @see name
51
-	 */
52
-	public $nom='Cactus';
47
+    /**
48
+     * @var string Nom du modele
49
+     * @deprecated
50
+     * @see name
51
+     */
52
+    public $nom='Cactus';
53 53
 
54
-	/**
55
-	 * @var string model name
56
-	 */
57
-	public $name='Cactus';
54
+    /**
55
+     * @var string model name
56
+     */
57
+    public $name='Cactus';
58 58
 
59
-	public $prefixinvoice='SI';
59
+    public $prefixinvoice='SI';
60 60
 
61
-	public $prefixcreditnote='SA';
61
+    public $prefixcreditnote='SA';
62 62
 
63
-	public $prefixdeposit='SD';
63
+    public $prefixdeposit='SD';
64 64
 
65 65
 
66 66
     /**
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
      */
71 71
     function info()
72 72
     {
73
-    	global $langs;
74
-		$langs->load("bills");
75
-      	return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit);
73
+        global $langs;
74
+        $langs->load("bills");
75
+            return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit);
76 76
     }
77 77
 
78 78
 
@@ -87,88 +87,88 @@  discard block
 block discarded – undo
87 87
     }
88 88
 
89 89
 
90
-	/**
91
-	 * 	Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering.
92
-	 *
93
-	 *  @return     boolean     false if conflict, true if ok
94
-	 */
95
-	function canBeActivated()
96
-	{
97
-		global $conf,$langs,$db;
98
-
99
-		$langs->load("bills");
100
-
101
-		// Check invoice num
102
-		$siyymm=''; $max='';
103
-
104
-		$posindice=8;
105
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
106
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
107
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
108
-		$sql.= " AND entity = ".$conf->entity;
109
-		$resql=$db->query($sql);
110
-		if ($resql)
111
-		{
112
-			$row = $db->fetch_row($resql);
113
-			if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
114
-		}
115
-		if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm))
116
-		{
117
-			$langs->load("errors");
118
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
119
-			return false;
120
-		}
121
-
122
-		// Check credit note num
123
-		$siyymm='';
124
-
125
-		$posindice=8;
126
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
127
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
128
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
129
-		$sql.= " AND entity = ".$conf->entity;
130
-
131
-		$resql=$db->query($sql);
132
-		if ($resql)
133
-		{
134
-			$row = $db->fetch_row($resql);
135
-			if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
136
-		}
137
-		if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm))
138
-		{
139
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
140
-			return false;
141
-		}
142
-
143
-		// Check deposit num
144
-		$siyymm='';
145
-
146
-		$posindice=8;
147
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
148
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
149
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
150
-		$sql.= " AND entity = ".$conf->entity;
151
-
152
-		$resql=$db->query($sql);
153
-		if ($resql)
154
-		{
155
-			$row = $db->fetch_row($resql);
156
-			if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
157
-		}
158
-		if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm))
159
-		{
160
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
161
-			return false;
162
-		}
90
+    /**
91
+     * 	Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering.
92
+     *
93
+     *  @return     boolean     false if conflict, true if ok
94
+     */
95
+    function canBeActivated()
96
+    {
97
+        global $conf,$langs,$db;
98
+
99
+        $langs->load("bills");
100
+
101
+        // Check invoice num
102
+        $siyymm=''; $max='';
103
+
104
+        $posindice=8;
105
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
106
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
107
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
108
+        $sql.= " AND entity = ".$conf->entity;
109
+        $resql=$db->query($sql);
110
+        if ($resql)
111
+        {
112
+            $row = $db->fetch_row($resql);
113
+            if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
114
+        }
115
+        if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm))
116
+        {
117
+            $langs->load("errors");
118
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
119
+            return false;
120
+        }
121
+
122
+        // Check credit note num
123
+        $siyymm='';
124
+
125
+        $posindice=8;
126
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
127
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
128
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
129
+        $sql.= " AND entity = ".$conf->entity;
130
+
131
+        $resql=$db->query($sql);
132
+        if ($resql)
133
+        {
134
+            $row = $db->fetch_row($resql);
135
+            if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
136
+        }
137
+        if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm))
138
+        {
139
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
140
+            return false;
141
+        }
142
+
143
+        // Check deposit num
144
+        $siyymm='';
145
+
146
+        $posindice=8;
147
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
148
+        $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
149
+        $sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
150
+        $sql.= " AND entity = ".$conf->entity;
151
+
152
+        $resql=$db->query($sql);
153
+        if ($resql)
154
+        {
155
+            $row = $db->fetch_row($resql);
156
+            if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
157
+        }
158
+        if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm))
159
+        {
160
+            $this->error=$langs->trans('ErrorNumRefModel',$max);
161
+            return false;
162
+        }
163 163
     }
164 164
 
165 165
     /**
166 166
      * Return next value
167
-	 *
168
-	 * @param	Societe		$objsoc     Object third party
169
-	 * @param  	Object		$object		Object invoice
167
+     *
168
+     * @param	Societe		$objsoc     Object third party
169
+     * @param  	Object		$object		Object invoice
170 170
      * @param   string		$mode       'next' for next value or 'last' for last value
171
-	 * @return 	string      			Value if OK, 0 if KO
171
+     * @return 	string      			Value if OK, 0 if KO
172 172
      */
173 173
     function getNextValue($objsoc,$object,$mode='next')
174 174
     {
@@ -189,63 +189,63 @@  discard block
 block discarded – undo
189 189
         dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
190 190
         if ($resql)
191 191
         {
192
-        	$obj = $db->fetch_object($resql);
193
-        	if ($obj) $max = intval($obj->max);
194
-        	else $max=0;
192
+            $obj = $db->fetch_object($resql);
193
+            if ($obj) $max = intval($obj->max);
194
+            else $max=0;
195 195
         }
196 196
         else
197 197
         {
198
-        	return -1;
198
+            return -1;
199 199
         }
200 200
 
201 201
         if ($mode == 'last')
202 202
         {
203
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
204
-    		else $num = sprintf("%04s",$max);
205
-
206
-        	$ref='';
207
-        	$sql = "SELECT ref as ref";
208
-        	$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
209
-        	$sql.= " WHERE ref LIKE '".$prefix."____-".$num."'";
210
-        	$sql.= " AND entity = ".$conf->entity;
211
-
212
-        	dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
213
-        	$resql=$db->query($sql);
214
-        	if ($resql)
215
-        	{
216
-        		$obj = $db->fetch_object($resql);
217
-        		if ($obj) $ref = $obj->ref;
218
-        	}
219
-        	else dol_print_error($db);
220
-
221
-        	return $ref;
203
+            if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
204
+            else $num = sprintf("%04s",$max);
205
+
206
+            $ref='';
207
+            $sql = "SELECT ref as ref";
208
+            $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
209
+            $sql.= " WHERE ref LIKE '".$prefix."____-".$num."'";
210
+            $sql.= " AND entity = ".$conf->entity;
211
+
212
+            dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
213
+            $resql=$db->query($sql);
214
+            if ($resql)
215
+            {
216
+                $obj = $db->fetch_object($resql);
217
+                if ($obj) $ref = $obj->ref;
218
+            }
219
+            else dol_print_error($db);
220
+
221
+            return $ref;
222 222
         }
223 223
         else if ($mode == 'next')
224 224
         {
225
-        	$date=$object->date;	// This is invoice date (not creation date)
226
-        	$yymm = strftime("%y%m",$date);
225
+            $date=$object->date;	// This is invoice date (not creation date)
226
+            $yymm = strftime("%y%m",$date);
227 227
 
228
-        	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
229
-        	else $num = sprintf("%04s",$max+1);
228
+            if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
229
+            else $num = sprintf("%04s",$max+1);
230 230
 
231
-        	dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
232
-        	return $prefix.$yymm."-".$num;
231
+            dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
232
+            return $prefix.$yymm."-".$num;
233 233
         }
234 234
         else dol_print_error('','Bad parameter for getNextValue');
235 235
     }
236 236
 
237 237
 
238 238
     /**
239
-	 * Return next free value
240
-	 *
239
+     * Return next free value
240
+     *
241 241
      * @param	Societe		$objsoc     	Object third party
242 242
      * @param	string		$objforref		Object for number to search
243 243
      * @param   string		$mode       	'next' for next value or 'last' for last value
244 244
      * @return  string      				Next free value
245 245
      */
246
-	function getNumRef($objsoc,$objforref,$mode='next')
247
-	{
248
-		return $this->getNextValue($objsoc,$objforref,$mode);
249
-	}
246
+    function getNumRef($objsoc,$objforref,$mode='next')
247
+    {
248
+        return $this->getNextValue($objsoc,$objforref,$mode);
249
+    }
250 250
 }
251 251
 
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *		\brief      File containing class for the numbering module Cactus
26 26
  */
27 27
 
28
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php';
28
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
29 29
 
30 30
 
31 31
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      * Dolibarr version of the loaded document
38 38
      * @public string
39 39
      */
40
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
40
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
41 41
 
42 42
 	/**
43 43
      * @var string Error code (or message)
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
 	 * @deprecated
50 50
 	 * @see name
51 51
 	 */
52
-	public $nom='Cactus';
52
+	public $nom = 'Cactus';
53 53
 
54 54
 	/**
55 55
 	 * @var string model name
56 56
 	 */
57
-	public $name='Cactus';
57
+	public $name = 'Cactus';
58 58
 
59
-	public $prefixinvoice='SI';
59
+	public $prefixinvoice = 'SI';
60 60
 
61
-	public $prefixcreditnote='SA';
61
+	public $prefixcreditnote = 'SA';
62 62
 
63
-	public $prefixdeposit='SD';
63
+	public $prefixdeposit = 'SD';
64 64
 
65 65
 
66 66
     /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     {
73 73
     	global $langs;
74 74
 		$langs->load("bills");
75
-      	return $langs->trans("CactusNumRefModelDesc1",$this->prefixinvoice,$this->prefixcreditnote,$this->prefixdeposit);
75
+      	return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit);
76 76
     }
77 77
 
78 78
 
@@ -94,70 +94,70 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	function canBeActivated()
96 96
 	{
97
-		global $conf,$langs,$db;
97
+		global $conf, $langs, $db;
98 98
 
99 99
 		$langs->load("bills");
100 100
 
101 101
 		// Check invoice num
102
-		$siyymm=''; $max='';
102
+		$siyymm = ''; $max = '';
103 103
 
104
-		$posindice=8;
104
+		$posindice = 8;
105 105
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
106
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
107
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
108
-		$sql.= " AND entity = ".$conf->entity;
109
-		$resql=$db->query($sql);
106
+		$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
107
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
108
+		$sql .= " AND entity = ".$conf->entity;
109
+		$resql = $db->query($sql);
110 110
 		if ($resql)
111 111
 		{
112 112
 			$row = $db->fetch_row($resql);
113
-			if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
113
+			if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; }
114 114
 		}
115
-		if ($siyymm && ! preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i',$siyymm))
115
+		if ($siyymm && !preg_match('/'.$this->prefixinvoice.'[0-9][0-9][0-9][0-9]/i', $siyymm))
116 116
 		{
117 117
 			$langs->load("errors");
118
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
118
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
119 119
 			return false;
120 120
 		}
121 121
 
122 122
 		// Check credit note num
123
-		$siyymm='';
123
+		$siyymm = '';
124 124
 
125
-		$posindice=8;
126
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
127
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
128
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
129
-		$sql.= " AND entity = ".$conf->entity;
125
+		$posindice = 8;
126
+		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
127
+		$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
128
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
129
+		$sql .= " AND entity = ".$conf->entity;
130 130
 
131
-		$resql=$db->query($sql);
131
+		$resql = $db->query($sql);
132 132
 		if ($resql)
133 133
 		{
134 134
 			$row = $db->fetch_row($resql);
135
-			if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
135
+			if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; }
136 136
 		}
137
-		if ($siyymm && ! preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i',$siyymm))
137
+		if ($siyymm && !preg_match('/'.$this->prefixcreditnote.'[0-9][0-9][0-9][0-9]/i', $siyymm))
138 138
 		{
139
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
139
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
140 140
 			return false;
141 141
 		}
142 142
 
143 143
 		// Check deposit num
144
-		$siyymm='';
144
+		$siyymm = '';
145 145
 
146
-		$posindice=8;
147
-		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
148
-		$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
149
-		$sql.= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
150
-		$sql.= " AND entity = ".$conf->entity;
146
+		$posindice = 8;
147
+		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
148
+		$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
149
+		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
150
+		$sql .= " AND entity = ".$conf->entity;
151 151
 
152
-		$resql=$db->query($sql);
152
+		$resql = $db->query($sql);
153 153
 		if ($resql)
154 154
 		{
155 155
 			$row = $db->fetch_row($resql);
156
-			if ($row) { $siyymm = substr($row[0],0,6); $max=$row[0]; }
156
+			if ($row) { $siyymm = substr($row[0], 0, 6); $max = $row[0]; }
157 157
 		}
158
-		if ($siyymm && ! preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i',$siyymm))
158
+		if ($siyymm && !preg_match('/'.$this->prefixdeposit.'[0-9][0-9][0-9][0-9]/i', $siyymm))
159 159
 		{
160
-			$this->error=$langs->trans('ErrorNumRefModel',$max);
160
+			$this->error = $langs->trans('ErrorNumRefModel', $max);
161 161
 			return false;
162 162
 		}
163 163
     }
@@ -170,28 +170,28 @@  discard block
 block discarded – undo
170 170
      * @param   string		$mode       'next' for next value or 'last' for last value
171 171
 	 * @return 	string      			Value if OK, 0 if KO
172 172
      */
173
-    function getNextValue($objsoc,$object,$mode='next')
173
+    function getNextValue($objsoc, $object, $mode = 'next')
174 174
     {
175
-        global $db,$conf;
175
+        global $db, $conf;
176 176
 
177
-        if ($object->type == 2) $prefix=$this->prefixcreditnote;
178
-        else if ($facture->type == 3) $prefix=$this->prefixdeposit;
179
-        else $prefix=$this->prefixinvoice;
177
+        if ($object->type == 2) $prefix = $this->prefixcreditnote;
178
+        else if ($facture->type == 3) $prefix = $this->prefixdeposit;
179
+        else $prefix = $this->prefixinvoice;
180 180
 
181 181
         // D'abord on recupere la valeur max
182
-        $posindice=8;
183
-        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";	// This is standard SQL
184
-        $sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
185
-        $sql.= " WHERE ref LIKE '".$prefix."____-%'";
186
-        $sql.= " AND entity = ".$conf->entity;
182
+        $posindice = 8;
183
+        $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
184
+        $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
185
+        $sql .= " WHERE ref LIKE '".$prefix."____-%'";
186
+        $sql .= " AND entity = ".$conf->entity;
187 187
 
188
-        $resql=$db->query($sql);
188
+        $resql = $db->query($sql);
189 189
         dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
190 190
         if ($resql)
191 191
         {
192 192
         	$obj = $db->fetch_object($resql);
193 193
         	if ($obj) $max = intval($obj->max);
194
-        	else $max=0;
194
+        	else $max = 0;
195 195
         }
196 196
         else
197 197
         {
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 
201 201
         if ($mode == 'last')
202 202
         {
203
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
204
-    		else $num = sprintf("%04s",$max);
203
+    		if ($max >= (pow(10, 4) - 1)) $num = $max; // If counter > 9999, we do not format on 4 chars, we take number as it is
204
+    		else $num = sprintf("%04s", $max);
205 205
 
206
-        	$ref='';
206
+        	$ref = '';
207 207
         	$sql = "SELECT ref as ref";
208
-        	$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn";
209
-        	$sql.= " WHERE ref LIKE '".$prefix."____-".$num."'";
210
-        	$sql.= " AND entity = ".$conf->entity;
208
+        	$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
209
+        	$sql .= " WHERE ref LIKE '".$prefix."____-".$num."'";
210
+        	$sql .= " AND entity = ".$conf->entity;
211 211
 
212 212
         	dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
213
-        	$resql=$db->query($sql);
213
+        	$resql = $db->query($sql);
214 214
         	if ($resql)
215 215
         	{
216 216
         		$obj = $db->fetch_object($resql);
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
         }
223 223
         else if ($mode == 'next')
224 224
         {
225
-        	$date=$object->date;	// This is invoice date (not creation date)
226
-        	$yymm = strftime("%y%m",$date);
225
+        	$date = $object->date; // This is invoice date (not creation date)
226
+        	$yymm = strftime("%y%m", $date);
227 227
 
228
-        	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
229
-        	else $num = sprintf("%04s",$max+1);
228
+        	if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
229
+        	else $num = sprintf("%04s", $max + 1);
230 230
 
231 231
         	dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
232 232
         	return $prefix.$yymm."-".$num;
233 233
         }
234
-        else dol_print_error('','Bad parameter for getNextValue');
234
+        else dol_print_error('', 'Bad parameter for getNextValue');
235 235
     }
236 236
 
237 237
 
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
      * @param   string		$mode       	'next' for next value or 'last' for last value
244 244
      * @return  string      				Next free value
245 245
      */
246
-	function getNumRef($objsoc,$objforref,$mode='next')
246
+	function getNumRef($objsoc, $objforref, $mode = 'next')
247 247
 	{
248
-		return $this->getNextValue($objsoc,$objforref,$mode);
248
+		return $this->getNextValue($objsoc, $objforref, $mode);
249 249
 	}
250 250
 }
251 251
 
Please login to merge, or discard this patch.
Braces   +35 added lines, -16 removed lines patch added patch discarded remove patch
@@ -174,9 +174,13 @@  discard block
 block discarded – undo
174 174
     {
175 175
         global $db,$conf;
176 176
 
177
-        if ($object->type == 2) $prefix=$this->prefixcreditnote;
178
-        else if ($facture->type == 3) $prefix=$this->prefixdeposit;
179
-        else $prefix=$this->prefixinvoice;
177
+        if ($object->type == 2) {
178
+            $prefix=$this->prefixcreditnote;
179
+        } else if ($facture->type == 3) {
180
+            $prefix=$this->prefixdeposit;
181
+        } else {
182
+            $prefix=$this->prefixinvoice;
183
+        }
180 184
 
181 185
         // D'abord on recupere la valeur max
182 186
         $posindice=8;
@@ -190,18 +194,25 @@  discard block
 block discarded – undo
190 194
         if ($resql)
191 195
         {
192 196
         	$obj = $db->fetch_object($resql);
193
-        	if ($obj) $max = intval($obj->max);
194
-        	else $max=0;
195
-        }
196
-        else
197
+        	if ($obj) {
198
+        	    $max = intval($obj->max);
199
+        	} else {
200
+        	    $max=0;
201
+        	}
202
+        } else
197 203
         {
198 204
         	return -1;
199 205
         }
200 206
 
201 207
         if ($mode == 'last')
202 208
         {
203
-    		if ($max >= (pow(10, 4) - 1)) $num=$max;	// If counter > 9999, we do not format on 4 chars, we take number as it is
204
-    		else $num = sprintf("%04s",$max);
209
+    		if ($max >= (pow(10, 4) - 1)) {
210
+    		    $num=$max;
211
+    		}
212
+    		// If counter > 9999, we do not format on 4 chars, we take number as it is
213
+    		else {
214
+    		    $num = sprintf("%04s",$max);
215
+    		}
205 216
 
206 217
         	$ref='';
207 218
         	$sql = "SELECT ref as ref";
@@ -214,24 +225,32 @@  discard block
 block discarded – undo
214 225
         	if ($resql)
215 226
         	{
216 227
         		$obj = $db->fetch_object($resql);
217
-        		if ($obj) $ref = $obj->ref;
228
+        		if ($obj) {
229
+        		    $ref = $obj->ref;
230
+        		}
231
+        	} else {
232
+        	    dol_print_error($db);
218 233
         	}
219
-        	else dol_print_error($db);
220 234
 
221 235
         	return $ref;
222
-        }
223
-        else if ($mode == 'next')
236
+        } else if ($mode == 'next')
224 237
         {
225 238
         	$date=$object->date;	// This is invoice date (not creation date)
226 239
         	$yymm = strftime("%y%m",$date);
227 240
 
228
-        	if ($max >= (pow(10, 4) - 1)) $num=$max+1;	// If counter > 9999, we do not format on 4 chars, we take number as it is
229
-        	else $num = sprintf("%04s",$max+1);
241
+        	if ($max >= (pow(10, 4) - 1)) {
242
+        	    $num=$max+1;
243
+        	}
244
+        	// If counter > 9999, we do not format on 4 chars, we take number as it is
245
+        	else {
246
+        	    $num = sprintf("%04s",$max+1);
247
+        	}
230 248
 
231 249
         	dol_syslog(get_class($this)."::getNextValue return ".$prefix.$yymm."-".$num);
232 250
         	return $prefix.$yymm."-".$num;
251
+        } else {
252
+            dol_print_error('','Bad parameter for getNextValue');
233 253
         }
234
-        else dol_print_error('','Bad parameter for getNextValue');
235 254
     }
236 255
 
237 256
 
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php 3 patches
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -36,28 +36,28 @@  discard block
 block discarded – undo
36 36
 */
37 37
 class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices
38 38
 {
39
-	/**
39
+    /**
40 40
      * Dolibarr version of the loaded document
41 41
      * @public string
42 42
      */
43
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
43
+    public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
44 44
 
45
-	/**
45
+    /**
46 46
      * @var string Error code (or message)
47 47
      */
48 48
     public $error = '';
49 49
 
50
-	/**
51
-	 * @var string Nom du modele
52
-	 * @deprecated
53
-	 * @see name
54
-	 */
55
-	public $nom='Tulip';
50
+    /**
51
+     * @var string Nom du modele
52
+     * @deprecated
53
+     * @see name
54
+     */
55
+    public $nom='Tulip';
56 56
 
57
-	/**
58
-	 * @var string model name
59
-	 */
60
-	public $name='Tulip';
57
+    /**
58
+     * @var string model name
59
+     */
60
+    public $name='Tulip';
61 61
 
62 62
 
63 63
     /**
@@ -65,63 +65,63 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * 	@return     string      Description Text
67 67
      */
68
-	function info()
68
+    function info()
69 69
     {
70
-    	global $conf, $langs;
70
+        global $conf, $langs;
71 71
 
72
-		// Load translation files required by the page
72
+        // Load translation files required by the page
73 73
         $langs->loadLangs(array("bills","admin"));
74 74
 
75
-		$form = new Form($this->db);
75
+        $form = new Form($this->db);
76 76
 
77
-		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
78
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
81
-		$texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
77
+        $texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
78
+        $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79
+        $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80
+        $texte.= '<input type="hidden" name="action" value="updateMask">';
81
+        $texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
82 82
         $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
83 83
         $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
84
-		$texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
85
-		$texte.= '<table class="nobordernopadding" width="100%">';
84
+        $texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
85
+        $texte.= '<table class="nobordernopadding" width="100%">';
86 86
 
87
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
88
-		$tooltip.=$langs->trans("GenericMaskCodes2");
89
-		$tooltip.=$langs->trans("GenericMaskCodes3");
90
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
91
-		$tooltip.=$langs->trans("GenericMaskCodes5");
87
+        $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
88
+        $tooltip.=$langs->trans("GenericMaskCodes2");
89
+        $tooltip.=$langs->trans("GenericMaskCodes3");
90
+        $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
91
+        $tooltip.=$langs->trans("GenericMaskCodes5");
92 92
 
93
-		// Parametrage du prefix
94
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
95
-		$texte.= ':</td>';
96
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>';
93
+        // Parametrage du prefix
94
+        $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
95
+        $texte.= ':</td>';
96
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>';
97 97
 
98
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
98
+        $texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
99 99
 
100
-		$texte.= '</tr>';
100
+        $texte.= '</tr>';
101 101
 		
102
-		// Parametrage du prefix des avoirs
103
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
104
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
105
-		$texte.= '</tr>';
102
+        // Parametrage du prefix des avoirs
103
+        $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
104
+        $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
105
+        $texte.= '</tr>';
106 106
 
107
-		if ($conf->global->MAIN_FEATURE_LEVEL >= 2)
108
-		{
109
-    		// Parametrage du prefix des replacement
110
-    		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
111
-    		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
112
-    		$texte.= '</tr>';
107
+        if ($conf->global->MAIN_FEATURE_LEVEL >= 2)
108
+        {
109
+            // Parametrage du prefix des replacement
110
+            $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
111
+            $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
112
+            $texte.= '</tr>';
113 113
 
114 114
 
115
-    		// Parametrage du prefix des acomptes
116
-    		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
117
-    		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
118
-    		$texte.= '</tr>';
119
-		}
115
+            // Parametrage du prefix des acomptes
116
+            $texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
117
+            $texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
118
+            $texte.= '</tr>';
119
+        }
120 120
 
121
-		$texte.= '</table>';
122
-		$texte.= '</form>';
121
+        $texte.= '</table>';
122
+        $texte.= '</form>';
123 123
 
124
-		return $texte;
124
+        return $texte;
125 125
     }
126 126
 
127 127
     /**
@@ -131,70 +131,70 @@  discard block
 block discarded – undo
131 131
      */
132 132
     function getExample()
133 133
     {
134
-    	global $conf,$langs,$mysoc;
135
-
136
-    	$old_code_client=$mysoc->code_client;
137
-    	$mysoc->code_client='CCCCCCCCCC';
138
-    	$numExample = $this->getNextValue($mysoc,'');
139
-		$mysoc->code_client=$old_code_client;
140
-
141
-		if (! $numExample)
142
-		{
143
-			$numExample = $langs->trans('NotConfigured');
144
-		}
145
-		return $numExample;
134
+        global $conf,$langs,$mysoc;
135
+
136
+        $old_code_client=$mysoc->code_client;
137
+        $mysoc->code_client='CCCCCCCCCC';
138
+        $numExample = $this->getNextValue($mysoc,'');
139
+        $mysoc->code_client=$old_code_client;
140
+
141
+        if (! $numExample)
142
+        {
143
+            $numExample = $langs->trans('NotConfigured');
144
+        }
145
+        return $numExample;
146 146
     }
147 147
 
148
-	/**
149
-	 * Return next value
150
-	 *
151
-	 * @param	Societe		$objsoc     Object third party
152
-	 * @param  	Object	    $object		Object invoice
148
+    /**
149
+     * Return next value
150
+     *
151
+     * @param	Societe		$objsoc     Object third party
152
+     * @param  	Object	    $object		Object invoice
153 153
      * @param	string		$mode       'next' for next value or 'last' for last value
154 154
      * @return 	string      			Value if OK, 0 if KO
155
-	 */
155
+     */
156 156
     function getNextValue($objsoc,$object,$mode='next')
157 157
     {
158
-		global $db,$conf;
159
-
160
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
161
-
162
-		// Get Mask value
163
-		$mask = '';
164
-		if (is_object($object) && $object->type == 1)
165
-		{
166
-			$mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK;
167
-			if (! $mask)
168
-			{
169
-				$mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
170
-			}
171
-		}
172
-		else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173
-		else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
174
-		else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
175
-		if (! $mask)
176
-		{
177
-			$this->error='NotConfigured';
178
-			return 0;
179
-		}
180
-
181
-		// Supplier invoices take invoice date instead of creation date for the mask
182
-		$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
183
-
184
-		return  $numFinal;
185
-	}
158
+        global $db,$conf;
159
+
160
+        require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
161
+
162
+        // Get Mask value
163
+        $mask = '';
164
+        if (is_object($object) && $object->type == 1)
165
+        {
166
+            $mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK;
167
+            if (! $mask)
168
+            {
169
+                $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
170
+            }
171
+        }
172
+        else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173
+        else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
174
+        else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
175
+        if (! $mask)
176
+        {
177
+            $this->error='NotConfigured';
178
+            return 0;
179
+        }
180
+
181
+        // Supplier invoices take invoice date instead of creation date for the mask
182
+        $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
183
+
184
+        return  $numFinal;
185
+    }
186 186
 
187 187
     /**
188
-	 * Return next free value
189
-	 *
188
+     * Return next free value
189
+     *
190 190
      * @param	Societe		$objsoc     	Object third party
191 191
      * @param	string		$objforref		Object for number to search
192 192
      * @param   string		$mode       	'next' for next value or 'last' for last value
193 193
      * @return  string      				Next free value
194 194
      */
195
-	function getNumRef($objsoc,$objforref,$mode='next')
196
-	{
197
-		return $this->getNextValue($objsoc,$objforref,$mode);
198
-	}
195
+    function getNumRef($objsoc,$objforref,$mode='next')
196
+    {
197
+        return $this->getNextValue($objsoc,$objforref,$mode);
198
+    }
199 199
 }
200 200
 
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  *	\brief      File containing the Tulip Class of numbering models of suppliers invoices references
28 28
  */
29 29
 
30
-require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturefournisseur.php';
30
+require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
31 31
 
32 32
 
33 33
 /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
      * Dolibarr version of the loaded document
41 41
      * @public string
42 42
      */
43
-	public $version = 'dolibarr';		// 'development', 'experimental', 'dolibarr'
43
+	public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
44 44
 
45 45
 	/**
46 46
      * @var string Error code (or message)
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 	 * @deprecated
53 53
 	 * @see name
54 54
 	 */
55
-	public $nom='Tulip';
55
+	public $nom = 'Tulip';
56 56
 
57 57
 	/**
58 58
 	 * @var string model name
59 59
 	 */
60
-	public $name='Tulip';
60
+	public $name = 'Tulip';
61 61
 
62 62
 
63 63
     /**
@@ -70,56 +70,56 @@  discard block
 block discarded – undo
70 70
     	global $conf, $langs;
71 71
 
72 72
 		// Load translation files required by the page
73
-        $langs->loadLangs(array("bills","admin"));
73
+        $langs->loadLangs(array("bills", "admin"));
74 74
 
75 75
 		$form = new Form($this->db);
76 76
 
77 77
 		$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
78
-		$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79
-		$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80
-		$texte.= '<input type="hidden" name="action" value="updateMask">';
81
-		$texte.= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
82
-        $texte.= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
83
-        $texte.= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
84
-		$texte.= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
85
-		$texte.= '<table class="nobordernopadding" width="100%">';
86
-
87
-		$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
88
-		$tooltip.=$langs->trans("GenericMaskCodes2");
89
-		$tooltip.=$langs->trans("GenericMaskCodes3");
90
-		$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Invoice"),$langs->transnoentities("Invoice"));
91
-		$tooltip.=$langs->trans("GenericMaskCodes5");
78
+		$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
79
+		$texte .= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
80
+		$texte .= '<input type="hidden" name="action" value="updateMask">';
81
+		$texte .= '<input type="hidden" name="maskconstinvoice" value="SUPPLIER_INVOICE_TULIP_MASK">';
82
+        $texte .= '<input type="hidden" name="maskconstreplacement" value="SUPPLIER_REPLACEMENT_TULIP_MASK">';
83
+        $texte .= '<input type="hidden" name="maskconstcredit" value="SUPPLIER_CREDIT_TULIP_MASK">';
84
+		$texte .= '<input type="hidden" name="maskconstdeposit" value="SUPPLIER_DEPOSIT_TULIP_MASK">';
85
+		$texte .= '<table class="nobordernopadding" width="100%">';
86
+
87
+		$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
88
+		$tooltip .= $langs->trans("GenericMaskCodes2");
89
+		$tooltip .= $langs->trans("GenericMaskCodes3");
90
+		$tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Invoice"), $langs->transnoentities("Invoice"));
91
+		$tooltip .= $langs->trans("GenericMaskCodes5");
92 92
 
93 93
 		// Parametrage du prefix
94
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
95
-		$texte.= ':</td>';
96
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">',$tooltip,1,1).'</td>';
94
+		$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceStandard").')';
95
+		$texte .= ':</td>';
96
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskinvoice" value="'.$conf->global->SUPPLIER_INVOICE_TULIP_MASK.'">', $tooltip, 1, 1).'</td>';
97 97
 
98
-		$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
98
+		$texte .= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
99 99
 
100
-		$texte.= '</tr>';
100
+		$texte .= '</tr>';
101 101
 		
102 102
 		// Parametrage du prefix des avoirs
103
-		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
104
-		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
105
-		$texte.= '</tr>';
103
+		$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):</td>';
104
+		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskcredit" value="'.$conf->global->SUPPLIER_CREDIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>';
105
+		$texte .= '</tr>';
106 106
 
107 107
 		if ($conf->global->MAIN_FEATURE_LEVEL >= 2)
108 108
 		{
109 109
     		// Parametrage du prefix des replacement
110
-    		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
111
-    		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
112
-    		$texte.= '</tr>';
110
+    		$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceReplacement").'):</td>';
111
+    		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskreplacement" value="'.$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>';
112
+    		$texte .= '</tr>';
113 113
 
114 114
 
115 115
     		// Parametrage du prefix des acomptes
116
-    		$texte.= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
117
-    		$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">',$tooltip,1,1).'</td>';
118
-    		$texte.= '</tr>';
116
+    		$texte .= '<tr><td>'.$langs->trans("Mask").' ('.$langs->trans("InvoiceDeposit").'):</td>';
117
+    		$texte .= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskdeposit" value="'.$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK.'">', $tooltip, 1, 1).'</td>';
118
+    		$texte .= '</tr>';
119 119
 		}
120 120
 
121
-		$texte.= '</table>';
122
-		$texte.= '</form>';
121
+		$texte .= '</table>';
122
+		$texte .= '</form>';
123 123
 
124 124
 		return $texte;
125 125
     }
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
      */
132 132
     function getExample()
133 133
     {
134
-    	global $conf,$langs,$mysoc;
134
+    	global $conf, $langs, $mysoc;
135 135
 
136
-    	$old_code_client=$mysoc->code_client;
137
-    	$mysoc->code_client='CCCCCCCCCC';
138
-    	$numExample = $this->getNextValue($mysoc,'');
139
-		$mysoc->code_client=$old_code_client;
136
+    	$old_code_client = $mysoc->code_client;
137
+    	$mysoc->code_client = 'CCCCCCCCCC';
138
+    	$numExample = $this->getNextValue($mysoc, '');
139
+		$mysoc->code_client = $old_code_client;
140 140
 
141
-		if (! $numExample)
141
+		if (!$numExample)
142 142
 		{
143 143
 			$numExample = $langs->trans('NotConfigured');
144 144
 		}
@@ -153,33 +153,33 @@  discard block
 block discarded – undo
153 153
      * @param	string		$mode       'next' for next value or 'last' for last value
154 154
      * @return 	string      			Value if OK, 0 if KO
155 155
 	 */
156
-    function getNextValue($objsoc,$object,$mode='next')
156
+    function getNextValue($objsoc, $object, $mode = 'next')
157 157
     {
158
-		global $db,$conf;
158
+		global $db, $conf;
159 159
 
160
-		require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
160
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
161 161
 
162 162
 		// Get Mask value
163 163
 		$mask = '';
164 164
 		if (is_object($object) && $object->type == 1)
165 165
 		{
166
-			$mask=$conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK;
167
-			if (! $mask)
166
+			$mask = $conf->global->SUPPLIER_REPLACEMENT_TULIP_MASK;
167
+			if (!$mask)
168 168
 			{
169
-				$mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
169
+				$mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK;
170 170
 			}
171 171
 		}
172
-		else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173
-		else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
174
-		else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
175
-		if (! $mask)
172
+		else if (is_object($object) && $object->type == 2) $mask = $conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173
+		else if (is_object($object) && $object->type == 3) $mask = $conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
174
+		else $mask = $conf->global->SUPPLIER_INVOICE_TULIP_MASK;
175
+		if (!$mask)
176 176
 		{
177
-			$this->error='NotConfigured';
177
+			$this->error = 'NotConfigured';
178 178
 			return 0;
179 179
 		}
180 180
 
181 181
 		// Supplier invoices take invoice date instead of creation date for the mask
182
-		$numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date);
182
+		$numFinal = get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date);
183 183
 
184 184
 		return  $numFinal;
185 185
 	}
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
      * @param   string		$mode       	'next' for next value or 'last' for last value
193 193
      * @return  string      				Next free value
194 194
      */
195
-	function getNumRef($objsoc,$objforref,$mode='next')
195
+	function getNumRef($objsoc, $objforref, $mode = 'next')
196 196
 	{
197
-		return $this->getNextValue($objsoc,$objforref,$mode);
197
+		return $this->getNextValue($objsoc, $objforref, $mode);
198 198
 	}
199 199
 }
200 200
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -168,10 +168,13 @@
 block discarded – undo
168 168
 			{
169 169
 				$mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
170 170
 			}
171
+		} else if (is_object($object) && $object->type == 2) {
172
+		    $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173
+		} else if (is_object($object) && $object->type == 3) {
174
+		    $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
175
+		} else {
176
+		    $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
171 177
 		}
172
-		else if (is_object($object) && $object->type == 2) $mask=$conf->global->SUPPLIER_CREDIT_TULIP_MASK;
173
-		else if (is_object($object) && $object->type == 3) $mask=$conf->global->SUPPLIER_DEPOSIT_TULIP_MASK;
174
-		else $mask=$conf->global->SUPPLIER_INVOICE_TULIP_MASK;
175 178
 		if (! $mask)
176 179
 		{
177 180
 			$this->error='NotConfigured';
Please login to merge, or discard this patch.
htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php 3 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
  */
35 35
 abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
36 36
 {
37
-	/**
38
-	 * @var string Error code (or message)
39
-	 */
40
-	public $error='';
37
+    /**
38
+     * @var string Error code (or message)
39
+     */
40
+    public $error='';
41 41
 
42 42
 
43 43
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
44
-	/**
45
-	 *  Return list of active generation models
46
-	 *
44
+    /**
45
+     *  Return list of active generation models
46
+     *
47 47
      *  @param	DoliDB	$db     			Database handler
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of numbers
50
-	 */
51
-	static function liste_modeles($db, $maxfilenamelength=0)
52
-	{
50
+     */
51
+    static function liste_modeles($db, $maxfilenamelength=0)
52
+    {
53 53
         // phpcs:enable
54
-		global $conf;
54
+        global $conf;
55 55
 
56
-		$type = 'invoice_supplier';
57
-		$list = array();
56
+        $type = 'invoice_supplier';
57
+        $list = array();
58 58
 
59
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
-		$list = getListOfModels($db, $type, $maxfilenamelength);
59
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
60
+        $list = getListOfModels($db, $type, $maxfilenamelength);
61 61
 
62
-		return $list;
63
-	}
62
+        return $list;
63
+    }
64 64
 }
65 65
 
66 66
 /**
@@ -68,50 +68,50 @@  discard block
 block discarded – undo
68 68
  */
69 69
 abstract class ModeleNumRefSuppliersInvoices
70 70
 {
71
-	/**
72
-	 * @var string Error code (or message)
73
-	 */
74
-	public $error='';
75
-
76
-	/**  Return if a model can be used or not
77
-	 *
78
-	 *   @return	boolean     true if model can be used
79
-	 */
80
-	function isEnabled()
81
-	{
82
-		return true;
83
-	}
84
-
85
-	/**  Returns the default description of the model numbering
86
-	 *
87
-	 *   @return    string      Description Text
88
-	 */
89
-	function info()
90
-	{
91
-		global $langs;
92
-		$langs->load("invoices");
93
-		return $langs->trans("NoDescription");
94
-	}
95
-
96
-	/**   Returns a numbering example
97
-	 *
98
-	 *    @return   string      Example
99
-	 */
100
-	function getExample()
101
-	{
102
-		global $langs;
103
-		$langs->load("invoices");
104
-		return $langs->trans("NoExample");
105
-	}
106
-
107
-	/**  Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering.
108
-	 *
109
-	 *   @return	boolean     false if conflict, true if ok
110
-	 */
111
-	function canBeActivated()
112
-	{
113
-		return true;
114
-	}
71
+    /**
72
+     * @var string Error code (or message)
73
+     */
74
+    public $error='';
75
+
76
+    /**  Return if a model can be used or not
77
+     *
78
+     *   @return	boolean     true if model can be used
79
+     */
80
+    function isEnabled()
81
+    {
82
+        return true;
83
+    }
84
+
85
+    /**  Returns the default description of the model numbering
86
+     *
87
+     *   @return    string      Description Text
88
+     */
89
+    function info()
90
+    {
91
+        global $langs;
92
+        $langs->load("invoices");
93
+        return $langs->trans("NoDescription");
94
+    }
95
+
96
+    /**   Returns a numbering example
97
+     *
98
+     *    @return   string      Example
99
+     */
100
+    function getExample()
101
+    {
102
+        global $langs;
103
+        $langs->load("invoices");
104
+        return $langs->trans("NoExample");
105
+    }
106
+
107
+    /**  Tests if the numbers already in force in the database do not cause conflicts that would prevent this numbering.
108
+     *
109
+     *   @return	boolean     false if conflict, true if ok
110
+     */
111
+    function canBeActivated()
112
+    {
113
+        return true;
114
+    }
115 115
 
116 116
     /**  Returns next value assigned
117 117
      *
@@ -121,24 +121,24 @@  discard block
 block discarded – undo
121 121
      * @return 	string      			Value if OK, 0 if KO
122 122
      */
123 123
     function getNextValue($objsoc,$object,$mode)
124
-	{
125
-		global $langs;
126
-		return $langs->trans("NotAvailable");
127
-	}
128
-
129
-	/**   Returns version of the model numbering
130
-	 *
131
-	 *    @return     string      Value
132
-	 */
133
-	function getVersion()
134
-	{
135
-		global $langs;
136
-		$langs->load("admin");
137
-
138
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
139
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
140
-		if ($this->version == 'dolibarr') return DOL_VERSION;
141
-		if ($this->version) return $this->version;
142
-		return $langs->trans("NotAvailable");
143
-	}
124
+    {
125
+        global $langs;
126
+        return $langs->trans("NotAvailable");
127
+    }
128
+
129
+    /**   Returns version of the model numbering
130
+     *
131
+     *    @return     string      Value
132
+     */
133
+    function getVersion()
134
+    {
135
+        global $langs;
136
+        $langs->load("admin");
137
+
138
+        if ($this->version == 'development') return $langs->trans("VersionDevelopment");
139
+        if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
140
+        if ($this->version == 'dolibarr') return DOL_VERSION;
141
+        if ($this->version) return $this->version;
142
+        return $langs->trans("NotAvailable");
143
+    }
144 144
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  *					and parent class for supplier invoices numbering models
27 27
  */
28 28
 require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
29
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';	// required for use by classes that inherit
29
+require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit
30 30
 
31 31
 
32 32
 /**
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	 * @var string Error code (or message)
39 39
 	 */
40
-	public $error='';
40
+	public $error = '';
41 41
 
42 42
 
43 43
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *  @param  integer	$maxfilenamelength  Max length of value to show
49 49
      *  @return	array						List of numbers
50 50
 	 */
51
-	static function liste_modeles($db, $maxfilenamelength=0)
51
+	static function liste_modeles($db, $maxfilenamelength = 0)
52 52
 	{
53 53
         // phpcs:enable
54 54
 		global $conf;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	/**
72 72
 	 * @var string Error code (or message)
73 73
 	 */
74
-	public $error='';
74
+	public $error = '';
75 75
 
76 76
 	/**  Return if a model can be used or not
77 77
 	 *
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param	string		$mode       'next' for next value or 'last' for last value
121 121
      * @return 	string      			Value if OK, 0 if KO
122 122
      */
123
-    function getNextValue($objsoc,$object,$mode)
123
+    function getNextValue($objsoc, $object, $mode)
124 124
 	{
125 125
 		global $langs;
126 126
 		return $langs->trans("NotAvailable");
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -142,10 +142,18 @@
 block discarded – undo
142 142
 		global $langs;
143 143
 		$langs->load("admin");
144 144
 
145
-		if ($this->version == 'development') return $langs->trans("VersionDevelopment");
146
-		if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
147
-		if ($this->version == 'dolibarr') return DOL_VERSION;
148
-		if ($this->version) return $this->version;
145
+		if ($this->version == 'development') {
146
+		    return $langs->trans("VersionDevelopment");
147
+		}
148
+		if ($this->version == 'experimental') {
149
+		    return $langs->trans("VersionExperimental");
150
+		}
151
+		if ($this->version == 'dolibarr') {
152
+		    return DOL_VERSION;
153
+		}
154
+		if ($this->version) {
155
+		    return $this->version;
156
+		}
149 157
 		return $langs->trans("NotAvailable");
150 158
 	}
151 159
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/modVariants.class.php 2 patches
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -33,79 +33,79 @@
 block discarded – undo
33 33
  */
34 34
 class modVariants 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
-	{
43
-		global $langs,$conf;
44
-
45
-		$this->db = $db;
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 = 610;
50
-		// Key text used to identify module (for permissions, menus, etc...)
51
-		$this->rights_class = 'variants';
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 = "products";
56
-		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->name = preg_replace('/^mod/i','',get_class($this));
58
-		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59
-		$this->description = 'Allows creating products variant based on new attributes';
60
-		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
61
-		$this->version = 'dolibarr';
62
-		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
63
-		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
64
-		// Name of image file used for this module.
65
-		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
66
-		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
67
-		$this->picto='product';
68
-
69
-		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
70
-		$this->module_parts = array();
71
-
72
-		// Data directories to create when module is enabled.
73
-		// Example: this->dirs = array("/mymodule/temp");
74
-		$this->dirs = array();
75
-
76
-		// Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
77
-		$this->config_page_url = array('admin.php@variants');
78
-
79
-		// Dependencies
80
-		$this->hidden = false;			// A condition to hide module
81
-		$this->depends = array('modProduct');	// List of module class names as string that must be enabled if this module is enabled
82
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
83
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
84
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
85
-		$this->need_dolibarr_version = array(3,0);	// Minimum version of Dolibarr required by module
86
-		$this->langfiles = array("products");
87
-
88
-		// Constants
89
-		$this->const = array();
90
-
91
-		// Array to add new pages in new tabs
92
-		$this->tabs = array(
36
+    /**
37
+     *   Constructor. Define names, constants, directories, boxes, permissions
38
+     *
39
+     *   @param      DoliDB		$db      Database handler
40
+     */
41
+    public function __construct($db)
42
+    {
43
+        global $langs,$conf;
44
+
45
+        $this->db = $db;
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 = 610;
50
+        // Key text used to identify module (for permissions, menus, etc...)
51
+        $this->rights_class = 'variants';
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 = "products";
56
+        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
+        $this->name = preg_replace('/^mod/i','',get_class($this));
58
+        // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59
+        $this->description = 'Allows creating products variant based on new attributes';
60
+        // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
61
+        $this->version = 'dolibarr';
62
+        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
63
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
64
+        // Name of image file used for this module.
65
+        // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
66
+        // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
67
+        $this->picto='product';
68
+
69
+        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
70
+        $this->module_parts = array();
71
+
72
+        // Data directories to create when module is enabled.
73
+        // Example: this->dirs = array("/mymodule/temp");
74
+        $this->dirs = array();
75
+
76
+        // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module.
77
+        $this->config_page_url = array('admin.php@variants');
78
+
79
+        // Dependencies
80
+        $this->hidden = false;			// A condition to hide module
81
+        $this->depends = array('modProduct');	// List of module class names as string that must be enabled if this module is enabled
82
+        $this->requiredby = array();	// List of module ids to disable if this one is disabled
83
+        $this->conflictwith = array();	// List of module class names as string this module is in conflict with
84
+        $this->phpmin = array(5,4);		// Minimum version of PHP required by module
85
+        $this->need_dolibarr_version = array(3,0);	// Minimum version of Dolibarr required by module
86
+        $this->langfiles = array("products");
87
+
88
+        // Constants
89
+        $this->const = array();
90
+
91
+        // Array to add new pages in new tabs
92
+        $this->tabs = array(
93 93
 //			'product:+combinations:Combinaciones:products:1:/variants/combinations.php?id=__ID__'
94
-		);
95
-
96
-		// Dictionaries
97
-		if (! isset($conf->mymodule->enabled))
98
-		{
99
-			$conf->mymodule=new stdClass();
100
-			$conf->mymodule->enabled=0;
101
-		}
102
-		$this->dictionaries=array();
103
-
104
-		// Boxes
105
-		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
106
-		$this->boxes = array();			// List of boxes
107
-
108
-		// Permissions
109
-		$this->rights = array();		// Permission array used by this module
110
-	}
94
+        );
95
+
96
+        // Dictionaries
97
+        if (! isset($conf->mymodule->enabled))
98
+        {
99
+            $conf->mymodule=new stdClass();
100
+            $conf->mymodule->enabled=0;
101
+        }
102
+        $this->dictionaries=array();
103
+
104
+        // Boxes
105
+        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
106
+        $this->boxes = array();			// List of boxes
107
+
108
+        // Permissions
109
+        $this->rights = array();		// Permission array used by this module
110
+    }
111 111
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *  \file       htdocs/core/modules/modVariants.class.php
26 26
  *  \ingroup    produit
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
 	public function __construct($db)
42 42
 	{
43
-		global $langs,$conf;
43
+		global $langs, $conf;
44 44
 
45 45
 		$this->db = $db;
46 46
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		// It is used to group modules in module setup page
55 55
 		$this->family = "products";
56 56
 		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
57
-		$this->name = preg_replace('/^mod/i','',get_class($this));
57
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
58 58
 		// Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module)
59 59
 		$this->description = 'Allows creating products variant based on new attributes';
60 60
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 		// Name of image file used for this module.
65 65
 		// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
66 66
 		// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
67
-		$this->picto='product';
67
+		$this->picto = 'product';
68 68
 
69 69
 		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
70 70
 		$this->module_parts = array();
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
 		$this->config_page_url = array('admin.php@variants');
78 78
 
79 79
 		// Dependencies
80
-		$this->hidden = false;			// A condition to hide module
81
-		$this->depends = array('modProduct');	// List of module class names as string that must be enabled if this module is enabled
82
-		$this->requiredby = array();	// List of module ids to disable if this one is disabled
83
-		$this->conflictwith = array();	// List of module class names as string this module is in conflict with
84
-		$this->phpmin = array(5,4);		// Minimum version of PHP required by module
85
-		$this->need_dolibarr_version = array(3,0);	// Minimum version of Dolibarr required by module
80
+		$this->hidden = false; // A condition to hide module
81
+		$this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled
82
+		$this->requiredby = array(); // List of module ids to disable if this one is disabled
83
+		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
84
+		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
85
+		$this->need_dolibarr_version = array(3, 0); // Minimum version of Dolibarr required by module
86 86
 		$this->langfiles = array("products");
87 87
 
88 88
 		// Constants
@@ -94,18 +94,18 @@  discard block
 block discarded – undo
94 94
 		);
95 95
 
96 96
 		// Dictionaries
97
-		if (! isset($conf->mymodule->enabled))
97
+		if (!isset($conf->mymodule->enabled))
98 98
 		{
99
-			$conf->mymodule=new stdClass();
100
-			$conf->mymodule->enabled=0;
99
+			$conf->mymodule = new stdClass();
100
+			$conf->mymodule->enabled = 0;
101 101
 		}
102
-		$this->dictionaries=array();
102
+		$this->dictionaries = array();
103 103
 
104 104
 		// Boxes
105 105
 		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
106
-		$this->boxes = array();			// List of boxes
106
+		$this->boxes = array(); // List of boxes
107 107
 
108 108
 		// Permissions
109
-		$this->rights = array();		// Permission array used by this module
109
+		$this->rights = array(); // Permission array used by this module
110 110
 	}
111 111
 }
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/rapport/pdf_paiement.class.php 3 patches
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -32,100 +32,100 @@  discard block
 block discarded – undo
32 32
  */
33 33
 class pdf_paiement
34 34
 {
35
-	/**
35
+    /**
36 36
      *  Constructor
37 37
      *
38 38
      *  @param      DoliDb		$db      Database handler
39
-	 */
40
-	function __construct($db)
41
-	{
42
-		global $langs,$conf;
39
+     */
40
+    function __construct($db)
41
+    {
42
+        global $langs,$conf;
43 43
 
44
-		// Load translation files required by the page
44
+        // Load translation files required by the page
45 45
         $langs->loadLangs(array("bills","compta","main"));
46 46
 
47
-		$this->db = $db;
48
-		$this->description = $langs->transnoentities("ListOfCustomerPayments");
49
-
50
-		// Dimension page pour format A4
51
-		$this->type = 'pdf';
52
-		$formatarray=pdf_getFormat();
53
-		$this->page_largeur = $formatarray['width'];
54
-		$this->page_hauteur = $formatarray['height'];
55
-		$this->format = array($this->page_largeur,$this->page_hauteur);
56
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
60
-
61
-		$this->tab_top = 30;
62
-
63
-		$this->line_height = 5;
64
-		$this->line_per_page = 40;
65
-		$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;	// must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
-
67
-		$this->posxdate=$this->marge_gauche+2;
68
-		$this->posxpaymenttype=42;
69
-		$this->posxinvoice=82;
70
-		$this->posxbankaccount=110;
71
-		$this->posxinvoiceamount=132;
72
-		$this->posxpaymentamount=162;
73
-		if ($this->page_largeur < 210) // To work with US executive format
74
-		{
75
-			$this->line_per_page = 35;
76
-			$this->posxpaymenttype-=10;
77
-			$this->posxinvoice-=0;
78
-			$this->posxinvoiceamount-=10;
79
-			$this->posxpaymentamount-=20;
80
-		}
81
-		// which type of document will be generated: clients (client) or providers (fourn) invoices
82
-		$this->doc_type = "client";
83
-	}
47
+        $this->db = $db;
48
+        $this->description = $langs->transnoentities("ListOfCustomerPayments");
49
+
50
+        // Dimension page pour format A4
51
+        $this->type = 'pdf';
52
+        $formatarray=pdf_getFormat();
53
+        $this->page_largeur = $formatarray['width'];
54
+        $this->page_hauteur = $formatarray['height'];
55
+        $this->format = array($this->page_largeur,$this->page_hauteur);
56
+        $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
+        $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
+        $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
+        $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
60
+
61
+        $this->tab_top = 30;
62
+
63
+        $this->line_height = 5;
64
+        $this->line_per_page = 40;
65
+        $this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;	// must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
+
67
+        $this->posxdate=$this->marge_gauche+2;
68
+        $this->posxpaymenttype=42;
69
+        $this->posxinvoice=82;
70
+        $this->posxbankaccount=110;
71
+        $this->posxinvoiceamount=132;
72
+        $this->posxpaymentamount=162;
73
+        if ($this->page_largeur < 210) // To work with US executive format
74
+        {
75
+            $this->line_per_page = 35;
76
+            $this->posxpaymenttype-=10;
77
+            $this->posxinvoice-=0;
78
+            $this->posxinvoiceamount-=10;
79
+            $this->posxpaymentamount-=20;
80
+        }
81
+        // which type of document will be generated: clients (client) or providers (fourn) invoices
82
+        $this->doc_type = "client";
83
+    }
84 84
 
85 85
 
86 86
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
87
-	/**
88
-	 *	Fonction generant la rapport sur le disque
89
-	 *
90
-	 *	@param	string	$_dir			repertoire
91
-	 *	@param	int		$month			mois du rapport
92
-	 *	@param	int		$year			annee du rapport
93
-	 *	@param	string	$outputlangs	Lang output object
94
-	 *	@return	int						<0 if KO, >0 if OK
95
-	 */
96
-	function write_file($_dir, $month, $year, $outputlangs)
97
-	{
87
+    /**
88
+     *	Fonction generant la rapport sur le disque
89
+     *
90
+     *	@param	string	$_dir			repertoire
91
+     *	@param	int		$month			mois du rapport
92
+     *	@param	int		$year			annee du rapport
93
+     *	@param	string	$outputlangs	Lang output object
94
+     *	@return	int						<0 if KO, >0 if OK
95
+     */
96
+    function write_file($_dir, $month, $year, $outputlangs)
97
+    {
98 98
         // phpcs:enable
99
-		include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
99
+        include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
100 100
 
101
-		global $conf, $hookmanager, $langs, $user;
101
+        global $conf, $hookmanager, $langs, $user;
102 102
 
103
-		$socid=0;
104
-		if ($user->societe_id) $socid=$user->societe_id;
103
+        $socid=0;
104
+        if ($user->societe_id) $socid=$user->societe_id;
105 105
 
106
-		if (! is_object($outputlangs)) $outputlangs=$langs;
107
-		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
106
+        if (! is_object($outputlangs)) $outputlangs=$langs;
107
+        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
+        if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
109 109
 
110
-		$this->month=$month;
111
-		$this->year=$year;
112
-		$dir=$_dir.'/'.$year;
110
+        $this->month=$month;
111
+        $this->year=$year;
112
+        $dir=$_dir.'/'.$year;
113 113
 
114
-		if (! is_dir($dir))
115
-		{
116
-			$result=dol_mkdir($dir);
117
-			if ($result < 0)
118
-			{
119
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
120
-				return -1;
121
-			}
122
-		}
114
+        if (! is_dir($dir))
115
+        {
116
+            $result=dol_mkdir($dir);
117
+            if ($result < 0)
118
+            {
119
+                $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
120
+                return -1;
121
+            }
122
+        }
123 123
 
124
-		$month = sprintf("%02d",$month);
125
-		$year = sprintf("%04d",$year);
124
+        $month = sprintf("%02d",$month);
125
+        $year = sprintf("%04d",$year);
126 126
 
127
-		$file = $dir . "/payments-".$year."-".$month.".pdf";
128
-		switch ($this->doc_type) {
127
+        $file = $dir . "/payments-".$year."-".$month.".pdf";
128
+        switch ($this->doc_type) {
129 129
             case "client":
130 130
                 $file = $dir . "/payments-".$year."-".$month.".pdf";
131 131
                 break;
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
         }
136 136
 
137 137
 
138
-		// Add pdfgeneration hook
139
-		if (! is_object($hookmanager))
140
-		{
141
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
142
-			$hookmanager=new HookManager($this->db);
143
-		}
144
-		$hookmanager->initHooks(array('pdfgeneration'));
145
-		$parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
146
-		global $action;
147
-		$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
138
+        // Add pdfgeneration hook
139
+        if (! is_object($hookmanager))
140
+        {
141
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
142
+            $hookmanager=new HookManager($this->db);
143
+        }
144
+        $hookmanager->initHooks(array('pdfgeneration'));
145
+        $parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
146
+        global $action;
147
+        $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
148 148
 
149 149
         $pdf=pdf_getInstance($this->format);
150 150
         $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
         $num=0;
160 160
         $lines=array();
161 161
 
162
-		// count number of lines of payment
163
-		$sql = "SELECT p.rowid as prowid";
164
-		switch ($this->doc_type) {
162
+        // count number of lines of payment
163
+        $sql = "SELECT p.rowid as prowid";
164
+        switch ($this->doc_type) {
165 165
             case "client":
166 166
                 $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
167 167
                 break;
@@ -169,192 +169,192 @@  discard block
 block discarded – undo
169 169
                 $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
170 170
                 break;
171 171
         }
172
-		$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
173
-		$sql.= " AND p.entity = " . $conf->entity;
174
-		$result = $this->db->query($sql);
175
-		if ($result)
176
-		{
177
-			$numpaiement = $this->db->num_rows($result);
178
-		}
179
-
180
-		// number of bill
181
-		switch ($this->doc_type) {
182
-			case "client":
183
-				$sql = "SELECT p.datep as dp, f.ref";
184
-				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
185
-				$sql.= ", c.code as paiement_code, p.num_paiement";
186
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
-				$sql.= ", pf.amount as pf_amount";
188
-				if (! empty($conf->banque->enabled))
189
-					$sql.= ", ba.ref as bankaccount";
190
-				$sql.= ", p.rowid as prowid";
191
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
-				$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193
-				$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
-				if (! empty($conf->banque->enabled))
195
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
197
-				if (! $user->rights->societe->client->voir && ! $socid)
198
-				{
199
-					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200
-				}
201
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
-				if (! empty($conf->banque->enabled))
203
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
-				$sql.= " AND f.entity = ".$conf->entity;
205
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206
-				if (! $user->rights->societe->client->voir && ! $socid)
207
-				{
208
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
209
-				}
210
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212
-				break;
213
-			case "fourn":
214
-				$sql = "SELECT p.datep as dp, f.ref as ref";
215
-				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
216
-				$sql.= ", c.code as paiement_code, p.num_paiement";
217
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
-				$sql.= ", pf.amount as pf_amount";
219
-				if (! empty($conf->banque->enabled))
220
-					$sql.= ", ba.ref as bankaccount";
221
-				$sql.= ", p.rowid as prowid";
222
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
-				$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
-				$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
-				if (! empty($conf->banque->enabled))
226
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
228
-				if (! $user->rights->societe->client->voir && ! $socid)
229
-				{
230
-					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231
-				}
232
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
-				if (! empty($conf->banque->enabled))
234
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
-				$sql.= " AND f.entity = ".$conf->entity;
236
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237
-				if (! $user->rights->societe->client->voir && ! $socid)
238
-				{
239
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
240
-				}
241
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243
-				break;
244
-		}
245
-
246
-		dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
247
-		$result = $this->db->query($sql);
248
-		if ($result)
249
-		{
250
-			$num = $this->db->num_rows($result);
251
-			$i = 0;
252
-
253
-			while ($i < $num)
254
-			{
255
-				$objp = $this->db->fetch_object($result);
256
-
257
-				$lines[$i][0] = $objp->ref;
258
-				$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
259
-				$lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
260
-				$lines[$i][3] = $objp->num_paiement;
261
-				$lines[$i][4] = price($objp->paiement_amount);
262
-				$lines[$i][5] = price($objp->facture_amount);
263
-				$lines[$i][6] = price($objp->pf_amount);
264
-				$lines[$i][7] = $objp->prowid;
265
-				$lines[$i][8] = $objp->bankaccount;
266
-				$lines[$i][9] = $objp->paiement_amount;
267
-				$i++;
268
-			}
269
-		}
270
-		else
271
-		{
272
-			dol_print_error($this->db);
273
-		}
274
-
275
-		$pages = intval(($num + $numpaiement) / $this->line_per_page);
276
-
277
-		if ((($num + $numpaiement) % $this->line_per_page)>0)
278
-		{
279
-			$pages++;
280
-		}
281
-
282
-		if ($pages == 0)
283
-		{
284
-			// force to build at least one page if report has no line
285
-			$pages = 1;
286
-		}
287
-
288
-		$pdf->Open();
289
-		$pagenb=0;
290
-		$pdf->SetDrawColor(128,128,128);
291
-
292
-		$pdf->SetTitle($outputlangs->transnoentities("Payments"));
293
-		$pdf->SetSubject($outputlangs->transnoentities("Payments"));
294
-		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
295
-		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296
-		//$pdf->SetKeyWords();
297
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
298
-
299
-		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300
-		$pdf->SetAutoPageBreak(1,0);
301
-
302
-		// New page
303
-		$pdf->AddPage();
304
-		$pagenb++;
305
-		$this->_pagehead($pdf, $pagenb, 1, $outputlangs);
306
-		$pdf->SetFont('','', 9);
307
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
308
-		$pdf->SetTextColor(0,0,0);
309
-
310
-
311
-		$this->Body($pdf, 1, $lines, $outputlangs);
312
-
313
-		if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
314
-
315
-		$pdf->Close();
316
-
317
-		$pdf->Output($file,'F');
318
-
319
-		// Add pdfgeneration hook
320
-		if (! is_object($hookmanager))
321
-		{
322
-			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
323
-			$hookmanager=new HookManager($this->db);
324
-		}
325
-		$hookmanager->initHooks(array('pdfgeneration'));
326
-		$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
327
-		global $action;
328
-		$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
329
-
330
-		if (! empty($conf->global->MAIN_UMASK))
331
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
332
-
333
-		$this->result = array('fullpath'=>$file);
334
-
335
-		return 1;
336
-	}
337
-
338
-	/**
339
-	 *  Show top header of page.
340
-	 *
341
-	 *  @param	PDF			$pdf     		Object PDF
342
-	 *  @param  int			$page	     	Object to show
343
-	 *  @param  int	    	$showaddress    0=no, 1=yes
344
-	 *  @param  Translate	$outputlangs	Object lang for output
345
-	 *  @return	void
346
-	 */
347
-	function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
348
-	{
349
-		global $langs, $conf;
350
-
351
-		// Do not add the BACKGROUND as this is a report
352
-		//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
353
-
354
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
355
-
356
-		$title=$conf->global->MAIN_INFO_SOCIETE_NOM;
357
-		switch($this->doc_type) {
172
+        $sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
173
+        $sql.= " AND p.entity = " . $conf->entity;
174
+        $result = $this->db->query($sql);
175
+        if ($result)
176
+        {
177
+            $numpaiement = $this->db->num_rows($result);
178
+        }
179
+
180
+        // number of bill
181
+        switch ($this->doc_type) {
182
+            case "client":
183
+                $sql = "SELECT p.datep as dp, f.ref";
184
+                //$sql .= ", c.libelle as paiement_type, p.num_paiement";
185
+                $sql.= ", c.code as paiement_code, p.num_paiement";
186
+                $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
+                $sql.= ", pf.amount as pf_amount";
188
+                if (! empty($conf->banque->enabled))
189
+                    $sql.= ", ba.ref as bankaccount";
190
+                $sql.= ", p.rowid as prowid";
191
+                $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
+                $sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193
+                $sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
+                if (! empty($conf->banque->enabled))
195
+                    $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
+                $sql.= " ".MAIN_DB_PREFIX."societe as s";
197
+                if (! $user->rights->societe->client->voir && ! $socid)
198
+                {
199
+                    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200
+                }
201
+                $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
+                if (! empty($conf->banque->enabled))
203
+                    $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
+                $sql.= " AND f.entity = ".$conf->entity;
205
+                $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206
+                if (! $user->rights->societe->client->voir && ! $socid)
207
+                {
208
+                    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
209
+                }
210
+                if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
+                $sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212
+                break;
213
+            case "fourn":
214
+                $sql = "SELECT p.datep as dp, f.ref as ref";
215
+                //$sql .= ", c.libelle as paiement_type, p.num_paiement";
216
+                $sql.= ", c.code as paiement_code, p.num_paiement";
217
+                $sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
+                $sql.= ", pf.amount as pf_amount";
219
+                if (! empty($conf->banque->enabled))
220
+                    $sql.= ", ba.ref as bankaccount";
221
+                $sql.= ", p.rowid as prowid";
222
+                $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
+                $sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
+                $sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
+                if (! empty($conf->banque->enabled))
226
+                    $sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
+                $sql.= " ".MAIN_DB_PREFIX."societe as s";
228
+                if (! $user->rights->societe->client->voir && ! $socid)
229
+                {
230
+                    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231
+                }
232
+                $sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
+                if (! empty($conf->banque->enabled))
234
+                    $sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
+                $sql.= " AND f.entity = ".$conf->entity;
236
+                $sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237
+                if (! $user->rights->societe->client->voir && ! $socid)
238
+                {
239
+                    $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
240
+                }
241
+                if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
+                $sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243
+                break;
244
+        }
245
+
246
+        dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
247
+        $result = $this->db->query($sql);
248
+        if ($result)
249
+        {
250
+            $num = $this->db->num_rows($result);
251
+            $i = 0;
252
+
253
+            while ($i < $num)
254
+            {
255
+                $objp = $this->db->fetch_object($result);
256
+
257
+                $lines[$i][0] = $objp->ref;
258
+                $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
259
+                $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
260
+                $lines[$i][3] = $objp->num_paiement;
261
+                $lines[$i][4] = price($objp->paiement_amount);
262
+                $lines[$i][5] = price($objp->facture_amount);
263
+                $lines[$i][6] = price($objp->pf_amount);
264
+                $lines[$i][7] = $objp->prowid;
265
+                $lines[$i][8] = $objp->bankaccount;
266
+                $lines[$i][9] = $objp->paiement_amount;
267
+                $i++;
268
+            }
269
+        }
270
+        else
271
+        {
272
+            dol_print_error($this->db);
273
+        }
274
+
275
+        $pages = intval(($num + $numpaiement) / $this->line_per_page);
276
+
277
+        if ((($num + $numpaiement) % $this->line_per_page)>0)
278
+        {
279
+            $pages++;
280
+        }
281
+
282
+        if ($pages == 0)
283
+        {
284
+            // force to build at least one page if report has no line
285
+            $pages = 1;
286
+        }
287
+
288
+        $pdf->Open();
289
+        $pagenb=0;
290
+        $pdf->SetDrawColor(128,128,128);
291
+
292
+        $pdf->SetTitle($outputlangs->transnoentities("Payments"));
293
+        $pdf->SetSubject($outputlangs->transnoentities("Payments"));
294
+        $pdf->SetCreator("Dolibarr ".DOL_VERSION);
295
+        $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296
+        //$pdf->SetKeyWords();
297
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
298
+
299
+        $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300
+        $pdf->SetAutoPageBreak(1,0);
301
+
302
+        // New page
303
+        $pdf->AddPage();
304
+        $pagenb++;
305
+        $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
306
+        $pdf->SetFont('','', 9);
307
+        $pdf->MultiCell(0, 3, '');		// Set interline to 3
308
+        $pdf->SetTextColor(0,0,0);
309
+
310
+
311
+        $this->Body($pdf, 1, $lines, $outputlangs);
312
+
313
+        if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
314
+
315
+        $pdf->Close();
316
+
317
+        $pdf->Output($file,'F');
318
+
319
+        // Add pdfgeneration hook
320
+        if (! is_object($hookmanager))
321
+        {
322
+            include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
323
+            $hookmanager=new HookManager($this->db);
324
+        }
325
+        $hookmanager->initHooks(array('pdfgeneration'));
326
+        $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
327
+        global $action;
328
+        $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
329
+
330
+        if (! empty($conf->global->MAIN_UMASK))
331
+            @chmod($file, octdec($conf->global->MAIN_UMASK));
332
+
333
+        $this->result = array('fullpath'=>$file);
334
+
335
+        return 1;
336
+    }
337
+
338
+    /**
339
+     *  Show top header of page.
340
+     *
341
+     *  @param	PDF			$pdf     		Object PDF
342
+     *  @param  int			$page	     	Object to show
343
+     *  @param  int	    	$showaddress    0=no, 1=yes
344
+     *  @param  Translate	$outputlangs	Object lang for output
345
+     *  @return	void
346
+     */
347
+    function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
348
+    {
349
+        global $langs, $conf;
350
+
351
+        // Do not add the BACKGROUND as this is a report
352
+        //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
353
+
354
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
355
+
356
+        $title=$conf->global->MAIN_INFO_SOCIETE_NOM;
357
+        switch($this->doc_type) {
358 358
             case "client":
359 359
                 $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
360 360
                 break;
@@ -362,139 +362,139 @@  discard block
 block discarded – undo
362 362
                 $title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
363 363
                 break;
364 364
         }
365
-		$title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
366
-		$pdf->SetFont('','B',$default_font_size + 1);
367
-		$pdf->SetXY($this->marge_gauche,10);
368
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
365
+        $title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
366
+        $pdf->SetFont('','B',$default_font_size + 1);
367
+        $pdf->SetXY($this->marge_gauche,10);
368
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
369 369
 
370
-		$pdf->SetFont('','',$default_font_size);
370
+        $pdf->SetFont('','',$default_font_size);
371 371
 
372 372
         $pdf->SetXY($this->posxdate, 16);
373
-		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
373
+        $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
374 374
 
375 375
         $pdf->SetXY($this->posxdate+100, 16);
376
-		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
376
+        $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
377 377
 
378 378
 
379
-		// Title line
379
+        // Title line
380 380
         $pdf->SetXY($this->posxdate, $this->tab_top+2);
381
-		$pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
381
+        $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
382 382
 
383
-		$pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
383
+        $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
384 384
         $pdf->SetXY($this->posxpaymenttype, $this->tab_top+2);
385
-		$pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
385
+        $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
386 386
 
387
-		$pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
387
+        $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
388 388
         $pdf->SetXY($this->posxinvoice, $this->tab_top+2);
389
-		$pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
389
+        $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
390 390
 
391
-		$pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
391
+        $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
392 392
         $pdf->SetXY($this->posxbankaccount, $this->tab_top+2);
393
-		$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
393
+        $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
394 394
 
395 395
 
396
-		$pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
396
+        $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
397 397
         $pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2);
398
-		$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
398
+        $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
399 399
 
400
-		$pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
400
+        $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
401 401
         $pdf->SetXY($this->posxpaymentamount, $this->tab_top+2);
402
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
402
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
403 403
 
404
-		$pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
404
+        $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
405 405
 
406
-		$pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
407
-	}
406
+        $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
407
+    }
408 408
 
409 409
 
410 410
     // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
411
-	/**
412
-	 *	Output body
413
-	 *
414
-	 *	@param	PDF			$pdf			PDF object
415
-	 *	@param	string		$page			Page
416
-	 *	@param	array		$lines			Array of lines
417
-	 *	@param	Translate	$outputlangs	Object langs
418
-	 *	@return	void
419
-	 */
420
-	function Body(&$pdf, $page, $lines, $outputlangs)
421
-	{
411
+    /**
412
+     *	Output body
413
+     *
414
+     *	@param	PDF			$pdf			PDF object
415
+     *	@param	string		$page			Page
416
+     *	@param	array		$lines			Array of lines
417
+     *	@param	Translate	$outputlangs	Object langs
418
+     *	@return	void
419
+     */
420
+    function Body(&$pdf, $page, $lines, $outputlangs)
421
+    {
422 422
         // phpcs:enable
423
-		global $langs;
424
-		$default_font_size = pdf_getPDFFontSize($outputlangs);
425
-
426
-		$pdf->SetFont('','', $default_font_size - 1);
427
-		$oldprowid = 0;
428
-		$total_page = 0;
429
-		$total = 0;
430
-		$pdf->SetFillColor(220,220,220);
431
-		$yp = 0;
432
-		$numlines=count($lines);
433
-		for ($j = 0 ; $j < $numlines ; $j++)
434
-		{
435
-			$i = $j;
436
-			if ($yp > $this->tab_height -5)
437
-			{
438
-				$page++;
439
-				$pdf->AddPage();
440
-				$this->_pagehead($pdf, $page, 0, $outputlangs);
441
-				$pdf->SetFont('','', $default_font_size - 1);
442
-				$yp = 0;
443
-			}
444
-			if ($oldprowid <> $lines[$j][7])
445
-			{
446
-				if ($yp > $this->tab_height -15)
447
-				{
448
-					$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
449
-					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height,  $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
450
-					$page++;
451
-					$pdf->AddPage();
452
-					$this->_pagehead($pdf, $page, 0, $outputlangs);
453
-					$pdf->SetFont('','', $default_font_size - 1);
454
-					$yp = 0;
455
-					$total += $total_page;
456
-					$total_page = 0;
457
-				}
458
-
459
-				$pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
460
-				$pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
461
-
462
-				$pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
463
-				$pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
464
-
465
-				$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
466
-				$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
467
-
468
-				$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
469
-				$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
470
-				$yp = $yp + 5;
471
-				$total_page += $lines[$j][9];
472
-			}
473
-
474
-			// Invoice number
475
-			$pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
476
-			$pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
477
-
478
-			// BankAccount
479
-			$pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
480
-			$pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
481
-
482
-			// Invoice amount
483
-			$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
484
-			$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
485
-
486
-			// Payment amount
487
-			$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
488
-			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
489
-			$yp = $yp + 5;
490
-
491
-			if ($oldprowid <> $lines[$j][7])
492
-			{
493
-				$oldprowid = $lines[$j][7];
494
-			}
495
-		}
496
-		$total += $total_page;
497
-		$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
498
-		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0);
499
-	}
423
+        global $langs;
424
+        $default_font_size = pdf_getPDFFontSize($outputlangs);
425
+
426
+        $pdf->SetFont('','', $default_font_size - 1);
427
+        $oldprowid = 0;
428
+        $total_page = 0;
429
+        $total = 0;
430
+        $pdf->SetFillColor(220,220,220);
431
+        $yp = 0;
432
+        $numlines=count($lines);
433
+        for ($j = 0 ; $j < $numlines ; $j++)
434
+        {
435
+            $i = $j;
436
+            if ($yp > $this->tab_height -5)
437
+            {
438
+                $page++;
439
+                $pdf->AddPage();
440
+                $this->_pagehead($pdf, $page, 0, $outputlangs);
441
+                $pdf->SetFont('','', $default_font_size - 1);
442
+                $yp = 0;
443
+            }
444
+            if ($oldprowid <> $lines[$j][7])
445
+            {
446
+                if ($yp > $this->tab_height -15)
447
+                {
448
+                    $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
449
+                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height,  $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
450
+                    $page++;
451
+                    $pdf->AddPage();
452
+                    $this->_pagehead($pdf, $page, 0, $outputlangs);
453
+                    $pdf->SetFont('','', $default_font_size - 1);
454
+                    $yp = 0;
455
+                    $total += $total_page;
456
+                    $total_page = 0;
457
+                }
458
+
459
+                $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
460
+                $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
461
+
462
+                $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
463
+                $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
464
+
465
+                $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
466
+                $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
467
+
468
+                $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
469
+                $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
470
+                $yp = $yp + 5;
471
+                $total_page += $lines[$j][9];
472
+            }
473
+
474
+            // Invoice number
475
+            $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
476
+            $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
477
+
478
+            // BankAccount
479
+            $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
480
+            $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
481
+
482
+            // Invoice amount
483
+            $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
484
+            $pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
485
+
486
+            // Payment amount
487
+            $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
488
+            $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
489
+            $yp = $yp + 5;
490
+
491
+            if ($oldprowid <> $lines[$j][7])
492
+            {
493
+                $oldprowid = $lines[$j][7];
494
+            }
495
+        }
496
+        $total += $total_page;
497
+        $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
498
+        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('Total')." : ".price($total), 0, 'R', 0);
499
+    }
500 500
 }
Please login to merge, or discard this patch.
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -39,44 +39,44 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	function __construct($db)
41 41
 	{
42
-		global $langs,$conf;
42
+		global $langs, $conf;
43 43
 
44 44
 		// Load translation files required by the page
45
-        $langs->loadLangs(array("bills","compta","main"));
45
+        $langs->loadLangs(array("bills", "compta", "main"));
46 46
 
47 47
 		$this->db = $db;
48 48
 		$this->description = $langs->transnoentities("ListOfCustomerPayments");
49 49
 
50 50
 		// Dimension page pour format A4
51 51
 		$this->type = 'pdf';
52
-		$formatarray=pdf_getFormat();
52
+		$formatarray = pdf_getFormat();
53 53
 		$this->page_largeur = $formatarray['width'];
54 54
 		$this->page_hauteur = $formatarray['height'];
55
-		$this->format = array($this->page_largeur,$this->page_hauteur);
56
-		$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
57
-		$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
58
-		$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
59
-		$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
55
+		$this->format = array($this->page_largeur, $this->page_hauteur);
56
+		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
57
+		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
58
+		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
59
+		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
60 60
 
61 61
 		$this->tab_top = 30;
62 62
 
63 63
 		$this->line_height = 5;
64 64
 		$this->line_per_page = 40;
65
-		$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;	// must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
-
67
-		$this->posxdate=$this->marge_gauche+2;
68
-		$this->posxpaymenttype=42;
69
-		$this->posxinvoice=82;
70
-		$this->posxbankaccount=110;
71
-		$this->posxinvoiceamount=132;
72
-		$this->posxpaymentamount=162;
65
+		$this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5; // must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
66
+
67
+		$this->posxdate = $this->marge_gauche + 2;
68
+		$this->posxpaymenttype = 42;
69
+		$this->posxinvoice = 82;
70
+		$this->posxbankaccount = 110;
71
+		$this->posxinvoiceamount = 132;
72
+		$this->posxpaymentamount = 162;
73 73
 		if ($this->page_largeur < 210) // To work with US executive format
74 74
 		{
75 75
 			$this->line_per_page = 35;
76
-			$this->posxpaymenttype-=10;
77
-			$this->posxinvoice-=0;
78
-			$this->posxinvoiceamount-=10;
79
-			$this->posxpaymentamount-=20;
76
+			$this->posxpaymenttype -= 10;
77
+			$this->posxinvoice -= 0;
78
+			$this->posxinvoiceamount -= 10;
79
+			$this->posxpaymentamount -= 20;
80 80
 		}
81 81
 		// which type of document will be generated: clients (client) or providers (fourn) invoices
82 82
 		$this->doc_type = "client";
@@ -100,54 +100,54 @@  discard block
 block discarded – undo
100 100
 
101 101
 		global $conf, $hookmanager, $langs, $user;
102 102
 
103
-		$socid=0;
104
-		if ($user->societe_id) $socid=$user->societe_id;
103
+		$socid = 0;
104
+		if ($user->societe_id) $socid = $user->societe_id;
105 105
 
106
-		if (! is_object($outputlangs)) $outputlangs=$langs;
106
+		if (!is_object($outputlangs)) $outputlangs = $langs;
107 107
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
108
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
109 109
 
110
-		$this->month=$month;
111
-		$this->year=$year;
112
-		$dir=$_dir.'/'.$year;
110
+		$this->month = $month;
111
+		$this->year = $year;
112
+		$dir = $_dir.'/'.$year;
113 113
 
114
-		if (! is_dir($dir))
114
+		if (!is_dir($dir))
115 115
 		{
116
-			$result=dol_mkdir($dir);
116
+			$result = dol_mkdir($dir);
117 117
 			if ($result < 0)
118 118
 			{
119
-				$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
119
+				$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
120 120
 				return -1;
121 121
 			}
122 122
 		}
123 123
 
124
-		$month = sprintf("%02d",$month);
125
-		$year = sprintf("%04d",$year);
124
+		$month = sprintf("%02d", $month);
125
+		$year = sprintf("%04d", $year);
126 126
 
127
-		$file = $dir . "/payments-".$year."-".$month.".pdf";
127
+		$file = $dir."/payments-".$year."-".$month.".pdf";
128 128
 		switch ($this->doc_type) {
129 129
             case "client":
130
-                $file = $dir . "/payments-".$year."-".$month.".pdf";
130
+                $file = $dir."/payments-".$year."-".$month.".pdf";
131 131
                 break;
132 132
             case "fourn":
133
-                $file = $dir . "/supplier_payments-".$year."-".$month.".pdf";
133
+                $file = $dir."/supplier_payments-".$year."-".$month.".pdf";
134 134
                 break;
135 135
         }
136 136
 
137 137
 
138 138
 		// Add pdfgeneration hook
139
-		if (! is_object($hookmanager))
139
+		if (!is_object($hookmanager))
140 140
 		{
141 141
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
142
-			$hookmanager=new HookManager($this->db);
142
+			$hookmanager = new HookManager($this->db);
143 143
 		}
144 144
 		$hookmanager->initHooks(array('pdfgeneration'));
145
-		$parameters=array('file'=>$file,'outputlangs'=>$outputlangs);
145
+		$parameters = array('file'=>$file, 'outputlangs'=>$outputlangs);
146 146
 		global $action;
147
-		$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
147
+		$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
148 148
 
149
-        $pdf=pdf_getInstance($this->format);
150
-        $default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
149
+        $pdf = pdf_getInstance($this->format);
150
+        $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
151 151
 
152 152
         if (class_exists('TCPDF'))
153 153
         {
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
         }
157 157
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
158 158
 
159
-        $num=0;
160
-        $lines=array();
159
+        $num = 0;
160
+        $lines = array();
161 161
 
162 162
 		// count number of lines of payment
163 163
 		$sql = "SELECT p.rowid as prowid";
164 164
 		switch ($this->doc_type) {
165 165
             case "client":
166
-                $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p";
166
+                $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
167 167
                 break;
168 168
             case "fourn":
169
-                $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
169
+                $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
170 170
                 break;
171 171
         }
172
-		$sql.= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
173
-		$sql.= " AND p.entity = " . $conf->entity;
172
+		$sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
173
+		$sql .= " AND p.entity = ".$conf->entity;
174 174
 		$result = $this->db->query($sql);
175 175
 		if ($result)
176 176
 		{
@@ -182,64 +182,64 @@  discard block
 block discarded – undo
182 182
 			case "client":
183 183
 				$sql = "SELECT p.datep as dp, f.ref";
184 184
 				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
185
-				$sql.= ", c.code as paiement_code, p.num_paiement";
186
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
-				$sql.= ", pf.amount as pf_amount";
188
-				if (! empty($conf->banque->enabled))
189
-					$sql.= ", ba.ref as bankaccount";
190
-				$sql.= ", p.rowid as prowid";
191
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
-				$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193
-				$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
-				if (! empty($conf->banque->enabled))
195
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
197
-				if (! $user->rights->societe->client->voir && ! $socid)
185
+				$sql .= ", c.code as paiement_code, p.num_paiement";
186
+				$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187
+				$sql .= ", pf.amount as pf_amount";
188
+				if (!empty($conf->banque->enabled))
189
+					$sql .= ", ba.ref as bankaccount";
190
+				$sql .= ", p.rowid as prowid";
191
+				$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192
+				$sql .= ", ".MAIN_DB_PREFIX."facture as f,";
193
+				$sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
+				if (!empty($conf->banque->enabled))
195
+					$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196
+				$sql .= " ".MAIN_DB_PREFIX."societe as s";
197
+				if (!$user->rights->societe->client->voir && !$socid)
198 198
 				{
199 199
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200 200
 				}
201
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
-				if (! empty($conf->banque->enabled))
203
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
-				$sql.= " AND f.entity = ".$conf->entity;
205
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206
-				if (! $user->rights->societe->client->voir && ! $socid)
201
+				$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
+				if (!empty($conf->banque->enabled))
203
+					$sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204
+				$sql .= " AND f.entity = ".$conf->entity;
205
+				$sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
206
+				if (!$user->rights->societe->client->voir && !$socid)
207 207
 				{
208
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
208
+					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
209 209
 				}
210
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
210
+				if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;
211
+				$sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212 212
 				break;
213 213
 			case "fourn":
214 214
 				$sql = "SELECT p.datep as dp, f.ref as ref";
215 215
 				//$sql .= ", c.libelle as paiement_type, p.num_paiement";
216
-				$sql.= ", c.code as paiement_code, p.num_paiement";
217
-				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
-				$sql.= ", pf.amount as pf_amount";
219
-				if (! empty($conf->banque->enabled))
220
-					$sql.= ", ba.ref as bankaccount";
221
-				$sql.= ", p.rowid as prowid";
222
-				$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
-				$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
-				$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
-				if (! empty($conf->banque->enabled))
226
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
-				$sql.= " ".MAIN_DB_PREFIX."societe as s";
228
-				if (! $user->rights->societe->client->voir && ! $socid)
216
+				$sql .= ", c.code as paiement_code, p.num_paiement";
217
+				$sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218
+				$sql .= ", pf.amount as pf_amount";
219
+				if (!empty($conf->banque->enabled))
220
+					$sql .= ", ba.ref as bankaccount";
221
+				$sql .= ", p.rowid as prowid";
222
+				$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223
+				$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224
+				$sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
+				if (!empty($conf->banque->enabled))
226
+					$sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
227
+				$sql .= " ".MAIN_DB_PREFIX."societe as s";
228
+				if (!$user->rights->societe->client->voir && !$socid)
229 229
 				{
230 230
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231 231
 				}
232
-				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
-				if (! empty($conf->banque->enabled))
234
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
-				$sql.= " AND f.entity = ".$conf->entity;
236
-				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237
-				if (! $user->rights->societe->client->voir && ! $socid)
232
+				$sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
+				if (!empty($conf->banque->enabled))
234
+					$sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
235
+				$sql .= " AND f.entity = ".$conf->entity;
236
+				$sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
237
+				if (!$user->rights->societe->client->voir && !$socid)
238 238
 				{
239
-					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
239
+					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
240 240
 				}
241
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
-				$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
241
+				if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;
242
+				$sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243 243
 				break;
244 244
 		}
245 245
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 				$objp = $this->db->fetch_object($result);
256 256
 
257 257
 				$lines[$i][0] = $objp->ref;
258
-				$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp),"day",false,$outputlangs,true);
258
+				$lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
259 259
 				$lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
260 260
 				$lines[$i][3] = $objp->num_paiement;
261 261
 				$lines[$i][4] = price($objp->paiement_amount);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 
275 275
 		$pages = intval(($num + $numpaiement) / $this->line_per_page);
276 276
 
277
-		if ((($num + $numpaiement) % $this->line_per_page)>0)
277
+		if ((($num + $numpaiement) % $this->line_per_page) > 0)
278 278
 		{
279 279
 			$pages++;
280 280
 		}
@@ -286,48 +286,48 @@  discard block
 block discarded – undo
286 286
 		}
287 287
 
288 288
 		$pdf->Open();
289
-		$pagenb=0;
290
-		$pdf->SetDrawColor(128,128,128);
289
+		$pagenb = 0;
290
+		$pdf->SetDrawColor(128, 128, 128);
291 291
 
292 292
 		$pdf->SetTitle($outputlangs->transnoentities("Payments"));
293 293
 		$pdf->SetSubject($outputlangs->transnoentities("Payments"));
294 294
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
295 295
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296 296
 		//$pdf->SetKeyWords();
297
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
297
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
298 298
 
299
-		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300
-		$pdf->SetAutoPageBreak(1,0);
299
+		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
300
+		$pdf->SetAutoPageBreak(1, 0);
301 301
 
302 302
 		// New page
303 303
 		$pdf->AddPage();
304 304
 		$pagenb++;
305 305
 		$this->_pagehead($pdf, $pagenb, 1, $outputlangs);
306
-		$pdf->SetFont('','', 9);
307
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
308
-		$pdf->SetTextColor(0,0,0);
306
+		$pdf->SetFont('', '', 9);
307
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
308
+		$pdf->SetTextColor(0, 0, 0);
309 309
 
310 310
 
311 311
 		$this->Body($pdf, 1, $lines, $outputlangs);
312 312
 
313
-		if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
313
+		if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
314 314
 
315 315
 		$pdf->Close();
316 316
 
317
-		$pdf->Output($file,'F');
317
+		$pdf->Output($file, 'F');
318 318
 
319 319
 		// Add pdfgeneration hook
320
-		if (! is_object($hookmanager))
320
+		if (!is_object($hookmanager))
321 321
 		{
322 322
 			include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
323
-			$hookmanager=new HookManager($this->db);
323
+			$hookmanager = new HookManager($this->db);
324 324
 		}
325 325
 		$hookmanager->initHooks(array('pdfgeneration'));
326
-		$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
326
+		$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
327 327
 		global $action;
328
-		$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
328
+		$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
329 329
 
330
-		if (! empty($conf->global->MAIN_UMASK))
330
+		if (!empty($conf->global->MAIN_UMASK))
331 331
 			@chmod($file, octdec($conf->global->MAIN_UMASK));
332 332
 
333 333
 		$this->result = array('fullpath'=>$file);
@@ -353,52 +353,52 @@  discard block
 block discarded – undo
353 353
 
354 354
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
355 355
 
356
-		$title=$conf->global->MAIN_INFO_SOCIETE_NOM;
357
-		switch($this->doc_type) {
356
+		$title = $conf->global->MAIN_INFO_SOCIETE_NOM;
357
+		switch ($this->doc_type) {
358 358
             case "client":
359
-                $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
359
+                $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
360 360
                 break;
361 361
             case "fourn":
362
-                $title.=' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
362
+                $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
363 363
                 break;
364 364
         }
365
-		$title.=' - '.dol_print_date(dol_mktime(0,0,0,$this->month,1,$this->year),"%B %Y",false,$outputlangs,true);
366
-		$pdf->SetFont('','B',$default_font_size + 1);
367
-		$pdf->SetXY($this->marge_gauche,10);
365
+		$title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);
366
+		$pdf->SetFont('', 'B', $default_font_size + 1);
367
+		$pdf->SetXY($this->marge_gauche, 10);
368 368
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
369 369
 
370
-		$pdf->SetFont('','',$default_font_size);
370
+		$pdf->SetFont('', '', $default_font_size);
371 371
 
372 372
         $pdf->SetXY($this->posxdate, 16);
373
-		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(),"day",false,$outputlangs,true), 0, 'L');
373
+		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');
374 374
 
375
-        $pdf->SetXY($this->posxdate+100, 16);
375
+        $pdf->SetXY($this->posxdate + 100, 16);
376 376
 		$pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
377 377
 
378 378
 
379 379
 		// Title line
380
-        $pdf->SetXY($this->posxdate, $this->tab_top+2);
380
+        $pdf->SetXY($this->posxdate, $this->tab_top + 2);
381 381
 		$pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
382 382
 
383 383
 		$pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
384
-        $pdf->SetXY($this->posxpaymenttype, $this->tab_top+2);
384
+        $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);
385 385
 		$pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
386 386
 
387 387
 		$pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
388
-        $pdf->SetXY($this->posxinvoice, $this->tab_top+2);
388
+        $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);
389 389
 		$pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
390 390
 
391 391
 		$pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
392
-        $pdf->SetXY($this->posxbankaccount, $this->tab_top+2);
392
+        $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);
393 393
 		$pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
394 394
 
395 395
 
396 396
 		$pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
397
-        $pdf->SetXY($this->posxinvoiceamount, $this->tab_top+2);
397
+        $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);
398 398
 		$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
399 399
 
400 400
 		$pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
401
-        $pdf->SetXY($this->posxpaymentamount, $this->tab_top+2);
401
+        $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);
402 402
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
403 403
 
404 404
 		$pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
@@ -423,34 +423,34 @@  discard block
 block discarded – undo
423 423
 		global $langs;
424 424
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
425 425
 
426
-		$pdf->SetFont('','', $default_font_size - 1);
426
+		$pdf->SetFont('', '', $default_font_size - 1);
427 427
 		$oldprowid = 0;
428 428
 		$total_page = 0;
429 429
 		$total = 0;
430
-		$pdf->SetFillColor(220,220,220);
430
+		$pdf->SetFillColor(220, 220, 220);
431 431
 		$yp = 0;
432
-		$numlines=count($lines);
433
-		for ($j = 0 ; $j < $numlines ; $j++)
432
+		$numlines = count($lines);
433
+		for ($j = 0; $j < $numlines; $j++)
434 434
 		{
435 435
 			$i = $j;
436
-			if ($yp > $this->tab_height -5)
436
+			if ($yp > $this->tab_height - 5)
437 437
 			{
438 438
 				$page++;
439 439
 				$pdf->AddPage();
440 440
 				$this->_pagehead($pdf, $page, 0, $outputlangs);
441
-				$pdf->SetFont('','', $default_font_size - 1);
441
+				$pdf->SetFont('', '', $default_font_size - 1);
442 442
 				$yp = 0;
443 443
 			}
444 444
 			if ($oldprowid <> $lines[$j][7])
445 445
 			{
446
-				if ($yp > $this->tab_height -15)
446
+				if ($yp > $this->tab_height - 15)
447 447
 				{
448 448
 					$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
449
-					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height,  $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
449
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $langs->transnoentities('SubTotal')." : ".price($total_page), 0, 'R', 0);
450 450
 					$page++;
451 451
 					$pdf->AddPage();
452 452
 					$this->_pagehead($pdf, $page, 0, $outputlangs);
453
-					$pdf->SetFont('','', $default_font_size - 1);
453
+					$pdf->SetFont('', '', $default_font_size - 1);
454 454
 					$yp = 0;
455 455
 					$total += $total_page;
456 456
 					$total_page = 0;
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 				$pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
464 464
 
465 465
 				$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
466
-				$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
466
+				$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
467 467
 
468 468
 				$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
469 469
 				$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 
482 482
 			// Invoice amount
483 483
 			$pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
484
-			$pdf->MultiCell($this->posxpaymentamount- $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
484
+			$pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
485 485
 
486 486
 			// Payment amount
487 487
 			$pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
Please login to merge, or discard this patch.
Braces   +46 added lines, -24 removed lines patch added patch discarded remove patch
@@ -70,9 +70,11 @@  discard block
 block discarded – undo
70 70
 		$this->posxbankaccount=110;
71 71
 		$this->posxinvoiceamount=132;
72 72
 		$this->posxpaymentamount=162;
73
-		if ($this->page_largeur < 210) // To work with US executive format
73
+		if ($this->page_largeur < 210) {
74
+		    // To work with US executive format
74 75
 		{
75 76
 			$this->line_per_page = 35;
77
+		}
76 78
 			$this->posxpaymenttype-=10;
77 79
 			$this->posxinvoice-=0;
78 80
 			$this->posxinvoiceamount-=10;
@@ -101,11 +103,17 @@  discard block
 block discarded – undo
101 103
 		global $conf, $hookmanager, $langs, $user;
102 104
 
103 105
 		$socid=0;
104
-		if ($user->societe_id) $socid=$user->societe_id;
106
+		if ($user->societe_id) {
107
+		    $socid=$user->societe_id;
108
+		}
105 109
 
106
-		if (! is_object($outputlangs)) $outputlangs=$langs;
110
+		if (! is_object($outputlangs)) {
111
+		    $outputlangs=$langs;
112
+		}
107 113
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
108
-		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
114
+		if (! empty($conf->global->MAIN_USE_FPDF)) {
115
+		    $outputlangs->charset_output='ISO-8859-1';
116
+		}
109 117
 
110 118
 		$this->month=$month;
111 119
 		$this->year=$year;
@@ -185,29 +193,34 @@  discard block
 block discarded – undo
185 193
 				$sql.= ", c.code as paiement_code, p.num_paiement";
186 194
 				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
187 195
 				$sql.= ", pf.amount as pf_amount";
188
-				if (! empty($conf->banque->enabled))
189
-					$sql.= ", ba.ref as bankaccount";
196
+				if (! empty($conf->banque->enabled)) {
197
+									$sql.= ", ba.ref as bankaccount";
198
+				}
190 199
 				$sql.= ", p.rowid as prowid";
191 200
 				$sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192 201
 				$sql.= ", ".MAIN_DB_PREFIX."facture as f,";
193 202
 				$sql.= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194
-				if (! empty($conf->banque->enabled))
195
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
203
+				if (! empty($conf->banque->enabled)) {
204
+									$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
205
+				}
196 206
 				$sql.= " ".MAIN_DB_PREFIX."societe as s";
197 207
 				if (! $user->rights->societe->client->voir && ! $socid)
198 208
 				{
199 209
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200 210
 				}
201 211
 				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202
-				if (! empty($conf->banque->enabled))
203
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
212
+				if (! empty($conf->banque->enabled)) {
213
+									$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
214
+				}
204 215
 				$sql.= " AND f.entity = ".$conf->entity;
205 216
 				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
206 217
 				if (! $user->rights->societe->client->voir && ! $socid)
207 218
 				{
208 219
 					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
209 220
 				}
210
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
221
+				if (! empty($socid)) {
222
+				    $sql .= " AND s.rowid = ".$socid;
223
+				}
211 224
 				$sql.= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
212 225
 				break;
213 226
 			case "fourn":
@@ -216,29 +229,34 @@  discard block
 block discarded – undo
216 229
 				$sql.= ", c.code as paiement_code, p.num_paiement";
217 230
 				$sql.= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218 231
 				$sql.= ", pf.amount as pf_amount";
219
-				if (! empty($conf->banque->enabled))
220
-					$sql.= ", ba.ref as bankaccount";
232
+				if (! empty($conf->banque->enabled)) {
233
+									$sql.= ", ba.ref as bankaccount";
234
+				}
221 235
 				$sql.= ", p.rowid as prowid";
222 236
 				$sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
223 237
 				$sql.= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
224 238
 				$sql.= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
225
-				if (! empty($conf->banque->enabled))
226
-					$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
239
+				if (! empty($conf->banque->enabled)) {
240
+									$sql.= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
241
+				}
227 242
 				$sql.= " ".MAIN_DB_PREFIX."societe as s";
228 243
 				if (! $user->rights->societe->client->voir && ! $socid)
229 244
 				{
230 245
 					$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
231 246
 				}
232 247
 				$sql.= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
233
-				if (! empty($conf->banque->enabled))
234
-					$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
248
+				if (! empty($conf->banque->enabled)) {
249
+									$sql.= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
250
+				}
235 251
 				$sql.= " AND f.entity = ".$conf->entity;
236 252
 				$sql.= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year,$month))."' AND '".$this->db->idate(dol_get_last_day($year,$month))."'";
237 253
 				if (! $user->rights->societe->client->voir && ! $socid)
238 254
 				{
239 255
 					$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
240 256
 				}
241
-				if (! empty($socid)) $sql .= " AND s.rowid = ".$socid;
257
+				if (! empty($socid)) {
258
+				    $sql .= " AND s.rowid = ".$socid;
259
+				}
242 260
 				$sql.= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
243 261
 				break;
244 262
 		}
@@ -266,8 +284,7 @@  discard block
 block discarded – undo
266 284
 				$lines[$i][9] = $objp->paiement_amount;
267 285
 				$i++;
268 286
 			}
269
-		}
270
-		else
287
+		} else
271 288
 		{
272 289
 			dol_print_error($this->db);
273 290
 		}
@@ -294,7 +311,9 @@  discard block
 block discarded – undo
294 311
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
295 312
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296 313
 		//$pdf->SetKeyWords();
297
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
314
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
315
+		    $pdf->SetCompression(false);
316
+		}
298 317
 
299 318
 		$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);   // Left, Top, Right
300 319
 		$pdf->SetAutoPageBreak(1,0);
@@ -310,7 +329,9 @@  discard block
 block discarded – undo
310 329
 
311 330
 		$this->Body($pdf, 1, $lines, $outputlangs);
312 331
 
313
-		if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
332
+		if (method_exists($pdf,'AliasNbPages')) {
333
+		    $pdf->AliasNbPages();
334
+		}
314 335
 
315 336
 		$pdf->Close();
316 337
 
@@ -327,8 +348,9 @@  discard block
 block discarded – undo
327 348
 		global $action;
328 349
 		$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
329 350
 
330
-		if (! empty($conf->global->MAIN_UMASK))
331
-			@chmod($file, octdec($conf->global->MAIN_UMASK));
351
+		if (! empty($conf->global->MAIN_UMASK)) {
352
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
353
+		}
332 354
 
333 355
 		$this->result = array('fullpath'=>$file);
334 356
 
Please login to merge, or discard this patch.
dolibarr/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
  */
31 31
 class pdf_paiement_fourn extends pdf_paiement
32 32
 {
33
-	/**
33
+    /**
34 34
      *  Constructor
35 35
      *
36 36
      *  @param      DoliDb		$db      Database handler
37
-	 */
38
-	function __construct($db)
39
-	{
40
-		parent::__construct($db);
41
-		$this->doc_type = "fourn";
42
-	}
37
+     */
38
+    function __construct($db)
39
+    {
40
+        parent::__construct($db);
41
+        $this->doc_type = "fourn";
42
+    }
43 43
 }
Please login to merge, or discard this patch.